Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-05

How to play audio from memory.

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Donald Ziesig

Hi All!

Is there any Free Pascal code that can play audio directly from memory?

I would like to be able to play the equivalent of a .WAV file through the stereo output jack of a Raspberry Pi.

Currently I am able to do this by calling omxplayer with a file name and volume information. Unfortunately, the latency between starting omxplayer and the beginning of the audio output is several seconds which is unacceptable for my application. I can't determine whether the latency comes from loading omxplayer's executable or reading the audio file, or both, but if I could have the code as part of the fpc executable and the audio data already in memory, I believe the latency will be as low as possible.

Any suggestions will be appreciated.

Don Ziesig

Reply by email

Graeme Geldenhuys
to Donald Ziesig
Donald Ziesig wrote
Currently I am able to do this by calling omxplayer with a file name and volume information. Unfortunately, the latency between starting omxplayer and the beginning of the audio output is several seconds

Yes, it?s possible with the United OpenLib of Sound (UOS). Fred has created an excellent library and it works very well. I?ve personally tested it on multiple platforms, and so too have others. The latency is very low when used with LCL, and even lower when used with fpGUI.

You can find the code here:
https://github.com/fredvs/uos/

It includes a couple of example applications too.

There has been quite a few discussions of UOS with Fred in the Lazarus Forums too.

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Donald Ziesig
to Graeme Geldenhuys
Graeme Geldenhuys wrote 20 lines
On 2016-05-11 21:53, Donald Ziesig wrote: > Currently I am able to do this by calling omxplayer with a file name and > volume information. Unfortunately, the latency between starting > omxplayer and the beginning of the audio output is several seconds Yes, it?s possible with the United OpenLib of Sound (UOS). Fred has created an excellent library and it works very well. I?ve personally tested it on multiple platforms, and so too have others. The latency is very low when used with LCL, and even lower when used with fpGUI. You can find the code here: https://github.com/fredvs/uos/ It includes a couple of example applications too. There has been quite a few discussions of UOS with Fred in the Lazarus Forums too. Regards, Graeme

Thanks Graeme! It works great on my laptop. Now I need to port it to the Raspberry Pi.

Unfortunately, the version I have on the Pi doesn't have the units for openssl and fpopenssl.

Since I will not need the ssl functionality, I am trying to track down the code tree that references those units. Do you know if Lazarus has a way to show the units used when a compilation fails?

Thanks again.

Don Ziesig

Reply by email

Graeme Geldenhuys
to Donald Ziesig
Donald Ziesig wrote
Unfortunately, the version I have on the Pi doesn't have the units for openssl and fpopenssl.

I doubt it is UOS that needs those dependencies. They have nothing to do with Sound, but rather Encryption and Security. It is most likely something in your project pulling in those dependencies.

the code tree that references those units. Do you know if Lazarus has a way to show the units used when a compilation fails?

Do a Build All instead of a standard Compile. Then right click in the IDE's Messages window and select "Copy -> Copy All Messages". Paste the clipboard to some text editor and review all the units compiled.

It would be nice if Lazarus IDE has an option to show unfiltered output in the Messages window, but I haven't figured out if this is possible or now. Older versions of Lazarus use do do that.

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Mattias Gaertner
to Graeme Geldenhuys
[...] > the code tree that references those units. Do you know if Lazarus has a > way to show the units used when a compilation fails?

You might want to increase the compiler verbosity. Project / Project Options / Compiler Options / Verbosity

Show quoted text 7 lines
Do a Build All instead of a standard Compile.Then right click in the IDE's Messages window and select "Copy -> Copy All Messages". Paste the clipboard to some text editor and review all the units compiled. It would be nice if Lazarus IDE has an option to show unfiltered output in the Messages window, but I haven't figured out if this is possible or now. Older versions of Lazarus use do do that.

Right Click / Filter*

Mattias

Reply by email