creating-players

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
creating-players [2024/02/29 00:48] – [recordConfigurationDataIntoMusicalEnvironment] steve.wangcreating-players [2024/03/18 20:22] (current) – [Example] steve.wang
Line 3: Line 3:
 **Overview: ** This tutorial will teach you how to create your own players like the ones that came with the example MusicalEnvironment. **Overview: ** This tutorial will teach you how to create your own players like the ones that came with the example MusicalEnvironment.
  
-**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 that you have imported Konduktiva to the //K// variable and assigned any of the example MusicalEnvironments 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> 
 +const K = require('konduktiva'
 +let e = K.setUpMusicalEnvironment(K.defaultConfigurationObject,4,'exampleMidiPlayer', K.exampleMusicalEnvironmentsExtraConfig) 
 +</code>
  
  
Line 17: Line 21:
  
 <code javascript> <code javascript>
 +
 let emptyConfig = K.emptyConfigObj() let emptyConfig = K.emptyConfigObj()
 console.log(emptyConfig) console.log(emptyConfig)
Line 50: Line 55:
 undefined undefined
 */ */
 +
 </code> </code>
  
 Run this to view what type of input each configuration option is expecting: Run this to view what type of input each configuration option is expecting:
 <code javascript> <code javascript>
 +
 K.emptyConfigObj.toString() K.emptyConfigObj.toString()
 +
 </code> </code>
  
 Or view an empty configuration object with the expected type input each configuration object is expecting here: Or view an empty configuration object with the expected type input each configuration object is expecting here:
 <code javascript> <code javascript>
 +
 { {
         total: undefined, //number         total: undefined, //number
Line 92: Line 101:
         channelValues: undefined, //[number]         channelValues: undefined, //[number]
     }     }
 +    
 </code> </code>
  
Line 97: Line 107:
  
 ===== recordConfigurationDataIntoMusicalEnvironment ===== ===== recordConfigurationDataIntoMusicalEnvironment =====
 +
 Object -> string -> MusicalEnvironment -> string Object -> string -> MusicalEnvironment -> string
  
 Takes the configuration object (first argument) and puts it into the MusicalEnvironment(third argument) under the user provided name (second argument). Takes the configuration object (first argument) and puts it into the MusicalEnvironment(third argument) under the user provided name (second argument).
  
-==== Syntax+==== Syntax ====
 <code javascript> <code javascript>
 +
 K.recordConfigurationDataIntoMusicalEnvironment (noteValueData, name, e) K.recordConfigurationDataIntoMusicalEnvironment (noteValueData, name, e)
 +
 </code> </code>
  
-==== Parameters  +==== Parameters ==== 
-=== noteValueData+=== noteValueData ===
 The configuration object. The configuration object.
-=== name+=== name ===
 The name of the items the function should create. The name of the items the function should create.
-=== e+=== e ===
 The MusicalEnvironment the information should be recorded in. The MusicalEnvironment the information should be recorded in.
  
-==== Example+==== Example ====
 <code javascript> <code javascript>
 //Code modified from Konduktiva setUpVerySimpleMusicalEnvironment function //Code modified from Konduktiva setUpVerySimpleMusicalEnvironment function
 //Create configuration object: //Create configuration object:
 let simpleMelodyData = K.R.clone(K.simpleMelodyDataTemplate) let simpleMelodyData = K.R.clone(K.simpleMelodyDataTemplate)
 +//K.simpleMelodyDataTemplate is a simple template of a configuration object
 simpleMelodyData.velocity = [100, 100, 100, 100] simpleMelodyData.velocity = [100, 100, 100, 100]
-simpleMelodyData.rhythmMap = [1, 234]+simpleMelodyData.rhythmMap = [1, 111]
 simpleMelodyData.noteValues = [[1], [2], [3], [4]] simpleMelodyData.noteValues = [[1], [2], [3], [4]]
 simpleMelodyData.rootMap = [ 'C', 'C', 'C', 'C' ] simpleMelodyData.rootMap = [ 'C', 'C', 'C', 'C' ]
  
 //Add it to MuiscalEnvironment: //Add it to MuiscalEnvironment:
-recordConfigurationDataIntoMusicalEnvironment(simpleMelodyData, 'p1', e)+K.recordConfigurationDataIntoMusicalEnvironment(simpleMelodyData, 'p1', e)
 </code> </code>
  
 Next a Player has to be created to make use of the data in the MusicalEnvironment. Use the //assignPlayerForMusicSynthesizerMidiOutput// function to do so. Next a Player has to be created to make use of the data in the MusicalEnvironment. Use the //assignPlayerForMusicSynthesizerMidiOutput// function to do so.
  
-===== assignPlayerForMusicSynthesizerMidiOutput+===== assignPlayerForMusicSynthesizerMidiOutput =====
 MusicalEnvironment -> string -> string -> Object ->  MusicalEnvironment -> string -> string -> Object -> 
  
 Function will configure a player to use the maps under the defaultName(second argument) unless otherwise stated in the playerData object (fourth argument). The code will create a player if a player by the name user provided (third argument) is not found. If found will modify the player found. Function will configure a player to use the maps under the defaultName(second argument) unless otherwise stated in the playerData object (fourth argument). The code will create a player if a player by the name user provided (third argument) is not found. If found will modify the player found.
  
-==== Syntax+==== Syntax ====
 <code javascript> <code javascript>
 K.assignPlayerForMusicSynthesizerMidiOutput (e, defaultName, playerName, playerData) K.assignPlayerForMusicSynthesizerMidiOutput (e, defaultName, playerName, playerData)
 +</code>
  
-==== Parameters +==== Parameters ==== 
-=== e+=== e ===
 MusicalEnvironment MusicalEnvironment
-=== defaultName+=== defaultName ===
 The name that the function will default all player variables it will configure to unless otherwise stated. The name that the function will default all player variables it will configure to unless otherwise stated.
-=== playerData+=== playerData ===
 Names to assign specific variables to. Overrides the default name. An object with all the argument variables set to undefined can be found by running the emptyPlayerDataConfigObj function found inside the Konduktiva package. The types of input the argument variables expect can be found as comments inside the function which can be viewed in the source code or simply using the JavaScript built in .toString() method.  Names to assign specific variables to. Overrides the default name. An object with all the argument variables set to undefined can be found by running the emptyPlayerDataConfigObj function found inside the Konduktiva package. The types of input the argument variables expect can be found as comments inside the function which can be viewed in the source code or simply using the JavaScript built in .toString() method. 
  
-==== Example+==== Example ===
 The example here is a continuation of the example from above. If you have not run the code from the example from above here it is again: The example here is a continuation of the example from above. If you have not run the code from the example from above here it is again:
 <code javascript> <code javascript>
Line 153: Line 168:
 //Create configuration object: //Create configuration object:
 let simpleMelodyData = K.R.clone(K.simpleMelodyDataTemplate) let simpleMelodyData = K.R.clone(K.simpleMelodyDataTemplate)
 +//K.simpleMelodyDataTemplate is a simple template of a configuration object
 simpleMelodyData.velocity = [100, 100, 100, 100] simpleMelodyData.velocity = [100, 100, 100, 100]
-simpleMelodyData.rhythmMap = [1, 234]+simpleMelodyData.rhythmMap = [1, 111]
 simpleMelodyData.noteValues = [[1], [2], [3], [4]] simpleMelodyData.noteValues = [[1], [2], [3], [4]]
 simpleMelodyData.rootMap = [ 'C', 'C', 'C', 'C' ] simpleMelodyData.rootMap = [ 'C', 'C', 'C', 'C' ]
  
 //Add it to MuiscalEnvironment: //Add it to MuiscalEnvironment:
-recordConfigurationDataIntoMusicalEnvironment(simpleMelodyData, 'p1', e)+K.recordConfigurationDataIntoMusicalEnvironment(simpleMelodyData, 'p1', e)
 </code> </code>
  
 New example starts here: New example starts here:
 <code javascript> <code javascript>
 +//make or modify player to use info:
 +K.assignPlayerForMusicSynthesizerMidiOutput(e, 'p1','exampleMidiPlayer1')
 +//configure legatoMap:
 +e.players.exampleMidiPlayer1.legatoMap = 'default'
  
 +//signal to player to start playing:
 +e.play('exampleMidiPlayer1')
 +</code>
 +
 +===== configObjCreation =====
 +Number -> [Number] -> [Number] -> [String] -> [[Number]] -> [Number] -> [Number] -> Object
 +
 +A useful tool for creating very basic configuration objects.
 +
 +==== Syntax ====
 +<code javascript>
 +K.configObjCreation (total, keys, octave, root, note, noteDuration, velocity)
 +</code>
 +
 +==== Paramters ====
 +=== total ===
 +They keyspan of the QuantizedMaps. Also the total variable in the configuration object.
 +=== keys ====
 +The keys of the QuantizedMaps.
 +=== octave ===
 +The value of the octave maps
 +=== root ===
 +The value of the root maps.
 +=== note ===
 +The value of the note maps.
 +=== noteDuration ===
 +The value of the noteDuration maps.
 +=== velocity===
 +The value of the velocity maps.
 +
 +==== Example ====
 +<code javascript>
 +let basicConfig = K.configObjCreation(4, [0, 1, 2, 3], [3, 3, 3, 3], ['C', 'C', 'C', 'C'], [[3], [4], [5], [6]], [2, 2, 2, 2], [100, 100, 100, 100])
 +</code>
  • creating-players.1709196485.txt.gz
  • Last modified: 2024/02/29 00:48
  • by steve.wang