@@ -23,6 +23,7 @@ PROGRAMME FUNCTION: EVI Wind Controller using the Freescale MP3V5004GP breath
2323// Compile options, comment/uncomment to change
2424
2525#define REVB
26+ // #define NEWTEENSYDUINO
2627
2728
2829// Pin definitions
@@ -107,7 +108,7 @@ PROGRAMME FUNCTION: EVI Wind Controller using the Freescale MP3V5004GP breath
107108#endif
108109
109110#define ON_Delay 20 // Set Delay after ON threshold before velocity is checked (wait for tounging peak)
110- #define touch_Thr 1200 // sensitivity for Teensy touch sensors
111+ // #define touch_Thr 1200 // sensitivity for Teensy touch sensors
111112#define CCN_Port 5 // Controller number for portamento level
112113#define CCN_PortOnOff 65 // Controller number for portamento on/off
113114
@@ -325,12 +326,12 @@ unsigned short extracMaxVal;// = 2400;
325326unsigned short ctouchThrVal;// = 120;
326327unsigned short transpose;
327328unsigned short MIDIchannel;
328- unsigned short breathCC; // OFF:MW:BR:VL:EX:MW+:BR+:VL+:EX+
329+ unsigned short breathCC; // OFF:MW:BR:VL:EX:MW+:BR+:VL+:EX+:CF
329330unsigned short breathAT;
330331unsigned short velocity;
331332unsigned short portamento;// switching on cc65? just cc5 enabled? SW:ON:OFF
332333unsigned short PBdepth; // OFF:1-12 divider
333- unsigned short extraCT; // OFF:MW:FP:FC :SP
334+ unsigned short extraCT; // OFF:MW:FP:CF :SP
334335unsigned short vibrato; // OFF:1-9
335336unsigned short deglitch; // 0-70 ms in steps of 5
336337unsigned short patch; // 1-128
@@ -359,6 +360,11 @@ int extracLoLimit = 500;
359360int extracHiLimit = 4000 ;
360361int ctouchLoLimit = 50 ;
361362int ctouchHiLimit = 350 ;
363+ int ttouchLoLimit = 50 ;
364+ int ttouchHiLimit = 1900 ;
365+
366+ int touch_Thr = 1300 ;
367+
362368
363369int breathStep;
364370int portamStep;
@@ -400,7 +406,7 @@ byte subParallel = 0;
400406byte subRotator = 0 ;
401407byte subPriority = 0 ;
402408
403- byte ccList[9 ] = {0 ,1 ,2 ,7 ,11 ,1 ,2 ,7 ,11 }; // OFF, Modulation, Breath, Volume, Expression (then same sent in hires)
409+ byte ccList[10 ] = {0 ,1 ,2 ,7 ,11 ,1 ,2 ,7 ,11 , 74 }; // OFF, Modulation, Breath, Volume, Expression (then same sent in hires)
404410
405411int pbDepthList[13 ] = {0 ,8192 ,4096 ,2731 ,2048 ,1638 ,1365 ,1170 ,1024 ,910 ,819 ,744 ,683 };
406412
@@ -441,6 +447,8 @@ byte activeMIDIchannel=1; // MIDI channel
441447byte activePatch=0 ;
442448byte doPatchUpdate=0 ;
443449
450+ byte legacy = 0 ;
451+
444452byte FPD = 0 ;
445453
446454int breathLevel=0 ; // breath level (smoothed) not mapped to CC value
@@ -498,6 +506,7 @@ int oldvibRead=0;
498506byte dirUp=0 ; // direction of first vibrato wave
499507
500508int fingeredNote; // note calculated from fingering (switches), transpose and octave settings
509+ int fingeredNoteUntransposed; // note calculated from fingering (switches), for on the fly settings
501510byte activeNote; // note playing
502511byte startNote=36 ; // set startNote to C (change this value in steps of 12 to start in other octaves)
503512int slurBase; // first note in slur sustain chord
@@ -637,6 +646,7 @@ void setup() {
637646 rotations[3 ] = readSetting (ROTN4_ADDR)-24 ;
638647 priority = readSetting (PRIO_ADDR);
639648
649+ legacy = dipSwBits & (1 <<1 );
640650 activePatch = patch;
641651
642652 breathStep = (breathHiLimit - breathLoLimit)/92 ; // 92 is the number of pixels in the settings bar
@@ -645,6 +655,7 @@ void setup() {
645655 extracStep = (extracHiLimit - extracLoLimit)/92 ;
646656 ctouchStep = (ctouchHiLimit - ctouchLoLimit)/92 ;
647657
658+ touch_Thr = map (ctouchThrVal,ctouchHiLimit,ctouchLoLimit,ttouchLoLimit,ttouchHiLimit);
648659
649660 if (!touchSensor.begin (0x5A )) {
650661 while (1 ); // Touch sensor initialization failed - stop doing stuff
@@ -684,7 +695,7 @@ void setup() {
684695 display.setTextColor (WHITE);
685696 display.setTextSize (1 );
686697 display.setCursor (85 ,52 );
687- display.println (" v.1.1.5 " ); // FIRMWARE VERSION NUMBER HERE <<<<<<<<<<<<<<<<<<<<<<<
698+ display.println (" v.1.1.7 " ); // FIRMWARE VERSION NUMBER HERE <<<<<<<<<<<<<<<<<<<<<<<
688699 display.display ();
689700
690701 delay (2000 );
@@ -738,6 +749,48 @@ void mainLoop() {
738749 initial_breath_value = pressureSensor;
739750 mainState = RISE_WAIT; // Go to next state
740751 }
752+ if (legacy){
753+ if ((pbUp > ((pitchbMaxVal + pitchbThrVal)/2 )) && (pbDn > ((pitchbMaxVal + pitchbThrVal)/2 ))){ // both pb pads touched
754+ readSwitches ();
755+ fingeredNoteUntransposed=patchLimit (fingeredNoteUntransposed+1 );
756+ if (exSensor >= ((extracThrVal+extracMaxVal)/2 )){ // instant midi setting
757+ if ((fingeredNoteUntransposed >= 72 ) && (fingeredNoteUntransposed <= 88 )) {
758+ MIDIchannel = fingeredNoteUntransposed - 72 ; // Mid C and up
759+ digitalWrite (13 ,LOW);
760+ delay (150 );
761+ digitalWrite (13 ,HIGH);
762+ }
763+ } else {
764+ if (!pinkyKey){ // note number to patch number
765+ if (patch != fingeredNoteUntransposed){
766+ patch = fingeredNoteUntransposed;
767+ doPatchUpdate = 1 ;
768+ digitalWrite (13 ,LOW);
769+ delay (150 );
770+ digitalWrite (13 ,HIGH);
771+ }
772+ } else { // hi and lo patch numbers
773+ if (fingeredNoteUntransposed > 75 ){
774+ if (patch != patchLimit (fingeredNoteUntransposed + 24 )){
775+ patch = patchLimit (fingeredNoteUntransposed + 24 ); // add 24 to get high numbers 108 to 127
776+ doPatchUpdate = 1 ;
777+ digitalWrite (13 ,LOW);
778+ delay (150 );
779+ digitalWrite (13 ,HIGH);
780+ }
781+ } else {
782+ if (patch != patchLimit (fingeredNoteUntransposed - 36 )){
783+ patch = patchLimit (fingeredNoteUntransposed - 36 ); // subtract 36 to get low numbers 0 to 36
784+ doPatchUpdate = 1 ;
785+ digitalWrite (13 ,LOW);
786+ delay (150 );
787+ digitalWrite (13 ,HIGH);
788+ }
789+ }
790+ }
791+ }
792+ }
793+ }
741794 specialKey=(touchRead (specialKeyPin) > touch_Thr); // S2 on pcb
742795 if (lastSpecialKey != specialKey){
743796 if (specialKey){
@@ -1121,6 +1174,10 @@ int noteValueCheck(int note){
11211174
11221175// **************************************************************
11231176
1177+ int patchLimit (int value){
1178+ if (value < 1 ) return 1 ; else if (value > 128 ) return 128 ; else return value;
1179+ }
1180+
11241181void midiPanic (){ // all notes off
11251182 usbMIDI.sendControlChange (123 , 0 , activeMIDIchannel);
11261183 dinMIDIsendControlChange (123 , 0 , activeMIDIchannel - 1 );
@@ -1242,7 +1299,7 @@ void breath(){
12421299 }
12431300
12441301 if (breathCCvalHires != oldbreathhires){
1245- if (breathCC > 4 ){ // send high resolution midi
1302+ if (( breathCC > 4 ) && (breathCC < 9 ) ){ // send high resolution midi
12461303 usbMIDI.sendControlChange (ccList[breathCC]+32 , breathCCvalFine, activeMIDIchannel);
12471304 dinMIDIsendControlChange (ccList[breathCC]+32 , breathCCvalFine, activeMIDIchannel - 1 );
12481305 }
@@ -1303,7 +1360,11 @@ void pitch_bend(){
13031360 }
13041361 pitchBend=constrain (pitchBend, 0 , 16383 );
13051362 if (pitchBend != oldpb){// only send midi data if pitch bend has changed from previous value
1363+ #if defined(NEWTEENSYDUINO)
1364+ usbMIDI.sendPitchBend (pitchBend-8192 , activeMIDIchannel); // newer teensyduino "pitchBend-8192" older just "pitchBend"... strange thing to change
1365+ #else
13061366 usbMIDI.sendPitchBend (pitchBend, activeMIDIchannel);
1367+ #endif
13071368 dinMIDIsendPitchBend (pitchBend, activeMIDIchannel - 1 );
13081369 oldpb=pitchBend;
13091370 }
@@ -1338,7 +1399,7 @@ void extraController(){
13381399 }
13391400 oldextrac = extracCC;
13401401 }
1341- if (extraCT == 3 ){ // Send filter cutoff (CC#74)
1402+ if (( extraCT == 3 ) && (breathCC != 9 ) ){ // Send filter cutoff (CC#74)
13421403 int extracCC = map (constrain (exSensor,extracThrVal,extracMaxVal),extracThrVal,extracMaxVal,1 ,127 );
13431404 if (extracCC != oldextrac){
13441405 usbMIDI.sendControlChange (74 ,extracCC, activeMIDIchannel);
@@ -1358,8 +1419,8 @@ void extraController(){
13581419 usbMIDI.sendControlChange (4 ,0 , activeMIDIchannel);
13591420 dinMIDIsendControlChange (4 ,0 , activeMIDIchannel - 1 );
13601421 oldextrac = 0 ;
1361- } else if (extraCT == 3 ){ // FC
1362- // send foot pedal 0
1422+ } else if (( extraCT == 3 ) && (breathCC != 9 )) { // CF
1423+ // send filter cutoff 0
13631424 usbMIDI.sendControlChange (74 ,0 , activeMIDIchannel);
13641425 dinMIDIsendControlChange (74 ,0 , activeMIDIchannel - 1 );
13651426 oldextrac = 0 ;
@@ -1462,6 +1523,7 @@ void readSwitches(){
14621523
14631524 // Calculate midi note number from pressed keys
14641525 fingeredNote=startNote-2 *K1-K2-3 *K3-5 *K4+2 *K5+K6+4 *K7+octaveR*12 +(octave-3 )*12 +transpose-12 +qTransp;
1526+ fingeredNoteUntransposed=startNote-2 *K1-K2-3 *K3-5 *K4+2 *K5+K6+4 *K7+octaveR*12 ;
14651527}
14661528
14671529// ***********************************************************
@@ -1606,14 +1668,27 @@ void menu() {
16061668 stateFirstRun = 1 ;
16071669 break ;
16081670 case 8 :
1609- // menu
1610- display.ssd1306_command (SSD1306_DISPLAYON);
1611- if (pinkyKey){
1671+ // menu
1672+ if (exSensor >= ((extracThrVal+extracMaxVal)/2 )){ // switch legacy settings control on/off
1673+ legacy = !legacy;
1674+ dipSwBits = dipSwBits ^ (1 <<1 );
1675+ writeSetting (DIPSW_BITS_ADDR,dipSwBits);
1676+ digitalWrite (13 ,LOW);
1677+ delay (150 );
1678+ digitalWrite (13 ,HIGH);
1679+ delay (150 );
1680+ digitalWrite (13 ,LOW);
1681+ delay (150 );
1682+ digitalWrite (13 ,HIGH);
1683+ } else if (pinkyKey){
1684+ display.ssd1306_command (SSD1306_DISPLAYON);
16121685 state = ROTATOR_MENU;
1686+ stateFirstRun = 1 ;
16131687 } else {
1688+ display.ssd1306_command (SSD1306_DISPLAYON);
16141689 state = MAIN_MENU;
1690+ stateFirstRun = 1 ;
16151691 }
1616- stateFirstRun = 1 ;
16171692 break ;
16181693 case 15 :
16191694 // all keys depressed, reboot to programming mode
@@ -2761,6 +2836,7 @@ void menu() {
27612836 // down
27622837 if (ctouchThrVal - ctouchStep > ctouchLoLimit){
27632838 ctouchThrVal -= ctouchStep;
2839+ touch_Thr = map (ctouchThrVal,ctouchHiLimit,ctouchLoLimit,ttouchLoLimit,ttouchHiLimit);
27642840 display.drawLine (pos1,20 ,pos1,26 ,BLACK);
27652841 pos1 = map (ctouchThrVal, ctouchLoLimit, ctouchHiLimit, 27 , 119 );
27662842 display.drawLine (pos1,20 ,pos1,26 ,WHITE);
@@ -2779,6 +2855,7 @@ void menu() {
27792855 // up
27802856 if (ctouchThrVal + ctouchStep < ctouchHiLimit){
27812857 ctouchThrVal += ctouchStep;
2858+ touch_Thr = map (ctouchThrVal,ctouchHiLimit,ctouchLoLimit,ttouchLoLimit,ttouchHiLimit);
27822859 display.drawLine (pos1,20 ,pos1,26 ,BLACK);
27832860 pos1 = map (ctouchThrVal, ctouchLoLimit, ctouchHiLimit, 27 , 119 );
27842861 display.drawLine (pos1,20 ,pos1,26 ,WHITE);
@@ -2823,7 +2900,7 @@ void menu() {
28232900 cursorBlinkTime = millis ();
28242901 } else {
28252902 plotBreathCC (BLACK);
2826- breathCC = 8 ;
2903+ breathCC = 9 ;
28272904 plotBreathCC (WHITE);
28282905 cursorNow = BLACK;
28292906 display.display ();
@@ -2843,7 +2920,7 @@ void menu() {
28432920 break ;
28442921 case 4 :
28452922 // up
2846- if (breathCC < 8 ){
2923+ if (breathCC < 9 ){
28472924 plotBreathCC (BLACK);
28482925 breathCC++;
28492926 plotBreathCC (WHITE);
@@ -3962,7 +4039,7 @@ void drawRotatorMenuScreen(){
39624039 display.print (" ROTATOR SETUP" );
39634040 display.drawLine (0 ,9 ,127 ,9 ,WHITE);
39644041 display.setCursor (0 ,12 );
3965- display.println (" INTERVAL " );
4042+ display.println (" PARALLEL " );
39664043 display.setCursor (0 ,21 );
39674044 display.println (" ROTATE 1" );
39684045 display.setCursor (0 ,30 );
@@ -4089,7 +4166,7 @@ void plotPriority(int color){
40894166 if (priority){
40904167 display.println (" ROT" );
40914168 } else {
4092- display.println (" BAS " );
4169+ display.println (" MEL " );
40934170 }
40944171}
40954172
@@ -4186,6 +4263,10 @@ void plotBreathCC(int color){
41864263 display.setCursor (79 ,33 );
41874264 display.println (" EX+" );
41884265 break ;
4266+ case 9 :
4267+ display.setCursor (83 ,33 );
4268+ display.println (" CF" );
4269+ break ;
41894270 }
41904271 } else {
41914272 display.setCursor (79 ,33 );
@@ -4387,7 +4468,7 @@ void plotExtra(int color){
43874468 break ;
43884469 case 3 :
43894470 display.setCursor (83 ,33 );
4390- display.println (" FC " );
4471+ display.println (" CF " );
43914472 break ;
43924473 case 4 :
43934474 display.setCursor (83 ,33 );
@@ -4641,6 +4722,12 @@ void drawSensorPixels(){
46414722 pos = map (constrain (touchSensor.filteredData (i), ctouchLoLimit, ctouchHiLimit), ctouchLoLimit, ctouchHiLimit, 28 , 118 );
46424723 display.drawPixel (pos, 38 , WHITE);
46434724 }
4725+ int posRead = map (touchRead (halfPitchBendKeyPin),ttouchLoLimit,ttouchHiLimit,ctouchHiLimit,ctouchLoLimit);
4726+ pos = map (constrain (posRead, ctouchLoLimit, ctouchHiLimit), ctouchLoLimit, ctouchHiLimit, 28 , 118 );
4727+ display.drawPixel (pos, 38 , WHITE);
4728+ posRead = map (touchRead (specialKeyPin),ttouchLoLimit,ttouchHiLimit,ctouchHiLimit,ctouchLoLimit);
4729+ pos = map (constrain (posRead, ctouchLoLimit, ctouchHiLimit), ctouchLoLimit, ctouchHiLimit, 28 , 118 );
4730+ display.drawPixel (pos, 38 , WHITE);
46444731 display.display ();
46454732 }
46464733 forcePix = 0 ;
0 commit comments