User Tools

Site Tools


controlling_20the_20audio_20mixer

Differences

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

Link to this comparison view

Next revision
Previous revision
controlling_20the_20audio_20mixer [2018/03/31 13:19] – external edit 127.0.0.1controlling_20the_20audio_20mixer [2024/01/05 00:22] (current) – external edit 127.0.0.1
Line 1: Line 1:
 =====Controlling the audio mixer===== =====Controlling the audio mixer=====
  
-//by Richard Russell, July 2007//\\ \\ **Note: On Windows Vista and Windows 7 each running application has its own independent audio mixer. The code listed here will work correctly, but the mixer controlled is that for the specific application.**\\ \\  The main //BBC BASIC for Windows// help documentation describes [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwine.html#playsound|how to control the wave output volume]] but this is just one of the volume controls usually provided by the audio mixer (accessed by double-clicking on the loudspeaker icon in the system tray). Typically you can independently control the volume of Wave, Synth and CD outputs and the level of CD, Microphone and Line inputs (and often several others). You can also mute selected outputs and select which input to use for recording.\\ \\  The **FN_mixerset** routine listed at the end of this article allows you to control the audio mixer from your BBC BASIC program. The routine should be called using code similar to the following:\\ \\ +//by Richard Russell, July 2007//\\ \\ **Note: On Windows Vista and Windows 7 each running application has its own independent audio mixer. The code listed here will work correctly, but the mixer controlled is that for the specific application.**\\ \\  The main //BBC BASIC for Windows// help documentation describes [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwine.html#playsound|how to control the wave output volume]] but this is just one of the volume controls usually provided by the audio mixer (accessed by double-clicking on the loudspeaker icon in the system tray). Typically you can independently control the volume of Wave, Synth and CD outputs and the level of CD, Microphone and Line inputs (and often several others). You can also mute selected outputs and select which input to use for recording.\\ \\  The **FN_mixerset** routine listed at the end of this article allows you to control the audio mixer from your BBC BASIC program. The routine should be called using code similar to the following: 
 + 
 +<code bb4w> 
         ok% = FN_mixerset(Dest%, Source%, Control%, Setting%)         ok% = FN_mixerset(Dest%, Source%, Control%, Setting%)
-The routine returns TRUE if the control was set successfully and FALSE if not.\\ \\  The parameters are as follows:\\ \\ +</code> 
 + 
 +The routine returns TRUE if the control was set successfully and FALSE if not.\\ \\  The parameters are as follows:
  
   * **"Dest%"** - The destination for the control, which will generally be either the **Speaker Output** (= **4**) or the **Recording Input** (= **7**).   * **"Dest%"** - The destination for the control, which will generally be either the **Speaker Output** (= **4**) or the **Recording Input** (= **7**).
Line 9: Line 13:
   * **"Control%"** - The control type, which will generally be **Volume** (= **&50030001**), **Mute** (= **&20010002**) or **Mux** (= **&70010001**).   * **"Control%"** - The control type, which will generally be **Volume** (= **&50030001**), **Mute** (= **&20010002**) or **Mux** (= **&70010001**).
   * **"Setting%"** - A value in the range **0-65535** for **Volume**, a value in the range **0-1** for **Mute** or the required source selection for **Mux**.   * **"Setting%"** - A value in the range **0-65535** for **Volume**, a value in the range **0-1** for **Mute** or the required source selection for **Mux**.
-\\  For other possible values consult the Microsoft documentation.\\ \\  So for example to set the **Microphone recording level** to midrange you could use code like this:\\ \\ + 
 +For other possible values consult the Microsoft documentation.\\ \\  So for example to set the **Microphone recording level** to midrange you could use code like this: 
 + 
 +<code bb4w>
         ok% = FN_mixerset(7, &1003, &50030001, 32768)         ok% = FN_mixerset(7, &1003, &50030001, 32768)
-To set the **CD Player output volume** to one-quarter:\\ \\ +</code> 
 + 
 +To set the **CD Player output volume** to one-quarter: 
 + 
 +<code bb4w>
         ok% = FN_mixerset(4, &1005, &50030001, 16384)         ok% = FN_mixerset(4, &1005, &50030001, 16384)
-To mute the **Line input**:\\ \\ +</code> 
 + 
 +To mute the **Line input**: 
 + 
 +<code bb4w>
         ok% = FN_mixerset(4, &1002, &20010002, 1)         ok% = FN_mixerset(4, &1002, &20010002, 1)
-To set a **Master Volume** control (which does not have a specific source) set the **"Source%"** parameter to zero. So to set the **Master speaker volume** to full you could do:\\ \\ +</code> 
 + 
 +To set a **Master Volume** control (which does not have a specific source) set the **"Source%"** parameter to zero. So to set the **Master speaker volume** to full you could do: 
 + 
 +<code bb4w>
         ok% = FN_mixerset(4, 0, &50030001, 65535)         ok% = FN_mixerset(4, 0, &50030001, 65535)
-Finally here is the code for **FN_mixerset** itself:\\ \\ +</code> 
 + 
 +Finally here is the code for **FN_mixerset** itself: 
 + 
 +<code bb4w>
         DEF FN_mixerset(dest%, source%, type%, setting%)         DEF FN_mixerset(dest%, source%, type%, setting%)
         LOCAL hmx%, res%, ndevs%, dev%, src%, ok%, MixerLine{}         LOCAL hmx%, res%, ndevs%, dev%, src%, ok%, MixerLine{}
Line 105: Line 128:
         IF res% ERROR 100, "mixerSetControlDetails failed"         IF res% ERROR 100, "mixerSetControlDetails failed"
         = TRUE         = TRUE
 +</code>
controlling_20the_20audio_20mixer.1522502350.txt.gz · Last modified: 2024/01/05 00:18 (external edit)