Hey Guys,
Fairly new to coding so apologies if this is an easy fix, I’ve been stumbling my way through this code up until this point.
Essentially, the code produces a circle - with size depending on what note it pressed and colour depending on how hard the note is pressed.
My question is: Is it possible to have an if(),while(),or for() statement that would identify a note that has been pressed, greater than one number BUT less than another, and run the code in that section.
i.e
if(note < 10 > 20)
ellipseMode(CENTER);
ellipse(x, y,note2, note2);
fill(HSB,vel2, vel2, 255);
noStroke();
import themidibus.*;
import javax.sound.midi.MidiMessage;
MidiBus myBus;
int currentColor = 0;
int midiDevice = 0;
int note = 0 ;
int vel = 0 ;
float x = random(1, 1920);
float y = random(1, 1080);
float left = 320 ;
float right = 960;
void setup() {
size(1920, 1080);
MidiBus.list();
myBus = new MidiBus(this, midiDevice, 1);
background(255);
}
void draw() {
ellipseMode(CENTER);
ellipse(x, y,note*2, note*2);
fill(HSB,vel*2, vel*2, 255);
noStroke();
rectMode(CENTER);
rect(x*2, y*2, note*2, note*2);
fill(HSB,vel*2, 255, vel*2);
noStroke();
}
void midiMessage(MidiMessage message, long timestamp, String bus_name) {
if(message.getMessage().length > 2){
note = (int)(message.getMessage()[1] & 0xFF) ;
vel = (int)(message.getMessage()[2] & 0xFF);
x = random(1, 1920);
y = random(1, 1080);
if(note == 64){
left = (vel * 5.04) + 640 ;
right = 1920 - left ;
}
println("Bus " + bus_name + ": Note "+ note + ", vel " + vel);
}
}
Any General help or ideas would be greatly appreciated!
(Ps. sorry if this is in the wrong section - new to the forum!)