Hi, when outputting through my Sony WH-1000XM4 bluetooth headphones on Windows, realtime audio from the server sounds glitchy, with incorrect transients, clicks, pauses, and “fast forward” pitch increases. These artifacts are seemingly not tied to the signal itself, they occur at random times even when replaying the same signal.
Here is a pathological synthdef that always exhibits the behavior for me, though it can also occur randomly during normal usage.
var def = SynthDef.new(\pulse, { arg out, amp, freq, degree, gate = 1, dur;
var feedback = LocalIn.ar(2);
var fuzz = 0.05;
var attackTime = 0.04;
var osc = [
SinOsc.ar((60 + degree + 12).midicps, phase: fuzz * feedback[0].range(0, 2pi)),
SinOsc.ar((60 + degree + 24).midicps, phase: fuzz * feedback[1].range(0, 2pi))
] * EnvGen.ar(Env.asr(
attackTime: (attackTime) * dur,
releaseTime: (1 - attackTime) * dur
), gate: gate);
LocalOut.ar(osc);
Out.ar(out, amp * Mix.ar(osc));
}).add;
server.sync;
Pmono(def.name, *[
degree: Pseries(0, 1, 8)
]).play;
I tried the following troubleshooting steps.
i) I verified it is caused by outputting via bluetooth. Listening to the above on same machine with the same settings through the same headphones but using a real wire, no bluetooth, the audio sounds fine. This is also the case for the system speakers
ii) I recorded the above to .wav with the same settings as the server, then played back that recording using PlayBuf using the server. Listening to this on the bluetooth headphones, no artifacting occurred. Listening to this .wav in other apps including audacity and the default windows media player, no artifacting occurrs either. It only happens for audio synthesized in realtime by the supercollider server.
iii) I disabled all Windows “audio enhancement”, including “Windows Sonic” and “Dolby Atmos”. This did not fix the issue.
iv) On startup, the server prints:
Booting with:
In: Windows WASAPI : Mikrofonarray (Intel® Smart Sound Technologie für digitale Mikrofone)
Out: Windows WASAPI : Kopfhörer (WH-1000XM4)
Sample rate: 48000.000
Latency (in/out): 0.022 / 0.023 sec
SC_AudioDriver: sample rate = 48000.000000, driver's block size = 256
The server sample rate matches that of my device, though trying other common sample rates made no difference to the artifacting.
v) ServerOptions.devices.do{|x| x.postln}; prints the following, where I omitted some of the irrelevant entries such as mics:
MME : Microsoft Sound Mapper - Input
MME : Mikrofonarray (Intel® Smart Sou
MME : Kopfhörer (WH-1000XM4)
MME : Microsoft Sound Mapper - Output
MME : Kopfhörer (WH-1000XM4)
MME : Lautsprecher (Senary Audio)
Windows DirectSound : Primary Sound Capture Driver
Windows DirectSound : Kopfhörer (WH-1000XM4)
Windows DirectSound : Primary Sound Driver
Windows DirectSound : Kopfhörer (WH-1000XM4)
Windows DirectSound : Lautsprecher (Senary Audio)
Windows WASAPI : Kopfhörer (WH-1000XM4)
Windows WASAPI : Lautsprecher (Senary Audio)
Windows WASAPI : Kopfhörer (WH-1000XM4)
Windows WDM-KS : Kopfhörer ()
Windows WDM-KS : Output 1 (Senary Audio headphone)
Windows WDM-KS : Output 2 (Senary Audio headphone)
Windows WDM-KS : Input (Senary Audio headphone)
Windows WDM-KS : Output 1 (Senary Audio output)
Windows WDM-KS : Output 2 (Senary Audio output)
Windows WDM-KS : Input (Senary Audio output)
Windows WDM-KS : Kopfhörer (@System32\drivers\bthhfenum.sys,#2;%1 Hands-Free%0
;(WH-1000XM4))
Windows WDM-KS : Kopfhörer (@System32\drivers\bthhfenum.sys,#2;%1 Hands-Free%0
The blank lines and duplicate entries were what was printed to the console, I did not copy it incorrectly.
I tried every device related to my headphones. only Windows WASAPI : Kopfhörer (WH-1000XM4) (the default) had good audio quality, DirectSound, WDM-KS and MME sounded like a cheap headsets but they did not exhibit the audio glitching.
I feel like it could be a latency issue but I don’t know which server option to set to what, or what other steps to take to trouble shoot. Windows does not allow you to change the bluetooth codec to my knowledge, and I couldn’t find any settings outside of supercollider that influenced playback.
Thank you for any suggestions.