@@ -369,131 +369,120 @@ void ofPooks::renderWarpTool(int screenNumber) {
369
369
370
370
}
371
371
372
- void ofPooks::newMidiMessage (ofxMidiMessage& eventArgs ) {
372
+ void ofPooks::newMidiMessage (ofxMidiMessage& midiMsg ) {
373
373
374
- // store some data from midi message in variables
375
- value = eventArgs .control ;
376
- value2 = eventArgs .value ;
377
- id = eventArgs .channel ;
374
+ // store some data from midi message in variables
375
+ control = midiMsg .control ;
376
+ value = midiMsg .value ;
377
+ channel = midiMsg .channel ;
378
378
379
- sprintf (msg, " value: (%i,%i), received from port: %i, id: %i \n\n with %f milliseconds difference from last message" ,value,value2,port,id,timestamp);
380
- ofLog (OF_LOG_NOTICE, " %s" , msg);
381
379
382
- float normValue2 = value2 / 16384 .0f ;
383
- if (id == 1 && value == 7 ) {
380
+ sprintf (msg, " value: (%i,%i), received from port: %i, id: %i \n\n with %f milliseconds difference from last message" ,control,value,port,channel,timestamp);
381
+ ofLog (OF_LOG_NOTICE, " %s" , msg);
382
+
383
+ float normValue2 = value / 127 .0f ;
384
+ if (control == 0 ) {
384
385
int newSampleIndex = normValue2 * (samples.size () - 1 );
385
386
selectSampleIndex (newSampleIndex);
386
- } else if (id == 2 && value == 7 ) {
387
- for (int j=0 ; j<MAX_SCREENS;j++) {
388
- if (screenSettings[j].canEdit ) {
389
- for (int i=0 ; i< MAX_LAYERS; i++) {
390
- if (screenLayerSettings[j][i].canEdit ) {
391
- screenLayerSettings[j][i].complexity = normValue2;
392
- }
393
- }
394
- }
395
- }
396
- } else if (id == 3 && value == 7 ) {
397
- for (int j=0 ; j<MAX_SCREENS;j++) {
398
- if (screenSettings[j].canEdit ) {
399
- for (int i=0 ; i< MAX_LAYERS; i++) {
400
- if (screenLayerSettings[j][i].canEdit ) {
401
- screenLayerSettings[j][i].selectedLayoutIndex = normValue2 * (MAX_LAYOUTS-1 );
402
- }
403
- }
404
- }
405
- }
406
- } else if (id == 4 && value == 7 ) {
407
- for (int j=0 ; j<MAX_SCREENS;j++) {
408
- if (screenSettings[j].canEdit ) {
409
- for (int i=0 ; i< MAX_LAYERS; i++) {
410
- if (screenLayerSettings[j][i].canEdit ) {
411
- screenLayerSettings[j][i].luminance = normValue2;
412
- }
413
- }
414
- }
387
+ } else if (control == 1 ) {
388
+ for (int j=0 ; j<MAX_SCREENS;j++) {
389
+ if (screenSettings[j].canEdit ) {
390
+ for (int i=0 ; i< MAX_LAYERS; i++) {
391
+ if (screenLayerSettings[j][i].canEdit ) {
392
+ screenLayerSettings[j][i].complexity = normValue2;
393
+ }
415
394
}
416
- } else if (id == 5 && value == 7 ) {
417
- for ( int j= 0 ; j<MAX_SCREENS;j++) {
418
- if (screenSettings[j]. canEdit ) {
419
- for (int i =0 ; i< MAX_LAYERS; i ++) {
420
- if (screenLayerSettings[j][i ].canEdit ) {
421
- screenLayerSettings[j][i]. alpha = normValue2;
422
- }
423
- }
424
- }
395
+ }
396
+ }
397
+ } else if (control == 2 ) {
398
+ for (int j =0 ; j<MAX_SCREENS;j ++) {
399
+ if (screenSettings[j ].canEdit ) {
400
+ for ( int i= 0 ; i< MAX_LAYERS; i++) {
401
+ if (screenLayerSettings[j][i]. canEdit ) {
402
+ screenLayerSettings[j][i]. selectedLayoutIndex = normValue2 * (MAX_LAYOUTS- 1 );
403
+ }
425
404
}
426
- } else if (id == 6 && value == 7 ) {
427
- int index = normValue2 * (colorChannels.size () - 1 );
428
- for (int j=0 ; j<MAX_SCREENS;j++) {
429
- if (screenSettings[j].canEdit ) {
430
- for (int i=0 ; i< MAX_LAYERS; i++) {
431
- if (screenLayerSettings[j][i].canEdit ) {
432
- screenLayerSettings[j][i].selectedColorIndex = index;
433
- }
434
- }
435
- }
405
+ }
406
+ }
407
+ } else if (control == 3 ) {
408
+ for (int j=0 ; j<MAX_SCREENS;j++) {
409
+ if (screenSettings[j].canEdit ) {
410
+ for (int i=0 ; i< MAX_LAYERS; i++) {
411
+ if (screenLayerSettings[j][i].canEdit ) {
412
+ screenLayerSettings[j][i].luminance = normValue2;
413
+ }
436
414
}
437
- } else if (id == 7 && value == 7 ) {
438
- for ( int j= 0 ; j<MAX_SCREENS;j++) {
439
- if (screenSettings[j]. canEdit ) {
440
- for (int i =0 ; i< MAX_LAYERS; i ++) {
441
- if (screenLayerSettings[j][i ].canEdit ) {
442
- screenLayerSettings[j][i]. speed = normValue2;
443
- }
444
- }
445
- }
415
+ }
416
+ }
417
+ } else if (control == 4 ) {
418
+ for (int j =0 ; j<MAX_SCREENS;j ++) {
419
+ if (screenSettings[j ].canEdit ) {
420
+ for ( int i= 0 ; i< MAX_LAYERS; i++) {
421
+ if (screenLayerSettings[j][i]. canEdit ) {
422
+ screenLayerSettings[j][i]. alpha = normValue2;
423
+ }
446
424
}
447
- } else if (id == 8 && value == 7 ) {
448
- for (int j=0 ; j<MAX_SCREENS;j++) {
449
- if (screenSettings[j].canEdit ) {
450
- for (int i=0 ; i< MAX_LAYERS; i++) {
451
- if (screenLayerSettings[j][i].canEdit ) {
452
- screenLayerSettings[j][i].layoutSpeed = normValue2;
453
- }
454
- }
455
- }
425
+ }
426
+ }
427
+ } else if (control == 5 ) {
428
+ int index = normValue2 * (colorChannels.size () - 1 );
429
+ for (int j=0 ; j<MAX_SCREENS;j++) {
430
+ if (screenSettings[j].canEdit ) {
431
+ for (int i=0 ; i< MAX_LAYERS; i++) {
432
+ if (screenLayerSettings[j][i].canEdit ) {
433
+ screenLayerSettings[j][i].selectedColorIndex = index;
434
+ }
456
435
}
457
- } else if (id == 1 ) {
458
- if (value == 47 ) {
459
- screenSettings[0 ].canEdit = normValue2 == 1.0 ;
460
- } else if (value == 45 ) {
461
- screenSettings[1 ].canEdit = normValue2 == 1.0 ;
462
- } else if (value == 48 ) {
463
- screenSettings[2 ].canEdit = normValue2 == 1.0 ;
464
- } else if (value == 49 ) {
465
- screenSettings[3 ].canEdit = normValue2 == 1.0 ;
466
- } else if (value == 46 ) {
467
- screenSettings[4 ].canEdit = normValue2 == 1.0 ;
468
- } else if (value == 44 ) {
469
- screenSettings[5 ].canEdit = normValue2 == 1.0 ;
436
+ }
437
+ }
438
+ } else if (control == 6 ) {
439
+ for (int j=0 ; j<MAX_SCREENS;j++) {
440
+ if (screenSettings[j].canEdit ) {
441
+ for (int i=0 ; i< MAX_LAYERS; i++) {
442
+ if (screenLayerSettings[j][i].canEdit ) {
443
+ screenLayerSettings[j][i].speed = normValue2;
444
+ }
470
445
}
471
-
446
+ }
472
447
}
473
-
474
- if (value == 10 ) {
475
- if (id > 0 && id <= MAX_SCREENS ) {
476
- if (screenSettings[id- 1 ]. canEdit ) {
477
- screenSettings[id- 1 ]. alpha = normValue2;
478
- }
479
- } else if (id == 9 ) {
480
- masterAlpha = normValue2;
481
- masterVolume = normValue2;
448
+ } else if (control == 7 ) {
449
+ for ( int j= 0 ; j<MAX_SCREENS;j++ ) {
450
+ if (screenSettings[j]. canEdit ) {
451
+ for ( int i= 0 ; i< MAX_LAYERS; i++ ) {
452
+ if (screenLayerSettings[j][i]. canEdit ) {
453
+ screenLayerSettings[j][i]. layoutSpeed = normValue2;
454
+ }
455
+ }
456
+ }
482
457
}
458
+ } else if (control == 32 ) {
459
+ screenSettings[0 ].canEdit = normValue2 == 1 .0f ;
460
+ } else if (control == 33 ) {
461
+ screenSettings[1 ].canEdit = normValue2 == 1 .0f ;
462
+ } else if (control == 34 ) {
463
+ screenSettings[2 ].canEdit = normValue2 == 1 .0f ;
464
+ } else if (control == 35 ) {
465
+ screenSettings[3 ].canEdit = normValue2 == 1 .0f ;
466
+ } else if (control == 36 ) {
467
+ screenSettings[4 ].canEdit = normValue2 == 1 .0f ;
468
+ } else if (control == 37 ) {
469
+ screenSettings[5 ].canEdit = normValue2 == 1 .0f ;
470
+ } else if (control >= 16 && control < (16 + MAX_SCREENS)) {
471
+ if (screenSettings[control-16 ].canEdit ) {
472
+ screenSettings[control-16 ].alpha = normValue2;
483
473
}
484
-
485
- if (value == 16 ) {
486
- for (int i=0 ; i<MAX_SCREENS; i++) {
487
- if (screenSettings[i].canEdit ) {
488
- int controlNo = id;
489
- if (id > 0 && id <= MAX_LAYERS) {
490
- screenLayerSettings[i][id-1 ].canEdit = normValue2 == 1.0 ;
491
- }
492
- }
493
- }
474
+ } else if (control >= 48 && control < 48 + MAX_LAYERS) {
475
+ for (int i=0 ; i<MAX_SCREENS; i++) {
476
+ if (screenSettings[i].canEdit ) {
477
+ screenLayerSettings[i][control - 48 ].canEdit = normValue2 == 1.0 ;
478
+ }
494
479
}
495
- port = eventArgs.portNum ;
496
- timestamp = eventArgs.deltatime ;
480
+ } else if (control == 23 ) {
481
+ masterAlpha = normValue2;
482
+ masterVolume = normValue2;
483
+ }
484
+ port = midiMsg.portNum ;
485
+ timestamp = midiMsg.deltatime ;
497
486
}
498
487
499
488
void ofPooks::selectColorChannelIndex (int colorChannelIndex) {
@@ -653,7 +642,7 @@ void ofPooks::windowResized(int w, int h){
653
642
}
654
643
655
644
// --------------------------------------------------------------
656
- void ofPooks::gotMessage (ofMessage msg ){
645
+ void ofPooks::gotMessage (ofMessage midiMsg ){
657
646
658
647
}
659
648
0 commit comments