Set the Left and Right volume of Wave file with out disturbing the System Master Volume

May 15, 2015 at 10:09 AM
I want to play the Wave file when the SystemMasterVolume is set to 100%.
While playing the audio, left and right channel volume gets changed and accordingly the wave file should vary the sounds.

I tried AudioEndOutputVolume.Channels, but it actually changing the SystemMasterVolume.

WasAPIOut.Volume is setting the volume but, channel wise (Left and Right) separate i could not find the API.

Code from my Project:
       // Fetching the wave file
        var waveSource = CodecFactory.Instance.GetCodec("C:\\SampleWaveFile.wav");
        _soundOut = new WasapiOut();

        //Looping through the same wav file
        LoopStream stream = new LoopStream(waveSource);

        //Initializing the stream,  I guess before this line, i need to set the volume of wave source  
        //for both let and right channels

        string audDID = _soundOut.Device.DeviceID;
        aepv = AudioEndpointVolume.FromDevice(_soundOut.Device);

        aepv.GetVolumeRange(out vMinDB, out vMaxDB, out vIncrDB);

       // Setting the system volume to the maximum
        aepv.SetMasterVolumeLevel(vMaxDB, Guid.Empty);
Thought process from my end is:
Read the wave file, go to the end of the file where left and right channel volume blocks are placed and replace with the new values and write the wave file back and upload to the Loop Stream. Has this approach is covered from any of the API's? or we need to write a wrapper around that?

Please suggest me the way to do.

Thanks in advance.

Siva Rapolul.
May 15, 2015 at 1:13 PM
So you basically just want to adjust the volume of each channel during a playback?
If yes, you can do that in realtime, you don't have to "go to the end of the file".
May 18, 2015 at 8:00 AM
Edited May 21, 2015 at 6:10 AM
Hi filoe,

So you basically just want to adjust the volume of each channel during a playback?
i want to adjust the Wave file volume of each channel during a playback by keeping my system volume to the maximum.

WasAPIOut class has volume property which takes the volume range from 0.0 to 1.0 irrespective of channel.

While googling i found like, i need to override a IWaveSource class and set the volume by overriding the read functionality.

Earlier i was setting the volume for AudioEndPointVolume.Channels property where i set the volumes of both left and right.
I was wrong in this, as i am actually changing the system Master volume.

I just want to change wave stream volumes, and i see IWavesource and WasAPIOut classes, where only volume property allows on value.

I am stuck here and not getting the way to proceed.
Can you please help me the way to do it, and hope that will take me forward for what i am looking for.

Thanks in advance.
May 27, 2015 at 9:37 PM
Marked as answer by filoe on 5/27/2015 at 1:37 PM