sonic-pi-net / sonic-pi

Code. Music. Live.
https://sonic-pi.net
Other
10.74k stars 918 forks source link

Audio output didn't work when first opened on a M1 mac #3149

Open tomhannen opened 2 years ago

tomhannen commented 2 years ago

Audio didn't output when I first loaded (I'm on an M1 MacBook Pro using a Tascam US 2x2 USB audio interface).

To get it working, I checked "Invert Stereo", "Force Mono" and "Enable Audio Inputs" in the preferences, and restarted the app. This solved the problem, but I'm not sure which of these actions fixed it.

samaaron commented 2 years ago

Hey @tomhannen,

this has been noted before. In v4 of Sonic Pi on macOS we specifically do not connect to audio input by default unless you set the checkbox "Enable Audio Inputs".

It seems that certain external devices need audio inputs to be connected to connect to the output too. Perhaps there's a duplex connection which does both in one that is tripping things up a little?

I really would like to keep the current behaviour of not connecting to external audio by default - but also want your situation to be easier to resolve.

If anyone has any thoughts on this, I'd love to hear them. The best I can think of currently is to rename "Enable Audio Inputs" to "Enable Audio Inputs and External Audio Devices" - although I'm not yet sure that all external audio hw needs this checked.

tomhannen commented 2 years ago

Wouldn't the expected behaviour to be to connect to whichever audio output the OS is currently defining as the system output? e.g. if I open Spotify, I don't have to define which output to use, as it's using the system to define the output?

samaaron commented 2 years ago

Wouldn't the expected behaviour to be to connect to whichever audio output the OS is currently defining as the system output?

If only it was that simple!

However, SuperCollider, the underlying synthesis engine, has a restriction that the input and output audio rates need to be identical. Unfortunately this proved not to be the case for many users who all had issues booting.

We therefore now only connect to the audio output - which resolves this issue in the common case as most people only use output and the rates only need to be the same if you connect to the input too. I assumed would be OK, but it seems that some external hardware (possibly all?) requires you to also connect to the input to be able to send output (which I don't fully understand why yet).

emlyn commented 2 years ago

it seems that some external hardware (possibly all?) requires you to also connect to the input to be able to send output (which I don't fully understand why yet).

That does seem strange, if it's the case then surely that hardware wouldn't work at all with a media player that has no audio input?

samaaron commented 2 years ago

That does seem strange, if it's the case then surely that hardware wouldn't work at all with a media player that has no audio input?

I imagine this has everything to do with the specifics of how SuperCollider connects to devices and any assumptions made there. It's possibly worth discussing this with the SuperCollider people directly.

samaaron commented 2 years ago

@tomhannen would it be possible to try something out for me?

  1. Configure your macOS audio preferences as you would normally with your Tascam device set.
  2. Modify your ~/.sonic-pi/config/audio-settings.toml file so that it matches below
  3. Start Sonic Pi
enable_inputs = true
num_inputs = 0
num_outputs = 2

Does that work as expected?

tomhannen commented 2 years ago

Hi, apologies if I haven't done this correctly. Here's what I did:

There was no file present in ~/.sonic-pi/config/audio-settings.toml so I created it, and added the code as listed. When I opened Sonic Pi, it outputted audio correctly from the Tascam device.

But I had already modified the settings previously to ensure that the output was working. So next I deleted Sonic Pi, and re-installed it.

When I opened the new install, the audio outputs were correctly assigned, even without adjusting the .toml file.

So to make sure, I quit Sonic Pi and deleted audio-settings.toml and gui-settings.ini

When I re-opened Sonic Pi this time, the audio was not playing correctly through the Tascam.

I quit Sonic Pi.

I recreated the audio-settings.toml file as requested.

It worked! Audio played through the Tascam without making any adjustments inside the app itself.

PacoLinux commented 1 year ago

Hi, new to Sonic Pi here!

Im having problems with a Mac M1:

paco@PacoM1 ➜ .sonic-pi uname -a Darwin PacoM1.local 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:30 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T8103 arm64

This code fails with pan: 1 (no sound) listening with bt headphones and cabled headphones but with incorporated speakers woks flawlessly.

play 90, pan: 1 sleep 5 play 90, pan: -1 sleep 5

But with

play 90, pan: 0.9 sleep 5 play 90, pan: -0.9 sleep 5

Works with all the devices, but with pan: 0.9 the sound is lower than in the other channel (at least in the headphones.)

When I arrive home I will try with an Intel Mac

daemon.log