I'm using GPIO12 & GPIO13 for PWM audio output to a set of powered speakers on a Raspberry Pi 3. However the speakers have a continuous high pitched beep to them which seems to be tied to the mouse being plugged into the USB port. As soon as I unplug the mouse, the beep disappears though there is still noise hiss/crackle emanating from the speakers. The speakers and Pi are powered from the same power supply.
Welcome to the world of RF. You're experiencing what's called "crosstalk". Basically what this means is that the EMI (electromagnetic interference) generated from one wire can influence other wires and cause similarly shaped signals on them even though they are not connected. This normally happens when the two wires are close together and travelling in parallel.
If you want to get rid of the crosstalk you should do as many of the following as possible:
Move the mouse and cabling as far as possible from your PWM circuit.
Arrange your cable and circuit so that wires in your PWM circuit have as little as possible wires in parallel with your mouse cable.
Shorten the wires in your PWM circuit so that the mouse cable can't influence it as much.
Wrap the mouse cable in aluminium foil and connect this to ground. This will effectively turn the cable almost into a coaxial cable, which will minimize EMI escaping to your circuit.
Wrap, or place your circuit inside a metal case, and connect this to ground. This will create a Faraday cage, removing all EMI getting to your circuit.
Use twisted pair cables or earth shielded (such as coaxial cables) to hook up to your circuit. These types of cables minimize the effect of EMI on the internal cables.
If however, you want to increase its effect you will want to do the opposite of items above :-)
Wrap your mouse cable around long sections of your circuit. This will make the wires as close as possible to each other, and in parallel.
Increase your circuit wires so that the mouse cable can influence it more greatly.
This is by no means the full list of options you have. If you need more I'd recommend researching more about EMI and crosstalk.