Cannot boot or play sound with supercollider on RPI3

Hi

I’ve tried numerous to get my audio to work on supercollider on my RPI3 with latest 32bit Debian Bookworm

What works:

Launching supercollider at boot in GUI mode through cronjob.
Playing sound in RPi with speaker-test -c2 -t wav

What doesn’t work:

Supercollider.scd

s.options.device = "hw:1";  // Directly access the HiFiBerry DAC on hw:1
s.options.sampleRate = 48000;  // Match your device's sample rate
s.options.numOutputBusChannels = 2;  // Stereo output
s.options.numInputBusChannels = 2;   // Stereo input, if needed

(
// Boot the server and play a test sound
s.waitForBoot {
    { SinOsc.ar(440, 0, 0.2) * Env.perc(0.01, 1).ar }.play;
};
)

Response:

-> a ServerOptions
-> a ServerOptions
-> a ServerOptions
-> a ServerOptions
-> localhost
Booting server 'localhost' on address 127.0.0.1:57110.
Found 0 LADSPA plugins
jackdmp 1.9.21
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 10
self-connect-mode is "Don't restrict self connect requests"
audio_reservation_init
Acquire audio card Audio0
creating alsa driver ... hw:0|hw:0|1024|2|48000|0|0|nomon|swmeter|-|32bit
Released audio card Audio0
audio_reservation_finish
could not initialize audio.
Server 'localhost' exited with exit code 0.

etc/asound.conf

 GNU nano 7.2                    /etc/asound.conf                              
pcm.!default {
    type hw
    card 1  # Replace with the correct card number if it?s not 1
}

ctl.!default {
    type hw
    card 1
}

I’ve tried with jack, got rid of the error message in SC but still no sound.
Though sound works in RaspberryPI when testing the afore mentioned line of code.

Can use some help to get my environment to run.

One thing is – see Audio device selection – .device does not choose the soundcard in Linux.

Recommended procedure is to configure JACK first (JACK is the only way to choose the soundcard – SC cannot override JACK’s configuration), start the JACK server first, then boot scsynth. It might not always be necessary to boot the JACK server first, since scsynth will try to boot it, but it’s possible for it to fail when scsynth boots it so I’ve never done it that way routinely.

hjh

I’ve installed everything again, got JACK to work.

jackd -P70 -d alsa -d hw:sndrpihifiberry -r 44100 -p 1024 -n 2 -S-S
jackdmp 1.9.21
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 70
self-connect-mode is “Don’t restrict self connect requests”
audio_reservation_init
Acquire audio card Audio2
creating alsa driver … hw:sndrpihifiberry|hw:sndrpihifiberry|1024|2|44100|0|0|nomon|swmeter|-|16bit
ALSA: Cannot open PCM device alsa_pcm for capture. Falling back to playback-only mode
configuring for 44100Hz, period = 1024 frames (23.2 ms), buffer = 2 periods
ALSA: final selected sample format for playback: 16bit little-endian
ALSA: use 2 periods for playback

But still get this error in SC:

Booting server ‘localhost’ on address 127.0.0.1:57110.
jackdmp 1.9.21
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 10
self-connect-mode is “Don’t restrict self connect requests”
audio_reservation_init
could not initialize audio.
Server ‘localhost’ exited with exit code 0.
→ a ServerOptions
→ a ServerOptions
→ a ServerOptions
→ localhost
Booting server ‘localhost’ on address 127.0.0.1:57110.
jackdmp 1.9.21
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 10
self-connect-mode is “Don’t restrict self connect requests”
audio_reservation_init
could not initialize audio.
Server ‘localhost’ exited with exit code 0.
→ localhost
Booting server ‘localhost’ on address 127.0.0.1:57110.
jackdmp 1.9.21
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 10
self-connect-mode is “Don’t restrict self connect requests”
audio_reservation_init
could not initialize audio.
Server ‘localhost’ exited with exit code 0.

Code:

s.options.device = "hw:sndrpihifiberry";
s.options.sampleRate = 44100;  // Ensure the sample rate matches JACK?s configuration.
s.options.numBuffers = 1024;    // Set buffer size to match JACK
s.boot;

{ SinOsc.ar(440, 0, 0.5) }.play;

This did the trick:

Server.default.options.device = "JACK";
Server.default.boot;