liveBook · Manning

Multitrack music

As explained in Learn Generative AI with PyTorch

Music represented as multiple separate tracks or voices that can be edited and processed independently.

Multitrack music represents a composition as separate musical lines or layers, such as instruments or vocal parts, that can be edited and processed independently. MuseGAN models interactions between these tracks to generate harmonious, cohesive compositions. section 13.0 section 13.1.2

A digital multitrack representation organizes music into nested time and pitch units:

  • Tracks correspond to instruments such as piano, bass, and drums, or voices such as soprano, alto, tenor, and bass. section 13.0 section 13.1.2
  • Bars divide time into measures, while steps subdivide each bar for sequencing rhythms and melodies. section 13.1.2
  • Each step contains a note encoded as an 84-value one-hot vector representing pitch numbers from 0 through 83. section 13.1.2

JSB Chorales representation

A JSB Chorales example contains four tracks—soprano, alto, tenor, and bass. Each track spans two bars, each bar contains 16 steps, and every step selects one of 84 possible pitches. section 13.1.2

Listing 13.1 Visualizing the staff notation using the music21 library
%matplotlib inline                                          #1
from music21 import midi, environment
  
mf = midi.MidiFile()    
mf.open("files/example.midi")                               #2
mf.read()
mf.close()
stream = midi.translate.midiFileToStream(mf)
us = environment.Environment() 
path = r'C:\Program Files\MuseScore 4\bin\MuseScore4.exe'
us['musescoreDirectPNGPath'] = path                         #3
stream.show()                                               #4

Visualize a MIDI file as staff notation with music21, making the separate tracks and their musical structure inspectable. section 13.1.2

How Learn Generative AI with PyTorch covers it

How deep it goes
Defines tracks, bars, steps, and pitch vectors, stopping short of detailed model architecture or training procedures.
Examples
Uses JSB Chorales, four-part vocal writing, two-bar grids, 16-step bars, 84 pitches, and an example MIDI file.
What you can do after
Apply multitrack structure by inspecting MIDI staff notation with the music21 library.
How it connects
Connects tracks with MuseGAN, generative adversarial networks, MIDI, digital audio workstations, step sequencing, and one-hot encoding.

This explainer was generated by Manning's knowledge graph from the text of Learn Generative AI with PyTorch. The section links point to the parts of the book it draws on.