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.
Page Index Toggle Pages: 1
Midi file playback? (Read 1259 times)
Midi file playback?
Mar 30th, 2009, 4:06pm
 
Hi,

I've been looking through the sound libraries for a simple midi file playback function.  Just want to drop a midi file into the data folder and loop it as background music.  I know it works if I convert it to .aiff/.wav/.mp3 but I'd like to keep the load time low.

The other question is, would I be better off converting the .mid files to mp3 and using Minim for playback?  I want the graphics to be running as fast as possible, so if midi playback would be processor-intensive I'll settle for a longer load time.

Thanks,
Ben
Re: Midi file playback?
Reply #1 - Mar 31st, 2009, 1:04am
 
Update: got Jm-Etude to play a midi file pretty painlessly:

 Etude e = new Etude(this);
 e.createScore("score","[insert .mid file URL here]");
 e.playMIDI("score");

only problem is, it only works with URLs.  Doesn't seem to find files in the data folder or by their absolute file path.  Which is fine until I want to export an app that can be used offline.  Anyone have experience with this?


Thanks,
Ben

edit: Etude seems to have problems with some midi files (changes tempo and doesn't always include all voices), but it's still a big step forward.
Re: Midi file playback?
Reply #2 - Mar 31st, 2009, 3:35pm
 
you can get it to read files in your sketch path like this:

Etude e = new Etude(this);
e.createScore("score", this.sketchPath + "/data/[insert .mid filename here]");
e.playMIDI("score");

Ken
Re: Midi file playback?
Reply #3 - Apr 1st, 2009, 6:38pm
 
Thanks, Ken!

At this point, though, I am moving away from jm-Etude (at the author's suggestion) and toward integrating this:

http://www.jsresources.org/examples/LoopingMidiPlayer14.html

but I am hitting a wall.  I have the .java file included in my sketch as a tab, and it seems to mesh without errors.  But I don't know how to actually create a LoopingMidiPlayer14 object and get it started.

Any suggestions?  Thanks,
Ben
Re: Midi file playback?
Reply #4 - Apr 2nd, 2009, 6:29am
 
Problem solved:
modified the script a bit and called "main" manually.  Added stop, restart, and url functions and got a decent looping midi jukebox.
Page Index Toggle Pages: 1