Automatically connecting multiple input devices via patchbox-module?

Hi,
I’ve got a rpi running patchbox that is connected to both a pisound and a usb soundcard. I am running a pd patch that successfully uses 4 inputs and 2 outputs. However, I need to connect the usb card each time via patchage or jack-connect. I’ve been trying to modify the puredata patchbox module for my purposes but can’t get the order of things right.

I’ve duplicated all the files in puredata-modules into a new folder in puredata-modules/imported/ and am making changes there. launch.sh now points directly to my pd project, and also tries to connect the soundcard via alsa_in and then jack_connect..

When I boot with this module, the usb device shows up in patchage, but it isn’t connected to puredata. Here’s my launch.sh file: Does anyone see any glaring errors or have hints for things to try?


#!/bin/sh

# Copyright (C) 2017-2018 Vilniaus Blokas UAB, https://blokas.io/pisound
# All rights reserved.
#
# This software may be modified and distributed under the terms
# of the BSD license.  See the LICENSE file for details.
#

. /usr/local/pisound/scripts/common/start_puredata.sh

PATCH = "/usr/local/puredata-patches/myproject/myproject.pd"
shift

echo
echo "$PATCH"
echo "$@"

(
	# Connect the osc2midi bridge to the MIDI Inputs and to Pure Data.
	sleep 4
	#/usr/local/pisound-ctl/connect_osc2midi.sh "pisound-ctl"
	#aconnect "pisound-ctl" "Pure Data";
	#aconnect -d "Pure Data:1" "pisound-ctl"
	#trying connect here:
	/usr/bin/alsa_in -j "teensy" -d hw:MIDIAudio /dev/null 
	sleep 4
	/usr/bin/jack_connect teensy:capture_1 pure_data:input_3> /dev/null &
	/usr/bin/jack_connect teensy:capture_2 pure_data:input_4> /dev/null &
) &

start_puredata "$PATCH" $@`