User Tools

Site Tools


controlling_20the_20master_20volume

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
controlling_20the_20master_20volume [2018/03/31 13:19] – external edit 127.0.0.1controlling_20the_20master_20volume [2024/01/05 00:22] (current) – external edit 127.0.0.1
Line 1: Line 1:
 =====Controlling the Master Volume===== =====Controlling the Master Volume=====
  
-//by Richard Russell, October 2016//\\ \\  The main Help documentation describes how to [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwine.html#playsound|control the sound volume]] but in **Windows Vista** and later each running application has its own volume control and the code shown there affects only the sound output from your own program. If instead you want to control the **master volume** you can use the code listed here.\\ \\  The code contains two functions: **FNgetVolume()** which returns the current setting and **PROCsetVolume()** which sets the volume to a specified value. In each case you can specify whether you want to work with **deciBels** (in which case the 'scalar%' parameter should be set to zero) or with a '**linear**' volume range from 0.0 to 1.0 (in which case the 'scalar%' parameter should be set non-zero).\\ \\  The code is adapted from the C++ code listed [[http://www.codeproject.com/Tips/233484/Change-Master-Volume-in-Visual-Cplusplus|here]].\\ +//by Richard Russell, October 2016//\\ \\  The main Help documentation describes how to [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwine.html#playsound|control the sound volume]] but in **Windows Vista** and later each running application has its own volume control and the code shown there affects only the sound output from your own program. If instead you want to control the **master volume** you can use the code listed here.\\ \\  The code contains two functions: **FNgetVolume()** which returns the current setting and **PROCsetVolume()** which sets the volume to a specified value. In each case you can specify whether you want to work with **deciBels** (in which case the 'scalar%' parameter should be set to zero) or with a '**linear**' volume range from 0.0 to 1.0 (in which case the 'scalar%' parameter should be set non-zero).\\ \\  The code is adapted from the C++ code listed [[http://www.codeproject.com/Tips/233484/Change-Master-Volume-in-Visual-Cplusplus|here]]. 
 + 
 +<code bb4w>
         DEF PROCsetVolume(volume#, scalar%)         DEF PROCsetVolume(volume#, scalar%)
         LOCAL ole32%, oleaut32%, deviceEnumerator%, endpointDevice%, endpointVolume%         LOCAL ole32%, oleaut32%, deviceEnumerator%, endpointDevice%, endpointVolume%
Line 114: Line 116:
         SYS `CLSIDFromString`, M%, C%         SYS `CLSIDFromString`, M%, C%
         = C%         = C%
 +</code>
controlling_20the_20master_20volume.1522502350.txt.gz · Last modified: 2024/01/05 00:18 (external edit)