GarageBand USB MIDI Control with Processing

I am working towards my midterm project

3 USB MIDI controllers, but first I needed to figure out how to control the voices in a program (here using GarageBand, but will be using MainStage or Ableton Live soon) using Processing.  The video after this one shows how I control it with the Arduino as well.

Here is a video of the sketch:

and here is it WITH the Arduino:

Here is the code, you need to install RWMidi library into processing

//based on an example in the book and mixed with sound from the library rwmidi tweek by Amelia Winger-Bearskin
import rwmidi.*;

MidiOutput output;

// variables for note generation from keystrike
int aChannel, sChannel, dChannel, fChannel;
int aNote, sNote, dNote, fNote;
int aVelocity, sVelocity, dVelocity, fVelocity;
int aSuccess, sSuccess, dSuccess, fSuccess;
int circleWidth = 20;
int lastCircle = -1;

void setup()
size(720, 480);
colorMode(HSB, height, height, height);
output = RWMidi.getOutputDevices()[0].createOutput();  // talks to garageband

void draw()

void changebackground() {
if (keyPressed) {
void makecircles() {
int whichCircle = mouseX / circleWidth;
if (whichCircle != lastCircle) {
int circlerandom = whichCircle * circleWidth;
fill(mouseY, height, height);
ellipse(circlerandom, 0, circleWidth, height*2);
lastCircle = whichCircle;

void mouserollover() {

if (mouseX>width-200 || mouseY>height-200) {
aChannel = 1;
aNote = 62;
aVelocity = 100;
aSuccess = output.sendNoteOn(aChannel, aNote, aVelocity); // note return a variabel of type INT
if (mouseX<width-200 || mouseY<height-200)
{ ellipse(50,50,50,50);
sChannel = 1;
sNote = 65;
sVelocity = 100;
sSuccess = output.sendNoteOn(sChannel, sNote, sVelocity); // note return a variabel of type INT

Comments Are Closed