stream-labs / obs-studio-node

libOBS (OBS Studio) for Node.Js, Electron and similar tools
GNU General Public License v2.0
606 stars 99 forks source link

Is it possible to get the volume of the audio devices and change them? #1356

Closed conanKD closed 11 months ago

conanKD commented 11 months ago

Hello,

i would like to be able to get the current volume of the input audio devices (i.e. the microphone) and also increase the volume. Does anyone know how to do this? Unfortunately I have no idea how to do that....

summeroff commented 11 months ago

Inputs have its own volumes what used inside application to monitor and encode into streams. You can access it here: https://github.com/stream-labs/obs-studio-node/blob/393fd49c4e2210c43d0468b2319b19b147e33971/obs-studio-client/source/input.cpp#L56 There is also system volume for microphone(what you can change in Windows and probably some api too). And there might be audio volume in drivers.

conanKD commented 11 months ago

Hey thanks for your response but unfortunately i am not able to use this because i am not sure how to acces it from the node enviroment.

I am currently using this example https://github.com/Envek/obs-studio-node-example/blob/b20e0c02034b1202921e853fbd888f5fedbe4f05/obsRecorder.js#L262 to create a wasapi_input_capture. This example uses the InputFactory and it returns me an instance of a Input Class which comes from the "obs_studio_client.node" module. When i try to modify the volume i try to set source.volume = 0.5 i.E. its not working for me and the sound is completly gone.

I am thankfull for any future help!

summeroff commented 11 months ago

you can use faders to change volume. https://github.com/stream-labs/obs-studio-node/blob/d8d302b355b47ee6895a6a504fa9317cb8df765a/tests/osn-tests/src/test_osn_fader.ts#L92-L100

set fader.deflection

conanKD commented 11 months ago

Hey man big thanks, this looks really promissing! It worked for me to set it to like 0.5 and the volume was significant lower than before. I also want to increase the volume above 1 (100%). I can set it to 2 but when i console.log the fader deflection it still says 1 even tho it feels louder (may just be placebo?). Is this even the correct way to increase the volume above 100%?

summeroff commented 11 months ago

you can use Gain filter to increase volume.

test volume on media files with quiet audio. as loud audio files can be already at maximum. increasing volume here is how one audio source sounds relative to other. their maximum limited by OS, sound card, headphones.

conanKD commented 11 months ago

Alright thanks for your answers! Helped a lot