Pages: [1]   Go Down
Author Topic: midi library v2 question  (Read 374 times)
0 Members and 1 Guest are viewing this topic.
berlin
Offline Offline
Full Member
***
Karma: 0
Posts: 154
fubbi.com
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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.
  }
}



« Last Edit: September 28, 2009, 08:32:39 pm by fubbi » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33387
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

berlin
Offline Offline
Full Member
***
Karma: 0
Posts: 154
fubbi.com
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hey yeah sorry unclear, thats what i meant

so definitely 127 then?

fubbi
Logged

berlin
Offline Offline
Full Member
***
Karma: 0
Posts: 154
fubbi.com
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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.
    }
  }
}

}
« Last Edit: September 30, 2009, 02:53:40 pm by fubbi » Logged

Pages: [1]   Go Up
Jump to: