Skip to content
Docs menu

Step 3: add music

Step 3 of 8

Compose a music bed and take the finished master.

Music uses the Composer. It returns a finished track (the master) and one stem per instrument.

song = catalyst.composer.compose("calm underscore for: rainy night street", effort="low", duration=30)
print(song.data["bpm"], song.data["key"])        # what the model decided
master = song.master                              # the finished mp3
print([s.role for s in song.stems])               # for example ['Grand Piano', 'Vibraphone']
catalyst.download(master, "music.mp3")

The two print lines show what the model decided and which instruments it made stems for (recorded from a real answer; yours will differ because the music is generated):

80 B dorian
['drum kit', 'Solo Contrabass', 'Grand Piano', 'Vibraphone']

Rust prints the key with quotes and each role inside Some(...) because {:?} shows the exact type: the value is a JSON string and the role is optional.

Good to know

  • effort is low (fast, default) or medium (adds the symbolic note model, takes longer).
  • There is no format option on compose: a composition is an mp3 master plus MIDI stems. You choose the format at download time.
  • To save the master and every stem at once, use download_all.

Checkpoint (M2): four files exist, and the three ambience prompts are visibly different.