Melodic Homeostasis: Regulated Variation from a Motif

This demo generates short melodies from an initial motif. It is not an AI music generator trained on songs; instead, it uses transparent rules of motif loyalty, exploration, tension, and resolution so you can see how a musical trajectory can emerge from an initial condition.

What this models

A melody is treated as a trajectory through pitch space. The seed motif provides the initial condition; the rule set regulates how far the melody may depart, when it should vary, and when it should return.

Rules in plain language

  1. Extract intervals, contour, range, and anchor notes from the motif.
  2. Generate candidate next notes from motif intervals and nearby scale tones.
  3. Score candidates by smoothness, motif identity, tension, and phrase resolution.
  4. Choose probabilistically, so the same motif can produce different outputs.

Interaction guide

  • Build a motif by clicking the keyboard, or type note names directly.
  • Play the motif first, then generate variations from it.
  • Compare outputs for the same input using the variation cards.
  • Play or export the selected melody as a MIDI file.
  • Ask: how much variation can occur before the motif loses identity?
Click a key to hear the note and add it to the motif. The keyboard spans C4–B5; you can still type notes outside this range directly.
Variation gallery same motif, different probabilistic trajectories ?
Selected melodic trajectory piano-roll view ?
The piano roll is a first visualisation of musical “shape”: contour, range, repetition, leaps, and returns. A richer affective or harmonic-shape visualisation could be added later.