This will have a great impact on your creativity:
Code:
j = 0;
window.setInterval(function() {
for (var i = 0; i < settings['numInstruments']; i++) {
settings['instrumentColors'][i] = [Math.floor(Math.random() * 255), Math.floor(Math.random() * 255), Math.floor(Math.random() * 255)];
};
SequencerView.repaint();
$('canvas').css('filter', 'blur(' + (Math.sin(j) * 8) + 'px)');
j += 0.1;
}, 100);
What else can you come up with?
Is it possible to come up with a code to reverse play sound files..?
looɔ ǝq plnoʍ ʇɐɥʇ
Meh...
(07-11-2018, 05:22 PM)Jacob_ Wrote: [ -> ]This will have a great impact on your creativity:
Code:
j = 0;
window.setInterval(function() {
for (var i = 0; i < settings['numInstruments']; i++) {
settings['instrumentColors'][i] = [Math.floor(Math.random() * 255), Math.floor(Math.random() * 255), Math.floor(Math.random() * 255)];
};
SequencerView.repaint();
$('canvas').css('filter', 'blur(' + (Math.sin(j) * 8) + 'px)');
j += 0.1;
}, 100);
What else can you come up with?
This is even better, it directly boosts creativity!
Code:
for (var inst = 0; inst < settings.numInstruments; inst = inst == 12 ? 17 : inst + 1) {
loadInstrument(inst);
}
var id = setInterval(function() {
if (Object.keys(audioSystem.sounds).length == 36) {
clearInterval(id)
for (var inst = 0; inst < settings.numInstruments; inst = inst == 12 ? 17 : inst + 1) {
var source = audioSystem.audioContext.createBufferSource();
source.buffer = audioSystem.sounds[inst];
source.connect(audioSystem.gainNodes[inst]);
source.start(audioSystem.audioContext.currentTime, 0, (72 - settings.min[inst]) * 30 / settings.originalBpm[inst]);
delete source;
}
}
}, 100)
This will download all the notes to your brain, boosting productivity via caching. You have to wait for all the notes to load though, so be patient.
(07-19-2018, 06:52 PM)Frank Wrote: [ -> ]Code:
for (var inst = 0; inst < settings.numInstruments; inst = inst == 12 ? 17 : inst + 1) {
loadInstrument(inst);
}
var id = setInterval(function() {
if (Object.keys(audioSystem.sounds).length == 36) {
clearInterval(id)
for (var inst = 0; inst < settings.numInstruments; inst = inst == 12 ? 17 : inst + 1) {
var source = audioSystem.audioContext.createBufferSource();
source.buffer = audioSystem.sounds[inst];
source.connect(audioSystem.gainNodes[inst]);
source.start(audioSystem.audioContext.currentTime, 0, (72 - settings.min[inst]) * 30 / settings.originalBpm[inst]);
delete source;
}
}
}, 100)
This will download all the notes to your brain, boosting productivity via caching. You have to wait for all the notes to load though, so be patient.
I could have used isSynthInstrument but I am too lazy to update.
(10-16-2018, 05:07 PM)blobertthebob Wrote: [ -> ] (10-16-2018, 04:54 PM)Jacob_ Wrote: [ -> ]Code:
loadInstrument(13);
var el = $('<input type="file" accept="audio/*">');
$(document.body).append(el);
el.on('change', function(e){
var reader = new FileReader();
reader.onload = function (e) {
var context = new AudioContext();
context.decodeAudioData(e.target.result, function(buffer){
var node = context.createAnalyser();
var resolution = 4;
node.fftSize = 4096;
node.smoothingTimeConstant = 0;
var bufferLength = node.frequencyBinCount;
var dataArray = new Uint8Array(bufferLength);
var audioSource = context.createBufferSource();
audioSource.buffer = buffer;
audioSource.loop = false;
audioSource.connect(node);
var time = 0;
audioSource.start(0);
setInterval(function(){
node.getByteFrequencyData(dataArray);
var f = [];
for (var i = 1; i < dataArray.length - 1; i++) {
var isPeak = dataArray[i] >= dataArray[i-1] && dataArray[i] >= dataArray[i+1];
if (isPeak) {
f.push([i, dataArray[i]]);
}
}
f.sort(function(a, b){return b[1] - a[1]});
for(var i = 0; i < Math.min(f.length, 4); i++) {
var frequency = f[i][0] * context.sampleRate / node.fftSize;
var note = piano[Math.round((piano.length*Math.log(2)+12*Math.log(55/frequency)+Math.log(4))/(Math.log(2)))];
if (note != undefined && f[i][1] > 32) {
song.addNote(new Note(song, note, time/resolution, 1/resolution, 13));
}
}
time++;
}, song.sleepTime/resolution);
setInterval(SequencerView.repaint, 1000);
});
}
reader.readAsArrayBuffer(e.target.files[0]);
});
el.click();
this is dank
Agreed, I was considering doing something like this, but I thought it was impossible. Who knows, maybe I should try to outdo this.