0

I can't get the panning to work in Naudio.
here is my code:

void Play(double Amp, double Left, double Right)
{
    BBeats = new binaural_beats();
    BBeats.Amplitude = Amp;
    BBeats.Amplitude2 = Amp;
    BBeats.Frequency = Left;
    BBeats.Frequency2 = Right;

    BBeats.Bufferlength = 44100 * 2 * 3; // will play for 3 sec

    waveout = new WaveOut();
    WaveChannel32 temp = new WaveChannel32(BBeats);

    temp.PadWithZeroes = false;
    temp.Pan = 0.0f;

    waveout.Init(temp);
    waveout.Play();
}

I tried 0.0F, 1.0F and 100F but it is not working.

I want it to play completely from one speaker and not from the other one. or from one channel and not the other channel.

Daniel Corzo
  • 1,055
  • 2
  • 19
  • 32
Brandon
  • 187
  • 1
  • 3
  • 11

3 Answers3

1

I just spent the entire night with same problem.

AND the solution was a whole different place than expected. I tried using pan and PanningSampleProvider, and MultiplexingWaveProvider, to obtain control over the pan, but I could only hear a minor change in sound, not really a pan. On my output meters, I could see maybe 10% variation.

Now I must translate from Danish, so it might not be 100% accurate. But under your sound device in windows, select the play device you are using, press properties, press extensions, and tick the "Deactivate all sound effects". BAM, 100% control over pan.

Guess windows have some kind of auto-level algorithm between stereo channels selected as default - don't know why and what it should do.

Michael Nelles
  • 5,426
  • 8
  • 41
  • 57
Frank
  • 11
  • 1
0

The Pan setting on WaveChannel32 goes from -1 (left only) to 1 (right only)

Or for more control over panning strategies, look at the PanningSampleProvider class.

Mark Heath
  • 48,273
  • 29
  • 137
  • 194
  • it is still not working... if I use 1 I hear the sound out of both speakers and if I use -1 I do not hear it out of any speakers. I should hear sound out if only one speaker at a time... – Brandon Jan 04 '17 at 14:01
0

I had the same problem. I tried to use PanningSampleProvider (NAudio) but it didn't work. I found out the cause was window system setting. Just turn off mono audio from Audio Setting. Turn off mono audio

Here is my source code:

var _audioFile = new AudioFileReader("E://CShap/Test/speaker.wav");
var monofile = new StereoToMonoSampleProvider(_audioFile);
var panner = new PanningSampleProvider(monofile);
panner.PanStrategy = new SquareRootPanStrategy();
panner.Pan = -1.0f; // pan fully left
WaveFileWriter.CreateWaveFile16("E://CShap/Test/speaker_resampler_L.wav", panner);
ngoctrambui
  • 141
  • 1
  • 4