GithubHelp home page GithubHelp logo

mcanthony / midi-machine Goto Github PK

View Code? Open in Web Editor NEW

This project forked from blr246/midi-machine

1.0 3.0 0.0 185 KB

A midi learning machine.

License: BSD 3-Clause "New" or "Revised" License

Lua 98.08% Shell 1.92%

midi-machine's Introduction

midi-machine

Process MIDI files and use them to train learning machines that generate music in the style of the input data.

Dependencies

The timidity player will play midi files generated by the midi-machine. It is available via homebrew on the Mac platform and via apt-get on Ubuntu. Check your preferred package manager.

Installation

Install Torch7 and timidity. Then clone the midi-machine repository using

$ git clone https://github.com/blr246/midi-machine.git

Get the jsb chorales data.

$ wget http://www.jsbchorales.net/down/sets/jsb403.zip

and extract it on your machine. A good location is a folder called midi in the root of this repository.

If your environment is configured properly, the proceed to the Usage section.

Usage

There are a number of scripts in the bin directory. Each of these tools allows for training and testing various models.

All of the bin scripts have command-line help strings. Run the command without arguments to read its usage string as in

$ th ./bin/main.lua

To train a simple model, run

$ th ./bin/main.lua MIDI_DIR TIME_SIGNATURE OUTPUT_DIR

The MIDI_DIR is the location of the jsb chorales data. A TIME_SIGNATURE is a string such as 4/2-8-24-4-256. This string indicates the meter of the music (4/2), the number of 32 notes per quarter note (8), the number of metronome ticks per click (24), the number of channels (4), and the GCD of all note event times (256).

The model and an example midi file will be written to OUTPUT_DIR. To play any midi file, run

$ timidity PATH_TO_MIDI

To hear several example songs generated by a model, use the jukebox.sh script as in

$ ./bin/jukebox.sh MIDI_DIR MODEL_PATH LENGTH

where MODEL_PATH is the model saved by the training job and LENGTH is the number of time steps to generate. The script will save generated songs to the /tmp directory and play them in turn.

Note that jukebox.sh is a wrapper for compose.lua.

Some reasonable examples

To generate some machines that make reasonable music, try

$ th bin/main.lua -h 32 -t iso -o 5 -s 0.2 -w l2 midi/ 4/2-8-24-4-512 experiments/

or

$ th bin/main.lua -h 32 -t iso -o 20 -r -s 0.2 -w l2 midi/ 4/2-8-24-4-512 experiments/

Note where the example song and model are saved. You can play the example song with timidity or use the model with ./bin/jukebox.sh to generate songs.

The mid library

A major component of the midi-machine is the mid library located in the lua/mid/ directory. The library contains the following core functions:

mid.data.read()

Read a .mid file as extracted events.

mid.data.write()

Write events to a .mid file.

mid.dataset.load()

Load a dataset used with Feedforward models.

mid.dataset.load_rnn()

Load a dataset used RNN models.

mid.dataset.compose()

Generate a song from predicted data.

Modules

There are several smaller modules in the lua directory.

models.lua

Contains setup for network types and as well as train_model() and predict() helpers.

RluMax.lua

A simple rectified linear unit that takes only positive values.

PerceptualLoss.lua

An experimental module for creating a perceptual loss function.

Rnn.lua

A general Recurrent Neural Network module that allows backpropagation through time training.

midi-machine's People

Contributors

blr246 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.