Jan 22nd 2013

6 comments

Baremetal MIDI file player / LV2 synth host for the Raspberry Pi

This is a simple MIDI file player that runs directly on the Raspberry Pi hardware, ie. it doesn't run Linux or any OS (although I did end up implementing a bunch of sketchy POSIX functions). This means it's essentially an embedded project, and you can see from the video that it boots up more or less instantly.

I've learned a bit about doing baremetal hardware programming in C. It feels quite rewarding, and despite being primarily intended as a Linux computer the Pi is quite usable as an embedded device. If you're interested in that sort of thing, this is a good place to start looking.

Unless anybody knows different, this project breaks new ground in two ways:

  • It contains the first baremetal audio code for the pi. Unfortunately I was only partly able to figure out how this should be done. My code uses the 'oscillator' clock source for the PWM, which leads to fairly dreadful audio quality. If anybody knows how to make the PWM work with the 'PLLA' source used in Linux, I'd love to hear about it.
  • It's the first embedded implementation of an LV2 plugin host. It's a rather loose interpretation of the spec as there's no working filesystem yet, so dynamic linkage and runtime reading of .ttl files aren't possible.

The source and binaries are available here. It includes three fairly bad sounding synth plugins, which you can hear demoed in the video.

Next step is to hook it up to the MIDI keyboard you can briefly see in the video.

Thanks to David Welch for his baremetal pi tutorial on github, to Remo Dentato for his midi file code, to Dave Robillard for his LV2 work, and to Wayne Stallwood for lending me a Pi to work on. You are the wind beneath my wings.

Update: I got featured on hackaday.com! Cool.

6 comments

David Robillard said:

Awesome. Perhaps it's time to add a standard LV2 way to do fully static builds containing many plugins...

Joeboy said:

I agree that that would be a great addition. As far as I know there isn't a go-to standard for audio plugins on embedded devices, and maybe some kind of statically linked version of LV2 could fit nicely in that niche. I also fantasize about using ingen to design patches some hypothetical open stompbox / synth.

Jay Vaughan said:

Hi - my name is Jay Vaughan, and I'd like to put this baremetal LV2 plugin on the Open Pandora hardware. Modifications would be required to utilize the Pandora's Burr-Brown DAC .. but this is a highly useful target!

If anyone else is interested - please contact me or look for 'torpor' on the Open Pandora forums .. I'll try to work on this in my spare hacking time over the next week. The goal of having a barebone LV2 synth server in the Pandora is *very* exciting! :)

Joeboy said:

Hi Jay. I would love to see people port this to other platforms, and collaborate in general. I think the Pi's floating point performance (VFP) might be a bit of a limitation, hopefully platforms with newer CPUs and NEON will improve on that.

I don't have any time right now, but I'll try to get in touch at some point.

Sorry about my blog posting your comment multiple times, I really must fix that...

Jerome said:

Hi Joeboy ... and the wind under your wings team ;-)
Your project is exactly what i am looking for.
So many exiting things to do with it.

I'm going to build a "printed midi guitar" with a RepRap 3D printer (see this awesome printer on the net).

I will include a roland hexamidi pickup (Roland GK3) to convert magnetic field into a midi signal.

Will your raspberry Pi be able to receive midi signal via a midi connector in ?
For the not but also for the bank change and the midi modulations ?

Thank you for your answer and for your work !

Jerome

Matt said:

Did you get a chance to try this sort of functionality running on the Pi's OS? If so I assume that the performance was too poor for such functionality.

Comments are disabled. Blame spammers.