3
votes

I'm using NAudio.dll in a C# application. I found that IWavePlayer has the property Volume but it's obsolete.

 public interface IWavePlayer : IDisposable
    {
        [Obsolete("Not intending to keep supporting this going forward: set the volume on your input WaveProvider instead")]
        float Volume { get; set; }

       //..........................
    }

So what should I do to set the volume? Does anyone have an example of how to do it?

1

1 Answers

3
votes

Some of the implementors of IWavePlayer still have a Volume property (for example, WaveOut and DirectSound out do), so just keep a reference to the concrete class rather than the interface. The property on the interface was made obsolete as not all implementors of IWavePlayer are able to support this.

In any case, it is often best to control the volume of the samples you are passing to the IWavePlayer yourself. There are many classes in NAudio that allow the modification of stream volume, particularly those inheriting from ISampleProvider. Look at the NAudioDemo source code and see how volume modification is implemented for an example.