Hello,
I’m having trouble using the MIDI data I receive using The MidiBus. The problem is that I can’t use the data I receive; in example to create a shape. All I’m getting is a square displayed only 1 time and that’s all. Any help would be really appreciated. Thanks in advance
import themidibus.*;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.SysexMessage;
import javax.sound.midi.ShortMessage;
MidiBus myBus;
int pitch;
int velocity;
int place; //ignore this
int channel;
int p1; //serves as temp pitch
int v1; //serves as temp velocity
void setup() {
size(480, 108);
smooth();
MidiBus.list();
frameRate(60);
ellipseMode(CENTER);
myBus = new MidiBus(this, 2, 0);
}
void draw () {
noStroke();
fill(70, 10);
rectMode(CORNER);
rect(0, 0, width, height);
if (pitch == 46) {
fill(255);
ellipse(width/2, height/2, p1, p1);
} else if (pitch == 42) {
fill(255, 0, 0);
rectMode(CENTER);
rect(width/2, height/2, p1, p1);
} else if (p1 == 39) {
fill (0, 150, 190);
rectMode(CENTER);
rect(width/2, height/2, p1, p1);
} else if (p1 == 36) {
fill(0, 0, 255);
rectMode(CENTER);
rect(width/2, height/2, p1, p1);
}
if (v1 == 127) {
for (int i=0; i<5; i++) {
place = (width/4) *i;
if (i==4) {
i=0;
}
}
}
strokeWeight(5);
strokeCap(ROUND);
line(place, 0+height/10, place, height-height/10);
myBus.sendNoteOn(channel, pitch, velocity);
}
void noteOn(int channel, int pitch, int velocity) {
p1=pitch;
v1=velocity;
println("pitch : "+pitch);
println("velocity : "+velocity);
}