Hi, MrKew.
Welcome to the Apple Support Communities. We’re glad you decided to reach out about your audio quality when running Xcode. If we understand correctly, the music is either skipping or you hear a buzzing sound, mostly when you're debugging the app in Xcode.
Is the app running any audio in the simulator? If it is, it's possible the audio from the music is struggling to share the audio output system with Xcode. You may want to reach out to Apple's Developer Support directly for guidance:
Support - Apple Developer
If it's happening with other intensive programs, you might look at Activity Monitor to see if you can find an app or process that is impacting performance on your Mac.
How to use Activity Monitor on your Mac - Apple Support
If you don't find a resolution in Activity Monitor, and it's happening outside of using Xcode, are you streaming content in YouTube and Spotify? If you are, is it possible it's an internet connection issue? If it sounds like this could be the case, you may find this article helpful:
How to troubleshoot Wi-Fi connectivity - Apple Support
All our best.