ErikOostveen / PlanetDrone

Planet Drone is an Open Source Raspberry PI Eurorack-Module project, which uses the SuperCollider platform to generate distinctive and captivating music drones.
42 stars 6 forks source link

Ways to use it with USB DAC #2

Closed lorenzoantei closed 1 week ago

lorenzoantei commented 1 week ago

Hi. I tried to use it with a USB DAC.

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 [HifiBerry DAC HiFi pcm5102a-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: UA5 [EDIROL UA-5], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I tried to edit ~/.jackdrc as follow:

$ cat .jackdrc 
/usr/local/bin/jackd -R -P 75 -T -d alsa -d hw:1 -r 44100 -p 256 -n 3

If I boot and tried to play something:

$ aplay /usr/share/sounds/alsa/Front_Center.wav
ALSA lib pcm_dmix.c:1075:(snd_pcm_dmix_open) unable to open slave
aplay: main:830: audio open error: Device or resource busy
$ ./reload.sh 
compiling class library...
    Found 738 primitives.
    Compiling directory '/usr/local/share/SuperCollider/SCClassLibrary'
    Compiling directory '/usr/local/share/SuperCollider/Extensions'
    Compiling directory '/home/pi/.local/share/SuperCollider/Extensions'
    numentries = 1111582 / 12540684 = 0.089
    4231 method selectors, 2964 classes
    method table size 8250384 bytes, big table size 50162736
    Number of Symbols 11784
    Byte Code Size 332335
    compiled 455 files in 1.17 seconds

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

compile done
localhost : setting clientID to 0.
internal : setting clientID to 0.
Class tree inited in 0.1 seconds

*** Welcome to SuperCollider 3.13.0-dev. *** For help type ctrl-c ctrl-h (Emacs) or :SChelp (vim) or ctrl-U (sced/gedit).
'/quit' message sent to server 'localhost'.
'/quit' message sent to server 'localhost'.
Booting server 'localhost' on address 127.0.0.1:57110.
Faust: supercollider.cpp: sc_api_version = 3
Faust: FaustJPverbRaw numControls=11
Found 0 LADSPA plugins
Faust: supercollider.cpp: sc_api_version = 3
Faust: FaustGreyholeRaw numControls=7
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jackdmp 1.9.22
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
Copyright 2016-2022 Filipe Coelho.
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"
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
creating alsa driver ... hw:1|hw:1|256|3|44100|0|0|nomon|swmeter|-|32bit
configuring for 44100Hz, period = 256 frames (5.8 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
JackDriver: client name is 'SuperCollider'
SC_AudioDriver: sample rate = 44100.000000, driver's block size = 256
JackDriver: connected  system:capture_1 to SuperCollider:in_1
JackDriver: connected  system:capture_2 to SuperCollider:in_2
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 17.4 ms
Requested notification messages from server 'localhost'
localhost: server process's maxLogins (1) matches with my options.
localhost: keeping clientID (0) as confirmed by server process.
Shared memory server interface initialized
server 'localhost' disconnected shared memory interface
Shared memory server interface initialized
server 'localhost' disconnected shared memory interface
Shared memory server interface initialized
JackEngine::XRun: client = SuperCollider was not finished, state = Running
lorenzoantei commented 1 week ago

// after boot $ aplay /usr/share/sounds/alsa/Front_Center.wav ALSA lib pcm_dmix.c:1075:(snd_pcm_dmix_open) unable to open slave aplay: main:830: audio open error: Device or resource busy pi@PlanetDrone-Samantha:~ $ ./killall.sh pi@PlanetDrone-Samantha:~ $ aplay /usr/share/sounds/alsa/Front_Center.wav Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono

ErikOostveen commented 1 week ago

Getting jackd to work can be quite a struggle. Perhaps my SuperCollider on UniHiker gives better insight:

https://github.com/ErikOostveen/SuperColliderOnUniHiker

lorenzoantei commented 1 week ago

Getting jackd to work can be quite a struggle. Perhaps my SuperCollider on UniHiker gives better insight:

https://github.com/ErikOostveen/SuperColliderOnUniHiker

Done! I follow your guide without built SuperCollider and add this to autostart.sh script:

# ...
# export DISPLAY=:0.0

export JACK_NO_AUDIO_RESERVATION=1 # EDIT

# Retrieve .scd patches
# ...

and with this into ~/.jackdrc:

$ cat ~/.jackdrc
/usr/bin/jackd -r -d alsa -d hw:1

Here an output of autostart script:

~ $ ./autostart.sh
pigpiod: no process found
compiling class library...
    Found 738 primitives.
    Compiling directory '/usr/local/share/SuperCollider/SCClassLibrary'
    Compiling directory '/usr/local/share/SuperCollider/Extensions'
    Compiling directory '/home/pi/.local/share/SuperCollider/Extensions'
    numentries = 1111582 / 12540684 = 0.089
    4231 method selectors, 2964 classes
    method table size 8250384 bytes, big table size 50162736
    Number of Symbols 11784
    Byte Code Size 332335
    compiled 455 files in 0.93 seconds

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

compile done
localhost : setting clientID to 0.
internal : setting clientID to 0.
Class tree inited in 0.07 seconds

*** Welcome to SuperCollider 3.13.0-dev. *** For help type ctrl-c ctrl-h (Emacs) or :SChelp (vim) or ctrl-U (sced/gedit).
Booting server 'localhost' on address 127.0.0.1:57110.
Faust: supercollider.cpp: sc_api_version = 3
Faust: FaustJPverbRaw numControls=11
Found 0 LADSPA plugins
Faust: supercollider.cpp: sc_api_version = 3
Faust: FaustGreyholeRaw numControls=7
Cannot connect to server socket err = Connection refused
Cannot connect to server request channel
jackdmp 1.9.22
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
Copyright 2016-2023 Filipe Coelho.
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 non-realtime mode
self-connect-mode is "Don't restrict self connect requests"
creating alsa driver ... hw:1|hw:1|1024|2|48000|0|0|nomon|swmeter|-|32bit
configuring for 48000Hz, period = 1024 frames (21.3 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 16bit little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 16bit little-endian
ALSA: use 2 periods for playback
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  system:capture_2 to SuperCollider:in_2
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 46.4 ms
Requested notification messages from server 'localhost'
localhost: server process's maxLogins (1) matches with my options.
localhost: keeping clientID (0) as confirmed by server process.
Shared memory server interface initialized