music_generation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
music_generation [2024/03/18 19:39] – [Pass Melodies through Chord Filters] steve.wangmusic_generation [2024/05/15 02:04] (current) steve.wang
Line 18: Line 18:
 String -> {String} -> Number -> String String -> {String} -> Number -> String
  
-Use the ```K.lsystem``` function to generate L-system with more control.+Use the ```K.lsystem``` function to generate L-system with more control. use the ```K.workerLsystem``` that does the same thing but with worker threads 9smae syntax).
  
 #### Syntax #### Syntax
Line 49: Line 49:
 #### How It Works: #### How It Works:
 If the generations the lsystem function has to generate is more than 0, it will recursively call itself with one less generation. If the generations it has to generate reaches 0, it will return the string that has been inputted. If the generations the lsystem function has to generate is more than 0, it will recursively call itself with one less generation. If the generations it has to generate reaches 0, it will return the string that has been inputted.
 +
 +### variousLsystems
 +An lsystem is generated each individual character is assigned a number. The code will go through the lsystem and placing the characters in number form into an array. The array is then assigned a name in an object. The object is then returned.
 +
 +#### Syntax
 +
 +```
 +variousLsystems(baseName,n,patternLength,rules,generations,replacementValues,inputString, allChars = getAllAlphabets())
 +```
 +
 +#### Parameters
 +##### baseName
 +This is the base string for all the keys in the returned object. So, the names of the resulting object will be baseName+number. number starts from 0.
 +
 +##### n 
 +The amount of arrays in the returned object.
 +
 +##### patternLength
 +The total value of all the numbers in each array.
 +
 +##### rules
 +L-system rules. Object
 +
 +##### generations
 +
 +L-system generations. Number
 +
 +##### replacementValues
 +
 +The number each character should be assigned to.
 +
 +##### inputString
 +The string L-system should start with. The axiom of the L-system.
 +
 +##### allChars
 +All characters used by the L-system it will default to all the English alphabets if nothing is filled in.
 +
 +#### Examples
 +```
 +//Might need to wait a few seconds depending on speed of your device.
 +let varyingLsystem = await K.variousLsystems('testing', 1, 32, {'a': 'b', 'b': 'ab'}, 20, [0.5, 1, 2, 3], 'a')
 +/*
 +> varyingLsystem
 +{
 +  testing0: [
 +      1, 0.5, 0.5,   1, 0.5, 0.5,   1, 0.5,   1, 0.5,
 +    0.5,   1, 0.5, 0.5,   1, 0.5,   1, 0.5, 0.5,   1,
 +    0.5,   1, 0.5, 0.5,   1, 0.5, 0.5,   1, 0.5,   1,
 +    0.5, 0.5,   1, 0.5, 0.5,   1, 0.5,   1, 0.5, 0.5,
 +      1, 0.5,   1, 0.5, 0.5,   1
 +  ]
 +}
 +*/
 +```
  
 ### generateLsystemByAssigningNumberToLetter ### generateLsystemByAssigningNumberToLetter
Line 114: Line 168:
 #### How It Works: #### How It Works:
 First, the octaves and the notes are generated. They are generated via the same process. An lsystem is generated in string form. Then converted  First, the octaves and the notes are generated. They are generated via the same process. An lsystem is generated in string form. Then converted 
 +
  
 ## Random  ## Random 
Line 185: Line 240:
 ## Circle Of Fifths ## Circle Of Fifths
  
-Generate circle of fifths chord progressions using the ``generateCircleOfFifthsChordProgressions`` function. The ``generateCircleOfFifthsChordProgressions`` function uses the ``createCircleOfFifths`` function.+Generate circle of fifths chord progressions using the ``generateCircleOfFifthsChordProgression`` function. The ``generateCircleOfFifthsChordProgression`` function uses the ``createCircleOfFifths`` function.
  
 ### createCircleOfFifths ### createCircleOfFifths
Line 221: Line 276:
 ``` ```
  
-### generateCircleOfFifthsChordProgressions+### generateCircleOfFifthsChordProgression
 [Number] -> String -> Number -> [String] [Number] -> String -> Number -> [String]
  
Line 228: Line 283:
 ### Syntax ### Syntax
 ``` ```
-K.generateCircleOfFifthsChordProgressions(chordLengths, key, counterClockwiseChance) +K.generateCircleOfFifthsChordProgression(chordLengths, key, counterClockwiseChance) 
 ``` ```
  
Line 243: Line 298:
 ### Example ### Example
 ``` ```
-let circleOfFifthsProgression = K.generateCircleOfFifthsChordProgressions([1,1,1,1], "C", 0.5)+let circleOfFifthsProgression = K.generateCircleOfFifthsChordProgression([1,1,1,1], "C", 0.5)
 //Add the information to MusicalEnvironment: //Add the information to MusicalEnvironment:
 //1. Convert information to musical letter notation: //1. Convert information to musical letter notation:
Line 335: Line 390:
 e.play('exampleMidiPlayer1') e.play('exampleMidiPlayer1')
  
 +```
 +
 +You can also create your own modeFilters like so:
 +```
 +//In this example, I will use the controlled L-system generator to generate a modeFilter
 +let lsystemModefilter = K.lsystem('a', {'a': 'ab', 'b': 'bab'}, 5)
 +let lsystemModeFilterChanges = K.countLetterChanges(lsystemModefilter)
 +
 +//Create a modeFilter:
 +e.modeFilters.lsystemModeFilter = new K.QuantizedMap(lsystemModeFilterChanges.length, lsystemModeFilterChanges, lsystemModeFilterChanges)
 +
 +//Create a modeMap to use modeFilter:
 +e.modeMaps.lsystem = new K.QuantizedMap(1, [1], ['lsystemModeFilter'])
 +
 +//Make Player use the created modeMap:
 +e.players.exampleMidiPlayer1.modeMap = 'lsystem'
 +
 +//Play player:
 +e.play('exampleMidiPlayer1')
 ``` ```
  
Line 358: Line 432:
 Berklee Online. (2023). Circle of Fifths: The Key to Unlocking Harmonic Understanding – Berklee. Berklee Online Take Note. https://online.berklee.edu/takenote/circle-of-fifths-the-key-to-unlocking-harmonic-understanding/ Berklee Online. (2023). Circle of Fifths: The Key to Unlocking Harmonic Understanding – Berklee. Berklee Online Take Note. https://online.berklee.edu/takenote/circle-of-fifths-the-key-to-unlocking-harmonic-understanding/
  
-</markdow +</markdown> 
-n>+
  • music_generation.1710815954.txt.gz
  • Last modified: 2024/03/18 19:39
  • by steve.wang