Ubuntu / Getting volume of Mic input

Nov 2, 2010 at 7:32pm
closed account (Lv0f92yv)
This might be a little outlandish... but I am trying to communicate with the mic in C++ on a ubuntu system. The goal is to 'query' the mic to determine the volume of noise coming in, if this volume is above a certain level, do something, etc.

Is this possible? Would I need to deal with device drivers somewhere in here? Or are there Ubuntu/Linux specific system calls which can make this relatively simple?

Thanks for any input.

Edit: I have googled around and come up only with windows stuff.
Last edited on Nov 2, 2010 at 7:41pm
Nov 2, 2010 at 7:40pm
I'd go and have a look at something like SDL (Simple Directmedia Layer).
There may be other lib that do sound only, SDL does everything from sound to graphics to keyboard/controller input and works on many platforms.

You can program something like this without a lib but then you need knowledge of how applications access the sound driver and enough experience to write a kernel driver.
Nov 2, 2010 at 10:16pm
closed account (Lv0f92yv)
SDL it is. Sounds good. Thanks.
Nov 2, 2010 at 11:30pm
closed account (Lv0f92yv)
I have installed SDL and looked through some tutorials, but it doesn't appear to support any audio input, only audio output.

Maybe I can 'cheat' and record the sound from my mic to a file (I can do this now), then open the file (wav file) with SDL and do some processing...
Nov 3, 2010 at 8:02am
Yes sorry I'v only done this ones a long time ago.
I used PortAudio for it, it works good with SDL if you'd like to do some graphics or other stuff too.

I forgot I installed a other lib for that, sorry.
Topic archived. No new replies allowed.