Go Down

Topic: midi library v2 question (Read 398 times) previous topic - next topic

fubbi

Sep 29, 2009, 02:39 am Last Edit: Sep 29, 2009, 03:32 am by fubbi Reason: 1
Hello

I am making a two button controller and have no midi interface here so I cant test it.

Can somebody please check this.

EDIT. This works fine, finally found a way of testing it but should it really be 255 instead of 127?



thanks
Code: [Select]
#include <MIDI.h>

int blackButton = 5;
int redButton = 8;
int redVal = 0;
int blackVal = 0;

void setup() {
 MIDI.begin();
 pinMode(blackButton, INPUT);
 pinMode(redButton, INPUT);
}

void loop(){

 blackVal = digitalRead(blackButton);
 if (blackVal == HIGH) {         // check if the input is HIGH (button released)
   MIDI.send(NoteOn,1,0,1); //will trigger note2 with 255 velocity on channel 1.
 }
 else {
   MIDI.send(NoteOn,1,127,1); //will trigger note2 with 0 velocity on channel 1.

 }


 redVal = digitalRead(redButton);
 if (redVal == HIGH) {         // check if the input is HIGH (button released)
   MIDI.send(NoteOn,2,0,1); //will trigger note2 with 255 velocity on channel 1.
 }
 else {
   MIDI.send(NoteOn,2,127,1); //will trigger note2 with 0 velocity on channel 1.
 }
}





Grumpy_Mike

Quote
should it really be 255 instead of 127?


What is 'it'

if it is this:-
Quote
//will trigger note2 with 255 velocity on channel 1.

There is no such thing as a velocity of 255 in MIDI, the maximum velocity is defined in 7 bits and is a value of only 127.

fubbi

hey yeah sorry unclear, thats what i meant

so definitely 127 then?

fubbi

fubbi

#3
Sep 30, 2009, 08:59 pm Last Edit: Sep 30, 2009, 09:53 pm by fubbi Reason: 1
EDIT: killing the ableton live prefs file did the job. everything works now



hi, so this is the code so far

garageband sees it, midimonitor sees it but ableton live sees no midi activity whatsoever...

is there something missing to make this fit the midiprotocol?


Code: [Select]
#include <MIDI.h>

int blackButton = 5;
int redButton = 8;
int blackButtonState = 0;
int redButtonState = 0;

void setup() {
 MIDI.begin();
 pinMode(blackButton, INPUT);
 pinMode(redButton, INPUT);
}

void loop(){
 
 int tempBlackState = digitalRead(blackButton);
 if(blackButtonState != tempBlackState){
   blackButtonState = tempBlackState;
   if (blackButtonState == HIGH) {         // check if the input is HIGH (button released)
     MIDI.send(NoteOff,1,0,1); //will trigger note2 with 255 velocity on channel 1.
   } else {
     MIDI.send(NoteOn,1,127,1); //will trigger note2 with 0 velocity on channel 1.
   }
 }

 int tempRedState = digitalRead(redButton);
 if(redButtonState != tempRedState){
   redButtonState = tempRedState;
   if (redButtonState == HIGH) {         // check if the input is HIGH (button released)
     MIDI.send(NoteOff,2,0,1); //will trigger note2 with 255 velocity on channel 1.
   } else {
     MIDI.send(NoteOn,2,127,1); //will trigger note2 with 0 velocity on channel 1.
   }
 }
}

}


Go Up