Interactive Music Loop Generator

Craft a melody and let AI create variations!

120 BPM

Technical Details

This Interactive Music Loop Generator leverages several modern web technologies and machine learning to create a dynamic music experience:

Workflow:

  1. Melody Input: Users click cells on an interactive grid. Each cell represents a specific musical pitch (row) at a specific time step (column).
  2. NoteSequence Creation: The selected grid cells are converted into a Magenta.js NoteSequence object. This object includes note pitches, start/end times (quantized steps), tempo (BPM), and quantization information (steps per quarter note).
  3. Playback:
    • The user's NoteSequence can be played directly using mm.Player.
    • Generated variations are also played back as NoteSequence objects.
    • Looping functionality is implemented manually by re-triggering playback when a sequence ends if looping is enabled.
  4. Variation Generation:
    1. The user's NoteSequence (or a processed version of it, typically quantized to 16 steps for the mel_4bar_small_q2 model) is fed as a "primer" to the music_vae_instance.sample() method.
    2. The MusicVAE model generates one or more new NoteSequence objects that are musically similar to the input but offer variation.
    3. The generated sequence's tempo is explicitly set to match the current application tempo before playback.
  5. Tempo Control: Users can adjust the playback tempo (BPM) using a slider. This dynamically changes the duration of each step in the grid and updates the tempo for new and looped playbacks.