Why does SonicPi not play nice with bluetooth earbuds?

I love SonicPi and dream of taking it on an airplane or other public place and code music.
However, listening to SonicPi through bluetooth earbuds is extremely painful. There is a constant buzzing/crackling sound when listening to it live. As other people have noted on the interwebs, if I record to a file and play it back via quicktime it sounds great… even using the same bluetooth earbuds.

I even tried two different bluetooth earbuds: Apple Airpods gen 3 and Beats Fit Pro. Both have the same behavior.

SonicPi plays live just fine over my macbook’s speakers.

It seems like it just congenitally does not like bluetooth earbuds.

Is this a known problem? Is this an unfixable problem? I would be happy to pateron if it would result in a fix.

Thanks

Apologies, but there does appear to be a strange compatibility issue between bluetooth headphones and SuperCollider - the synthesis engine used by Sonic Pi. I’ve taken a look but haven’t been able to figure it out, sorry. If anyone has any ideas or thoughts on what might be happening here, I’d love to learn more.

It’s also important to point out that Patreon is a vehicle for supporting my work and not for requesting features / fixes.

1 Like

It might be because SuperCollider requires the bitdepth and sampling rate to be equal between input and output (by default, from what I understand of it).

If you connect bluetooth headphones and if they actually come with a microphone, then there is a good chance that the OS will pick up the bluetooth microphone as well. The audio playback will align with the maximum sampling rate and bit depth of the microphone, which is expected to be much lower than the one you need for audio playback (you don’t need a very good sampling rate to transmit voice information).

I believe that you can openly specify the sampling rate and the bit depth of both the microphone and the audio playback independently at server boot, but this is not how SuperCollider behaves by default.

Please correct me if I am wrong on this!

EDIT: the recording is not concerned because you are still recording to a file with the expect sampling rate and bit depth.

1 Like

I had the exact same issue you described.

I believe that @Bubo might be right, my earbud mic sample rate is much lower, which was forcing the output to have terrible quality (quite noticeable noise as you described). The way I fixed it was to switch the input device in the system preferences to one that supports a higher sampling rate (in my case the built-in MacBook mic). No more noise.

If you don’t have that option, try setting up a virtual input device with a better sampling rate and switch to that. It might also be possible to force it from .sonic-pi/config/audio-settings.toml, not sure.

1 Like