Outputting sounds (from frequency)

Jan 30, 2009 at 3:23am
What I need to do is to output sounds from the default sound playback device. I'm guessing I have to use DirectSound or something.

What I basicly want to do is give it a Frequency and a duration, and it will output a sound of that frequency for that duration. Somehow like the Beep function, but that only works with the motherboard speaker (newer computers don't have any?) or is there a way to change the output of that?

Some people told me that I could maybe generate WAV, but that works with amplitude so I would have to use Fourier transform (FFTW?) or something. It all sounds to advanced for me.

Also, after that, I would need another program (the receiver) that would listen for these inputs and when it hears any sound, it writes down the frequency of it.

Thanks in advance,
~Ph0X
Jan 30, 2009 at 5:55am
Yes, WAV stores volume levels, but you can generate a wave with
v(t)=sin(t*pi*f)*a
t being time in seconds, f being frequency, and a being amplitude (a value higher than 1.0 will generate clipping).
Jan 30, 2009 at 7:36am
Thanks, but now, how do I generate WAVE in c++?
Jan 30, 2009 at 12:20pm
I was assuming you knew how to, judging by the fact that you didn't mention it as a problem.
You can use the technique I described above to generate the signal to send to sound output.
Jan 30, 2009 at 5:04pm
No, you don't need DS.
Just win32 MM api
The code (in C) had been posted on api ng news://comp.os.ms-windows.programmer.win32
like for all Win32 apis..
Jan 30, 2009 at 9:31pm
Well there's a reason why I posted in BEGGINERS and not in C++, my knowledge of C++ is VERY limited, and when it comes to generating sound, its close to 0.

Could I please have a short sample in C++ or some keywords to search on google about? I searched for hours and didn't find anything else than Beep().
Feb 3, 2009 at 2:57am
Bump?
I still need a way to stream sounds through my default soundcard
Feb 25, 2009 at 1:35am
Sorry but bump again.
I really need to get this done.
Can't find how to output sound.
Topic archived. No new replies allowed.