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/17 20:23] steve.wangmusic_generation [2024/05/15 02:04] (current) steve.wang
Line 6: Line 6:
 **Things To Note:** This tutorial assumes you have already installed Konduktiva successfully using the [[https://github.com/renickbell/konduktiva|Konduktiva installation]] instructions and have read through and understood the [[:first_steps|first steps tutorial]]. The tutorial also assumes 2 things. One, Konduktiva has been assigned to the //K// variable. Two, user created a Musical Environment using the //setUpMusicalEnvironment// function using //K.defaultConfigurationObject// as the first argument and //'exampleMidiPlayer'// as the third argument then, assigned the output to the //e// variable. **Things To Note:** This tutorial assumes you have already installed Konduktiva successfully using the [[https://github.com/renickbell/konduktiva|Konduktiva installation]] instructions and have read through and understood the [[:first_steps|first steps tutorial]]. The tutorial also assumes 2 things. One, Konduktiva has been assigned to the //K// variable. Two, user created a Musical Environment using the //setUpMusicalEnvironment// function using //K.defaultConfigurationObject// as the first argument and //'exampleMidiPlayer'// as the third argument then, assigned the output to the //e// variable.
 <code javascript> <code javascript>
-let K = require('./src/combined.js')+const K = require('konduktiva')
 let e = K.setUpMusicalEnvironment(K.defaultConfigurationObject,4,'exampleMidiPlayer', K.exampleMusicalEnvironmentsExtraConfig) let e = K.setUpMusicalEnvironment(K.defaultConfigurationObject,4,'exampleMidiPlayer', K.exampleMusicalEnvironmentsExtraConfig)
 </code> </code>
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 274: Line 329:
 ``` ```
 //Generate the random notes: //Generate the random notes:
-randomMelodyExample = K.generateRandomMelody('C', 'bluesPentatonicScale', 10, 4, 6)+randomMelodyExample = K.generateRandomMelody('C', 'blues', 10, 4, 6)
 /*output: /*output:
 [ [
Line 330: Line 385:
  
 //configure player to use it: //configure player to use it:
-e.players.exampleMidiPlayer1 = 'aeolianAndDorian'+e.players.exampleMidiPlayer1.modeMap = 'aeolianAndDorian'
  
 //make that player play: //make that player play:
 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 359: Line 433:
  
 </markdown> </markdown>
 +
  • music_generation.1710732202.txt.gz
  • Last modified: 2024/03/17 20:23
  • by steve.wang