You are not logged in.

#1 2010-06-14 18:58:00

x5x_tim
Member
Registered: 2010-06-13
Posts: 86

Microphone levels

Hi,

I want to display the current sound level by the default mic input.
I don't really care what language it is. Just some pointers would be great.

Thanks,

x5x_tim

Offline

#2 2010-06-14 20:36:31

igor_b
Member
Registered: 2010-03-05
Posts: 14

Re: Microphone levels

x5x_tim wrote:

Hi,

I want to display the current sound level by the default mic input.
I don't really care what language it is. Just some pointers would be great.

Thanks,

x5x_tim

i suggest that you go with rtaudio (http://www.music.mcgill.ca/~gary/rtaudio/) because it's one of the simplest. there are examples on web site how to get sound from input (it's in c/c++). you'll get a block of audio data in a float array and you can do whatever you want with it.

sound level can be measured for example with average power - you sum all the squared elements of an array with soud data, divide it with block size, and that's it. this way, if your block size is too small (256 samples or less) average power will be changing quickly - you can average that value during the few last blocks to get more smooth value to display.

when you have that working, go with the gui. you can choose any toolkit you want. qt is very nice because it is very powerful, easy to grasp, and has a great ide (qtcreator). one simple window with progress bar should be enough. if you want something more fancy, you can make your own widget or do some css styling on standard widget, but you can take a look at that by yourself if you want.

Last edited by igor_b (2010-06-14 20:38:13)

Offline

#3 2010-06-15 18:59:52

x5x_tim
Member
Registered: 2010-06-13
Posts: 86

Re: Microphone levels

Thanks, I played with the examples a while.
I couldn't get record to actually record any sound though, while Audacity can.
Anyway, thanks for the suggestion, the recording problem seems to be on my side, as I get the same with arecord.

Offline

#4 2010-06-16 10:10:46

igor_b
Member
Registered: 2010-03-05
Posts: 14

Re: Microphone levels

x5x_tim wrote:

Thanks, I played with the examples a while.
I couldn't get record to actually record any sound though, while Audacity can.
Anyway, thanks for the suggestion, the recording problem seems to be on my side, as I get the same with arecord.

check alsamixer, capture tab. maybe microphone is not selected for capture..

audacity uses portaudio for audio i/o. portaudio is another pretty cool cross platform audio system. i've never actually used it, but you cantry  smile. it shouldn't be much different from rtaudio.

Last edited by igor_b (2010-06-16 10:11:04)

Offline

Board footer

Powered by FluxBB