Skip to content

Commit

Permalink
Updated README and removed old code
Browse files Browse the repository at this point in the history
  • Loading branch information
Buddy28911 committed May 5, 2021
1 parent 9252274 commit 3ad074b
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 10 deletions.
129 changes: 126 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Evolutionary Composition
## By Danny
## By Danny Noe
### Director: Dr. Lutz Hamel
### CSC 499

<br>

# 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.
Expand Down Expand Up @@ -43,4 +44,126 @@ To learn about the various command-line arguments use

```
python3 main.py -h -v
```
```

<br>

# Command-Line Arguments

Evolutionary Composition can be configured in various ways.

<br>

## General Parameters

<br>

- Verbosity: Outputs program's settings.
<br> Flags: '-v' || '--verbosity'
```
-v
```

- Outport: Sets the outport device for MIDO. If none is given, you will get the (system specific) default port.
<br> Flags: '-o' || '--outport'
```
-o "IAC Driver Bus 1"
```

<br>

## Musical Parameters

<br>

- 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#"]
<br> Flags: '-k' || '--key_signature'
```
-k Gb
```

- Tempo: Sets the tempo (in BPM) for the program. Range: [2,300]
<br> Flags: '-t' || '--tempo'
```
-t 100
```

- Backing Track: Enables a backing track. Turn on the track with True, False for off.
<br> 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
<br> Flags: '-a' || '--arp_or_scale'
```
-a f
```

<br>

## Algorithm Parameters

<br>

- Genetic Algorithm: Sets the GA to use. Supported GAs are eaSimple, eaMuPlusLambda, eaMuCommaLambda
<br> 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

<br>

- Pop size: Sets the number of melodies to generate in the initial population.
<br> Flags: '--popsize'
```
--popsize 10
```

<br>

- Ngen: ngen sets the number of generations the GA will run for.
<br> Flags: '--ngen'
```
--ngen 3
```

<br>

- Mu: sets the number of individuals to select for the next generation.
<br> Flags: '--mu'
```
--mu 3
```

<br>

- Lambda_: sets number of children to produce at each generation.
<br> Flags: '--lambda_'
```
--lambda_ 6
```

<br>

- cxpb: sets the probability that an offspring is produced by crossover.
<br> Flags: '--cxpb'
```
--cxpb 0.7
```

<br>

- mutb: sets the probability that an offspring is produced by mutation.
<br> Flags: '--mutb'
```
--mutb 0.3
```
<b>Note:</b> cxpb + mutpb should = 1.0
7 changes: 1 addition & 6 deletions gen_alg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 3ad074b

Please sign in to comment.