liveBook · Manning

Melody

As explained in Learn Generative AI with PyTorch

The sequence of pitched notes that forms the tune of a musical piece, here one of the controlled generation factors.

Melody is the recognizable sequence of pitched notes that forms a tune. Its pitch, rhythm, and contour shape a piece’s main musical and emotional themes. section 13.2.1

In controlled music generation, melody is one of four latent inputs alongside chords, style, and groove. These factors provide more detailed control than a single noise vector. section 13.2 section 13.2.1

The melody input has a specific role in the four-track, two-bar arrangement:

  • Begins as a (4, 32) noise vector, giving melody information across four tracks. section 13.2.1
  • Passes through a temporal network that stretches it into two (4, 32) vectors. section 13.2.1
  • Produces eight (1, 32) vectors, one for each track-and-bar combination. section 13.2.1

Melody in a generated composition

For a composition with four tracks and two bars, the melody vector is expanded so every track-bar pair receives its own melody representation, while chords govern bars collectively and groove applies across tracks. section 13.2.1

Figure 13.5 Music generation using chords, style, melody, and groove. Each music composition consists of four tracks and spans two bars. We will extract four noise vectors from the latent space for this purpose. The first vector, representing chords, has a dimension of (1, 32). This vector will be processed through a temporal network to expand the chords into two (1, 32) vectors, corresponding to the two bars, with identical values across all tracks. The second vector, denoting style, also has a dimension of (1, 32) and remains constant across all tracks and bars. The third vector, melody, is shaped as (4, 32). It will be stretched through a temporal network into two (4, 32) vectors, resulting in eight (1, 32) vectors, each representing a unique track and bar combination. Lastly, the fourth vector, groove, with a dimension of (4, 32), will be applied to the four tracks, maintaining the same values for both bars.

Trace how melody moves from a (4, 32) latent vector through temporal expansion into eight track-and-bar representations. section 13.2.1

How Learn Generative AI with PyTorch covers it

How deep it goes
Defines melody musically and specifies its latent shape, temporal expansion, and eight resulting track-bar vectors.
Examples
Uses a four-track, two-bar composition whose melody vector expands into eight track-and-bar representations.
What it assumes
Assumes basic music elements and latent-vector familiarity while defining melody, chords, style, and groove accessibly.
What you can do after
Evaluate how melodic control is distributed across tracks and bars in a MuseGAN-style generator.
How it connects
Links melody with chords, style, groove, latent space, temporal networks, and MuseGAN music generation.

Related concepts

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.