Do I need my codec to be ALSA or not? - audio

I have a project that I am working on, for the purposes of this question, lets say they are wireless speakers.
We are using the raspberry pi for development right now but we plan to move to our own embedded solution. The codec we've chosen fits our needs best, although it isn't an "ALSA supported" codec. As in the ALSA webpage doesn't have info on it.
Much of the PCM code I've found to develop this on the raspberry pi use ALSA streams. Is it a standard to use an ALSA codec for these types of projects?
I haven't worked much with embedded linux or RTOS. I work with bare-metal systems quite frequently though which explains my confusion on what ALSA exactly is. It seems like some odd middleware or something.

ALSA is
the API that application that want to use sound use; and
the library that implements this API; and
the interface between this library and the kernel; and
the kernel implementation of this interface; and
the framework to be used by sound drivers.
To have your codec supported in Linux, you must write an ALSA driver.

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.

Is sound system in linux layered system as OSI model?

I'm new with linux and especially with sound system. I've read many articles about this subject but I'm still confused. I know that Alsa provides audio functionality to the rest of the system. This mean that Alsa is lowest "layer" on sound system (after hardware itself). I also know that ALSA by itself can only handle one application at a time. So here are my questions:
1)Is PulseAudio a bridge to provide usage of Alsa for multiple apps?
2)Are Gstreamer, Phonon and Xine same bridge programs as PulseAudio?
3)Is Alsa converting analog signal into digital signal?
My questions may seem stupid. Thank you.
The OSI model isn't really a good fit to ALSA, as it really only provides layer 1.
PulseAudio is an audio server and is the single client of a ALSA device interface. It provides something analogous to Layer 7 of the OSI model to applications. It mixes the audio output streams from each client application connection down to a single stream for output. It provides an alsa-compatible interface to audio client software (e.g. GStreamer and Xine) which acts as a proxy and connects to the audio server.
Analogue to digital (and digital to analogue) conversion takes place in hardware in what is referred to, rather confusingly, as a CoDec.

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

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.

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.

Attach sameplerate or dmix ALSA plugin to OSS device

I have an application in an embedded system that has a application which is OSS based. Unfortunately, this application is at a fixed sample rate (8K), but I need it to be at 48K. Furthermore, I can't change the application.
I'm researching sample rate conversion plugins, such as dmix or libsamplerate, but I don't see how to use that with OSS.
Can somebody please point me in the right direction? Can I configure ALSA in such a way as to convert the OSS interface from 8K->48K in/out of the system?
TIA
Mike
What you want is the alsa-oss package which provides a tool you can use to run a program and redirect it's OSS sound output into ALSA where all the normal ALSA tools are available.

Resources