This project has moved and is read-only. For the latest updates, please go here.

PanSlider Object - How to use?

Nov 13, 2012 at 8:04 PM


I´ am currently programming a small "DJ Software" (Just for Fun) and I want to use a PanSlider for controlling the volume of the left and right speaker. Is it possible?

The "Pan_Changed"-Event is already running. But at this point I don´t what to do in the Event-Function to use the pan.

Does anybody have already use the PanSlider Object? A little Code excerpt would be very nice.

Best regards Moritz M. :)

Nov 14, 2012 at 7:01 AM

The PanSlider control is a very simple example control that returns values between -1.0 (left) and 1.0 (right), with 0.0 as centre.

You would use it in conjunction with any class in NAudio that has a Pan property. For example, PanningSampleProvider, or WaveChannel32. PanningSampleProvider lets to choose a panning law to use. Set up playback something like this

var file = new AudioFileReader(myFile);
var panningSampleProvider = new PanningSampleProvider(file);
var player = new WaveOut();
this.panSlider1.PanChanged += (s,a) => panningSampleProvider.Pan = panSlider1.Pan; player.Init(panningSampleProvider);



Nov 14, 2012 at 4:26 PM
Edited Nov 14, 2012 at 4:56 PM

Hello and Thanks!


I have already a IWavePlayer using a MeteringSampleProvider. So how can I use a MeteringSampleProvider and a PanningSampleProvider in the same Player? Does it work with Stereo Sound or just with Mono?


Moritz :)


Sorry for my bad English!

Nov 16, 2012 at 10:48 AM

You pipe them through each other. So pass the MeteringSampleProvider into the PanningSampleProvider (or the other way round, depending if you want to meter the sound before it is panned or not).