Click here to Skip to main content
15,889,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C# visual studio windows form project.

Is it possible to adjust the volume of a played wav file with the System.Media namespace ?

I'm able to play the file with the code found on microsoft.com, but I can't find a way to set the volume at a given level.

C#
private void playSimpleSound()
{
    SoundPlayer simpleSound = new SoundPlayer(@"c:\Windows\Media\chimes.wav");
    simpleSound.Play();
}
Posted

1 solution

It does not have its own volume. You can do one of two things: adjust the system volume level or modify the volume of the waveform you want to play.

On the system volume control, please see: http://www.dreamincode.net/forums/topic/45693-controlling-sound-volume-in-c%23[^].

You can also recalculate the waveform volume on the fly and output new waveform. Please see: https://social.msdn.microsoft.com/Forums/vstudio/en-US/42b46e40-4d4a-48f8-8681-9b0167cfe781/attenuating-soundplayer-volume?forum=csharpgeneral[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900