If I am sure of the genre beforehand, I can choose the music to fit the writing. On the other hand, if a particular piece of music appeals to me first, I can let it lead me somewhere unknown and full of surprises. I think that is my preference. I like to have no plan, just ideas inspired by the music.
I use this method for the flash-fiction competition that I take part in on Saturdays. I start the music as I begin to write and let it take me away. That might be a dark place if it's the theme music from Twin Peaks, for example. But if I choose my beloved tacky supermarket music, then some humour will come into the piece. Classical music makes my writing calmer, deeper, somehow more emotional. And, as I mentioned in an earlier post, Brian Eno's Music For Airports is a favourite, very unobtrusive and therefore ideal for moments of intense concentration.
A CD I love at the moment is Dark Was The Night. It has an odd assortment on it, by a variety of artists I have never heard of. But somehow it is inspiring and keeps my imagination vivid. Maybe it's the strange mixture of different styles and tempo.
There are times when I prefer silence. Or I'm so engrossed that I don't stop to think about music. I just keep writing, oblivious of anything going on in the background. But I feel at my best and most productive when it's playing and especially when it blends into the words, so that story and music merge.