For many of the songs I write, the melodies are inspired by the lyrics I am working with. When the lyrics are a poem or a short piece of prose, I read the words over and over and over again until they give me the melody.
When the lyrics are a mantra, it works a little differently. Often I will simply find myself reluctant to sing a particular mantra song I have written. So, I pause, sit for a while, and when I next touch my guitar, the new song for that mantra comes with the chords my fingers play. Other times a friend or student will ask me to write a mantra song. In this case I sit down with my guitar, think to myself I need a song for so-and-so and, a short while later, I have the song I was seeking.
Then there are times when an experience or a feeling brings the song to me. The song Oceans of Song, for example, came to me one beautiful summer afternoon while picking blueberries. It captured the joy, wonder and gratitude I felt for the beauty of the day and the wondrous perfection of the blueberries I was picking.