Hello! I'm trying to set up a midi controller with arduino, using piezos. Though I have no idea about programming I googled up and managed to adapt this code to my needs. It reads the analog inputs and if the piezo sends a voltage higher than what I specified, it sends a midi message. I use hairlessMIDI as serial-midi converter and loopMIDI as virtual midi ports. Then in the DAW (Reaper) I select the virtual port as the controller and play the VST.
So, my problem is when I try to play two notes at the same time, only one of them is played/heared from the vst. How could I solve that? Any idea? Is there anything missing in the code? I understand that thecnically you can't send several actually simultaneous notes, but they can be sent close enough to be virtually simultaneous. But for some reason this isn't happening.
Thank you very much in advance.
void setup() {
// Set MIDI baud rate:
Serial.begin(256000);
}
void loop() {
int piez0 = analogRead(A0)/2;
int piez1 = analogRead(A1);
int piez2 = analogRead(A2);
int piez3 = analogRead(A3);
int vel0 = piez0/4;
int vel1 = piez1/4;
int noteON = 144;
int noteOFF = 128;
int hihat = 42;
int snare = 43;
int crash = 44;
if (piez0 > 300) {
MIDImessage(noteON, hihat, 127);
delay(100);
MIDImessage(noteOFF, hihat, 127);
}
if (piez1 > 300) {
MIDImessage(noteON, snare, 127);
delay(100);
MIDImessage(noteOFF, snare, 127);
}
if (piez2 > 300) {
MIDImessage(noteON, crash, 127);
delay(200);
MIDImessage(noteOFF, crash, 127);
}
}
void MIDImessage(int command, int MIDInote, int MIDIvelocity) {
Serial.write(command);
Serial.write(MIDInote);
Serial.write(MIDIvelocity);
}