Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
action-functions [2024/02/08 23:32] – [Action Functions] steve.wang | action-functions [2024/04/24 17:37] (current) – [midiSequencedRhythm/callMusicSynthesizerRhythm:] steve.wang | ||
---|---|---|---|
Line 2: | Line 2: | ||
**Overview: ** This tutorial will teach you about what actions function do in Konduktiva and how they work. | **Overview: ** This tutorial will teach you about what actions function do in Konduktiva and how they work. | ||
- | **Things To Note:** This tutorial assumes you have already installed Konduktiva successfully using the [[https:// | ||
- | An Action Function is the function the player calls when the Konduktiva scheduler tells it that to do something. The action function the player uses can be controlled at the variable // | + | **Things To Note:** This tutorial assumes you have already installed Konduktiva successfully using the [[https:// |
+ | <code javascript> | ||
+ | const K = require(' | ||
+ | let e = K.setUpMusicalEnvironment(K.defaultConfigurationObject, | ||
+ | </ | ||
+ | |||
+ | |||
+ | An Action Function is the function the player calls when the Konduktiva scheduler tells it that to do something. | ||
<code javascript> | <code javascript> | ||
//Code will work if you have imported Konduktiva to K variable and assigned any of the example MusicalEnvironments to e. | //Code will work if you have imported Konduktiva to K variable and assigned any of the example MusicalEnvironments to e. | ||
Line 14: | Line 20: | ||
</ | </ | ||
- | To test if the action function is being triggered you can assign the player to use the default action function and turn on verbose: | + | To test if the action function is being triggered you can assign the player to use the default action function and turn on verbose. Verbose is a feature that will prompt the functions to log many things which is useful for debugging.: |
<code javascript> | <code javascript> | ||
e.players.exampleMidiPlayer1.action = ' | e.players.exampleMidiPlayer1.action = ' | ||
Line 33: | Line 39: | ||
==== default: ==== | ==== default: ==== | ||
{{ : | {{ : | ||
- | ==== midiSequencedRhythm/ | ||
- | {{ : | ||
==== sendNotesMidiInfo: | ==== sendNotesMidiInfo: | ||
Line 50: | Line 54: | ||
**Overview: ** This tutorial will teach you how to make your own action function by going through the steps of making a new action function called // | **Overview: ** This tutorial will teach you how to make your own action function by going through the steps of making a new action function called // | ||
- | **Things To Note:** This tutorial assumes you have already installed Konduktiva successfully using the [[https:// | + | **Things To Note:** This tutorial assumes you have already installed Konduktiva successfully using the [[https:// |
Setup: | Setup: | ||
<code javascript> | <code javascript> | ||
const K = require(' | const K = require(' | ||
- | let e = K.setUpMusicalEnvironment(1) | + | let e = K.setUpMusicalEnvironment(K.defaultConfigurationObject, |
</ | </ | ||
Line 69: | Line 73: | ||
console.log(' | console.log(' | ||
console.log(' | console.log(' | ||
- | console.log(' | + | console.log(' |
} | } | ||
</ | </ | ||
+ | |||
+ | Notice we did not use b argument. The b argument is for next onset. To get beat use e.currentBeat(). | ||
Next we have to make it so the players in the MusicalEnvironment can use it. To do so, we have the add it to the actions object of the MusicalEnvironment: | Next we have to make it so the players in the MusicalEnvironment can use it. To do so, we have the add it to the actions object of the MusicalEnvironment: | ||
Line 90: | Line 96: | ||
<code javascript> | <code javascript> | ||
- | function | + | function |
| | ||
let noteToPlay = K.randomRange(0, | let noteToPlay = K.randomRange(0, | ||
Line 106: | Line 112: | ||
}, 1000) | }, 1000) | ||
} | } | ||
- | e.actions.sendMidiData | + | e.actions.sendRandomMidiNote |
- | e.players.exampleMidiPlayer1.action = 'sendMidiData' | + | e.players.exampleMidiPlayer1.action = 'sendRandomMidiNote' |
e.play(' | e.play(' | ||
</ | </ | ||
+ | |||
+ | It should sound something like this: | ||
+ | |||
+ | {{ : | ||
[[http:// | [[http:// |