Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

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 adding a new note to a counterpoint line, an episode is finished when counterpoint duration becomes equal to that of cantus firmus, and reward is determined by applying evaluational rules to the resulting piece.

Some pieces generated with this package are uploaded to a publicly available cloud storage. A cantus firmus attributed to Fux is used in all of them.

To find more details, look at a draft of a paper. Also, if you are interested in algorithmic composition without too strict limitations of species counterpoint, look at the Geniartor tool.

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 30 minutes on a CPU of a regular laptop. Before creating a new config, it might be useful to look at an example with explanations.

If you are on Mac OS, please check that parallelism is enabled.

Generated 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.

Files for rl-musician, version 0.4.4
Filename, size File type Python version Upload date Hashes
Filename, size rl-musician-0.4.4.tar.gz (31.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page