At least two well-known composers wrote pieces that they said started with a dream.
Around 1750 the great violinist Giuseppe Tartini dreamed that he made a deal with the devil for his soul. He handed the devil his violin. “Imagine my astonishment when I heard a sonata so unusual and so beautiful, performed with such mastery and intelligence, on a level I had never before conceived was possible. I was so overcome that I stopped breathing and woke up gasping.” Tartini attempted to reproduce the music in his dream and wrote the virtuosic violin sonata that’s known as “The Devil’s Trill.”
Igor Stravinsky told a similar story about his Octet (1923). “The Octet began with a dream. I found myself in a small room surrounded by a small group of instrumentalists who were playing some very agreeable music. I did not recognize the music they played, and I could not recall any of it the next day, but I do remember my curiosity – in the dream – to know how many musicians there were. I remember, too, that after I had counted them to the number eight, I looked again and saw that they were playing bassoons, trombones, trumpets, a flute, and a clarinet. I awoke from this little dream concert in a state of delight and the next morning I began to compose the Octet.”