Skip to main content

Composition of music with reinforcement learning.

Project description

Build Status codecov Maintainability PyPI version

RL-Musician

Overview

As of now, this is a proof-of-concept for music composition with reinforcement learning solely. Here, creation of fifth species counterpoint is considered and environment is based on a special data structure that represents musical piece with pre-defined cantus firmus. An action is filling of current measure for a counterpoint line, an episode is finished when all measures are filled one by one, and reward is determined by applying evaluational rules to the resulting piece.

Comparing to music composition tools such as MuseNet, reinforcement learning approach (at least in theory) has two advantages:

  • Actual creativity lies not in imitation of famous pieces, but in finding new ways to create something to be called art. Reinforcement learning meets this criterion, but supervised learning doesn't.
  • There are tuning systems other than equal temperament (say, in microtonal music) and there can be not enough examples for some of them. A model cannot be trained in a supervised manner without a dataset, but, given some rules, an optimal policy can be found even for an absolutely new tuning system.

To find more details, look at a draft of a paper. However, it relates to version 0.3.0 and so first species counterpoint is discussed there. Of course, the draft will be updated in the future.

Installation

To install a stable version, run:

pip install rl-musician

Usage

To create a reward-maximizing musical piece and some its variations, run:

python -m rlmusician [-c path_to_your_config]

Default config is used if -c argument is not passed. Search of optimal piece with these default settings takes about 20 minutes on a CPU of a regular laptop. If you are on Mac OS, please check that parallelism is enabled.

Created pieces are stored in a directory specified in the config. For each piece, there is a nested directory that contains:

  • Piano roll in TSV format;
  • MIDI file;
  • Events file in sinethesizer TSV format;
  • WAV file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rl-musician-0.4.0.tar.gz (29.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page