Resolume is able to detect the midi but when I midi map the pulse to launch a clip the video just stops. Also when I map it to a slider like opacity, the slider moved up and down from 0 automatically to 100 erratically but the video does not change. Any suggestions?
Code: Select all
#include <MIDI.h>
#define Heart 2 //Attach the Grove Ear-clip sensor to digital pin 2.
#define LED 4 //Attach an LED to digital pin 4
boolean beat = false; /* This "beat" variable is used to control the timing of the Serial communication
so that data is only sent when there is a "change" in digital readings. */
//MIDI_CREATE_DEFAULT_INSTANCE();
int velocity = 50;//velocity of MIDI notes, must be between 0 and 127
//higher velocity usually makes MIDI instruments louder
int noteON = 144;//144 = 10010000 in binary, note on command
//int noteOFF = 128;//128 = 10000000 in binary, note off command
//==SETUP==========================================================================================
void setup() {
//MIDI.begin(MIDI_CHANNEL_OMNI);
Serial.begin(115200); //Initialise serial communication
pinMode(Heart, INPUT); //Set digital pin 2 (heart rate sensor pin) as an INPUT
pinMode(LED, OUTPUT); //Set digital pin 4 (LED) to an OUTPUT
}
//==LOOP============================================================================================
void loop() {
if (digitalRead(Heart) > 0) { //The heart rate sensor will trigger HIGH when there is a heart beat
if (!beat) { //Only send data when it first discovers a heart beat - otherwise it will send a high value multiple times
beat = true; //By changing the beat variable to true, it stops further transmissions of the high signal
digitalWrite(LED, HIGH);
int note=60;
MIDImessage(noteON, note, velocity);//turn note on
delay(300);//hold note for 300ms
//Serial.println(1023); //Send the high value to the computer via Serial communication.
}
} else { //If the reading is LOW,
if (beat) { //and if this has just changed from HIGH to LOW (first low reading)
beat = false; //change the beat variable to false (to stop multiple transmissions)
digitalWrite(LED, LOW);
int note=60;
MIDImessage(noteON, note, 0);//turn note off
delay(300);//wait 200ms until triggering next note
//Serial.println(0); //then send a low value to the computer via Serial communication.
}
}
}
void MIDImessage(int command, int MIDInote, int MIDIvelocity) {
Serial.write(command);//send note on or note off command
Serial.write(MIDInote);//send pitch data
Serial.write(MIDIvelocity);//send velocity data
}