We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › load and play MIDI file
Page Index Toggle Pages: 1
load and play MIDI file (Read 1264 times)
load and play MIDI file
Mar 16th, 2010, 1:21pm
 
How do I simply load and play a MIDI file?

It seems like many libraries let you mess around with the MIDI commands, but don't have a playback function. Am I wrong?
Re: load and play MIDI file
Reply #1 - Mar 17th, 2010, 7:45am
 
The Processing MIDIFILE reading support thread seems related...
The Music Video: Midi File Visualization threads might exhibit code solving this issue (haven't checked the code, just see the description...).
Re: load and play MIDI file
Reply #2 - Mar 17th, 2010, 9:12am
 
google "javax midi" for further docs, but essentially it looks something like this:

Quote:
import javax.sound.midi.*;
void setup() {
  try {
    File midiFile = new File(dataPath("whatever.mid"));
    Sequencer sequencer = MidiSystem.getSequencer();
    sequencer.open();
    Sequence sequence = MidiSystem.getSequence(midiFile);
    sequencer.setSequence(sequence);
    sequencer.start();
  } catch(Exception e) {}
}
Page Index Toggle Pages: 1