Switching audio devices in Supercollider breaks stuff

Hi

I'm guessing this is more of a Supercollider problem than a Tidal one but hopefully it's still ok to post here.

Got everything installed and working fine with only a few hiccups, but then when I tried to use my headphones I noticed the sound was still coming out of my speakers. almost like it doesn't know how to swap between the two. I managed to manually make it use the headphones using this code:

Server.default.options.outDevice_("External Headphones");

Problem is this seems to have broken some stuff. If I try and use the built in speakers again (or whatever the system audio device is) it gives this error message:

SC_AudioDriver: sample rate = 44100.000000, driver's block size = 512
Exception in World_OpenUDP: bind: Address already in use
Server 'localhost' exited with exit code 1.

The only way I've found to fix this is to completely restart my computer, restarting Supercollider has no effect.

Is there a way to make Supercollider swap between headphones/speakers/audio devices 'on the fly' without breaking stuff and requiring a restart?

I'm on a Mac running Catalina btw.

Thanks!

1 Like

Hi @DanD,

I'm not a mac user, but perhaps an audio routing thingie like blackhole would help? That would create a virtual device which I think you could re-route audio from on-the-fly.

At least, you can avoid a reboot by doing Sever -> Kill all servers in the supercollider menus

1 Like

Hey Dan,

Are you using Atom as your editor rather than the SCIDE? Sometimes if you don't s.quit; before closing the editor it leaves a rogue scsynth running on the system that then causes all kinds of annoyances. Kill from terminal or from activity monitor and see if that helps.

SC should boot with whatever your system default audio is, even if that is some weird stuff like the Cisco WEBEX Virtual Interface. Using the Server.default ... ; stuff should then only require a s.reboot; to reinitialise, but this may not be working if you have a rogue scsynth running (and hence why a reboot fixes it). Of course if you're not using Atom (or VSCode probably) and are using SCIDE, then... I mean it might still be happening, but I'd be surprised.

I often switch between an external audio interface running at 48khz and my laptop speaker, which seem to only want to run at 44.1khz in mojave, which has been tripping up SC in weird ways (sometimes with an error, sometimes time warping data). Opening the Audio Midi Setup utility to switch the sample rate explicitly and rebooting the sc server has been fixing this.

'Kill all servers' from the supercollider 'server' menus should be the same as force quit in a process manager / activity monitor.

Thanks for all the pointers, it set me off in the right direction to figure things out. The main problem is my total lack of experience in SC and Tidal of course :slight_smile:

This is the process that works for me if I want to reliably switch audio devices/get SC to recognise the new system default one. Maybe there's an easier way, but this works:

  • 'hush' Tidal
  • SC > Server > 'Kill All Servers'
  • SC > Server > 'Boot Server'
  • Manually start Superdirt or run the code in the startup file (if you're starting
    Superdirt this way)

That last one was catching me out for a while there. It'd still be nice if just switched when I plugged in headphones or whatever but hey, you can't have everything right?

Blackhole looks really cool and I've been looking for something like this since Soundflower got old and cranky, good shout @yaxu thanks. There doesn't seem to be an easy way to get it to do the switching thing, or easier than doing the above at any rate. Maybe with a bit more a play. Still super useful for other stuff though.

1 Like

When I'm recording I switch between headphones and speakers quite a bit by having SC outputting to a DAW (I'm on Windows so I use Virtual Cable for this), and then switch monitoring of the DAW between headphones and speakers.

This is the same as setting up a virtual audio device (as Alex says) - output from SuperCollider to soundflower/blackhole then you can switch the output from soundflower between headphones and speakers without SuperCollider knowing anything :slight_smile:

2 Likes

This is a neat solution, I did think of experimenting with routing the audio through a DAW but it seemed a bit of a faff for when you're just mucking about.

It gave me the idea to have another quick tinker and you can do something similar with Quicktime (on Mac) for a lighter solution. SC outputs audio to Blackhole, start a new audio recording in Quicktime (you don't have to actually record), set the input to blackhole, turn up the monitoring and hey presto you can switch between headphones and speakers to your hearts content. With the added bonus that you can then do a quick and dirty recording if you really want.

2 Likes

I would like to change the audio output in the SC startup file to blackhole 16ch for ex 5 and 6. What line of code should I specify? I basically wanna output tidal to a max msp visual audio reactive patch.