I have this happen every once in a while, and I love it. That state between sleeping and full wakefulness is one of my favorite things to experience because of things like this, hearing music, and also being much more creative. I've learned to stay in the state for a decent while - seemingly lengthening it from seconds to a number of minutes - by keeping my mind relaxed/loose. (The state of transitioning from wakefulness to sleep is also nice, but it seems less readily "useful" in this way.)
As someone that wouldn't regularly consider themselves a musician, hearing music out of nowhere is super cool but weird.