Skip to content

Instantly share code, notes, and snippets.

@CarloCattano
Last active August 15, 2023 04:23
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Raspberry pi UART MIDI Serial

rp3.+ raspberry OS lite (or better PatchboxOS as a starting point)

https://blokas.io/patchbox-os/

testing notes
Disable bluetooth or send bt to another serial port
    sudo nano /boot/config.txt

    enable_uart=1    
   
    dtoverlay=midi-uart0
midi-uart0 ttymidi will set Serial S&R MIDI at 31250 when using 38400 baudrate automatically

Remove UART serial shell option in boot/cmdline.txt

   sudo nano /boot/cmdline.txt
      delete:    
            console=serial0,115200 console=tty1

Disable Bluetooth

    dtoverlay=disable-bt
    sudo systemctl disable hciuart.service
    sudo systemctl disable bluealsa.service
    sudo systemctl disable bluetooth.service

OR move Bluetooth to other serial port

    dtoverlay=pi3-miniuart-bt 

install wiringpi ( optional )

    sudo apt-get install wiringpi
    gpio readall    (check tty dev tx rx)

download and install ttymidi to access pi serial http://www.varal.org/ttymidi/

    wget http://www.varal.org/ttymidi/ttymidi.tar.gz

    tar -zxvf ttymidi.tar.gz

    cd ttymidi/

    nano Makefike
    add -lpthread in "all:"

    make
    sudo make install

start serial midi and stay in background

    ttymidi -s /dev/ttyAMA0 -b 38400 -v &   // It will s&r at 31250 since midi-uart0

change midi device name

    ttymidi -s /dev/ttyAMA0 -v -n device_name

Depending on your setup you can manage ttymidi midi port instance after creation with ALSA MIDI or JACK

send the ALSA midi to Jack Midi for system messages (clock etc) to pass through as well
    a2jmidid

ALSA - list and connect to available ALSA MIDI input clients

    aconnect -l    aconnect id:0 id2:1                     

Connect TX/RX/GND (use midi specs circuitery for protection etc)

https://www.midi.org/specifications-old/item/midi-din-electrical-specification <-----

TX RX PINS ON THE PI ( Check your model , tested rpi3B+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment