Git Product home page Git Product logo

piano-generator's Introduction

Piano Generator

Project developed for research at Federal University of Rio Grande do Norte. This program generates piano pieces based on a provide template, using a Genetic Algorithm.

Limitations:

  • Using only diatonic scales;
  • A single track for the melody (monophonic);
  • A single track for the harmonic chords;
  • No percussion tracks;
  • Piano as the only possible instrument;
  • Only one chord per measure;
  • A single arpeggio pattern for all measures.

The best generated pieces are uploaded in the chosensolution branch. The template pieces used are Happy1, Happy2, Sad1 and Sad2 from the folder "templates". Best samples generated from each template are the ones in the folders "results/Seed 0 (60)" and "results/Seed1 (60)".

Overview

Initial Population

A set of initial pieces are created with the same number of notes and measures as the template, the same scale and the same arpeggio pattern. Chord tonics and melody notes are chosen randomly.

Fitness Function

A set of 109 musical features from the template are extracted and compared with other piece's features. The fittest individuals are the most similar to the template - computed with an euclidean distance between the feature vectors.

Genetic Operations

There is only a single crossover operation: the selection of three parents - one for the tempo and scale, one for the harmony chords and one for the melody.

The mutation operations are:

  • Change mode: changes the scale mode, keeping the root key and the melodic functions of each note in the melody, using a random number from 0 to 6;
  • Change BPM: changes a new BPM value, from 50% to 150% of the current BPM;
  • Change note start time: moves the note start time, using a random float between the end of the previous and the next notes in the melody;
  • Change note duration: changes the note end time, using a random float from the end of the previous note to the start of the next note in the melody;
  • Change note function: changes the function of the note (melody or chord tonic), decreasing or increasing it by one step;
  • Change note accidental: changes the accidental of the note (melody or chord tonic), increasing or decreasing the pitch by half a tone;
  • Change octave: increases or decreases all notes' (melody or chord tonics) pitches by one octave.

Installation

piano-generator's People

Contributors

luisaras avatar

Watchers

James Cloos 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.