First post, by gdjacobs
- Rank
- l33t++
I've been working on and off on a project to add some additional capability to my Retro K6-2 machine, in particular the ability to play both GM/GS and LA midi using a compact equipment setup. My ultimate plan is to build an SBC into a 5 1/4 drive mount with an LCD message panel and basic controls on the front to use as a universal MIDI module.
The major unknown element of this project was which SBC would be best considering cost, capability, and form factor. I had previously tested Munt on an n270 Atom based netbook with some success, but I was unsure if ARM compilers would be efficient enough to allow Munt to run in realtime on any of the inexpensive SBCs available, the most obvious candidate being the Raspberry Pi 2.
After some tinkering and several long interruptions, I've achieved a measure of success and wanted to document my installation in case anyone wishes to use similar hardware to emulate Munt with their own systems.
I'm assuming your RPi2 has already been installed and configured using Raspbian. I began with a Debian Wheezy based version, then updated to Debian Jessie (latest stable) for more a up to date GCC and GlibC. I recommend you use this release as well.
Munt is fairly CPU intensive, so perform a couple of checks to ensure your CPU is operating at full power. Do the following as root.
# Pin the CPU by computing some digits of Pi
echo "scale=10^6; 4*a(1)" | bc -l &
# Measure the current CPU core clock
vcgencmd measure_clock arm
# This should be 900000000 for a Pi 2, higher for the more powerful models.
# Check for any thermal or voltage events.
vcgencmd get_throttled
# A healthy return is 0x0 indicating voltage and thermals are stable and in spec.
# 0x50000 indicates undervoltage has happened previously, but the CPU is clocked
# normally right now. 0x50005 indicates the CPU is currently throttled due to
# undervoltage. Other combinations indicate thermal issues as well.
killall bc
One important tool normally included in Raspbian but not in some cut down distros is cpufrequtils. If your CPU is underclocked, voltage and thermal issues don't appear to be a problem, and the CPU isn't manually underclocked in /boot/config.txt, this may be the culprit. Make sure it is installed.
apt-get install cpufrequtils
In terms of build requirements, I first installed the standard Debian build depends, cmake, Portaudio headers, some X headers, and QtMobility headers:
apt-get install build-essential cmake portaudio19-dev qtmobility-dev libglib2.0-dev libx11-dev libxt-dev libxpm-dev
Newer Debian versions (and workalikes such as Raspbian and Ubuntu) don't feature qtmobility, so please install qtmultimedia5-dev instead.
apt-get install git build-essential cmake portaudio19-dev qtmultimedia5-dev libglib2.0-dev libx11-dev libxt-dev libxpm-dev
Versions of qtmultimedia including 5.10 and newer already depend on libglib2.0-dev. If this applies to your case, you may exclude libglib2.0-dev and have it be managed automatically.
Feel free to add other libraries for JACK or Pulseaudio, depending what you're going to use.
Munt doesn't really enable any optimizations by default, so I used some settings recommended by ARM for the Cortex A7 (get them here) in concert with the general optimizer.
export CCFLAGS="-Ofast -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard"
export CXXFLAGS="-Ofast -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard"
If you're using an ARMv8 processor, such as the Cortex A53 in a Pi3 with a 64 bit build, please use the following flags.
export CCFLAGS="-Ofast -mcpu=cortex-a53"
export CXXFLAGS="-Ofast -mcpu=cortex-a53"
O2 can be used here instead of Ofast, but I'm more interested in speed than strict adherence to IEEE floating point.
Download the latest source version of Munt and unpack it to a directory of your choosing. As I used the master git branch of Munt, I labeled the source directory munt-master. Furthermore, I have created a build directory entitled munt-build at the same level as the source directory.
Next, configure the build directory using cmake. From the build directory:
cmake -DCMAKE_BUILD_TYPE=Release ../munt-master
Finally, run the make process.
make -j 4
sudo make install
Lastly, in the source directory, there is a subdirectory with two lightweight utilities designed to listen exclusively for incoming sequencer connections without any menus or dialogs for selecting MIDI files. One, xmt32, has a message display for the Pi's graphical output, the other, mt32d, outputs messages to the terminal. My eventual plan is to create a version of mt32d that outputs SYSX messages to a small LCD panel via GPIO, but "lightweight" seems like a good idea for the time being.
Go to the directory in question and build the software:
cd ../munt-master/mt32emu_alsadrv
make
At this stage, if you try to install the programs in question, you will receive an error message. You must unpack your MT32 roms (at least one of MT32_CONTROL.ROM and MT32_PCM.ROM or CM32L_CONTROL.ROM and CM32L_PCM.ROM) into a subdirectory of the mt32emu_alsadrv folder
called roms.
Last, install the final two executables.
sudo make install
This will also install your MT32 roms to /usr/share/mt32-rom-data.
You should be up and running with all three existant options to use Munt. I'm seeing 60% usage on a single core using this type of install, so you should have plenty of horsepower to run DOS emulators or other utility programs on the other three cores in the CPU.
Edit:
Based on reports from jaffa225man, this install method seems to be applicable for the RPi3 when using 32 bit userland (current Raspbian build). If Raspbian is updated to support a 64 bit userland and build toolchain, this will have to be revisited.
Added flags for an RPi3 with a 64 bit userland and small changes required for Debian Stretch (and Buster).
========= USEFUL DOWNLOADS =========
Ready to go disk images. Use any raw writing method to copy to an SD card (minimum 8gb). Follow the steps to copy ROM files as above to get working Munt.
For an RPi2:
Roland MT-32, CM-32L + General MIDI for $50 Building a MIDI box
For an RPi3:
Roland MT-32, CM-32L + General MIDI for $50 Building a MIDI box
All hail the Great Capacitor Brand Finder