4545#define MAX_HIZS 2
4646#define MAX_PADS 4
4747#define MAX_AIRS 2
48+ #define MAX_PHANTOM_POWERS 1
4849
4950typedef struct {
5051 char name [64 ];
@@ -58,6 +59,7 @@ typedef struct {
5859 unsigned num_hiz ;
5960 unsigned num_pad ;
6061 unsigned num_air ;
62+ unsigned num_phantom_power ;
6163 bool pads_are_switches ;
6264 bool matrix_mix_column_major ;
6365 unsigned matrix_mix_offset ;
@@ -71,6 +73,7 @@ typedef struct {
7173 int hiz_map [MAX_HIZS ];
7274 int pad_map [MAX_PADS ];
7375 int air_map [MAX_AIRS ];
76+ int phantom_power_map [MAX_PHANTOM_POWERS ];
7477} Device ;
7578
7679static Device devices [] = {
@@ -83,6 +86,7 @@ static Device devices[] = {
8386 .num_hiz = 2 ,
8487 .num_pad = 0 ,
8588 .num_air = 0 ,
89+ .num_phantom_power = 0 ,
8690 .pads_are_switches = false,
8791 .matrix_mix_column_major = false,
8892 .matrix_mix_offset = 33 , .matrix_mix_stride = 7 ,
@@ -103,6 +107,7 @@ static Device devices[] = {
103107 .num_hiz = 2 ,
104108 .num_pad = 4 ,
105109 .num_air = 0 ,
110+ .num_phantom_power = 0 ,
106111 .pads_are_switches = false,
107112 .matrix_mix_column_major = false,
108113 .matrix_mix_offset = 40 , .matrix_mix_stride = 9 , // < Matrix 01 Mix A
@@ -123,6 +128,7 @@ static Device devices[] = {
123128 .num_hiz = 2 ,
124129 .num_pad = 4 , // XXX does the device have pad? bug in kernel-driver?
125130 .num_air = 0 ,
131+ .num_phantom_power = 0 ,
126132 .pads_are_switches = false,
127133 .matrix_mix_column_major = false,
128134 .matrix_mix_offset = 26 , .matrix_mix_stride = 9 , // XXX stride should be 7, bug in kernel-driver ?!
@@ -143,6 +149,7 @@ static Device devices[] = {
143149 .num_hiz = 0 ,
144150 .num_pad = 0 ,
145151 .num_air = 0 ,
152+ .num_phantom_power = 0 ,
146153 .pads_are_switches = false,
147154 .matrix_mix_column_major = false,
148155 .matrix_mix_offset = 50 , .matrix_mix_stride = 9 ,
@@ -161,8 +168,9 @@ static Device devices[] = {
161168 .smst = 0 ,
162169 .samo = 4 ,
163170 .num_hiz = 2 ,
164- .num_pad = 2 ,
165- .num_air = 2 ,
171+ .num_pad = 2 ,
172+ .num_air = 2 ,
173+ .num_phantom_power = 0 ,
166174 .pads_are_switches = true,
167175 .matrix_mix_column_major = true,
168176 .matrix_mix_offset = 20 , .matrix_mix_stride = 8 ,
@@ -184,6 +192,7 @@ static Device devices[] = {
184192 .num_hiz = 2 ,
185193 .num_pad = 2 ,
186194 .num_air = 2 ,
195+ .num_phantom_power = 1 ,
187196 .pads_are_switches = true,
188197 .matrix_mix_column_major = true,
189198 .matrix_mix_offset = 21 , .matrix_mix_stride = 8 ,
@@ -195,6 +204,7 @@ static Device devices[] = {
195204 .hiz_map = { 15 , 19 },
196205 .pad_map = { 16 , 20 , -1 , -1 },
197206 .air_map = { 14 , 18 },
207+ .phantom_power_map = { 17 },
198208 },
199209};
200210
@@ -232,6 +242,7 @@ typedef struct {
232242 RobTkCBtn * * btn_hiz ;
233243 RobTkCBtn * * btn_pad ;
234244 RobTkCBtn * * btn_air ;
245+ RobTkCBtn * * btn_phantom_power ;
235246 RobTkPBtn * btn_reset ;
236247
237248 RobTkLbl * heading [3 ];
@@ -380,6 +391,13 @@ static Mctrl* air (RobTkApp *ui, unsigned c)
380391 return & ui -> ctrl [ui -> device -> air_map [c ]];
381392}
382393
394+ /* Phantom power switches */
395+ static Mctrl * phantom_power (RobTkApp * ui , unsigned c )
396+ {
397+ assert (c < ui -> device -> num_phantom_power );
398+ return & ui -> ctrl [ui -> device -> phantom_power_map [c ]];
399+ }
400+
383401/* master gain */
384402static Mctrl * mst_gain (RobTkApp * ui )
385403{
@@ -602,6 +620,8 @@ static int open_mixer (RobTkApp* ui, const char* card, int opts)
602620 d .pads_are_switches = true;
603621 } else if (strstr (c -> name , " Air" )) {
604622 d .air_map [d .num_air ++ ] = i ;
623+ } else if (strstr (c -> name , " Phantom Power" )) {
624+ d .phantom_power_map [d .num_phantom_power ++ ] = i ;
605625 }
606626 } else {
607627 if (strstr (c -> name , "Line 0" ) || strstr (c -> name , "Line 1" )) {
@@ -896,6 +916,15 @@ static bool cb_set_air (RobWidget* w, void* handle) {
896916 return TRUE;
897917}
898918
919+ static bool cb_set_phantom_power (RobWidget * w , void * handle ) {
920+ RobTkApp * ui = (RobTkApp * )handle ;
921+ if (ui -> disable_signals ) return TRUE;
922+ for (uint32_t i = 0 ; i < ui -> device -> num_phantom_power ; ++ i ) {
923+ set_switch (phantom_power (ui , i ), robtk_cbtn_get_active (ui -> btn_phantom_power [i ]));
924+ }
925+ return TRUE;
926+ }
927+
899928static bool cb_src_sel (RobWidget * w , void * handle ) {
900929 RobTkApp * ui = (RobTkApp * )handle ;
901930 if (ui -> disable_signals ) return TRUE;
@@ -1195,6 +1224,11 @@ static RobWidget* toplevel (RobTkApp* ui, void* const top) {
11951224 } else {
11961225 ui -> btn_air = NULL ;
11971226 }
1227+ if (ui -> device -> num_phantom_power > 0 ) {
1228+ ui -> btn_phantom_power = malloc (ui -> device -> num_phantom_power * sizeof (RobTkCBtn * ));
1229+ } else {
1230+ ui -> btn_phantom_power = NULL ;
1231+ }
11981232
11991233 const int c0 = 4 ; // matrix column offset
12001234 const int rb = 2 + ui -> device -> smi ; // matrix bottom
@@ -1429,6 +1463,15 @@ static RobWidget* toplevel (RobTkApp* ui, void* const top) {
14291463 i , i + 1 , 5 , 6 , 0 , 0 , RTK_SHRINK , RTK_SHRINK );
14301464 }
14311465
1466+ /* Phantom Power */
1467+ for (unsigned int i = 0 ; i < ui -> device -> num_phantom_power ; ++ i ) {
1468+ ui -> btn_phantom_power [i ] = robtk_cbtn_new ("Phantom" , GBT_LED_LEFT , false);
1469+ robtk_cbtn_set_active (ui -> btn_phantom_power [i ], get_switch (phantom_power (ui , i )) == 1 );
1470+ robtk_cbtn_set_callback (ui -> btn_phantom_power [i ], cb_set_phantom_power , ui );
1471+ rob_table_attach (ui -> output , robtk_cbtn_widget (ui -> btn_phantom_power [i ]),
1472+ i , i + 1 , 6 , 7 , 0 , 0 , RTK_SHRINK , RTK_SHRINK );
1473+ }
1474+
14321475 /* output selectors */
14331476 for (unsigned int o = 0 ; o < ui -> device -> sout ; ++ o ) {
14341477 int row = 4 * floor (o / 10 ); // beware of bleed into Hi-Z, Pads
@@ -1525,6 +1568,10 @@ static void gui_cleanup (RobTkApp* ui) {
15251568 robtk_cbtn_destroy (ui -> btn_air [i ]);
15261569 }
15271570
1571+ for (int i = 0 ; i < ui -> device -> num_phantom_power ; i ++ ) {
1572+ robtk_cbtn_destroy (ui -> btn_phantom_power [i ]);
1573+ }
1574+
15281575 robtk_sep_destroy (ui -> sep_v );
15291576 robtk_sep_destroy (ui -> sep_h );
15301577 robtk_sep_destroy (ui -> spc_v [0 ]);
@@ -1554,6 +1601,7 @@ static void gui_cleanup (RobTkApp* ui) {
15541601 free (ui -> btn_hiz );
15551602 free (ui -> btn_pad );
15561603 free (ui -> btn_air );
1604+ free (ui -> btn_phantom_power );
15571605}
15581606
15591607static char * lookup_device ()
0 commit comments