class-musicalenvironment

class: 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. You populate the MusicalEnvironment with Players, IOI functions, and action functions. The tempo exists as a property of this MusicalEnvironment.

The constructor takes no arguments. Call it to get a default MusicalEnvironment which can then be adjusted to your needs.

 e = new 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.

currentTempo:

Returns the current tempo of the MusicalEnvironment. To change the tempo use the changeTempo method.

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 `relativeSemitoneorrelativeScaleDegree`. 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 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.

-> Number

Returns the current beat of the MusicalEnvironment

Syntax
e.currentBeat()
Parameters
Examples
console.log(e.currentBeat())


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


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)]


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]


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')


Starts the scheduler for the MusicalEnvironment. It takes no arguments and returns nothing.

Syntax
e.startScheduler()
Parameters
Examples
e.startScheduler()


Stops the scheduler for the MusicalEnvironment. Takes no arguments and retunrs nothing.

Syntax
e.stopScheduler()
Parameters
Examples
e.stopScheduler()


String ->

Syntax

e.play(player)

Parameters

players

Player name

e.play('musicSynthesizerSession1')


String ->

Syntax

e.stop(player)

Parameters

players

Player name

e.stop('musicSynthesizerSession1')


->

Returns an array of all the player names.

Syntax
e.allPlayers()
Parameters
Examples
console.log(e.allPlayers)


-> [[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' ]
]
*/


->

Returns an array of all the names of players that are currently playing.

Syntax
e.playingPlayers()
Parameters
Examples
console.log(e.playingPlayers()) //[]


[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'])


[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'])


->

All players start playing.

Syntax
e.playAll()
Parameters
Examples
e.playAll()


->

All players stop playing.

Syntax
e.stopAll()
Parameters
Examples
e.stopAll()


[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'])


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)
Parameters
p

Player name

Examples
e.togglePlayer('musicSynthesizerSession1')


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.

This function helps add QuantizedMaps into the MusicalEnvironment with correct types. If something is wrong, this function will throw an error.

Syntax
addMapToMusicalEnvironment (e, objectName, mapName, keyspan, keys, values)
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.

Examples
addMapToMusicalEnvironment(e, 'rhythmMaps', 'chalk', 10, [0, 1, 2, 3], [4, 5, 6, 7])
console.log(e.rhythmMaps.chalk)
/*
QuantizedMap {
  keyspan: 1,
  keys: [ 1 ],
  values: QuantizedMap {
    keyspan: 10,
    keys: [ 0, 1, 2, 3 ],
    values: [ 4, 5, 6, 7 ]
  }
}
*/


  • class-musicalenvironment.txt
  • Last modified: 2023/10/05 22:46
  • by steve.wang