Setting up RPi MIDI #2

July 27, 2017

In a previous post on setting MIDI baud-rates on the RPi I used a slight of hand (i.e. init_uart_clock etc.) to trick the RPi in setting the UART to a 31250 baud needed for MIDI. While browsing the Raspberry Pi forum I spotted this nugget of information from PhilE:

in config.txt add:

enable_uart=1
dtoverlay=pi3-miniuart-bt
dtoverlay=midi-uart0

 

This combination does three things:

1) Enables the UART. It isn’t strictly necessary when combined with pi3-miniuart-bt
2) Reassigns the weaker UART (ttyS0) for Bluetooth and frees ttyAMA0 for our MIDI interface
3) Using an DT overlay to achieve the same UART clock settings as our init_uart_clock etc. trick

It makes things a lot simpler 🙂


Zero MIDI

December 26, 2016

A quick teaser for my next Raspberry Pi MIDI project:

 


Four new Raspberry Pi Zero add-on boards

January 18, 2016

Another bunch of new PCB’s. This time for the Raspberry Pi Zero.

RPI_PCBs_201601_small

In no particular order, there’s a serial RS232 board, a GVS I/O board with ULN2803 for servo’s etc., a Breakout board (I2C, SPI, UART and GPIO) and another MIDI interface ;-).

More details/info shortly.

As usually you’ll find them on our Tindie store.


Setting up RPi MIDI and Fluid Synth (SoftSynth)

December 13, 2015

The first part of this post are some instructions I wrote back in 2014 (more here)

NOTE: Setting the 31250 baud-rate this way only works for Raspbian kernel 3.18.11, the newer kernel Raspbian 4.xx has some issues.

Getting a MIDI 31250 Baud Rate on a Pi is not easy as it should be as 31250 is not a standard Pi baud-rate. But you can trick your Pi into it if you overclock (or rather underclock) the UART clock.

Start a terminal session and type:

sudo nano /boot/config.txt

Add these lines to the end of the file

# Change UART clock to 2441406 for MIDI 31250 baud rate
 
init_uart_clock=2441406
init_uart_baud=38400

save and exit.

Once saved reboot your Pi.

Next we need to stop the serial UART being used by Raspbian for the shell console. Check my previous post “MiniPIiio RS232 set-up” on how to do this.

Finally we need to add the following to “cmdline.txt”

bcm2708.uart_clock=3000000

 

Once we’ve done this we can get on with installing the MIDI UART driver and the SoftSynth.

  1. Check audio ports & levels
  2. Install MIDI UART driver
  3. Install SoftSynth
  4. Get MIDI IN talking to SoftSynth

Open up a terminal window and first..

 

1. Check audio ports and levels

Use HDMI audio for sound

amixer cset numid=3 2

Check the volume if needed

alsamixer

 

2. Install MIDI UART Driver

sudo apt-get install libasound2-dev
wget http://www.varal.org/ttymidi/ttymidi.tar.gz
tar -zxvf ttymidi.tar.gz
cd ttymidi/

We need to modify the make file for the Raspberry Pi, so lets

sudo nano Makefile

add -lpthread to line

gcc src/ttymidi.c -o ttymidi -lasound

so it looks like

gcc src/ttymidi.c -o ttymidi -lasound -lpthread

save file with “ctrl-x” and “Y”

Lets run the Make file and install binary

make

sudo make install

 

3. Install Fluidsynth

sudo apt-get install fluidsynth

err, that’s it just wait into it downloads and installs its self.

 

4. Get MIDI IN talking to SoftSynth

Start MIDI UART driver

ttymidi -s /dev/ttyAME0 -b 38400 &

Start the SoftSynth

fluidsynth --audio-driver=alsa /usr/share/sounds/sf2/FluidR3_GM.sf2

Check what devices they are listed as

aconnect -io

With device numbers connect MIDI IN to SoftSynth using “aconnect xx:x yy:y” for example:

aconnect 128:0 129:0

New RPi MIDI board and a new MIDI Breakout board

December 13, 2015

RPi_PIIO_MIDI_PCB

I should have called this post “yet-another RPi MIDI board” as it’s includes my third iteration of a MIDI interface for the Pi. But YARMB doesn’t actually trip off the tongue 🙂

So here we have a new RPi MIDI board. Briefly its spec is:

  • MIDI IN via 5-W DIN Connector
  • MIDI OUT via 5-W DIN Connector
  • 3.3V Operation
  • HAT foot print (65 x 56mm).
  • Four fixing holes.
  • ID EEPROM (not fitted)

 

In addition to the RPi MIDI, there’s also a MIDI break out board (BoB) board. It’s spec is:

  • MIDI IN via 5-W DIN Connector
  • MIDI OUT via 5-W DIN Connector
  • MIDI THRU via 5-W DIN Connector
  • On board 5V Voltage Regulator
  • Size 80 x 49mm.
  • Four fixing holes.

 


Raspberry Pi MiniPIIO MIDI board

June 26, 2014

I design my first Pi MIDI interface way back in 2012 while I was waiting for my first Pi board to arrive.

It’s went through several revisions since then and now looks like this:

RPi_MiniPiio_MIDI_small

RPi_MiniPiio_MIDI_Front_small

The circuit is now completely 5V as per the original MIDI specification but the MIDI IN is 3.3V compatible with the Pi via a voltage divider circuit.

OK that’s the hardware what about the software?

Getting a MIDI 31250 Baud Rate on a Pi is not easy as it should be as 31250 is not a standard Pi baud-rate. But you can trick your Pi into it if you overclock (or rather underclock) the UART clock.

Start a terminal session and type:

sudo nano /boot/config.txt

Add these lines to the end of the file

# Change UART clock to 2441406 for MIDI 31250 baud rate

init_uart_clock=2441406
init_uart_baud=38400

save and exit.

Once saved reboot your Pi.

Next we need to stop the serial UART being used by Raspbian for the shell console. Check my previous post “MiniPIiio RS232 set-up” on how to do this.

Finally we need to add the following to “cmdline.txt”

bcm2708.uart_clock=3000000

After doing all of this we should be ready to connect a MIDI keyboard or synth to our Pi.

 

Again I hope to have it stocked in out our store on Tindie soon:

https://www.tindie.com/stores/DTronixs/