Book Image

Hands-On Music Generation with Magenta

By : Alexandre DuBreuil
Book Image

Hands-On Music Generation with Magenta

By: Alexandre DuBreuil

Overview of this book

The importance of machine learning (ML) in art is growing at a rapid pace due to recent advancements in the field, and Magenta is at the forefront of this innovation. With this book, you’ll follow a hands-on approach to using ML models for music generation, learning how to integrate them into an existing music production workflow. Complete with practical examples and explanations of the theoretical background required to understand the underlying technologies, this book is the perfect starting point to begin exploring music generation. The book will help you learn how to use the models in Magenta for generating percussion sequences, monophonic and polyphonic melodies in MIDI, and instrument sounds in raw audio. Through practical examples and in-depth explanations, you’ll understand ML models such as RNNs, VAEs, and GANs. Using this knowledge, you’ll create and train your own models for advanced music generation use cases, along with preparing new datasets. Finally, you’ll get to grips with integrating Magenta with other technologies, such as digital audio workstations (DAWs), and using Magenta.js to distribute music generation apps in the browser. By the end of this book, you'll be well-versed with Magenta and have developed the skills you need to use ML models for music generation in your own style.
Table of Contents (16 chapters)
1
Section 1: Introduction to Artwork Generation
3
Section 2: Music Generation with Machine Learning
8
Section 3: Training, Learning, and Generating a Specific Style
11
Section 4: Making Your Models Interact with Other Applications

Chapter 8: Magenta in the Browser with Magenta.js

  1. We can train models using TensorFlow.js, but we cannot train models using Magenta.js. We need to train the models in Magenta using Python and import the resulting models in Magenta.js.
  2. The Web Audio API enables audio synthesis in the browser using audio nodes for generation, transformation, and routing. The easiest way to use it is to use an audio framework such as Tone.js.
  3. The method is randomSample and the argument is the pitch of the generated note. As an example, using 60 will result in a single note at MIDI pitch 60, or C4 in letter notation. This is also useful as a reference for pitching the note up or down using Tone.js.

  1. The method is sample and the number of instruments depends on the model that is being used. In our example, we've used the trio model, which generates three instruments. Using a melody model will...