This is an old revision of the document!
First Steps
Overview: This tutorial will act as a guide about how to get started after installating Konduktiva. See how to install Konduktiva on the Konduktiva Github page
Things To Note: Only follow this tutorial after you have correctly followed the installation instructions.
Start the nodejs REPL in a terminal if you have installed Konduktiva globally (using the -g tag). If not navigate the the directory where you have installed Konduktiva using the cd command or using the file manager navigate to the location you have installed Konduktiva and open a terminal there.:
node
Run the following line of code in the REPL which will load the Konduktiva library if you have installed it throught npm. For loading using other methods go to https://github.com/renickbell/konduktiva/blob/main/README.md#running-the-code|the Running The Code part of the Konduktiva Github page. :
const K = require('konduktiva')
After this is loaded, you will need to open one instance of MIDI output. Next, setup a default/example MusicalEnvironment with
let e = K.setUpMusicalEnvironment(0)
If you log ``e``, you will see that is a MusicalEnvironment class. It has some basic configurations for the new user to get started
you change the tempo(speed) like this
//Makes music go slower e.changeTempo(80) //Makes music go faster e.changeTempo(180)
Before you can start playing music, you have to connect Konduktiva to your music synthesizer of choice. Click here to learn how to do so
Now you can start playing some beats. Try this command to allow one player to start playing.
e.play('exampleMidiPlayer1')
You should here something like this: You can also restart the node session by cressing CTRL + D in the terminal and typing node again. Then you might want to try some of these other functions:
let e = K.setUpMusicalEnvironment(0) e.play('exampleMidiPlayer1') //OR let e = K.setUpMusicalEnvironment(1) e.play('exampleMidiPlayer1') //OR let e = K.setUpMusicalEnvironment(3) e.play('exampleMidiPlayer1')
REMEMBER to restart nodejs everytime you run one of those functions. As you learn more about Konduktiva, you will learn other ways to do this so you do not have to restart node every single time.
Konduktiva can send MIDI messages to more than one music synthesizer session. Try opening another session of your music synthesizer then try this function:
let e = K.setUpMusicalEnvironment(2) e.play('exampleMidiPlayer1') e.play('exampleMidiPlayer2')
You should here both your music synthesizer sessions playing different things. It should sound something like this:
Next open 2 more music synthesizer session. 4 in total and run the code below:
let e = K.setUpMusicalEnvironment(4) e.play('exampleMidiPlayer1') e.play('exampleMidiPlayer2') e.play('exampleMidiPlayer3') e.play('exampleMidiPlayer4')
This might sound something like this:
You can allow multiple players to play simultaneously:
e.play('exampleMidiPlayer3') e.play('exampleMidiPlayer4') e.play('exampleMidiPlayer2')
All the exampleMidiPlayers should be playing now.
After each line you should here an extra layer of sound.
It might sound something like this:
To stop a specific session. This will stop exampleMidiPlayer3 player:
e.stop('exampleMidiPlayer3')
To stop all players:
e.stopAll()
Explanation of K.setUpMusicalEnvironment function:
Argument 0 is for the most basic. Argument 1 is for slightly more complex than the most basic Argument 2 is for two players. Argument 3 is for more complex and longer single player Argument 4 is for 4 players
All the variables that control the music can be set by using the beginner friendly musicalEnvironment configuration objects. Example configuration objects can be found in the file example-melodies-data.js and documentation on the musicalEnvironment configuration objects can be found in the file Konduktiva-documentation.md.
Recommended reading Conceptual Overview
Changing Things Played With Existing QuantizedMaps
The sound output can be easily changed by simply switching the data the player looks at without creating any new data.
Changing notes played
This will cause the notes to loop between 0 to 3.
e.players.exampleMidiPlayer1.noteMap = 'default' //To look at the information being used: console.log(e.noteMaps.default)
Changing modeMap used
This will cause the chord progression form ionian, to phrygian, then to mixolydian.
e.players.exampleMidiPlayer1.modeMap = 'default' //To look at the information being used: console.log(e.modeMaps.default)
Changing melody used
This will cause the player to cycle between the notes 0 to 3.
e.players.exampleMidiPlayer1.noteMap = 'default' //To look at the information being used: console.log(e.noteMaps.default)
Playing Chords
To play chords another action function will have to be used. To switch action functions do this:
e.players.exampleMidiPlayer1.action = 'sendChordMidiInfo'
Or click here to learn more about action functions.
Next Steps
The recommended way to change specific variables in the MusicalEnvironment is to use the addMap method because it checks for many different types of errors and common mistakes when coding quickly. However, if you are confident and need more speed you can choose to directly interact with the MusicalEnvironment object. Here are some examples
Changing Octaves
For example, if I wanted to change the octaves of exampleMidiPlayer4 without changing timing I would do this:
//Identify which octave map exampleMidiPlayer4 is looking at: e.players.exampleMidiPlayer4.octaveMap //Next (the safer way): e.addMap('octaveMaps', e.players.exampleMidiPlayer4.octaveMap, e.octaveMaps[e.players.exampleMidiPlayer4.octaveMap].keyspan, e.octaveMaps[e.players.exampleMidiPlayer4.octaveMap].keys, [[ 6 ], [ 6 ], [ 6 ], [ 6 ], [ 6 ], [ 6 ], [ 6 ], [ 6 ], [ 6 ], [ 6 ], [ 6 ], [ 6 ]] ) //to see the changes: console.log(e.octaveMaps[e.players.exampleMidiPlayer4.octaveMap].values) //OR do this the less safe way but potentially faster with more control: e.octaveMaps[e.players.exampleMidiPlayer4.octaveMap].values =[[ 6 ], [ 6 ], [ 6 ], [ 6 ], [ 6 ], [ 6 ], [ 6 ], [ 6 ], [ 6 ], [ 6 ], [ 6 ], [ 6 ]] //to see the changes: console.log(e.octaveMaps[e.players.exampleMidiPlayer4.octaveMap].values)
Changing RhythmMap
Example changing rhythmMap for exampleMidiPlayer4 without changing timing. Similar to changing octave.
//Recommended safe way: e.addMap('rhythmMaps', e.players.exampleMidiPlayer4.rhythmMap, e.rhythmMaps[e.players.exampleMidiPlayer4.rhythmMap].values[0].keyspan, e.rhythmMaps[e.players.exampleMidiPlayer4.rhythmMap].values[0].keys, [2, 4, 6] ) //other potentially faster way: e.rhythmMaps[e.players.exampleMidiPlayer4.rhythmMap].values[0].values = [2, 4, 6]
Changing Melody, Notes or Chords
Example of changing notes played for exampleMidiPlayer4 Similar to changing octave.:
//Recommended way e.addMap('noteMaps', e.players.exampleMidiPlayer4.noteMap, 5, [0, 1, 2, 3, 4], [ [40],[50], [60], [70], [80]] ) //OR e.noteMaps[e.players.exampleMidiPlayer4.noteMap] = new QuantizedMap(5, [0, 1, 2, 3, 4], [ [40],[50], [60], [70], [80]])
Changing The MusicalEnvironment In General
To change things in the MusicalEnviornment, one should use the addMap method. The documentation is in konduktiva-documentation.md
Or read about the different ways to generate music here