From 0ff7b818a35859e8f1bac29dbbed9c189608a20d Mon Sep 17 00:00:00 2001 From: CHRISTOPHE Date: Fri, 20 Sep 2019 21:56:16 +0200 Subject: [PATCH] debut de modification du logiciel pour tester la gestion par ports --- .../MidiHallSynthChrom/MidiHallSynthChrom.ino | 417 +++++++++--------- 1 file changed, 220 insertions(+), 197 deletions(-) diff --git a/ressource arduino/MidiHallSynthChrom/MidiHallSynthChrom.ino b/ressource arduino/MidiHallSynthChrom/MidiHallSynthChrom.ino index 74b7dca..3b8512c 100644 --- a/ressource arduino/MidiHallSynthChrom/MidiHallSynthChrom.ino +++ b/ressource arduino/MidiHallSynthChrom/MidiHallSynthChrom.ino @@ -1,6 +1,22 @@ -/* sortie capteur branché sur pin24 arduino */ +/* travail du 20/09/2019 modification du cablage pour essai gestion par port + + +| port A | Broche | note | MIDI hex | +| -------- | -------- | -------- | -------- | +| A0 | 22 | C2 | 24 | +| A1 | 23 | D2 | 26 | +| A2 | 24 | E2 | 28 | +| A3 | 25 | F2 | 29 | +| A4 | 26 | G2 | 2B | +| A5 | 27 | A2 | 2D | +| A6 | 28 | B2 | 2F | +| A7 | 29 | C3 | 30 | + + +*/ + bool EtatEntree24 = HIGH ; bool VarSuivi24 = HIGH ; @@ -19,27 +35,21 @@ bool EtatEntree29 = HIGH ; bool VarSuivi29 = HIGH ; - - bool EtatEntree30 = HIGH ; - bool VarSuivi30 = HIGH ; - - bool EtatEntree31 = HIGH ; - bool VarSuivi31 = HIGH ; - - bool EtatEntree32 = HIGH ; - bool VarSuivi32 = HIGH ; + bool EtatEntree22 = HIGH ; + bool VarSuivi22 = HIGH ; - bool EtatEntree33 = HIGH ; - bool VarSuivi33 = HIGH ; - - bool EtatEntree34 = HIGH ; - bool VarSuivi34 = HIGH ; - + bool EtatEntree23 = HIGH ; + bool VarSuivi23 = HIGH ; - bool EtatEntree35 = HIGH ; - bool VarSuivi35 = HIGH ; +void noteOn(int cmd, int pitch, int velocity) /* plays a MIDI note. Doesn't check to see that cmd is greater than 127, + or that data values are less than 127 */ +{ + Serial.write(cmd); + Serial.write(pitch); + Serial.write(velocity); +} @@ -54,12 +64,9 @@ void setup() pinMode(27,INPUT); pinMode(28,INPUT); pinMode(29,INPUT); - pinMode(30,INPUT); - pinMode(31,INPUT); - pinMode(32,INPUT); - pinMode(33,INPUT); - pinMode(34,INPUT); - pinMode(35,INPUT); + pinMode(22,INPUT); + pinMode(23,INPUT); + @@ -67,39 +74,45 @@ void setup() Serial.begin(31250); /* initialisation d'un port serie au debit MIDI */ noteOn(0x80, 0x24 , 0x00 ) ; /* note off sur canal1 ; C2 ; vel 0 */ - noteOn(0x80, 0x25 , 0x00 ) ; + noteOn(0x80, 0x26 , 0x00 ) ; /* note off sur canal1 ; D2 ; vel 0 */ - noteOn(0x80, 0x27 , 0x00 ) ; + noteOn(0x80, 0x28 , 0x00 ) ; /* note off sur canal1 ; E2 ; vel 0 */ noteOn(0x80, 0x29 , 0x00 ) ; - noteOn(0x80, 0x30 , 0x00 ) ; - noteOn(0x80, 0x31 , 0x00 ) ; - noteOn(0x80, 0x32 , 0x00 ) ; - noteOn(0x80, 0x33 , 0x00 ) ; - noteOn(0x80, 0x34 , 0x00 ) ; - noteOn(0x80, 0x35 , 0x00 ) ; - - - + + noteOn(0x80, 0x2B , 0x00 ) ; + + noteOn(0x80, 0x2D , 0x00 ) ; + + noteOn(0x80, 0x2F , 0x00 ) ; + + noteOn(0x80, 0x30 , 0x00 ) ; +char PortA = 0 ; +char DernierEtatPortA = 0 ; +char ModifPortA = 0 ; } -void noteOn(int cmd, int pitch, int velocity) /* plays a MIDI note. Doesn't check to see that cmd is greater than 127, - or that data values are less than 127 */ -{ - Serial.write(cmd); - Serial.write(pitch); - Serial.write(velocity); -} - - void loop() - { +{ - EtatEntree24 = digitalRead(24); + PortA = PINA ; + ModifPortA = DernierEtatPortA ^ DernierEtatPortA + + + + + + + DernierEtatPortA = PortA ; + +/* FIN */ + + + /* EtatEntree24 = digitalRead(24); EtatEntree25 = digitalRead(25); EtatEntree26 = digitalRead(26); EtatEntree27 = digitalRead(27); @@ -110,182 +123,181 @@ void loop() EtatEntree32 = digitalRead(32); EtatEntree33 = digitalRead(33); EtatEntree34 = digitalRead(34); - EtatEntree35 = digitalRead(35); + EtatEntree35 = digitalRead(35); */ - - if ( (EtatEntree24 != VarSuivi24) && (EtatEntree24 == HIGH) ) - { - noteOn(0x80, 0x24 , 0x00) ; /* note off sur canal1 ; C2 ; vel 0 */ - /* Serial.println("touche lachee"); */ - VarSuivi24 = HIGH; - } - - if ( (EtatEntree24 != VarSuivi24) && (EtatEntree24 == LOW) ) - { - noteOn(0x90, 0x24 , 0x70) ; /* note on sur canal1 ; C2 ; vel */ - /* Serial.println("touche appuyee"); */ - VarSuivi24 = LOW; - } - - if ( (EtatEntree25 != VarSuivi25) && (EtatEntree25 == HIGH) ) - { - noteOn(0x80, 0x25 , 0x00) ; - /* Serial.println("touche lachee"); */ - VarSuivi25 = HIGH; - } - - if ( (EtatEntree25 != VarSuivi25) && (EtatEntree25 == LOW) ) - { - noteOn(0x90, 0x25 , 0x70) ; /* note on sur canal1 ; C2 ; vel */ - /* Serial.println("touche appuyee"); */ - VarSuivi25 = LOW; - } - if ( (EtatEntree26 != VarSuivi26) && (EtatEntree26 == HIGH) ) - { - noteOn(0x80, 0x26 , 0x00) ; /* note off sur canal1 ; D2 ; vel 0 */ - /* Serial.println("touche lachee"); */ - VarSuivi26 = HIGH; - } - - if ( (EtatEntree26 != VarSuivi26) && (EtatEntree26 == LOW) ) - { - noteOn(0x90, 0x26 , 0x70) ; /* note on sur canal1 ; D2 ; vel */ - /* Serial.println("touche appuyee"); */ - VarSuivi26 = LOW; - } - - - if ( (EtatEntree27 != VarSuivi27) && (EtatEntree27 == HIGH) ) - { - noteOn(0x80, 0x27 , 0x00) ; /* note off sur canal1 ; C2 ; vel 0 */ - /* Serial.println("touche lachee"); */ - VarSuivi27 = HIGH; - } - - if ( (EtatEntree27 != VarSuivi27) && (EtatEntree27 == LOW) ) - { - noteOn(0x90, 0x27 , 0x70) ; /* note on sur canal1 ; C2 ; vel */ - /* Serial.println("touche appuyee"); */ - VarSuivi27 = LOW; - } - - if ( (EtatEntree28 != VarSuivi28) && (EtatEntree28 == HIGH) ) - { - noteOn(0x80, 0x28 , 0x00) ; /* note off sur canal1 ; C2 ; vel 0 */ - /* Serial.println("touche lachee"); */ - VarSuivi28 = HIGH; - } - - if ( (EtatEntree28 != VarSuivi28) && (EtatEntree28 == LOW) ) - { - noteOn(0x90, 0x28 , 0x70) ; /* note on sur canal1 ; C2 ; vel */ - /* Serial.println("touche appuyee"); */ - VarSuivi28 = LOW; - } +// if ( (EtatEntree24 != VarSuivi24) && (EtatEntree24 == HIGH) ) +// { +// noteOn(0x80, 0x24 , 0x00) ; /* note off sur canal1 ; C2 ; vel 0 */ +// /* Serial.println("touche lachee"); */ +// VarSuivi24 = HIGH; +// } +// + // if ( (EtatEntree24 != VarSuivi24) && (EtatEntree24 == LOW) ) +// { +// noteOn(0x90, 0x24 , 0x70) ; /* note on sur canal1 ; C2 ; vel */ +// /* Serial.println("touche appuyee"); */ +// VarSuivi24 = LOW; +// } - if ( (EtatEntree29 != VarSuivi29) && (EtatEntree29 == HIGH) ) - { - noteOn(0x80, 0x29 , 0x00) ; /* note off sur canal1 ; ; vel 0 */ - /* Serial.println("touche lachee"); */ - VarSuivi29 = HIGH; - } +// if ( (EtatEntree25 != VarSuivi25) && (EtatEntree25 == HIGH) ) + // { +// // noteOn(0x80, 0x25 , 0x00) ; + // VarSuivi25 = HIGH; + // } - if ( (EtatEntree29 != VarSuivi29) && (EtatEntree29 == LOW) ) - { - noteOn(0x90, 0x29 , 0x70) ; /* note on sur canal1 ; C2 ; vel */ - /* Serial.println("touche appuyee"); */ - VarSuivi29 = LOW; - } + // if ( (EtatEntree25 != VarSuivi25) && (EtatEntree25 == LOW) ) + // { + // noteOn(0x90, 0x25 , 0x70) ; /* note on sur canal1 ; C2 ; vel */ +// /* Serial.println("touche appuyee"); */ +// VarSuivi25 = LOW; +// } +// if ( (EtatEntree26 != VarSuivi26) && (EtatEntree26 == HIGH) ) +// { +// noteOn(0x80, 0x26 , 0x00) ; /* note off sur canal1 ; D2 ; vel 0 */ + // /* Serial.println("touche lachee"); */ + // VarSuivi26 = HIGH; +// } + +// if ( (EtatEntree26 != VarSuivi26) && (EtatEntree26 == LOW) ) +// { +// noteOn(0x90, 0x26 , 0x70) ; /* note on sur canal1 ; D2 ; vel */ +// /* Serial.println("touche appuyee"); */ +// VarSuivi26 = LOW; +// } + +// +// if ( (EtatEntree27 != VarSuivi27) && (EtatEntree27 == HIGH) ) + // { + // noteOn(0x80, 0x27 , 0x00) ; /* note off sur canal1 ; C2 ; vel 0 */ + // /* Serial.println("touche lachee"); */ + // VarSuivi27 = HIGH; + // } + // + // if ( (EtatEntree27 != VarSuivi27) && (EtatEntree27 == LOW) ) + // { + // noteOn(0x90, 0x27 , 0x70) ; /* note on sur canal1 ; C2 ; vel */ + // /* Serial.println("touche appuyee"); */ +// VarSuivi27 = LOW; +// } +// + // if ( (EtatEntree28 != VarSuivi28) && (EtatEntree28 == HIGH) ) +// { +// noteOn(0x80, 0x28 , 0x00) ; /* note off sur canal1 ; C2 ; vel 0 */ + // /* Serial.println("touche lachee"); */ + // VarSuivi28 = HIGH; + // } + // + // if ( (EtatEntree28 != VarSuivi28) && (EtatEntree28 == LOW) ) + // { + // noteOn(0x90, 0x28 , 0x70) ; /* note on sur canal1 ; C2 ; vel */ + // /* Serial.println("touche appuyee"); */ + // VarSuivi28 = LOW; + // } +// + + // if ( (EtatEntree29 != VarSuivi29) && (EtatEntree29 == HIGH) ) + // { + // noteOn(0x80, 0x29 , 0x00) ; /* note off sur canal1 ; ; vel 0 */ + // /* Serial.println("touche lachee"); */ + // VarSuivi29 = HIGH; + // } + + // if ( (EtatEntree29 != VarSuivi29) && (EtatEntree29 == LOW) ) + // { + // noteOn(0x90, 0x29 , 0x70) ; /* note on sur canal1 ; C2 ; vel */ +// /* Serial.println("touche appuyee"); */ + // VarSuivi29 = LOW; +// } - if ( (EtatEntree30 != VarSuivi30) && (EtatEntree30 == HIGH) ) - { - noteOn(0x80, 0x2A , 0x00) ; + // if ( (EtatEntree30 != VarSuivi30) && (EtatEntree30 == HIGH) ) + // { + // noteOn(0x80, 0x2A , 0x00) ; + // + // VarSuivi30 = HIGH; + // } - VarSuivi30 = HIGH; - } + // if ( (EtatEntree30 != VarSuivi30) && (EtatEntree30 == LOW) ) +// { +// noteOn(0x90, 0x2A , 0x70) ; - if ( (EtatEntree30 != VarSuivi30) && (EtatEntree30 == LOW) ) - { - noteOn(0x90, 0x2A , 0x70) ; - - VarSuivi30 = LOW; - } +// VarSuivi30 = LOW; + // } - if ( (EtatEntree31 != VarSuivi31) && (EtatEntree31 == HIGH) ) - { - noteOn(0x80, 0x2B , 0x00) ; + // if ( (EtatEntree31 != VarSuivi31) && (EtatEntree31 == HIGH) ) + // { + // noteOn(0x80, 0x2B , 0x00) ; - VarSuivi31 = HIGH; - } + // VarSuivi31 = HIGH; +// } - if ( (EtatEntree31 != VarSuivi31) && (EtatEntree31 == LOW) ) - { - noteOn(0x90, 0x2B , 0x70) ; + // if ( (EtatEntree31 != VarSuivi31) && (EtatEntree31 == LOW) ) + // { + // noteOn(0x90, 0x2B , 0x70) ; + // + // VarSuivi31 = LOW; + // } +// +// if ( (EtatEntree32 != VarSuivi32) && (EtatEntree32 == HIGH) ) + // { + // noteOn(0x80, 0x2C , 0x00) ; - VarSuivi31 = LOW; - } + // VarSuivi32 = HIGH; + // } + + // if ( (EtatEntree32 != VarSuivi32) && (EtatEntree32 == LOW) ) + // { + // noteOn(0x90, 0x2C , 0x70) ; + + // VarSuivi32 = LOW; + // } - if ( (EtatEntree32 != VarSuivi32) && (EtatEntree32 == HIGH) ) - { - noteOn(0x80, 0x2C , 0x00) ; + // if ( (EtatEntree33 != VarSuivi33) && (EtatEntree33 == HIGH) ) + // { +// noteOn(0x80, 0x2D , 0x00) ; - VarSuivi32 = HIGH; - } + // VarSuivi33 = HIGH; + // } - if ( (EtatEntree32 != VarSuivi32) && (EtatEntree32 == LOW) ) - { - noteOn(0x90, 0x2C , 0x70) ; + // if ( (EtatEntree33 != VarSuivi33) && (EtatEntree33 == LOW) ) + // { + // noteOn(0x90, 0x2D , 0x70) ; - VarSuivi32 = LOW; - } - - if ( (EtatEntree33 != VarSuivi33) && (EtatEntree33 == HIGH) ) - { - noteOn(0x80, 0x2D , 0x00) ; - - VarSuivi33 = HIGH; - } - - if ( (EtatEntree33 != VarSuivi33) && (EtatEntree33 == LOW) ) - { - noteOn(0x90, 0x2D , 0x70) ; - - VarSuivi33 = LOW; - } + // VarSuivi33 = LOW; +// } - if ( (EtatEntree34 != VarSuivi34) && (EtatEntree34 == HIGH) ) - { - noteOn(0x80, 0x2E , 0x00) ; + // if ( (EtatEntree34 != VarSuivi34) && (EtatEntree34 == HIGH) ) + // { + // noteOn(0x80, 0x2E , 0x00) ; + // + // VarSuivi34 = HIGH; + // } - VarSuivi34 = HIGH; - } + // if ( (EtatEntree34 != VarSuivi34) && (EtatEntree34 == LOW) ) + // { + // noteOn(0x90, 0x2E , 0x70) ; - if ( (EtatEntree34 != VarSuivi34) && (EtatEntree34 == LOW) ) - { - noteOn(0x90, 0x2E , 0x70) ; - - VarSuivi34 = LOW; - } + // VarSuivi34 = LOW; +// } - if ( (EtatEntree35 != VarSuivi35) && (EtatEntree35 == HIGH) ) - { - noteOn(0x80, 0x2F , 0x00) ; + // if ( (EtatEntree35 != VarSuivi35) && (EtatEntree35 == HIGH) ) + // { + // noteOn(0x80, 0x2F , 0x00) ; - VarSuivi35 = HIGH; - } - - if ( (EtatEntree35 != VarSuivi35) && (EtatEntree35 == LOW) ) - { - noteOn(0x90, 0x2F , 0x70) ; - - VarSuivi35 = LOW; - } +// VarSuivi35 = HIGH; +// } +// +// if ( (EtatEntree35 != VarSuivi35) && (EtatEntree35 == LOW) ) + // { +// noteOn(0x90, 0x2F , 0x70) ; + // + // VarSuivi35 = LOW; + // } @@ -307,6 +319,17 @@ void loop() //Note on channel 1 (0x90), some note value (note), silent velocity (0x00): noteOn(0x90, note, 0x00); delay(100); */ + + + + + + + + + + + }