|
-
January 5th, 2010, 01:10 PM
#1
Detecting peaks in realtime from a microphone
Hi to all.
I start by apologizing for my newbyosity in this field of c++, that is audio tracks. I understand, however, the principles behind sampling and sound recording issues in a computer.
I put in open terms. I am developing a software that needs to be able to detect when the microphone input sound reaches a certain level.
I see the API native functions for the waveforms, like waveIn..., waveOut... and so on, but I don't know what to choice to get sound in input in realtime.
The problem is not so difficult, if I could access the values of incoming samples, even one each X samples, and compare it with a percentage of the maximum value allowing by input device dynamics. The fact is, I don't know how to do, and if it is possible with the waveform functions I named.
Sorry for the problem-specific question, I appreciate any help.
Thanks in advance. Oh, and happy 2010!!!
- Buzzyous -
-
January 5th, 2010, 02:03 PM
#2
Re: Detecting peaks in realtime from a microphone
Reading the peaks is the trivial part. Just iterate through your audio buffer and keep the highest value. The tough part is implementing a routine to sample the audio. Check out some of the classes here:
http://www.codeproject.com/KB/audio-...eo%20-%20Audio
and here:
http://www.codeguru.com/cpp/g-m/multimedia/
I've looked at many and used ideas from several to come up with an implementation right for my own purposes.
-
January 6th, 2010, 03:12 AM
#3
Re: Detecting peaks in realtime from a microphone
I viewed some of these, and found some interesting. Still reading, there are many articles. Thank you for the addressing.
But, you said the difficult part is to sample the audio; there are API functions that record the input audio to save it in a file. Could that data be read or interpreted as sampled audio in RT, block by block, instead of sending them to a file on memory? Do I really need to do the sampling on my own?
I mean, when I have a HWAVEIN received with WaveIn function, could I navigate the data related to it as an "array of samples", or something like that?
Last edited by Buzzyous; January 6th, 2010 at 03:15 AM.
- Buzzyous -
-
January 6th, 2010, 08:36 AM
#4
Re: Detecting peaks in realtime from a microphone
Windows API adds some simple wrappers for all the necessary handling of simple playback (sndPlaySound() ) but it obscures all the internal stuff from the user. I don't know of any way to get at the actual buffers. Nonetheless, recording is a different beast altogether. I don't know of any other way than to: acutally define a callback, threadproc, or message handler called each time the buffer is filled by the sound hardware; create the buffers; then continuously manage the buffers (save to file, monitor, etc.) each time the callback signals a full buffer. It's an ugly process and I understand that it is a little better using DirectX sound APIs, but I've never gone that route.
-
January 6th, 2010, 11:23 AM
#5
Re: Detecting peaks in realtime from a microphone
You've been very clear. Thank you again, I will try something out of your suggestion.
- Buzzyous -
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|