User Tools

Site Tools


cs276:handlemidi

This is an old revision of the document!


/* * Handle MIDI * * The notes array contains minimal MIDI note and duration information. JMEtude functions * handle creating a musical phrase using the MIDI data and playing the notes. */

import jmetude.*;

Etude e; float notes[][] = 60_1.0_62_1.0_64_1.0_65_1.0_67_1.0_69_1.0_71_1.0_72_4.0;

void setup() {

  noLoop();
  size(200,100);
  e = new Etude(this);
  e.createPhrase("phrase");
  e.addPhraseNoteList("phrase", notes);
  // uncomment this next line to play an existing midi file instead
  // e.createScore("score", "gfhblast.mid");

}

void draw() {

background(50);
PImage splash = loadImage("loading.gif");
image(splash, 0, 0);

}

void mousePressed() {

e.stopMIDI();
int inst = (int) random(0,127);
e.setPhraseInstrument("score", inst);
e.playMIDI("score");

}

cs276/handlemidi.1197405797.txt.gz · Last modified: 2007/12/11 14:43 by scarl