Hi All
New to this forum.
I am just starting out have moved from Arduino to Teensy for my second MIDI Vst controller. When I used a 5 pin port on arduino and monitored with MIDI OX I would only get CC messages when there was a control change. I wrote this little sketch below(I know its crude) and it does everything I expect except when monitoring in MIDIOX I get a continual stream of updates (the values remain the same until I press the button as expected) and then the new value is continually sent. Is this just the way usbMIDI works or is there something else going on? I'm concerned that this would be a huge data hog if midi data continually coming into my DAW ?
Thanks
Iain
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin_BLUE = 8; // the number of the LED pin
const int ledPin_YELLOW = 9;
const int ledPin_GREEN = 10;
// Variables will change:
int state = 1; // interger to hold current state
int old = 0; // interger to hold last state
int buttonPoll = 0; // interger to hold button state
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
pinMode(ledPin_BLUE, OUTPUT);
pinMode(ledPin_YELLOW, OUTPUT);
pinMode(ledPin_GREEN, OUTPUT);
// set initial LED state
digitalWrite(ledPin_BLUE, HIGH);
digitalWrite(ledPin_YELLOW, LOW);
digitalWrite(ledPin_GREEN, LOW);
}
void loop() {
buttonPoll = digitalRead(buttonPin); //read button pin
if (buttonPoll == 1){
delay(5);
buttonPoll = digitalRead(buttonPin);
if (buttonPoll == 0) {
state = old + 1;
}}
else{
delay(50);
}
switch (state) {
case 1:
digitalWrite(ledPin_BLUE, HIGH);
digitalWrite(ledPin_YELLOW, LOW);
digitalWrite(ledPin_GREEN, LOW);
usbMIDI.sendControlChange( 1, 0, 1);
usbMIDI.send_now();
old = state;
break;
case 2:
digitalWrite(ledPin_BLUE, LOW);
digitalWrite(ledPin_YELLOW, HIGH);
digitalWrite(ledPin_GREEN, LOW);
usbMIDI.sendControlChange( 1, 55, 1);
usbMIDI.send_now();
old = state;
break;
case 3:
digitalWrite(ledPin_BLUE, LOW);
digitalWrite(ledPin_YELLOW, LOW);
digitalWrite(ledPin_GREEN, HIGH);
usbMIDI.sendControlChange( 1, 127, 1);
usbMIDI.send_now();
old = 0;
}
// MIDI Controllers should discard incoming MIDI messages.
while (usbMIDI.read()) {
}
}
New to this forum.
I am just starting out have moved from Arduino to Teensy for my second MIDI Vst controller. When I used a 5 pin port on arduino and monitored with MIDI OX I would only get CC messages when there was a control change. I wrote this little sketch below(I know its crude) and it does everything I expect except when monitoring in MIDIOX I get a continual stream of updates (the values remain the same until I press the button as expected) and then the new value is continually sent. Is this just the way usbMIDI works or is there something else going on? I'm concerned that this would be a huge data hog if midi data continually coming into my DAW ?
Thanks
Iain
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin_BLUE = 8; // the number of the LED pin
const int ledPin_YELLOW = 9;
const int ledPin_GREEN = 10;
// Variables will change:
int state = 1; // interger to hold current state
int old = 0; // interger to hold last state
int buttonPoll = 0; // interger to hold button state
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
pinMode(ledPin_BLUE, OUTPUT);
pinMode(ledPin_YELLOW, OUTPUT);
pinMode(ledPin_GREEN, OUTPUT);
// set initial LED state
digitalWrite(ledPin_BLUE, HIGH);
digitalWrite(ledPin_YELLOW, LOW);
digitalWrite(ledPin_GREEN, LOW);
}
void loop() {
buttonPoll = digitalRead(buttonPin); //read button pin
if (buttonPoll == 1){
delay(5);
buttonPoll = digitalRead(buttonPin);
if (buttonPoll == 0) {
state = old + 1;
}}
else{
delay(50);
}
switch (state) {
case 1:
digitalWrite(ledPin_BLUE, HIGH);
digitalWrite(ledPin_YELLOW, LOW);
digitalWrite(ledPin_GREEN, LOW);
usbMIDI.sendControlChange( 1, 0, 1);
usbMIDI.send_now();
old = state;
break;
case 2:
digitalWrite(ledPin_BLUE, LOW);
digitalWrite(ledPin_YELLOW, HIGH);
digitalWrite(ledPin_GREEN, LOW);
usbMIDI.sendControlChange( 1, 55, 1);
usbMIDI.send_now();
old = state;
break;
case 3:
digitalWrite(ledPin_BLUE, LOW);
digitalWrite(ledPin_YELLOW, LOW);
digitalWrite(ledPin_GREEN, HIGH);
usbMIDI.sendControlChange( 1, 127, 1);
usbMIDI.send_now();
old = 0;
}
// MIDI Controllers should discard incoming MIDI messages.
while (usbMIDI.read()) {
}
}