adding-midi-file-to-musical-environment

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
adding-midi-file-to-musical-environment [2024/01/22 17:55] steve.wangadding-midi-file-to-musical-environment [2024/03/20 18:37] (current) steve.wang
Line 3: Line 3:
 **Overview: ** A midi file can be played via Konduktiva. During this process, the midi data will also be convert in forms to normal Konduktiva information (Quantized maps etc.) **Overview: ** A midi file can be played via Konduktiva. During this process, the midi data will also be convert in forms to normal Konduktiva information (Quantized maps etc.)
  
-**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>
  
 ===== addMidiFileToMusicalEnvironment ===== ===== addMidiFileToMusicalEnvironment =====
-String -> String -> MusicalEnvironment ->+String -> String -> MusicalEnvironment -> Function
  
-This function will automatically create or modify the player with the same name as the midi file to be usedThe number of players created will be based the amount of tracks that have MIDI on/off messages and MIDI CC messages in them.Quantized maps will be automatically created based on the Midi dataTempo and time signature will also automatically be modified+This function will automatically create QuantizedMaps based on midi information in the file and add them to the MusicalEnvironmentIt will then return a function that when called will create or edit players based on the player names provided to use the maps created by the parent function "addMidiFileToMusicalEnvironment". It will also automatically configure the tempo and the time signature of the MusicalEnvironment to match the MIDI fileIt will then return an array of the names of the players it has modified or createdIt will throw and error if insufficient player names are provided. Extra player names provided will be ignored.
  
 ==== Syntax ==== ==== Syntax ====
 <code javascript> <code javascript>
-addMidiFileToMusicalEnvironment(filePath, musicalKey, e)+K.addMidiFileToMusicalEnvironment(filePath, musicalKey, e)
 </code> </code>
  
Line 27: Line 31:
 == bwv849.mid == == bwv849.mid ==
 From: https://www.midiworld.com/bach.htm From: https://www.midiworld.com/bach.htm
 +
 Download: https://www.midiworld.com/midis/other/bach/bwv849.mid Download: https://www.midiworld.com/midis/other/bach/bwv849.mid
  
 == two-bar-Cm-midi-test.mid == == two-bar-Cm-midi-test.mid ==
 From: Renick Bell From: Renick Bell
 +
 Download: Download:
  
 == scarborough-fair.mid == == scarborough-fair.mid ==
 https://bitmidi.com/scarborough-fair-mid https://bitmidi.com/scarborough-fair-mid
 +
 +== scarborough.mid ==
 +https://bitmidi.com/scarborough-mid
  
 == Code == == Code ==
 +WARNING: Remember to change the file paths according to the place you have installed the MIDI files. Or place the downloaded MIDI files to the directory you have launched nodejs in.
 +
 +For the first 3 examples, you will need 1 music synthesizer session listening to channel 1. However for the last example, you will need 7 music synthesizer sessions. Each music synthesizer should be listening to a number from 1 to 7 (Including 1 and 7).
  
 <code javascript> <code javascript>
-addMidiFileToMusicalEnvironment('./bwv849.mid', 'C#', e) +let twoCs = K.addMidiFileToMusicalEnvironment('./two-bar-Cm-midi-test.mid', 'C', e
-e.play('bwv849') +let cPlayers = twoCs(['CPlayers']
-e.stop('bwv849') +e.play('CPlayers') 
-addMidiFileToMusicalEnvironment('./two-bar-Cm-midi-test.mid', 'C', e) +e.stop('CPlayers') 
-e.play('two-bar-Cm-midi-test') + 
-e.stop('two-bar-Cm-midi-test') +let bwv = K.addMidiFileToMusicalEnvironment('./bwv849.mid', 'C#', e
-addMidiFileToMusicalEnvironment('./scarborough-fair.mid', 'D', e) +let bwvPlayers = bwv(['bwvPlayer1']
-e.play('scarborough-fair') +e.playWithConnected('bwvPlayer1') 
-e.stop('scarborough-fair') +e.stopWithConnected('bwvPlayer1') 
- + 
 +let scarbroFair = K.addMidiFileToMusicalEnvironment('./scarborough-fair.mid', 'D', e
 +let scarFairPlayers = scarbroFair(['scarbroFairPlayer']
 +e.playWithConnected('scarbroFairPlayer') 
 +e.stopWithConnected('scarbroFairPlayer'
 + 
 +//7 music synthesizer sessions listening to channel 1 through 7. 
 +let scarBro = K.addMidiFileToMusicalEnvironment('./scarborough.mid', 'D', e
 +let scarBroPlayers = scarBro(['scarBroPlayer1','scarBroPlayer2','scarBroPlayer3','scarBroPlayer4','scarBroPlayer5','scarBroPlayer6','scarBroPlayer7',]) 
 +scarBroPlayers.forEach(x => { 
 +    e.playWithConnected(x) 
 +}) 
 +scarBroPlayers.forEach(x => { 
 +    e.stopWithConnected(x) 
 +}) 
 +</code> 
 + 
 +CPlayers alone should sound like this: 
 +{{ :midi-playback-two-cs.mp3 |}} 
 + 
 +bwvPlayers alone should sound like this: 
 +{{ :midi-playback-bwv849.mp3 |}} 
 + 
 +scarFairPlayers alone should sound like this:  
 +{{ :midi-playback-scarbrofair.mp3 |}} 
 +scarBroPlayers alone should sound like this:  
 + 
 +{{ :midi-playback-scarbro.mp3 |}}
  • adding-midi-file-to-musical-environment.1705974929.txt.gz
  • Last modified: 2024/01/22 17:55
  • by steve.wang