i wish to generate two opposing tone one in the right stereo channel and one in the left stereo channel both at different frequencies i wish to accomplish this in c or objective c
program simple tone generator that plays two tones one in each of the two stereo
4.2k views Asked by AudioBubble At
3
There are 3 answers
0

You can easily generate the tone with a sine wave: the nth sample is given by A*sin(2*pi*n*f/R)
, where A is the amplitude (volume), f
is the frequency in Hertz, and R
is the sample rate in samples per second. For stereo sound, you generate two independent waves with different parameters.
The hard part is actually playing the sound. You'll have to use some sort of platform-specific audio library, or a third-party library that abstracts away the platform-specific details. Alternatively, you could just write out the sound data to a WAV file, which is not terribly difficult, since WAV files are just raw, uncompressed PCM data with a RIFF header.
You could use the beep function to generate tones but I am not sure how you would have one tone come from one channel and the other from another. The only thing I could think of is using two different threads each one calling the beep function but both tones would come out of both channels. Good Luck!