1 // ****************************************************************************
5 // Include file for mixer interfacing with the EchoGals-derived classes.
7 // Set editor tabs to 3 for your viewing pleasure.
9 // ----------------------------------------------------------------------------
11 // This file is part of Echo Digital Audio's generic driver library.
12 // Copyright Echo Digital Audio Corporation (c) 1998 - 2005
13 // All rights reserved
16 // This library is free software; you can redistribute it and/or
17 // modify it under the terms of the GNU Lesser General Public
18 // License as published by the Free Software Foundation; either
19 // version 2.1 of the License, or (at your option) any later version.
21 // This library is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 // Lesser General Public License for more details.
26 // You should have received a copy of the GNU Lesser General Public
27 // License along with this library; if not, write to the Free Software
28 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 // ****************************************************************************
32 // Prevent problems with multiple includes
36 #include "EchoGalsXface.h"
41 #define ECHOGAIN_MUTED DSP_TO_GENERIC(-128) // Minimum possible gain
42 #define ECHOGAIN_MINOUT DSP_TO_GENERIC(-128) // Min output gain in dB
43 #define ECHOGAIN_MAXOUT DSP_TO_GENERIC(6) // Max output gain in dB
44 #define ECHOGAIN_MININP DSP_TO_GENERIC(-25) // Min input gain in dB
45 #define ECHOGAIN_MAXINP DSP_TO_GENERIC(25) // Max input gain in dB
47 #define ECHOGAIN_UPDATE 0xAAAAAA // Using this value means:
49 // to the DSP using the
50 // currently stored value.
53 //=============================================================================
55 // Most of the mixer functions have been unified into a single interface;
56 // you pass either a single MIXER_FUNCTION struct or an array of MIXER_FUNCTION
57 // structs. Each MIXER_FUNCTION is generally used to set or get one or more
60 //=============================================================================
63 // Structure to specify a bus, pipe, or a monitor being routed from
64 // the input to the output
66 enum ECHO_CHANNEL_TYPES
73 ECHO_NO_CHANNEL_TYPE
= 0xffff,
74 ECHO_CHANNEL_UNUSED
= 0xffff
77 typedef struct tMIXER_AUDIO_CHANNEL
79 WORD wCardId
; // This field is obsolete
80 WORD wChannel
; // Depends on dwType:
81 // ECHO_BUS_OUT wChannel = output bus #
82 // ECHO_BUS_IN wChannel = input bus #
83 // ECHO_PIPE_OUT wChannel = output pipe #
84 // ECHO_PIPE_IN wChannel = input pipe #
85 // ECHO_MONITOR wChannel = input bus #
86 DWORD dwType
; // One of the above enums
87 } MIXER_AUDIO_CHANNEL
, *PMIXER_AUDIO_CHANNEL
;
91 // Mixer Function Tags
93 // These codes are used to specify the mixer function you want to perform;
94 // they determine which field in the Data union to use
96 #define MXF_GET_CAPS 1 // Get card capabilities
97 #define MXF_GET_LEVEL 2 // Get level for one channel
98 #define MXF_SET_LEVEL 3 // Set level for one channel
99 #define MXF_GET_NOMINAL 4 // Get nominal level for one channel
100 #define MXF_SET_NOMINAL 5 // Set nominal level for one channel
101 #define MXF_GET_MONITOR 6 // Get monitor for one channel
102 #define MXF_SET_MONITOR 7 // Set monitor for one channel
103 #define MXF_GET_INPUT_CLOCK 8 // Get input clock
104 #define MXF_SET_INPUT_CLOCK 9 // Set input clock for one card
105 #define MXF_GET_METERS 10 // Get meters for all channels on one card
106 #define MXF_GET_METERS_ON 11 // Get meters on state for one card
107 #define MXF_SET_METERS_ON 12 // Set meters on state for one card
108 // Meters must only be enabled while
109 // driver for card exists; the meters are
110 // written via bus mastering directly to memory
111 #define MXF_GET_PROF_SPDIF 13 // Get Professional or consumer S/PDIF mode
113 #define MXF_SET_PROF_SPDIF 14 // Set Professional or consumer S/PDIF mode
115 #define MXF_GET_MUTE 15 // Get mute state for one channel
116 #define MXF_SET_MUTE 16 // Set mute state for one channel
117 #define MXF_GET_MONITOR_MUTE 19 // Get monitor mute state for one channel
118 #define MXF_SET_MONITOR_MUTE 20 // Set monitor mute state for one channel
119 #define MXF_GET_MONITOR_PAN 23 // Get monitor pan value for one stereo channel
120 #define MXF_SET_MONITOR_PAN 24 // Set monitor pan value for one stereo channel
121 #define MXF_GET_FLAGS 27 // Get driver flags
122 #define MXF_SET_FLAGS 28 // Set driver flag
123 #define MXF_CLEAR_FLAGS 29 // Clear driver flags
124 #define MXF_GET_SAMPLERATE_LOCK 30 // Get locked sample rate for one card
125 #define MXF_SET_SAMPLERATE_LOCK 31 // Set locked sample rate for one card
126 #define MXF_GET_SAMPLERATE 32 // Get actual sample rate for one card
127 #define MXF_GET_MIDI_IN_ACTIVITY 35 // Get MIDI in activity state
128 #define MXF_GET_MIDI_OUT_ACTIVITY 36 // Get MIDI out activity state
129 #define MXF_GET_DIGITAL_MODE 37 // Get digital mode
130 #define MXF_SET_DIGITAL_MODE 38 // Get digital mode
132 #define MXF_GET_PAN 39 // Get & set pan
133 #define MXF_SET_PAN 40
134 #define MXF_GET_OUTPUT_CLOCK 41 // Get output clock
135 #define MXF_SET_OUTPUT_CLOCK 42 // Set output clock for one card
136 #define MXF_GET_CLOCK_DETECT 43 // Get the currently detected clocks
137 #define MXF_GET_DIG_IN_AUTO_MUTE 44 // Get the state of the digital input auto-mute
138 #define MXF_SET_DIG_IN_AUTO_MUTE 45 // Set the state of the digital input auto-mute
139 #define MXF_GET_AUDIO_LATENCY 46 // Get the latency for a single pipe
141 #define MXF_GET_PHANTOM_POWER 47 // Get phantom power state
142 #define MXF_SET_PHANTOM_POWER 48 // Set phantom power state
146 // Output pipe control change - only used if you specify
147 // ECHO_PIPE_OUT in the dwType field for MIXER_AUDIO_CHANNEL
151 WORD wBusOut
; // For cards without vmixer, should
152 // be the same as wChannel in MIXER_AUDIO_CHANNEL
155 INT32 iLevel
; // New gain in dB X 256
156 INT32 iPan
; // 0 <= new pan <= MAX_MIXER_PAN,
157 // 0 = full left MAX_MIXER_PAN = full right
158 BOOL bMuteOn
; // To mute or not to mute
159 // MXF_GET_MONITOR_MUTE &
160 // MXF_SET_MONITOR_MUTE
163 } MIXER_PIPE_OUT
, PMIXER_PIPE_OUT
;
167 // The MIXER_AUDIO_CHANNEL header has the card and input channel.
168 // This structure has the output channel and the gain, mute or pan
169 // state for one monitor.
171 // Only used if you specify ECHO_MONITOR in the dwType field
172 // for MIXER_AUDIO_CHANNEL.
174 typedef struct tMIXER_MONITOR
179 INT32 iLevel
; // New gain in dB X 256
180 INT32 iPan
; // 0 <= new pan <= MAX_MIXER_PAN,
181 // 0 = full left MAX_MIXER_PAN = full right
182 BOOL bMuteOn
; // To mute or not to mute
183 // MXF_GET_MONITOR_MUTE &
184 // MXF_SET_MONITOR_MUTE
186 } MIXER_MONITOR
, *PMIXER_MONITOR
;
190 // If you specify MXF_GET_AUDIO_LATENCY, then you get the following
193 typedef struct tECHO_AUDIO_LATENCY
198 } ECHO_AUDIO_LATENCY
;
203 // Mixer Function Data Structure
205 typedef struct tMIXER_FUNCTION
207 MIXER_AUDIO_CHANNEL Channel
; // Which channel to service
208 INT32 iFunction
; // What function to do
209 ECHOSTATUS RtnStatus
; // Return Result
212 ECHOGALS_CAPS Capabilities
; // MXF_GET_CAPS
213 INT32 iNominal
; // MXF_GET_NOMINAL & MXF_SET_NOMINAL
214 INT32 iLevel
; // MXF_GET_LEVEL & MXF_SET_LEVEL
215 MIXER_MONITOR Monitor
; // MXF_GET_MONITOR & MXF_SET_MONITOR
216 // MXF_GET_MONITOR_MUTE & MXF_SET_MONITOR_MUTE
217 // MXF_GET_MONITOR_PAN & MXF_SET_MONITOR_PAN
218 WORD wClock
; // MXF_GET_INPUT_CLOCK & MXF_SET_INPUT_CLOCK
219 // MXF_GET_OUTPUT_CLOCK & MXF_SET_OUTPUT_CLOCK
220 DWORD dwClockDetectBits
;
221 // MXF_GET_CLOCK_DETECTs
222 ECHOGALS_METERS Meters
; // MXF_GET_METERS
223 BOOL bMetersOn
; // MXF_GET_METERS_ON &
225 BOOL bProfSpdif
; // MXF_GET_PROF_SPDIF &
226 // MXF_SET_PROF_SPDIF
227 BOOL bMuteOn
; // MXF_GET_MUTE & MXF_SET_MUTE
228 BOOL bNotifyOn
; // MXF_GET_NOTIFY_ON &
230 WORD wFlags
; // MXF_GET_FLAGS, MXF_SET_FLAGS &
231 // MXF_CLEAR_FLAGS (See
232 // ECHOGALS_FLAG_??? in file
234 DWORD dwLockedSampleRate
;
235 // MXF_GET_SAMPLERATE_LOCK &
236 // MXF_SET_SAMPLERATE_LOCK
237 DWORD dwSampleRate
; // MXF_GET_SAMPLERATE
238 BOOL bMidiActive
; // MXF_GET_MIDI_IN_ACTIVITY &
239 // MXF_GET_MIDI_OUT_ACTIVITY
240 INT32 iDigMode
; // MXF_GET_DIGITAL_MODE &
241 // MXF_SET_DIGITAL_MODE
243 MIXER_PIPE_OUT PipeOut
; // MXF_GET_LEVEL & MXF_SET_LEVEL
244 // MXF_GET_MUTE & MXF_SET_MUTE
245 // MXF_GET_PAN & MXF_SET_PAN
247 BOOL fDigitalInAutoMute
; // MXF_GET_DIG_IN_AUTO_MUTE
248 // MXF_SET_DIG_IN_AUTO_MUTE
249 ECHO_AUDIO_LATENCY Latency
; // MXF_GET_AUDIO_LATENCY
251 BOOL fPhantomPower
; // Phantom power state (true == on, false == off)
253 } MIXER_FUNCTION
, *PMIXER_FUNCTION
;
256 // Mixer Multifunction Interface
258 // Allow user to supply an array of commands to be performed in one call.
259 // Since this is a variable length structure, user beware!
261 typedef struct tMIXER_MULTI_FUNCTION
264 MIXER_FUNCTION MixerFunction
[ 1 ];
265 } MIXER_MULTI_FUNCTION
, *PMIXER_MULTI_FUNCTION
;
268 // Use this macro to size the data structure
270 #define ComputeMixerMultiFunctionSize(Ct) ( sizeof( MIXER_MULTI_FUNCTION ) + ( sizeof( MIXER_FUNCTION ) * ( Ct - 1 ) ) )
276 // Mixers allow for notification whenever a change occurs.
277 // Mixer notify structure contains channel and parameter(s) that
282 // Mixer Parameter Changed definitions
284 #define MXN_LEVEL 0 // Level changed
285 #define MXN_NOMINAL 1 // Nominal level changed
286 #define MXN_INPUT_CLOCK 2 // Input clock changed
287 #define MXN_SPDIF 3 // S/PDIF - Professional mode changed
288 #define MXN_MUTE 4 // Mute state changed
289 #define MXN_PAN 6 // Pan value changed
291 #define MXN_FLAGS 12 // A driver flag changed
293 #define MXN_DIGITAL_MODE 14 // Digital mode changed
294 #define MXN_OUTPUT_CLOCK 15 // Output clock changed
295 #define MXN_MAX 15 // Max notify parameters
297 typedef struct tMIXER_NOTIFY
299 WORD wType
; // Same as enums used for MIXER_AUDIO_CHANNEL
308 WORD wBusOut
; // For monitor & output pipe notifies only
309 WORD wParameter
; // One of the above MXN_*
311 } MIXER_NOTIFY
, *PMIXER_NOTIFY
;
314 typedef struct tMIXER_MULTI_NOTIFY
317 DWORD dwCount
; // When passed to the generic driver,
318 // dwCount holds the size of the Notifies array.
319 // On returning from the driver, dwCount
320 // holds the number of entries in Notifies
321 // filled out by the generic driver.
322 MIXER_NOTIFY Notifies
[1]; // Dynamic array; there are dwCount entries
323 } MIXER_MULTI_NOTIFY
, *PMIXER_MULTI_NOTIFY
;
328 #define MAX_MIXER_PAN 1000 // this is pan hard right
331 //=============================================================================
333 // After designing eighteen or nineteen consoles for this hardware, we've
334 // learned that it's useful to be able to get all the following stuff at
335 // once. Typically the console will run a timer that fetchs this periodically.
337 // Meters and dwClockDetectBits are exactly the same as you would get if you
338 // did each of those mixer functions separately.
340 // dwNumPendingNotifies is how many notifies are in the queue associated with
341 // the client. You can use this number to create an array of MIXER_NOTIFY
342 // structures and call CEchoGals::GetControlChanges. This way you only check
343 // for control changes if the controls have actually changed.
345 //=============================================================================
347 typedef struct tECHO_POLLED_STUFF
350 ECHOGALS_METERS Meters
;
351 DWORD dwClockDetectBits
;
352 DWORD dwNumPendingNotifies
;