Reputation: 21
I am using MIDI.js in my project, here is my code for playing sequence of MIDI notes
for (var repeat = 0; repeat < melodyrepititions; repeat++)
{
for (var i = 0; i < composition.length; i++)
{
for (var j = 0; j < composition[i].length; j++)
{
if (composition[i][j] != 0)
{
MIDI.noteOn(0, composition[i][j] + scale, velocity,delay );
MIDI.noteOff(0, composition[i][j] + scale, delay+onlynotationsofeachbeatbracketdelay[i][j]);
}
else if (composition[i][j] == 0)
{
MIDI.noteOff(0, composition[i][j] + scale, delay);
}
delay = delay + onlynotationsofeachbeatbracketdelay[i][j];
}
}
}
I want to implement MIDI.js player for this sequence to start,pause,stop the melody while playing. I am not able to figure out how can I use MIDI.js player functions for such sequence. Please guide.
Upvotes: 0
Views: 1604
Reputation: 1121
use https://github.com/surikov/SSSynthesiser.js instead of MIDI.js.
SSSynthesiser.js has full controls over what is playing. You can change in realtime all instrument samples, melody etc.
Update
this is old answer.
Use https://github.com/surikov/webaudiofont instead of it.
Read docs, look to examples. See example for MIDI-player here https://surikov.github.io/webaudiofont/examples/midiplayer.html
Upvotes: 1
Reputation: 21
I think it is not possible to implement MIDI player directly to sequence of notes, so solution I got is, one need to convert sequence of notes into MIDI file & then you can input MIDI file to player. Here is link which gives more details on conversion of MIDI file
http://mudcu.be/journal/2011/11/base64-soundfonts/
Library which helps to convert sequence of notes in MIDI file https://github.com/sergi/jsmidi
Upvotes: 0