Distorted audio from Sonic Pi

Sometimes I get distorted audio when I run Sonic Pi. For example, when I run the code in this post https://in-thread.sonic-pi.net/t/sweepingsynth-my-best-creation-so-far/5898, I get distorted audio. When I play the youtube video of this code https://www.youtube.com/watch?v=dE4nrpsIPZM, it sounds fine. Here’s how it sounds on my machine, https://jamcultur.bandcamp.com/track/sonic-pi-distortion

I’m running Sonic Pi v4.0.3 on Windows 10 and am listening to the youtube video on the same machine with the same audio setup. Why does Sonic Pi sound distorted on my machine? How can I fix this?