Ttymidi and puredata connect

I am very beginner in Rpi :slight_smile: I use pisound and patchbox.
I would like to connect arduino midi using ttymidi as a controller on puredata.
I’ve created a desktop file for autostart puredata and ttymidi. BUT it can’t be connected automatically.
This is my .sh
ttymidi -s /dev/ttyUSB0 -v &
echo “start lucibox”
/usr/bin/pd /home/patch/lucibox/machines/1/moon_loopstation.pd

I have to open a new terminal to do these 4 steps to connect ttymidi and pure data:

  1. aconnect -io // to see the connection of i/o of ttymidi and puredata
  2. aconnect 131:0 132:0 // connect ttymidi to pd
  3. aconnect 132:1 131:1 // connect pd to ttymidi
  4. these midi numbers change time after time.

Thank you in advance for the help.

What is the output of aconnect -io?

aconnect (as well as other ALSA MIDI software) accept substrings of the device names, so you may be able to use some more ‘constant’ identifier for your setup. It seems the substring is matched only from the start of the actual port name.

This is described in the documentation of snd_seq_parse_address:

Actually arg need to be only a prefix of the wanted client. That is, if a client named “Foobar XXL Master 2012” with number 128 is available, then parsing “Foobar” will return the address 128:0 if no other client is an exact match.

Hi @Giedrius ,

It changes constantly after reboot. For now
client 0: ‘System’ [type=kernel]
0 'Timer ’
1 'Announce ’
client 14: ‘Midi Through’ [type=kernel]
0 ‘Midi Through Port-0’
client 20: ‘pisound’ [type=kernel,card=1]
0 ‘pisound MIDI PS-21A9VQ4’
client 130: ‘pisound-ctl’ [type=user,pid=518]
0 'pisound-ctl ’
client 131: ‘Ttymidi’ [type=user,pid=1164]
1 ‘Ttymidi Midi-In’
0 ‘Ttymidi Midi-Out’
client 132: ‘Pure Data’ [type=user,pid=1175]
0 ‘Pure Data Midi-In 1’
1 ‘Pure Data Midi-Out 1’


aconnect Ttymidi:0 "Pure Data:0"
aconnect "Pure Data:1" Ttymidi:1

It helps! Thank you
Yesterday I tried your suggestions to adjust the .sh:
ttymidi -s /dev/ttyUSB0 -v &
echo “start lucibox”
/usr/bin/pd /home/patch/lucibox/machines/1/moon_loopstation.pd &
sleep 2.5
aconnect 131:0 132:0
aconnect 132:1 131:1

But nothing happens. The pd started the moon_loopstation and it closed again (also the terminal)
How can I start the ttymidi, pd file and make connection in a sequence?

ttymidi -s /dev/ttyUSB0 -v &
echo "start lucibox"
sleep 2.5
echo "Connecting MIDI"
aconnect Ttymidi:0 "Pure Data:0"
aconnect "Pure Data:1" Ttymidi:1
) &
/usr/bin/pd /home/patch/lucibox/machines/1/moon_loopstation.pd 

@Giedrius Thank you again. I’ll try later I have to go now :slight_smile: I will let you know

@Giedrius the code works! Thank you

1 Like