Pi-based MIDI Show Controller


7 posts
by Douglas6 » Thu May 02, 2013 1:33 am
I saw this project http://www.raspberrypi.org/archives/2688#comments this morning, a MIDI music player with synchronized Christmas lights, and I thought first, no reason the MIDI control track had to supply the audio too, as long as they are in synch. Then I thought more generally about a MIDI track controlling 8 or more line voltages, and I wondered if this was an interesting project for my Pi. Some years ago I wrote a Java MIDI player/editor http://www.dkographicdetails.com/midium/ (free, and worth every penny), so I wondered if it would run on a Pi. I Loaded up OpenJDK, and sure enough it runs, though unacceptably slowly. But I plugged in an AKAI MPD18 pad controller, and it was recognized out-of-the-box. so it got me thinking...

What are folks thoughts on a Pi-based, MIDI-controlled, 8 or 16-outlet relay controller, for use with a Christmas lights display, DJ gig, or even live performance application? I'm thinking a MIDI pad controller that could fire off one-shot or sequenced loops of line voltage control (ok, just on-off), possibly with a master clock (tempo)? Technically, it seems very doable, but does it makes sense? MIDI Show Control (kinda) for the masses? And is Java-on-a-Pi up to the task?
I'm a programmer, not a performer or EE, so I'd love to hear of any interest or experience along these lines.
User avatar
Posts: 483
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL
by xranby » Thu May 02, 2013 9:54 am
Douglas6 wrote:I saw this project http://www.raspberrypi.org/archives/2688#comments this morning, a MIDI music player with synchronized Christmas lights, and I thought first, no reason the MIDI control track had to supply the audio too, as long as they are in synch. Then I thought more generally about a MIDI track controlling 8 or more line voltages, and I wondered if this was an interesting project for my Pi. Some years ago I wrote a Java MIDI player/editor http://www.dkographicdetails.com/midium/ (free, and worth every penny), so I wondered if it would run on a Pi. I Loaded up OpenJDK, and sure enough it runs, though unacceptably slowly. But I plugged in an AKAI MPD18 pad controller, and it was recognized out-of-the-box. so it got me thinking...

What are folks thoughts on a Pi-based, MIDI-controlled, 8 or 16-outlet relay controller, for use with a Christmas lights display, DJ gig, or even live performance application? I'm thinking a MIDI pad controller that could fire off one-shot or sequenced loops of line voltage control (ok, just on-off), possibly with a master clock (tempo)? Technically, it seems very doable, but does it makes sense? MIDI Show Control (kinda) for the masses? And is Java-on-a-Pi up to the task?
I'm a programmer, not a performer or EE, so I'd love to hear of any interest or experience along these lines.



When testing OpenJDK try all the available JVM.
The default JVM zero is used because lets Rasbian build all the java packages inside the archive, but if you use OpenJDK in combination with one of the alternative JVM such as JamVM, avian or CACAO you will get better performance.
Try it using
java -jamvm
java -cacao
java -avian
after you have the required jvm packages installed.

Distributions like Rasbian should consider switching the default JVM inside openjdk to JamVM since it offers at least twice the performance and is stable enough to rebuild the archive. JamVM have been used as the default OpenJDK JVM for building the Ubuntu Oneiric archive on ARM so this is known to work.
viewtopic.php?f=81&t=27805 - list of java JVM alternatives to use.
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby
User avatar
Posts: 401
Joined: Sat Mar 03, 2012 10:02 pm
by xranby » Thu May 02, 2013 10:39 am
midi initialization in OpenJDK take quite a while to complete the reason why is that Gervill the midi implementation inside Oracle JDK and OpenJDK is generating an, several megabytes large, "emergency"-sound-bank on start-up for use by the Gervill software-synthesizer on devices without a hardware midi implementation.

Gervill is written by Karl Helgason, you may watch his presentation from FOSDEM 2009 where he describe the Gervill generation of the emergency sound-bank. According to Karl there is a way to insert a pre-generated high quality "SoundFonts" soundbank into Gervill and this will prevent the generation of the emergency soundbank at start-up and give higher quality midi sounds.
The Emergency soundbank is described 7min:20sec into the talk
http://archive.org/details/fosdem_2009_ ... ynthesizer

The quick ways to fix initialization is to
A) figure out how to download and give gervill an "free" SoundFonts soundbank to prevent the start-up delay. (there is no known opensource SoundFont soundbank thus therefore we can not bundle any pre-generated sound bank with the OpenJDK packages.) Actually this may be solved by providing a package that contains the pre-generated Gervill emergency soundbank written to disk.
B) improve the Gervill implementation start-up inside the OpenJDK source code, it quite possible that we may tune the defaults to better suit the raspberry pi needs.
Last edited by xranby on Thu May 02, 2013 1:41 pm, edited 1 time in total.
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby
User avatar
Posts: 401
Joined: Sat Mar 03, 2012 10:02 pm
by Douglas6 » Thu May 02, 2013 12:52 pm
Thank you Xerxes for the excellent information. I was planning to try Oracle next (I had problems with MIDI under OpenJDK years ago) , but first I'll give the alternate VMs you mentioned a try. On my Ubuntu box I use a soundfont from http://www.personalcopy.com ("free for non-commercial use") for quality; I'll try it on the pi for speed. This app I'm thinking of will not include a synthesizer, though.
Next: any tips for accessing I2C with Java?
User avatar
Posts: 483
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL
by xranby » Thu May 02, 2013 12:56 pm
Douglas6 wrote:Thank you Xerxes for the excellent information. I was planning to try Oracle next (I had problems with MIDI under OpenJDK years ago) , but first I'll give the alternate VMs you mentioned a try. On my Ubuntu box I use a soundfont from http://www.personalcopy.com ("free for non-commercial use") for quality; I'll try it on the pi for speed. This app I'm thinking of will not include a synthesizer, though.
Next: any tips for accessing I2C with Java?


For all I2C java needs use Pi4J
http://pi4j.com/
viewtopic.php?f=34&t=25346 - Pi4J I2C examples
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby
User avatar
Posts: 401
Joined: Sat Mar 03, 2012 10:02 pm
by xranby » Thu May 02, 2013 1:00 pm
http://midi-clorianos.blogspot.se/2011/ ... -free.html - SoundFonts want to be free
Code to pre-generate a .sf2 SoundFonts soundbank using Gervill!
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby
User avatar
Posts: 401
Joined: Sat Mar 03, 2012 10:02 pm
by Tom Swirly » Wed May 15, 2013 3:32 am
If you want to do lights, you can control those LPD8806 lighting strings from the RP, giving you possibly hundreds of individually controllable RGB LEDs from the RP.

In my rig, I have 240 lights and I can update them all 1300 times a second from Python. And the stuff is pretty cheap, about $0.50 per light.

My main project, [url=github.com/rec/echomesh]echomesh[/url], has a pattern generator that can control these lights, as well as a C++ visualizer that lets you program your patterns on your desktop machine and then transfer them to your RP. (Note: it should all theoretically work on the PC but I'm only doing builds for the Mac and the RP...)

I'm in the last stages of the beta for this, but it works really nicely...
Posts: 160
Joined: Tue Sep 25, 2012 1:08 am