adding-midi-file-to-musical-environment

This is an old revision of the document!


Adding midi file to musical environment

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 Konduktiva installation instructions and have read through and understood the 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.

String → String → MusicalEnvironment → Function

This function will automatically create QuantizedMaps based on midi information in the file and add them to the MusicalEnvironment. It 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 file. It will then return an array of the names of the players it has modified or created. It will throw and error if insufficient player names are provided. Extra player names provided will be ignored.

K.addMidiFileToMusicalEnvironment(filePath, musicalKey, e)

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.

MIDI Files Used (Download)

bwv849.mid
two-bar-Cm-midi-test.mid

From: Renick Bell

Download:

scarborough-fair.mid
scarborough.mid
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).

let twoCs = K.addMidiFileToMusicalEnvironment('./two-bar-Cm-midi-test.mid', 'C', e)
let cPlayers = twoCs(['CPlayers'])
e.play('CPlayers')
e.stop('CPlayers')
 
let bwv = K.addMidiFileToMusicalEnvironment('./bwv849.mid', 'C#', e)
let bwvPlayers = bwv(['bwvPlayer1'])
e.playWithConnected('bwvPlayer1')
e.stopWithConnected('bwvPlayer1')
 
let scarbroFair = K.addMidiFileToMusicalEnvironment('./scarborough-fair.mid', 'D', e)
let scarFairPlayers = scarbroFair(['scarbroFairPlayer'])
e.playWithConnected('scarbroFairPlayer')
e.stopWithConnected('scarbroFairPlayer')
 
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)
})
  • adding-midi-file-to-musical-environment.1708760886.txt.gz
  • Last modified: 2024/02/23 23:48
  • by steve.wang