If an idea comes into my head I keep going and then I can hear rthe song in my head. This usually happen when I don't have any paper or a computer nearby. Also I can't come up with anything when I try to. I usually improvise on tunes like Adagio for strings and Rhapsody In blue etc to come up with stuff as an exercise. Th downfall o hearing the music in your head is sometimes your mind takes other people's melodies (a piece I'm writing for my college prescreening stuff I recently discovered the main melody is very similar to the opening of mvmt one of Scherezade D:)