root/trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.cpp

Revision 653, 20.6 kB (checked in by ppalmers, 15 years ago)

- a first pass at Focusrite Saffire Pro mixer support. Note: the mixer only works when streaming.

Line 
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 {
34     debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::Focusrite::SaffireProDevice (NodeID %d)\n",
35                  getConfigRom().getNodeId() );
36
37     // the saffire pro doesn't seem to like it if the commands are too fast
38     if (AVC::AVCCommand::getSleepAfterAVCCommand() < 200) {
39         AVC::AVCCommand::setSleepAfterAVCCommand( 200 );
40     }
41
42     // create control objects for the saffire pro
43     m_Phantom1 = new BinaryControl(*this, FR_SAFFIREPRO_CMD_ID_PHANTOM14,
44                  "Phantom_1to4", "Phantom 1-4", "Switch Phantom Power on channels 1-4");
45     if (m_Phantom1) addElement(m_Phantom1);
46    
47     m_Phantom2 = new BinaryControl(*this, FR_SAFFIREPRO_CMD_ID_PHANTOM58,
48                  "Phantom_5to8", "Phantom 5-8", "Switch Phantom Power on channels 5-8");
49     if (m_Phantom2) addElement(m_Phantom2);
50    
51     m_Insert1 = new BinaryControl(*this, FR_SAFFIREPRO_CMD_ID_INSERT1,
52                 "Insert1", "Insert 1", "Switch Insert on Channel 1");
53     if (m_Insert1) addElement(m_Insert1);
54    
55     m_Insert2 = new BinaryControl(*this, FR_SAFFIREPRO_CMD_ID_INSERT2,
56                 "Insert2", "Insert 2", "Switch Insert on Channel 2");
57     if (m_Insert2) addElement(m_Insert2);
58    
59     m_AC3pass = new BinaryControl(*this, FR_SAFFIREPRO_CMD_ID_AC3_PASSTHROUGH,
60                 "AC3pass", "AC3 Passtrough", "Enable AC3 Passthrough");
61     if (m_AC3pass) addElement(m_AC3pass);
62    
63     m_MidiTru = new BinaryControl(*this, FR_SAFFIREPRO_CMD_ID_MIDI_TRU,
64                 "MidiTru", "Midi Tru", "Enable Midi Tru");
65     if (m_MidiTru) addElement(m_MidiTru);
66
67     // matrix mix controls
68     m_InputMixer=new SaffireProMatrixMixer(*this, SaffireProMatrixMixer::eMMT_InputMix, "InputMix");
69     if (m_InputMixer) addElement(m_InputMixer);
70    
71     m_OutputMixer=new SaffireProMatrixMixer(*this, SaffireProMatrixMixer::eMMT_OutputMix, "OutputMix");
72     if (m_OutputMixer) addElement(m_OutputMixer);
73 }
74
75 SaffireProDevice::~SaffireProDevice()
76 {
77     // remove and delete control elements
78     deleteElement(m_Phantom1);
79     if (m_Phantom1) delete m_Phantom1;
80    
81     deleteElement(m_Phantom2);
82     if (m_Phantom2) delete m_Phantom2;
83    
84     deleteElement(m_Insert1);
85     if (m_Insert1) delete m_Insert1;
86    
87     deleteElement(m_Insert2);
88     if (m_Insert2) delete m_Insert2;
89    
90     deleteElement(m_AC3pass);
91     if (m_AC3pass) delete m_AC3pass;
92    
93     deleteElement(m_MidiTru);
94     if (m_MidiTru) delete m_MidiTru;
95    
96     deleteElement(m_InputMixer);
97     if (m_InputMixer) delete m_InputMixer;
98    
99     deleteElement(m_OutputMixer);
100     if (m_OutputMixer) delete m_OutputMixer;
101 }
102
103 void
104 SaffireProDevice::showDevice()
105 {
106     debugOutput(DEBUG_LEVEL_NORMAL, "This is a BeBoB::Focusrite::SaffireProDevice\n");
107     FocusriteDevice::showDevice();
108 }
109
110 void
111 SaffireProDevice::setVerboseLevel(int l)
112 {
113     debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l );
114
115     if (m_Phantom1) m_Phantom2->setVerboseLevel(l);
116     if (m_Phantom2) m_Phantom2->setVerboseLevel(l);
117     if (m_Insert1) m_Insert1->setVerboseLevel(l);
118     if (m_Insert2) m_Insert2->setVerboseLevel(l);
119     if (m_MidiTru) m_MidiTru->setVerboseLevel(l);
120     if (m_AC3pass) m_AC3pass->setVerboseLevel(l);
121     if (m_InputMixer) m_InputMixer->setVerboseLevel(l);
122     if (m_OutputMixer) m_OutputMixer->setVerboseLevel(l);
123
124     // FIXME: add the other elements here too
125
126     FocusriteDevice::setVerboseLevel(l);
127 }
128
129 int
130 SaffireProDevice::getSamplingFrequency( ) {
131     uint32_t sr;
132     if ( !getSpecificValue(FR_SAFFIREPRO_CMD_ID_SAMPLERATE, &sr ) ) {
133         debugError( "getSpecificValue failed\n" );
134         return 0;
135     }
136    
137     debugOutput( DEBUG_LEVEL_NORMAL,
138                      "getSampleRate: %d\n", sr );
139
140     return convertDefToSr(sr);
141 }
142
143 bool
144 SaffireProDevice::setSamplingFrequencyDo( int s )
145 {
146     uint32_t value=convertSrToDef(s);
147     if ( !setSpecificValue(FR_SAFFIREPRO_CMD_ID_SAMPLERATE, value) ) {
148         debugError( "setSpecificValue failed\n" );
149         return false;
150     }
151     return true;
152 }
153
154 // FIXME: this is not really documented, and is an assumtion
155 int
156 SaffireProDevice::getSamplingFrequencyMirror( ) {
157     uint32_t sr;
158     if ( !getSpecificValue(FR_SAFFIREPRO_CMD_ID_SAMPLERATE_MIRROR, &sr ) ) {
159         debugError( "getSpecificValue failed\n" );
160         return 0;
161     }
162    
163     debugOutput( DEBUG_LEVEL_NORMAL,
164                      "getSampleRateMirror: %d\n", sr );
165
166     return convertDefToSr(sr);
167 }
168
169 bool
170 SaffireProDevice::setSamplingFrequency( int s )
171 {
172     bool snoopMode=false;
173     if(!getOption("snoopMode", snoopMode)) {
174         debugWarning("Could not retrieve snoopMode parameter, defauling to false\n");
175     }
176
177     if(snoopMode) {
178         int current_sr=getSamplingFrequency();
179         if (current_sr != s ) {
180             debugError("In snoop mode it is impossible to set the sample rate.\n");
181             debugError("Please start the client with the correct setting.\n");
182             return false;
183         }
184         return true;
185     } else {
186         const int max_tries=2;
187         int ntries=max_tries+1;
188         while(--ntries) {
189             if(!setSamplingFrequencyDo( s )) {
190                 debugWarning("setSamplingFrequencyDo failed\n");
191             }
192            
193             int timeout=10; // multiples of 1s
194 //             while(timeout--) {
195 //                 // wait for a while
196 //                 usleep(1000 * 1000);
197 //                 
198 //                 // we should figure out how long to wait before the device
199 //                 // becomes available again
200 //                 
201 //                 // rediscover the device
202 //                 if (discover()) break;
203 //
204 //             }
205            
206             if(timeout) {
207                 int verify=getSamplingFrequency();
208                
209                 debugOutput( DEBUG_LEVEL_NORMAL,
210                             "setSampleRate (try %d): requested samplerate %d, device now has %d\n",
211                             max_tries-ntries, s, verify );
212                            
213                 if (s == verify) break;
214             }
215         }
216        
217         if (ntries==0) {
218             debugError("Setting samplerate failed...\n");
219             return false;
220         }
221
222         return true;
223     }
224     // not executable
225     return false;
226
227 }
228
229
230 // Saffire pro matrix mixer element
231
232 SaffireProMatrixMixer::SaffireProMatrixMixer(SaffireProDevice& p,
233                                              enum eMatrixMixerType type)
234 : Control::MatrixMixer("MatrixMixer")
235 , m_Parent(p)
236 , m_type(type)
237 {
238     init(type);
239 }
240
241 SaffireProMatrixMixer::SaffireProMatrixMixer(SaffireProDevice& p,
242                                              enum eMatrixMixerType type, std::string n)
243 : Control::MatrixMixer(n)
244 , m_Parent(p)
245 , m_type(type)
246 {
247     init(type);
248 }
249
250 void SaffireProMatrixMixer::addSignalInfo(std::vector<struct sSignalInfo> &target,
251     std::string name, std::string label, std::string descr)
252 {
253     struct sSignalInfo s;
254     s.name=name;
255     s.label=label;
256     s.description=descr;
257
258     target.push_back(s);
259 }
260
261 void SaffireProMatrixMixer::setCellInfo(int row, int col, int addr, bool valid)
262 {
263     struct sCellInfo c;
264     c.row=row;
265     c.col=col;
266     c.valid=valid;
267     c.address=addr;
268
269     m_CellInfo[row][col]=c;
270 }
271
272 void SaffireProMatrixMixer::init(enum eMatrixMixerType type)
273 {
274     if (type==eMMT_OutputMix) {
275         addSignalInfo(m_RowInfo, "PC1", "PC 1", "PC Channel 1");
276         addSignalInfo(m_RowInfo, "PC2", "PC 2", "PC Channel 2");
277         addSignalInfo(m_RowInfo, "PC3", "PC 3", "PC Channel 3");
278         addSignalInfo(m_RowInfo, "PC4", "PC 4", "PC Channel 4");
279         addSignalInfo(m_RowInfo, "PC5", "PC 5", "PC Channel 5");
280         addSignalInfo(m_RowInfo, "PC6", "PC 6", "PC Channel 6");
281         addSignalInfo(m_RowInfo, "PC7", "PC 7", "PC Channel 7");
282         addSignalInfo(m_RowInfo, "PC8", "PC 8", "PC Channel 8");
283         addSignalInfo(m_RowInfo, "PC9", "PC 9", "PC Channel 9");
284         addSignalInfo(m_RowInfo, "PC10", "PC 10", "PC Channel 10");
285         addSignalInfo(m_RowInfo, "IMIXL", "IMix L", "Input Mix Left");
286         addSignalInfo(m_RowInfo, "IMIXR", "IMix R", "Input Mix Right");
287        
288         addSignalInfo(m_ColInfo, "OUT1", "OUT 1", "Output Channel 1");
289         addSignalInfo(m_ColInfo, "OUT2", "OUT 2", "Output Channel 2");
290         addSignalInfo(m_ColInfo, "OUT3", "OUT 3", "Output Channel 3");
291         addSignalInfo(m_ColInfo, "OUT4", "OUT 4", "Output Channel 4");
292         addSignalInfo(m_ColInfo, "OUT5", "OUT 5", "Output Channel 5");
293         addSignalInfo(m_ColInfo, "OUT6", "OUT 6", "Output Channel 6");
294         addSignalInfo(m_ColInfo, "OUT7", "OUT 7", "Output Channel 7");
295         addSignalInfo(m_ColInfo, "OUT8", "OUT 8", "Output Channel 8");
296         addSignalInfo(m_ColInfo, "OUT9", "OUT 9", "Output Channel 9");
297         addSignalInfo(m_ColInfo, "OUT10", "OUT 10", "Output Channel 10");
298        
299         // init the cell matrix
300         #define FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_COLS 10
301         #define FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_ROWS 12
302        
303         std::vector<struct sCellInfo> tmp_cols( FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_COLS );
304         std::vector< std::vector<struct sCellInfo> > tmp_all(FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_ROWS, tmp_cols);
305         m_CellInfo = tmp_all;
306    
307         struct sCellInfo c;
308         c.row=-1;
309         c.col=-1;
310         c.valid=false;
311         c.address=0;
312        
313         for (int i=0;i<FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_ROWS;i++) {
314             for (int j=0;j<FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_COLS;j++) {
315                 m_CellInfo[i][j]=c;
316             }
317         }
318    
319         // now set the cells that are valid
320         setCellInfo(0,0,FR_SAFFIREPRO_CMD_ID_PC1_TO_OUT1, true);
321         setCellInfo(1,1,FR_SAFFIREPRO_CMD_ID_PC2_TO_OUT2, true);
322         setCellInfo(10,0,FR_SAFFIREPRO_CMD_ID_MIX1_TO_OUT1, true);
323         setCellInfo(11,1,FR_SAFFIREPRO_CMD_ID_MIX2_TO_OUT2, true);
324         setCellInfo(0,2,FR_SAFFIREPRO_CMD_ID_PC1_TO_OUT3, true);
325         setCellInfo(1,3,FR_SAFFIREPRO_CMD_ID_PC2_TO_OUT4, true);
326         setCellInfo(2,2,FR_SAFFIREPRO_CMD_ID_PC3_TO_OUT3, true);
327         setCellInfo(3,3,FR_SAFFIREPRO_CMD_ID_PC4_TO_OUT4, true);
328         setCellInfo(10,2,FR_SAFFIREPRO_CMD_ID_MIX1_TO_OUT3, true);
329         setCellInfo(11,3,FR_SAFFIREPRO_CMD_ID_MIX2_TO_OUT4, true);
330         setCellInfo(0,4,FR_SAFFIREPRO_CMD_ID_PC1_TO_OUT5, true);
331         setCellInfo(1,5,FR_SAFFIREPRO_CMD_ID_PC2_TO_OUT6, true);
332         setCellInfo(4,4,FR_SAFFIREPRO_CMD_ID_PC5_TO_OUT5, true);
333         setCellInfo(5,5,FR_SAFFIREPRO_CMD_ID_PC6_TO_OUT6, true);
334         setCellInfo(10,4,FR_SAFFIREPRO_CMD_ID_MIX1_TO_OUT5, true);
335         setCellInfo(11,5,FR_SAFFIREPRO_CMD_ID_MIX2_TO_OUT6, true);
336         setCellInfo(0,6,FR_SAFFIREPRO_CMD_ID_PC1_TO_OUT7, true);
337         setCellInfo(1,7,FR_SAFFIREPRO_CMD_ID_PC2_TO_OUT8, true);
338         setCellInfo(6,6,FR_SAFFIREPRO_CMD_ID_PC7_TO_OUT7, true);
339         setCellInfo(7,7,FR_SAFFIREPRO_CMD_ID_PC8_TO_OUT8, true);
340         setCellInfo(10,6,FR_SAFFIREPRO_CMD_ID_MIX1_TO_OUT7, true);
341         setCellInfo(11,7,FR_SAFFIREPRO_CMD_ID_MIX2_TO_OUT8, true);
342         setCellInfo(0,8,FR_SAFFIREPRO_CMD_ID_PC1_TO_OUT9, true);
343         setCellInfo(1,9,FR_SAFFIREPRO_CMD_ID_PC2_TO_OUT10, true);
344         setCellInfo(8,8,FR_SAFFIREPRO_CMD_ID_PC9_TO_OUT9, true);
345         setCellInfo(9,9,FR_SAFFIREPRO_CMD_ID_PC10_TO_OUT10, true);
346         setCellInfo(10,8,FR_SAFFIREPRO_CMD_ID_MIX1_TO_OUT9, true);
347         setCellInfo(11,9,FR_SAFFIREPRO_CMD_ID_MIX2_TO_OUT10, true);
348
349     } else if (type==eMMT_InputMix) {
350         addSignalInfo(m_RowInfo, "AN1", "Analog 1", "Analog Input 1");
351         addSignalInfo(m_RowInfo, "AN2", "Analog 2", "Analog Input 2");
352         addSignalInfo(m_RowInfo, "AN3", "Analog 3", "Analog Input 3");
353         addSignalInfo(m_RowInfo, "AN4", "Analog 4", "Analog Input 4");
354         addSignalInfo(m_RowInfo, "AN5", "Analog 5", "Analog Input 5");
355         addSignalInfo(m_RowInfo, "AN6", "Analog 6", "Analog Input 6");
356         addSignalInfo(m_RowInfo, "AN7", "Analog 7", "Analog Input 7");
357         addSignalInfo(m_RowInfo, "AN8", "Analog 8", "Analog Input 8");
358         addSignalInfo(m_RowInfo, "SPDIFL", "SPDIF L", "SPDIF Left Input");
359         addSignalInfo(m_RowInfo, "SPDIFR", "SPDIF R", "SPDIF Right Input");
360        
361         addSignalInfo(m_RowInfo, "ADAT11", "ADAT1 1", "ADAT1 Channel 1");
362         addSignalInfo(m_RowInfo, "ADAT12", "ADAT1 2", "ADAT1 Channel 2");
363         addSignalInfo(m_RowInfo, "ADAT13", "ADAT1 3", "ADAT1 Channel 3");
364         addSignalInfo(m_RowInfo, "ADAT14", "ADAT1 4", "ADAT1 Channel 4");
365         addSignalInfo(m_RowInfo, "ADAT15", "ADAT1 5", "ADAT1 Channel 5");
366         addSignalInfo(m_RowInfo, "ADAT16", "ADAT1 6", "ADAT1 Channel 6");
367         addSignalInfo(m_RowInfo, "ADAT17", "ADAT1 7", "ADAT1 Channel 7");
368         addSignalInfo(m_RowInfo, "ADAT18", "ADAT1 8", "ADAT1 Channel 8");
369        
370         addSignalInfo(m_RowInfo, "ADAT21", "ADAT2 1", "ADAT2 Channel 1");
371         addSignalInfo(m_RowInfo, "ADAT22", "ADAT2 2", "ADAT2 Channel 2");
372         addSignalInfo(m_RowInfo, "ADAT23", "ADAT2 3", "ADAT2 Channel 3");
373         addSignalInfo(m_RowInfo, "ADAT24", "ADAT2 4", "ADAT2 Channel 4");
374         addSignalInfo(m_RowInfo, "ADAT25", "ADAT2 5", "ADAT2 Channel 5");
375         addSignalInfo(m_RowInfo, "ADAT26", "ADAT2 6", "ADAT2 Channel 6");
376         addSignalInfo(m_RowInfo, "ADAT27", "ADAT2 7", "ADAT2 Channel 7");
377         addSignalInfo(m_RowInfo, "ADAT28", "ADAT2 8", "ADAT2 Channel 8");
378        
379         addSignalInfo(m_ColInfo, "IMIXL", "IMix L", "Input Mix Left");
380         addSignalInfo(m_ColInfo, "IMIXR", "IMix R", "Input Mix Right");
381        
382         // init the cell matrix
383         #define FOCUSRITE_SAFFIRE_PRO_INMIX_NB_COLS 2
384         #define FOCUSRITE_SAFFIRE_PRO_INMIX_NB_ROWS 26
385        
386         std::vector<struct sCellInfo> tmp_cols( FOCUSRITE_SAFFIRE_PRO_INMIX_NB_COLS );
387         std::vector< std::vector<struct sCellInfo> > tmp_all(FOCUSRITE_SAFFIRE_PRO_INMIX_NB_ROWS,tmp_cols);
388         m_CellInfo = tmp_all;
389    
390         struct sCellInfo c;
391         c.row=-1;
392         c.col=-1;
393         c.valid=false;
394         c.address=0;
395        
396         for (int i=0;i<FOCUSRITE_SAFFIRE_PRO_INMIX_NB_ROWS;i++) {
397             for (int j=0;j<FOCUSRITE_SAFFIRE_PRO_INMIX_NB_COLS;j++) {
398                 m_CellInfo[i][j]=c;
399             }
400         }
401    
402         // now set the cells that are valid
403         setCellInfo(0,0,FR_SAFFIREPRO_CMD_ID_AN1_TO_IMIXL, true);
404         setCellInfo(0,1,FR_SAFFIREPRO_CMD_ID_AN1_TO_IMIXR, true);
405         setCellInfo(1,0,FR_SAFFIREPRO_CMD_ID_AN2_TO_IMIXL, true);
406         setCellInfo(1,1,FR_SAFFIREPRO_CMD_ID_AN2_TO_IMIXR, true);
407         setCellInfo(2,0,FR_SAFFIREPRO_CMD_ID_AN3_TO_IMIXL, true);
408         setCellInfo(2,1,FR_SAFFIREPRO_CMD_ID_AN3_TO_IMIXR, true);
409         setCellInfo(3,0,FR_SAFFIREPRO_CMD_ID_AN4_TO_IMIXL, true);
410         setCellInfo(3,1,FR_SAFFIREPRO_CMD_ID_AN4_TO_IMIXR, true);
411         setCellInfo(4,0,FR_SAFFIREPRO_CMD_ID_AN5_TO_IMIXL, true);
412         setCellInfo(4,1,FR_SAFFIREPRO_CMD_ID_AN5_TO_IMIXR, true);
413         setCellInfo(5,0,FR_SAFFIREPRO_CMD_ID_AN6_TO_IMIXL, true);
414         setCellInfo(5,1,FR_SAFFIREPRO_CMD_ID_AN6_TO_IMIXR, true);
415         setCellInfo(6,0,FR_SAFFIREPRO_CMD_ID_AN7_TO_IMIXL, true);
416         setCellInfo(6,1,FR_SAFFIREPRO_CMD_ID_AN7_TO_IMIXR, true);
417         setCellInfo(7,0,FR_SAFFIREPRO_CMD_ID_AN8_TO_IMIXL, true);
418         setCellInfo(7,1,FR_SAFFIREPRO_CMD_ID_AN8_TO_IMIXR, true);
419         setCellInfo(8,0,FR_SAFFIREPRO_CMD_ID_SPDIFL_TO_IMIXL, true);
420         setCellInfo(8,1,FR_SAFFIREPRO_CMD_ID_SPDIFL_TO_IMIXR, true);
421         setCellInfo(9,0,FR_SAFFIREPRO_CMD_ID_SPDIFR_TO_IMIXL, true);
422         setCellInfo(9,1,FR_SAFFIREPRO_CMD_ID_SPDIFR_TO_IMIXR, true);
423
424         setCellInfo(10,0,FR_SAFFIREPRO_CMD_ID_ADAT11_TO_IMIXL, true);
425         setCellInfo(10,1,FR_SAFFIREPRO_CMD_ID_ADAT11_TO_IMIXR, true);
426         setCellInfo(11,0,FR_SAFFIREPRO_CMD_ID_ADAT12_TO_IMIXL, true);
427         setCellInfo(11,1,FR_SAFFIREPRO_CMD_ID_ADAT12_TO_IMIXR, true);
428         setCellInfo(12,0,FR_SAFFIREPRO_CMD_ID_ADAT13_TO_IMIXL, true);
429         setCellInfo(12,1,FR_SAFFIREPRO_CMD_ID_ADAT13_TO_IMIXR, true);
430         setCellInfo(13,0,FR_SAFFIREPRO_CMD_ID_ADAT14_TO_IMIXL, true);
431         setCellInfo(13,1,FR_SAFFIREPRO_CMD_ID_ADAT14_TO_IMIXR, true);
432         setCellInfo(14,0,FR_SAFFIREPRO_CMD_ID_ADAT15_TO_IMIXL, true);
433         setCellInfo(14,1,FR_SAFFIREPRO_CMD_ID_ADAT15_TO_IMIXR, true);
434         setCellInfo(15,0,FR_SAFFIREPRO_CMD_ID_ADAT16_TO_IMIXL, true);
435         setCellInfo(15,1,FR_SAFFIREPRO_CMD_ID_ADAT16_TO_IMIXR, true);
436         setCellInfo(16,0,FR_SAFFIREPRO_CMD_ID_ADAT17_TO_IMIXL, true);
437         setCellInfo(16,1,FR_SAFFIREPRO_CMD_ID_ADAT17_TO_IMIXR, true);
438         setCellInfo(17,0,FR_SAFFIREPRO_CMD_ID_ADAT18_TO_IMIXL, true);
439         setCellInfo(17,1,FR_SAFFIREPRO_CMD_ID_ADAT18_TO_IMIXR, true);
440
441         setCellInfo(18,0,FR_SAFFIREPRO_CMD_ID_ADAT21_TO_IMIXL, true);
442         setCellInfo(18,1,FR_SAFFIREPRO_CMD_ID_ADAT21_TO_IMIXR, true);
443         setCellInfo(19,0,FR_SAFFIREPRO_CMD_ID_ADAT22_TO_IMIXL, true);
444         setCellInfo(19,1,FR_SAFFIREPRO_CMD_ID_ADAT22_TO_IMIXR, true);
445         setCellInfo(20,0,FR_SAFFIREPRO_CMD_ID_ADAT23_TO_IMIXL, true);
446         setCellInfo(20,1,FR_SAFFIREPRO_CMD_ID_ADAT23_TO_IMIXR, true);
447         setCellInfo(21,0,FR_SAFFIREPRO_CMD_ID_ADAT24_TO_IMIXL, true);
448         setCellInfo(21,1,FR_SAFFIREPRO_CMD_ID_ADAT24_TO_IMIXR, true);
449         setCellInfo(22,0,FR_SAFFIREPRO_CMD_ID_ADAT25_TO_IMIXL, true);
450         setCellInfo(22,1,FR_SAFFIREPRO_CMD_ID_ADAT25_TO_IMIXR, true);
451         setCellInfo(23,0,FR_SAFFIREPRO_CMD_ID_ADAT26_TO_IMIXL, true);
452         setCellInfo(23,1,FR_SAFFIREPRO_CMD_ID_ADAT26_TO_IMIXR, true);
453         setCellInfo(24,0,FR_SAFFIREPRO_CMD_ID_ADAT27_TO_IMIXL, true);
454         setCellInfo(24,1,FR_SAFFIREPRO_CMD_ID_ADAT27_TO_IMIXR, true);
455         setCellInfo(25,0,FR_SAFFIREPRO_CMD_ID_ADAT28_TO_IMIXL, true);
456         setCellInfo(25,1,FR_SAFFIREPRO_CMD_ID_ADAT28_TO_IMIXR, true);
457
458     } else {
459         debugError("Invalid mixer type\n");
460     }
461 }
462
463 void SaffireProMatrixMixer::show()
464 {
465     debugOutput(DEBUG_LEVEL_NORMAL, "Saffire Pro Matrix mixer type %d\n");
466 }
467
468 std::string SaffireProMatrixMixer::getRowName( const int row )
469 {
470     debugOutput(DEBUG_LEVEL_VERBOSE, "name for row %d is %s\n",
471                                      row, m_RowInfo.at(row).name.c_str());
472     return m_RowInfo.at(row).name;
473 }
474
475 std::string SaffireProMatrixMixer::getColName( const int col )
476 {
477     debugOutput(DEBUG_LEVEL_VERBOSE, "name for col %d is %s\n",
478                                      col, m_ColInfo.at(col).name.c_str());
479     return m_ColInfo.at(col).name;
480 }
481
482 int SaffireProMatrixMixer::canWrite( const int row, const int col )
483 {
484     debugOutput(DEBUG_LEVEL_VERBOSE, "canWrite for row %d col %d is %d\n",
485                                      row, col, m_CellInfo.at(row).at(col).valid);
486     return m_CellInfo.at(row).at(col).valid;
487 }
488
489 double SaffireProMatrixMixer::setValue( const int row, const int col, const double val )
490 {
491     int32_t v=val;
492     struct sCellInfo c=m_CellInfo.at(row).at(col);
493    
494     debugOutput(DEBUG_LEVEL_VERBOSE, "setValue for id %d row %d col %d to %lf (%ld)\n",
495                                      c.address, row, col, val, v);
496    
497     if (v>0x07FFF) v=0x07FFF;
498     else if (v<0) v=0;
499
500     if ( !m_Parent.setSpecificValue(c.address, v) ) {
501         debugError( "setSpecificValue failed\n" );
502         return false;
503     } else return true;
504 }
505
506 double SaffireProMatrixMixer::getValue( const int row, const int col )
507 {
508     struct sCellInfo c=m_CellInfo.at(row).at(col);
509     uint32_t val=0;
510
511     if ( !m_Parent.getSpecificValue(c.address, &val) ) {
512         debugError( "getSpecificValue failed\n" );
513         return 0;
514     } else {
515         debugOutput(DEBUG_LEVEL_VERBOSE, "getValue for id %d row %d col %d = %lf\n",
516                                          c.address, row, col, val);
517         return val;
518     }
519 }
520
521 int SaffireProMatrixMixer::getRowCount( )
522 {
523     return m_RowInfo.size();
524 }
525
526 int SaffireProMatrixMixer::getColCount( )
527 {
528     return m_ColInfo.size();
529 }
530
531 } // Focusrite
532 } // BeBoB
Note: See TracBrowser for help on using the browser.