This project has moved. For the latest updates, please go here.

change left or Right channel volume.

May 13, 2013 at 11:15 AM
Edited May 15, 2013 at 10:16 AM
hi mark,I want to Change left or right channel volume using naudio. and i want to select at a time 3 output sound device ex-"Speaker(realtek high definition audio", line1(virtual audio cable)","Realtek digital output".
May 15, 2013 at 2:54 PM
I'd do this with a custom ISampleProvider, which would make it easy to multiply the samples by different left and right channel volumes as they came through. Look at the source code for VolumeSampleProvider for an example of mono volume modification. It wouldn't be too hard to change it for stereo - you'd just have LeftVolume and RightVolume and you'd alternate samples in the Read method:
for (int n = 0; n < sampleCount; n+= 2)
    buffer[offset + n] *= LeftVolume;
    buffer[offset + n + 1] *= RightVolume;
May 15, 2013 at 3:33 PM
Edited May 15, 2013 at 3:41 PM
I can set master volume for overall song.
like: volumesampleprovider class:
 public class VolumeSampleProvider : ISampleProvider
    private ISampleProvider source;
    private float volume;
  public VolumeSampleProvider(ISampleProvider source)
          this.volume = 1.0f;
   public int Read(float[] buffer, int offset, int sampleCount)
        int samplesRead = source.Read(buffer, offset, sampleCount);

        for (int n = 0; n < sampleCount; n++)
                buffer[offset + n] *= volume * .8F;
       public float Volume
        get { return volume; }
        set { volume = value; }
and my i sample provider is:
public interface ISampleProvider

    WaveFormat WaveFormat { get; }
    int Read(float[] buffer, int offset, int count);
how i set left channel and write channel volume from this two class?
my audioplaybackpanel class is:
this.setVolumeDelegate = (vol) => waveChannel.Volume = vol;

I want to set left and right channel from this(audioplaybackpanel class)
May 16, 2013 at 4:00 PM
Just use the code I showed above, and add a LeftVolume and RightVolume property instead of the Volume one.
May 18, 2013 at 8:21 AM
It work all right for single song. When go to next song then it is reset. what i doing now?