Connecting Tech Pros Worldwide Forums | Help | Site Map

waveInOpen - All sampling rates are supported?

Newbie
 
Join Date: Jul 2008
Posts: 6
#1: Jul 21 '08
Hi Everybody,

I'm trying to play a little with waveIn functions... My goal is to calculate if I'm listening a specified sin frequency or not.

For this reason I'm going down with the samplerate... How can I be sure of the sampling rate set on my device?
If I declare waveFormat.nSamplesPerSec = 9441000; waveInOpen return NO error.. (same if I put 500 Hz) But I'm not really sure that's working (9 MHz!!)...

For example if I want to find a 500Hz sinwave I need to sample at 2000Hz.. (4 times more the searched freq). In this way I should get the 0 / 1 / 0 / -1 sequency but I need to be sure that my audio device is sampling at that samplerate (and not only that my WAVEFORMAT structure is accepted) otherwise my calculations will be wrong.

There's any way to get this data direct from the device?

Thanks for attention.

Sergio

Savage's Avatar
Expert
 
Join Date: Feb 2007
Posts: 1,737
#2: Jul 21 '08

re: waveInOpen - All sampling rates are supported?


Try calling IsFormatSupported
Newbie
 
Join Date: Jul 2008
Posts: 6
#3: Jul 22 '08

re: waveInOpen - All sampling rates are supported?


Hi, Thanks for reply,
As I said, I already capture the result of waveInOpen (with WAVE_FORMAT_QUERY flag) and with 9 Mhz this return NO ERROR. (MMSYSERR_NOERROR)

If I change for example the deep to 32 bits this raise me an error, or if I set 10 channels is also returning a BADFORMAT error...

It seems to be only the samplingrate that doesnt work as it should!
Savage's Avatar
Expert
 
Join Date: Feb 2007
Posts: 1,737
#4: Jul 22 '08

re: waveInOpen - All sampling rates are supported?


Quote:

Originally Posted by wizche

Hi, Thanks for reply,
As I said, I already capture the result of waveInOpen (with WAVE_FORMAT_QUERY flag) and with 9 Mhz this return NO ERROR. (MMSYSERR_NOERROR)

If I change for example the deep to 32 bits this raise me an error, or if I set 10 channels is also returning a BADFORMAT error...

It seems to be only the samplingrate that doesnt work as it should!

Well,if IsFormatSupported() pass then I think it's guaranteed that format is supported.
You can try calling waveInGetDevCaps
to obtain device capabilities but i think it will only get standard values.

I don't know of any other method to check device caps,so it's on you to try it out.Never actually tried to do something like that.
Reply