Differences
This shows you the differences between two versions of the page.
| live-coding-melody-and-harmony-in-javascript-code-examples [2024/08/10 05:38] – created steve.wang | live-coding-melody-and-harmony-in-javascript-code-examples [2024/08/10 06:57] (current) – steve.wang | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| <code javascript> | <code javascript> | ||
| + | let exampleQMap = new K.QuantizedMap(4, | ||
| + | |||
| + | // | ||
| + | exampleQMap.wrapLookup(1.5) //' | ||
| + | exampleQMap.wrapLookup(4) //' | ||
| + | exampleQMap.wrapLookup(6.5) //' | ||
| + | </ | ||
| + | |||
| + | ===== Viewing QuantizedMaps in MusicalEnvironment ===== | ||
| + | |||
| + | <code javascript> | ||
| + | console.log(e.octaveMaps) | ||
| + | console.log(e.noteMaps) | ||
| + | console.log(e.chordMaps) | ||
| + | console.log(e.modeFilters) | ||
| + | </ | ||
| + | |||
| + | ===== Stochastic algorithm for generating melodies based on modes ===== | ||
| + | |||
| + | https:// | ||
| + | |||
| + | ===== Deterministic algorithm for generating melodies based on L-systems ===== | ||
| + | |||
| + | https:// | ||
| + | |||
| + | |||
| + | ===== Algorithm for chord progressions based on the circle of fifths ===== | ||
| + | |||
| + | https:// | ||
| + | |||
| + | ===== Using Algorithmically Generated Chords and Melodies Together ===== | ||
| + | A function that filters note according to player modeFilter. | ||
| + | |||
| + | <code javascript> | ||
| + | //Configure Player to use harmonic minor modeFilter: | ||
| + | e.modeMaps.default.values[0] = ' | ||
| + | |||
| + | //Checking all three individually: | ||
| + | console.log(K.filterMode(2, | ||
| + | console.log(K.filterMode(5, | ||
| + | console.log(K.filterMode(10, | ||
| + | |||
| + | //Checking all with array: | ||
| + | console.log([2, | ||
| + | return K.filterMode(x, | ||
| + | })) //[ 2, 5, 8 ] | ||
| + | </ | ||
| + | |||
| + | ===== Figure 7b ===== | ||
| + | |||
| + | <code javascript> | ||
| + | e.modeFilters[' | ||
| + | e.modeFilters[' | ||
| + | e.modeFilters[' | ||
| + | |||
| + | e.modeMaps.customExample = new K.QuantizedMap(9, | ||
| + | |||
| + | e.players.exampleMidiPlayer1.modeMap = ' | ||
| + | |||
| + | console.log([1, | ||
| + | return K.filterMode(x, | ||
| + | })) | ||
| + | console.log([3, | ||
| + | return K.filterMode(x, | ||
| + | })) | ||
| + | console.log([9, | ||
| + | return K.filterMode(x, | ||
| + | })) | ||
| + | </ | ||
| + | |||
| + | ===== Making Music In Konduktiva with our Additions ===== | ||
| + | |||
| + | <code javascript> | ||
| + | K.addChordProgressionFromRomanNumeral(e, | ||
| + | |||
| + | console.log(e.chordMaps.exampleProgression) | ||
| + | console.log(e.rootMaps.exampleProgression) | ||
| + | </ | ||
| + | |||
| + | ===== simpleRhythmPattern ===== | ||
| + | |||
| + | <code javascript> | ||
| + | K.simpleRhythmPattern (e, | ||
| + | { | ||
| + | voice: ' | ||
| + | patternName: | ||
| + | patternLength: | ||
| + | IOIs: [1,1,1,1], | ||
| + | bools: [true, | ||
| + | } | ||
| + | ) | ||
| + | |||
| + | console.log(e.rhythmMaps.testKick) | ||
| + | |||
| + | console.log(e.rhythmMaps.testKick.values) | ||
| + | </ | ||