diff options
Diffstat (limited to 'src/frontend/ui_mixer.fl')
-rw-r--r-- | src/frontend/ui_mixer.fl | 2225 |
1 files changed, 2225 insertions, 0 deletions
diff --git a/src/frontend/ui_mixer.fl b/src/frontend/ui_mixer.fl new file mode 100644 index 0000000..11dee83 --- /dev/null +++ b/src/frontend/ui_mixer.fl | |||
@@ -0,0 +1,2225 @@ | |||
1 | # data file for the Fltk User Interface Designer (fluid) | ||
2 | version 1.0109 | ||
3 | header_name {.h} | ||
4 | code_name {.cxx} | ||
5 | decl {\#define MAXSAMRATE 48000} {public | ||
6 | } | ||
7 | |||
8 | decl {\#define maxfilterunits 200} {public | ||
9 | } | ||
10 | |||
11 | decl {\#define maxreverbunits 20} {public | ||
12 | } | ||
13 | |||
14 | decl {\#define maxreverbseconds 1} {public | ||
15 | } | ||
16 | |||
17 | decl {\#define eqperchan 4} {public | ||
18 | } | ||
19 | |||
20 | decl {\#define Pi2 (2*3.1415926535897)} {public | ||
21 | } | ||
22 | |||
23 | decl {\#include <config.h>} {public | ||
24 | } | ||
25 | |||
26 | decl {\#include <string>} {public | ||
27 | } | ||
28 | |||
29 | decl {\#include <vector>} {public | ||
30 | } | ||
31 | |||
32 | decl {\#include <soundlibs.h>} {public | ||
33 | } | ||
34 | |||
35 | decl {\#include <iostream>} {public | ||
36 | } | ||
37 | |||
38 | decl {\#include <fstream>} {public | ||
39 | } | ||
40 | |||
41 | decl {\#include <FL/FLTKstuff.H>} {public | ||
42 | } | ||
43 | |||
44 | decl {\#include <FL/filename.H>} {public | ||
45 | } | ||
46 | |||
47 | decl {\#include <convertlib.h>} {public | ||
48 | } | ||
49 | |||
50 | decl {\#include <WidgetPDial.h>} {public | ||
51 | } | ||
52 | |||
53 | decl {\#include <time.h>} {public | ||
54 | } | ||
55 | |||
56 | decl {\#include <math.h>} {public | ||
57 | } | ||
58 | |||
59 | decl {\#include <ui_hd24connect.h>} {public | ||
60 | } | ||
61 | |||
62 | class stereosample {open | ||
63 | } { | ||
64 | decl {float left;} {public | ||
65 | } | ||
66 | decl {float right;} {public | ||
67 | } | ||
68 | } | ||
69 | |||
70 | decl {class MixerChannelControl;} {public | ||
71 | } | ||
72 | |||
73 | decl {class MixerChannelUI;} {public | ||
74 | } | ||
75 | |||
76 | decl {class MixerChannelData;} {public | ||
77 | } | ||
78 | |||
79 | decl {class MasterChannelUI;} {public | ||
80 | } | ||
81 | |||
82 | decl {class MasterChannelControl;} {public | ||
83 | } | ||
84 | |||
85 | decl {class MixerControl;} {public | ||
86 | } | ||
87 | |||
88 | decl {class MixerChannelUI;} {public | ||
89 | } | ||
90 | |||
91 | class MixerLevelMeterData {} { | ||
92 | decl {\#define PEAKMODE_NOHOLD 0} {public | ||
93 | } | ||
94 | decl {\#define PEAKMODE_TEMPHOLD 1} {public | ||
95 | } | ||
96 | decl {\#define PEAKMODE_CONTHOLD 2} {public | ||
97 | } | ||
98 | decl {\#define PEAKMODE_MAXHOLD 33} {public | ||
99 | } | ||
100 | decl {int mode;} {public | ||
101 | } | ||
102 | decl {double dB;} {public | ||
103 | } | ||
104 | decl {double peakvalue; /* for peak hold */} {public | ||
105 | } | ||
106 | decl {double metervalue;} {public | ||
107 | } | ||
108 | decl {int holdtime;} {public | ||
109 | } | ||
110 | decl {int dBrange;} {public | ||
111 | } | ||
112 | } | ||
113 | |||
114 | class MixerLevelMeterControl {} { | ||
115 | decl {MixerLevelMeterData* data;} {} | ||
116 | Function {MixerLevelMeterControl()} {open | ||
117 | } { | ||
118 | code {data=new MixerLevelMeterData; | ||
119 | init();} {} | ||
120 | } | ||
121 | Function {~MixerLevelMeterControl()} {open | ||
122 | } { | ||
123 | code {delete data;} {} | ||
124 | } | ||
125 | Function {setvalue(double levelval)} {open | ||
126 | } { | ||
127 | code {data->dB=20*log10(levelval); | ||
128 | return; | ||
129 | |||
130 | // reset peaks if desired | ||
131 | switch (data->mode) { | ||
132 | case PEAKMODE_NOHOLD: this->peakreset(); break; | ||
133 | case PEAKMODE_TEMPHOLD: | ||
134 | if (data->holdtime>PEAKMODE_MAXHOLD) { | ||
135 | peakreset(); | ||
136 | } else { | ||
137 | data->holdtime++; | ||
138 | } | ||
139 | break; | ||
140 | case PEAKMODE_CONTHOLD: | ||
141 | break; | ||
142 | default: | ||
143 | data->mode=PEAKMODE_NOHOLD; | ||
144 | peakreset(); | ||
145 | break; | ||
146 | } | ||
147 | |||
148 | if (levelval>data->metervalue) { | ||
149 | data->peakvalue=data->metervalue; | ||
150 | data->holdtime=0; | ||
151 | }} {} | ||
152 | } | ||
153 | Function {peakmode(int p_peakmode)} {open return_type void | ||
154 | } { | ||
155 | code {data->mode=p_peakmode; | ||
156 | peakreset();} {} | ||
157 | } | ||
158 | Function {peakreset()} {open return_type void | ||
159 | } { | ||
160 | code {data->peakvalue=0; | ||
161 | data->holdtime=0;} {} | ||
162 | } | ||
163 | Function {init()} {open return_type void | ||
164 | } { | ||
165 | code {data->peakvalue=0; | ||
166 | data->holdtime=0; | ||
167 | |||
168 | data->dBrange=60; | ||
169 | this->setvalue(0); | ||
170 | return;} {} | ||
171 | } | ||
172 | Function {getpctvalue()} {open return_type float | ||
173 | } { | ||
174 | code {float pct=100-(100*(-(data->dB)/(data->dBrange))); | ||
175 | |||
176 | if (pct<0) { pct=0; } | ||
177 | if (pct>100) { pct=100; } | ||
178 | |||
179 | return pct;} {} | ||
180 | } | ||
181 | } | ||
182 | |||
183 | class MixerLevelMeterUI {: {public Fl_Group} | ||
184 | } { | ||
185 | decl {MixerLevelMeterControl* control;} {public | ||
186 | } | ||
187 | Function {MixerLevelMeterUI(int a,int b,int c,int d,const char* e):Fl_Group(a,b,c,d,e)} {} { | ||
188 | code {init_ui();} {} | ||
189 | } | ||
190 | Function {MixerLevelMeterUI(int a,int b,int c,int d):Fl_Group(a,b,c,d,NULL)} {} { | ||
191 | code {init_ui();} {} | ||
192 | } | ||
193 | Function {init_ui()} {open private | ||
194 | } { | ||
195 | code {this->control=new MixerLevelMeterControl();} {} | ||
196 | } | ||
197 | Function {draw()} {open | ||
198 | } { | ||
199 | code {float pct=(control->getpctvalue())/100; | ||
200 | |||
201 | int zro=y(); | ||
202 | int bot=zro+128; | ||
203 | int myx=x(); | ||
204 | int top=bot- ((int)( pct*128)); | ||
205 | |||
206 | fl_color(fl_rgb_color(0,255,0)); | ||
207 | fl_line(myx,top,myx,bot); | ||
208 | myx++; | ||
209 | fl_line(myx,top,myx,bot); | ||
210 | myx--; | ||
211 | |||
212 | fl_color(fl_rgb_color(0,0,0)); | ||
213 | fl_line(myx,zro,myx,top); | ||
214 | myx++; | ||
215 | fl_line(myx,zro,myx,top); | ||
216 | |||
217 | return;} {} | ||
218 | } | ||
219 | Function {~MixerLevelMeterUI()} {open | ||
220 | } { | ||
221 | code {delete control;} {} | ||
222 | } | ||
223 | } | ||
224 | |||
225 | class MixerChannelData {open | ||
226 | } { | ||
227 | decl {int bypass; /* 1 to bypass all mixing */} {public | ||
228 | } | ||
229 | decl {friend class MixerChannelUI;} {} | ||
230 | decl {friend class MixerChannelControl;} {} | ||
231 | decl {MixerChannelUI* parentui;} {} | ||
232 | decl {double trackpeak;} {public | ||
233 | } | ||
234 | decl {int enable_eq; /* overall eq settings */} {public | ||
235 | } | ||
236 | decl {int enable_pan; /* overall eq settings */} {public | ||
237 | } | ||
238 | decl {int eq_on[eqperchan];} {public | ||
239 | } | ||
240 | decl {double eq_gain[eqperchan];} {public | ||
241 | } | ||
242 | decl {double eq_freq[eqperchan];} {public | ||
243 | } | ||
244 | decl {double eq_Q[eqperchan];} {public | ||
245 | } | ||
246 | decl {double eq_type[eqperchan];} {public | ||
247 | } | ||
248 | decl {double fadermult;} {public | ||
249 | } | ||
250 | decl {double faderval;} {public | ||
251 | } | ||
252 | decl {double panvalue;} {public | ||
253 | } | ||
254 | decl {float* delaybuffer;} {} | ||
255 | decl {long delaybuffersize;} {public | ||
256 | } | ||
257 | decl {long delaybuffersam;} {public | ||
258 | } | ||
259 | decl {int solo;} {} | ||
260 | decl {int mute;} {} | ||
261 | decl {int ch_number;} {} | ||
262 | decl {char strchnum[4];} {} | ||
263 | decl {float* sample;} {public | ||
264 | } | ||
265 | decl {int mixmono;} {} | ||
266 | decl {MixerControl* parentmixercontrol;} {} | ||
267 | decl {__uint32 samplerate;} {public | ||
268 | } | ||
269 | decl {int selected;} {} | ||
270 | decl {int ringbufpos[maxreverbunits];} {} | ||
271 | } | ||
272 | |||
273 | class MixerChannelControl {open | ||
274 | } { | ||
275 | decl {friend class MixerChannelUI;} {} | ||
276 | decl {friend class MixerChannelData;} {} | ||
277 | decl {MixerChannelData* data;} {public | ||
278 | } | ||
279 | Function {init()} {open return_type void | ||
280 | } { | ||
281 | code {data->bypass=0; | ||
282 | data->trackpeak=0; | ||
283 | data->enable_eq=1; | ||
284 | data->enable_pan=1; | ||
285 | data->solo=0; | ||
286 | data->mute=0; | ||
287 | data->sample=(float *)malloc(24000*sizeof(float)); | ||
288 | data->eq_gain[0]=0; | ||
289 | data->eq_gain[1]=0; | ||
290 | data->eq_gain[2]=0; | ||
291 | data->eq_gain[3]=0; | ||
292 | data->eq_Q[0]=1; | ||
293 | data->eq_Q[1]=1; | ||
294 | data->eq_Q[2]=1; | ||
295 | data->eq_Q[3]=1; | ||
296 | data->eq_on[0]=1; | ||
297 | data->eq_on[1]=1; | ||
298 | data->eq_on[2]=1; | ||
299 | data->eq_on[3]=1; | ||
300 | data->eq_freq[0]=100; | ||
301 | data->eq_freq[1]=600; | ||
302 | data->eq_freq[2]=1600; | ||
303 | data->eq_freq[3]=6000; | ||
304 | data->samplerate=44100; // TODO: set to proper val | ||
305 | data->faderval=90; | ||
306 | data->fadermult=1; | ||
307 | data->panvalue=0; | ||
308 | |||
309 | |||
310 | data->delaybuffersize=maxreverbunits*maxreverbseconds*MAXSAMRATE; | ||
311 | data->delaybuffer=(float *)malloc(sizeof(float)*(data->delaybuffersize)); | ||
312 | if (data->delaybuffer==NULL) cout << " out of mem L" << endl; | ||
313 | data->delaybuffersam=data->delaybuffersize; | ||
314 | for (int i=0;i<data->delaybuffersize;i++) | ||
315 | { | ||
316 | data->delaybuffer[i]=0; | ||
317 | } | ||
318 | data->ringbufpos[0]=881; | ||
319 | data->ringbufpos[1]=883; | ||
320 | data->ringbufpos[2]=887; | ||
321 | data->ringbufpos[3]=907; | ||
322 | data->ringbufpos[4]=911; | ||
323 | data->ringbufpos[5]=919; | ||
324 | data->ringbufpos[6]=929; | ||
325 | data->ringbufpos[7]=937; | ||
326 | data->ringbufpos[8]=941; | ||
327 | data->ringbufpos[9]=947; | ||
328 | data->ringbufpos[10]=953; | ||
329 | data->ringbufpos[11]=967; | ||
330 | data->ringbufpos[12]=971; | ||
331 | data->ringbufpos[13]=977; | ||
332 | data->ringbufpos[14]=983; | ||
333 | data->ringbufpos[15]=991; | ||
334 | data->ringbufpos[16]=997; | ||
335 | data->ringbufpos[17]=1009; | ||
336 | data->ringbufpos[18]=1013; | ||
337 | data->ringbufpos[19]=1019; | ||
338 | |||
339 | return;} {} | ||
340 | } | ||
341 | Function {MixerChannelControl()} {open | ||
342 | } { | ||
343 | code {data=new MixerChannelData(); | ||
344 | init();} {} | ||
345 | } | ||
346 | Function {~MixerChannelControl()} {open | ||
347 | } { | ||
348 | code {free (data->sample); | ||
349 | data->sample=NULL; | ||
350 | free (data->delaybuffer); | ||
351 | data->delaybuffer=NULL; | ||
352 | delete data; | ||
353 | data=NULL;} {} | ||
354 | } | ||
355 | Function {fadervalue(const double p_val)} {} { | ||
356 | code {double lin; | ||
357 | if (p_val == 0) { | ||
358 | lin=0; | ||
359 | } else { | ||
360 | lin=pow(10,(p_val-90)/60); | ||
361 | } | ||
362 | data->fadermult=lin; | ||
363 | data->faderval=p_val; | ||
364 | data->parentui->fader->value(p_val); | ||
365 | data->parentui->redraw();} {} | ||
366 | } | ||
367 | Function {fadervalue()} {open return_type double | ||
368 | } { | ||
369 | code {return data->faderval;} {} | ||
370 | } | ||
371 | Function {updatemeters()} {open return_type void | ||
372 | } { | ||
373 | code {// update and redraw meterlevels object | ||
374 | this->parentui()->mixled->control->setvalue(data->trackpeak); | ||
375 | this->parentui()->mixled->redraw(); | ||
376 | // then, reset peak value | ||
377 | trackpeak(0);} {} | ||
378 | } | ||
379 | Function {solo(int p_val)} {open return_type void | ||
380 | } { | ||
381 | code {data->solo=p_val; | ||
382 | data->parentui->mixsolo->value(p_val); | ||
383 | data->parentui->mixsolo->damage(); | ||
384 | data->parentui->mixsolo->redraw(); | ||
385 | if (p_val==1) | ||
386 | { | ||
387 | this->parentmixercontrol()->selectedchannel(this->channel_number()-1); | ||
388 | }} {} | ||
389 | } | ||
390 | Function {mute(int p_val)} {open return_type void | ||
391 | } { | ||
392 | code {data->mute=p_val; | ||
393 | data->parentui->mixmute->value(p_val); | ||
394 | data->parentui->mixmute->damage(); | ||
395 | data->parentui->mixmute->redraw(); | ||
396 | //if (ui!=NULL) { | ||
397 | // ui->readmixer(); | ||
398 | //}} {} | ||
399 | } | ||
400 | Function {solo()} {open return_type int | ||
401 | } { | ||
402 | code {return data->solo;} {} | ||
403 | } | ||
404 | Function {mute()} {open return_type int | ||
405 | } { | ||
406 | code {return data->mute;} {} | ||
407 | } | ||
408 | Function {issolo()} {open return_type int | ||
409 | } { | ||
410 | code {return data->solo;} {} | ||
411 | } | ||
412 | Function {ismute()} {open return_type int | ||
413 | } { | ||
414 | code {return data->mute;} {} | ||
415 | } | ||
416 | Function {getfadermult()} {open return_type double | ||
417 | } { | ||
418 | code {return data->fadermult;} {} | ||
419 | } | ||
420 | Function {trackpeak()} {open return_type double | ||
421 | } { | ||
422 | code {return data->trackpeak;} {} | ||
423 | } | ||
424 | Function {trackpeak(double peakval)} {open return_type void | ||
425 | } { | ||
426 | code {data->trackpeak=peakval;} {} | ||
427 | } | ||
428 | Function {channel_number(int ch)} {open return_type void | ||
429 | } { | ||
430 | code {data->ch_number=ch; | ||
431 | snprintf(data->strchnum,3,"%d",ch); | ||
432 | data->parentui->mixmute->label(data->strchnum);} {} | ||
433 | } | ||
434 | Function {channel_number()} {open return_type int | ||
435 | } { | ||
436 | code {return data->ch_number;} {} | ||
437 | } | ||
438 | Function {parentmixercontrol(MixerControl* p_parentmixercontrol)} {open return_type void | ||
439 | } { | ||
440 | code {data->parentmixercontrol=p_parentmixercontrol;} {} | ||
441 | } | ||
442 | Function {parentui(MixerChannelUI* p_parentui)} {open return_type void | ||
443 | } { | ||
444 | code {data->parentui=p_parentui;} {} | ||
445 | } | ||
446 | Function {parentui()} {open return_type {MixerChannelUI*} | ||
447 | } { | ||
448 | code {return data->parentui;} {} | ||
449 | } | ||
450 | Function {parentmixercontrol()} {open return_type {MixerControl*} | ||
451 | } { | ||
452 | code {return data->parentmixercontrol;} {} | ||
453 | } | ||
454 | Function {panvalue(const double p_val)} {open | ||
455 | } { | ||
456 | code {data->panvalue=p_val; | ||
457 | data->parentui->mixpan->value(p_val); | ||
458 | data->parentui->mixpan->damage(); | ||
459 | data->parentui->mixpan->redraw();} {} | ||
460 | } | ||
461 | Function {panvalue()} {open return_type double | ||
462 | } { | ||
463 | code {return data->panvalue;} {} | ||
464 | } | ||
465 | Function {sample(int framenum,float samval)} {open | ||
466 | } { | ||
467 | code {if (data==NULL) return; | ||
468 | if ((data->sample)==NULL) return; | ||
469 | data->sample[framenum]=samval; | ||
470 | /*float q=1; | ||
471 | if (samval<0) { | ||
472 | q=-1; | ||
473 | } | ||
474 | if ((samval*q) > data->trackpeak) { | ||
475 | data->trackpeak=samval*q; | ||
476 | }*/} {} | ||
477 | } | ||
478 | Function {sample(int framenum)} {return_type float | ||
479 | } { | ||
480 | code {return data->sample[framenum];} {} | ||
481 | } | ||
482 | Function {getsample(stereosample* sam,int framenum)} {open return_type void | ||
483 | } { | ||
484 | code {float monosam=data->sample[framenum]; | ||
485 | |||
486 | if (data->bypass==1) | ||
487 | { | ||
488 | /* Bypass all mixer functions, just return the sample */ | ||
489 | sam->left=monosam/2; | ||
490 | sam->right=monosam/2; | ||
491 | return; | ||
492 | } | ||
493 | |||
494 | float panval; | ||
495 | if (data->enable_eq==1) { | ||
496 | int Q=1; | ||
497 | // FilterCell(unsigned long Unit, double Input, double Frequency, double Q, double Gain, unsigned long Type) | ||
498 | if (eq_on(0)==1 && (eq_gain(0)!=0)) monosam=FilterCell(0,monosam,eq_freq(0),Q,eq_gain(0),7); | ||
499 | if (eq_on(1)==1 && (eq_gain(1)!=0)) monosam=FilterCell(1,monosam,eq_freq(1),Q,eq_gain(1),7); | ||
500 | if (eq_on(2)==1 && (eq_gain(2)!=0)) monosam=FilterCell(2,monosam,eq_freq(2),Q,eq_gain(2),7); | ||
501 | if (eq_on(3)==1 && (eq_gain(3)!=0)) monosam=FilterCell(3,monosam,eq_freq(3),Q,eq_gain(3),7); | ||
502 | } | ||
503 | |||
504 | monosam*=getfadermult(); | ||
505 | |||
506 | sam->left=monosam; | ||
507 | sam->right=monosam; | ||
508 | |||
509 | if (data->enable_pan==1) | ||
510 | { | ||
511 | panval=panvalue(); | ||
512 | } else { | ||
513 | panval=0; | ||
514 | } | ||
515 | |||
516 | float pctright=(panval+127)/254; | ||
517 | float pctleft=1-pctright; | ||
518 | sam->left*=pctleft; | ||
519 | sam->right*=pctright; | ||
520 | |||
521 | float subsamval=fabs(monosam); | ||
522 | if (subsamval > trackpeak()) { | ||
523 | trackpeak(subsamval); | ||
524 | } | ||
525 | |||
526 | return;} {} | ||
527 | } | ||
528 | Function {channelselect(int select)} {return_type void | ||
529 | } { | ||
530 | code {data->selected=select; | ||
531 | parentui()->mixchsel->value(select); | ||
532 | parentui()->mixchsel->redraw();} {} | ||
533 | } | ||
534 | Function {FilterCell(unsigned long Unit, double Input, double Frequency, double Q, double Gain, unsigned long Type)} {return_type double | ||
535 | } { | ||
536 | code {__uint32 SampleRate=data->samplerate; | ||
537 | |||
538 | /* --------------------------------------------------------------- */ | ||
539 | double Output,S,omega,A,sn,cs,alpha,beta,temp1,temp2,temp3,temp4; | ||
540 | Output=Input; | ||
541 | |||
542 | /* -- check if frequency, Q, gain or type has changed.. and, if so, update coefficients */ | ||
543 | if ( ( Frequency != filter_f[Unit] ) || ( Gain != filter_g[Unit] ) || ( Q != filter_q[Unit] ) || ( Type != filter_t[Unit] ) ) { | ||
544 | filter_f[Unit] = Frequency; filter_q[Unit] = Q; filter_g[Unit] = Gain; filter_t[Unit] = Type; /* remember last frequency, q, gain and type */ | ||
545 | switch (Type) { | ||
546 | case 0: /* no filtering */ | ||
547 | filter_b0[Unit] = pow( 10.0, Gain / 20.0 ); /* convert from dB to linear */ | ||
548 | break; | ||
549 | case 1: /* lowpass */ | ||
550 | Gain = pow( 10.0, Gain / 20.0 ); /* convert from dB to linear */ | ||
551 | omega = ( Pi2 * Frequency ) / SampleRate; | ||
552 | sn = sin( omega ); cs = cos( omega ); | ||
553 | alpha = sn / ( 2.0 * Q ); | ||
554 | filter_a0[Unit] = 1.0 / ( 1.0 + alpha ); | ||
555 | filter_a1[Unit] = ( -2.0 * cs ) * filter_a0[Unit]; | ||
556 | filter_a2[Unit] = ( 1.0 - alpha ) * filter_a0[Unit]; | ||
557 | filter_b1[Unit] = ( 1.0 - cs ) * filter_a0[Unit] * Gain; | ||
558 | filter_b0[Unit] = filter_b1[Unit] * 0.5; | ||
559 | break; | ||
560 | case 2: /* highpass */ | ||
561 | Gain = pow( 10.0, Gain / 20.0 ); /* convert from dB to linear */ | ||
562 | omega = ( Pi2 * Frequency ) / SampleRate; | ||
563 | sn = sin( omega ); cs = cos( omega ); | ||
564 | alpha = sn / ( 2.0 * Q ); | ||
565 | filter_a0[Unit] = 1.0 / ( 1.0 + alpha ); | ||
566 | filter_a1[Unit] = ( -2.0 * cs ) * filter_a0[Unit]; | ||
567 | filter_a2[Unit] = ( 1.0 - alpha ) * filter_a0[Unit]; | ||
568 | filter_b1[Unit] = -( 1.0 + cs ) * filter_a0[Unit] * Gain; | ||
569 | filter_b0[Unit] = -filter_b1[Unit] * 0.5; | ||
570 | break; | ||
571 | case 3: /* bandpass */ | ||
572 | Gain = pow( 10.0, Gain / 20.0 ); /* convert from dB to linear */ | ||
573 | omega = ( Pi2 * Frequency ) / SampleRate; | ||
574 | sn = sin( omega ); cs = cos( omega ); | ||
575 | alpha = sn / ( 2.0 * Q ); | ||
576 | filter_a0[Unit] = 1.0 / ( 1.0 + alpha ); | ||
577 | filter_a1[Unit] = ( -2.0 * cs ) * filter_a0[Unit]; | ||
578 | filter_a2[Unit] = ( 1.0 - alpha ) * filter_a0[Unit]; | ||
579 | filter_b0[Unit] = alpha * filter_a0[Unit] * Gain; | ||
580 | break; | ||
581 | case 4: /* notch */ | ||
582 | Gain = pow( 10.0, Gain / 20.0 ); /* convert from dB to linear */ | ||
583 | omega = ( Pi2 * Frequency ) / SampleRate; | ||
584 | sn = sin( omega ); cs = cos( omega ); | ||
585 | alpha = sn / ( 2.0 * Q ); | ||
586 | filter_a0[Unit] = 1.0 / ( 1.0 + alpha ); | ||
587 | filter_a1[Unit] = ( -2.0 * cs ) * filter_a0[Unit]; | ||
588 | filter_a2[Unit] = ( 1.0 - alpha ) * filter_a0[Unit]; | ||
589 | filter_b0[Unit] = filter_a0[Unit] * Gain; | ||
590 | filter_b1[Unit] = filter_a1[Unit] * Gain; | ||
591 | break; | ||
592 | case 5: /* lowshelf */ | ||
593 | /* "shelf slope" 1.0 = max slope, because neither Q nor bandwidth is used in */ | ||
594 | /* those filters (note: true only for lowshelf and highshelf, not peaking). */ | ||
595 | S = 1.0; /* used only by lowshelf and highshelf */ | ||
596 | A = pow( 10.0 , ( Gain / 40.0 ) ); /* Gain is expressed in dB */ | ||
597 | omega = ( Pi2 * Frequency ) / SampleRate; | ||
598 | sn = sin( omega ); cs = cos( omega ); | ||
599 | temp1 = A + 1.0; temp2 = A - 1.0; temp3 = temp1 * cs; temp4 = temp2 * cs; | ||
600 | beta = sn * sqrt( ( A * A + 1.0 ) / S - temp2 * temp2 ); | ||
601 | filter_a0[Unit] = 1.0 / ( temp1 + temp4 + beta ); | ||
602 | filter_a1[Unit] = ( -2.0 * ( temp2 + temp3 ) ) * filter_a0[Unit]; | ||
603 | filter_a2[Unit] = ( temp1 + temp4 - beta ) * filter_a0[Unit]; | ||
604 | filter_b0[Unit] = ( A * ( temp1 - temp4 + beta ) ) * filter_a0[Unit]; | ||
605 | filter_b1[Unit] = ( 2.0 * A * ( temp2 - temp3 ) ) * filter_a0[Unit]; | ||
606 | filter_b2[Unit] = ( A * ( temp1 - temp4 - beta ) ) * filter_a0[Unit]; | ||
607 | break; | ||
608 | case 6: /* highshelf */ | ||
609 | /* "shelf slope" 1.0 = max slope, because neither Q nor bandwidth is used in */ | ||
610 | /* those filters (note: true only for lowshelf and highshelf, not peaking). */ | ||
611 | S = 1.0; /* used only by lowshelf and highshelf */ | ||
612 | A = pow( 10.0, ( Gain / 40.0 ) ); /* Gain is expressed in dB */ | ||
613 | omega = ( Pi2 * Frequency ) / SampleRate; | ||
614 | sn = sin( omega ); cs = cos( omega ); | ||
615 | temp1 = A + 1.0; temp2 = A - 1.0; temp3 = temp1 * cs; temp4 = temp2 * cs; | ||
616 | beta = sn * sqrt( ( A * A + 1.0 ) / S - temp2 * temp2 ); | ||
617 | filter_a0[Unit] = 1.0 / ( temp1 - temp4 + beta ); | ||
618 | filter_a1[Unit] = ( 2.0 * ( temp2 - temp3 ) ) * filter_a0[Unit]; | ||
619 | filter_a2[Unit] = ( temp1 - temp4 - beta ) * filter_a0[Unit]; | ||
620 | filter_b0[Unit] = ( A * ( temp1 + temp4 + beta ) ) * filter_a0[Unit]; | ||
621 | filter_b1[Unit] = ( -2.0 * A * ( temp2 + temp3 ) ) * filter_a0[Unit]; | ||
622 | filter_b2[Unit] = ( A * ( temp1 + temp4 - beta ) ) * filter_a0[Unit]; | ||
623 | break; | ||
624 | case 7: /* peaking */ | ||
625 | A = pow( 10.0, ( Gain / 40.0 ) ); /* Gain is expressed in dB */ | ||
626 | omega = ( Pi2 * Frequency ) / SampleRate; | ||
627 | sn = sin( omega ); cs = cos( omega ); | ||
628 | alpha = sn / ( 2.0 * Q ); | ||
629 | temp1 = alpha * A; | ||
630 | temp2 = alpha / A; | ||
631 | filter_a0[Unit] = 1.0 / ( 1.0 + temp2 ); | ||
632 | filter_a1[Unit] = ( -2.0 * cs ) * filter_a0[Unit]; | ||
633 | filter_a2[Unit] = ( 1.0 - temp2 ) * filter_a0[Unit]; | ||
634 | filter_b0[Unit] = ( 1.0 + temp1 ) * filter_a0[Unit]; | ||
635 | filter_b2[Unit] = ( 1.0 - temp1 ) * filter_a0[Unit]; | ||
636 | break; | ||
637 | } | ||
638 | } | ||
639 | /* -- filter loop: if you don't change the parameters of the filter dynamically, ~only this code will be executed. */ | ||
640 | switch (Type) { | ||
641 | case 0: /* no filtering */ | ||
642 | Output = filter_b0[Unit]*Input; | ||
643 | break; | ||
644 | case 1: /* lowpass */ | ||
645 | case 2: /* highpass */ | ||
646 | Output = filter_b0[Unit]*Input | ||
647 | + filter_b1[Unit]*filter_i1[Unit] | ||
648 | + filter_b0[Unit]*filter_i2[Unit] | ||
649 | - filter_a1[Unit]*filter_o1[Unit] | ||
650 | - filter_a2[Unit]*filter_o2[Unit]; | ||
651 | break; | ||
652 | case 3: /* bandpass */ | ||
653 | Output = filter_b0[Unit]*Input | ||
654 | - filter_b0[Unit]*filter_i2[Unit] | ||
655 | - filter_a1[Unit]*filter_o1[Unit] | ||
656 | - filter_a2[Unit]*filter_o2[Unit]; | ||
657 | break; | ||
658 | case 4: /* notch */ | ||
659 | Output = filter_b0[Unit]*Input | ||
660 | + filter_b1[Unit]*filter_i1[Unit] | ||
661 | + filter_b0[Unit]*filter_i2[Unit] | ||
662 | - filter_a1[Unit]*filter_o1[Unit] | ||
663 | - filter_a2[Unit]*filter_o2[Unit]; | ||
664 | break; | ||
665 | case 5: /* low shelving */ | ||
666 | case 6: /* high shelving */ | ||
667 | Output = filter_b0[Unit]*Input | ||
668 | + filter_b1[Unit]*filter_i1[Unit] | ||
669 | + filter_b2[Unit]*filter_i2[Unit] | ||
670 | - filter_a1[Unit]*filter_o1[Unit] | ||
671 | - filter_a2[Unit]*filter_o2[Unit]; | ||
672 | break; | ||
673 | case 7: /* peaking */ | ||
674 | Output = filter_b0[Unit]*Input | ||
675 | + filter_a1[Unit]*filter_i1[Unit] | ||
676 | + filter_b2[Unit]*filter_i2[Unit] | ||
677 | - filter_a1[Unit]*filter_o1[Unit] | ||
678 | - filter_a2[Unit]*filter_o2[Unit]; | ||
679 | break; | ||
680 | } | ||
681 | filter_o2[Unit]=filter_o1[Unit]; | ||
682 | filter_o1[Unit]=Output; | ||
683 | filter_i2[Unit]=filter_i1[Unit]; | ||
684 | filter_i1[Unit]=Input; /* update variables for recursion */ | ||
685 | |||
686 | return(Output);} {} | ||
687 | } | ||
688 | Function {eq_gain(int whicheq,double gain)} {open return_type void | ||
689 | } { | ||
690 | code {if (whicheq>4) return; | ||
691 | if (whicheq<0) return; | ||
692 | data->eq_gain[whicheq]=gain; | ||
693 | |||
694 | |||
695 | //cout << "set freq to "<<freq <<" for (base0)ch "<<channel_number()-1 << endl; | ||
696 | WidgetPDial* gainwidget=NULL; | ||
697 | Fl_Output* dispwidget=NULL; | ||
698 | switch (whicheq) { | ||
699 | case 0: | ||
700 | { | ||
701 | gainwidget=parentmixercontrol()->parentui()->gain1; | ||
702 | dispwidget=parentmixercontrol()->parentui()->dispgain1; | ||
703 | break; | ||
704 | } | ||
705 | case 1: | ||
706 | { | ||
707 | gainwidget=parentmixercontrol()->parentui()->gain2; | ||
708 | dispwidget=parentmixercontrol()->parentui()->dispgain2; | ||
709 | break; | ||
710 | } | ||
711 | case 2: | ||
712 | { | ||
713 | gainwidget=parentmixercontrol()->parentui()->gain3; | ||
714 | dispwidget=parentmixercontrol()->parentui()->dispgain3; | ||
715 | break; | ||
716 | } | ||
717 | case 3: | ||
718 | { | ||
719 | gainwidget=parentmixercontrol()->parentui()->gain4; | ||
720 | dispwidget=parentmixercontrol()->parentui()->dispgain4; | ||
721 | break; | ||
722 | } | ||
723 | } | ||
724 | if (dispwidget!=NULL) | ||
725 | { | ||
726 | string* sval=Convert::int64tostr((__sint64)gain); | ||
727 | dispwidget->value(sval->c_str()); | ||
728 | delete sval; | ||
729 | dispwidget->redraw(); | ||
730 | } | ||
731 | if (gainwidget!=NULL) | ||
732 | { | ||
733 | gainwidget->value(gain); | ||
734 | gainwidget->redraw(); | ||
735 | }} {} | ||
736 | } | ||
737 | Function {eq_gain(int whicheq)} {open return_type double | ||
738 | } { | ||
739 | code {if (whicheq>4) return 0; | ||
740 | if (whicheq<0) return 0; | ||
741 | return data->eq_gain[whicheq];} {} | ||
742 | } | ||
743 | Function {eq_freq(int whicheq,double freq)} {open return_type void | ||
744 | } { | ||
745 | code {if (whicheq>4) return; | ||
746 | if (whicheq<0) return; | ||
747 | data->eq_freq[whicheq]=freq; | ||
748 | //cout << "set freq to "<<freq <<" for (base0)ch "<<channel_number()-1 << endl; | ||
749 | WidgetPDial* freqwidget=NULL; | ||
750 | Fl_Output* dispwidget=NULL; | ||
751 | switch (whicheq) { | ||
752 | case 0: | ||
753 | { | ||
754 | freqwidget=parentmixercontrol()->parentui()->freq1; | ||
755 | dispwidget=parentmixercontrol()->parentui()->dispfreq1; | ||
756 | break; | ||
757 | } | ||
758 | case 1: | ||
759 | { | ||
760 | freqwidget=parentmixercontrol()->parentui()->freq2; | ||
761 | dispwidget=parentmixercontrol()->parentui()->dispfreq2; | ||
762 | break; | ||
763 | } | ||
764 | case 2: | ||
765 | { | ||
766 | freqwidget=parentmixercontrol()->parentui()->freq3; | ||
767 | dispwidget=parentmixercontrol()->parentui()->dispfreq3; | ||
768 | break; | ||
769 | } | ||
770 | case 3: | ||
771 | { | ||
772 | freqwidget=parentmixercontrol()->parentui()->freq4; | ||
773 | dispwidget=parentmixercontrol()->parentui()->dispfreq4; | ||
774 | break; | ||
775 | } | ||
776 | } | ||
777 | if (dispwidget!=NULL) | ||
778 | { | ||
779 | string* sval=Convert::int64tostr((__sint64)freq); | ||
780 | dispwidget->value(sval->c_str()); | ||
781 | delete sval; | ||
782 | dispwidget->redraw(); | ||
783 | } | ||
784 | if (freqwidget!=NULL) | ||
785 | { | ||
786 | freqwidget->value(freq); | ||
787 | freqwidget->redraw(); | ||
788 | }} {} | ||
789 | } | ||
790 | Function {eq_freq(int whicheq)} {return_type double | ||
791 | } { | ||
792 | code {if (whicheq>4) return 0; | ||
793 | if (whicheq<0) return 0; | ||
794 | return data->eq_freq[whicheq];} {} | ||
795 | } | ||
796 | Function {eq_on(int whicheq,int onoff)} {return_type void | ||
797 | } { | ||
798 | code {if (whicheq>4) return; | ||
799 | if (whicheq<0) return; | ||
800 | data->eq_on[whicheq]=onoff; | ||
801 | |||
802 | switch (whicheq) { | ||
803 | case 0: parentmixercontrol()->parentui()->eqon1->value(onoff); break; | ||
804 | case 1: parentmixercontrol()->parentui()->eqon2->value(onoff); break; | ||
805 | case 2: parentmixercontrol()->parentui()->eqon3->value(onoff); break; | ||
806 | case 3: parentmixercontrol()->parentui()->eqon4->value(onoff); break; | ||
807 | } | ||
808 | parentmixercontrol()->parentui()->eqon1->redraw(); | ||
809 | parentmixercontrol()->parentui()->eqon2->redraw(); | ||
810 | parentmixercontrol()->parentui()->eqon3->redraw(); | ||
811 | parentmixercontrol()->parentui()->eqon4->redraw();} {} | ||
812 | } | ||
813 | Function {eq_on(int whicheq)} {return_type int | ||
814 | } { | ||
815 | code {if (whicheq>4) return 0; | ||
816 | if (whicheq<0) return 0; | ||
817 | return data->eq_on[whicheq];} {} | ||
818 | } | ||
819 | Function {eq_Q(int whicheq,double Q)} {return_type void | ||
820 | } { | ||
821 | code {if (whicheq>4) return; | ||
822 | if (whicheq<0) return; | ||
823 | data->eq_Q[whicheq]=Q; | ||
824 | //cout << "set freq to "<<freq <<" for (base0)ch "<<channel_number()-1 << endl; | ||
825 | |||
826 | //switch (whicheq) { | ||
827 | // case 0: parentmixercontrol()->parentui()->Q1->value(freq); break; | ||
828 | // case 1: parentmixercontrol()->parentui()->Q2->value(freq); break; | ||
829 | // case 2: parentmixercontrol()->parentui()->Q3->value(freq); break; | ||
830 | // case 3: parentmixercontrol()->parentui()->Q4->value(freq); break; | ||
831 | //} | ||
832 | //parentmixercontrol()->parentui()->freq1->redraw(); | ||
833 | //parentmixercontrol()->parentui()->freq2->redraw(); | ||
834 | //parentmixercontrol()->parentui()->freq3->redraw(); | ||
835 | //parentmixercontrol()->parentui()->freq4->redraw();} {} | ||
836 | } | ||
837 | Function {eq_Q(int whicheq)} {return_type double | ||
838 | } { | ||
839 | code {if (whicheq>4) return 0; | ||
840 | if (whicheq<0) return 0; | ||
841 | return data->eq_Q[whicheq];} {} | ||
842 | } | ||
843 | decl {double filter_i1[eqperchan]; /* temporary variables */} {} | ||
844 | decl {double filter_i2[eqperchan];} {} | ||
845 | decl {double filter_o1[eqperchan];} {} | ||
846 | decl {double filter_o2[eqperchan];} {} | ||
847 | decl {double filter_a0[eqperchan]; /*coefficients */} {} | ||
848 | decl {double filter_a1[eqperchan];} {} | ||
849 | decl {double filter_a2[eqperchan];} {} | ||
850 | decl {double filter_b0[eqperchan]; /*coefficients */} {} | ||
851 | decl {double filter_b1[eqperchan];} {} | ||
852 | decl {double filter_b2[eqperchan];} {} | ||
853 | decl {double filter_f[eqperchan]; /* last freq used */} {} | ||
854 | decl {double filter_q[eqperchan]; /* last Q used */} {} | ||
855 | decl {double filter_g[eqperchan]; /* last gain used */} {} | ||
856 | decl {unsigned long filter_t[eqperchan]; /* last T used */} {} | ||
857 | Function {pan_enabled(int yesno)} {open return_type void | ||
858 | } { | ||
859 | code {data->enable_pan=yesno;} {} | ||
860 | } | ||
861 | Function {pan_enabled()} {open return_type int | ||
862 | } { | ||
863 | code {return data->enable_pan;} {} | ||
864 | } | ||
865 | Function {eq_enabled(int yesno)} {return_type void | ||
866 | } { | ||
867 | code {data->enable_eq=yesno;} {} | ||
868 | } | ||
869 | Function {eq_enabled()} {open return_type int | ||
870 | } { | ||
871 | code {return data->enable_eq;} {} | ||
872 | } | ||
873 | Function {bypass(int yesno)} {open return_type void | ||
874 | } { | ||
875 | code {data->bypass=yesno;} {} | ||
876 | } | ||
877 | Function {bypass()} {open return_type int | ||
878 | } { | ||
879 | code {return data->bypass;} {} | ||
880 | } | ||
881 | Function {samplerate(__uint32 p_samplerate)} {open return_type void | ||
882 | } { | ||
883 | code {data->samplerate=p_samplerate;} {} | ||
884 | } | ||
885 | Function {samplerate()} {open return_type __uint32 | ||
886 | } { | ||
887 | code {return data->samplerate;} {} | ||
888 | } | ||
889 | } | ||
890 | |||
891 | class MixerChannelUI {open : {public Fl_Group} | ||
892 | } { | ||
893 | decl {MixerChannelControl* control;} {public | ||
894 | } | ||
895 | Function {MixerChannelUI(int a,int b,int c,int d,const char* e):Fl_Group(a,b,c,d,e)} {open | ||
896 | } { | ||
897 | code {init_ui();} {} | ||
898 | } | ||
899 | Function {MixerChannelUI(int a,int b,int c,int d):Fl_Group(a,b,c,d,NULL)} {open | ||
900 | } { | ||
901 | code {init_ui();} {} | ||
902 | } | ||
903 | Function {init_ui()} {open private | ||
904 | } { | ||
905 | code {this->control=new MixerChannelControl(); | ||
906 | this->control->parentui(this); | ||
907 | make_window();} {} | ||
908 | } | ||
909 | Function {make_window()} {open | ||
910 | } { | ||
911 | Fl_Window channelstrip {open | ||
912 | xywh {698 377 20 235} type Double | ||
913 | code0 {o->position(this->x(),this->y());} | ||
914 | class Fl_Group visible | ||
915 | } { | ||
916 | Fl_Group resources {open | ||
917 | xywh {80 62 150 98} hide deactivate | ||
918 | } { | ||
919 | Fl_Button button_mute_up { | ||
920 | tooltip Play image {images/button_mute.gif} xywh {80 62 5 13} labelsize 11 align 16 deactivate | ||
921 | } | ||
922 | Fl_Button button_mute_dn { | ||
923 | tooltip Play image {images/button_mute_dn.gif} xywh {85 62 35 13} labelsize 11 align 16 deactivate | ||
924 | } | ||
925 | Fl_Button button_solo_up { | ||
926 | tooltip Play image {images/button_solo.gif} xywh {80 62 5 13} labelsize 11 align 16 deactivate | ||
927 | } | ||
928 | Fl_Button button_solo_dn { | ||
929 | tooltip Play image {images/button_solo_dn.gif} xywh {85 62 45 13} labelsize 11 align 16 deactivate | ||
930 | } | ||
931 | } | ||
932 | Fl_Button mixmute { | ||
933 | label 1 | ||
934 | callback {//mute(0,o->value()); | ||
935 | this->control->mute(o->value());} | ||
936 | tooltip Mute xywh {0 65 20 15} selection_color 1 labelfont 1 labelsize 10 align 2 | ||
937 | code0 {o->up_image(button_mute_up->image()); o->down_image(button_mute_dn->image());} | ||
938 | class Fl_Image_Toggle_Button | ||
939 | } | ||
940 | Fl_Button mixsolo { | ||
941 | callback {this->control->solo(o->value());} | ||
942 | tooltip Solo xywh {0 45 20 15} selection_color 2 | ||
943 | code0 {o->up_image(button_solo_up->image()); o->down_image(button_solo_dn->image());} | ||
944 | class Fl_Image_Toggle_Button | ||
945 | } | ||
946 | Fl_Dial mixpan { | ||
947 | callback {control->panvalue(o->value());} | ||
948 | xywh {0 25 20 20} minimum -127 maximum 127 step 1 | ||
949 | class WidgetPDial | ||
950 | } | ||
951 | Fl_Round_Button mixchsel { | ||
952 | callback {this->control->parentmixercontrol()->selectedchannel(this->control->channel_number()-1);} | ||
953 | xywh {0 0 15 20} down_box ROUND_DOWN_BOX align 2 | ||
954 | } | ||
955 | Fl_Group mixled {open | ||
956 | xywh {18 93 4 132} | ||
957 | class MixerLevelMeterUI | ||
958 | } {} | ||
959 | Fl_Slider fader { | ||
960 | callback {control->fadervalue(o->value());} | ||
961 | image {images/fader.gif} xywh {0 92 18 128} type {Vert Knob} color 8 labelfont 1 labelsize 10 align 0 minimum 127 maximum 0 step 1 value 90 | ||
962 | code0 {o->clear_visible_focus();} | ||
963 | } | ||
964 | } | ||
965 | } | ||
966 | Function {~MixerChannelUI()} {open | ||
967 | } { | ||
968 | code {delete control;} {} | ||
969 | } | ||
970 | } | ||
971 | |||
972 | class MasterChannelData {open | ||
973 | } { | ||
974 | decl {friend class MasterChannelUI;} {} | ||
975 | decl {friend class MasterChannelControl;} {} | ||
976 | decl {MasterChannelUI* parentui;} {} | ||
977 | decl {double trackpeak[2];} {public | ||
978 | } | ||
979 | decl {int eq_on[eqperchan];} {public | ||
980 | } | ||
981 | decl {double eq_gain[eqperchan];} {public | ||
982 | } | ||
983 | decl {double eq_freq[eqperchan];} {public | ||
984 | } | ||
985 | decl {double eq_Q[eqperchan];} {public | ||
986 | } | ||
987 | decl {double eq_type[eqperchan];} {public | ||
988 | } | ||
989 | decl {double fadermult[2];} {public | ||
990 | } | ||
991 | decl {double fadervalue;} {public | ||
992 | } | ||
993 | decl {double panvalue;} {public | ||
994 | } | ||
995 | decl {float* delaybuffer;} {} | ||
996 | decl {long delaybuffersize;} {public | ||
997 | } | ||
998 | decl {long delaybuffersam;} {public | ||
999 | } | ||
1000 | decl {int solo;} {} | ||
1001 | decl {int mute;} {} | ||
1002 | decl {int ch_number;} {} | ||
1003 | decl {char strchnum[4];} {} | ||
1004 | decl {float* sample;} {public | ||
1005 | } | ||
1006 | decl {int mixmono;} {} | ||
1007 | } | ||
1008 | |||
1009 | class MasterChannelControl {open | ||
1010 | } { | ||
1011 | decl {friend class MasterChannelUI;} {} | ||
1012 | Function {init()} {open return_type void | ||
1013 | } { | ||
1014 | code {data->solo=0; | ||
1015 | data->mute=0; | ||
1016 | data->mixmono=0; | ||
1017 | data->sample=(float *)malloc(24000*sizeof(float)); | ||
1018 | data->trackpeak[0]=0; | ||
1019 | data->trackpeak[1]=0; | ||
1020 | data->fadermult[0]=1; | ||
1021 | data->fadermult[1]=1; | ||
1022 | data->panvalue=0; | ||
1023 | data->fadervalue=90; | ||
1024 | return;} {} | ||
1025 | } | ||
1026 | decl {MasterChannelData* data;} {} | ||
1027 | Function {MasterChannelControl()} {open | ||
1028 | } { | ||
1029 | code {data=new MasterChannelData; | ||
1030 | init();} {} | ||
1031 | } | ||
1032 | Function {~MasterChannelControl()} {open | ||
1033 | } { | ||
1034 | code {free (data->sample); | ||
1035 | delete data;} {} | ||
1036 | } | ||
1037 | Function {fadervalue(const double p_val)} {open | ||
1038 | } { | ||
1039 | code {double lin; | ||
1040 | if (p_val == 0) { | ||
1041 | lin=0; | ||
1042 | } else { | ||
1043 | lin=pow(10,(p_val-90)/60); | ||
1044 | } | ||
1045 | data->fadermult[0]=lin; | ||
1046 | data->fadermult[1]=lin; | ||
1047 | data->fadervalue=p_val; | ||
1048 | data->parentui->redraw(); | ||
1049 | //faderarray[channel]=lin; | ||
1050 | //mixmute[channel]->draw(); | ||
1051 | //mixfader[channel]->draw(); | ||
1052 | //mixled[channel]->draw(); | ||
1053 | //masterled[0]->draw(); | ||
1054 | //masterled[1]->draw(); | ||
1055 | //this->redraw();*/} {} | ||
1056 | } | ||
1057 | Function {fadervalue()} {open return_type double | ||
1058 | } { | ||
1059 | code {return data->fadervalue;} {} | ||
1060 | } | ||
1061 | Function {updatemeters()} {open return_type void | ||
1062 | } { | ||
1063 | code {// update and redraw meterlevels object | ||
1064 | this->parentui()->mixledleft->control->setvalue(data->trackpeak[0]); | ||
1065 | this->parentui()->mixledright->control->setvalue(data->trackpeak[1]); | ||
1066 | |||
1067 | this->parentui()->mixledleft->redraw(); | ||
1068 | this->parentui()->mixledright->redraw(); | ||
1069 | // then, reset peak value | ||
1070 | trackpeak(0,0); | ||
1071 | trackpeak(1,0);} {} | ||
1072 | } | ||
1073 | Function {trackpeak(int lr)} {open return_type double | ||
1074 | } { | ||
1075 | code {return data->trackpeak[lr];} {} | ||
1076 | } | ||
1077 | Function {trackpeak(int lr,double peakval)} {open return_type void | ||
1078 | } { | ||
1079 | code {data->trackpeak[lr]=peakval;} {} | ||
1080 | } | ||
1081 | Function {parentui(MasterChannelUI* p_parentui)} {open return_type void | ||
1082 | } { | ||
1083 | code {data->parentui=p_parentui;} {} | ||
1084 | } | ||
1085 | Function {parentui()} {open return_type {MasterChannelUI*} | ||
1086 | } { | ||
1087 | code {return data->parentui;} {} | ||
1088 | } | ||
1089 | Function {sample(int framenum,float samval)} {open | ||
1090 | } { | ||
1091 | code {data->sample[framenum]=samval; | ||
1092 | /*float q=1; | ||
1093 | if (samval<0) { | ||
1094 | q=-1; | ||
1095 | } | ||
1096 | if ((samval*q) > data->trackpeak) { | ||
1097 | data->trackpeak=samval*q; | ||
1098 | }*/} {} | ||
1099 | } | ||
1100 | Function {sample(int framenum)} {open return_type float | ||
1101 | } { | ||
1102 | code {return data->sample[framenum];} {} | ||
1103 | } | ||
1104 | Function {getfadermult(int lr)} {open return_type double | ||
1105 | } { | ||
1106 | code {return data->fadermult[lr];} {} | ||
1107 | } | ||
1108 | Function {mixmono(int inval)} {open return_type void | ||
1109 | } { | ||
1110 | code {data->mixmono=inval; | ||
1111 | parentui()->mix_mono->value(inval); | ||
1112 | parentui()->mix_mono->redraw();} {} | ||
1113 | } | ||
1114 | Function {mixmono()} {open return_type int | ||
1115 | } { | ||
1116 | code {return data->mixmono;} {} | ||
1117 | } | ||
1118 | } | ||
1119 | |||
1120 | class MasterChannelUI {open : {public Fl_Group} | ||
1121 | } { | ||
1122 | decl {MasterChannelControl* control;} {public | ||
1123 | } | ||
1124 | Function {MasterChannelUI(int a,int b,int c,int d,const char* e):Fl_Group(a,b,c,d,e)} {open | ||
1125 | } { | ||
1126 | code {init_ui();} {} | ||
1127 | } | ||
1128 | Function {MasterChannelUI(int a,int b,int c,int d):Fl_Group(a,b,c,d,NULL)} {open | ||
1129 | } { | ||
1130 | code {init_ui();} {} | ||
1131 | } | ||
1132 | Function {init_ui()} {open private | ||
1133 | } { | ||
1134 | code {this->control=new MasterChannelControl(); | ||
1135 | this->control->parentui(this); | ||
1136 | make_window();} {} | ||
1137 | } | ||
1138 | Function {make_window()} {open | ||
1139 | } { | ||
1140 | Fl_Window channelstrip {open | ||
1141 | xywh {889 373 30 235} type Double | ||
1142 | code0 {o->position(this->x(),this->y());} | ||
1143 | class Fl_Group visible | ||
1144 | } { | ||
1145 | Fl_Group mixledleft {open | ||
1146 | xywh {2 92 4 132} | ||
1147 | class MixerLevelMeterUI | ||
1148 | } {} | ||
1149 | Fl_Group mixledright {open | ||
1150 | xywh {24 92 4 132} | ||
1151 | class MixerLevelMeterUI | ||
1152 | } {} | ||
1153 | Fl_Slider fader { | ||
1154 | callback {control->fadervalue(o->value());} | ||
1155 | image {images/fader.gif} xywh {6 92 18 128} type {Vert Knob} color 8 labelfont 1 labelsize 10 align 0 minimum 127 maximum 0 step 1 value 90 | ||
1156 | code0 {o->clear_visible_focus();} | ||
1157 | } | ||
1158 | Fl_Button mix_mono { | ||
1159 | label MONO | ||
1160 | callback {control->mixmono(o->value());} | ||
1161 | xywh {0 68 30 15} type Toggle selection_color 3 labelsize 8 | ||
1162 | code0 {o->clear_visible_focus();} | ||
1163 | } | ||
1164 | } | ||
1165 | } | ||
1166 | Function {~MasterChannelUI()} {open | ||
1167 | } { | ||
1168 | code {delete control;} {} | ||
1169 | } | ||
1170 | } | ||
1171 | |||
1172 | class MixerData {open | ||
1173 | } { | ||
1174 | decl {MixerUI* parentui;} {} | ||
1175 | decl {friend class MixerControl;} {} | ||
1176 | decl {int eqon;} {} | ||
1177 | decl {float* mixermasterout;} {public | ||
1178 | } | ||
1179 | decl {double trackpeak[2];} {public | ||
1180 | } | ||
1181 | decl {double fadermult[2];} {public | ||
1182 | } | ||
1183 | decl {__uint32 samplerate;} {public | ||
1184 | } | ||
1185 | decl {int selectedchannel;} {public | ||
1186 | } | ||
1187 | decl {double fadervalue;} {public | ||
1188 | } | ||
1189 | decl {__uint32 delaybuffersam;} {public | ||
1190 | } | ||
1191 | decl {int bypass;} {} | ||
1192 | } | ||
1193 | |||
1194 | class MixerControl {open | ||
1195 | } { | ||
1196 | decl {friend class MixerUI;} {} | ||
1197 | decl {MixerData* data;} {} | ||
1198 | Function {mix(int frames) /* <----------------------------------*/} {open | ||
1199 | } { | ||
1200 | code {int solo=0; | ||
1201 | int trackon[24]; // 0=mute, 1=normal, 2=solo | ||
1202 | MixerChannelControl* trackctl[24]; | ||
1203 | for (int tracknum=0;tracknum<24;tracknum++) { | ||
1204 | trackctl[tracknum]=parentui()->mixerchannel[tracknum]->control; | ||
1205 | trackon[tracknum]=1; // normal | ||
1206 | MixerChannelControl* track=trackctl[tracknum]; | ||
1207 | if (track->issolo()!=0) { | ||
1208 | solo=1; | ||
1209 | trackon[tracknum]++; | ||
1210 | } | ||
1211 | if (track->ismute()!=0) { | ||
1212 | trackon[tracknum]--; | ||
1213 | } | ||
1214 | track->eq_enabled(data->eqon); | ||
1215 | track->pan_enabled(1-(parentui()->fader_master->control->mixmono())); | ||
1216 | track->bypass(data->bypass); | ||
1217 | } | ||
1218 | |||
1219 | stereosample sam; | ||
1220 | for (int i=0;i<frames;i++) { | ||
1221 | float outleft=0; | ||
1222 | float outright=0; | ||
1223 | |||
1224 | |||
1225 | for (int j=0;j<24 /* tracks */;j++) { | ||
1226 | if (!(trackon[j]>solo)) continue; | ||
1227 | MixerChannelControl* track=trackctl[j]; | ||
1228 | |||
1229 | track->getsample(&sam,i); | ||
1230 | |||
1231 | outleft+=sam.left; | ||
1232 | outright+=sam.right; | ||
1233 | } | ||
1234 | outleft*=parentui()->fader_master->control->getfadermult(0); | ||
1235 | outright*=parentui()->fader_master->control->getfadermult(1); | ||
1236 | |||
1237 | /* clipping */ | ||
1238 | if (outleft>1) { | ||
1239 | outleft=1; } | ||
1240 | else { | ||
1241 | if (outleft<-1) outleft=-1; | ||
1242 | } | ||
1243 | if (outright>1) { | ||
1244 | outright=1; | ||
1245 | } else { | ||
1246 | if (outright<-1) outright=-1; | ||
1247 | } | ||
1248 | |||
1249 | |||
1250 | if (fabs(outleft) > parentui()->fader_master->control->trackpeak(0)) { | ||
1251 | parentui()->fader_master->control->trackpeak(0,fabs(outleft)); | ||
1252 | } | ||
1253 | if (fabs(outright) > parentui()->fader_master->control->trackpeak(1)) { | ||
1254 | parentui()->fader_master->control->trackpeak(1,fabs(outright)); | ||
1255 | } | ||
1256 | |||
1257 | /* / tape saturation emulation | ||
1258 | if (parentui()->tapesaton->value()==1) | ||
1259 | { | ||
1260 | int tapewidth=100; | ||
1261 | float myleft=0; | ||
1262 | float myright=0; | ||
1263 | for (int tapepos=0;tapepos<tapewidth;tapepos++) | ||
1264 | { | ||
1265 | float maxleft=.3+( ((rand()%32767)-16384)/(16384*5) ); | ||
1266 | float maxright=.3+( ((rand()%32767)-16384)/(16384*5) ); | ||
1267 | if (outleft>maxleft) { | ||
1268 | myleft+=maxleft; | ||
1269 | } else { | ||
1270 | myleft+=outleft; | ||
1271 | } | ||
1272 | if (outright>maxright) { | ||
1273 | myright+=maxright; | ||
1274 | } else { | ||
1275 | myright+=outright; | ||
1276 | } | ||
1277 | } | ||
1278 | outleft=myleft/tapewidth; | ||
1279 | outright=myright/tapewidth; | ||
1280 | } */ | ||
1281 | data->mixermasterout[i*25+0]=outleft; | ||
1282 | data->mixermasterout[i*25+1]=outright; | ||
1283 | }} {} | ||
1284 | } | ||
1285 | Function {init()} {open return_type void | ||
1286 | } { | ||
1287 | code {data->eqon=1; | ||
1288 | data->mixermasterout=(float *)malloc(512000*sizeof(float)); | ||
1289 | data->parentui=NULL; | ||
1290 | data->selectedchannel=0; | ||
1291 | data->bypass=1; | ||
1292 | |||
1293 | return;} {} | ||
1294 | } | ||
1295 | Function {MixerControl()} {} { | ||
1296 | code {data=new MixerData(); | ||
1297 | data->parentui=NULL; | ||
1298 | data->samplerate=0; | ||
1299 | init();} {} | ||
1300 | } | ||
1301 | Function {~MixerControl()} {} { | ||
1302 | code {free (data->mixermasterout); | ||
1303 | |||
1304 | //delaybuffersize=maxreverbunits*maxreverbseconds*MAXSAMRATE; | ||
1305 | //delaybuffer=(float *)malloc(sizeof(float)*delaybuffersize); | ||
1306 | //if (delaybuffer==NULL) cout << " out of mem L" << endl; | ||
1307 | //delaybuffersam=delaybuffersize; | ||
1308 | //for (int i=0;i<delaybuffersize;i++) | ||
1309 | //{ | ||
1310 | // delaybuffer[i]=0; | ||
1311 | //} | ||
1312 | delete data;} {} | ||
1313 | } | ||
1314 | Function {parentui(MixerUI* p_parentui)} {return_type void | ||
1315 | } { | ||
1316 | code {data->parentui=p_parentui;} {} | ||
1317 | } | ||
1318 | Function {parentui()} {return_type {MixerUI*} | ||
1319 | } { | ||
1320 | code {return data->parentui;} {} | ||
1321 | } | ||
1322 | Function {fadervalue(const double p_val)} {} { | ||
1323 | code {double lin; | ||
1324 | if (p_val == 0) { | ||
1325 | lin=0; | ||
1326 | } else { | ||
1327 | lin=pow(10,(p_val-90)/60); | ||
1328 | } | ||
1329 | data->fadermult[0]=lin; | ||
1330 | data->fadermult[1]=lin; | ||
1331 | data->fadervalue=p_val; | ||
1332 | //faderarray[channel]=lin; | ||
1333 | //mixmute[channel]->draw(); | ||
1334 | //mixfader[channel]->draw(); | ||
1335 | //mixled[channel]->draw(); | ||
1336 | //masterled[0]->draw(); | ||
1337 | //masterled[1]->draw(); | ||
1338 | parentui()->fader_master->fader->value(p_val); | ||
1339 | parentui()->fader_master->redraw(); //this->redraw();*/} {} | ||
1340 | } | ||
1341 | Function {fadervalue()} {return_type double | ||
1342 | } { | ||
1343 | code {return data->fadervalue;} {} | ||
1344 | } | ||
1345 | Function {trackpeak(int lr)} {return_type double | ||
1346 | } { | ||
1347 | code {return data->trackpeak[lr];} {} | ||
1348 | } | ||
1349 | Function {trackpeak(int lr,double peakval)} {return_type void | ||
1350 | } { | ||
1351 | code {data->trackpeak[lr]=peakval;} {} | ||
1352 | } | ||
1353 | Function {masterout(int tracknum,int framenum)} {return_type float | ||
1354 | } { | ||
1355 | code {return data->mixermasterout[framenum*25+tracknum];} {} | ||
1356 | } | ||
1357 | Function {lin2dB(double lin)} {return_type double | ||
1358 | } { | ||
1359 | code {return log10(lin)*20.0;} {} | ||
1360 | } | ||
1361 | Function {dB2lin(double dB)} {return_type double | ||
1362 | } { | ||
1363 | code {return pow(10.0,dB/20.0);} {} | ||
1364 | } | ||
1365 | Function {selectedchannel(int channel_base0)} {return_type void | ||
1366 | } { | ||
1367 | code {data->selectedchannel=channel_base0; | ||
1368 | for (int i=0;i<24;i++) { | ||
1369 | if (channel_base0!=i) { | ||
1370 | this->parentui()->mixerchannel[i]->control->channelselect(0); | ||
1371 | } else { | ||
1372 | this->parentui()->mixerchannel[i]->control->channelselect(1); | ||
1373 | } | ||
1374 | } | ||
1375 | MixerChannelControl* mixcontrol=this->parentui()->mixerchannel[channel_base0]->control; | ||
1376 | |||
1377 | // reloading controls with their own value causes a redraw. | ||
1378 | mixcontrol->eq_gain(0,mixcontrol->eq_gain(0)); | ||
1379 | mixcontrol->eq_gain(1,mixcontrol->eq_gain(1)); | ||
1380 | mixcontrol->eq_gain(2,mixcontrol->eq_gain(2)); | ||
1381 | mixcontrol->eq_gain(3,mixcontrol->eq_gain(3)); | ||
1382 | |||
1383 | mixcontrol->eq_freq(0,mixcontrol->eq_freq(0)); | ||
1384 | mixcontrol->eq_freq(1,mixcontrol->eq_freq(1)); | ||
1385 | mixcontrol->eq_freq(2,mixcontrol->eq_freq(2)); | ||
1386 | mixcontrol->eq_freq(3,mixcontrol->eq_freq(3)); | ||
1387 | |||
1388 | mixcontrol->eq_on(0,mixcontrol->eq_on(0)); | ||
1389 | mixcontrol->eq_on(1,mixcontrol->eq_on(1)); | ||
1390 | mixcontrol->eq_on(2,mixcontrol->eq_on(2)); | ||
1391 | mixcontrol->eq_on(3,mixcontrol->eq_on(3));} {} | ||
1392 | } | ||
1393 | Function {selectedchannel()} {return_type int | ||
1394 | } { | ||
1395 | code {return data->selectedchannel;} {} | ||
1396 | } | ||
1397 | Function {savemix(string* strfile)} {return_type {string*} | ||
1398 | } { | ||
1399 | code {fstream to_out(strfile->c_str(),ios::out); | ||
1400 | if (to_out==NULL) { | ||
1401 | string *error=new string(""); | ||
1402 | *error+="Cannot open mix file for writing."; | ||
1403 | return error; | ||
1404 | } | ||
1405 | |||
1406 | for (int i=0;i<24;i++) { | ||
1407 | MixerChannelControl* track=parentui()->mixerchannel[i]->control; | ||
1408 | to_out << "[Track="<<i+1<<"]" <<endl; | ||
1409 | to_out << "solo=" << track->solo() << endl; | ||
1410 | to_out << "mute=" << track->mute() << endl; | ||
1411 | to_out << "fader=" << track->fadervalue() << endl; | ||
1412 | to_out << "pan=" << track->panvalue() << endl; | ||
1413 | |||
1414 | for (int j=0;j<eqperchan;j++) { | ||
1415 | to_out << "eq_on[" << j << "]=" << track->eq_on(j) << endl; | ||
1416 | to_out << "eq_freq[" << j << "]=" << track->eq_freq(j) << endl; | ||
1417 | to_out << "eq_gain[" << j << "]=" << track->eq_gain(j) << endl; | ||
1418 | to_out << "eq_Q[" << j << "]=" << track->eq_Q(j) << endl; | ||
1419 | |||
1420 | } | ||
1421 | } | ||
1422 | to_out << "[Master]" << endl; | ||
1423 | to_out << "eqon=" << eq_on() << endl; | ||
1424 | to_out << "mono=" << parentui()->fader_master->control->mixmono() << endl; | ||
1425 | to_out << "fader=" << parentui()->fader_master->control->fadervalue()<< endl; | ||
1426 | |||
1427 | to_out.flush(); | ||
1428 | to_out.close(); | ||
1429 | return NULL;} {} | ||
1430 | } | ||
1431 | Function {savetrackmix(string* strfile,int base0track)} {return_type {string*} | ||
1432 | } { | ||
1433 | code {fstream to_out(strfile->c_str(),ios::out); | ||
1434 | if (to_out==NULL) { | ||
1435 | string *error=new string(""); | ||
1436 | *error+="Cannot open mix file for writing."; | ||
1437 | return error; | ||
1438 | } | ||
1439 | |||
1440 | int i=base0track; | ||
1441 | |||
1442 | MixerChannelControl* track=parentui()->mixerchannel[i]->control; | ||
1443 | to_out << "[Track="<<i+1<<"]" <<endl; | ||
1444 | to_out << "solo=" << track->solo() << endl; | ||
1445 | to_out << "mute=" << track->mute() << endl; | ||
1446 | to_out << "fader=" << track->fadervalue() << endl; | ||
1447 | to_out << "pan=" << track->panvalue() << endl; | ||
1448 | |||
1449 | for (int j=0;j<eqperchan;j++) { | ||
1450 | to_out << "eq_on[" << j << "]=" << track->eq_on(j) << endl; | ||
1451 | to_out << "eq_freq[" << j << "]=" << track->eq_freq(j) << endl; | ||
1452 | to_out << "eq_gain[" << j << "]=" << track->eq_gain(j) << endl; | ||
1453 | to_out << "eq_Q[" << j << "]=" << track->eq_Q(j) << endl; | ||
1454 | |||
1455 | } | ||
1456 | |||
1457 | to_out.flush(); | ||
1458 | to_out.close(); | ||
1459 | return NULL;} {} | ||
1460 | } | ||
1461 | Function {loadmix(string* strfile)} {return_type {string*} | ||
1462 | } { | ||
1463 | code {fstream from_in(strfile->c_str(),ios::in); | ||
1464 | if (from_in==NULL) { | ||
1465 | string *error=new string(""); | ||
1466 | *error+="Cannot open mix file for writing."; | ||
1467 | return error; | ||
1468 | } | ||
1469 | string line; | ||
1470 | int savechan=selectedchannel(); | ||
1471 | bool master=false; | ||
1472 | while (!(from_in.eof())) | ||
1473 | { | ||
1474 | getline(from_in,line); | ||
1475 | if (line=="") continue; | ||
1476 | if (line.substr(0,7)=="[Track=") { | ||
1477 | master=false; | ||
1478 | int ch=Convert::str2long(line.substr(7,2)); | ||
1479 | this->selectedchannel(ch-1); | ||
1480 | continue; | ||
1481 | } | ||
1482 | MixerChannelControl* track=parentui()->mixerchannel[selectedchannel()]->control; | ||
1483 | if (line.substr(0,8)=="[Master]") { | ||
1484 | master=true; | ||
1485 | continue; | ||
1486 | } | ||
1487 | if (master) { | ||
1488 | if (line.substr(0,5)=="mono=") { | ||
1489 | parentui()->fader_master->control->mixmono(Convert::str2long(line.substr(5,1))); | ||
1490 | continue; | ||
1491 | } | ||
1492 | if (line.substr(0,5)=="eqon=") { | ||
1493 | this->eq_on(Convert::str2long(line.substr(5,1))); | ||
1494 | continue; | ||
1495 | } | ||
1496 | } | ||
1497 | if (line.substr(0,5)=="solo=") { | ||
1498 | // mixsolo[this->selectedchannel]->value(Convert::str2long(line.substr(5,1))); | ||
1499 | track->solo(Convert::str2long(line.substr(5,1))); | ||
1500 | continue; | ||
1501 | } | ||
1502 | if (line.substr(0,5)=="mute=") { | ||
1503 | // mixmute[this->selectedchannel]->value(Convert::str2long(line.substr(5,1))); | ||
1504 | track->mute(Convert::str2long(line.substr(5,1))); | ||
1505 | continue; | ||
1506 | } | ||
1507 | if (line.substr(0,4)=="pan=") { | ||
1508 | track->panvalue(Convert::str2dbl(line.substr(4,10))); | ||
1509 | continue; | ||
1510 | } | ||
1511 | if ((line.substr(0,8)=="eq_freq[") | ||
1512 | &&(line.substr(9,2)=="]=")) | ||
1513 | { | ||
1514 | int whicheq=Convert::str2long(line.substr(8,1)); | ||
1515 | double freq=Convert::str2dbl(line.substr(11,10)); | ||
1516 | track->eq_freq(whicheq,freq); | ||
1517 | continue; | ||
1518 | |||
1519 | } | ||
1520 | if ((line.substr(0,8)=="eq_gain[") | ||
1521 | &&(line.substr(9,2)=="]=")) | ||
1522 | { | ||
1523 | int whicheq=Convert::str2long(line.substr(8,1)); | ||
1524 | double gain=Convert::str2dbl(line.substr(11,10)); | ||
1525 | track->eq_gain(whicheq,gain); | ||
1526 | continue; | ||
1527 | |||
1528 | } | ||
1529 | if ((line.substr(0,5)=="eq_Q[") | ||
1530 | &&(line.substr(6,2)=="]=")) | ||
1531 | { | ||
1532 | int whicheq=Convert::str2long(line.substr(5,1)); | ||
1533 | double Q=Convert::str2dbl(line.substr(8,10)); | ||
1534 | track->eq_Q(whicheq,Q); | ||
1535 | continue; | ||
1536 | } | ||
1537 | if ((line.substr(0,6)=="eq_on[") | ||
1538 | &&(line.substr(7,2)=="]=")) | ||
1539 | { | ||
1540 | int whicheq=Convert::str2long(line.substr(6,1)); | ||
1541 | int onoff=Convert::str2long(line.substr(9,10)); | ||
1542 | track->eq_on(whicheq,onoff); | ||
1543 | continue; | ||
1544 | } | ||
1545 | if (line.substr(0,6)=="fader=") { | ||
1546 | if (master) { | ||
1547 | this->fadervalue(Convert::str2dbl(line.substr(6,10))); | ||
1548 | } | ||
1549 | else | ||
1550 | { | ||
1551 | track->fadervalue(Convert::str2dbl(line.substr(6,10))); | ||
1552 | |||
1553 | } | ||
1554 | |||
1555 | continue; | ||
1556 | } | ||
1557 | |||
1558 | cout << "Unknown setting, ignoring: " << line << endl; | ||
1559 | } | ||
1560 | this->selectedchannel(savechan); | ||
1561 | from_in.close(); | ||
1562 | |||
1563 | return NULL;} {} | ||
1564 | } | ||
1565 | Function {loadtrackmix(string* strfile,int base0track)} {open return_type {string*} | ||
1566 | } { | ||
1567 | code {fstream from_in(strfile->c_str(),ios::in); | ||
1568 | if (from_in==NULL) { | ||
1569 | string *error=new string(""); | ||
1570 | *error+="Cannot open mix file for writing."; | ||
1571 | return error; | ||
1572 | } | ||
1573 | string line; | ||
1574 | int savechan=base0track; | ||
1575 | while (!(from_in.eof())) | ||
1576 | { | ||
1577 | getline(from_in,line); | ||
1578 | if (line=="") continue; | ||
1579 | if (line.substr(0,7)=="[Track=") { | ||
1580 | continue; | ||
1581 | } | ||
1582 | MixerChannelControl* track=parentui()->mixerchannel[selectedchannel()]->control; | ||
1583 | if (line.substr(0,5)=="solo=") { | ||
1584 | // mixsolo[this->selectedchannel]->value(Convert::str2long(line.substr(5,1))); | ||
1585 | track->solo(Convert::str2long(line.substr(5,1))); | ||
1586 | continue; | ||
1587 | } | ||
1588 | if (line.substr(0,5)=="mute=") { | ||
1589 | // mixmute[this->selectedchannel]->value(Convert::str2long(line.substr(5,1))); | ||
1590 | track->mute(Convert::str2long(line.substr(5,1))); | ||
1591 | continue; | ||
1592 | } | ||
1593 | if (line.substr(0,4)=="pan=") { | ||
1594 | track->panvalue(Convert::str2dbl(line.substr(4,10))); | ||
1595 | continue; | ||
1596 | } | ||
1597 | if ((line.substr(0,8)=="eq_freq[") | ||
1598 | &&(line.substr(9,2)=="]=")) | ||
1599 | { | ||
1600 | int whicheq=Convert::str2long(line.substr(8,1)); | ||
1601 | double freq=Convert::str2dbl(line.substr(11,10)); | ||
1602 | track->eq_freq(whicheq,freq); | ||
1603 | continue; | ||
1604 | |||
1605 | } | ||
1606 | if ((line.substr(0,8)=="eq_gain[") | ||
1607 | &&(line.substr(9,2)=="]=")) | ||
1608 | { | ||
1609 | int whicheq=Convert::str2long(line.substr(8,1)); | ||
1610 | double gain=Convert::str2dbl(line.substr(11,10)); | ||
1611 | track->eq_gain(whicheq,gain); | ||
1612 | continue; | ||
1613 | |||
1614 | } | ||
1615 | if ((line.substr(0,5)=="eq_Q[") | ||
1616 | &&(line.substr(6,2)=="]=")) | ||
1617 | { | ||
1618 | int whicheq=Convert::str2long(line.substr(5,1)); | ||
1619 | double Q=Convert::str2dbl(line.substr(8,10)); | ||
1620 | track->eq_Q(whicheq,Q); | ||
1621 | continue; | ||
1622 | } | ||
1623 | if ((line.substr(0,6)=="eq_on[") | ||
1624 | &&(line.substr(7,2)=="]=")) | ||
1625 | { | ||
1626 | int whicheq=Convert::str2long(line.substr(6,1)); | ||
1627 | int onoff=Convert::str2long(line.substr(9,10)); | ||
1628 | track->eq_on(whicheq,onoff); | ||
1629 | continue; | ||
1630 | } | ||
1631 | if (line.substr(0,6)=="fader=") { | ||
1632 | track->fadervalue(Convert::str2dbl(line.substr(6,10))); | ||
1633 | continue; | ||
1634 | } | ||
1635 | |||
1636 | cout << "Unknown setting, ignoring: " << line << endl; | ||
1637 | } | ||
1638 | this->selectedchannel(savechan); | ||
1639 | from_in.close(); | ||
1640 | |||
1641 | return NULL;} {} | ||
1642 | } | ||
1643 | Function {updatemeters()} {open | ||
1644 | } { | ||
1645 | code {MixerUI* pui=this->parentui(); | ||
1646 | if (pui==NULL) return; | ||
1647 | for (int tracknum=0;tracknum<24;tracknum++) { | ||
1648 | pui->mixerchannel[tracknum]->control->updatemeters(); | ||
1649 | } | ||
1650 | // update and redraw meterlevels object | ||
1651 | pui->fader_master->control->updatemeters();} {} | ||
1652 | } | ||
1653 | Function {samplerate(__uint32 p_samplerate)} {open return_type void | ||
1654 | } { | ||
1655 | code {data->samplerate=p_samplerate; | ||
1656 | |||
1657 | MixerUI* pui=this->parentui(); | ||
1658 | if (pui==NULL) return; | ||
1659 | for (int tracknum=0;tracknum<24;tracknum++) { | ||
1660 | pui->mixerchannel[tracknum]->control->samplerate(p_samplerate); | ||
1661 | }} {} | ||
1662 | } | ||
1663 | Function {samplerate()} {open return_type __uint32 | ||
1664 | } { | ||
1665 | code {return data->samplerate;} {} | ||
1666 | } | ||
1667 | Function {eq_on(int onoff)} {return_type void | ||
1668 | } { | ||
1669 | code {data->eqon=onoff; | ||
1670 | parentui()->eqon->value(onoff); | ||
1671 | parentui()->eqon->redraw();} {} | ||
1672 | } | ||
1673 | Function {eq_on()} {open return_type int | ||
1674 | } { | ||
1675 | code {return data->eqon;} {} | ||
1676 | } | ||
1677 | Function {bypass()} {return_type int | ||
1678 | } { | ||
1679 | code {return data->bypass;} {} | ||
1680 | } | ||
1681 | Function {bypass(int onoff)} {return_type void | ||
1682 | } { | ||
1683 | code {data->bypass=onoff; | ||
1684 | parentui()->bypass->value(onoff); | ||
1685 | parentui()->bypass->redraw();} {} | ||
1686 | } | ||
1687 | } | ||
1688 | |||
1689 | class MixerUI {open : {public Fl_Group} | ||
1690 | } { | ||
1691 | decl {MixerControl* control;} {public | ||
1692 | } | ||
1693 | decl {MixerChannelUI* mixerchannel[24];} {public | ||
1694 | } | ||
1695 | decl {/* ===MIXER UI stuff ===================================================== */} {} | ||
1696 | decl {HD24UserInterface* ui;} {} | ||
1697 | decl {Fl_Window* window} {} | ||
1698 | Function {make_window() /*<-----------------------------------*/} {open | ||
1699 | } { | ||
1700 | Fl_Window mixgroup {open | ||
1701 | xywh {41 257 605 460} type Double | ||
1702 | code0 {o->position(this->x(),this->y());} | ||
1703 | class Fl_Group visible | ||
1704 | } { | ||
1705 | Fl_Group resources {open | ||
1706 | xywh {70 52 150 98} hide deactivate | ||
1707 | } { | ||
1708 | Fl_Button button_small_up { | ||
1709 | tooltip arm image {images/button_small.gif} xywh {75 52 145 13} deactivate | ||
1710 | } | ||
1711 | Fl_Button button_small_dn { | ||
1712 | tooltip arm image {images/button_small_dn.gif} xywh {70 52 5 13} deactivate | ||
1713 | } | ||
1714 | } | ||
1715 | Fl_Group mixergroup {open | ||
1716 | xywh {-9 0 643 463} | ||
1717 | code0 {init_gui();} | ||
1718 | } { | ||
1719 | Fl_Box {} { | ||
1720 | xywh {-9 354 625 109} box BORDER_BOX | ||
1721 | } | ||
1722 | Fl_Box {} { | ||
1723 | label S | ||
1724 | tooltip Solo xywh {5 269 10 14} color 1 selection_color 1 labelfont 1 labelsize 12 | ||
1725 | } | ||
1726 | Fl_Box {} { | ||
1727 | label M | ||
1728 | tooltip Mute xywh {5 286 10 14} color 1 selection_color 1 labelfont 1 labelsize 12 | ||
1729 | } | ||
1730 | Fl_Group channelgroup {open selected | ||
1731 | xywh {0 210 584 250} deactivate | ||
1732 | } { | ||
1733 | Fl_Group mixerchannel1 {open | ||
1734 | xywh {17 221 20 231} box BORDER_BOX color 7 | ||
1735 | code0 {mixerchannel[0]=o;} | ||
1736 | class MixerChannelUI | ||
1737 | } {} | ||
1738 | Fl_Group mixerchannel2 {open | ||
1739 | xywh {37 221 20 231} box BORDER_BOX color 7 | ||
1740 | code0 {mixerchannel[1]=o;} | ||
1741 | class MixerChannelUI | ||
1742 | } {} | ||
1743 | Fl_Group mixerchannel3 {open | ||
1744 | xywh {57 221 20 231} box BORDER_BOX color 7 | ||
1745 | code0 {mixerchannel[2]=o;} | ||
1746 | class MixerChannelUI | ||
1747 | } {} | ||
1748 | Fl_Group mixerchannel4 {open | ||
1749 | xywh {77 221 20 231} box BORDER_BOX color 7 | ||
1750 | code0 {mixerchannel[3]=o;} | ||
1751 | class MixerChannelUI | ||
1752 | } {} | ||
1753 | Fl_Group mixerchannel5 {open | ||
1754 | xywh {97 221 20 231} box BORDER_BOX color 7 | ||
1755 | code0 {mixerchannel[4]=o;} | ||
1756 | class MixerChannelUI | ||
1757 | } {} | ||
1758 | Fl_Group mixerchannel6 {open | ||
1759 | xywh {117 221 20 231} box BORDER_BOX color 7 | ||
1760 | code0 {mixerchannel[5]=o;} | ||
1761 | class MixerChannelUI | ||
1762 | } {} | ||
1763 | Fl_Group mixerchannel7 {open | ||
1764 | xywh {137 221 20 231} box BORDER_BOX color 7 | ||
1765 | code0 {mixerchannel[6]=o;} | ||
1766 | class MixerChannelUI | ||
1767 | } {} | ||
1768 | Fl_Group mixerchannel8 {open | ||
1769 | xywh {157 221 20 231} box BORDER_BOX color 7 | ||
1770 | code0 {mixerchannel[7]=o;} | ||
1771 | class MixerChannelUI | ||
1772 | } {} | ||
1773 | Fl_Group mixerchannel9 {open | ||
1774 | xywh {177 221 20 231} box BORDER_BOX color 7 | ||
1775 | code0 {mixerchannel[8]=o;} | ||
1776 | class MixerChannelUI | ||
1777 | } {} | ||
1778 | Fl_Group mixerchannel10 {open | ||
1779 | xywh {197 221 20 231} box BORDER_BOX color 7 | ||
1780 | code0 {mixerchannel[9]=o;} | ||
1781 | class MixerChannelUI | ||
1782 | } {} | ||
1783 | Fl_Group mixerchannel11 {open | ||
1784 | xywh {217 221 20 231} box BORDER_BOX color 7 | ||
1785 | code0 {mixerchannel[10]=o;} | ||
1786 | class MixerChannelUI | ||
1787 | } {} | ||
1788 | Fl_Group mixerchannel12 {open | ||
1789 | xywh {237 221 20 231} box BORDER_BOX color 7 | ||
1790 | code0 {mixerchannel[11]=o;} | ||
1791 | class MixerChannelUI | ||
1792 | } {} | ||
1793 | Fl_Group mixerchannel13 {open | ||
1794 | xywh {257 221 20 231} box BORDER_BOX color 7 | ||
1795 | code0 {mixerchannel[12]=o;} | ||
1796 | class MixerChannelUI | ||
1797 | } {} | ||
1798 | Fl_Group mixerchannel14 {open | ||
1799 | xywh {277 221 20 231} box BORDER_BOX color 7 | ||
1800 | code0 {mixerchannel[13]=o;} | ||
1801 | class MixerChannelUI | ||
1802 | } {} | ||
1803 | Fl_Group mixerchannel15 {open | ||
1804 | xywh {297 221 20 231} box BORDER_BOX color 7 | ||
1805 | code0 {mixerchannel[14]=o;} | ||
1806 | class MixerChannelUI | ||
1807 | } {} | ||
1808 | Fl_Group mixerchannel16 {open | ||
1809 | xywh {317 221 20 231} box BORDER_BOX color 7 | ||
1810 | code0 {mixerchannel[15]=o;} | ||
1811 | class MixerChannelUI | ||
1812 | } {} | ||
1813 | Fl_Group mixerchannel17 {open | ||
1814 | xywh {337 221 20 231} box BORDER_BOX color 7 | ||
1815 | code0 {mixerchannel[16]=o;} | ||
1816 | class MixerChannelUI | ||
1817 | } {} | ||
1818 | Fl_Group mixerchannel18 {open | ||
1819 | xywh {357 221 20 231} box BORDER_BOX color 7 | ||
1820 | code0 {mixerchannel[17]=o;} | ||
1821 | class MixerChannelUI | ||
1822 | } {} | ||
1823 | Fl_Group mixerchannel19 {open | ||
1824 | xywh {377 221 20 231} box BORDER_BOX color 7 | ||
1825 | code0 {mixerchannel[18]=o;} | ||
1826 | class MixerChannelUI | ||
1827 | } {} | ||
1828 | Fl_Group mixerchannel20 {open | ||
1829 | xywh {397 221 20 231} box BORDER_BOX color 7 | ||
1830 | code0 {mixerchannel[19]=o;} | ||
1831 | class MixerChannelUI | ||
1832 | } {} | ||
1833 | Fl_Group mixerchannel21 {open | ||
1834 | xywh {417 221 20 231} box BORDER_BOX color 7 | ||
1835 | code0 {mixerchannel[20]=o;} | ||
1836 | class MixerChannelUI | ||
1837 | } {} | ||
1838 | Fl_Group mixerchannel22 {open | ||
1839 | xywh {437 221 20 231} box BORDER_BOX color 7 | ||
1840 | code0 {mixerchannel[21]=o;} | ||
1841 | class MixerChannelUI | ||
1842 | } {} | ||
1843 | Fl_Group mixerchannel23 {open | ||
1844 | xywh {457 221 20 231} box BORDER_BOX color 7 | ||
1845 | code0 {mixerchannel[22]=o;} | ||
1846 | class MixerChannelUI | ||
1847 | } {} | ||
1848 | Fl_Group mixerchannel24 {open | ||
1849 | xywh {477 221 20 231} box BORDER_BOX color 7 | ||
1850 | code0 {mixerchannel[23]=o;} | ||
1851 | class MixerChannelUI | ||
1852 | } {} | ||
1853 | } | ||
1854 | Fl_Tabs {} {open | ||
1855 | xywh {10 25 435 195} | ||
1856 | } { | ||
1857 | Fl_Group eqgroup { | ||
1858 | label EQ open | ||
1859 | xywh {10 45 435 175} labelfont 1 labelsize 10 deactivate | ||
1860 | } { | ||
1861 | Fl_Dial gain1 { | ||
1862 | callback {mixerchannel[control->selectedchannel()]->control->eq_gain(0,o->value());} | ||
1863 | xywh {20 159 30 30} minimum -20 maximum 20 step 10 | ||
1864 | class WidgetPDial | ||
1865 | } | ||
1866 | Fl_Dial gain2 { | ||
1867 | callback {mixerchannel[control->selectedchannel()]->control->eq_gain(1,o->value());} | ||
1868 | xywh {65 159 30 30} minimum -20 maximum 20 step 10 | ||
1869 | class WidgetPDial | ||
1870 | } | ||
1871 | Fl_Dial gain3 { | ||
1872 | callback {mixerchannel[control->selectedchannel()]->control->eq_gain(2,o->value());} | ||
1873 | xywh {110 159 30 30} minimum -20 maximum 20 step 10 | ||
1874 | class WidgetPDial | ||
1875 | } | ||
1876 | Fl_Dial gain4 { | ||
1877 | label GAIN | ||
1878 | callback {mixerchannel[control->selectedchannel()]->control->eq_gain(3,o->value());} | ||
1879 | xywh {155 159 30 30} labelfont 1 labelsize 12 align 8 minimum -20 maximum 20 step 10 | ||
1880 | class WidgetPDial | ||
1881 | } | ||
1882 | Fl_Dial freq1 { | ||
1883 | callback {mixerchannel[control->selectedchannel()]->control->eq_freq(0,o->value());} | ||
1884 | xywh {20 125 30 30} minimum 20 maximum 200 step 10 value 100 | ||
1885 | class WidgetPDial | ||
1886 | } | ||
1887 | Fl_Dial freq2 { | ||
1888 | callback {mixerchannel[control->selectedchannel()]->control->eq_freq(1,o->value());} | ||
1889 | xywh {65 125 30 30} minimum 150 maximum 1000 step 20 value 600 | ||
1890 | class WidgetPDial | ||
1891 | } | ||
1892 | Fl_Dial freq3 { | ||
1893 | callback {mixerchannel[control->selectedchannel()]->control->eq_freq(2,o->value());} | ||
1894 | xywh {110 125 30 30} minimum 800 maximum 3000 step 10 value 1600 | ||
1895 | class WidgetPDial | ||
1896 | } | ||
1897 | Fl_Dial freq4 { | ||
1898 | label FREQ | ||
1899 | callback {mixerchannel[control->selectedchannel()]->control->eq_freq(3,o->value());} | ||
1900 | xywh {155 125 30 30} labelfont 1 labelsize 12 align 8 minimum 3000 maximum 12000 step 1 value 6000 | ||
1901 | class WidgetPDial | ||
1902 | } | ||
1903 | Fl_Check_Button eqon1 { | ||
1904 | label { Low} | ||
1905 | callback {mixerchannel[control->selectedchannel()]->control->eq_on(0,o->value());} | ||
1906 | xywh {15 95 20 15} down_box DOWN_BOX value 1 labelsize 12 align 5 | ||
1907 | } | ||
1908 | Fl_Check_Button eqon2 { | ||
1909 | label {Lo/Mid} | ||
1910 | callback {mixerchannel[control->selectedchannel()]->control->eq_on(1,o->value());} | ||
1911 | xywh {60 95 20 15} down_box DOWN_BOX value 1 labelsize 12 align 5 | ||
1912 | } | ||
1913 | Fl_Check_Button eqon3 { | ||
1914 | label {Hi/Mid} | ||
1915 | callback {mixerchannel[control->selectedchannel()]->control->eq_on(2,o->value());} | ||
1916 | xywh {105 95 20 15} down_box DOWN_BOX value 1 labelsize 12 align 5 | ||
1917 | } | ||
1918 | Fl_Check_Button eqon4 { | ||
1919 | label High | ||
1920 | callback {mixerchannel[control->selectedchannel()]->control->eq_on(3,o->value());} | ||
1921 | xywh {150 95 20 15} down_box DOWN_BOX value 1 labelsize 12 align 5 | ||
1922 | } | ||
1923 | Fl_Check_Button eqon { | ||
1924 | label {Enable equalizer (all channels)} | ||
1925 | callback {control->eq_on(o->value());} | ||
1926 | xywh {15 50 205 20} down_box DOWN_BOX value 1 labelsize 12 | ||
1927 | } | ||
1928 | Fl_Check_Button reverbon { | ||
1929 | label {Reverb (not yet available)} | ||
1930 | callback {//mixerchannel[control->selectedchannel()]->control->reverb_on(o->value());} | ||
1931 | xywh {240 95 175 15} down_box DOWN_BOX value 1 labelsize 12 deactivate | ||
1932 | } | ||
1933 | Fl_Check_Button tapesaton { | ||
1934 | label {Tape emulation} | ||
1935 | callback {//mixerchannel[control->selectedchannel()]->control->reverb_on(o->value());} | ||
1936 | xywh {240 80 175 15} down_box DOWN_BOX value 1 labelsize 12 deactivate | ||
1937 | } | ||
1938 | Fl_Output dispgain1 { | ||
1939 | xywh {15 190 40 15} box FLAT_BOX color 53 labelsize 10 align 0 textsize 10 | ||
1940 | } | ||
1941 | Fl_Output dispgain2 { | ||
1942 | xywh {60 190 40 15} box FLAT_BOX color 53 labelsize 10 align 0 textsize 10 | ||
1943 | } | ||
1944 | Fl_Output dispgain3 { | ||
1945 | xywh {105 190 40 15} box FLAT_BOX color 53 labelsize 10 align 0 textsize 10 | ||
1946 | } | ||
1947 | Fl_Output dispgain4 { | ||
1948 | xywh {150 190 40 15} box FLAT_BOX color 53 labelsize 10 align 0 textsize 10 | ||
1949 | } | ||
1950 | Fl_Output dispfreq1 { | ||
1951 | xywh {15 109 40 15} box FLAT_BOX color 53 labelsize 10 align 0 textsize 10 | ||
1952 | } | ||
1953 | Fl_Output dispfreq2 { | ||
1954 | xywh {60 109 40 15} box FLAT_BOX color 53 labelsize 10 align 0 textsize 10 | ||
1955 | } | ||
1956 | Fl_Output dispfreq3 { | ||
1957 | xywh {105 109 40 15} box FLAT_BOX color 53 labelsize 10 align 0 textsize 10 | ||
1958 | } | ||
1959 | Fl_Output dispfreq4 { | ||
1960 | xywh {150 109 40 15} box FLAT_BOX color 53 labelsize 10 align 0 textsize 10 | ||
1961 | } | ||
1962 | } | ||
1963 | Fl_Tabs {} { | ||
1964 | label AUX | ||
1965 | xywh {10 45 330 175} labelfont 1 labelsize 10 hide | ||
1966 | } {} | ||
1967 | } | ||
1968 | Fl_Button bypass { | ||
1969 | label {Bypass Mixer} | ||
1970 | callback {control->bypass(o->value()); | ||
1971 | |||
1972 | switch (o->value()) | ||
1973 | { | ||
1974 | case 0: | ||
1975 | eqgroup->activate(); | ||
1976 | channelgroup->activate(); | ||
1977 | break; | ||
1978 | case 1: | ||
1979 | eqgroup->deactivate(); | ||
1980 | channelgroup->deactivate(); | ||
1981 | break; | ||
1982 | |||
1983 | }} | ||
1984 | tooltip Solo xywh {10 0 90 20} type Toggle value 1 selection_color 1 labelsize 12 | ||
1985 | } | ||
1986 | Fl_Group fader_master {open | ||
1987 | xywh {574 221 20 231} box BORDER_BOX color 7 | ||
1988 | class MasterChannelUI | ||
1989 | } {} | ||
1990 | } | ||
1991 | } | ||
1992 | } | ||
1993 | Function {MixerUI(int a,int b,int c,int d):Fl_Group(a,b,c,d,NULL)} {open | ||
1994 | } { | ||
1995 | code {control=new MixerControl(); | ||
1996 | control->parentui(this); | ||
1997 | this->window=(Fl_Window*)(this->make_window());} {} | ||
1998 | } | ||
1999 | Function {~MixerUI()} {open | ||
2000 | } { | ||
2001 | code {delete control;} {} | ||
2002 | } | ||
2003 | Function {init_gui()} {open | ||
2004 | } { | ||
2005 | code {int starty=(mixerchannel[0]->y()); | ||
2006 | int startx=(mixerchannel[0]->x()); | ||
2007 | fader_master->clear_visible_focus(); | ||
2008 | for (int i=1;i<=24;i++) | ||
2009 | { | ||
2010 | if (i==1) { | ||
2011 | mixerchannel[i-1]->control->channelselect(1); | ||
2012 | } | ||
2013 | mixerchannel[i-1]->position(startx+((i-1)*23),starty); | ||
2014 | // mixerchannel[i-1]->size(mixerchannel[0]->w(),mixerchannel[0]->h()); | ||
2015 | mixerchannel[i-1]->clear_visible_focus(); | ||
2016 | mixerchannel[i-1]->control->channel_number(i); | ||
2017 | |||
2018 | mixerchannel[i-1]->control->parentmixercontrol(this->control); | ||
2019 | |||
2020 | // set values on freq/gain displays: | ||
2021 | mixerchannel[i-1]->control->eq_freq(0,mixerchannel[i-1]->control->eq_freq(0)); | ||
2022 | mixerchannel[i-1]->control->eq_freq(1,mixerchannel[i-1]->control->eq_freq(1)); | ||
2023 | mixerchannel[i-1]->control->eq_freq(2,mixerchannel[i-1]->control->eq_freq(2)); | ||
2024 | mixerchannel[i-1]->control->eq_freq(3,mixerchannel[i-1]->control->eq_freq(3)); | ||
2025 | |||
2026 | mixerchannel[i-1]->control->eq_gain(0,mixerchannel[i-1]->control->eq_gain(0)); | ||
2027 | mixerchannel[i-1]->control->eq_gain(1,mixerchannel[i-1]->control->eq_gain(1)); | ||
2028 | mixerchannel[i-1]->control->eq_gain(2,mixerchannel[i-1]->control->eq_gain(2)); | ||
2029 | mixerchannel[i-1]->control->eq_gain(3,mixerchannel[i-1]->control->eq_gain(3)); | ||
2030 | |||
2031 | |||
2032 | // eq_freq[(i-1)*eqperchan+0]=100; | ||
2033 | // eq_freq[(i-1)*eqperchan+1]=600; | ||
2034 | // eq_freq[(i-1)*eqperchan+2]=1600; | ||
2035 | // eq_freq[(i-1)*eqperchan+3]=6000; | ||
2036 | // eq_on[(i-1)*eqperchan+0]=eqon1->value(); | ||
2037 | // eq_on[(i-1)*eqperchan+1]=eqon2->value(); | ||
2038 | // eq_on[(i-1)*eqperchan+2]=eqon3->value(); | ||
2039 | // eq_on[(i-1)*eqperchan+3]=eqon4->value(); | ||
2040 | // for (int j=0;j<4;j++) { | ||
2041 | // eq_gain[(i-1)*eqperchan+j]=0; | ||
2042 | // | ||
2043 | // eq_Q[(i-1)*eqperchan+j]=1; | ||
2044 | // eq_type[(i-1)*eqperchan+j]=7; | ||
2045 | // } | ||
2046 | mixerchannel[i-1]->clear_visible_focus(); | ||
2047 | // mixsolo[i-1]->position(8+(startx)+((i-1)*23),mixsolo[i-1]->y()); | ||
2048 | // mixsolo[i-1]->size(mixsolo[0]->w(),mixsolo[0]->h()); | ||
2049 | // mixsolo[i-1]->up_image(mixsolo[0]->up_image()); | ||
2050 | // mixsolo[i-1]->down_image(mixsolo[0]->down_image()); | ||
2051 | |||
2052 | // mixmute[i-1]->position(mixsolo[i-1]->x(),mixmute[i-1]->y()); | ||
2053 | // mixmute[i-1]->size(mixmute[0]->w(),mixmute[0]->h()); | ||
2054 | // mixmute[i-1]->up_image(mixmute[0]->up_image()); | ||
2055 | // mixmute[i-1]->down_image(mixmute[0]->down_image()); | ||
2056 | |||
2057 | // mixfader[i-1]->position(mixsolo[i-1]->x(),mixfader[i-1]->y()); | ||
2058 | // mixfader[i-1]->size(mixfader[0]->w(),mixfader[0]->h()); | ||
2059 | |||
2060 | // mixchsel[i-1]->position(mixsolo[i-1]->x(),mixchsel[i-1]->y()); | ||
2061 | // mixpan[i-1]->position(mixsolo[i-1]->x(),mixpan[i-1]->y()); | ||
2062 | // mixled[i-1]->position(mixfader[i-1]->x()+17,mixfader[0]->y()); | ||
2063 | mixerchannel[i-1]->control->fadervalue(90); | ||
2064 | } | ||
2065 | |||
2066 | //masterled[0]->position(fader_master->x()-2,fader_master->y()); | ||
2067 | //masterled[1]->position(fader_master->x()+17,fader_master->y()); | ||
2068 | fader_master->control->fadervalue(90); | ||
2069 | //this->selectedchannel(0);} {} | ||
2070 | } | ||
2071 | Function {set_ui(HD24UserInterface* p_ui)} {open return_type void | ||
2072 | } { | ||
2073 | code {this->ui=p_ui;} {} | ||
2074 | } | ||
2075 | Function {loadfromfile()} {open return_type void | ||
2076 | } { | ||
2077 | code {string* mixdir=hd24utils::getlastdir("mixdir"); | ||
2078 | |||
2079 | Fl_Native_File_Chooser chooser; | ||
2080 | chooser.directory(mixdir->c_str()); | ||
2081 | delete mixdir; | ||
2082 | |||
2083 | chooser.title("Select a mix to load\\0"); | ||
2084 | chooser.type(Fl_Native_File_Chooser::BROWSE_FILE); | ||
2085 | chooser.filter("Mixer settings\\t*.{mix}\\0"); | ||
2086 | //chooser.preview(0); | ||
2087 | switch (chooser.show()) { | ||
2088 | case -1: break; //error | ||
2089 | case 1: break; //cancel | ||
2090 | default: | ||
2091 | if (chooser.filename()) { | ||
2092 | string* cfilename=new string(chooser.filename()); | ||
2093 | |||
2094 | //cout << "filename = " << *strfile << endl; | ||
2095 | string* fpath=new string(""); | ||
2096 | *fpath+=cfilename->substr(0,strlen(cfilename->c_str())-strlen(fl_filename_name(cfilename->c_str()))); | ||
2097 | hd24utils::setlastdir("mixdir",fpath->c_str()); | ||
2098 | control->loadmix(cfilename); | ||
2099 | delete fpath; | ||
2100 | delete cfilename; | ||
2101 | } | ||
2102 | break; | ||
2103 | }} {} | ||
2104 | } | ||
2105 | Function {savetofile()} {open return_type void | ||
2106 | } { | ||
2107 | code {string* mixdir=new string(""); | ||
2108 | *mixdir+=*(hd24utils::getlastdir("mixdir")); | ||
2109 | |||
2110 | Fl_Native_File_Chooser chooser; | ||
2111 | chooser.filter("Mix files\\t*.mix"); | ||
2112 | chooser.title("Save mixer settings to file"); | ||
2113 | chooser.directory(mixdir->c_str()); | ||
2114 | chooser.options(Fl_Native_File_Chooser::NEW_FOLDER); | ||
2115 | chooser.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE); | ||
2116 | |||
2117 | switch (chooser.show()) { | ||
2118 | case -1: break; //error | ||
2119 | case 1: break; //cancel | ||
2120 | default: | ||
2121 | // save header to chooser.filename() | ||
2122 | |||
2123 | bool bFileexists=false; | ||
2124 | if (bFileexists) { | ||
2125 | bool choice=ui->confirm( | ||
2126 | "A file with this name already exists. Do you wish to overwrite it?" | ||
2127 | ); | ||
2128 | if (!(choice)) return; | ||
2129 | } | ||
2130 | string* strfile=new string(chooser.filename()); | ||
2131 | //cout << "filename = " << *strfile << endl; | ||
2132 | string* fpath=new string(""); | ||
2133 | *fpath+=strfile->substr(0,strlen(strfile->c_str())-strlen(fl_filename_name(strfile->c_str()))); | ||
2134 | hd24utils::setlastdir("mixdir",fpath->c_str()); | ||
2135 | |||
2136 | string* anyerrors=control->savemix(strfile); | ||
2137 | |||
2138 | delete strfile; | ||
2139 | delete fpath; | ||
2140 | if (anyerrors==NULL) { | ||
2141 | fl_message("Mix file saved successfully."); | ||
2142 | } else { | ||
2143 | delete anyerrors; | ||
2144 | fl_message("Could not write mix file. Access denied? Disk full?"); | ||
2145 | } | ||
2146 | break; | ||
2147 | } | ||
2148 | delete mixdir;} {} | ||
2149 | } | ||
2150 | Function {loadtrackmixfromfile()} {open return_type void | ||
2151 | } { | ||
2152 | code {string* mixdir=hd24utils::getlastdir("mixdir"); | ||
2153 | |||
2154 | Fl_Native_File_Chooser chooser; | ||
2155 | chooser.directory(mixdir->c_str()); | ||
2156 | delete mixdir; | ||
2157 | |||
2158 | chooser.title("Select a mix to load\\0"); | ||
2159 | chooser.type(Fl_Native_File_Chooser::BROWSE_FILE); | ||
2160 | chooser.filter("Mixer settings\\t*.{mix}\\0"); | ||
2161 | //chooser.preview(0); | ||
2162 | switch (chooser.show()) { | ||
2163 | case -1: break; //error | ||
2164 | case 1: break; //cancel | ||
2165 | default: | ||
2166 | if (chooser.filename()) { | ||
2167 | string* cfilename=new string(chooser.filename()); | ||
2168 | |||
2169 | //cout << "filename = " << *strfile << endl; | ||
2170 | string* fpath=new string(""); | ||
2171 | *fpath+=cfilename->substr(0,strlen(cfilename->c_str())-strlen(fl_filename_name(cfilename->c_str()))); | ||
2172 | hd24utils::setlastdir("mixdir",fpath->c_str()); | ||
2173 | control->loadtrackmix(cfilename,control->selectedchannel()); | ||
2174 | delete fpath; | ||
2175 | delete cfilename; | ||
2176 | } | ||
2177 | break; | ||
2178 | }} {} | ||
2179 | } | ||
2180 | Function {savetrackmixtofile()} {open return_type void | ||
2181 | } { | ||
2182 | code {string* mixdir=new string(""); | ||
2183 | *mixdir+=*(hd24utils::getlastdir("mixdir")); | ||
2184 | |||
2185 | Fl_Native_File_Chooser chooser; | ||
2186 | chooser.filter("Mix files\\t*.mix"); | ||
2187 | chooser.title("Save mixer settings to file"); | ||
2188 | chooser.directory(mixdir->c_str()); | ||
2189 | chooser.options(Fl_Native_File_Chooser::NEW_FOLDER); | ||
2190 | chooser.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE); | ||
2191 | |||
2192 | switch (chooser.show()) { | ||
2193 | case -1: break; //error | ||
2194 | case 1: break; //cancel | ||
2195 | default: | ||
2196 | // save header to chooser.filename() | ||
2197 | |||
2198 | bool bFileexists=false; | ||
2199 | if (bFileexists) { | ||
2200 | bool choice=ui->confirm( | ||
2201 | "A file with this name already exists. Do you wish to overwrite it?" | ||
2202 | ); | ||
2203 | if (!(choice)) return; | ||
2204 | } | ||
2205 | string* strfile=new string(chooser.filename()); | ||
2206 | //cout << "filename = " << *strfile << endl; | ||
2207 | string* fpath=new string(""); | ||
2208 | *fpath+=strfile->substr(0,strlen(strfile->c_str())-strlen(fl_filename_name(strfile->c_str()))); | ||
2209 | hd24utils::setlastdir("mixdir",fpath->c_str()); | ||
2210 | |||
2211 | string* anyerrors=control->savetrackmix(strfile,control->selectedchannel()); | ||
2212 | |||
2213 | delete strfile; | ||
2214 | if (anyerrors==NULL) { | ||
2215 | fl_message("Mix file saved successfully."); | ||
2216 | } else { | ||
2217 | delete anyerrors; | ||
2218 | fl_message("Could not write mix file. Access denied? Disk full?"); | ||
2219 | } | ||
2220 | delete fpath; | ||
2221 | break; | ||
2222 | } | ||
2223 | delete mixdir;} {} | ||
2224 | } | ||
2225 | } | ||