1 |
/* |
---|
2 |
* Copyright (C) 2007 by Pieter Palmers |
---|
3 |
* |
---|
4 |
* This file is part of FFADO |
---|
5 |
* FFADO = Free Firewire (pro-)audio drivers for linux |
---|
6 |
* |
---|
7 |
* FFADO is based upon FreeBoB. |
---|
8 |
* |
---|
9 |
* This library is free software; you can redistribute it and/or |
---|
10 |
* modify it under the terms of the GNU Lesser General Public |
---|
11 |
* License version 2.1, as published by the Free Software Foundation; |
---|
12 |
* |
---|
13 |
* This library is distributed in the hope that it will be useful, |
---|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 |
* Lesser General Public License for more details. |
---|
17 |
* |
---|
18 |
* You should have received a copy of the GNU Lesser General Public |
---|
19 |
* License along with this library; if not, write to the Free Software |
---|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
---|
21 |
* MA 02110-1301 USA |
---|
22 |
*/ |
---|
23 |
|
---|
24 |
#include "focusrite_saffirepro.h" |
---|
25 |
#include "focusrite_cmd.h" |
---|
26 |
|
---|
27 |
namespace BeBoB { |
---|
28 |
namespace Focusrite { |
---|
29 |
|
---|
30 |
SaffireProDevice::SaffireProDevice( Ieee1394Service& ieee1394Service, |
---|
31 |
std::auto_ptr<ConfigRom>( configRom )) |
---|
32 |
: FocusriteDevice( ieee1394Service, configRom) |
---|
33 |
, m_MixerContainer ( NULL ) |
---|
34 |
{ |
---|
35 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::Focusrite::SaffireProDevice (NodeID %d)\n", |
---|
36 |
getConfigRom().getNodeId() ); |
---|
37 |
|
---|
38 |
// the saffire pro doesn't seem to like it if the commands are too fast |
---|
39 |
if (AVC::AVCCommand::getSleepAfterAVCCommand() < 500) { |
---|
40 |
AVC::AVCCommand::setSleepAfterAVCCommand( 500 ); |
---|
41 |
} |
---|
42 |
} |
---|
43 |
|
---|
44 |
SaffireProDevice::~SaffireProDevice() |
---|
45 |
{ |
---|
46 |
destroyMixer(); |
---|
47 |
} |
---|
48 |
|
---|
49 |
bool |
---|
50 |
SaffireProDevice::buildMixer() |
---|
51 |
{ |
---|
52 |
bool result=true; |
---|
53 |
debugOutput(DEBUG_LEVEL_VERBOSE, "Building a Focusrite SaffirePro mixer...\n"); |
---|
54 |
|
---|
55 |
destroyMixer(); |
---|
56 |
|
---|
57 |
// create the mixer object container |
---|
58 |
m_MixerContainer = new Control::Container("Mixer"); |
---|
59 |
|
---|
60 |
if (!m_MixerContainer) { |
---|
61 |
debugError("Could not create mixer container...\n"); |
---|
62 |
return false; |
---|
63 |
} |
---|
64 |
|
---|
65 |
// create control objects for the saffire pro |
---|
66 |
result &= m_MixerContainer->addElement( |
---|
67 |
new BinaryControl(*this, FR_SAFFIREPRO_CMD_ID_PHANTOM14, 0, |
---|
68 |
"Phantom_1to4", "Phantom 1-4", "Switch Phantom Power on channels 1-4")); |
---|
69 |
|
---|
70 |
result &= m_MixerContainer->addElement( |
---|
71 |
new BinaryControl(*this, FR_SAFFIREPRO_CMD_ID_PHANTOM58, 0, |
---|
72 |
"Phantom_5to8", "Phantom 5-8", "Switch Phantom Power on channels 5-8")); |
---|
73 |
|
---|
74 |
result &= m_MixerContainer->addElement( |
---|
75 |
new BinaryControl(*this, FR_SAFFIREPRO_CMD_ID_INSERT1, 0, |
---|
76 |
"Insert1", "Insert 1", "Switch Insert on Channel 1")); |
---|
77 |
|
---|
78 |
result &= m_MixerContainer->addElement( |
---|
79 |
new BinaryControl(*this, FR_SAFFIREPRO_CMD_ID_INSERT2, 0, |
---|
80 |
"Insert2", "Insert 2", "Switch Insert on Channel 2")); |
---|
81 |
|
---|
82 |
result &= m_MixerContainer->addElement( |
---|
83 |
new BinaryControl(*this, FR_SAFFIREPRO_CMD_ID_AC3_PASSTHROUGH, 0, |
---|
84 |
"AC3pass", "AC3 Passtrough", "Enable AC3 Passthrough")); |
---|
85 |
|
---|
86 |
result &= m_MixerContainer->addElement( |
---|
87 |
new BinaryControl(*this, FR_SAFFIREPRO_CMD_ID_MIDI_TRU, 0, |
---|
88 |
"MidiTru", "Midi Tru", "Enable Midi Tru")); |
---|
89 |
|
---|
90 |
// output mute controls |
---|
91 |
result &= m_MixerContainer->addElement( |
---|
92 |
new BinaryControl(*this, |
---|
93 |
FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT12, FR_SAFFIREPRO_CMD_ID_BITFIELD_BIT_MUTE, |
---|
94 |
"Out12Mute", "Out1/2 Mute", "Output 1/2 Mute")); |
---|
95 |
result &= m_MixerContainer->addElement( |
---|
96 |
new BinaryControl(*this, |
---|
97 |
FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT34, FR_SAFFIREPRO_CMD_ID_BITFIELD_BIT_MUTE, |
---|
98 |
"Out34Mute", "Out3/4 Mute", "Output 3/4 Mute")); |
---|
99 |
result &= m_MixerContainer->addElement( |
---|
100 |
new BinaryControl(*this, |
---|
101 |
FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT56, FR_SAFFIREPRO_CMD_ID_BITFIELD_BIT_MUTE, |
---|
102 |
"Out56Mute", "Out5/6 Mute", "Output 5/6 Mute")); |
---|
103 |
result &= m_MixerContainer->addElement( |
---|
104 |
new BinaryControl(*this, |
---|
105 |
FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT78, FR_SAFFIREPRO_CMD_ID_BITFIELD_BIT_MUTE, |
---|
106 |
"Out78Mute", "Out7/8 Mute", "Output 7/8 Mute")); |
---|
107 |
|
---|
108 |
// output front panel hw volume control |
---|
109 |
result &= m_MixerContainer->addElement( |
---|
110 |
new BinaryControl(*this, |
---|
111 |
FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT12, FR_SAFFIREPRO_CMD_ID_BITFIELD_BIT_HWCTRL, |
---|
112 |
"Out12HwCtrl", "Out1/2 HwCtrl", "Output 1/2 Front Panel Hardware volume control")); |
---|
113 |
result &= m_MixerContainer->addElement( |
---|
114 |
new BinaryControl(*this, |
---|
115 |
FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT34, FR_SAFFIREPRO_CMD_ID_BITFIELD_BIT_HWCTRL, |
---|
116 |
"Out34HwCtrl", "Out3/4 HwCtrl", "Output 3/4 Front Panel Hardware volume control")); |
---|
117 |
result &= m_MixerContainer->addElement( |
---|
118 |
new BinaryControl(*this, |
---|
119 |
FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT56, FR_SAFFIREPRO_CMD_ID_BITFIELD_BIT_HWCTRL, |
---|
120 |
"Out56HwCtrl", "Out5/6 HwCtrl", "Output 5/6 Front Panel Hardware volume control")); |
---|
121 |
result &= m_MixerContainer->addElement( |
---|
122 |
new BinaryControl(*this, |
---|
123 |
FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT78, FR_SAFFIREPRO_CMD_ID_BITFIELD_BIT_HWCTRL, |
---|
124 |
"Out78HwCtrl", "Out7/8 HwCtrl", "Output 7/8 Front Panel Hardware volume control")); |
---|
125 |
|
---|
126 |
// output active monitor padding |
---|
127 |
result &= m_MixerContainer->addElement( |
---|
128 |
new BinaryControl(*this, |
---|
129 |
FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT12, FR_SAFFIREPRO_CMD_ID_BITFIELD_BIT_PAD, |
---|
130 |
"Out12Pad", "Out1/2 Pad", "Output 1/2 Active Monitor Pad")); |
---|
131 |
result &= m_MixerContainer->addElement( |
---|
132 |
new BinaryControl(*this, |
---|
133 |
FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT34, FR_SAFFIREPRO_CMD_ID_BITFIELD_BIT_PAD, |
---|
134 |
"Out34Pad", "Out3/4 Pad", "Output 3/4 Active Monitor Pad")); |
---|
135 |
result &= m_MixerContainer->addElement( |
---|
136 |
new BinaryControl(*this, |
---|
137 |
FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT56, FR_SAFFIREPRO_CMD_ID_BITFIELD_BIT_PAD, |
---|
138 |
"Out56Pad", "Out5/6 Pad", "Output 5/6 Active Monitor Pad")); |
---|
139 |
result &= m_MixerContainer->addElement( |
---|
140 |
new BinaryControl(*this, |
---|
141 |
FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT78, FR_SAFFIREPRO_CMD_ID_BITFIELD_BIT_PAD, |
---|
142 |
"Out78Pad", "Out7/8 Pad", "Output 7/8 Active Monitor Pad")); |
---|
143 |
|
---|
144 |
// output level dim |
---|
145 |
result &= m_MixerContainer->addElement( |
---|
146 |
new BinaryControl(*this, |
---|
147 |
FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT12, FR_SAFFIREPRO_CMD_ID_BITFIELD_BIT_PAD, |
---|
148 |
"Out12Dim", "Out1/2 Dim", "Output 1/2 Level Dim")); |
---|
149 |
result &= m_MixerContainer->addElement( |
---|
150 |
new BinaryControl(*this, |
---|
151 |
FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT34, FR_SAFFIREPRO_CMD_ID_BITFIELD_BIT_PAD, |
---|
152 |
"Out34Dim", "Out3/4 Dim", "Output 3/4 Level Dim")); |
---|
153 |
result &= m_MixerContainer->addElement( |
---|
154 |
new BinaryControl(*this, |
---|
155 |
FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT56, FR_SAFFIREPRO_CMD_ID_BITFIELD_BIT_PAD, |
---|
156 |
"Out56Dim", "Out5/6 Dim", "Output 5/6 Level Dim")); |
---|
157 |
result &= m_MixerContainer->addElement( |
---|
158 |
new BinaryControl(*this, |
---|
159 |
FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT78, FR_SAFFIREPRO_CMD_ID_BITFIELD_BIT_PAD, |
---|
160 |
"Out78Dim", "Out7/8 Dim", "Output 7/8 Level Dim")); |
---|
161 |
|
---|
162 |
// indicators |
---|
163 |
result &= m_MixerContainer->addElement( |
---|
164 |
new BinaryControl(*this, |
---|
165 |
FR_SAFFIREPRO_CMD_ID_MUTE_INDICATOR, 0, |
---|
166 |
"Out12MuteInd", "Out1/2 Mute Ind", "Output 1/2 Mute Indicator")); |
---|
167 |
|
---|
168 |
result &= m_MixerContainer->addElement( |
---|
169 |
new BinaryControl(*this, |
---|
170 |
FR_SAFFIREPRO_CMD_ID_DIM_INDICATOR, 0, |
---|
171 |
"Out12DimInd", "Out1/2 Dim Ind", "Output 1/2 Level Dim Indicator")); |
---|
172 |
|
---|
173 |
// matrix mix controls |
---|
174 |
result &= m_MixerContainer->addElement( |
---|
175 |
new SaffireProMatrixMixer(*this, SaffireProMatrixMixer::eMMT_InputMix, "InputMix")); |
---|
176 |
|
---|
177 |
result &= m_MixerContainer->addElement( |
---|
178 |
new SaffireProMatrixMixer(*this, SaffireProMatrixMixer::eMMT_OutputMix, "OutputMix")); |
---|
179 |
|
---|
180 |
if (!result) { |
---|
181 |
debugWarning("One or more control elements could not be created."); |
---|
182 |
// clean up those that couldn't be created |
---|
183 |
destroyMixer(); |
---|
184 |
return false; |
---|
185 |
} |
---|
186 |
|
---|
187 |
if (!addElement(m_MixerContainer)) { |
---|
188 |
debugWarning("Could not register mixer to device\n"); |
---|
189 |
// clean up |
---|
190 |
destroyMixer(); |
---|
191 |
return false; |
---|
192 |
} |
---|
193 |
|
---|
194 |
return true; |
---|
195 |
} |
---|
196 |
|
---|
197 |
bool |
---|
198 |
SaffireProDevice::destroyMixer() |
---|
199 |
{ |
---|
200 |
debugOutput(DEBUG_LEVEL_VERBOSE, "destroy mixer...\n"); |
---|
201 |
|
---|
202 |
if (m_MixerContainer == NULL) { |
---|
203 |
debugOutput(DEBUG_LEVEL_VERBOSE, "no mixer to destroy...\n"); |
---|
204 |
return true; |
---|
205 |
} |
---|
206 |
|
---|
207 |
if (!deleteElement(m_MixerContainer)) { |
---|
208 |
debugError("Mixer present but not registered to the avdevice\n"); |
---|
209 |
return false; |
---|
210 |
} |
---|
211 |
|
---|
212 |
// remove and delete (as in free) child control elements |
---|
213 |
m_MixerContainer->clearElements(true); |
---|
214 |
delete m_MixerContainer; |
---|
215 |
return true; |
---|
216 |
} |
---|
217 |
|
---|
218 |
void |
---|
219 |
SaffireProDevice::showDevice() |
---|
220 |
{ |
---|
221 |
debugOutput(DEBUG_LEVEL_NORMAL, "This is a BeBoB::Focusrite::SaffireProDevice\n"); |
---|
222 |
FocusriteDevice::showDevice(); |
---|
223 |
} |
---|
224 |
|
---|
225 |
void |
---|
226 |
SaffireProDevice::setVerboseLevel(int l) |
---|
227 |
{ |
---|
228 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); |
---|
229 |
|
---|
230 |
if (m_MixerContainer) m_MixerContainer->setVerboseLevel(l); |
---|
231 |
|
---|
232 |
// FIXME: add the other elements here too |
---|
233 |
|
---|
234 |
FocusriteDevice::setVerboseLevel(l); |
---|
235 |
} |
---|
236 |
|
---|
237 |
int |
---|
238 |
SaffireProDevice::getSamplingFrequency( ) { |
---|
239 |
uint32_t sr; |
---|
240 |
if ( !getSpecificValue(FR_SAFFIREPRO_CMD_ID_SAMPLERATE, &sr ) ) { |
---|
241 |
debugError( "getSpecificValue failed\n" ); |
---|
242 |
return 0; |
---|
243 |
} |
---|
244 |
|
---|
245 |
debugOutput( DEBUG_LEVEL_NORMAL, |
---|
246 |
"getSampleRate: %d\n", sr ); |
---|
247 |
|
---|
248 |
return convertDefToSr(sr); |
---|
249 |
} |
---|
250 |
|
---|
251 |
bool |
---|
252 |
SaffireProDevice::setSamplingFrequencyDo( int s ) |
---|
253 |
{ |
---|
254 |
uint32_t value=convertSrToDef(s); |
---|
255 |
if ( !setSpecificValue(FR_SAFFIREPRO_CMD_ID_SAMPLERATE, value) ) { |
---|
256 |
debugError( "setSpecificValue failed\n" ); |
---|
257 |
return false; |
---|
258 |
} |
---|
259 |
return true; |
---|
260 |
} |
---|
261 |
|
---|
262 |
// FIXME: this is not really documented, and is an assumtion |
---|
263 |
int |
---|
264 |
SaffireProDevice::getSamplingFrequencyMirror( ) { |
---|
265 |
uint32_t sr; |
---|
266 |
if ( !getSpecificValue(FR_SAFFIREPRO_CMD_ID_SAMPLERATE_MIRROR, &sr ) ) { |
---|
267 |
debugError( "getSpecificValue failed\n" ); |
---|
268 |
return 0; |
---|
269 |
} |
---|
270 |
|
---|
271 |
debugOutput( DEBUG_LEVEL_NORMAL, |
---|
272 |
"getSampleRateMirror: %d\n", sr ); |
---|
273 |
|
---|
274 |
return convertDefToSr(sr); |
---|
275 |
} |
---|
276 |
|
---|
277 |
bool |
---|
278 |
SaffireProDevice::setSamplingFrequency( int s ) |
---|
279 |
{ |
---|
280 |
bool snoopMode=false; |
---|
281 |
if(!getOption("snoopMode", snoopMode)) { |
---|
282 |
debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); |
---|
283 |
} |
---|
284 |
|
---|
285 |
if(snoopMode) { |
---|
286 |
int current_sr=getSamplingFrequency(); |
---|
287 |
if (current_sr != s ) { |
---|
288 |
debugError("In snoop mode it is impossible to set the sample rate.\n"); |
---|
289 |
debugError("Please start the client with the correct setting.\n"); |
---|
290 |
return false; |
---|
291 |
} |
---|
292 |
return true; |
---|
293 |
} else { |
---|
294 |
const int max_tries=2; |
---|
295 |
int ntries=max_tries+1; |
---|
296 |
while(--ntries) { |
---|
297 |
if(!setSamplingFrequencyDo( s )) { |
---|
298 |
debugWarning("setSamplingFrequencyDo failed\n"); |
---|
299 |
} |
---|
300 |
|
---|
301 |
int timeout=10; // multiples of 1s |
---|
302 |
while(timeout--) { |
---|
303 |
// wait for a while |
---|
304 |
usleep(1000 * 1000); |
---|
305 |
|
---|
306 |
// we should figure out how long to wait before the device |
---|
307 |
// becomes available again |
---|
308 |
|
---|
309 |
// check device status |
---|
310 |
// if (discover()) break; |
---|
311 |
if (timeout==5) break; |
---|
312 |
} |
---|
313 |
|
---|
314 |
if(timeout) { |
---|
315 |
int verify=getSamplingFrequency(); |
---|
316 |
|
---|
317 |
debugOutput( DEBUG_LEVEL_NORMAL, |
---|
318 |
"setSampleRate (try %d): requested samplerate %d, device now has %d\n", |
---|
319 |
max_tries-ntries, s, verify ); |
---|
320 |
|
---|
321 |
if (s == verify) { |
---|
322 |
break; |
---|
323 |
} |
---|
324 |
} |
---|
325 |
} |
---|
326 |
|
---|
327 |
if (ntries==0) { |
---|
328 |
debugError("Setting samplerate failed...\n"); |
---|
329 |
return false; |
---|
330 |
} |
---|
331 |
|
---|
332 |
// rediscover the device |
---|
333 |
// return discover(); |
---|
334 |
return true; |
---|
335 |
} |
---|
336 |
// not executable |
---|
337 |
return false; |
---|
338 |
|
---|
339 |
} |
---|
340 |
|
---|
341 |
bool |
---|
342 |
SaffireProDevice::isStreaming() { |
---|
343 |
uint32_t ready; |
---|
344 |
if ( !getSpecificValue(FR_SAFFIREPRO_CMD_ID_STREAMING, &ready ) ) { |
---|
345 |
debugError( "getSpecificValue failed\n" ); |
---|
346 |
return false; |
---|
347 |
} |
---|
348 |
|
---|
349 |
debugOutput( DEBUG_LEVEL_NORMAL, |
---|
350 |
"isDeviceReady: %d\n", ready!=0 ); |
---|
351 |
return ready != 0; |
---|
352 |
} |
---|
353 |
|
---|
354 |
|
---|
355 |
// Saffire pro matrix mixer element |
---|
356 |
|
---|
357 |
SaffireProMatrixMixer::SaffireProMatrixMixer(SaffireProDevice& p, |
---|
358 |
enum eMatrixMixerType type) |
---|
359 |
: Control::MatrixMixer("MatrixMixer") |
---|
360 |
, m_Parent(p) |
---|
361 |
, m_type(type) |
---|
362 |
{ |
---|
363 |
init(type); |
---|
364 |
} |
---|
365 |
|
---|
366 |
SaffireProMatrixMixer::SaffireProMatrixMixer(SaffireProDevice& p, |
---|
367 |
enum eMatrixMixerType type, std::string n) |
---|
368 |
: Control::MatrixMixer(n) |
---|
369 |
, m_Parent(p) |
---|
370 |
, m_type(type) |
---|
371 |
{ |
---|
372 |
init(type); |
---|
373 |
} |
---|
374 |
|
---|
375 |
void SaffireProMatrixMixer::addSignalInfo(std::vector<struct sSignalInfo> &target, |
---|
376 |
std::string name, std::string label, std::string descr) |
---|
377 |
{ |
---|
378 |
struct sSignalInfo s; |
---|
379 |
s.name=name; |
---|
380 |
s.label=label; |
---|
381 |
s.description=descr; |
---|
382 |
|
---|
383 |
target.push_back(s); |
---|
384 |
} |
---|
385 |
|
---|
386 |
void SaffireProMatrixMixer::setCellInfo(int row, int col, int addr, bool valid) |
---|
387 |
{ |
---|
388 |
struct sCellInfo c; |
---|
389 |
c.row=row; |
---|
390 |
c.col=col; |
---|
391 |
c.valid=valid; |
---|
392 |
c.address=addr; |
---|
393 |
|
---|
394 |
m_CellInfo[row][col]=c; |
---|
395 |
} |
---|
396 |
|
---|
397 |
void SaffireProMatrixMixer::init(enum eMatrixMixerType type) |
---|
398 |
{ |
---|
399 |
if (type==eMMT_OutputMix) { |
---|
400 |
addSignalInfo(m_RowInfo, "PC1", "PC 1", "PC Channel 1"); |
---|
401 |
addSignalInfo(m_RowInfo, "PC2", "PC 2", "PC Channel 2"); |
---|
402 |
addSignalInfo(m_RowInfo, "PC3", "PC 3", "PC Channel 3"); |
---|
403 |
addSignalInfo(m_RowInfo, "PC4", "PC 4", "PC Channel 4"); |
---|
404 |
addSignalInfo(m_RowInfo, "PC5", "PC 5", "PC Channel 5"); |
---|
405 |
addSignalInfo(m_RowInfo, "PC6", "PC 6", "PC Channel 6"); |
---|
406 |
addSignalInfo(m_RowInfo, "PC7", "PC 7", "PC Channel 7"); |
---|
407 |
addSignalInfo(m_RowInfo, "PC8", "PC 8", "PC Channel 8"); |
---|
408 |
addSignalInfo(m_RowInfo, "PC9", "PC 9", "PC Channel 9"); |
---|
409 |
addSignalInfo(m_RowInfo, "PC10", "PC 10", "PC Channel 10"); |
---|
410 |
addSignalInfo(m_RowInfo, "IMIXL", "IMix L", "Input Mix Left"); |
---|
411 |
addSignalInfo(m_RowInfo, "IMIXR", "IMix R", "Input Mix Right"); |
---|
412 |
|
---|
413 |
addSignalInfo(m_ColInfo, "OUT1", "OUT 1", "Output Channel 1"); |
---|
414 |
addSignalInfo(m_ColInfo, "OUT2", "OUT 2", "Output Channel 2"); |
---|
415 |
addSignalInfo(m_ColInfo, "OUT3", "OUT 3", "Output Channel 3"); |
---|
416 |
addSignalInfo(m_ColInfo, "OUT4", "OUT 4", "Output Channel 4"); |
---|
417 |
addSignalInfo(m_ColInfo, "OUT5", "OUT 5", "Output Channel 5"); |
---|
418 |
addSignalInfo(m_ColInfo, "OUT6", "OUT 6", "Output Channel 6"); |
---|
419 |
addSignalInfo(m_ColInfo, "OUT7", "OUT 7", "Output Channel 7"); |
---|
420 |
addSignalInfo(m_ColInfo, "OUT8", "OUT 8", "Output Channel 8"); |
---|
421 |
addSignalInfo(m_ColInfo, "OUT9", "OUT 9", "Output Channel 9"); |
---|
422 |
addSignalInfo(m_ColInfo, "OUT10", "OUT 10", "Output Channel 10"); |
---|
423 |
|
---|
424 |
// init the cell matrix |
---|
425 |
#define FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_COLS 10 |
---|
426 |
#define FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_ROWS 12 |
---|
427 |
|
---|
428 |
std::vector<struct sCellInfo> tmp_cols( FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_COLS ); |
---|
429 |
std::vector< std::vector<struct sCellInfo> > tmp_all(FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_ROWS, tmp_cols); |
---|
430 |
m_CellInfo = tmp_all; |
---|
431 |
|
---|
432 |
struct sCellInfo c; |
---|
433 |
c.row=-1; |
---|
434 |
c.col=-1; |
---|
435 |
c.valid=false; |
---|
436 |
c.address=0; |
---|
437 |
|
---|
438 |
for (int i=0;i<FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_ROWS;i++) { |
---|
439 |
for (int j=0;j<FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_COLS;j++) { |
---|
440 |
m_CellInfo[i][j]=c; |
---|
441 |
} |
---|
442 |
} |
---|
443 |
|
---|
444 |
// now set the cells that are valid |
---|
445 |
setCellInfo(0,0,FR_SAFFIREPRO_CMD_ID_PC1_TO_OUT1, true); |
---|
446 |
setCellInfo(1,1,FR_SAFFIREPRO_CMD_ID_PC2_TO_OUT2, true); |
---|
447 |
setCellInfo(10,0,FR_SAFFIREPRO_CMD_ID_MIX1_TO_OUT1, true); |
---|
448 |
setCellInfo(11,1,FR_SAFFIREPRO_CMD_ID_MIX2_TO_OUT2, true); |
---|
449 |
setCellInfo(0,2,FR_SAFFIREPRO_CMD_ID_PC1_TO_OUT3, true); |
---|
450 |
setCellInfo(1,3,FR_SAFFIREPRO_CMD_ID_PC2_TO_OUT4, true); |
---|
451 |
setCellInfo(2,2,FR_SAFFIREPRO_CMD_ID_PC3_TO_OUT3, true); |
---|
452 |
setCellInfo(3,3,FR_SAFFIREPRO_CMD_ID_PC4_TO_OUT4, true); |
---|
453 |
setCellInfo(10,2,FR_SAFFIREPRO_CMD_ID_MIX1_TO_OUT3, true); |
---|
454 |
setCellInfo(11,3,FR_SAFFIREPRO_CMD_ID_MIX2_TO_OUT4, true); |
---|
455 |
setCellInfo(0,4,FR_SAFFIREPRO_CMD_ID_PC1_TO_OUT5, true); |
---|
456 |
setCellInfo(1,5,FR_SAFFIREPRO_CMD_ID_PC2_TO_OUT6, true); |
---|
457 |
setCellInfo(4,4,FR_SAFFIREPRO_CMD_ID_PC5_TO_OUT5, true); |
---|
458 |
setCellInfo(5,5,FR_SAFFIREPRO_CMD_ID_PC6_TO_OUT6, true); |
---|
459 |
setCellInfo(10,4,FR_SAFFIREPRO_CMD_ID_MIX1_TO_OUT5, true); |
---|
460 |
setCellInfo(11,5,FR_SAFFIREPRO_CMD_ID_MIX2_TO_OUT6, true); |
---|
461 |
setCellInfo(0,6,FR_SAFFIREPRO_CMD_ID_PC1_TO_OUT7, true); |
---|
462 |
setCellInfo(1,7,FR_SAFFIREPRO_CMD_ID_PC2_TO_OUT8, true); |
---|
463 |
setCellInfo(6,6,FR_SAFFIREPRO_CMD_ID_PC7_TO_OUT7, true); |
---|
464 |
setCellInfo(7,7,FR_SAFFIREPRO_CMD_ID_PC8_TO_OUT8, true); |
---|
465 |
setCellInfo(10,6,FR_SAFFIREPRO_CMD_ID_MIX1_TO_OUT7, true); |
---|
466 |
setCellInfo(11,7,FR_SAFFIREPRO_CMD_ID_MIX2_TO_OUT8, true); |
---|
467 |
setCellInfo(0,8,FR_SAFFIREPRO_CMD_ID_PC1_TO_OUT9, true); |
---|
468 |
setCellInfo(1,9,FR_SAFFIREPRO_CMD_ID_PC2_TO_OUT10, true); |
---|
469 |
setCellInfo(8,8,FR_SAFFIREPRO_CMD_ID_PC9_TO_OUT9, true); |
---|
470 |
setCellInfo(9,9,FR_SAFFIREPRO_CMD_ID_PC10_TO_OUT10, true); |
---|
471 |
setCellInfo(10,8,FR_SAFFIREPRO_CMD_ID_MIX1_TO_OUT9, true); |
---|
472 |
setCellInfo(11,9,FR_SAFFIREPRO_CMD_ID_MIX2_TO_OUT10, true); |
---|
473 |
|
---|
474 |
} else if (type==eMMT_InputMix) { |
---|
475 |
addSignalInfo(m_RowInfo, "AN1", "Analog 1", "Analog Input 1"); |
---|
476 |
addSignalInfo(m_RowInfo, "AN2", "Analog 2", "Analog Input 2"); |
---|
477 |
addSignalInfo(m_RowInfo, "AN3", "Analog 3", "Analog Input 3"); |
---|
478 |
addSignalInfo(m_RowInfo, "AN4", "Analog 4", "Analog Input 4"); |
---|
479 |
addSignalInfo(m_RowInfo, "AN5", "Analog 5", "Analog Input 5"); |
---|
480 |
addSignalInfo(m_RowInfo, "AN6", "Analog 6", "Analog Input 6"); |
---|
481 |
addSignalInfo(m_RowInfo, "AN7", "Analog 7", "Analog Input 7"); |
---|
482 |
addSignalInfo(m_RowInfo, "AN8", "Analog 8", "Analog Input 8"); |
---|
483 |
addSignalInfo(m_RowInfo, "SPDIFL", "SPDIF L", "SPDIF Left Input"); |
---|
484 |
addSignalInfo(m_RowInfo, "SPDIFR", "SPDIF R", "SPDIF Right Input"); |
---|
485 |
|
---|
486 |
addSignalInfo(m_RowInfo, "ADAT11", "ADAT1 1", "ADAT1 Channel 1"); |
---|
487 |
addSignalInfo(m_RowInfo, "ADAT12", "ADAT1 2", "ADAT1 Channel 2"); |
---|
488 |
addSignalInfo(m_RowInfo, "ADAT13", "ADAT1 3", "ADAT1 Channel 3"); |
---|
489 |
addSignalInfo(m_RowInfo, "ADAT14", "ADAT1 4", "ADAT1 Channel 4"); |
---|
490 |
addSignalInfo(m_RowInfo, "ADAT15", "ADAT1 5", "ADAT1 Channel 5"); |
---|
491 |
addSignalInfo(m_RowInfo, "ADAT16", "ADAT1 6", "ADAT1 Channel 6"); |
---|
492 |
addSignalInfo(m_RowInfo, "ADAT17", "ADAT1 7", "ADAT1 Channel 7"); |
---|
493 |
addSignalInfo(m_RowInfo, "ADAT18", "ADAT1 8", "ADAT1 Channel 8"); |
---|
494 |
|
---|
495 |
addSignalInfo(m_RowInfo, "ADAT21", "ADAT2 1", "ADAT2 Channel 1"); |
---|
496 |
addSignalInfo(m_RowInfo, "ADAT22", "ADAT2 2", "ADAT2 Channel 2"); |
---|
497 |
addSignalInfo(m_RowInfo, "ADAT23", "ADAT2 3", "ADAT2 Channel 3"); |
---|
498 |
addSignalInfo(m_RowInfo, "ADAT24", "ADAT2 4", "ADAT2 Channel 4"); |
---|
499 |
addSignalInfo(m_RowInfo, "ADAT25", "ADAT2 5", "ADAT2 Channel 5"); |
---|
500 |
addSignalInfo(m_RowInfo, "ADAT26", "ADAT2 6", "ADAT2 Channel 6"); |
---|
501 |
addSignalInfo(m_RowInfo, "ADAT27", "ADAT2 7", "ADAT2 Channel 7"); |
---|
502 |
addSignalInfo(m_RowInfo, "ADAT28", "ADAT2 8", "ADAT2 Channel 8"); |
---|
503 |
|
---|
504 |
addSignalInfo(m_ColInfo, "IMIXL", "IMix L", "Input Mix Left"); |
---|
505 |
addSignalInfo(m_ColInfo, "IMIXR", "IMix R", "Input Mix Right"); |
---|
506 |
|
---|
507 |
// init the cell matrix |
---|
508 |
#define FOCUSRITE_SAFFIRE_PRO_INMIX_NB_COLS 2 |
---|
509 |
#define FOCUSRITE_SAFFIRE_PRO_INMIX_NB_ROWS 26 |
---|
510 |
|
---|
511 |
std::vector<struct sCellInfo> tmp_cols( FOCUSRITE_SAFFIRE_PRO_INMIX_NB_COLS ); |
---|
512 |
std::vector< std::vector<struct sCellInfo> > tmp_all(FOCUSRITE_SAFFIRE_PRO_INMIX_NB_ROWS,tmp_cols); |
---|
513 |
m_CellInfo = tmp_all; |
---|
514 |
|
---|
515 |
struct sCellInfo c; |
---|
516 |
c.row=-1; |
---|
517 |
c.col=-1; |
---|
518 |
c.valid=false; |
---|
519 |
c.address=0; |
---|
520 |
|
---|
521 |
for (int i=0;i<FOCUSRITE_SAFFIRE_PRO_INMIX_NB_ROWS;i++) { |
---|
522 |
for (int j=0;j<FOCUSRITE_SAFFIRE_PRO_INMIX_NB_COLS;j++) { |
---|
523 |
m_CellInfo[i][j]=c; |
---|
524 |
} |
---|
525 |
} |
---|
526 |
|
---|
527 |
// now set the cells that are valid |
---|
528 |
setCellInfo(0,0,FR_SAFFIREPRO_CMD_ID_AN1_TO_IMIXL, true); |
---|
529 |
setCellInfo(0,1,FR_SAFFIREPRO_CMD_ID_AN1_TO_IMIXR, true); |
---|
530 |
setCellInfo(1,0,FR_SAFFIREPRO_CMD_ID_AN2_TO_IMIXL, true); |
---|
531 |
setCellInfo(1,1,FR_SAFFIREPRO_CMD_ID_AN2_TO_IMIXR, true); |
---|
532 |
setCellInfo(2,0,FR_SAFFIREPRO_CMD_ID_AN3_TO_IMIXL, true); |
---|
533 |
setCellInfo(2,1,FR_SAFFIREPRO_CMD_ID_AN3_TO_IMIXR, true); |
---|
534 |
setCellInfo(3,0,FR_SAFFIREPRO_CMD_ID_AN4_TO_IMIXL, true); |
---|
535 |
setCellInfo(3,1,FR_SAFFIREPRO_CMD_ID_AN4_TO_IMIXR, true); |
---|
536 |
setCellInfo(4,0,FR_SAFFIREPRO_CMD_ID_AN5_TO_IMIXL, true); |
---|
537 |
setCellInfo(4,1,FR_SAFFIREPRO_CMD_ID_AN5_TO_IMIXR, true); |
---|
538 |
setCellInfo(5,0,FR_SAFFIREPRO_CMD_ID_AN6_TO_IMIXL, true); |
---|
539 |
setCellInfo(5,1,FR_SAFFIREPRO_CMD_ID_AN6_TO_IMIXR, true); |
---|
540 |
setCellInfo(6,0,FR_SAFFIREPRO_CMD_ID_AN7_TO_IMIXL, true); |
---|
541 |
setCellInfo(6,1,FR_SAFFIREPRO_CMD_ID_AN7_TO_IMIXR, true); |
---|
542 |
setCellInfo(7,0,FR_SAFFIREPRO_CMD_ID_AN8_TO_IMIXL, true); |
---|
543 |
setCellInfo(7,1,FR_SAFFIREPRO_CMD_ID_AN8_TO_IMIXR, true); |
---|
544 |
setCellInfo(8,0,FR_SAFFIREPRO_CMD_ID_SPDIFL_TO_IMIXL, true); |
---|
545 |
setCellInfo(8,1,FR_SAFFIREPRO_CMD_ID_SPDIFL_TO_IMIXR, true); |
---|
546 |
setCellInfo(9,0,FR_SAFFIREPRO_CMD_ID_SPDIFR_TO_IMIXL, true); |
---|
547 |
setCellInfo(9,1,FR_SAFFIREPRO_CMD_ID_SPDIFR_TO_IMIXR, true); |
---|
548 |
|
---|
549 |
setCellInfo(10,0,FR_SAFFIREPRO_CMD_ID_ADAT11_TO_IMIXL, true); |
---|
550 |
setCellInfo(10,1,FR_SAFFIREPRO_CMD_ID_ADAT11_TO_IMIXR, true); |
---|
551 |
setCellInfo(11,0,FR_SAFFIREPRO_CMD_ID_ADAT12_TO_IMIXL, true); |
---|
552 |
setCellInfo(11,1,FR_SAFFIREPRO_CMD_ID_ADAT12_TO_IMIXR, true); |
---|
553 |
setCellInfo(12,0,FR_SAFFIREPRO_CMD_ID_ADAT13_TO_IMIXL, true); |
---|
554 |
setCellInfo(12,1,FR_SAFFIREPRO_CMD_ID_ADAT13_TO_IMIXR, true); |
---|
555 |
setCellInfo(13,0,FR_SAFFIREPRO_CMD_ID_ADAT14_TO_IMIXL, true); |
---|
556 |
setCellInfo(13,1,FR_SAFFIREPRO_CMD_ID_ADAT14_TO_IMIXR, true); |
---|
557 |
setCellInfo(14,0,FR_SAFFIREPRO_CMD_ID_ADAT15_TO_IMIXL, true); |
---|
558 |
setCellInfo(14,1,FR_SAFFIREPRO_CMD_ID_ADAT15_TO_IMIXR, true); |
---|
559 |
setCellInfo(15,0,FR_SAFFIREPRO_CMD_ID_ADAT16_TO_IMIXL, true); |
---|
560 |
setCellInfo(15,1,FR_SAFFIREPRO_CMD_ID_ADAT16_TO_IMIXR, true); |
---|
561 |
setCellInfo(16,0,FR_SAFFIREPRO_CMD_ID_ADAT17_TO_IMIXL, true); |
---|
562 |
setCellInfo(16,1,FR_SAFFIREPRO_CMD_ID_ADAT17_TO_IMIXR, true); |
---|
563 |
setCellInfo(17,0,FR_SAFFIREPRO_CMD_ID_ADAT18_TO_IMIXL, true); |
---|
564 |
setCellInfo(17,1,FR_SAFFIREPRO_CMD_ID_ADAT18_TO_IMIXR, true); |
---|
565 |
|
---|
566 |
setCellInfo(18,0,FR_SAFFIREPRO_CMD_ID_ADAT21_TO_IMIXL, true); |
---|
567 |
setCellInfo(18,1,FR_SAFFIREPRO_CMD_ID_ADAT21_TO_IMIXR, true); |
---|
568 |
setCellInfo(19,0,FR_SAFFIREPRO_CMD_ID_ADAT22_TO_IMIXL, true); |
---|
569 |
setCellInfo(19,1,FR_SAFFIREPRO_CMD_ID_ADAT22_TO_IMIXR, true); |
---|
570 |
setCellInfo(20,0,FR_SAFFIREPRO_CMD_ID_ADAT23_TO_IMIXL, true); |
---|
571 |
setCellInfo(20,1,FR_SAFFIREPRO_CMD_ID_ADAT23_TO_IMIXR, true); |
---|
572 |
setCellInfo(21,0,FR_SAFFIREPRO_CMD_ID_ADAT24_TO_IMIXL, true); |
---|
573 |
setCellInfo(21,1,FR_SAFFIREPRO_CMD_ID_ADAT24_TO_IMIXR, true); |
---|
574 |
setCellInfo(22,0,FR_SAFFIREPRO_CMD_ID_ADAT25_TO_IMIXL, true); |
---|
575 |
setCellInfo(22,1,FR_SAFFIREPRO_CMD_ID_ADAT25_TO_IMIXR, true); |
---|
576 |
setCellInfo(23,0,FR_SAFFIREPRO_CMD_ID_ADAT26_TO_IMIXL, true); |
---|
577 |
setCellInfo(23,1,FR_SAFFIREPRO_CMD_ID_ADAT26_TO_IMIXR, true); |
---|
578 |
setCellInfo(24,0,FR_SAFFIREPRO_CMD_ID_ADAT27_TO_IMIXL, true); |
---|
579 |
setCellInfo(24,1,FR_SAFFIREPRO_CMD_ID_ADAT27_TO_IMIXR, true); |
---|
580 |
setCellInfo(25,0,FR_SAFFIREPRO_CMD_ID_ADAT28_TO_IMIXL, true); |
---|
581 |
setCellInfo(25,1,FR_SAFFIREPRO_CMD_ID_ADAT28_TO_IMIXR, true); |
---|
582 |
|
---|
583 |
} else { |
---|
584 |
debugError("Invalid mixer type\n"); |
---|
585 |
} |
---|
586 |
} |
---|
587 |
|
---|
588 |
void SaffireProMatrixMixer::show() |
---|
589 |
{ |
---|
590 |
debugOutput(DEBUG_LEVEL_NORMAL, "Saffire Pro Matrix mixer type %d\n"); |
---|
591 |
} |
---|
592 |
|
---|
593 |
std::string SaffireProMatrixMixer::getRowName( const int row ) |
---|
594 |
{ |
---|
595 |
debugOutput(DEBUG_LEVEL_VERBOSE, "name for row %d is %s\n", |
---|
596 |
row, m_RowInfo.at(row).name.c_str()); |
---|
597 |
return m_RowInfo.at(row).name; |
---|
598 |
} |
---|
599 |
|
---|
600 |
std::string SaffireProMatrixMixer::getColName( const int col ) |
---|
601 |
{ |
---|
602 |
debugOutput(DEBUG_LEVEL_VERBOSE, "name for col %d is %s\n", |
---|
603 |
col, m_ColInfo.at(col).name.c_str()); |
---|
604 |
return m_ColInfo.at(col).name; |
---|
605 |
} |
---|
606 |
|
---|
607 |
int SaffireProMatrixMixer::canWrite( const int row, const int col ) |
---|
608 |
{ |
---|
609 |
debugOutput(DEBUG_LEVEL_VERBOSE, "canWrite for row %d col %d is %d\n", |
---|
610 |
row, col, m_CellInfo.at(row).at(col).valid); |
---|
611 |
return m_CellInfo.at(row).at(col).valid; |
---|
612 |
} |
---|
613 |
|
---|
614 |
double SaffireProMatrixMixer::setValue( const int row, const int col, const double val ) |
---|
615 |
{ |
---|
616 |
int32_t v=val; |
---|
617 |
struct sCellInfo c=m_CellInfo.at(row).at(col); |
---|
618 |
|
---|
619 |
debugOutput(DEBUG_LEVEL_VERBOSE, "setValue for id %d row %d col %d to %lf (%ld)\n", |
---|
620 |
c.address, row, col, val, v); |
---|
621 |
|
---|
622 |
if (v>0x07FFF) v=0x07FFF; |
---|
623 |
else if (v<0) v=0; |
---|
624 |
|
---|
625 |
if ( !m_Parent.setSpecificValue(c.address, v) ) { |
---|
626 |
debugError( "setSpecificValue failed\n" ); |
---|
627 |
return false; |
---|
628 |
} else return true; |
---|
629 |
} |
---|
630 |
|
---|
631 |
double SaffireProMatrixMixer::getValue( const int row, const int col ) |
---|
632 |
{ |
---|
633 |
struct sCellInfo c=m_CellInfo.at(row).at(col); |
---|
634 |
uint32_t val=0; |
---|
635 |
|
---|
636 |
if ( !m_Parent.getSpecificValue(c.address, &val) ) { |
---|
637 |
debugError( "getSpecificValue failed\n" ); |
---|
638 |
return 0; |
---|
639 |
} else { |
---|
640 |
debugOutput(DEBUG_LEVEL_VERBOSE, "getValue for id %d row %d col %d = %lf\n", |
---|
641 |
c.address, row, col, val); |
---|
642 |
return val; |
---|
643 |
} |
---|
644 |
} |
---|
645 |
|
---|
646 |
int SaffireProMatrixMixer::getRowCount( ) |
---|
647 |
{ |
---|
648 |
return m_RowInfo.size(); |
---|
649 |
} |
---|
650 |
|
---|
651 |
int SaffireProMatrixMixer::getColCount( ) |
---|
652 |
{ |
---|
653 |
return m_ColInfo.size(); |
---|
654 |
} |
---|
655 |
|
---|
656 |
} // Focusrite |
---|
657 |
} // BeBoB |
---|