views:

531

answers:

1

Does anyone know how to access ALSA (low-level audio API) in Linux using Mono?

NOTE: I'm hoping to access ALSA using PInvoke.

+2  A: 

I believe there are not any bindings for Mono. You could look at the Python ALSA bindings and the Mono D-BUS bindings and try to build your own.

However, it would probably be better and easier for you to just use GStreamer. The Mono GStreamer bindings are mature and work well.

John Millikin
Are "bindings" in mono like using PInvoke in .NET? I need to use just a very small subset of ALSA functionality. Could GStreamer be used to build a leapfrog buffer playback system?
MusiGenesis
Don't know -- I can't even find any info on what a "leapfrog buffer" is. Bindings are a term used for making a library written in one language available to another language. If you only need a small part of the API, you could try P/Invoke. http://www.mono-project.com/Interop_with_Native_Libraries
John Millikin
Thanks for the interop link. That's what I'm looking to do, but I don't know how to do it specifically with ALSA.
MusiGenesis
Leapfrog uses two alternating buffers to play a WAV file. They're loaded with the first and second chunks from the file and then queued into the play buffer. When the first is done the second starts playing; the first is reloaded with the 3rd chunk and queued up and so on.
MusiGenesis
The leapfrog technique lets you play a big file without having to load the entire thing into memory at once.
MusiGenesis
That sounds like a fairly common, if low-level, playback technique. GStreamer supports that easily -- it's used in the Banshee media player. You can use the code there for an example of how to use GStreamer in C#.
John Millikin
Also, there's no particular method for invoking ALSA functions -- you'll need to look at the ALSA documentation, decide which functions you want to call, and add them to a C# using the code in the link I posted.
John Millikin
I'm going to look at GStreamer - thanks for the links and code.
MusiGenesis