Adding notes to the notes of a melody

If you want to add notes to the existing notes of a melody (to make chords), you generally have to copy your melody then add lots of <> to each note, which can be a time-consuming.

The \addNote function here makes it faster and simpler.

The syntax is : \addNote \melody \newNotes

Here :
melody = \relative {c'4.-> d8-. c4(\p b8) r c4\f c c2}
newnotes = {e f e d e s e}

Note that with this function, you can easily create some other useful functions. For example, a function \doubleOctave is shown here. This doubles each note with the note an octave higher.