Code Monkey home page Code Monkey logo

evolutionary_composition's Introduction

Evolutionary Composition

By Danny Noe

Director: Dr. Lutz Hamel

CSC 499


Introduction

Evolutionary Composition is my senior capstone project. The project's goal is to see what type of music a program can create using genetic algorithms and human curation. Specifically, the program will use human curation to create and evolve themes to the user's liking. First, the program generates a batch of melodies. Then, each of these tunes is played for the user. The user rates each melody on a scale from 0 to 5. An elitist selection algorithm picks the highest-scoring pieces for the next generation of music. The next population is created through mating and mutation. A cross-over function takes two parent melodies and returns two children. The first child contains [[First half of parent2's measures], [Second half of parent1's measures]]. The second child contains [[First half of parent1's measures], [Second half of parent2's measures]]. The mutation function mutates a parent melody by randomly pitch-shifting each note in the melody. The pitch-shifted melody is returned as the child. The algorithm repeats until the desired number of generations is satisfied.


Dependencies

The Evolutionary Composition program runs on Python 3.

The project's dependencies are

  • DEAP
  • Numpy
  • MIDO
  • python-rtmidi

Use

To run the program with no command-line args use

python3 main.py

To learn about the various command-line arguments use

python3 main.py -h -v

Command-Line Arguments

Evolutionary Composition can be configured in various ways.


General Parameters


  • Verbosity: Outputs program's settings.
    Flags: '-v' || '--verbosity'
-v
  • Outport: Sets the outport device for MIDO. If none is given, you will get the (system specific) default port.
    Flags: '-o' || '--outport'
-o "IAC Driver Bus 1"

Musical Parameters


  • Key Signature: Sets the key signature for the program. Supported key signatures are ["Cb","Gb","Db","Ab","Eb","Bb","F","C","G","D","A","E","B","F#","C#"]
    Flags: '-k' || '--key_signature'
-k Gb 
  • Tempo: Sets the tempo (in BPM) for the program. Range: [2,300]
    Flags: '-t' || '--tempo'
-t 100
  • Backing Track: Enables a backing track. Turn on the track with True, False for off.
    Flags: '-b' || '--back_track'
-b t
  • Arpeggio or Scale: Sets the backing track to play an ascending arpeggio or scale. True for arp, false for scale
    Flags: '-a' || '--arp_or_scale'
-a f

Algorithm Parameters


  • Genetic Algorithm: Sets the GA to use. Supported GAs are eaSimple, eaMuPlusLambda, eaMuCommaLambda
    Flags: '-ga' || '--genetic_alg'
-ga "eaMuPlusLambda"

Each GA has its own specific parameters that can be configured.

  • eaMuPlusLambda (๐œ‡ + ๐œ†) Parameters: POPSIZE, NGEN, MU, LAMBDA_ CXPB, MUTPB, NGEN
  • eaMuCommaLambda (๐œ‡ , ๐œ†) Parameters: POPSIZE, NGEN, MU, LAMBDA_ CXPB, MUTPB, NGEN
  • eaSimple (๐œ‡ , ๐œ†) Parameters: POPSIZE, NGEN, CXPB, MUTPB, NGEN

  • Pop size: Sets the number of melodies to generate in the initial population.
    Flags: '--popsize'
--popsize 10

  • Ngen: ngen sets the number of generations the GA will run for.
    Flags: '--ngen'
--ngen 3

  • Mu: sets the number of individuals to select for the next generation.
    Flags: '--mu'
--mu 3

  • Lambda_: sets number of children to produce at each generation.
    Flags: '--lambda_'
--lambda_ 6

  • cxpb: sets the probability that an offspring is produced by crossover.
    Flags: '--cxpb'
--cxpb 0.7

  • mutb: sets the probability that an offspring is produced by mutation.
    Flags: '--mutb'
--mutb 0.3

Note: cxpb + mutpb should = 1.0

evolutionary_composition's People

Contributors

buddy28911 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.