Friday 31 August 2012

TTYMIDI on the Raspberry Pi

With Linux being Linux, there are several ways to do most things and MIDI over a serial port is no exception. On Intel X86 platform for example, ALSA comes with a snd-serial-u16550 driver, unfortunately at the time this is not supported on the Raspberry PI. There is however a simple alternative thanks to Thiago Teixeira who created ttymidi which creates a serial to ALSA interface.




I will not go into too much detail in this post as the basics are well covered at his site. The keyboard you can see is Virtual MIDI Piano Keyboard VMPK running on Windows 7 with a PuTTY remote shell.
 
 
sudo apt-get install libasound2-dev

wget http://www.varal.org/ttymidi/ttymidi.tar.gz
tar -zxvf ttymidi.tar.gz
cd ttymidi/
make
sudo make install




ttymidi -s /dev/ttyAMA0 -b 38400  &

Will run ttymidi in the back ground.


ttymidi -s /dev/ttyAMA0 -b 38400  -v

Will run ttymidi in verbose mode (midi traffic displayed on screen).


aconnect -iol

Will display available ALSA connecters, see fluidsynth

aconnect

Is used to connect inputs and outputs within ALSA.

aplaymidi -p 128:1 your_midid_file.mid will send a MIDI file to the MIDI out.




7 comments:

  1. Missing pthread library in Makefile

    ReplyDelete
  2. agreed. You need to add -lpthread to make file.

    ReplyDelete
  3. I've same problem, but don't know how to solve. What we are doing with -lpthread ? I've do this: make -lpthread but compiler returns an error. I'm a beginner, please help me. Thanks

    ReplyDelete
  4. @Massimo Meli: Do the following - "sudo nano Makefile", then add "-lpthread" to line "gcc src/ttymidi.c -o ttymidi -lasound"

    Source: https://zuzebox.wordpress.com/2015/12/13/setting-up-rpi-midi-and-fluid-synth-softsynth/

    ReplyDelete
  5. Many thanks, this worked perfectly. :D

    ReplyDelete
  6. I'm confused. If midi standard is specified for 31250 baud rate, then why ttymidi does not support that rate?

    ReplyDelete
  7. ttymidi acts as serial to AKSA bridge, 31250 is not a standard baudrate, so eg. it receive 38400 (that is standard baudrate) from other devices like Arduino

    ReplyDelete