Writing melodies is hard, and here are some ideas I gathered from the Internet (YouTube videos like this) that might help.

Thematic

Think of a theme or topic of the music you want to write. It’s generally a lot easier to write about topics / themes in which you have personal experience (or of which you feel strong emotions). This is so that you can use existing feelings about that topic to elicit melodies.

Genre & Style

Determine what genre or style or ethnicity your song will take root in, since they can have similarities you can borrow such as:

  • drum beats
  • rhythmic, melodic, and metric patterns
  • scales
  • chord progressions

Key & Harmony

First determine what key your song will be in, then:

  • Determine the function of the current note and think about where the note can possibly resolve to (e.g. 5 can go to 1, 3 can go to a 2, 4, 6, etc).
    • 4 to 3
    • 6 to 5
    • 7 to 8/1
    • 7 to 6 (jazz)
  • Venture outside the key (chromaticism) occasionally, which adds color to the melody line.
  • Ensure that the melody outlines or works harmonically with other parts (i.e. bass line, piano).
  • Consider what the chord progression and cadence will be and plan the melody accordingly.
  • Consider changing the key (modulate) to change mood or create lift (e.g. half-step key change lift) or even just internally / for a short while (e.g. modulate only during the bridge, then go back to original key)

Over an Existing Progression

  • Move through notes of the underlying chords through different registers.
  • Add non-chordal passing notes for tension and immediate resolution (to a chord tone).
  • Accent some passing tones (e.g. put the passing note on a strong beat).
  • Add suspensions, anticipations, and pedal tones (still, one step away from resolution)
    • Suspension: Suspend a tone from the last tone for a little bit then resolving to a (current) chordal tone
    • Anticipation: Borrow a note from the next chord for a little bit and then resolving to the (future) chord / chordal tone
    • Pedal Tone: Hold (or frequently revisit) a tone over a series of chord changes, which adds a sense of continuity throughout
  • Add sequences (see the next section).
  • Think of the overall shape of the melodic and its relationship with the chord progression. It’s nice to do something different than the chord progression, e.g. if the chord progression is descend, it’d be nice to occasionally ascend in the melody (note that ascent and descent are not the only way to describe progressions!).
  • Balance the steps, skips, and leaps.
  • Keep the rhythm interesting. Don’t lock the rhythm into the chord changes.
  • Play with the listener’s expectation of the melodic progression / shape / direction. Occasionally subvert it to keep interest.

Phrasing & Structure

Adding restrictions and structure to the melody can actually help creativity as it reduces the complexities that come with having way too many options. Here are some general ways to structure a melody.

An easy way to give a melody structure is to add phrasing. A musical phrase often comes the form of question & answer (or formally, antecedent & consequent). The antecedent and consequent generally begins the same way and end differently: the antecedent ends on a unresolved cadence, and the consequent ends on a less unresolved cadence. In additional, questions and answers don’t always have to come in pairs. Sometimes having having multiple questions, multiple answers, or only answering at the end of the song is fine too. Do not let phrasing restrain your creativity. Adding dynamics to the phrases make it more alive, too.

Sometimes it might be helpful to distinguish the verse and chorus by have fewer melodic skips (anything greater than or equal to a minor third) in the verses and more skips in the choruses. This is an easy (but sometimes overused way) to create a gap between the energy of the verse and the chorus. Dynamics also help here.

If it’s hard to create additional melodies, make sure the existing melodic line is catchy enough and repeat this melodic idea but make changes as it repeats, such as changing chords or gradually adding more layers / accompanying instruments.

One easy one to extend a melody is to make a sequence, where a melodic idea / shape is repeated but sequentially shifted one or more tones up or down (e.g. A … B … C …; A … G … F …)

General Tips

If you are still have no idea what to write about, maybe just listen and learn melodies from favorite songs, figure out why / what notes / what melodic interval / what chordal harmony / what motivic idea makes it feel good.