How to output a sound wave to only left or right channel?

Jan 5, 2011 at 5:45 PM

Hello. I just tried to use following method to generate sound wave in different frequencies.

class SineWaveOscillator : WaveProvider16
    {
        double phaseAngle;

        public SineWaveOscillator(int sampleRate) :
            base(sampleRate, 1)
        {
        }

        public double Frequency { set; get; }
        public short Amplitude { set; get; }

        public override int Read(short[] buffer, int offset,
          int sampleCount)
        {

            for (int index = 0; index < sampleCount; index++)
            {
                buffer[offset + index] =
                  (short)(Amplitude * Math.Sin(phaseAngle));
                phaseAngle +=
                  2 * Math.PI * Frequency / WaveFormat.SampleRate;

                if (phaseAngle > 2 * Math.PI)
                    phaseAngle -= 2 * Math.PI;
            }
            return sampleCount;
        }
    }

public void soundPlay()
{
WaveOut w = new WaveOut();
SineWaveOscillator s = new SineWaveOscillator(44100);
s.frequency=1000;
s.amplitude=8192;
w.Init(s);
w.Play();
}


It seems OK but I still have a problem. How can I output this wave to only one channel, left channel or right channel?

Thank you a lot.