Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Nikolay-Lysenko/rl-musician
Composition of short musical pieces with reinforcement learning. To be more detailed, framing of fifth species counterpoint writing as an optimization problem.
https://github.com/Nikolay-Lysenko/rl-musician
ai-music algorithmic-composition counterpoint reinforcement-learning
Last synced: about 2 months ago
JSON representation
Composition of short musical pieces with reinforcement learning. To be more detailed, framing of fifth species counterpoint writing as an optimization problem.
- Host: GitHub
- URL: https://github.com/Nikolay-Lysenko/rl-musician
- Owner: Nikolay-Lysenko
- License: mit
- Created: 2019-08-17T09:57:43.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-17T20:53:07.000Z (about 1 year ago)
- Last Synced: 2024-11-07T12:52:53.241Z (2 months ago)
- Topics: ai-music, algorithmic-composition, counterpoint, reinforcement-learning
- Language: Python
- Homepage:
- Size: 1.2 MB
- Stars: 44
- Watchers: 6
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://github.com/Nikolay-Lysenko/rl-musician/actions/workflows/main.yml/badge.svg)](https://github.com/Nikolay-Lysenko/rl-musician/actions/workflows/main.yml)
[![codecov](https://codecov.io/gh/Nikolay-Lysenko/rl-musician/branch/master/graph/badge.svg)](https://codecov.io/gh/Nikolay-Lysenko/rl-musician)
[![Maintainability](https://api.codeclimate.com/v1/badges/a43618b5f9454d01186c/maintainability)](https://codeclimate.com/github/Nikolay-Lysenko/rl-musician/maintainability)
[![PyPI version](https://badge.fury.io/py/rl-musician.svg)](https://badge.fury.io/py/rl-musician)# 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](https://en.wikipedia.org/wiki/Counterpoint#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](https://www.dropbox.com/sh/ouv8tcpio8z5flp/AABIx8D-QlIM_FtuQ9LqFntNa?dl=0). A cantus firmus attributed to [Fux](https://en.wikipedia.org/wiki/Johann_Joseph_Fux) is used in all of them.
To find more details, look at [a draft of a paper](https://github.com/Nikolay-Lysenko/rl-musician/blob/master/docs/paper/paper.pdf). Also, if you are interested in algorithmic composition without too strict limitations of species counterpoint, look at the tools named [Geniartor](https://github.com/Nikolay-Lysenko/geniartor) and [Dodecaphony](https://github.com/Nikolay-Lysenko/dodecaphony).
## Installation
To install a stable version, run:
```bash
pip install rl-musician
```## Usage
To create a reward-maximizing musical piece and some its variations, run:
```bash
python -m rlmusician [-c path_to_your_config]
```[Default config](https://github.com/Nikolay-Lysenko/rl-musician/blob/master/rlmusician/configs/default_config.yml) is used if `-c` argument is not passed. Search of optimal piece with these default settings takes about 5 minutes on a CPU of a regular laptop. Before creating a new config, it might be useful to look at [an example with explanations](https://github.com/Nikolay-Lysenko/rl-musician/blob/master/docs/config_with_explanations.yml).
If you are on Mac OS, please check that [parallelism is enabled](https://stackoverflow.com/questions/50168647/multiprocessing-causes-python-to-crash-and-gives-an-error-may-have-been-in-progr).
Generated pieces are stored in a directory specified in the config. For each piece, there is a nested directory that contains:
* MIDI file;
* WAV file;
* Events file in [sinethesizer](https://github.com/Nikolay-Lysenko/sinethesizer) TSV format;
* PDF file with sheet music and its Lilypond source.