Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
adding-midi-file-to-musical-environment [2024/01/22 17:43] – created steve.wang | adding-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:// | + | **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, | ||
+ | </ | ||
===== addMidiFileToMusicalEnvironment ===== | ===== addMidiFileToMusicalEnvironment ===== | ||
- | String -> String -> MusicalEnvironment -> | + | String -> String -> MusicalEnvironment -> Function |
- | This function will automatically create | + | This function will automatically create |
==== Syntax ==== | ==== Syntax ==== | ||
<code javascript> | <code javascript> | ||
+ | K.addMidiFileToMusicalEnvironment(filePath, | ||
+ | </ | ||
+ | |||
+ | ==== Parameters ==== | ||
+ | ===filePath === | ||
+ | The path to the MIDI file (.mid) that is to be used. | ||
+ | === musicalKey === | ||
+ | The key of the MIDI file. | ||
+ | === e === | ||
+ | MusicalEnvironment to add to. | ||
+ | |||
+ | ==== Examples ==== | ||
+ | === MIDI Files Used (Download) === | ||
+ | == bwv849.mid == | ||
+ | From: https:// | ||
+ | |||
+ | Download: https:// | ||
+ | |||
+ | == two-bar-Cm-midi-test.mid == | ||
+ | From: Renick Bell | ||
+ | |||
+ | Download: | ||
+ | |||
+ | == scarborough-fair.mid == | ||
+ | https:// | ||
+ | |||
+ | == scarborough.mid == | ||
+ | https:// | ||
+ | |||
+ | == 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> | ||
+ | let twoCs = K.addMidiFileToMusicalEnvironment(' | ||
+ | let cPlayers = twoCs([' | ||
+ | e.play(' | ||
+ | e.stop(' | ||
+ | |||
+ | let bwv = K.addMidiFileToMusicalEnvironment(' | ||
+ | let bwvPlayers = bwv([' | ||
+ | e.playWithConnected(' | ||
+ | e.stopWithConnected(' | ||
+ | |||
+ | let scarbroFair = K.addMidiFileToMusicalEnvironment(' | ||
+ | let scarFairPlayers = scarbroFair([' | ||
+ | e.playWithConnected(' | ||
+ | e.stopWithConnected(' | ||
+ | |||
+ | //7 music synthesizer sessions listening to channel 1 through 7. | ||
+ | let scarBro = K.addMidiFileToMusicalEnvironment(' | ||
+ | let scarBroPlayers = scarBro([' | ||
+ | scarBroPlayers.forEach(x => { | ||
+ | e.playWithConnected(x) | ||
+ | }) | ||
+ | scarBroPlayers.forEach(x => { | ||
+ | e.stopWithConnected(x) | ||
+ | }) | ||
+ | </ | ||
+ | |||
+ | CPlayers alone should sound like this: | ||
+ | {{ : | ||
+ | |||
+ | bwvPlayers alone should sound like this: | ||
+ | {{ : | ||
+ | |||
+ | scarFairPlayers alone should sound like this: | ||
+ | {{ : | ||
+ | scarBroPlayers alone should sound like this: | ||
+ | {{ : |