Reader small image

You're reading from  Hands-On Music Generation with Magenta

Product typeBook
Published inJan 2020
Reading LevelExpert
Publisher
ISBN-139781838824419
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Alexandre DuBreuil
Alexandre DuBreuil
author image
Alexandre DuBreuil

Alexandre DuBreuil is a software engineer and generative music artist. Through collaborations with bands and artists, he has worked on many generative art projects, such as generative video systems for music bands in concerts that create visuals based on the underlying musical structure, a generative drawing software that creates new content based on a previous artist's work, and generative music exhibits in which the generation is based on real-time events and data. Machine learning has a central role in his music generation projects, and Alexandre has been using Magenta since its release for inspiration, music production, and as the cornerstone for making autonomous music generation systems that create endless soundscapes.
Read more about Alexandre DuBreuil

Right arrow

Making Magenta Interact with Music Applications

In this chapter, we'll see how Magenta fits into a broader picture by showing how to make it interact with other music applications such as Digital Audio Workstations (DAWs) and synthesizers. We'll explain how to send MIDI sequences from Magenta to FluidSynth and DAWs using the MIDI interface. By doing so, we'll learn how to handle MIDI ports on all platforms and how to loop MIDI sequences in Magenta. We'll show how to synchronize multiple applications using MIDI clocks and transport information. Finally, we'll cover Magenta Studio, a standalone packaging of Magenta based on Magenta.js that can also integrate into Ableton Live as a plugin.

The following topics will be covered in this chapter:

  • Sending MIDI to a DAW or synthesizer
  • Looping the generated MIDI
  • Using Magenta as a standalone application with Magenta...

Technical requirements

In this chapter, we'll use the following tools:

  • The command line or Bash to launch Magenta from the Terminal
  • Python and its libraries to write music generation code using Magenta
  • Magenta to generate music in MIDI and synchronize with other applications
  • Mido and other MIDI tools to send MIDI notes and clock
  • FluidSynth to receive MIDI from Magenta
  • A DAW of your choice (Ableton Live, Bitwig, and so on) to receive MIDI from Magenta
  • Magenta Studio as a standalone application or Ableton Live plugin

In Magenta, we'll make the use of the MIDI interface to send MIDI sequences and MIDI clock to other music applications. We'll cover its usage in depth, but if you feel like you need more information, the Magenta MIDI interface, README.md, in the Magenta source code (github.com/tensorflow/magenta/tree/master/magenta/interfaces/midi) is a good place...

Sending MIDI to a DAW or synthesizer

Since the start of this book, we've been generating MIDI as physical files and then listening to them using either MuseScore or FluidSynth. This is a good way of composing music, generating new sequences, keeping the ones we like, and generating more based on them. But what if we'd like the MIDI notes to play continuously as the model generates them? This is a good way of making an autonomous music generation system, where Magenta is the composer, and an external program is a player, as it plays the notes it receives using instruments.

In this section, we'll be looking at how to send MIDI from Magenta to synthesizers or DAWs. We'll also show how to loop the sequences that are generated in Magenta and how to synchronize our Magenta program with the application it is sending the sequences to.

...

Looping the generated MIDI

Now that we can send generated MIDI to a DAW, let's have a look at how to loop the generated MIDI. This opens up many different use cases, such as building a system that generates music continuously. We'll first have a look at how to loop NoteSequence. We'll also cover how to synchronize Magenta with a DAW using a MIDI clock, which is important in long-running live music systems.

Using the MIDI player to loop a sequence

In this example, we'll be using the player instance from Magenta to loop a generated NoteSequence, by copying the sequence and playing it at a later time, before the player ends its playback.

You can follow this example in the chapter_09_example_03.py file in the...

Using Magenta as a standalone application with Magenta Studio

Magenta Studio is the closest you can get to a Magenta standalone application, in the sense that it doesn't require any installation and any knowledge of technologies to make it work. This is especially important, because Magenta and the technology that powers it is complex, but in the end, it is important that everybody can use it.

We'll be looking at how Magenta Studio works and find many elements we've already covered in the previous chapters. Magenta Studio comes in two packagings:

Summary

In this chapter, we've covered the interaction of Magenta with established music production software.

First, we have shown how to send MIDI from Magenta to DAWs or synthesizers. We started by looking at MIDI ports using Mido, a powerful Python library to handle MIDI operations. We've shown examples of how to loop MIDI in Magenta, which requires proper timing and threading tools. We also looked at synchronization between Magenta and a DAW using various methods, most notably using the MIDI clock messages and transport messages. We finished the MIDI section by showing how Magenta could send MIDI directly to hardware synthesizers, such as keyboards.

Finally, we introduced Magenta Studio, both as a standalone application and as an Ableton Live plugin. We looked at its integration in Ableton Live and the importance of integrating Magenta in existing music tools.

Looking...

Questions

  1. What is the difference between a software synthesizer, such as FluidSynth, and a DAW, such as Ableton Live?
  2. Why is opening MIDI virtual ports required to make music software interact with each other?
  3. Write the code based on chapter_09_example_03.py that, instead of looping the four bars sequence, generates a new sequence every four bars.
  4. Why is syncing based on the MIDI control message not robust?
  5. Why is Magenta Studio such an important project in the music composition ecosystem?
  6. What are the technologies behind Magenta Studio Plugins and Magenta Studio Standalone?

Further Reading

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On Music Generation with Magenta
Published in: Jan 2020Publisher: ISBN-13: 9781838824419
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Alexandre DuBreuil

Alexandre DuBreuil is a software engineer and generative music artist. Through collaborations with bands and artists, he has worked on many generative art projects, such as generative video systems for music bands in concerts that create visuals based on the underlying musical structure, a generative drawing software that creates new content based on a previous artist's work, and generative music exhibits in which the generation is based on real-time events and data. Machine learning has a central role in his music generation projects, and Alexandre has been using Magenta since its release for inspiration, music production, and as the cornerstone for making autonomous music generation systems that create endless soundscapes.
Read more about Alexandre DuBreuil