simple LM386 amplifier noise
The simplest way to fix your circuit is to build it as the datasheet recommends:



Notice the variable resistor connected to pin 3.  You describe the problem as "noise when the music is playing," which makes me think what you actually have is distortion.

The most common sources of audio will have a line level output (PC) or a headphone output (smart phone, mp3 player, etc.)  Signals at those levels amplified by a factor of 20 (as your circuit would do) will cause clipping (extreme distortion) in the audio.

The fix is to lower the volume.  That's what that 10k variable resistor is there for.  It reduces the signal level so that the output to the speaker doesn't clip.

Next after that is to add a series capacitor between \$V_{IN}\$ and your music source.  A 1µF non-polarized capacitor would be fine.  That should take care of any DC offset that may be causing problems.



Those two steps should fix your problems.  The LM386 generally works well if you follow the notes in the datasheet.  It isn't a great amplifier, but hasn't survived all these years by being a complete piece of crap.