From 7eaf0ed2f2bedb4f3dc7113d18aa5b4a24a6aa41 Mon Sep 17 00:00:00 2001 From: Christophe Date: Fri, 9 Aug 2019 21:18:26 +0200 Subject: [PATCH] ESSAI OK pour envoie note on, note off sortie arduino --- .../MidiHallSynthChrom/MidiHallSynthChrom.ino | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 ressource arduino/MidiHallSynthChrom/MidiHallSynthChrom.ino diff --git a/ressource arduino/MidiHallSynthChrom/MidiHallSynthChrom.ino b/ressource arduino/MidiHallSynthChrom/MidiHallSynthChrom.ino new file mode 100644 index 0000000..4c7878e --- /dev/null +++ b/ressource arduino/MidiHallSynthChrom/MidiHallSynthChrom.ino @@ -0,0 +1,69 @@ + + +/* capteur branché avec sortie sur pin24 arduino */ + bool EtatEntree24 = HIGH ; + bool VarSuivi24 = HIGH ; + bool EtatEntree26 = HIGH ; + bool VarSuivi26 = HIGH ; + bool EtatEntree28 = HIGH ; + bool VarSuivi28 = HIGH ; + +void setup() ² +{ + + pinMode(24,INPUT); + pinMode(26,INPUT); + pinMode(28,INPUT); + Serial.begin(31250); /* initialisation d'un port serie au debit MIDI */ + noteOn(0x80, 0x24 , 0x00 ) ; /* note off sur canal1 ; C2 ; vel 0 */ + noteOn(0x80, 0x26 , 0x00 ) ; /* note off sur canal1 ; D2 ; vel 0 */ + noteOn(0x80, 0x28 , 0x00 ) ; /* note off sur canal1 ; E2 ; vel 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); + EtatEntree26 = digitalRead(24); + EtatEntree28 = digitalRead(24); + if ( (EtatEntree24 != VarSuivi24) && (EtatEntree24 == HIGH) ) + { + noteOn(0x80, 0x24 , 0x00) ; /* note off sur canal1 ; C2 ; vel 0 */ + /* Serial.println("touche lachee"); */ + VarSuivi = HIGH; + } + + if ( (EtatEntree != VarSuivi) && (EtatEntree == LOW) ) + { + noteOn(0x90, 0x24 , 0x70) ; /* note on sur canal1 ; C2 ; vel */ + /* Serial.println("touche appuyee"); */ + VarSuivi = LOW; + } + + + + /* // play notes from F#-0 (0x1E) to F#-5 (0x5A): + for (int note = 0x1E; note < 0x5A; note ++) { + //Note on channel 1 (0x90), some note value (note), middle velocity (0x45): + noteOn(0x90, note, 0x45); + delay(100); + //Note on channel 1 (0x90), some note value (note), silent velocity (0x00): + noteOn(0x90, note, 0x00); + delay(100); */ + + } + + +