forked from polluxsynth/xtor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblofeld_params.c
1271 lines (1159 loc) · 47.7 KB
/
blofeld_params.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/****************************************************************************
* xtor - GTK based editor for MIDI synthesizers
*
* blofeld_params.c - Parameter management for Waldorf Blofeld.
*
* Copyright (C) 2014 Ricard Wanderlof <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
****************************************************************************/
#include <stdio.h>
#include <string.h>
#include "param.h"
#include "blofeld_params.h"
#include "midi.h"
#include "debug.h"
/* Blofeld patch and parameter dump sysex definitions.
* These are taken from blofeld_sysex_v1_04.txt */
#define SYSEX_ID_WALDORF 0x3E
#define EQUIPMENT_ID_BLOFELD 0x13
#define SNDR 0x00 /* Sound Request */
#define SNDD 0x10 /* Sound Dump */
#define SNDP 0x20 /* Sound Parameter Change */
#define GLBR 0x04 /* Global Request */
#define GLBD 0x14 /* Global Dump */
/* Offsets in Waldorf dumps, see sysex manual */
#define EXC 0
#define IDW 1
#define IDE 2
#define DEV 3
#define IDM 4
/* SNDP offsets */
#define LL 5
#define HH 6
#define PP 7
#define XX 8
/* SNDD offsets */
#define BB 5
#define NN 6
#define SDATA 7
/* Parameter buffers: 00..19h are banks A..Z (not all banks exist) */
#define EDIT_BUF 0x7f
struct limits {
int min;
int max;
};
/* Structure for parameter definitions */
/* Used for all parameters, including bitmapped ones */
struct blofeld_param {
const char *name;
struct limits *limits;
struct blofeld_param *child;
struct blofeld_bitmap_param *bm_param; /* NULL for ordinary parameters */
/* More to come, such as CC number, where applicable */
};
/* Extra definitions for bitmapped parameters */
struct blofeld_bitmap_param {
const char *parent_param_name; /* Name of parent; searched during init */
struct blofeld_param *parent_param; /* Pointer to parent */
int bitmask;
int bitshift;
};
/* Limit structures */
struct limits norm = { 0, 127 };
struct limits oct = { 12, 112 };
struct limits bend = { -24, 24 };
struct limits bipolar = { -64, 63 };
struct limits semitone = { -12, 12 };
struct limits keytrack = { -200, 196 };
struct limits fmsource = { 0, 11 };
struct limits modsource = { 0, 30 };
struct limits moddest = { 0, 53 };
struct limits filterdrive = { 0, 12 };
struct limits fxdrive = { 0, 11 };
struct limits fx1type = { 0, 5 };
struct limits fx2type = { 0, 8 };
struct limits lfoshape = { 0, 5 };
struct limits lfophase = { 0, 355 };
struct limits envmode = { 0, 4 };
struct limits wave = { 0, 72 };
struct limits wave3 = { 0, 4 };
struct limits onoff = { 0, 1 };
struct limits threebit = { 0, 7 };
struct limits sixbit = { 0, 63 };
struct limits modop = { 0, 7 };
struct limits arpmode = { 0, 3 };
struct limits arppat = { 0, 15 };
struct limits arpclock = { 0, 42 };
struct limits arplength = { 0, 43 };
struct limits arpoct = { 0, 9 };
struct limits arpdir = { 0, 3 };
struct limits arpsortord = { 0, 5 };
struct limits arpvel = { 0, 6 };
struct limits arpplen = { 0, 15 };
struct limits arptempo = { 40, 300 };
struct limits ascii = { 32, 127 };
struct limits category = { 0, 12 };
/* Bitmapped parameters additional structures */
struct blofeld_bitmap_param unison = { "Allocation Mode", NULL, 0x70, 4 };
struct blofeld_bitmap_param allocation = { "Allocation Mode", NULL, 0x01, 0 };
struct blofeld_bitmap_param fenvmode = { "Filter Envelope Trig+Mode", NULL, 0x07, 0 };
struct blofeld_bitmap_param fenvtrig = { "Filter Envelope Trig+Mode", NULL, 0x20, 5 };
struct blofeld_bitmap_param aenvmode = { "Amplifier Envelope Trig+Mode", NULL, 0x07, 0 };
struct blofeld_bitmap_param aenvtrig = { "Amplifier Envelope Trig+Mode", NULL, 0x20, 5 };
struct blofeld_bitmap_param env3mode = { "Envelope 3 Trig+Mode", NULL, 0x07, 0 };
struct blofeld_bitmap_param env4trig = { "Envelope 4 Trig+Mode", NULL, 0x20, 5 };
struct blofeld_bitmap_param env4mode = { "Envelope 4 Trig+Mode", NULL, 0x07, 0 };
struct blofeld_bitmap_param env3trig = { "Envelope 3 Trig+Mode", NULL, 0x20, 5 };
/* LFO speed and clock are the same parameter viewed in different ways
* depending on the Clocked parameter. Speed is normal 0..127, but clock
* is every second value, i.e. 0->0..1, 1->2..3, etc , so suitable for bitmap
* parameter.
*/
struct blofeld_bitmap_param lfo1speed = { "LFO 1 Clock+Speed", NULL, 0x7f, 0 };
struct blofeld_bitmap_param lfo1clock = { "LFO 1 Clock+Speed", NULL, 0x7e, 1 };
struct blofeld_bitmap_param lfo2speed = { "LFO 2 Clock+Speed", NULL, 0x7f, 0 };
struct blofeld_bitmap_param lfo2clock = { "LFO 2 Clock+Speed", NULL, 0x7e, 1 };
struct blofeld_bitmap_param lfo3speed = { "LFO 3 Clock+Speed", NULL, 0x7f, 0 };
struct blofeld_bitmap_param lfo3clock = { "LFO 3 Clock+Speed", NULL, 0x7e, 1 };
/* FX 2 has two parameters with different data types */
/* Damping is continuous 0..127, polarity is 0..1 */
struct blofeld_bitmap_param fx2damping = { "Effect 2 Parameter 154.", NULL, 0x7f, 0 };
struct blofeld_bitmap_param fx2polarity = { "Effect 2 Parameter 154.", NULL, 0x7f, 0 };
/* Spread is continuous -64..+63, curve is 0..11 */
struct blofeld_bitmap_param fx2spread = { "Effect 2 Parameter 155.", NULL, 0x7f, 0 };
struct blofeld_bitmap_param fx2curve = { "Effect 2 Parameter 155.", NULL, 0x7f, 0 };
#define ARP_STEP_BITMAPS(N) \
struct blofeld_bitmap_param arpstep ## N = { "Arpeggiator Pattern StGlAcc " #N, NULL, 0x70, 4 }; \
struct blofeld_bitmap_param arpglide ## N = { "Arpeggiator Pattern StGlAcc " #N, NULL, 0x08, 3 }; \
struct blofeld_bitmap_param arpacc ## N = { "Arpeggiator Pattern StGlAcc " #N, NULL, 0x07, 0 }; \
struct blofeld_bitmap_param arplen ## N = { "Arpeggiator Pattern TimLen " #N, NULL, 0x70, 4 }; \
struct blofeld_bitmap_param arptim ## N = { "Arpeggiator Pattern TimLen " #N, NULL, 0x07, 0 }
ARP_STEP_BITMAPS(1);
ARP_STEP_BITMAPS(2);
ARP_STEP_BITMAPS(3);
ARP_STEP_BITMAPS(4);
ARP_STEP_BITMAPS(5);
ARP_STEP_BITMAPS(6);
ARP_STEP_BITMAPS(7);
ARP_STEP_BITMAPS(8);
ARP_STEP_BITMAPS(9);
ARP_STEP_BITMAPS(10);
ARP_STEP_BITMAPS(11);
ARP_STEP_BITMAPS(12);
ARP_STEP_BITMAPS(13);
ARP_STEP_BITMAPS(14);
ARP_STEP_BITMAPS(15);
ARP_STEP_BITMAPS(16);
/* string parameter: bitmask == 0, bitshift == string length */
struct blofeld_bitmap_param patchname = { "Name Char 1", NULL, 0, 16 };
#define BLOFELD_PARAMS_ALL (sizeof(blofeld_params) / \
sizeof(blofeld_params[0]))
/* Some definitions for tedious parameters that occur multiple times */
#define MODIFIER(N) \
{ "Modifier " #N " Source A", &modsource, NULL, NULL }, \
{ "Modifier " #N " Source B", &modsource, NULL, NULL }, \
{ "Modifier " #N " Operation", &modop, NULL, NULL }, \
{ "Modifier " #N " Constant", &bipolar, NULL, NULL }
#define MODULATION(N) \
{ "Modulation " #N " Source", &modsource, NULL, NULL }, \
{ "Modulation " #N " Destination", &moddest, NULL, NULL }, \
{ "Modulation " #N " Amount", &bipolar, NULL, NULL } \
#define ARPSTEP(N) \
{ "Arp Step Type " #N ".", &threebit, NULL, &arpstep ## N }, \
{ "Arp Step Glide " #N ".", &onoff, NULL, &arpglide ## N }, \
{ "Arp Step Accent " #N ".", &threebit, NULL, &arpacc ## N }, \
{ "Arp Step Timing " #N ".", &threebit, NULL, &arptim ## N }, \
{ "Arp Step Length " #N ".", &threebit, NULL, &arplen ## N }
/* Names of certain parameters, for interfacing with xtor core. */
static char patch_name[] = "Patch Name";
static char device_name[] = "Device Name";
/* The Parameter Definition List */
/* Note: Owing to the design of the UI, in order to have the same parameter
* appear in more than one place, parameters who are references by the UI
* cannot have names that end with a digit,
* This is because glade suffixes widget names with numbers when copying,
* which we filter out in the main ui driver in order to have widgets
* with the same base name (i.e. without the number suffix) that control the
* same parameter.
*/
struct blofeld_param blofeld_params[] = {
/* name, limits, child, bm_param */
{ "reserved", NULL, NULL, NULL }, /* 0 */
{ "Osc 1 Octave", &oct, NULL, NULL },
{ "Osc 1 Semitone", &semitone, NULL, NULL },
{ "Osc 1 Detune", &bipolar, NULL, NULL },
{ "Osc 1 Bend Range", &bend, NULL, NULL },
{ "Osc 1 Keytrack", &keytrack, NULL, NULL },
{ "Osc 1 FM Source", &fmsource, NULL, NULL },
{ "Osc 1 FM Amount", &norm, NULL, NULL },
{ "Osc 1 Wave", &wave, NULL, NULL },
{ "Osc 1 Waveshape", &norm, NULL, NULL },
{ "Osc 1 Shape Source", &modsource, NULL, NULL },
{ "Osc 1 Shape Amount", &bipolar, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Osc 1 Limit WT", &onoff, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Osc 1 Brilliance", &norm, NULL, NULL }, /* 16 */
{ "Osc 2 Octave", &oct, NULL, NULL },
{ "Osc 2 Semitone", &semitone, NULL, NULL },
{ "Osc 2 Detune", &bipolar, NULL, NULL },
{ "Osc 2 Bend Range", &bend, NULL, NULL },
{ "Osc 2 Keytrack", &keytrack, NULL, NULL },
{ "Osc 2 FM Source", &fmsource, NULL, NULL },
{ "Osc 2 FM Amount", &norm, NULL, NULL },
{ "Osc 2 Wave", &wave, NULL, NULL },
{ "Osc 2 Waveshape", &norm, NULL, NULL },
{ "Osc 2 Shape Source", &modsource, NULL, NULL },
{ "Osc 2 Shape Amount", &bipolar, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Osc 2 Limit WT", &onoff, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Osc 2 Brilliance", &norm, NULL, NULL }, /* 32 */
{ "Osc 3 Octave", &oct, NULL, NULL },
{ "Osc 3 Semitone", &semitone, NULL, NULL },
{ "Osc 3 Detune", &bipolar, NULL, NULL },
{ "Osc 3 Bend Range", &bend, NULL, NULL },
{ "Osc 3 Keytrack", &keytrack, NULL, NULL },
{ "Osc 3 FM Source", &fmsource, NULL, NULL },
{ "Osc 3 FM Amount", &norm, NULL, NULL },
{ "Osc 3 Wave", &wave3, NULL, NULL },
{ "Osc 3 Waveshape", &norm, NULL, NULL },
{ "Osc 3 Shape Source", &modsource, NULL, NULL },
{ "Osc 3 Shape Amount", &bipolar, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Osc 3 Brilliance", &norm, NULL, NULL }, /* 48 */
{ "Osc 2 to 3 Sync", &norm, NULL, NULL },
{ "Osc Common Pitch Source", &norm, NULL, NULL },
{ "Osc Common Pitch Amount", &bipolar, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Osc Common Glide Enable", &norm, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Osc Common Glide Mode", &norm, NULL, NULL },
{ "Osc Common Glide Rate", &norm, NULL, NULL },
{ "Allocation Mode", NULL, NULL, NULL },
{ "Osc Common Unison Amount", &norm, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Osc 1 Level", &norm, NULL, NULL },
{ "Osc 1 Balance", &bipolar, NULL, NULL },
{ "Osc 2 Level", &norm, NULL, NULL },
{ "Osc 2 Balance", &bipolar, NULL, NULL },
{ "Osc 3 Level", &norm, NULL, NULL },
{ "Osc 3 Balance", &bipolar, NULL, NULL },
{ "Noise Level", &norm, NULL, NULL },
{ "Noise Balance", &bipolar, NULL, NULL },
{ "Noise Color", &bipolar, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Ringmod Level", &norm, NULL, NULL },
{ "Ringmod Balance", &bipolar, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Filter 1 Type", &norm, NULL, NULL }, /* 77 */
{ "Filter 1 Cutoff", &norm, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Filter 1 Resonance", &norm, NULL, NULL },
{ "Filter 1 Drive", &norm, NULL, NULL },
{ "Filter 1 Drive Curve", &filterdrive, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Filter 1 Keytrack", &keytrack, NULL, NULL },
{ "Filter 1 Env Amount", &bipolar, NULL, NULL },
{ "Filter 1 Env Velocity", &bipolar, NULL, NULL },
{ "Filter 1 Mod Source", &norm, NULL, NULL },
{ "Filter 1 Mod Amount", &bipolar, NULL, NULL },
{ "Filter 1 FM Source", &fmsource, NULL, NULL },
{ "Filter 1 FM Amount", &norm, NULL, NULL },
{ "Filter 1 Pan", &bipolar, NULL, NULL },
{ "Filter 1 Pan Source", &norm, NULL, NULL },
{ "Filter 1 Pan Amount", &bipolar, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Filter 2 Type", &norm, NULL, NULL }, /* 97 */
{ "Filter 2 Cutoff", &norm, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Filter 2 Resonance", &norm, NULL, NULL },
{ "Filter 2 Drive", &norm, NULL, NULL },
{ "Filter 2 Drive Curve", &filterdrive, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Filter 2 Keytrack", &keytrack, NULL, NULL },
{ "Filter 2 Env Amount", &bipolar, NULL, NULL },
{ "Filter 2 Env Velocity", &bipolar, NULL, NULL },
{ "Filter 2 Mod Source", &norm, NULL, NULL },
{ "Filter 2 Mod Amount", &bipolar, NULL, NULL },
{ "Filter 2 FM Source", &fmsource, NULL, NULL },
{ "Filter 2 FM Amount", &norm, NULL, NULL },
{ "Filter 2 Pan", &bipolar, NULL, NULL },
{ "Filter 2 Pan Source", &norm, NULL, NULL },
{ "Filter 2 Pan Amount", &bipolar, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Filter Routing", &onoff, NULL, NULL }, /* 117 */
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Amplifier Volume", &norm, NULL, NULL }, /* 121 */
{ "Amplifier Velocity", &bipolar, NULL, NULL },
{ "Amplifier Mod Source", &norm, NULL, NULL },
{ "Amplifier Mod Amount", &bipolar, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Effect 1 Type", &fx1type, NULL, NULL }, /* 128 */
{ "Effect 1 Mix", &norm, NULL, NULL },
{ "Effect 1 Parameter 130.", &norm, NULL, NULL },
{ "Effect 1 Parameter 131.", &norm, NULL, NULL },
{ "Effect 1 Parameter 132.", &norm, NULL, NULL },
{ "Effect 1 Parameter 133.", &norm, NULL, NULL },
{ "Effect 1 Parameter 134.", &norm, NULL, NULL },
{ "Effect 1 Parameter 135.", &norm, NULL, NULL },
{ "Effect 1 Parameter 136.", &norm, NULL, NULL },
{ "Effect 1 Parameter 137.", &norm, NULL, NULL },
{ "Effect 1 Parameter 138.", &onoff, NULL, NULL },
{ "Effect 1 Parameter 139.", &fxdrive, NULL, NULL },
{ "Effect 1 Parameter 140.", &norm, NULL, NULL },
{ "Effect 1 Parameter 141.", &norm, NULL, NULL },
{ "Effect 1 Parameter 142.", &norm, NULL, NULL },
{ "Effect 1 Parameter 143.", &norm, NULL, NULL },
{ "Effect 2 Type", &fx2type, NULL, NULL }, /* 144 */
{ "Effect 2 Mix", &norm, NULL, NULL },
{ "Effect 2 Parameter 146.", &norm, NULL, NULL },
{ "Effect 2 Parameter 147.", &norm, NULL, NULL },
{ "Effect 2 Parameter 148.", &norm, NULL, NULL },
{ "Effect 2 Parameter 149.", &norm, NULL, NULL },
{ "Effect 2 Parameter 150.", &norm, NULL, NULL },
{ "Effect 2 Parameter 151.", &norm, NULL, NULL },
{ "Effect 2 Parameter 152.", &norm, NULL, NULL },
{ "Effect 2 Parameter 153.", &norm, NULL, NULL },
{ "Effect 2 Parameter 154.", &onoff, NULL, NULL },
{ "Effect 2 Parameter 155.", &fxdrive, NULL, NULL },
{ "Effect 2 Parameter 156.", &norm, NULL, NULL },
{ "Effect 2 Parameter 157.", &norm, NULL, NULL },
{ "Effect 2 Parameter 158.", &norm, NULL, NULL },
{ "Effect 2 Parameter 159.", &norm, NULL, NULL },
{ "LFO 1 Shape", &lfoshape, NULL, NULL }, /* 160 */
{ "LFO 1 Clock+Speed", &norm, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "LFO 1 Sync", &onoff, NULL, NULL },
{ "LFO 1 Clocked", &onoff, NULL, NULL },
{ "LFO 1 Phase", &lfophase, NULL, NULL },
{ "LFO 1 Delay", &norm, NULL, NULL },
{ "LFO 1 Fade", &bipolar, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "LFO 1 Keytrack", &keytrack, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "LFO 2 Shape", &lfoshape, NULL, NULL }, /* 172 */
{ "LFO 2 Clock+Speed", &norm, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "LFO 2 Sync", &onoff, NULL, NULL },
{ "LFO 2 Clocked", &onoff, NULL, NULL },
{ "LFO 2 Phase", &lfophase, NULL, NULL },
{ "LFO 2 Delay", &norm, NULL, NULL },
{ "LFO 2 Fade", &bipolar, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "LFO 2 Keytrack", &keytrack, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "LFO 3 Shape", &lfoshape, NULL, NULL }, /* 184 */
{ "LFO 3 Clock+Speed", &norm, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "LFO 3 Sync", &onoff, NULL, NULL },
{ "LFO 3 Clocked", &onoff, NULL, NULL },
{ "LFO 3 Phase", &lfophase, NULL, NULL },
{ "LFO 3 Delay", &norm, NULL, NULL },
{ "LFO 3 Fade", &bipolar, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "LFO 3 Keytrack", &keytrack, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Filter Envelope Trig+Mode", &envmode, NULL, NULL }, /* 196 */
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Filter Envelope Attack", &norm, NULL, NULL },
{ "Filter Envelope Attack Level", &norm, NULL, NULL },
{ "Filter Envelope Decay", &norm, NULL, NULL },
{ "Filter Envelope Sustain", &norm, NULL, NULL },
{ "Filter Envelope Decay Two", &norm, NULL, NULL },
{ "Filter Envelope Sustain Two", &norm, NULL, NULL },
{ "Filter Envelope Release", &norm, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Amplifier Envelope Trig+Mode", &envmode, NULL, NULL }, /* 208 */
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Amplifier Envelope Attack", &norm, NULL, NULL },
{ "Amplifier Envelope Attack Level", &norm, NULL, NULL },
{ "Amplifier Envelope Decay", &norm, NULL, NULL },
{ "Amplifier Envelope Sustain", &norm, NULL, NULL },
{ "Amplifier Envelope Decay Two", &norm, NULL, NULL },
{ "Amplifier Envelope Sustain Two", &norm, NULL, NULL },
{ "Amplifier Envelope Release", &norm, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Envelope 3 Trig+Mode", &envmode, NULL, NULL }, /* 220 */
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Envelope 3 Attack", &norm, NULL, NULL },
{ "Envelope 3 Attack Level", &norm, NULL, NULL },
{ "Envelope 3 Decay", &norm, NULL, NULL },
{ "Envelope 3 Sustain", &norm, NULL, NULL },
{ "Envelope 3 Decay Two", &norm, NULL, NULL },
{ "Envelope 3 Sustain Two", &norm, NULL, NULL },
{ "Envelope 3 Release", &norm, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Envelope 4 Trig+Mode", &envmode, NULL, NULL }, /* 232 */
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Envelope 4 Attack", &norm, NULL, NULL },
{ "Envelope 4 Attack Level", &norm, NULL, NULL },
{ "Envelope 4 Decay", &norm, NULL, NULL },
{ "Envelope 4 Sustain", &norm, NULL, NULL },
{ "Envelope 4 Decay Two", &norm, NULL, NULL },
{ "Envelope 4 Sustain Two", &norm, NULL, NULL },
{ "Envelope 4 Release", &norm, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
MODIFIER(1), /* 245 */
MODIFIER(2),
MODIFIER(3),
MODIFIER(4),
MODULATION(1), /* 261 */
MODULATION(2),
MODULATION(3),
MODULATION(4),
MODULATION(5),
MODULATION(6),
MODULATION(7),
MODULATION(8),
MODULATION(9),
MODULATION(10),
MODULATION(11),
MODULATION(12),
MODULATION(13),
MODULATION(14),
MODULATION(15),
MODULATION(16),
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Arpeggiator Mode", &arpmode, NULL, NULL }, /* 311 */
{ "Arpeggiator Pattern", &arppat, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Arpeggiator Clock", &arpclock, NULL, NULL },
{ "Arpeggiator Length", &arplength, NULL, NULL },
{ "Arpeggiator Octave", &arpoct, NULL, NULL },
{ "Arpeggiator Direction", &arpdir, NULL, NULL },
{ "Arpeggiator Sort Order", &arpsortord, NULL, NULL },
{ "Arpeggiator Arp Velocity", &arpvel, NULL, NULL },
{ "Arpeggiator Timing Factor", &norm, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Arpeggiator Ptn Reset", &onoff, NULL, NULL },
{ "Arpeggiator Ptn Length", &arpplen, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Arpeggiator Tempo", &arptempo, NULL, NULL },
{ "Arpeggiator Pattern StGlAcc 1", NULL, NULL, NULL }, /* 327 */
{ "Arpeggiator Pattern StGlAcc 2", NULL, NULL, NULL },
{ "Arpeggiator Pattern StGlAcc 3", NULL, NULL, NULL },
{ "Arpeggiator Pattern StGlAcc 4", NULL, NULL, NULL },
{ "Arpeggiator Pattern StGlAcc 5", NULL, NULL, NULL },
{ "Arpeggiator Pattern StGlAcc 6", NULL, NULL, NULL },
{ "Arpeggiator Pattern StGlAcc 7", NULL, NULL, NULL },
{ "Arpeggiator Pattern StGlAcc 8", NULL, NULL, NULL },
{ "Arpeggiator Pattern StGlAcc 9", NULL, NULL, NULL },
{ "Arpeggiator Pattern StGlAcc 10", NULL, NULL, NULL },
{ "Arpeggiator Pattern StGlAcc 11", NULL, NULL, NULL },
{ "Arpeggiator Pattern StGlAcc 12", NULL, NULL, NULL },
{ "Arpeggiator Pattern StGlAcc 13", NULL, NULL, NULL },
{ "Arpeggiator Pattern StGlAcc 14", NULL, NULL, NULL },
{ "Arpeggiator Pattern StGlAcc 15", NULL, NULL, NULL },
{ "Arpeggiator Pattern StGlAcc 16", NULL, NULL, NULL },
{ "Arpeggiator Pattern TimLen 1", NULL, NULL, NULL }, /* 343 */
{ "Arpeggiator Pattern TimLen 2", NULL, NULL, NULL },
{ "Arpeggiator Pattern TimLen 3", NULL, NULL, NULL },
{ "Arpeggiator Pattern TimLen 4", NULL, NULL, NULL },
{ "Arpeggiator Pattern TimLen 5", NULL, NULL, NULL },
{ "Arpeggiator Pattern TimLen 6", NULL, NULL, NULL },
{ "Arpeggiator Pattern TimLen 7", NULL, NULL, NULL },
{ "Arpeggiator Pattern TimLen 8", NULL, NULL, NULL },
{ "Arpeggiator Pattern TimLen 9", NULL, NULL, NULL },
{ "Arpeggiator Pattern TimLen 10", NULL, NULL, NULL },
{ "Arpeggiator Pattern TimLen 11", NULL, NULL, NULL },
{ "Arpeggiator Pattern TimLen 12", NULL, NULL, NULL },
{ "Arpeggiator Pattern TimLen 13", NULL, NULL, NULL },
{ "Arpeggiator Pattern TimLen 14", NULL, NULL, NULL },
{ "Arpeggiator Pattern TimLen 15", NULL, NULL, NULL },
{ "Arpeggiator Pattern TimLen 16", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL }, /* 359 */
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "Name Char 1", &ascii, NULL, NULL },
{ "Name Char 2", &ascii, NULL, NULL },
{ "Name Char 3", &ascii, NULL, NULL },
{ "Name Char 4", &ascii, NULL, NULL },
{ "Name Char 5", &ascii, NULL, NULL },
{ "Name Char 6", &ascii, NULL, NULL },
{ "Name Char 7", &ascii, NULL, NULL },
{ "Name Char 8", &ascii, NULL, NULL },
{ "Name Char 9", &ascii, NULL, NULL },
{ "Name Char 10", &ascii, NULL, NULL },
{ "Name Char 11", &ascii, NULL, NULL },
{ "Name Char 12", &ascii, NULL, NULL },
{ "Name Char 13", &ascii, NULL, NULL },
{ "Name Char 14", &ascii, NULL, NULL },
{ "Name Char 15", &ascii, NULL, NULL },
{ "Name Char 16", &ascii, NULL, NULL },
{ "Category", &category, NULL, NULL }, /* 379 */
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL },
{ "reserved", NULL, NULL, NULL }, /* 382 */
/* Bitmap parameters. Originally devised for parameters which had
* bitfields, so that several 'bitmap parameters' would have the same
* parent parameter, but referencing different bitfields in the parent.
* (Note that the implementation allows for overlapping bitfields as well).
* However, the term 'Bitmap parameters' now also includes parameters
* which have multiple parents and one single child, which in our case
* is the patch name (only). */
{ "Osc Common Unison Mode", &threebit, NULL, &unison },
{ "Osc Common Allocation", &onoff, NULL, &allocation },
{ "Filter Envelope Mode", &envmode, NULL, &fenvmode },
{ "Filter Envelope Trig", &onoff, NULL, &fenvtrig },
{ "Amplifier Envelope Mode", &envmode, NULL, &aenvmode },
{ "Amplifier Envelope Trig", &onoff, NULL, &aenvtrig },
{ "Envelope 3 Mode", &envmode, NULL, &env3mode },
{ "Envelope 3 Trig", &onoff, NULL, &env3trig },
{ "Envelope 4 Mode", &envmode, NULL, &env4mode },
{ "Envelope 4 Trig", &onoff, NULL, &env4trig },
{ "LFO 1 Speed", &norm, NULL, &lfo1speed },
{ "LFO 1 Clock", &sixbit, NULL, &lfo1clock },
{ "LFO 2 Speed", &norm, NULL, &lfo2speed },
{ "LFO 2 Clock", &sixbit, NULL, &lfo2clock },
{ "LFO 3 Speed", &norm, NULL, &lfo3speed },
{ "LFO 3 Clock", &sixbit, NULL, &lfo3clock },
ARPSTEP(1),
ARPSTEP(2),
ARPSTEP(3),
ARPSTEP(4),
ARPSTEP(5),
ARPSTEP(6),
ARPSTEP(7),
ARPSTEP(8),
ARPSTEP(9),
ARPSTEP(10),
ARPSTEP(11),
ARPSTEP(12),
ARPSTEP(13),
ARPSTEP(14),
ARPSTEP(15),
ARPSTEP(16),
{ "Effect 2 Spread", &bipolar, NULL, &fx2spread },
{ "Effect 2 Curve", &filterdrive, NULL, &fx2curve },
{ "Effect 2 Damping", &norm, NULL, &fx2damping },
{ "Effect 2 Polarity", &onoff, NULL, &fx2polarity },
/* Not really a bit field, but needs special treatment, so we include it in
* the group. */
{ patch_name, NULL, NULL, &patchname },
/* End of list marker. Do not remove. */
{ "", NULL, NULL, NULL }
};
/* These are the parameter values for all parameters, i.e. our Edit Buffer */
int parameter_list[BLOFELD_PARAMS];
/* We have one global paste buffer, and one for the arpeggiator */
#define PASTE_BUFFERS 2
int paste_buffer[PASTE_BUFFERS][BLOFELD_PARAMS];
/* Sysex device number */
int device_number = 0;
/* Callback and parameter for parameter updates */
notify_cb notify_ui = NULL;
void *notify_ref;
/* Fint index in parameter list of parameter with a given name. */
/* Used locally and also from xtor core during startup to find
* parameters corresponding to parameter widgets. */
/* Not referenced directly, but via struct, hence 'static' */
static int
blofeld_find_index(const char *param_name)
{
int idx = -1; /* not found */
int i;
if (!param_name) return idx;
for (i = 0; i < BLOFELD_PARAMS_ALL; i++) {
if (!strcmp(blofeld_params[i].name, param_name)) {
idx = i;
break;
}
}
return idx;
}
/* Get min, max and step sizes for parameter. Used by xtor core
* during setup. */
/* Not referenced directly, but via struct, hence 'static' */
int
blofeld_get_param_properties(int param_num,
struct param_properties *props)
{
if (param_num < BLOFELD_PARAMS_ALL && props) {
props->ui_min = blofeld_params[param_num].limits->min;
props->ui_max = blofeld_params[param_num].limits->max;
/* set sane values for step size */
int range = props->ui_max + 1 - props->ui_min;
props->ui_step = (range / 128 > 1) ? 1 : 1;
return 0;
}
return -1;
}
/* Checksum routine, algorithm according to Waldorf. */
static int
midi_csum(const unsigned char *buf, int bytes)
{
int c = 0;
while (bytes--)
c += *buf++;
return (c & 127);
}
/* Send patch dump request to Blofeld. We hope to get an answer, but won't
* hold our breath (i.e. we process the sound dump when it arrives
* and don't hang around here waiting for it). */
void
blofeld_get_dump(int buf_no, int devno)
{
unsigned char sndr[] = { SYSEX,
SYSEX_ID_WALDORF,
EQUIPMENT_ID_BLOFELD,
devno, /* device number */
SNDR,
EDIT_BUF,
buf_no,
EOX };
midi_send_sysex(SYNTH_PORT, sndr, sizeof(sndr));
}
/* Patch dump routine for sending to synth.
* Used as send_func_sender parameter in call to blofeld_xfer_dump. */
static int
midi_send(char *buf, int size, int userdata)
{
midi_send_sysex(SYNTH_PORT, buf, size);
return 0;
}
/* Send patch dump to Blofeld or file, depending on send_func sender */
/* By using a function as parameter rather than returning a buffer and let
* the caller do it, we can have the send buffer on the stack, rather
* than allocate it and hope the caller remembers to free it, or have it
* statically allocated. Yeah, really important...but we got to have a bit
* of fun. */
int
blofeld_xfer_dump(int buf_no, int dev_no, send_func sender, int userdata)
{
unsigned char sndd[BLOFELD_PARAMS + 9] = { SYSEX,
SYSEX_ID_WALDORF,
EQUIPMENT_ID_BLOFELD,
dev_no,
SNDD,
EDIT_BUF,
buf_no };
int parno;
for (parno = 0; parno < BLOFELD_PARAMS; parno++)
sndd[SDATA + parno] = parameter_list[parno];
sndd[SDATA + BLOFELD_PARAMS] = midi_csum(&sndd[SDATA], BLOFELD_PARAMS);
sndd[SDATA + BLOFELD_PARAMS + 1] = EOX;
return sender(sndd, sizeof(sndd), userdata);
}
/* Send patch dump to Blofeld. Used when user presses Send button in UI. */
void
blofeld_send_dump(int buf_no, int dev_no)
{
blofeld_xfer_dump(buf_no, dev_no, midi_send, 0);
}
/* Send single parameter value to Blofeld. */
static
void send_parameter_update(int parnum, int buf_no, int devno, int value)
{
unsigned char sndp[] = { SYSEX,
SYSEX_ID_WALDORF,
EQUIPMENT_ID_BLOFELD,
devno, /* device number */
SNDP,
buf_no,
parnum >> 7, parnum & 127, /* big endian */
value,
EOX };
dprintf("Blofeld update param: parnum %d, buf %d, value %d\n",
parnum, buf_no, value);
if (parnum < BLOFELD_PARAMS)
midi_send_sysex(SYNTH_PORT, sndp, sizeof(sndp));
}
/* Prototype for forward declaration */
static void update_ui_int_param_children(struct blofeld_param *param,
struct blofeld_param *excepted_child,
int buf_no, int value, int mask);
/* Convert UI representation of value to MIDI parameter value */
static int
ui_to_param_value(struct blofeld_param *param, int value)
{
int min = param->limits->min;
int max = param->limits->max;
int range = max + 1 - min;
if (min == -200) /* keytrack */
value = (value + 202) * 64 / 200; /* empirically verified against Blofeld */
else if (max == 300) { /* arp tempo */
/* empirically verified against Blofeld. */
/* See param_value_to_ui for algorithm. */
if (value > 165)
value = value / 5 + 67;
else if (value > 90)
value = value - 65;
else
value = (value - 40) / 2;
} else if (min < 0) /* bipolar parameter */
value += 64; /* center around mid range (64) */
else if (min == 12) /* octave */
value = 12 * value + 16; /* coding for octave parameters */
return value;
}
/* Update numeric (integer) parameter and send to Blofeld */
static void
update_int_param(struct blofeld_param *param,
int parnum, int buf_no, int value)
{
int parval = ui_to_param_value(param, value);
/* If bitmap param, fetch parent, then update value */
if (param->bm_param) {
struct blofeld_param *parent = param->bm_param->parent_param;
if (parent == NULL) {
eprintf("Warning: bitmap parameter %s has no parent!\n", param->name);
return;
}
parnum = parent - blofeld_params;
int mask = param->bm_param->bitmask;
int shift = param->bm_param->bitshift;
/* mask out non-changed bits, then or with new value */
parval = (parameter_list[parnum] & ~mask) | (parval << shift);
/* Update UI for all children that have a bitmask that overlaps,
* (skipping the one we've just received the update for) */
/* This happens for for instance LFO Speed vs Clock */
update_ui_int_param_children(parent, param, buf_no, parval, mask);
}
/* Update parameter list, then send to Blofeld */
parameter_list[parnum] = parval;
send_parameter_update(parnum, buf_no, 0, parval);
}
/* Update string parameter and send to Blofeld */
static void
update_str_param(struct blofeld_param *param, int parnum,
int buf_no, const unsigned char *string)
{
/* String parameters must be 'bitmap' parameters, and bitmask must be == 0 */
if (!param->bm_param || param->bm_param->bitmask)
return;
struct blofeld_param *parent = param->bm_param->parent_param;
if (parent == NULL) {
eprintf("Warning: bitmap/string parameter %s has no parent!\n", param->name);
return;
}
parnum = parent - blofeld_params; /* param no of first char of parent */
/* Now update each char parameter in the param list, then
* send it on to Blofeld. */
int len = param->bm_param->bitshift; /* we use bitshift field as (max) len */
while (len--) {
/* If we run out of the end of the string, the rest of the chars are ' ' */
/* So once we hit \0, stay there, otherwise move on. */
unsigned char ch = (*string) ? (*string++) : ' ';
/* To minimize amount of data to be sent, only update the parameters that
* are changed. Otherwise, we send the whole string each time a single
* character is updated. We could do this for ordinary parameters too,
* but the gain would be much less. */
if (parameter_list[parnum] != ch) {
parameter_list[parnum] = ch;
send_parameter_update(parnum, buf_no, 0, ch);
}
parnum++;
}
}
/* called from UI when parameter updated */
/* Not referenced directly, but via struct, hence 'static' */
static void
blofeld_update_param(int parnum, int buf_no, const void *valptr)
{
if (parnum >= BLOFELD_PARAMS_ALL || !valptr) /* sanity check */
return;
struct blofeld_param *param = &blofeld_params[parnum];
if (param->limits) /* string parameters have limits set to NULL */
update_int_param(param, parnum, buf_no, *(const int *)valptr);
else
update_str_param(param, parnum, buf_no, valptr);
}
/* Convert parameter value to UI representation of value */
static int
param_value_to_ui(struct blofeld_param *param, int value)
{
int min = param->limits->min;
int max = param->limits->max;
if (min == -200) /* keytrack */
value = value * 200 / 64 - 200; /* empirically verified against Blofeld */
else if (max == 300) {/* arp tempo */
/* empirically verified against Blofeld */
if (value <= 25)
/* 0..25 map to 40..90 BPM in steps of 2 */
value = value * 2 + 40;
else if (value <= 100)
/* 26..100 map to 91..165 in steps of 1 */
value = value + 65;
else
/* 101..127 map to 170..400 in steps of 5 */
value = (value - 67) * 5;
} else if (min < 0)
value -= 64;
else if (min == 12) /* octave */
value = (value - 16 ) / 12;
return value;
}
/* Update integer parameter in UI. (I.e. all parameters except patch name.) */
static void
update_ui_int_param(struct blofeld_param *param, int buf_no, int parval)
{
int parnum = param - blofeld_params;
int value = param_value_to_ui(param, parval);
if (notify_ui) notify_ui(parnum, buf_no, &value, notify_ref);
}
/* Update string parameter in UI. (Only one we have is patch name.) */
static void
update_ui_str_param(struct blofeld_param *param, int buf_no)
{
/* here we assume the caller has validated that we are a bm/str parameter */
int len = param->bm_param->bitshift;
unsigned char string[len + 1];
int parnum = param - blofeld_params;
int parent_parnum = param->bm_param->parent_param - blofeld_params;
int i;
for (i = 0; i < len; i++)
string[i] = (unsigned char) parameter_list[parent_parnum + i];
string[len] = '\0';
if (notify_ui) notify_ui(parnum, buf_no, string, notify_ref);
}
/* update the ui for all children of the supplied param but only if the
* bitmask overlaps with the supplied mask. */
static void
update_ui_int_param_children(struct blofeld_param *param,
struct blofeld_param *excepted_child,
int buf_no, int value, int mask)
{
struct blofeld_param *child = param->child;
if (!child) return; /* We shouldn't be called in this case, but .. */
dprintf("Updating ui for children of %s, mask %d\n", param->name, mask);
/* Children of same parent are always grouped together. Parent points
* to first child, so we just keep examining children until we find one
* with a different parent.
*/
do {
int bitmask = child->bm_param->bitmask;
int bitshift = child->bm_param->bitshift;
if ((bitmask & mask) && child != excepted_child) {
dprintf("Updating child %s: bitmask %d mask %d\n",
param->name, bitmask, mask);
update_ui_int_param(child, buf_no, (value & bitmask) >> bitshift);
}
child++;
} while (child->bm_param && child->bm_param->parent_param == param);
}
/* called from MIDI (or paste buf) when parameter updated */
static void
update_ui(int parnum, int buf_no, int value)
{
if (parnum >= BLOFELD_PARAMS) /* sanity check */
return;
struct blofeld_param *param = &blofeld_params[parnum];
dprintf("Blofeld update ui: parno %d, buf %d, value %d\n",
parnum, buf_no, value);
parameter_list[parnum] = value;
if (!param->child) { /* no children => ordinary parameter ... */
if (param->limits) /* ... unless it has no limits, then it's 'reserved' */
update_ui_int_param(param, buf_no, value);
return;
}
struct blofeld_param *child = param->child;
if (!child->bm_param->bitmask) { /* string parameter */
update_ui_str_param(child, buf_no);
return;
}
/* bitmapped parameter */
/* update all the children */
update_ui_int_param_children(param, NULL, buf_no, value, 0x7f);
}
/* Update all parameter values in UI when sound dump received. */
static void
update_ui_all(unsigned char *param_buf, int buf_no)
{
int parnum;
static int force = 1; /* force complete update first time called */
for (parnum = 0; parnum < BLOFELD_PARAMS; parnum++) {
/* Only send UI updates for parameters that differ */
if (param_buf[parnum] != parameter_list[parnum] || force) {
update_ui(parnum, buf_no, param_buf[parnum]);
}
}
force = 0;
}
/* Cap a value at min and max limits */
#define CAP(value, min, max) \
if (value < (min)) value = (min); else if (value > (max)) value = (max)
/* Send parameter update to Blofeld when value changed in UI. */