Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
dlscientist

How to control individual app or device volumes using code in windows 10.

Recommended Posts

Posted · Original PosterOP

I am a gamer and I like to use discord as my chat application while playing video games. I want to know how I can use cmd, powershell,or whatever code to create a command that changes the volume of a specific application or device.  For example. I could have 4 hotkeys. One raises the volume of the game, one lowers the volume of the game, one raises the volume of discord, and one lowers the volume of discord. How would I go about this using code?

Link to post
Share on other sites
Posted · Original PosterOP
3 hours ago, LukeTheCoder05 said:

Have you tried volume mixer

Yes, however I want to do it using code so that I will not have to alt tab out of my game and enter the volume mixer just to do this.

Link to post
Share on other sites

what is a volume mixer? 


Sudo make me a sandwich 

 

Check out my guide on creating your own private cloud storage

 

Link to post
Share on other sites
15 hours ago, wasab said:

what is a volume mixer? 

He's probably talking about those physical desk thingy like streaming boards. Linus had a video about one of those 2 weeks about with a swear word beeper in it. You can have many line in/out and control them individually. Or some keyboard support some basic form of this like the Logitech G19

Link to post
Share on other sites
Posted · Original PosterOP
41 minutes ago, Franck said:

He's probably talking about those physical desk thingy like streaming boards. Linus had a video about one of those 2 weeks about with a swear word beeper in it. You can have many line in/out and control them individually. Or some keyboard support some basic form of this like the Logitech G19

Guys I mean the volume mixer in windows 10. Right click the sound icon and click "open volume mixer".

Link to post
Share on other sites
3 minutes ago, dlscientist said:

Guys I mean the volume mixer in windows 10. Right click the sound icon and click "open volume mixer".

Yeah


I'm gonna go find my own tech support...

with BLACKJACK and HOOKERS!

(Welcome to LTT Forums)

Link to post
Share on other sites
13 minutes ago, dlscientist said:

Guys I mean the volume mixer in windows 10. Right click the sound icon and click "open volume mixer".

the windows volume mixer won't work for all applications. It's up to the developper to add it or not as a separate audio option.

 

By default it's always only hooked to the master volume in the mixer which is not what you would like because that is global.

 

A few apps i know that are individually controllable thru windows mixer is the game Destiny 2 and Skype. (actually i think most if not all Battle.Net games have it implemented)

They are very rare those that implement separate channel that are visible and controllable through windows audio panel.

Discord is not displayed there and has its own volume settings so you can't through there.

 

That being said if you code your own application to control these you can control games that display in the windows audio menu quite easily and discord there is command line you can send to it to play with things like that. Obviously you have to code 2 different ways and you cannot deal with games that don't support it at all Like ARK and Minecraft.

 

If you have those desk mixer you can with the application split the audio per executable in some models but i am not aware if it's possible to control more than 3-4 source at a time. This would be the easiest option for sure.

 

If your game doesn't show separately in the audio mixer you have have to check if you can bind keys in the controls for volume up/down if you can good, else you're screwed.

Discord already has key mapping for volume up/down, mute, etc when the overlay is active. that would allow you to have 4 key mapped.

 

Link to post
Share on other sites
Posted · Original PosterOP
4 minutes ago, Franck said:

the windows volume mixer won't work for all applications. It's up to the developper to add it or not as a separate audio option.

 

By default it's always only hooked to the master volume in the mixer which is not what you would like because that is global.

 

A few apps i know that are individually controllable thru windows mixer is the game Destiny 2 and Skype. (actually i think most if not all Battle.Net games have it implemented)

They are very rare those that implement separate channel that are visible and controllable through windows audio panel.

Discord is not displayed there and has its own volume settings so you can't through there.

 

That being said if you code your own application to control these you can control games that display in the windows audio menu quite easily and discord there is command line you can send to it to play with things like that. Obviously you have to code 2 different ways and you cannot deal with games that don't support it at all Like ARK and Minecraft.

 

If you have those desk mixer you can with the application split the audio per executable in some models but i am not aware if it's possible to control more than 3-4 source at a time. This would be the easiest option for sure.

 

If your game doesn't show separately in the audio mixer you have have to check if you can bind keys in the controls for volume up/down if you can good, else you're screwed.

Discord already has key mapping for volume up/down, mute, etc when the overlay is active. that would allow you to have 4 key mapped.

 

When I looked discord didn't have keybindings for volume up and down? If it does then that's awesome. Post the link to the page that shows those options.

Link to post
Share on other sites

Look into this link:

 

https://stackoverflow.com/questions/21355891/change-audio-level-from-powershell

 

Once you have access to the API it is trivial to control the volume in powershell.

 

Thing is...and here's where I have to say I am not trying to be mean, but I am also not really trying not to be mean either...I found this info on the first result of my first google search. Google doesn't show you the search time anymore, but even with overhead for my typing speed, loading the page etc etc I am estimating less than 2 seconds of effort were spent on my getting that answer. 

 

Now, it may be because I know what to search for better, but if you don't even know what to search for then I cannot ever recommend you loading up powershell, because you will fuck something up, especially when you are getting into the modern day equivalent of COM.

Link to post
Share on other sites
2 hours ago, dlscientist said:

When I looked discord didn't have keybindings for volume up and down? If it does then that's awesome. Post the link to the page that shows those options.

You just click on the user in the overlay volume. and click arrow left or right and will lower the user volume up and down. At this point the mouse is easier for me. Discord has 1 volume per users in the channel.

 

IF you want the whole control you have to check @FlappyBoobs link it's very easy to do but it will only allow you to control the master volume as discord does NOT display a separate volume control in the windows mixer. So all games and Discord are all link to the same volume control.

 

You need special software to split the audio in different channels per application then as of will it be controllable when inside a game with keybinding chances are VERY low. For that you need an external desk control panel where the software usually send those channel to it and allow you to control the multiple IN/OUT channel volumes.

Link to post
Share on other sites

Kind of a dead post but I just wanted to mention that the program nircmd.exe has a function

setappvolume

. For example:

 

nircmd setappvolume plexamp.exe .2

That will set plexamp.exe to have 20% of the master volume level. This will also be reflected in the volume mixer.

Here's their blog announcing it

Here's the download (scroll to the bottom). I always have nircmd.exe in my system32 folder.

Link to post
Share on other sites
On 6/6/2019 at 9:41 AM, Franck said:

the windows volume mixer won't work for all applications. It's up to the developper to add it or not as a separate audio option.

Nope. Windows does it all. It doesn't show, it will show the moment they output sound. Unless the dev really screwed something up.

 

Link to post
Share on other sites
  1. Learn how to write system level software
  2. Write an audio driver that has the features you need
  3. Deploy audio driver
  4. Cuss because it doesn't work
  5. Repeat until successful.

Good luck! :) 


I will never succumb to the New Cult and I reject the leadership of @Aelar_Nailo and his wicked parrot armies led by @FakeCIA and @DildorTheDecent. I will keep my eyes pure and remain dedicated to the path of the One True; IlLinusNati

Link to post
Share on other sites
On 6/27/2020 at 9:16 PM, GoodBytes said:

Nope. Windows does it all. It doesn't show, it will show the moment they output sound. Unless the dev really screwed something up.

 

read everything. Windows doesn't not split each of the channels for each one you have. If you don't code anything everything is hooked to the master volume.

 

By default OpenGL sound goes out the master volume,

By default DirectSound (directx equivalent) goes out the master volume

by default C++, Java and C# audio come out the master volume.

 

In all these case the way to show your app as a separate knob in the windows volume control is the same. You need to create an output audio device (in the language you use) and windows will recognize it automatically and will show a separate knob. You can create up to 128 individual output channel before the windows mixer completely crash when you try open it but behind the scene it still works and you can still turn on and off the different output channel by code.

Link to post
Share on other sites

Ah ok

36 minutes ago, Franck said:

read everything. Windows doesn't not split each of the channels for each one you have. If you don't code anything everything is hooked to the master volume.

 

By default OpenGL sound goes out the master volume,

By default DirectSound (directx equivalent) goes out the master volume

by default C++, Java and C# audio come out the master volume.

 

In all these case the way to show your app as a separate knob in the windows volume control is the same. You need to create an output audio device (in the language you use) and windows will recognize it automatically and will show a separate knob. You can create up to 128 individual output channel before the windows mixer completely crash when you try open it but behind the scene it still works and you can still turn on and off the different output channel by code.

Ah ok I am following you. Yes, you are correct. I thought you were referring to the per app control, not per output source control.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×