Sometimes I hear music in my dreams, most of the times is great.
Sometimes, like the others, the music fades away when I wake up and I try to write it but not always. Some of my best tracks (or what I think is my best) originated from my dreams.
My piano fantasy (not anymore on NG), my trumpet concerto (not on NG)...etc.
Latest track "composed" like this is "Spring Breeze". On New Year's Eve 2011 I had a dream that I play that song and in my dream I was analyzing the guitar chords. I was realizing that it's a dream and if I don't pay attention I will forget it when I wake up. Then, in my dream, I was rehearsing it and I was thinking "now I will wake up and write it".
I woke up, I realized that I'm way too sleepy and lazy to write the song, so I woke up my wife and ask her to record me on her phone.