In an interview with the Wall Street Journal, Boris Akunin, Russian author of a successful series of mystery novels, says before he begins writing he plays recorded music: "I have to put on the right sort of music, to listen to it for five or 10 minutes just to get tuned to the right mood." For a tragic mood, he likes Mahler, for a tender mood, it's early Beatles albums.
There's another way to use music. That is to wait until you naturally get into a good writing mood, then put on a song or an album that you don't normally play but that supports the writing mood. Do this two or three times, each time using the same music.
Thereafter, when you don't feel in a great writing mood, but want to, you put on that music, and it should create the mood by association. In NLP, this is called an anchor. (Of course, before there was NLP, Pavlov did something similar with dogs and food.)
For more writing tips, see my site, www.timetowrite.com.