class-musicalenvironment

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
class-musicalenvironment [2022/03/19 05:18] renickclass-musicalenvironment [2023/10/05 22:46] (current) steve.wang
Line 1: Line 1:
 ====== class: MusicalEnvironment ====== ====== class: MusicalEnvironment ======
- +<markdown> 
-===== Description =====+## MusicalEnvironment
  
 This is a class used for storing all of the data that is needed for producing a performance with Konduktiva, including Players, Actions, IOI functions, RhythmMaps, and so on. This is a class used for storing all of the data that is needed for producing a performance with Konduktiva, including Players, Actions, IOI functions, RhythmMaps, and so on.
 +You populate the MusicalEnvironment with Players, IOI functions, and action functions. The tempo exists as a property of this MusicalEnvironment.
 +
 +### Constructor
 + The constructor takes no arguments. Call it to get a default MusicalEnvironment which can then be adjusted to your needs.
 + 
 + ```
 + e = new MusicalEnvironment();
 + ```
 +
 +### Variables in the MusicalEnvironment
 +The titles of each variable in this documentation are aimed at giving as much information as possible. For example, the first title "bools: boolean[]". "bools" is the variable name and "boolean[]" tells you that the variable bools is supposed to be an array full of booleans.
 +
 +#### actions: function{}
 +Actions functions that can be used are stored here.
 +#### beatOfChangeToCurrentTempo: number
 +#### chordProgressions: QuantizedMap{}
 +Chord progressions that players can use. The keys are the beats/time of when the player should change the playing chord progression.
 +
 +#### controlChangeMaps: QuanitzedMap{} (experimental)(optional)
 +Not filling this in deactivates this specific feature.
 +
 +Control Change maps players can use. The keys are the beats/time of when to send the actual CC messages in the values.
 +#### currentBeatsPerMeasure: number
 +Shows the current beats per measure. Default is 4.
 +#### currentDensityGraphs: string[]
 +An array of densityGraph names. The acutal densityGraphs are stored in the [densityGraphs variable](#densityGraphs).
 +#### currentTempo: 
 +Returns the current tempo of the MusicalEnvironment. To change the tempo use the [changeTempo method](#changeTempo).
 +#### densityGraphs: object{}
 +An object filled with densityGraphs. The actual graphs are in form of QuantizedMaps. So, it is a QuantizedMap in an object in another object.
 +#### IOIs: function{}
 +IOI function are stored here.
 +#### lookahead: number
 +Returns the lookahead time.
 +#### maskMaps: QuantizedMap{}
 +maskMaps are basically the booleans. The keys are the time and the values are trues or falses. If it is a true for a specific time, the action function will be called. If it is a false, action function will not be called.
 +#### maxPolyphonyMaps: QuantizedMap{} (optional)
 +Not filling this in will deactivate this specific feature.
 +
 +Sets the amount of midi notes a player is allowed to play at a given beat. The keys are the beats and the values are the amount of midi notes the player is allowed to play.
 +#### modeFilters: QuantizedMap{}
 +The mode players should filter. 
 +#### modeMaps: QuantizedMap{}
 +The keys and values of modeFilters should be at a given beat. The modeMaps values are strings which are names of modes. The modes currently available as of the time of writing are, ionian, dorian, phrygian, lydian, mixolydian, aeolian, locrian. To get all of the Modes available to you, run this line of code after loading Konduktiva into nodejs. ``` Mode.all().forEach(x => console.log(x.name)) ``` This will list all the modes the tonal library has available.
 +#### noteDurationMaps: QuantizedMap{}
 +These QuantizeMaps store how long each note should play for at a given beat. They are the note spans. The keys are the beats and the values are the 
 +CONFIRMING WITH BELL ON HOLD
 +
 +#### noteMaps: QuantizedMap{}
 +Stores the noteValues. The keys is the beats and the values are the notes to play.
 +#### notesInputMode: string
 +Two options ```relativeSemitone``` or ```relativeScaleDegree```. This changes how the action function uses the noteMaps
 +#### octaveMaps: QuantizedMap{}
 +Stores the octaves the action function should use at a given beat. The keys are the beats and the values are the octaves to use.
 +#### outputs: object[]
 +An array full of midi outputs that can be used by easymidi. To update this list run this function ```updateMidiOutputList(e)```. Replace ```e``` with your MusicalEnvironment variable name.
 +#### players: object[]
 +An array full of player objects. Find out more by looking at the [player](#Players-and-the-two-important-functions-they-reference:-IOI-functions-and-action-functions) section.
 +#### rhythmMaps: QuantizedMap{}
 +CHECK WITH BELL
 +#### rhythmPatterns: QuantizedMap{}
 +Needed to call ```rhythmPattern.add(e, playerName) for things to work correctly. Ask bell.
 +#### root: string
 +The root letter. By default it is 'A'c
 +#### rootMaps: QuantizedMap{}
 +Stores the root English letters. The keys are the beats and the values are the English letters.
 +#### sampleKits
 +#### samplePatternCount
 +#### samplePatternStore
 +#### samplePatterns
 +#### samples
 +#### scheduledPlayers
 +#### scheduler
 +Tasktimer? ASK BELL
 +#### song: QuantizedMap{} (optional)
 +Not filling this in deactivates this specific feature.
 +
 +The chord progression a player should play at a given beat. The keys are the beats and the values are the chord progression names in form of strings. The action function will check if the chordProgression map is playing the correct chord progression according to this.c
 +#### superDirtPath
 +#### timeOfChangeToCurrentTempo
 +#### velocityMaps: QuantizedMap{}
 +Controls the midi velocity variable from 0-127 at a given beat. The keys are the beats and the values are the velocity.
 +
 +### Methods in the MusicalEnvironment
 +### currentBeat
 +-> Number
 +
 +Returns the current beat of the MusicalEnvironment
 +##### Syntax
 +```
 +e.currentBeat()
 +```
 +
 +##### Parameters
 +
 +##### Examples
 +```
 +console.log(e.currentBeat())
 +```
 +
 +---
 +
 +---
 +
 +### changeTempo
 +Number ->
 +
 +Takes a number as an argument and changes the currentTempo to that number.
 +##### Syntax
 +```
 +e.changeTempo(tempo)
 +```
 +
 +##### Parameters
 +###### tempo
 +New tempo of the current MusicalEnvironment
 +
 +##### Examples
 +```
 +console.log(e.changeTempo(100)) //TEMPO CHANGE! time: 5.690928572999313; beat: 8.493846618000418
 +console.log(e.changeTempo(120)) //TEMPO CHANGE! time: 22.66408885199949; beat: 36.78241345300153
 +```
 +
 +---
 +
 +---
 +
 +### getAction
 +string -> Function
 +
 +Returns the action function of a specific player in this MusicalEnvironment
 +Takes player name in form of a string as an argument.
 +##### Syntax
 +```
 +e.getAction(player)
 +```
 +
 +##### Parameters
 +###### player
 +Name of a variable in e.players
 +
 +##### Examples
 +```
 +console.log(e.getAction('kick')) //[Function (anonymous)]
 +console.log(e.getAction('snare')) //[Function (anonymous)]
 +```
 +
 +---
 +
 +---
 +
 +### getIOIFunc
 +string -> Function
 +
 +Returns the IOI function of a specific player in this MusicalEnvironment.
 +
 +##### Syntax
 +```
 +e.getIOIFunc(player)
 +```
 +
 +##### Parameters
 +###### player
 +Name of a variable in e.players
 +
 +##### Examples
 +```
 +console.log(e.getIOIFunc('kick')) //[Function: defaultIOI]
 +console.log(e.getIOIFunc('snare')) //[Function: defaultIOI]
 +```
 +
 +---
 +
 +---
 +
 +### scheduleEvents
 +ASK BELL
 +string -> 
 +
 +Returns the IOI function of a specific player in this MusicalEnvironment. Not meant to be called by user.
 +##### Syntax
 +```
 +e.scheduledPlayers(player)
 +```
 +
 +##### Parameters
 +###### player
 +Name of a variable in e.players
 +
 +##### Examples
 +```
 +e.scheduleEvents('musicSynthesizerSession1')
 +```
 +
 +---
 +
 +---
 +
 +### startScheduler
 +
 +Starts the scheduler for the MusicalEnvironment. It takes no arguments and returns nothing.
 +##### Syntax
 +```
 +e.startScheduler()
 +```
 +
 +##### Parameters
 +
 +##### Examples
 +```
 +e.startScheduler()
 +```
 +
 +---
 +
 +---
 +
 +### stopScheduler
 +
 +Stops the scheduler for the MusicalEnvironment. Takes no arguments and retunrs nothing.
 +##### Syntax
 +```
 +e.stopScheduler()
 +```
 +
 +##### Parameters
 +
 +##### Examples
 +```
 +e.stopScheduler()
 +```
 +
 +---
 +
 +---
 +
 +### play
 +String -> 
 +
 +#### Syntax
 +```
 +e.play(player)
 +```
 +
 +#### Parameters
 +##### players
 +Player name
 +
 +### Examples
 +```
 +e.play('musicSynthesizerSession1')
 +```
 +
 +---
 +
 +---
 +
 +### stop
 +String -> 
 +
 +#### Syntax
 +```
 +e.stop(player)
 +```
 +
 +#### Parameters
 +##### players
 +Player name
 +
 +### Examples
 +```
 +e.stop('musicSynthesizerSession1')
 +```
 +
 +---
 +
 +---
 +
 +### allPlayers
 + -> 
 +
 +Returns an array of all the player names.
 +##### Syntax
 +```
 +e.allPlayers()
 +```
 +
 +##### Parameters
 +
 +##### Examples
 +```
 +console.log(e.allPlayers)
 +```
 +
 +---
 +
 +---
 +
 +### allPlayerStatus
 + -> [[String, String] ...]
 +
 +Returns an array full of arrays. Each sub array contains the player name and their status. All the player names and their status also gets logged into the console.
 +##### Syntax
 +```
 +e.allPlayerStatus()
 +```
 +
 +##### Parameters
 +
 +##### Examples
 +```
 +console.log(e.allPlayerStatus())
 +/*
 +[
 +  [ 'kick', 'stopped' ],
 +  [ 'snare', 'stopped' ],
 +  [ 'perc', 'stopped' ],
 +  [ 'hat', 'stopped' ],
 +  [ 'sub', 'stopped' ],
 +  [ 'stab1', 'stopped' ],
 +  [ 'stab2', 'stopped' ],
 +  [ 'atmo', 'stopped' ],
 +  [ 'musicSynthesizerSession1', 'stopped' ]
 +]
 +*/
 +```
 +
 +---
 +
 +---
 +
 +### playingPlayers
 + ->
 +
 +Returns an array of all the names of players that are currently playing.
 +##### Syntax
 +```
 +e.playingPlayers()
 +```
 +
 +##### Parameters
 +
 +##### Examples
 +```
 +console.log(e.playingPlayers()) //[]
 +```
 +
 +---
 +
 +---
 +
 +### playN
 +[String] -> 
 +
 +Starts playing all the player names in the array.
 +
 +##### Syntax
 +```
 +e.playN(ps)
 +```
 +
 +##### Parameters
 +###### ps
 +An array of player names.
 +
 +##### Examples
 +```
 +e.playN(['musicSynthesizerSession1', 'musicSynthesizerSession2'])
 +```
 +
 +---
 +
 +---
 +
 +
 +### stopN
 +[String] -> 
 +
 +Stops playing all the player names in the array.
 +
 +##### Syntax
 +```
 +e.stopN(ps)
 +```
 +
 +##### Parameters
 +###### ps
 +An array of player names.
 +
 +##### Examples
 +```
 +e.stopN(['musicSynthesizerSession1', 'musicSynthesizerSession2'])
 +```
 +
 +---
 +
 +---
 +
 +### playAll
 + ->
 +
 +All players start playing.
 +
 +##### Syntax
 +```
 +e.playAll()
 +```
 +
 +##### Parameters
 +
 +##### Examples
 +```
 +e.playAll()
 +```
 +
 +---
 +
 +---
 +
 +### stopAll
 + ->
 +
 +All players stop playing.
 +
 +##### Syntax
 +```
 +e.stopAll()
 +```
 +
 +##### Parameters
 +
 +##### Examples
 +```
 +e.stopAll()
 +```
 +
 +---
 +
 +---
 +
 +### solo
 +
 +[String] ->
 +
 +Stops playing all the player names in the array after checking if the players exist inside the MusicalEnvironment.
 +##### Syntax
 +```
 +e.solo(ps)
 +```
 +
 +##### Parameters
 +###### ps
 +An array of player names.
 +
 +##### Examples
 +```
 +e.stopN(['musicSynthesizerSession1', 'musicSynthesizerSession2'])
 +```
 +
 +---
 +
 +---
 +
 +### togglePlayer
 +String -> 
 +
 +Toggles the state of a specific player. If that player is playing it will be stopped. If that player is stopped, it will start playing.
 +
 +##### Syntax
 +```
 +e.togglePlayer(p)
 +```
  
-===== Constructor =====+##### Parameters 
 +###### p 
 +Player name
  
-The constructor takes no arguments. Call it to get a default MusicalEnvironment which can then be adjusted to your needs.+##### Examples 
 +``` 
 +e.togglePlayer('musicSynthesizerSession1'
 +```
  
-<code> +---
-e = new MusicalEnvironment(); +
-</code>+
  
-===== Static Properties =====+--- 
 +## Interacting with the Musical Environment
  
-===== Static Methods =====+There are different ways you can interacte and change things in the MusicalEnvironment. You can change it by doing ```e.variable ```. This way is excellent if you are familliar with what you are doing and if you have time. When live coding we often have to act and think quickly. When doing this is is especially easy to make mistakes when making QuanitzedMaps. 
  
-===== Instance Properties =====+### addMapToMusicalEnvironment
  
-  - players +This function helps add QuantizedMaps into the MusicalEnvironment with correct types. If something is wrong, this function will throw an error.  
-  - actions +##### Syntax 
-  - IOIs +``` 
-  - densityGraphs +addMapToMusicalEnvironment (e, objectName, mapName, keyspan, keys, values) 
-  - rhythmMaps +```
-  - maskMaps +
-  - superDirtPath +
-  - samples +
-  - sampleKits +
-  - samplePatterns +
-  - samplePatternCount +
-  - samplePatternStore +
-  - currentDensityGraphs +
-  - currentBeatsPerMeasure +
-  - currentTempo +
-  - beatOfChangeToCurrentTempo +
-  - timeOfChangeToCurrentTempo +
-  - scheduler +
-  - lookahead +
-  - scheduledPlayers +
-  - scale +
-  - root+
  
-===== Instance Methods =====+##### Parameters 
 +###### e 
 +MusicalEnvironment 
 +###### objectName 
 +Name of a variable in the MusicalEnvironment to add to. 
 +###### mapName 
 +Name of the new QuantizedMap. 
 +###### keyspan 
 +Th keyspan of the new QuantizedMap. 
 +###### keys 
 +The keys of the new QuantizedMap. 
 +###### values 
 +The values of the new QuantizedMap.
  
-  - currentBeat +##### Examples 
-  - changeTempo +``` 
-  - getAction +addMapToMusicalEnvironment(e, 'rhythmMaps', 'chalk', 10, [0, 1, 2, 3], [4, 5, 6, 7]) 
-  - getIOIFunc +console.log(e.rhythmMaps.chalk) 
-  - scheduleEvents +/* 
-  - startScheduler +QuantizedMap { 
-  - play +  keyspan: 1, 
-  - stop +  keys: [ 1 ], 
-  - allPlayers +  values: QuantizedMap { 
-  - allPlayerStatus +    keyspan: 10, 
-  - playingPlayers +    keys: [ 0, 1, 2, 3 ], 
-  - playN +    values: [ 4, 5, 6, 7 ] 
-  - stopN +  } 
-  - playAll +} 
-  - stopAll +*/ 
-  - solo +```
-  - togglePlayer+
  
-===== Examples =====+---
  
 +---
 +</markdown>
  • class-musicalenvironment.1647692303.txt.gz
  • Last modified: 2022/03/19 05:18
  • by renick