11-05-2018, 07:43 PM
##966556
Failure.
Code:
var el = $('<input type="file" accept="audio/*">');
$(document.body).append(el);
el.on('change', function(e) {
loadInstrument(14)
var reader = new FileReader();
reader.onload = function(e) {
var context = new AudioContext();
context.decodeAudioData(e.target.result, function(buffer) {
var audioData = new Float32Array(buffer.length);
buffer.copyFromChannel(audioData, 0);
var sampleRate = buffer.sampleRate;
var noteLength = 0.01;
//60 * 4 = 240 BPM = 1 Measure / Second. There are 16 notes per measure.
song.setBPM(240 * sampleRate * noteLength / 16);
for (var i = 0; i < audioData.length; i++) {
if (audioData[i] > 0) {
song.addNote(new Note(song, "C2", i * noteLength, noteLength, 14));
}
}
});
}
reader.readAsArrayBuffer(e.target.files[0]);
});
el.click();
Kim Wrote:##878337 + https://js-game.glitch.me + Doesnt take peopel serious if their has badly speling gramer puntuatin