andreasjansson / musicgen-looper

Generate fixed-bpm loops from text prompts

  • Public
  • 46.2K runs
  • GitHub
  • Paper
  • License

Readme

MusicGen-Looper

Generate fixed-bpm loops from text prompts

How it works

First a piece of music is generated by running the prompt (appending ", {bpm} bpm") through MusicGen. Then BeatNet detects beats and downbeats. An even number of bars is extracted from the output audio.

Variations are created by using MusicGen’s continuation feature, passing the last bar of the first variation as input to the continuation model.

All variations are time stretched with Rubberband to match the requested tempo exactly. If the actual tempo of the first variation is +/-10 bpm from the requested tempo, an error is thrown.

Failure cases

  • BeatNet often struggles to pick the right downbeat, which causes loops to start on a different beat than 1.
  • MusicGen has its own limitations, e.g. it can’t generate vocals