0

I am trying to create a class that can control the windows volume setting. So far I have been succesful in turning the volume up and down, plus muting the volume. This is done following a code sample from dotnetcurry.

The problem is that I need this class to be able to set a specific volume say like 57%. I could make a function that turned the volume down to 0% and then turn it up to 57%, but that would mean I should always assume I have to turn it down from 100% and then go up to 57% even though the start volume was 20% or was already at 57%. I could turn it up first but the same problem exists. I dont know the current volume setting from start.

I have tried to see if there is a function I could call to get the current volume setting, but all I could find was how loud the current sound is, not the setting of the volume control. If I had access to the volume level setting, I could validate it before taking action and make the function a lot nicer.

Is there a way to get the current volume setting in C#/Windows?

Thomas Weller
  • 55,411
  • 20
  • 125
  • 222
evilfish
  • 661
  • 8
  • 30
  • Did this work? https://stackoverflow.com/a/31042902/4802649 – Phiter Jan 06 '18 at 17:59
  • So basically you don't want to *get* the volume as in the question title, you want to *set* the volume to a specific level. – Thomas Weller Jan 06 '18 at 18:02
  • From that question, use this answer: https://stackoverflow.com/a/35660274/480982 – Thomas Weller Jan 06 '18 at 18:04
  • @ThomasWeller Well, when I think about it, setting a specific volume would be fantastic. I just was lost in a train of thought. but I still think the question is justified. – evilfish Jan 06 '18 at 18:16
  • @ThomasWeller Ahhhh... I didn't see that core audio system. I would say this is then a dunplicate of the one you found. – evilfish Jan 06 '18 at 18:31

0 Answers0