Key information designating a key for a tune to be composed and chord
information designating chords for respective chord spans to constitute a
chord progression for the tune are inputted to a melody generating
apparatus. In the chord span to which a diatonic chord such as C major
chord is designated, melody notes are generated using the scale notes of
the inputted key, while in the chord span to which a nondiatonic chord
such as DbM7 chord is designated, an available note scale is determined
based on the key information and the chord information, and then melody
notes are generated using the notes such as Ab Bb of the available note
scale. As the notes which are neither the scale notes of the key nor the
chord tones may be employed for a melody, the generated melody will have
musical naturalness and fits the nondiatonic chords also.