How to do audio stream processing in Linux(RPi) via C? - linux

Hej
I would like to build an audio effect into a RPi. This effect should be programmed in C. I am not familiar with the software audio interfaces in Linux. The ALSA interface looks very complicated. Port Audio seems to be an alternative.
Any ideas(maybe with a tutorial)?

With some work you can also get OpenAL to stream and render audio using c language - then you could perform your processing in that context ...
Node.js is available on RPi which offers audio modules

PortAudio seems the best approach. A good tutorial can be found here:
http://portaudio.com/docs/v19-doxydocs/tutorial_start.html
Sometimes the Interface configuration needs to be done manually.

Related

Alternative to ALSA dmix

In an embedded Linux project I have exactly two processes that need to access the audio device. So far I'm using ALSA dmix for that. However, dmix is giving me a lot of trouble (as explained in this question).
Now I'm wondering - are there any simple alternatives to dmix? I can imagine that PulseAudio is doing a much better job, but I'm not sure if its not an overkill to bring a general-usage sound server into a small embedded project, just for mixing two audio streams.

how to add webrtc aec in pjsip,running on Embedded Linux

i dont konw how build webrtc aec in pjsip,I don't want to download all the code for webrtc, just the aec section,embed cpu is imx6ul,Please give me some guidance, thank you very much
They are both written in C so migration of the WebRTC module and make it compiable should be easy.
You should take advantage of pjsip's Audio Manipulation Algorithms module. It allows you to apply algos on the processing audio sample frames.
https://www.pjsip.org/pjmedia/docs/html/group__PJMEDIA__FRAME__OP.htm
For the AEC, make sure you have access to the loopback channel on the codec. (Samples from playing speaker).
Steps:
Create a New Audio Manipulation Algorithms Module
Gain access to audio playback/capture signals with pjmedia
Migrate WebRTC AEC Module
Reroute the signal processing pipeline and enabling the AEC Algorithms module

Capture audio stream from Xtion pro with OpenNI2?

Dose any one try to captured the audio stream using OpenNI2 library from Xtion pro??
I searched the Internet and found the audio API in OpenNI2 source code. Audio API
It seems that it only can "Play" the audio but capture audio stream.
And it doesn't demonstrate how to use those API.
Is there any example code which recorded the audio stream using OpenNI2 from Xtion pro?
BTW, my OpenNI version is 2.2.0.33.
Thanks anyone's help : )
After I surveyed so much information, I found that OpenNI2 didn't support the audio stream anymore. Hence, someone suggest me to use another library to capture audio stream from Xtion Pro.
Now, I'm using the PortAudio to deal with the audio stream. It's quit powerful tool and easy to use.
Moreover, it's cross-platform library which support Windows, Mac OS, and Unix using C/C++, and the Documentation is clear and the example code is understandable.
So, if some newbies like me want to use Xtion Pro to capture audio stream, I will recommend this library.
Any other suggestions are very welcome : )

manipulating audio input buffer on Ubuntu Linux

Suppose that I want to code an audio filter in C++ that is applied on every audio or to a specific microphone/source, where should I start with this on ubuntu ?
edit, to be clear I don't get how to do this and what is the role of Pulseaudio, ALSA and Gstreamer.
Alsa provides an API for accessing and controlling audio and MIDI hardware. One portion of ALSA is a series of kernel-mode device drivers, whilst the other is a user-space library that applications link against. Alsa is single-client.
PulseAudio is framework that facilitates multiple client applications accessing a single audio interface (alsa is single-client). It provides a daemon process which 'owns' the audio interface and provides a IPC transport for audio between the daemon and applications using it. This is used heavily in open source desktop environments. Use of Pulse is largely transparent to applications - they continue to access the audio input and output using the alsa API with audio transport and mixing. There is also Jack which is targeted more towards 'professional' audio applications - perhaps a bit of a misnomer, although what is meant here is low latency music production tools.
gStreamer is a general purpose multi-media framework based on the signal-graph pattern, in which components have a number of inputs and output pins and provide a transformation function. A Graph of these components is build to implement operations such as media decoding, with special nodes for audio and video input or output. It is similar in concept to CoreAudio and DirectShow. VLC and libAV are both open source alternatives that operate along similar lines. Your choice between these is a matter of API style, and implementation language. gStreamer, in particular, is an OO API implemented in C. VLC is C++.
The obvious way of implementing the problem you describe is to implement a gStreamer/libAV/VLC component. If you want to process the audio and then route it to another application, this can be achieved by looping it back through Pulse or Jack.
Alsa provides a plug-in mechanism, but I suspect that implementing this from the ALSA documentation will be tough going.
The de-facto architecture for building effects plug-ins of the type you describe is Steinberg's VST. There are plenty of open source hosts and examples of plug-ins that can be used on Linux, and crucially, there is decent documentation. As with a gStreamer/libAV/VLC, you be able to route audio in an out of this.
Out of these, VST is probably the easiest to pick up.

Best cross-platform audio library for synchronizing audio playback

I'm writing a cross-platform program that involves scrolling a waveform along with uncompressed wav/aiff audio playback. Low latency and accuracy are pretty important. What is the best cross-platform audio library for audio playback when synchronizing to an external clock? By that I mean that I would like to be able to write the playback code so it sends events to a listener many times per second that includes the "hearing frame" at the moment of the notification.
That's all I need to do. No recording, no mixing, no 3d audio, nothing. Just playback with the best possible hearing frame notifications available.
Right now I am considering RTAudio and PortAudio, mostly the former since it uses ALSA.
The target platforms, in order of importance, are Mac OSX 10.5/6, Ubuntu 10.11, Windows XP/7.
C/C++ are both fine.
Thanks for your help!
The best performing cross platform library for this is jack. Properly configured, jack on Linux can outperform Windows asio easily (in terms of low latency processing without dropouts). But you cannot expect normal users to use jack (the demon should be started by the user before the app is started, and it can be a bit tricky to set up). If you are making an app specifically for pro-audio I would highly recommend looking in to jack.
Edit:
Portaudio is not as high-performance, but is much simpler for the user (no special configuration should be needed on their end, unlike jack). Most open source cross platform audio programs that I have used use portaudio (much moreso than openal), but unlike jack I have not used it personally. It is callback based, and looks pretty straightforward though.
OpenAL maybe an option for you.

Resources