diff --git a/README.md b/README.md index d129335..5cca662 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ # Evolutionary Composition -## By Danny +## By Danny Noe ### Director: Dr. Lutz Hamel ### CSC 499
-# General Description +# 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. @@ -43,4 +44,126 @@ To learn about the various command-line arguments use ``` python3 main.py -h -v -``` \ No newline at end of file +``` + +
+ +# 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 diff --git a/gen_alg.py b/gen_alg.py index db84491..3074bfd 100644 --- a/gen_alg.py +++ b/gen_alg.py @@ -120,12 +120,6 @@ def run_genetic_algorithm(rep_obj, alg_args) -> tuple: toolbox.register("evaluate", representation.evaluate_music, rep_obj) population = toolbox.population(n=alg_args.pop_size) - - num = 0 - for melody in population: - filename = "midi_for_steve" + str(num) + ".mid" - rep_obj.melody_to_midi(melody, filename, False) - num += 1 alg_args.pop_size = load_midi(population, toolbox, rep_obj.key_signature) @@ -139,4 +133,5 @@ def run_genetic_algorithm(rep_obj, alg_args) -> tuple: algorithms.eaSimple(population, toolbox, alg_args.cxpb, alg_args.mutpb, alg_args.ngen, None, hall_of_fame) save_best_melodies(rep_obj, population, hall_of_fame) + print("The best melodies have been saved to the ./midi_out/ directory.") return population, hall_of_fame \ No newline at end of file diff --git a/main.py b/main.py index 2338c43..617cf99 100644 --- a/main.py +++ b/main.py @@ -12,7 +12,7 @@ parser.add_argument('-o', '--outport', type=str, help="Sets the outport device for MIDO. If none is given, you will get the (system specific) default port.") parser.add_argument('-v', '--verbosity', action='store_true', help="Outputs program's settings") parser.add_argument('-k', '--key_signature', type=str, help="Sets the key signature for the program", choices=key_sig, default="C") -parser.add_argument('-t', '--tempo', type=int, help="Sets the tempo (in BPM) for the program", choices=range(1, 301), metavar="[0,300]", default=120) +parser.add_argument('-t', '--tempo', type=int, help="Sets the tempo (in BPM) for the program", choices=range(2, 301), metavar="[2,300]", default=120) def str2bool(v): if isinstance(v, bool):