-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathfabla.fl
518 lines (496 loc) · 15.5 KB
/
fabla.fl
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
# data file for the Fltk User Interface Designer (fluid)
version 1.0300
header_name {.h}
code_name {.cxx}
class FablaUI {open
} {
Function {FablaUI()} {open
} {
code {setupUI();
w->show();} {}
}
Function {FablaUI(void* xParentWindow, Fabla* f)} {open
} {
code {setupUI();
fabla = f;
// embed drawn stuff into LV2 host provided area
fl_embed( w, (Window)xParentWindow );} {}
}
Function {setupUI()} {open
} {
code {// In case FLTK hasn't set up yet
fl_open_display();
selectedPad = 0;} {}
Fl_Window w {
label Fabla
callback {close_cb( o, 0 );} open
xywh {1403 321 515 490} type Double box UP_BOX color 48 selection_color 0 labelcolor 88
code0 {\#include "avtk.h"}
code1 {using namespace Avtk;}
code2 {\#include <FL/x.H>}
code3 {\#include "lv2/lv2plug.in/ns/lv2core/lv2.h"} visible
} {
Fl_Box {} {
label Source
xywh {346 41 159 215} box UP_BOX
class Background
}
Fl_Box adsr {
xywh {351 66 150 84} box UP_BOX
code0 {adsr->attack(0); adsr->decay(0.5);}
code1 {adsr->sustain(1); adsr->release(0.5);}
class ADSR
}
Fl_Box {} {
label Master
xywh {346 265 159 215} box UP_BOX
class Background
}
Fl_Box compressor {
label Compressor
callback {if ( o->mouseRightClicked )
{
float tmp = 0.0f;
if ( o->active )
tmp = 1.f;
writeFunction(controller, COMP_ENABLE, sizeof(float), 0, (const void*) &tmp);
}
else
{
float tmp = o->getMakeup();
writeFunction(controller, COMP_MAKEUP, sizeof(float), 0, (const void*) &tmp);
}}
xywh {352 290 97 84} box UP_BOX
code0 {compressor->set_active( false );}
class Compressor
}
Fl_Box compressorBox {
xywh {351 379 97 97} box BORDER_BOX
code0 {compressorBox->color( fl_rgb_color( 28,28,28 ));}
}
Fl_Box masterVol {
label Vol
callback {float tmp = o->value();
writeFunction(controller, MASTER_VOL, sizeof(float), 0, (const void*) &tmp);}
xywh {453 290 48 186} box UP_BOX
code0 {\#include "../dsp/ports.h"}
code1 {\#include "lv2/lv2plug.in/ns/extensions/ui/ui.h"}
code2 {\#include "../dsp/shared.h"}
code3 {\#include "fabla.hxx"}
class Volume
}
Fl_Box adsrBox {selected
xywh {350 155 150 98} box BORDER_BOX
code0 {adsrBox->color( fl_rgb_color( 28,28,28 ));}
}
Fl_Box compRelease {
label Rel
callback {float tmp = o->value();
//compressor->release( tmp );
writeFunction(controller, COMP_DECAY, sizeof(float), 0, (const void*) &tmp);}
xywh {406 435 30 30} box UP_BOX color 48 labelcolor 54
code0 {compRelease->defaultValue(0.3);}
class Dial
}
Fl_Box {} {
label Waveform
xywh {9 41 330 132} box UP_BOX
class Background
}
Fl_Box {} {
label Pads
xywh {9 180 330 300} box UP_BOX
class Background
}
Fl_Box waveform {
xywh {11 64 324 107} box UP_BOX
class Waveform
}
Fl_Box image {
label {header image}
xywh {0 0 515 36} box UP_BOX
code0 {\#include "header.c"}
code1 {image->setPixbuf(header.pixel_data,4);}
class Image
}
Fl_Box p13 {
label 13
callback {pad_click( o->ID(), o->mouseRightClicked );}
xywh {15 205 75 64} box BORDER_BOX labelfont 1 labelcolor 54
code0 {p13->ID(12);}
class Pad
}
Fl_Box p14 {
label 14
callback {pad_click( o->ID(), o->mouseRightClicked );}
xywh {97 205 75 64} box BORDER_BOX labelfont 1 labelcolor 54
code0 {p14->ID(13);}
class Pad
}
Fl_Box p15 {
label 15
callback {pad_click( o->ID(), o->mouseRightClicked );}
xywh {178 205 75 64} box BORDER_BOX labelfont 1 labelcolor 54
code0 {p15->ID(14);}
class Pad
}
Fl_Box p16 {
label 16
callback {pad_click( o->ID(), o->mouseRightClicked );}
xywh {259 205 75 64} box BORDER_BOX labelfont 1 labelcolor 54
code0 {p16->ID(15);}
class Pad
}
Fl_Box p9 {
label 9
callback {pad_click( o->ID(), o->mouseRightClicked );}
xywh {15 273 75 64} box BORDER_BOX labelfont 1 labelcolor 54
code0 {p9->ID(8);}
class Pad
}
Fl_Box p5 {
label 5
callback {pad_click( o->ID(), o->mouseRightClicked );}
xywh {15 341 75 64} box BORDER_BOX labelfont 1 labelcolor 54
code0 {p5->ID(4);}
class Pad
}
Fl_Box p1 {
label 1
callback {pad_click( o->ID(), o->mouseRightClicked );}
xywh {15 411 75 64} box BORDER_BOX labelfont 1 labelcolor 54
code0 {p1->selected(true);}
code1 {p1->ID(0);}
code2 {\#include <FL/Fl_Native_File_Chooser.H>}
class Pad
}
Fl_Box p10 {
label 10
callback {pad_click( o->ID(), o->mouseRightClicked );}
xywh {97 273 75 64} box BORDER_BOX labelfont 1 labelcolor 54
code0 {p10->ID(9);}
class Pad
}
Fl_Box p6 {
label 6
callback {pad_click( o->ID(), o->mouseRightClicked );}
xywh {97 341 75 64} box BORDER_BOX labelfont 1 labelcolor 54
code0 {p6->ID(5);}
class Pad
}
Fl_Box p2 {
label 2
callback {pad_click( o->ID(), o->mouseRightClicked );}
xywh {97 411 75 64} box BORDER_BOX labelfont 1 labelcolor 54
code0 {p2->ID(1);}
class Pad
}
Fl_Box p11 {
label 11
callback {pad_click( o->ID(), o->mouseRightClicked );}
xywh {178 273 75 64} box BORDER_BOX labelfont 1 labelcolor 54
code0 {p11->ID(10);}
class Pad
}
Fl_Box p7 {
label 7
callback {pad_click( o->ID(), o->mouseRightClicked );}
xywh {178 341 75 64} box BORDER_BOX labelfont 1 labelcolor 54
code0 {p7->ID(6);}
class Pad
}
Fl_Box p3 {
label 3
callback {pad_click( o->ID(), o->mouseRightClicked );}
xywh {178 411 75 64} box BORDER_BOX labelfont 1 labelcolor 54
code0 {p3->ID(2);}
class Pad
}
Fl_Box p12 {
label 12
callback {pad_click( o->ID(), o->mouseRightClicked );}
xywh {259 273 75 64} box BORDER_BOX labelfont 1 labelcolor 54
code0 {p12->ID(11);}
class Pad
}
Fl_Box p8 {
label 8
callback {pad_click( o->ID(), o->mouseRightClicked );}
xywh {259 341 75 64} box BORDER_BOX labelfont 1 labelcolor 54
code0 {p8->ID(7);}
class Pad
}
Fl_Box p4 {
label 4
callback {pad_click( o->ID(), o->mouseRightClicked );}
xywh {259 411 75 64} box BORDER_BOX labelfont 1 labelcolor 54
code0 {p4->ID(3);}
class Pad
}
Fl_Box compAttack {
label Atk
callback {float tmp = o->value();
//compressor->attack( tmp );
writeFunction(controller, COMP_ATTACK, sizeof(float), 0, (const void*) &tmp);}
xywh {365 435 30 30} box UP_BOX color 48 labelcolor 54
code0 {compAttack->defaultValue(0.1);}
class Dial
}
Fl_Box compThres {
label Thres
callback {float tmp = o->value();
compressor->threshold( tmp );
writeFunction(controller, COMP_THRES, sizeof(float), 0, (const void*) &tmp);}
xywh {406 395 30 30} box UP_BOX color 48 labelcolor 54
code0 {compThres->defaultValue(0.7);}
class Dial
}
Fl_Box compRatio {
label Ratio
callback {float tmp = o->value();
compressor->ratio( tmp );
writeFunction(controller, COMP_RATIO, sizeof(float), 0, (const void*) &tmp);}
xywh {365 395 30 30} box UP_BOX color 48 labelcolor 54
code0 {compRatio->defaultValue(0.3);}
class Dial
}
Fl_Box gain {
label VOL
callback {float tmp = o->value();
int port = int(PAD_GAIN) + selectedPad;
padData[selectedPad].gain = tmp;
writeFunction(controller, port, sizeof(float), 0, (const void*) &tmp);
//printf("gain on pad\# %i, port\# %i, value %f\\n", selectedPad, port, tmp);}
xywh {357 210 38 38} box UP_BOX color 48 labelcolor 54
code0 {gain->drawLabel(true);}
code1 {gain->value( 0.5 );}
code2 {gain->defaultValue(0.5);}
class Dial
}
Fl_Box d {
label D
callback {adsr->decay( o->value() );
float tmp = o->value();
int port = int(PAD_DECAY) + selectedPad;
padData[selectedPad].d = tmp;
writeFunction(controller, port, sizeof(float), 0, (const void*) &tmp);
printf("decay on pad\# %i, port\# %i, value %f\\n", selectedPad, port, tmp);}
xywh {393 170 30 30} box UP_BOX color 48 labelfont 1 labelcolor 54
code0 {d->defaultValue(0.5);}
class Dial
}
Fl_Box speed {
label SPD
callback {float tmp = o->value();
int port = int(PAD_SPEED) + selectedPad;
padData[selectedPad].speed = tmp;
writeFunction(controller, port, sizeof(float), 0, (const void*) &tmp);
printf("speed on pad\# %i, port\# %i, value %f\\n", selectedPad, port, tmp);}
xywh {408 210 38 38} box UP_BOX color 48 labelcolor 54
code0 {speed->drawLabel(true);}
code1 {speed->value( 0.5 );}
code2 {speed->defaultValue(0.5);}
class Dial
}
Fl_Box a {
label A
callback {adsr->attack( o->value() );
float tmp = o->value();
int port = int(PAD_ATTACK) + selectedPad;
padData[selectedPad].a = tmp;
writeFunction(controller, port, sizeof(float), 0, (const void*) &tmp);
printf("attack on pad\# %i, port\# %i, value %f\\n", selectedPad, port, tmp);}
xywh {358 170 30 30} box UP_BOX color 48 labelfont 1 labelcolor 54
code0 {a->defaultValue(0.0);}
class Dial
}
Fl_Box r {
label R
callback {adsr->release( o->value() );
float tmp = o->value();
int port = int(PAD_RELEASE) + selectedPad;
padData[selectedPad].r = tmp;
writeFunction(controller, port, sizeof(float), 0, (const void*) &tmp);
printf("release on pad\# %i, port\# %i, value %f\\n", selectedPad, port, tmp);}
xywh {463 170 30 30} box UP_BOX color 48 labelfont 1 labelcolor 54
code0 {r->defaultValue(0.5);}
class Dial
}
Fl_Box s {
label S
callback {adsr->sustain( o->value() );
float tmp = o->value();
int port = int(PAD_SUSTAIN) + selectedPad;
padData[selectedPad].s = tmp;
writeFunction(controller, port, sizeof(float), 0, (const void*) &tmp);
printf("sustain on pad\# %i, port\# %i, value %f\\n", selectedPad, port, tmp);}
xywh {428 170 30 30} box UP_BOX color 48 labelfont 1 labelcolor 54
code0 {extern void writeLoadSample(Fabla* self, int pad, const char* filename, size_t filename_len);}
code1 {extern void writePadPlay(Fabla* self, int pad );}
code2 {s->value(1.0);}
code3 {s->defaultValue(1.f);}
class Dial
}
Fl_Box pan {
label PAN
callback {float tmp = o->value();
int port = int(PAD_PAN) + selectedPad;
padData[selectedPad].pan = tmp;
writeFunction(controller, port, sizeof(float), 0, (const void*) &tmp);
printf("pan on pad\# %i, port\# %i, value %f\\n", selectedPad, port, tmp);}
xywh {455 210 38 38} box UP_BOX color 48 labelcolor 54
code0 {pan->drawLabel(true);}
code1 {pan->value( 0.5 );}
code2 {pan->defaultValue(0.5);}
class Dial
}
}
}
decl {Fabla* fabla;} {public local
}
Function {idle()} {open
} {
code {// takes care of handling events
Fl::check();
Fl::flush();} {}
}
Function {select_pad(int p)} {open
} {
code {switch(selectedPad + 1)
{
case 1: p1->selected(false); break;
case 2: p2->selected(false); break;
case 3: p3->selected(false); break;
case 4: p4->selected(false); break;
case 5: p5->selected(false); break;
case 6: p6->selected(false); break;
case 7: p7->selected(false); break;
case 8: p8->selected(false); break;
case 9: p9->selected(false); break;
case 10: p10->selected(false); break;
case 11: p11->selected(false); break;
case 12: p12->selected(false); break;
case 13: p13->selected(false); break;
case 14: p14->selected(false); break;
case 15: p15->selected(false); break;
case 16: p16->selected(false); break;
default: printf("unknown pad");
}
selectedPad = p;
switch(selectedPad+1)
{
case 1: p1->selected(true); break;
case 2: p2->selected(true); break;
case 3: p3->selected(true); break;
case 4: p4->selected(true); break;
case 5: p5->selected(true); break;
case 6: p6->selected(true); break;
case 7: p7->selected(true); break;
case 8: p8->selected(true); break;
case 9: p9->selected(true); break;
case 10: p10->selected(true); break;
case 11: p11->selected(true); break;
case 12: p12->selected(true); break;
case 13: p13->selected(true); break;
case 14: p14->selected(true); break;
case 15: p15->selected(true); break;
case 16: p16->selected(true); break;
default: printf("unknown pad");
}
// set dial values
gain->value( padData[selectedPad].gain );
speed->value( padData[selectedPad].speed );
pan->value( padData[selectedPad].pan );
a->value( padData[selectedPad].a );
d->value( padData[selectedPad].d );
s->value( padData[selectedPad].s );
r->value( padData[selectedPad].r );
// set ADSR values
adsr->attack ( a->value() );
adsr->decay ( d->value() );
adsr->sustain( s->value() );
adsr->release( r->value() );
// set Waveform to draw new data
if ( padData[selectedPad].loaded )
{
waveform->setData( UI_WAVEFORM_PIXELS, padData[selectedPad].waveformLength, padData[selectedPad].waveform, padData[selectedPad].name );
}
else
{
waveform->setData( 0, 0, 0, "" );
}} {}
}
decl {int selectedPad;} {public local
}
Function {pad_click(int id, int rclick)} {open
} {
code {//printf("pad %i clicked, right = %i\\n", id, rclick);
if ( rclick )
{
// pop up "load sample" dialog, write Atom event to DSP
/*
Fl_File_Chooser* fnfc = new Fl_File_Chooser( getenv("HOME"),
"Wav\\t*.wav",
0, // single file select
"Load Sample" );
fnfc->show();
printf("shown");
while( fnfc->shown() )
{
printf("waiting...");
Fl::wait();
printf("waiting 2");
}
printf("done");
const char* filename = fnfc->value();
char * filename = fl_file_chooser ("Load Sample", "Wav\\t*.wav", NULL, 0);
if ( filename )
{
printf("Loading directory: %s\\n", filename);
writeLoadSample(fabla, id, filename, strlen(filename) );
free( (void*)filename );
}
//delete fnfc;
*/
// pop up "load sample" dialog, write Atom event to DSP
Fl_Native_File_Chooser fnfc;
fnfc.title("Load Sample");
fnfc.type(Fl_Native_File_Chooser::BROWSE_FILE);
fnfc.filter("Wav\\t*.wav");
fnfc.directory( getenv("HOME") );
switch ( fnfc.show() )
{
case -1: printf("ERROR: %s\\\\n", fnfc.errmsg()); break; // ERROR
case 1: printf("CANCEL\\\\n"); break; // CANCEL
default: printf("Loading directory: %s\\\\n", fnfc.filename());
writeLoadSample(fabla, id, fnfc.filename(), strlen(fnfc.filename()));
break;
}
}
else
{
// write pad play Atom to DSP
writePadPlay( fabla, id );
// update the UI showing the ADSR / waveform of this pad
select_pad( id );
}} {}
}
decl {LV2UI_Controller controller;} {public local
}
decl {LV2UI_Write_Function writeFunction} {public local
}
decl {UIPadData padData[16];} {
comment {holds all pad individual data} public local
}
Function {close_cb(Fl_Widget* o, void*)} {open
} {
code {if ((Fl::event() == FL_KEYDOWN || Fl::event() == FL_SHORTCUT) && Fl::event_key() == FL_Escape)
{
return; // ignore ESC
}
else
{
o->hide();
}} {}
}
}