views:

449

answers:

4

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

A: 

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!

this is also a great avenue.. food for thought.i need to work my way to this possibility ill give it a go thanks workinprogress
+4  A: 

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.

Adam Rosenfield
this is interesting stuff.. im on to it. cheers adam
+3  A: 

The DefaultOutputUnit sample code

/Developer/Examples/CoreAudio/SimpleSDK/DefaultOutputUnit

shows how to play a sine wave, and it would be relatively trivial to adapt it to play two different sine waves on the left and right speakers.

Peter N Lewis
bang on it.. much appreciation peter. thanks
A: 

may be a possibility would be to use an audio file and change the play back speed to alter its pitch any idea how to accomplish this.