User Tools

Site Tools


cs276:handlemidi
/*
 *  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);
}
 
void draw() {
  background(50);
  PImage splash = loadImage("splash.gif");
  image(splash, 0, 0);
}
 
void mousePressed() {
  e.stopMIDI();
  int inst = (int) random(0,127);
  e.setPhraseInstrument("phrase", inst);
  e.playMIDI("phrase");
}
cs276/handlemidi.txt · Last modified: 2008/11/15 13:50 by scarl