Re: [PD] help on bash script
thanks, jack! Gesendet: Montag, 09. November 2020 um 14:00 Uhr Von: "Jack" An: pd-list@lists.iem.at Betreff: Re: [PD] help on bash script Here a bash script I used to use. You can adapt it for your needs : #!/bin/bash chemin1=$(dirname "$0")/PH.pd sudo etherwake C8:60:00:2D:48:50 sleep 1 pd -nosleep -noaudio -alsamidi -midiindev 0,1 -midioutdev 0 -open $chemin1 & sleep 1 KA=$(aconnect -i | grep "Pure Data") while [ "$KA" = "" ] do sleep 1 KA=$(aconnect -i | grep "Pure Data") done aconnect 'Pure Data':2 'UM-1':0 sleep 1 aconnect 'UM-1':0 'Pure Data':0 sleep 1 aconnect 'nanoKONTROL':0 'Pure Data':1 echo "//Done.//" ++ Jack Le 09/11/2020 à 13:25, Roman Haefeli a écrit : > On Mon, 2020-11-09 at 12:54 +0100, Jakob Laue wrote: >> Hey friends, >> i have a raspberry pi that executes a bash script on startup. Inside >> this bash script I want two things to happen. >> 1) start my pd patch >> 2) connect my launchpad mini (connected via usb) to pd using the >> aconnect-command >> >> >> ..i think i have to use aconnect because in pd itself i only see alsa >> midi as a midi device. >> >> >> At the moment, my bash script only looks like this: >> >> #!/bin/bash >> >> sudo /usr/local/bin/pd -nogui -rt -open >> /home/pi/Documents/RSP/RSP/myPatch.pd >> >> aconnect 'Pure Data':1 'Launchpad Mini':0 >> >> aconnect 'Launchpad Mini':0 'Pure Data':0 >> >> >> >> The problem is that the aconnect-commands seem to be not executed or >> executed too early because the virtual midi connections are not made. >> >> The aconnect-commands have to be done after pd is started, so how >> could I change the script to wait until pd is done loading? > > > Poor man's solution: > > put a 'sleep 5' after starting Pd. > > A slightly more advanced way: > > while ! aconnect --list | grep "Pure Data"; do sleep 0.1; > > Put that after firing up Pd. It continues only after "Pure Data" > appears in the list of available MIDI ports. > > Roman > > > ___ > Pd-list@lists.iem.at mailing list > UNSUBSCRIBE and account-management -> > https://lists.puredata.info/listinfo/pd-list > ___ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list[https://lists.puredata.info/listinfo/pd-list] ___ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Re: [PD] help on bash script
Gesendet: Montag, 09. November 2020 um 13:59 Uhr Von: "Peter P." An: pd-list@lists.iem.at Betreff: Re: [PD] help on bash script * Roman Haefeli [2020-11-09 13:25]: [...] > Poor man's solution: > > put a 'sleep 5' after starting Pd. This of course introduces a race condition. Might almost always work™. > A slightly more advanced way: > > while ! aconnect --list | grep "Pure Data"; do sleep 0.1; > > Put that after firing up Pd. It continues only after "Pure Data" > appears in the list of available MIDI ports. Which is much more elegant, thanks Roman. Note that this will cause confusion when more than one Pd instance is running. A possible command line flag to name a Pd instance for alsa-midi was discussed in the aforementioned thread. It seems that it did not get implemented in the end. Yes, that looks elegant indeed! I will try that, thanks! Regarding multiple instances of pd: For now I have not planned to run more than one instance of pd, so I think I am good with that for now:) ___ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list ___ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Re: [PD] help on bash script
Here a bash script I used to use. You can adapt it for your needs : #!/bin/bash chemin1=$(dirname "$0")/PH.pd sudo etherwake C8:60:00:2D:48:50 sleep 1 pd -nosleep -noaudio -alsamidi -midiindev 0,1 -midioutdev 0 -open $chemin1 & sleep 1 KA=$(aconnect -i | grep "Pure Data") while [ "$KA" = "" ] do sleep 1 KA=$(aconnect -i | grep "Pure Data") done aconnect 'Pure Data':2 'UM-1':0 sleep 1 aconnect 'UM-1':0 'Pure Data':0 sleep 1 aconnect 'nanoKONTROL':0 'Pure Data':1 echo "//Done.//" ++ Jack Le 09/11/2020 à 13:25, Roman Haefeli a écrit : > On Mon, 2020-11-09 at 12:54 +0100, Jakob Laue wrote: >> Hey friends, >> i have a raspberry pi that executes a bash script on startup. Inside >> this bash script I want two things to happen. >> 1) start my pd patch >> 2) connect my launchpad mini (connected via usb) to pd using the >> aconnect-command >> >> >> ..i think i have to use aconnect because in pd itself i only see alsa >> midi as a midi device. >> >> >> At the moment, my bash script only looks like this: >> >> #!/bin/bash >> >> sudo /usr/local/bin/pd -nogui -rt -open >> /home/pi/Documents/RSP/RSP/myPatch.pd >> >> aconnect 'Pure Data':1 'Launchpad Mini':0 >> >> aconnect 'Launchpad Mini':0 'Pure Data':0 >> >> >> >> The problem is that the aconnect-commands seem to be not executed or >> executed too early because the virtual midi connections are not made. >> >> The aconnect-commands have to be done after pd is started, so how >> could I change the script to wait until pd is done loading? > > > Poor man's solution: > > put a 'sleep 5' after starting Pd. > > A slightly more advanced way: > > while ! aconnect --list | grep "Pure Data"; do sleep 0.1; > > Put that after firing up Pd. It continues only after "Pure Data" > appears in the list of available MIDI ports. > > Roman > > > ___ > Pd-list@lists.iem.at mailing list > UNSUBSCRIBE and account-management -> > https://lists.puredata.info/listinfo/pd-list > signature.asc Description: OpenPGP digital signature ___ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Re: [PD] help on bash script
* Roman Haefeli [2020-11-09 13:25]: [...] > Poor man's solution: > > put a 'sleep 5' after starting Pd. This of course introduces a race condition. Might almost always work™. > A slightly more advanced way: > > while ! aconnect --list | grep "Pure Data"; do sleep 0.1; > > Put that after firing up Pd. It continues only after "Pure Data" > appears in the list of available MIDI ports. Which is much more elegant, thanks Roman. Note that this will cause confusion when more than one Pd instance is running. A possible command line flag to name a Pd instance for alsa-midi was discussed in the aforementioned thread. It seems that it did not get implemented in the end. cheers, P ___ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Re: [PD] help on bash script
On Mon, 2020-11-09 at 12:54 +0100, Jakob Laue wrote: > Hey friends, > i have a raspberry pi that executes a bash script on startup. Inside > this bash script I want two things to happen. > 1) start my pd patch > 2) connect my launchpad mini (connected via usb) to pd using the > aconnect-command > > > ..i think i have to use aconnect because in pd itself i only see alsa > midi as a midi device. > > > At the moment, my bash script only looks like this: > > #!/bin/bash > > sudo /usr/local/bin/pd -nogui -rt -open > /home/pi/Documents/RSP/RSP/myPatch.pd > > aconnect 'Pure Data':1 'Launchpad Mini':0 > > aconnect 'Launchpad Mini':0 'Pure Data':0 > > > > The problem is that the aconnect-commands seem to be not executed or > executed too early because the virtual midi connections are not made. > > The aconnect-commands have to be done after pd is started, so how > could I change the script to wait until pd is done loading? Poor man's solution: put a 'sleep 5' after starting Pd. A slightly more advanced way: while ! aconnect --list | grep "Pure Data"; do sleep 0.1; Put that after firing up Pd. It continues only after "Pure Data" appears in the list of available MIDI ports. Roman signature.asc Description: This is a digitally signed message part ___ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Re: [PD] help on bash script
* Jakob Laue [2020-11-09 12:54]: > Hey friends, > i have a raspberry pi that executes a bash script on startup. Inside this bash > script I want two things to happen. > 1) start my pd patch > 2) connect my launchpad mini (connected via usb) to pd using the > aconnect-command Have you tried searching for the keyword "aconnect" in the mailing list archive? See eg this thread https://lists.puredata.info/pipermail/pd-list/2015-05/110230.html It seems that [aconnect] is not found when using "Find externals". Its sources are in SVN at least. Dan's script from this thread https://lists.puredata.info/pipermail/pd-list/2014-01/105522.html is also nice! ___ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list