This file is indexed.

/usr/share/ffado-mixer-qt4/ffado/mixer/motu.py is in ffado-mixer-qt4 2.3.0-5.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
#
# Copyright (C) 2005-2008 by Pieter Palmers
# Copyright (C) 2008 by Jonathan Woithe
#
# This file is part of FFADO
# FFADO = Free Firewire (pro-)audio drivers for linux
#
# FFADO is based upon FreeBoB.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

from PyQt4.QtCore import SIGNAL, SLOT, QObject, Qt
from PyQt4.QtGui import QWidget, QApplication
from ffado.config import *

import logging
log = logging.getLogger('motu')

# Model defines.  These must agree with what is used in motu_avdevice.h.
MOTU_MODEL_NONE             = 0x0000
MOTU_MODEL_828mkII          = 0x0001
MOTU_MODEL_TRAVELER         = 0x0002
MOTU_MODEL_ULTRALITE        = 0x0003
MOTU_MODEL_8PRE             = 0x0004
MOTU_MODEL_828MkI           = 0x0005
MOTU_MODEL_896HD            = 0x0006
MOTU_MODEL_828mk3           = 0x0007
MOTU_MODEL_ULTRALITEmk3     = 0x0008
MOTU_MODEL_ULTRALITEmk3_HYB = 0x0009
MOTU_MODEL_TRAVELERmk3      = 0x000a
MOTU_MODEL_896HDmk3         = 0x000b

class Motu(QWidget):
    def __init__(self,parent = None):
        QWidget.__init__(self,parent)
        uicLoad("ffado/mixer/motu", self)

        self.init()

    def init(self):

        # For matrix mixer controls (channel faders, pans, solos, mutes) the
        # first index (the row) is the zero-based mix number while the
        # second index (the column) is the zero-based channel number.  The
        # third index gives the control of the stereo pair of the control
        # used as the key.  The order of the channel enumeration must agree
        # with that used when creating the dbus controls within
        # motu_avdevice.cpp.
        self.ChannelFaders={
            self.mix1ana1_fader: ['/Mixer/fader', 0, 0, self.mix1ana2_fader],
            self.mix1ana2_fader: ['/Mixer/fader', 0, 1, self.mix1ana1_fader],
            self.mix1ana3_fader: ['/Mixer/fader', 0, 2, self.mix1ana4_fader],
            self.mix1ana4_fader: ['/Mixer/fader', 0, 3, self.mix1ana3_fader],
            self.mix1ana5_fader: ['/Mixer/fader', 0, 4, self.mix1ana6_fader],
            self.mix1ana6_fader: ['/Mixer/fader', 0, 5, self.mix1ana5_fader],
            self.mix1ana7_fader: ['/Mixer/fader', 0, 6, self.mix1ana8_fader],
            self.mix1ana8_fader: ['/Mixer/fader', 0, 7, self.mix1ana7_fader],
            self.mix1aes1_fader: ['/Mixer/fader', 0, 8, self.mix1aes2_fader],
            self.mix1aes2_fader: ['/Mixer/fader', 0, 9, self.mix1aes1_fader],
            self.mix1spdif1_fader: ['/Mixer/fader', 0, 10, self.mix1spdif2_fader],
            self.mix1spdif2_fader: ['/Mixer/fader', 0, 11, self.mix1spdif1_fader],
            self.mix1adat1_fader: ['/Mixer/fader', 0, 12, self.mix1adat2_fader],
            self.mix1adat2_fader: ['/Mixer/fader', 0, 13, self.mix1adat1_fader],
            self.mix1adat3_fader: ['/Mixer/fader', 0, 14, self.mix1adat4_fader],
            self.mix1adat4_fader: ['/Mixer/fader', 0, 15, self.mix1adat3_fader],
            self.mix1adat5_fader: ['/Mixer/fader', 0, 16, self.mix1adat6_fader],
            self.mix1adat6_fader: ['/Mixer/fader', 0, 17, self.mix1adat5_fader],
            self.mix1adat7_fader: ['/Mixer/fader', 0, 18, self.mix1adat8_fader],
            self.mix1adat8_fader: ['/Mixer/fader', 0, 19, self.mix1adat7_fader],

            self.mix2ana1_fader: ['/Mixer/fader', 1, 0, self.mix2ana2_fader],
            self.mix2ana2_fader: ['/Mixer/fader', 1, 1, self.mix2ana1_fader],
            self.mix2ana3_fader: ['/Mixer/fader', 1, 2, self.mix2ana4_fader],
            self.mix2ana4_fader: ['/Mixer/fader', 1, 3, self.mix2ana3_fader],
            self.mix2ana5_fader: ['/Mixer/fader', 1, 4, self.mix2ana6_fader],
            self.mix2ana6_fader: ['/Mixer/fader', 1, 5, self.mix2ana5_fader],
            self.mix2ana7_fader: ['/Mixer/fader', 1, 6, self.mix2ana8_fader],
            self.mix2ana8_fader: ['/Mixer/fader', 1, 7, self.mix2ana7_fader],
            self.mix2aes1_fader: ['/Mixer/fader', 1, 8, self.mix2aes2_fader],
            self.mix2aes2_fader: ['/Mixer/fader', 1, 9, self.mix2aes1_fader],
            self.mix2spdif1_fader: ['/Mixer/fader', 1, 10, self.mix2spdif2_fader],
            self.mix2spdif2_fader: ['/Mixer/fader', 1, 11, self.mix2spdif1_fader],
            self.mix2adat1_fader: ['/Mixer/fader', 1, 12, self.mix2adat2_fader],
            self.mix2adat2_fader: ['/Mixer/fader', 1, 13, self.mix2adat1_fader],
            self.mix2adat3_fader: ['/Mixer/fader', 1, 14, self.mix2adat4_fader],
            self.mix2adat4_fader: ['/Mixer/fader', 1, 15, self.mix2adat3_fader],
            self.mix2adat5_fader: ['/Mixer/fader', 1, 16, self.mix2adat6_fader],
            self.mix2adat6_fader: ['/Mixer/fader', 1, 17, self.mix2adat5_fader],
            self.mix2adat7_fader: ['/Mixer/fader', 1, 18, self.mix2adat8_fader],
            self.mix2adat8_fader: ['/Mixer/fader', 1, 19, self.mix2adat7_fader],

            self.mix3ana1_fader: ['/Mixer/fader', 2, 0, self.mix3ana2_fader],
            self.mix3ana2_fader: ['/Mixer/fader', 2, 1, self.mix3ana1_fader],
            self.mix3ana3_fader: ['/Mixer/fader', 2, 2, self.mix3ana4_fader],
            self.mix3ana4_fader: ['/Mixer/fader', 2, 3, self.mix3ana3_fader],
            self.mix3ana5_fader: ['/Mixer/fader', 2, 4, self.mix3ana6_fader],
            self.mix3ana6_fader: ['/Mixer/fader', 2, 5, self.mix3ana5_fader],
            self.mix3ana7_fader: ['/Mixer/fader', 2, 6, self.mix3ana8_fader],
            self.mix3ana8_fader: ['/Mixer/fader', 2, 7, self.mix3ana7_fader],
            self.mix3aes1_fader: ['/Mixer/fader', 2, 8, self.mix3aes2_fader],
            self.mix3aes2_fader: ['/Mixer/fader', 2, 9, self.mix3aes1_fader],
            self.mix3spdif1_fader: ['/Mixer/fader', 2, 10, self.mix3spdif2_fader],
            self.mix3spdif2_fader: ['/Mixer/fader', 2, 11, self.mix3spdif1_fader],
            self.mix3adat1_fader: ['/Mixer/fader', 2, 12, self.mix3adat2_fader],
            self.mix3adat2_fader: ['/Mixer/fader', 2, 13, self.mix3adat1_fader],
            self.mix3adat3_fader: ['/Mixer/fader', 2, 14, self.mix3adat4_fader],
            self.mix3adat4_fader: ['/Mixer/fader', 2, 15, self.mix3adat3_fader],
            self.mix3adat5_fader: ['/Mixer/fader', 2, 16, self.mix3adat6_fader],
            self.mix3adat6_fader: ['/Mixer/fader', 2, 17, self.mix3adat5_fader],
            self.mix3adat7_fader: ['/Mixer/fader', 2, 18, self.mix3adat8_fader],
            self.mix3adat8_fader: ['/Mixer/fader', 2, 19, self.mix3adat7_fader],

            self.mix4ana1_fader: ['/Mixer/fader', 3, 0, self.mix4ana2_fader],
            self.mix4ana2_fader: ['/Mixer/fader', 3, 1, self.mix4ana1_fader],
            self.mix4ana3_fader: ['/Mixer/fader', 3, 2, self.mix4ana4_fader],
            self.mix4ana4_fader: ['/Mixer/fader', 3, 3, self.mix4ana3_fader],
            self.mix4ana5_fader: ['/Mixer/fader', 3, 4, self.mix4ana6_fader],
            self.mix4ana6_fader: ['/Mixer/fader', 3, 5, self.mix4ana5_fader],
            self.mix4ana7_fader: ['/Mixer/fader', 3, 6, self.mix4ana8_fader],
            self.mix4ana8_fader: ['/Mixer/fader', 3, 7, self.mix4ana7_fader],
            self.mix4aes1_fader: ['/Mixer/fader', 3, 8, self.mix4aes2_fader],
            self.mix4aes2_fader: ['/Mixer/fader', 3, 9, self.mix4aes1_fader],
            self.mix4spdif1_fader: ['/Mixer/fader', 3, 10, self.mix4spdif2_fader],
            self.mix4spdif2_fader: ['/Mixer/fader', 3, 11, self.mix4spdif1_fader],
            self.mix4adat1_fader: ['/Mixer/fader', 3, 12, self.mix4adat2_fader],
            self.mix4adat2_fader: ['/Mixer/fader', 3, 13, self.mix4adat1_fader],
            self.mix4adat3_fader: ['/Mixer/fader', 3, 14, self.mix4adat4_fader],
            self.mix4adat4_fader: ['/Mixer/fader', 3, 15, self.mix4adat3_fader],
            self.mix4adat5_fader: ['/Mixer/fader', 3, 16, self.mix4adat6_fader],
            self.mix4adat6_fader: ['/Mixer/fader', 3, 17, self.mix4adat5_fader],
            self.mix4adat7_fader: ['/Mixer/fader', 3, 18, self.mix4adat8_fader],
            self.mix4adat8_fader: ['/Mixer/fader', 3, 19, self.mix4adat7_fader],
        }

        self.Faders={
            self.mix1_fader: ['/Mixer/Mix1/Mix_fader'],
            self.mix2_fader: ['/Mixer/Mix2/Mix_fader'],
            self.mix3_fader: ['/Mixer/Mix3/Mix_fader'],
            self.mix4_fader: ['/Mixer/Mix4/Mix_fader'],
            self.mainout_fader: ['/Mixer/Mainout_fader'],
            self.phones_fader:  ['/Mixer/Phones_fader'],
        }

        self.ChannelControls={
            self.mix1ana1_pan:   ['/Mixer/pan', 0, 0],
            self.mix1ana2_pan:   ['/Mixer/pan', 0, 1],
            self.mix1ana3_pan:   ['/Mixer/pan', 0, 2],
            self.mix1ana4_pan:   ['/Mixer/pan', 0, 3],
            self.mix1ana5_pan:   ['/Mixer/pan', 0, 4],
            self.mix1ana6_pan:   ['/Mixer/pan', 0, 5],
            self.mix1ana7_pan:   ['/Mixer/pan', 0, 6],
            self.mix1ana8_pan:   ['/Mixer/pan', 0, 7],
            self.mix1aes1_pan:   ['/Mixer/pan', 0, 8],
            self.mix1aes2_pan:   ['/Mixer/pan', 0, 9],
            self.mix1spdif1_pan: ['/Mixer/pan', 0, 10],
            self.mix1spdif2_pan: ['/Mixer/pan', 0, 11],
            self.mix1adat1_pan:  ['/Mixer/pan', 0, 12],
            self.mix1adat2_pan:  ['/Mixer/pan', 0, 13],
            self.mix1adat3_pan:  ['/Mixer/pan', 0, 14],
            self.mix1adat4_pan:  ['/Mixer/pan', 0, 15],
            self.mix1adat5_pan:  ['/Mixer/pan', 0, 16],
            self.mix1adat6_pan:  ['/Mixer/pan', 0, 17],
            self.mix1adat7_pan:  ['/Mixer/pan', 0, 18],
            self.mix1adat8_pan:  ['/Mixer/pan', 0, 19],

            self.mix2ana1_pan:   ['/Mixer/pan', 1, 0],
            self.mix2ana2_pan:   ['/Mixer/pan', 1, 1],
            self.mix2ana3_pan:   ['/Mixer/pan', 1, 2],
            self.mix2ana4_pan:   ['/Mixer/pan', 1, 3],
            self.mix2ana5_pan:   ['/Mixer/pan', 1, 4],
            self.mix2ana6_pan:   ['/Mixer/pan', 1, 5],
            self.mix2ana7_pan:   ['/Mixer/pan', 1, 6],
            self.mix2ana8_pan:   ['/Mixer/pan', 1, 7],
            self.mix2aes1_pan:   ['/Mixer/pan', 1, 8],
            self.mix2aes2_pan:   ['/Mixer/pan', 1, 9],
            self.mix2spdif1_pan: ['/Mixer/pan', 1, 10],
            self.mix2spdif2_pan: ['/Mixer/pan', 1, 11],
            self.mix2adat1_pan:  ['/Mixer/pan', 1, 12],
            self.mix2adat2_pan:  ['/Mixer/pan', 1, 13],
            self.mix2adat3_pan:  ['/Mixer/pan', 1, 14],
            self.mix2adat4_pan:  ['/Mixer/pan', 1, 15],
            self.mix2adat5_pan:  ['/Mixer/pan', 1, 16],
            self.mix2adat6_pan:  ['/Mixer/pan', 1, 17],
            self.mix2adat7_pan:  ['/Mixer/pan', 1, 18],
            self.mix2adat8_pan:  ['/Mixer/pan', 1, 19],

            self.mix3ana1_pan:   ['/Mixer/pan', 2, 0],
            self.mix3ana2_pan:   ['/Mixer/pan', 2, 1],
            self.mix3ana3_pan:   ['/Mixer/pan', 2, 2],
            self.mix3ana4_pan:   ['/Mixer/pan', 2, 3],
            self.mix3ana5_pan:   ['/Mixer/pan', 2, 4],
            self.mix3ana6_pan:   ['/Mixer/pan', 2, 5],
            self.mix3ana7_pan:   ['/Mixer/pan', 2, 6],
            self.mix3ana8_pan:   ['/Mixer/pan', 2, 7],
            self.mix3aes1_pan:   ['/Mixer/pan', 2, 8],
            self.mix3aes2_pan:   ['/Mixer/pan', 2, 9],
            self.mix3spdif1_pan: ['/Mixer/pan', 2, 10],
            self.mix3spdif2_pan: ['/Mixer/pan', 2, 11],
            self.mix3adat1_pan:  ['/Mixer/pan', 2, 12],
            self.mix3adat2_pan:  ['/Mixer/pan', 2, 13],
            self.mix3adat3_pan:  ['/Mixer/pan', 2, 14],
            self.mix3adat4_pan:  ['/Mixer/pan', 2, 15],
            self.mix3adat5_pan:  ['/Mixer/pan', 2, 16],
            self.mix3adat6_pan:  ['/Mixer/pan', 2, 17],
            self.mix3adat7_pan:  ['/Mixer/pan', 2, 18],
            self.mix3adat8_pan:  ['/Mixer/pan', 2, 19],

            self.mix4ana1_pan:   ['/Mixer/pan', 3, 0],
            self.mix4ana2_pan:   ['/Mixer/pan', 3, 1],
            self.mix4ana3_pan:   ['/Mixer/pan', 3, 2],
            self.mix4ana4_pan:   ['/Mixer/pan', 3, 3],
            self.mix4ana5_pan:   ['/Mixer/pan', 3, 4],
            self.mix4ana6_pan:   ['/Mixer/pan', 3, 5],
            self.mix4ana7_pan:   ['/Mixer/pan', 3, 6],
            self.mix4ana8_pan:   ['/Mixer/pan', 3, 7],
            self.mix4aes1_pan:   ['/Mixer/pan', 3, 8],
            self.mix4aes2_pan:   ['/Mixer/pan', 3, 9],
            self.mix4spdif1_pan: ['/Mixer/pan', 3, 10],
            self.mix4spdif2_pan: ['/Mixer/pan', 3, 11],
            self.mix4adat1_pan:  ['/Mixer/pan', 3, 12],
            self.mix4adat2_pan:  ['/Mixer/pan', 3, 13],
            self.mix4adat3_pan:  ['/Mixer/pan', 3, 14],
            self.mix4adat4_pan:  ['/Mixer/pan', 3, 15],
            self.mix4adat5_pan:  ['/Mixer/pan', 3, 16],
            self.mix4adat6_pan:  ['/Mixer/pan', 3, 17],
            self.mix4adat7_pan:  ['/Mixer/pan', 3, 18],
            self.mix4adat8_pan:  ['/Mixer/pan', 3, 19],
        }

        self.Controls={
            self.ana1_trimgain:  ['/Mixer/Control/Ana1_trimgain'],
            self.ana2_trimgain:  ['/Mixer/Control/Ana2_trimgain'],
            self.ana3_trimgain:  ['/Mixer/Control/Ana3_trimgain'],
            self.ana4_trimgain:  ['/Mixer/Control/Ana4_trimgain'],
            self.ana5_trimgain:  ['/Mixer/Control/Ana5_trimgain'],
            self.ana6_trimgain:  ['/Mixer/Control/Ana6_trimgain'],
            self.ana7_trimgain:  ['/Mixer/Control/Ana7_trimgain'],
            self.ana8_trimgain:  ['/Mixer/Control/Ana8_trimgain'],
            self.spdif1_trimgain:  ['/Mixer/Control/Spdif1_trimgain'],
            self.spdif2_trimgain:  ['/Mixer/Control/Spdif2_trimgain'],
        }

        self.ChannelBinarySwitches={
            self.mix1ana1_mute:  ['/Mixer/mute', 0, 0],
            self.mix1ana2_mute:  ['/Mixer/mute', 0, 1],
            self.mix1ana3_mute:  ['/Mixer/mute', 0, 2],
            self.mix1ana4_mute:  ['/Mixer/mute', 0, 3],
            self.mix1ana5_mute:  ['/Mixer/mute', 0, 4],
            self.mix1ana6_mute:  ['/Mixer/mute', 0, 5],
            self.mix1ana7_mute:  ['/Mixer/mute', 0, 6],
            self.mix1ana8_mute:  ['/Mixer/mute', 0, 7],
            self.mix1aes1_mute:  ['/Mixer/mute', 0, 8],
            self.mix1aes2_mute:  ['/Mixer/mute', 0, 9],
            self.mix1spdif1_mute: ['/Mixer/mute', 0, 10],
            self.mix1spdif2_mute: ['/Mixer/mute', 0, 11],
            self.mix1adat1_mute: ['/Mixer/mute', 0, 12],
            self.mix1adat2_mute: ['/Mixer/mute', 0, 13],
            self.mix1adat3_mute: ['/Mixer/mute', 0, 14],
            self.mix1adat4_mute: ['/Mixer/mute', 0, 15],
            self.mix1adat5_mute: ['/Mixer/mute', 0, 16],
            self.mix1adat6_mute: ['/Mixer/mute', 0, 17],
            self.mix1adat7_mute: ['/Mixer/mute', 0, 18],
            self.mix1adat8_mute: ['/Mixer/mute', 0, 19],
            self.mix1ana1_solo:  ['/Mixer/solo', 0, 0],
            self.mix1ana2_solo:  ['/Mixer/solo', 0, 1],
            self.mix1ana3_solo:  ['/Mixer/solo', 0, 2],
            self.mix1ana4_solo:  ['/Mixer/solo', 0, 3],
            self.mix1ana5_solo:  ['/Mixer/solo', 0, 4],
            self.mix1ana6_solo:  ['/Mixer/solo', 0, 5],
            self.mix1ana7_solo:  ['/Mixer/solo', 0, 6],
            self.mix1ana8_solo:  ['/Mixer/solo', 0, 7],
            self.mix1aes1_solo:  ['/Mixer/solo', 0, 8],
            self.mix1aes2_solo:  ['/Mixer/solo', 0, 9],
            self.mix1spdif1_solo: ['/Mixer/solo', 0, 10],
            self.mix1spdif2_solo: ['/Mixer/solo', 0, 11],
            self.mix1adat1_solo: ['/Mixer/solo', 0, 12],
            self.mix1adat2_solo: ['/Mixer/solo', 0, 13],
            self.mix1adat3_solo: ['/Mixer/solo', 0, 14],
            self.mix1adat4_solo: ['/Mixer/solo', 0, 15],
            self.mix1adat5_solo: ['/Mixer/solo', 0, 16],
            self.mix1adat6_solo: ['/Mixer/solo', 0, 17],
            self.mix1adat7_solo: ['/Mixer/solo', 0, 18],
            self.mix1adat8_solo: ['/Mixer/solo', 0, 19],

            self.mix2ana1_mute:  ['/Mixer/mute', 1, 0],
            self.mix2ana2_mute:  ['/Mixer/mute', 1, 1],
            self.mix2ana3_mute:  ['/Mixer/mute', 1, 2],
            self.mix2ana4_mute:  ['/Mixer/mute', 1, 3],
            self.mix2ana5_mute:  ['/Mixer/mute', 1, 4],
            self.mix2ana6_mute:  ['/Mixer/mute', 1, 5],
            self.mix2ana7_mute:  ['/Mixer/mute', 1, 6],
            self.mix2ana8_mute:  ['/Mixer/mute', 1, 7],
            self.mix2aes1_mute:  ['/Mixer/mute', 1, 8],
            self.mix2aes2_mute:  ['/Mixer/mute', 1, 9],
            self.mix2spdif1_mute: ['/Mixer/mute', 1, 10],
            self.mix2spdif2_mute: ['/Mixer/mute', 1, 11],
            self.mix2adat1_mute: ['/Mixer/mute', 1, 12],
            self.mix2adat2_mute: ['/Mixer/mute', 1, 13],
            self.mix2adat3_mute: ['/Mixer/mute', 1, 14],
            self.mix2adat4_mute: ['/Mixer/mute', 1, 15],
            self.mix2adat5_mute: ['/Mixer/mute', 1, 16],
            self.mix2adat6_mute: ['/Mixer/mute', 1, 17],
            self.mix2adat7_mute: ['/Mixer/mute', 1, 18],
            self.mix2adat8_mute: ['/Mixer/mute', 1, 19],
            self.mix2ana1_solo:  ['/Mixer/solo', 1, 0],
            self.mix2ana2_solo:  ['/Mixer/solo', 1, 1],
            self.mix2ana3_solo:  ['/Mixer/solo', 1, 2],
            self.mix2ana4_solo:  ['/Mixer/solo', 1, 3],
            self.mix2ana5_solo:  ['/Mixer/solo', 1, 4],
            self.mix2ana6_solo:  ['/Mixer/solo', 1, 5],
            self.mix2ana7_solo:  ['/Mixer/solo', 1, 6],
            self.mix2ana8_solo:  ['/Mixer/solo', 1, 7],
            self.mix2aes1_solo:  ['/Mixer/solo', 1, 8],
            self.mix2aes2_solo:  ['/Mixer/solo', 1, 9],
            self.mix2spdif1_solo: ['/Mixer/solo', 1, 10],
            self.mix2spdif2_solo: ['/Mixer/solo', 1, 11],
            self.mix2adat1_solo: ['/Mixer/solo', 1, 12],
            self.mix2adat2_solo: ['/Mixer/solo', 1, 13],
            self.mix2adat3_solo: ['/Mixer/solo', 1, 14],
            self.mix2adat4_solo: ['/Mixer/solo', 1, 15],
            self.mix2adat5_solo: ['/Mixer/solo', 1, 16],
            self.mix2adat6_solo: ['/Mixer/solo', 1, 17],
            self.mix2adat7_solo: ['/Mixer/solo', 1, 18],
            self.mix2adat8_solo: ['/Mixer/solo', 1, 19],

            self.mix3ana1_mute:  ['/Mixer/mute', 2, 0],
            self.mix3ana2_mute:  ['/Mixer/mute', 2, 1],
            self.mix3ana3_mute:  ['/Mixer/mute', 2, 2],
            self.mix3ana4_mute:  ['/Mixer/mute', 2, 3],
            self.mix3ana5_mute:  ['/Mixer/mute', 2, 4],
            self.mix3ana6_mute:  ['/Mixer/mute', 2, 5],
            self.mix3ana7_mute:  ['/Mixer/mute', 2, 6],
            self.mix3ana8_mute:  ['/Mixer/mute', 2, 7],
            self.mix3aes1_mute:  ['/Mixer/mute', 2, 8],
            self.mix3aes2_mute:  ['/Mixer/mute', 2, 9],
            self.mix3spdif1_mute: ['/Mixer/mute', 2, 10],
            self.mix3spdif2_mute: ['/Mixer/mute', 2, 11],
            self.mix3adat1_mute: ['/Mixer/mute', 2, 12],
            self.mix3adat2_mute: ['/Mixer/mute', 2, 13],
            self.mix3adat3_mute: ['/Mixer/mute', 2, 14],
            self.mix3adat4_mute: ['/Mixer/mute', 2, 15],
            self.mix3adat5_mute: ['/Mixer/mute', 2, 16],
            self.mix3adat6_mute: ['/Mixer/mute', 2, 17],
            self.mix3adat7_mute: ['/Mixer/mute', 2, 18],
            self.mix3adat8_mute: ['/Mixer/mute', 2, 19],
            self.mix3ana1_solo:  ['/Mixer/solo', 2, 0],
            self.mix3ana2_solo:  ['/Mixer/solo', 2, 1],
            self.mix3ana3_solo:  ['/Mixer/solo', 2, 2],
            self.mix3ana4_solo:  ['/Mixer/solo', 2, 3],
            self.mix3ana5_solo:  ['/Mixer/solo', 2, 4],
            self.mix3ana6_solo:  ['/Mixer/solo', 2, 5],
            self.mix3ana7_solo:  ['/Mixer/solo', 2, 6],
            self.mix3ana8_solo:  ['/Mixer/solo', 2, 7],
            self.mix3aes1_solo:  ['/Mixer/solo', 2, 8],
            self.mix3aes2_solo:  ['/Mixer/solo', 2, 9],
            self.mix3spdif1_solo: ['/Mixer/solo', 2, 10],
            self.mix3spdif2_solo: ['/Mixer/solo', 2, 11],
            self.mix3adat1_solo: ['/Mixer/solo', 2, 12],
            self.mix3adat2_solo: ['/Mixer/solo', 2, 13],
            self.mix3adat3_solo: ['/Mixer/solo', 2, 14],
            self.mix3adat4_solo: ['/Mixer/solo', 2, 15],
            self.mix3adat5_solo: ['/Mixer/solo', 2, 16],
            self.mix3adat6_solo: ['/Mixer/solo', 2, 17],
            self.mix3adat7_solo: ['/Mixer/solo', 2, 18],
            self.mix3adat8_solo: ['/Mixer/solo', 2, 19],

            self.mix4ana1_mute:  ['/Mixer/mute', 3, 0],
            self.mix4ana2_mute:  ['/Mixer/mute', 3, 1],
            self.mix4ana3_mute:  ['/Mixer/mute', 3, 2],
            self.mix4ana4_mute:  ['/Mixer/mute', 3, 3],
            self.mix4ana5_mute:  ['/Mixer/mute', 3, 4],
            self.mix4ana6_mute:  ['/Mixer/mute', 3, 5],
            self.mix4ana7_mute:  ['/Mixer/mute', 3, 6],
            self.mix4ana8_mute:  ['/Mixer/mute', 3, 7],
            self.mix4aes1_mute:  ['/Mixer/mute', 3, 8],
            self.mix4aes2_mute:  ['/Mixer/mute', 3, 9],
            self.mix4spdif1_mute: ['/Mixer/mute', 3, 10],
            self.mix4spdif2_mute: ['/Mixer/mute', 3, 11],
            self.mix4adat1_mute: ['/Mixer/mute', 3, 12],
            self.mix4adat2_mute: ['/Mixer/mute', 3, 13],
            self.mix4adat3_mute: ['/Mixer/mute', 3, 14],
            self.mix4adat4_mute: ['/Mixer/mute', 3, 15],
            self.mix4adat5_mute: ['/Mixer/mute', 3, 16],
            self.mix4adat6_mute: ['/Mixer/mute', 3, 17],
            self.mix4adat7_mute: ['/Mixer/mute', 3, 18],
            self.mix4adat8_mute: ['/Mixer/mute', 3, 19],
            self.mix4ana1_solo:  ['/Mixer/solo', 3, 0],
            self.mix4ana2_solo:  ['/Mixer/solo', 3, 1],
            self.mix4ana3_solo:  ['/Mixer/solo', 3, 2],
            self.mix4ana4_solo:  ['/Mixer/solo', 3, 3],
            self.mix4ana5_solo:  ['/Mixer/solo', 3, 4],
            self.mix4ana6_solo:  ['/Mixer/solo', 3, 5],
            self.mix4ana7_solo:  ['/Mixer/solo', 3, 6],
            self.mix4ana8_solo:  ['/Mixer/solo', 3, 7],
            self.mix4aes1_solo:  ['/Mixer/solo', 3, 8],
            self.mix4aes2_solo:  ['/Mixer/solo', 3, 9],
            self.mix4spdif1_solo: ['/Mixer/solo', 3, 10],
            self.mix4spdif2_solo: ['/Mixer/solo', 3, 11],
            self.mix4adat1_solo: ['/Mixer/solo', 3, 12],
            self.mix4adat2_solo: ['/Mixer/solo', 3, 13],
            self.mix4adat3_solo: ['/Mixer/solo', 3, 14],
            self.mix4adat4_solo: ['/Mixer/solo', 3, 15],
            self.mix4adat5_solo: ['/Mixer/solo', 3, 16],
            self.mix4adat6_solo: ['/Mixer/solo', 3, 17],
            self.mix4adat7_solo: ['/Mixer/solo', 3, 18],
            self.mix4adat8_solo: ['/Mixer/solo', 3, 19],
        }

        self.BinarySwitches={
            self.mix1_mute:      ['/Mixer/Mix1/Mix_mute'],
            self.mix2_mute:      ['/Mixer/Mix2/Mix_mute'],
            self.mix3_mute:      ['/Mixer/Mix3/Mix_mute'],
            self.mix4_mute:      ['/Mixer/Mix4/Mix_mute'],

            self.ana1_pad:       ['/Mixer/Control/Ana1_pad'],
            self.ana2_pad:       ['/Mixer/Control/Ana2_pad'],
            self.ana3_pad:       ['/Mixer/Control/Ana3_pad'],
            self.ana4_pad:       ['/Mixer/Control/Ana4_pad'],
            self.ana5_pad:       ['/Mixer/Control/Ana5_pad'],
            self.ana6_pad:       ['/Mixer/Control/Ana6_pad'],
            self.ana7_pad:       ['/Mixer/Control/Ana7_pad'],
            self.ana8_pad:       ['/Mixer/Control/Ana8_pad'],
            self.ana1_invert:    ['/Mixer/Control/Ana1_invert'],
            self.ana2_invert:    ['/Mixer/Control/Ana2_invert'],
            self.ana3_invert:    ['/Mixer/Control/Ana3_invert'],
            self.ana4_invert:    ['/Mixer/Control/Ana4_invert'],
            self.ana5_invert:    ['/Mixer/Control/Ana5_invert'],
            self.ana6_invert:    ['/Mixer/Control/Ana6_invert'],
            self.ana7_invert:    ['/Mixer/Control/Ana7_invert'],
            self.ana8_invert:    ['/Mixer/Control/Ana8_invert'],
            self.spdif1_invert:  ['/Mixer/Control/Spdif1_invert'],
            self.spdif2_invert:  ['/Mixer/Control/Spdif2_invert'],
            self.ana1_level:     ['/Mixer/Control/Ana1_level'],
            self.ana2_level:     ['/Mixer/Control/Ana2_level'],
            self.ana3_level:     ['/Mixer/Control/Ana3_level'],
            self.ana4_level:     ['/Mixer/Control/Ana4_level'],
            self.ana5_level:     ['/Mixer/Control/Ana5_level'],
            self.ana6_level:     ['/Mixer/Control/Ana6_level'],
            self.ana7_level:     ['/Mixer/Control/Ana7_level'],
            self.ana8_level:     ['/Mixer/Control/Ana8_level'],
            self.ana1_boost:     ['/Mixer/Control/Ana1_boost'],
            self.ana2_boost:     ['/Mixer/Control/Ana2_boost'],
            self.ana3_boost:     ['/Mixer/Control/Ana3_boost'],
            self.ana4_boost:     ['/Mixer/Control/Ana4_boost'],
            self.ana5_boost:     ['/Mixer/Control/Ana5_boost'],
            self.ana6_boost:     ['/Mixer/Control/Ana6_boost'],
            self.ana7_boost:     ['/Mixer/Control/Ana7_boost'],
            self.ana8_boost:     ['/Mixer/Control/Ana8_boost'],
        }

        self.Selectors={
            self.mix1_dest:      ['/Mixer/Mix1/Mix_dest'],
            self.mix2_dest:      ['/Mixer/Mix2/Mix_dest'],
            self.mix3_dest:      ['/Mixer/Mix3/Mix_dest'],
            self.mix4_dest:      ['/Mixer/Mix4/Mix_dest'],

            self.phones_src:	 ['/Mixer/Control/Phones_src'],

            self.optical_in_mode:   ['/Mixer/Control/OpticalIn_mode'],
            self.optical_out_mode:  ['/Mixer/Control/OpticalOut_mode'],

            self.meter_src_ctrl:    ['/Mixer/Control/Meter_src'],
            self.aesebu_meter_ctrl: ['/Mixer/Control/Meter_aesebu_src'],
            self.peakhold_time_ctrl:['/Mixer/Control/Meter_peakhold_time'],
            self.cliphold_time_ctrl:['/Mixer/Control/Meter_cliphold_time'],
        }

        # Other mixer variables
        self.is_streaming = 0
        self.sample_rate = 0
        self.model = MOTU_MODEL_NONE


    # public slot: channel faders within a matrix mixer
    def updateChannelFader(self, a0):
        sender = self.sender()
        vol = a0
        log.debug("setting %s for mix %d channel %d to %d" % (self.ChannelFaders[sender][0], 
            self.ChannelFaders[sender][1], self.ChannelFaders[sender][2], vol))
        self.hw.setMatrixMixerValue(self.ChannelFaders[sender][0],
            self.ChannelFaders[sender][1], self.ChannelFaders[sender][2], vol)
        # Using the ctrl modifier key makes stereo pairs move in unison
        if (QApplication.keyboardModifiers() == Qt.ControlModifier):
            pair = self.ChannelFaders[sender][3]
            pair.setValue(vol)

    # public slot: a multivalue control within a matrix mixer
    def updateChannelControl(self, a0):
        sender = self.sender()
        val = a0
        log.debug("setting %s for mix %d channel %d to %d" % (self.ChannelControls[sender][0], 
            self.ChannelControls[sender][1], self.ChannelControls[sender][2], val))
        self.hw.setMatrixMixerValue(self.ChannelControls[sender][0], 
            self.ChannelControls[sender][1], self.ChannelControls[sender][2], val)

    # public slot: a generic single multivalue control
    def updateControl(self, a0):
        sender = self.sender()
        val = a0
        log.debug("setting %s control to %d" % (self.Controls[sender][0], val))
        self.hw.setDiscrete(self.Controls[sender][0], val)

    # public slot: a binary switch within a matrix mixer
    def updateChannelBinarySwitch(self, a0):
        sender = self.sender()
        val=a0
        log.debug("setting %s for mix %d channel %d switch to %d" % (self.ChannelBinarySwitches[sender][0], 
            self.ChannelBinarySwitches[sender][1], self.ChannelBinarySwitches[sender][2], val))
        self.hw.setMatrixMixerValue(self.ChannelBinarySwitches[sender][0], 
            self.ChannelBinarySwitches[sender][1], self.ChannelBinarySwitches[sender][2], val)

    # public slot: generic single binary switch
    def updateBinarySwitch(self, a0):
        sender = self.sender()
        val=a0
        log.debug("setting %s switch to %d" % (self.BinarySwitches[sender][0], val))
        self.hw.setDiscrete(self.BinarySwitches[sender][0], val)

    # public slot: a faders (not in a matrix mixer)
    def updateFader(self, a0):
        sender = self.sender()
        vol = a0
        log.debug("setting %s mix fader to %d" % (self.Faders[sender][0], vol))
        self.hw.setDiscrete(self.Faders[sender][0], vol)

    # public slot: selectors (eg: mix destination controls)
    def updateSelector(self, a0):
        sender = self.sender()
        dest=a0
        log.debug("setting %s selector to %d" % (self.Selectors[sender][0], dest))
        self.hw.setDiscrete(self.Selectors[sender][0], dest)

    # public slots: mix output controls
    def set_mix1_dest(self,a0):
        self.setMixDest('mix1', a0)

    def setSelector(self,a0,a1):
        name=a0
        state = a1
        log.debug("setting %s state to %d" % (name, state))
        self.hw.setDiscrete(self.SelectorControls[name][0], state)

    # Hide and disable a control
    def disable_hide(self,widget):
        widget.hide()
        widget.setEnabled(False)

    # Set destination lists for the 8pre.  MainOut is index 2 and for the
    # moment we assume the ADAT options follow that.
    def set_8pre_dest_list(self, list):
        list.setItemText(2, "MainOut")
        list.setItemText(3, "ADAT 1-2")
        list.setItemText(4, "ADAT 3-4")
        list.setItemText(5, "ADAT 5-6")
        list.setItemText(6, "ADAT 7-8")
        list.setMaxCount(7)

    def initValues_g1(self):
        # Set up widgets for generation-1 devices (only the 828mk1 for now). 
        # For now disable all mix faders and analog controls since we don't
        # know how to control them (and it's not clear that they are even
        # present in the hardware).
        self.disable_hide(self.mixtab)
        self.disable_hide(self.masterbox)
        self.disable_hide(self.analog_settings_box)

        # The 828mk1 didn't have meter controls
        self.disable_hide(self.meter_src)
        self.disable_hide(self.aesebu_meter)
        self.disable_hide(self.peakhold_time)
        self.disable_hide(self.cliphold_time)

        # For the moment hide this control too since it's not clear how
        # it might be used to interact with the 828mk1.  Ultimately we
        # may be able to reset its items and use it for the monitor source
        # selector.
        self.disable_hide(self.phones_src)
        self.disable_hide(self.phones_src_frame)

    def initValues_g2(self):
        # Set up widgets for generation-2 devices

        # The 828Mk2 has separate Mic inputs but no AES/EBU, so use the
        # AES/EBU mixer controls as "Mic" controls.  If a device comes along
        # with both mic and AES inputs this approach will have to be
        # re-thought.
        # Doing this means that on the 828Mk2, the mixer matrix elements
        # used for AES/EBU on other models are used for the Mic channels. 
        # So long as the MixerChannels_828Mk2 definition in
        # motu_avdevice.cpp defines the mic channels immediately after the 8
        # analog channels we'll be right.  Note that we don't need to change
        # the matrix lookup tables (self.ChannelFaders etc) because the QT
        # controls are still named *aesebu*.
        if (self.model == MOTU_MODEL_828mkII):
            self.mix1_tab.setTabText(1, "Mic inputs");
            self.mix2_tab.setTabText(1, "Mic inputs");
            self.mix3_tab.setTabText(1, "Mic inputs");
            self.mix4_tab.setTabText(1, "Mic inputs");
        else:
            # Only the Traveler and 896HD have AES/EBU inputs, so disable the AES/EBU
            # tab for all other models.
            if (self.model!=MOTU_MODEL_TRAVELER and self.model!=MOTU_MODEL_896HD):
                self.mix1_tab.setTabEnabled(1, False)
                self.mix2_tab.setTabEnabled(1, False)
                self.mix3_tab.setTabEnabled(1, False)
                self.mix4_tab.setTabEnabled(1, False)

        # All models except the 896HD and 8pre have SPDIF inputs.
        if (self.model==MOTU_MODEL_8PRE or self.model==MOTU_MODEL_896HD):
            self.mix1_tab.setTabEnabled(2, False);
            self.mix2_tab.setTabEnabled(2, False);
            self.mix3_tab.setTabEnabled(2, False);
            self.mix4_tab.setTabEnabled(2, False);

        # Devices without AES/EBU inputs/outputs (currently all except the
        # Traveler and 896HD) have dedicated "MainOut" outputs instead. 
        # AES/EBU is normally ID 6 in the destination lists and "MainOut"
        # displaces it on non-AES/EBU models.  The 896HD has both AES/EBU
        # and MainOut which complicates this; it uses ID 6 for MainOut and
        # ID 7 (nominally SPDIF) for AES/EBU.  Therefore change ID 6 to
        # "MainOut" for everything but the Traveler, and set ID 7 (nominally
        # SPDIF) to AES/EBU for the 896HD.
        if (self.model != MOTU_MODEL_TRAVELER):
            self.mix1_dest.setItemText(6, "MainOut")
            self.mix2_dest.setItemText(6, "MainOut")
            self.mix3_dest.setItemText(6, "MainOut")
            self.mix4_dest.setItemText(6, "MainOut")
            self.phones_src.setItemText(6, "MainOut")
        if (self.model == MOTU_MODEL_896HD):
            self.mix1_dest.setItemText(7, "AES/EBU")
            self.mix2_dest.setItemText(7, "AES/EBU")
            self.mix3_dest.setItemText(7, "AES/EBU")
            self.mix4_dest.setItemText(7, "AES/EBU")
            self.phones_src.setItemText(7, "AES/EBU")

        # The Ultralite doesn't have ADAT channels (or any optical ports at
        # all)
        if (self.model == MOTU_MODEL_ULTRALITE):
            self.mix1_tab.setTabEnabled(3, False)  # ADAT page
            self.mix2_tab.setTabEnabled(3, False)  # ADAT page
            self.mix3_tab.setTabEnabled(3, False)  # ADAT page
            self.mix4_tab.setTabEnabled(3, False)  # ADAT page
            self.optical_in_mode.setEnabled(False)
            self.optical_out_mode.setEnabled(False)

        # The 896HD and 8pre don't have optical SPDIF (aka Toslink) capability
        if (self.model==MOTU_MODEL_896HD or self.model==MOTU_MODEL_8PRE):
            self.optical_in_mode.removeItem(2)
            self.optical_out_mode.removeItem(2)

        # The 8pre doesn't have software phones/main fader controls
        if (self.model==MOTU_MODEL_8PRE):
            self.disable_hide(self.mainout_fader)
            self.disable_hide(self.phones_fader)
            self.disable_hide(self.masterbox)

        # The 8pre's destination list is rather different to all other 
        # models.
        if (self.model==MOTU_MODEL_8PRE):
            self.set_8pre_dest_list(self.mix1_dest)
            self.set_8pre_dest_list(self.mix2_dest)
            self.set_8pre_dest_list(self.mix3_dest)
            self.set_8pre_dest_list(self.mix4_dest)
            self.set_8pre_dest_list(self.phones_src)

        # Only the 896HD has meter controls
        if (self.model != MOTU_MODEL_896HD):
            self.disable_hide(self.meter_src)
            self.disable_hide(self.aesebu_meter)
            self.disable_hide(self.peakhold_time)
            self.disable_hide(self.cliphold_time)

        # Some controls must be disabled if the device is streaming
        if (self.is_streaming):
            log.debug("Disabling controls which require inactive streaming")
            self.optical_in_mode.setEnabled(False)
            self.optical_out_mode.setEnabled(False)

        # Some channels aren't available at higher sampling rates
        if (self.sample_rate > 96000):
            log.debug("Disabling controls not present above 96 kHz")
            self.mix1_tab.setTabEnabled(3, False)  # ADAT
            self.mix1_tab.setTabEnabled(2, False)  # SPDIF
            self.mix1_tab.setTabEnabled(1, False)  # AES/EBU
            self.mix2_tab.setTabEnabled(3, False)  # ADAT
            self.mix2_tab.setTabEnabled(2, False)  # SPDIF
            self.mix2_tab.setTabEnabled(1, False)  # AES/EBU
            self.mix3_tab.setTabEnabled(3, False)  # ADAT
            self.mix3_tab.setTabEnabled(2, False)  # SPDIF
            self.mix3_tab.setTabEnabled(1, False)  # AES/EBU
            self.mix4_tab.setTabEnabled(3, False)  # ADAT
            self.mix4_tab.setTabEnabled(2, False)  # SPDIF
            self.mix4_tab.setTabEnabled(1, False)  # AES/EBU
        if (self.sample_rate > 48000):
            log.debug("Disabling controls not present above 48 kHz")
            self.mix1adat5.setEnabled(False)
            self.mix1adat6.setEnabled(False)
            self.mix1adat7.setEnabled(False)
            self.mix1adat8.setEnabled(False)
            self.mix2adat5.setEnabled(False)
            self.mix2adat6.setEnabled(False)
            self.mix2adat7.setEnabled(False)
            self.mix2adat8.setEnabled(False)
            self.mix3adat5.setEnabled(False)
            self.mix3adat6.setEnabled(False)
            self.mix3adat7.setEnabled(False)
            self.mix3adat8.setEnabled(False)
            self.mix4adat5.setEnabled(False)
            self.mix4adat6.setEnabled(False)
            self.mix4adat7.setEnabled(False)
            self.mix4adat8.setEnabled(False)

        # Ensure the correct input controls are active for a given interface.
        # Only the Ultralite has phase inversion switches.
        if (not(self.model == MOTU_MODEL_ULTRALITE)):
            self.disable_hide(self.ana1_invert)
            self.disable_hide(self.ana2_invert)
            self.disable_hide(self.ana3_invert)
            self.disable_hide(self.ana4_invert)
            self.disable_hide(self.ana5_invert)
            self.disable_hide(self.ana6_invert)
            self.disable_hide(self.ana7_invert)
            self.disable_hide(self.ana8_invert)
            self.disable_hide(self.spdif1_invert)
            self.disable_hide(self.spdif2_invert)
        # The Traveler has pad switches for analog 1-4 only; other interfaces
        # don't have pad switches at all.
        if (not(self.model == MOTU_MODEL_TRAVELER)):
            self.disable_hide(self.ana1_pad)
            self.disable_hide(self.ana2_pad)
            self.disable_hide(self.ana3_pad)
            self.disable_hide(self.ana4_pad)
        self.disable_hide(self.ana5_pad)
        self.disable_hide(self.ana6_pad)
        self.disable_hide(self.ana7_pad)
        self.disable_hide(self.ana8_pad)
        # The Traveler has level and boost switches for analog 5-8.  The
        # 8pre, Ultralite and the 896HD don't implement them.  All other
        # interfaces have them over analog 1-8.
        if (self.model==MOTU_MODEL_TRAVELER or self.model==MOTU_MODEL_ULTRALITE or self.model==MOTU_MODEL_896HD or self.model==MOTU_MODEL_8PRE):
            self.disable_hide(self.ana1_level)
            self.disable_hide(self.ana2_level)
            self.disable_hide(self.ana3_level)
            self.disable_hide(self.ana4_level)
            self.disable_hide(self.ana1_boost)
            self.disable_hide(self.ana2_boost)
            self.disable_hide(self.ana3_boost)
            self.disable_hide(self.ana4_boost)
        if (self.model==MOTU_MODEL_ULTRALITE or self.model==MOTU_MODEL_896HD or self.model==MOTU_MODEL_8PRE):
            self.disable_hide(self.ana5_level)
            self.disable_hide(self.ana6_level)
            self.disable_hide(self.ana7_level)
            self.disable_hide(self.ana8_level)
            self.disable_hide(self.ana5_boost)
            self.disable_hide(self.ana6_boost)
            self.disable_hide(self.ana7_boost)
            self.disable_hide(self.ana8_boost)
        # The Traveler has trimgain for analog 1-4.  The Ultralite has trimgain for
        # analog 1-8 and SPDIF 1-2.  All other interfaces don't have trimgain.
        if (not(self.model==MOTU_MODEL_TRAVELER or self.model==MOTU_MODEL_ULTRALITE)):
            self.disable_hide(self.ana1_trimgain)
            self.disable_hide(self.ana1_trimgain_label)
            self.disable_hide(self.ana2_trimgain)
            self.disable_hide(self.ana2_trimgain_label)
            self.disable_hide(self.ana3_trimgain)
            self.disable_hide(self.ana3_trimgain_label)
            self.disable_hide(self.ana4_trimgain)
            self.disable_hide(self.ana4_trimgain_label)
        if (not(self.model == MOTU_MODEL_ULTRALITE)):
            self.disable_hide(self.ana5_trimgain)
            self.disable_hide(self.ana5_trimgain_label)
            self.disable_hide(self.ana6_trimgain)
            self.disable_hide(self.ana6_trimgain_label)
            self.disable_hide(self.ana7_trimgain)
            self.disable_hide(self.ana7_trimgain_label)
            self.disable_hide(self.ana8_trimgain)
            self.disable_hide(self.ana8_trimgain_label)
            self.disable_hide(self.spdif1_trimgain)
            self.disable_hide(self.spdif1_trimgain_label)
            self.disable_hide(self.spdif1ctrl)
            self.disable_hide(self.spdif2_trimgain)
            self.disable_hide(self.spdif2_trimgain_label)
            self.disable_hide(self.spdif2ctrl)

        # The 8pre has no digital controls for the analog inputs, so there's
        # no point in showing the frame which would normally contain them.
        if (self.model == MOTU_MODEL_8PRE):
            self.disable_hide(self.analog_settings_box)

    def initValues(self):
        # Is the device streaming?
        self.is_streaming = self.hw.getDiscrete('/Mixer/Info/IsStreaming')
        log.debug("device streaming flag: %d" % (self.is_streaming))

        # Retrieve other device settings as needed and customise the UI
        # based on these options.
        self.model = self.hw.getDiscrete('/Mixer/Info/Model')
        log.debug("device model identifier: %d" % (self.model))
        self.sample_rate = self.hw.getDiscrete('/Mixer/Info/SampleRate')
        log.debug("device sample rate: %d" % (self.sample_rate))

        # MOTU Mark 3 devices should be configured to use the "Motu_Mark3" 
        # mixer.
        if (self.model==MOTU_MODEL_828mk3 or self.model==MOTU_MODEL_ULTRALITEmk3 or self.model==MOTU_MODEL_ULTRALITEmk3_HYB or self.model==MOTU_MODEL_TRAVELERmk3 or self.model==MOTU_MODEL_896HDmk3):
            log.debug("Generation-3 MOTU devices should be configured to use the Motu_Mark3 mixer")
            return
        elif (self.model==MOTU_MODEL_828MkI):
            self.initValues_g1()
        else:
            self.initValues_g2()

        # Now fetch the current values into the respective controls.  Don't
        # bother fetching controls which are disabled.
        for ctrl, info in self.ChannelFaders.iteritems():
            if (not(ctrl.isEnabled())):
                continue
            vol = self.hw.getMatrixMixerValue(info[0], info[1], info[2])
            log.debug("%s for mix %d channel %d is %d" % (info[0], info[1], info[2], vol))
            ctrl.setValue(vol)
            QObject.connect(ctrl, SIGNAL('valueChanged(int)'), self.updateChannelFader)

        for ctrl, info in self.Faders.iteritems():
            if (not(ctrl.isEnabled())):
                continue
            vol = self.hw.getDiscrete(info[0])
            log.debug("%s mix fader is %d" % (info[0] , vol))
            ctrl.setValue(vol)
            QObject.connect(ctrl, SIGNAL('valueChanged(int)'), self.updateFader)

        for ctrl, info in self.ChannelControls.iteritems():
            if (not(ctrl.isEnabled())):
                continue
            pan = self.hw.getMatrixMixerValue(info[0], info[1], info[2])
            log.debug("%s for mix %d channel %d is %d" % (info[0], info[1], info[2], pan))
            ctrl.setValue(pan)
            QObject.connect(ctrl, SIGNAL('valueChanged(int)'), self.updateChannelControl)

        for ctrl, info in self.Controls.iteritems():
            if (not(ctrl.isEnabled())):
                continue
            pan = self.hw.getDiscrete(info[0])
            log.debug("%s control is %d" % (info[0] , pan))
            ctrl.setValue(pan)
            QObject.connect(ctrl, SIGNAL('valueChanged(int)'), self.updateControl)

        for ctrl, info in self.ChannelBinarySwitches.iteritems():
            if (not(ctrl.isEnabled())):
                continue
            val = self.hw.getMatrixMixerValue(info[0], info[1], info[2])
            log.debug("%s for mix %d channel %d is %d" % (info[0] , info[1], info[2], val))
            if val:
                ctrl.setChecked(True)
            else:
                ctrl.setChecked(False)
            QObject.connect(ctrl, SIGNAL('toggled(bool)'), self.updateChannelBinarySwitch)

        for ctrl, info in self.BinarySwitches.iteritems():
            if (not(ctrl.isEnabled())):
                continue
            val = self.hw.getDiscrete(info[0])
            log.debug("%s switch is %d" % (info[0] , val))
            if val:
                ctrl.setChecked(True)
            else:
                ctrl.setChecked(False)
            QObject.connect(ctrl, SIGNAL('toggled(bool)'), self.updateBinarySwitch)

        for ctrl, info in self.Selectors.iteritems():
            if (not(ctrl.isEnabled())):
                continue
            dest = self.hw.getDiscrete(info[0])
            log.debug("%s selector is %d" % (info[0] , dest))
            ctrl.setCurrentIndex(dest)
            QObject.connect(ctrl, SIGNAL('activated(int)'), self.updateSelector)

        # We could enable/disable ADAT controls here depending on whether
        # the optical port is set to ADAT or something else.  A disable
        # can't be done earlier since we have to read the ADAT mixer
        # settings (which won't happen if they're disabled).  However, on
        # the other hand it may be more convenient to leave all controls
        # active at all times.  We'll see.

# vim: et