multiple usb soundcards - redFrik/supercolliderStandaloneRPI2 GitHub Wiki

this page describes how to use two cheap generic audio usb cards to get 2 input and 4 output sound channels simultaneously from supercollider.

it is assumed you have supercolliderStandaloneRPI2 installed, have the two usb soundcards connected and is logged in to the pi via ssh.

short version

  • export DISPLAY=:0.0
  • jackd -P75 -dalsa -dhw:1 -p1024 -n3 -s -r44100 &
  • alsa_in -j "myusbin" -dhw:2 -p1024 -n3 -c1 -r44100 &
  • alsa_out -j "myusbout" -d hw:2 -p1024 -n3 -c2 -r44100 &
  • cd supercolliderStandaloneRPI2
  • ./sclang -a -l sclang.yaml
  • s.options.numInputBusChannels= 2
  • s.options.numOutputBusChannels= 4
  • s.boot
  • "jack_connect SuperCollider:in_2 myusbin:capture_1 &".unixCmd
  • "jack_connect SuperCollider:out_3 myusbout:playback_1 &".unixCmd
  • "jack_connect SuperCollider:out_4 myusbout:playback_2 &".unixCmd
  • a= Pbind(\degree, Pseq([0, 1, 2, 3], inf), \amp, 0.5, \pan, -1, \out, Pseq([0, 1, 2, 3], inf)).play
  • a.stop

long version

same but with additional commands and printouts to show the whole process.

pi@rpi3:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
 Subdevices: 8/8
 Subdevice #0: subdevice #0
 Subdevice #1: subdevice #1
 Subdevice #2: subdevice #2
 Subdevice #3: subdevice #3
 Subdevice #4: subdevice #4
 Subdevice #5: subdevice #5
 Subdevice #6: subdevice #6
 Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
 Subdevices: 1/1
 Subdevice #0: subdevice #0
card 1: Device [Generic USB Audio Device], device 0: USB Audio [USB Audio]
 Subdevices: 1/1
 Subdevice #0: subdevice #0
card 2: Device_1 [Generic USB Audio Device], device 0: USB Audio [USB Audio]
 Subdevices: 1/1
 Subdevice #0: subdevice #0

pi@rpi3:~ $ export DISPLAY=:0.0
pi@rpi3:~ $ jackd -P75 -dalsa -dhw:1 -p1024 -n3 -s -r44100 &
[1] 1117
pi@rpi3:~ $ jackdmp 1.9.10
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2014 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
JACK server starting in realtime mode with priority 75
self-connect-mode is "Don't restrict self connect requests"
audio_reservation_init
Acquire audio card Audio1
creating alsa driver ... hw:1|hw:1|1024|3|44100|0|0|nomon|swmeter|soft-mode|32bit
configuring for 44100Hz, period = 1024 frames (23.2 ms), buffer = 3 periods
ALSA: final selected sample format for capture: 16bit little-endian
ALSA: use 3 periods for capture
ALSA: final selected sample format for playback: 16bit little-endian
ALSA: use 3 periods for playback

pi@rpi3:~ $ alsa_in -j "myusbin" -dhw:2 -p1024 -n3 -c1 -r44100 &
[2] 1151
selected sample format: 16bit
delay = 4009

pi@rpi3:~ $ alsa_out -j "myusbout" -d hw:2 -p1024 -n3 -c2 -r44100 &
[2] 1126
selected sample format: 16bit

pi@rpi3:~ $ jack_lsp
system:capture_1
system:playback_1
system:playback_2
myusbin:capture_1
myusbout:playback_1
myusbout:playback_2

pi@rpi3:~ $ cd supercolliderStandaloneRPI2
pi@rpi3:~/supercolliderStandaloneRPI2 $ ./sclang -a -l sclang.yaml
init_OSC
compiling class library...
initPassOne started
libEGL warning: DRI2: failed to authenticate
	NumPrimitives = 728
initPassOne done
	compiling dir: './share/system/SCClassLibrary'
	compiling dir: './share/system/Extensions'
	pass 1 done
	numentries = 1202792 / 17545780 = 0.069
	5449 method selectors, 3220 classes
	method table size 9153048 bytes, big table size 70183120
	Number of Symbols 14104
	Byte Code Size 414244
	compiled 441 files in 1.53 seconds

Info: 4 methods are currently overwritten by extensions. To see which, execute:
MethodOverride.printAll

compile done
Class tree inited in 0.08 seconds
Cleaning up temp synthdefs...
WARNING: Extension in './share/system/SCClassLibrary/Platform/linux/extMIDIOut.sc' overwrites Meta_MIDIClient:externalSources in main class library.
WARNING: Extension in './share/system/SCClassLibrary/Platform/linux/extMIDIOut.sc' overwrites Meta_MIDIClient:externalDestinations in main class library.
WARNING: Extension in './share/system/SCClassLibrary/Platform/linux/extMIDIOut.sc' overwrites Meta_MIDIIn:connectAll in main class library.
Intentional overwrites must be put in a 'SystemOverwrites' subfolder.


*** Welcome to SuperCollider 3.8.0. *** For help type ctrl-c ctrl-h (Emacs) or :SChelp (vim) or ctrl-U (sced/gedit).
sc3> s.options.numInputBusChannels= 2
-> a ServerOptions
sc3> s.options.numOutputBusChannels= 4
-> a ServerOptions
sc3> s.boot
booting 57110
-> localhost
sc3> Found 0 LADSPA plugins
JackDriver: client name is 'SuperCollider'
SC_AudioDriver: sample rate = 44100.000000, driver's block size = 1024
JackDriver: connected  system:capture_1 to SuperCollider:in_1
JackDriver: connected  SuperCollider:out_1 to system:playback_1
JackDriver: connected  SuperCollider:out_2 to system:playback_2
SuperCollider 3 server ready.
JackDriver: max output latency 69.7 ms
Receiving notification messages from server localhost
Resetting recChannels to 4
Shared memory server interface initialized

sc3> "jack_connect SuperCollider:in_2 myusbin:capture_1 &".unixCmd
-> 1353
sc3> RESULT = 0

sc3> "jack_connect SuperCollider:out_3 myusbout:playback_1 &".unixCmd
-> 1359
sc3> RESULT = 0

sc3> "jack_connect SuperCollider:out_4 myusbout:playback_2 &".unixCmd
-> 1364
sc3> RESULT = 0

sc3> a= Pbind(\degree, Pseq([0, 1, 2, 3], inf), \amp, 0.5, \pan, -1, \out, Pseq([0, 1, 2, 3], inf)).play
-> an EventStreamPlayer

sc3> a.stop
-> an EventStreamPlayer

sc3> a= {Pan2.ar(DelayN.ar(SoundIn.ar(0), 2, 2), SinOsc.kr(1))}.play(outbus:0) //in0 to out0+1
-> Synth('temp__0' : 1259)
sc3> a.release
-> Synth('temp__0' : 1259)
sc3> a= {Pan2.ar(DelayN.ar(SoundIn.ar(0), 2, 2), SinOsc.kr(1))}.play(outbus:2) //in0 to out2+3
-> Synth('temp__1' : 1260)
sc3> a.release
-> Synth('temp__1' : 1260)
sc3> a= {Pan2.ar(DelayN.ar(SoundIn.ar(1), 2, 2), SinOsc.kr(1))}.play(outbus:0) //in1 to out0+1
-> Synth('temp__2' : 1261)
sc3> a.release
-> Synth('temp__2' : 1261)
sc3> a= {Pan2.ar(DelayN.ar(SoundIn.ar(1), 2, 2), SinOsc.kr(1))}.play(outbus:2) //in1 to out2+3
-> Synth('temp__3' : 1262)
sc3> a.release
-> Synth('temp__3' : 1262)
sc3>