08-02-2020, 11:41 AM
function playSynthNote(context, id, note, length, delay) {
delay = delay ? delay : 0;
var oscillator = oscillators[id][note];
if (oscillator) {
var gain = oscillator.gain.gain;
var volume = 0.1 * audioSystem.masterVolume;
var onTime = context.currentTime + delay + 0.01;
var offTime = context.currentTime + delay + 0.01 + length;
if (noteOffTime[id][note] > onTime) {
gain.setTargetAtTime(volume / 2, context.currentTime, 0.01);
gain.setTargetAtTime(volume, noteOffTime[id][note], 0.01);
}
noteOffTime[id][note] = offTime;
gain.setTargetAtTime(volume, onTime, 1);
gain.setTargetAtTime(0, offTime, 0);
}
}
gain.setTargetAtTime(volume, onTime: this is for attack
gain.setTargetAtTime(0, offTime: this is for decay (the 2nd interger)
if you plug this in the console then you can edit the 8 bit instruments more but it wont save to a sequence
delay = delay ? delay : 0;
var oscillator = oscillators[id][note];
if (oscillator) {
var gain = oscillator.gain.gain;
var volume = 0.1 * audioSystem.masterVolume;
var onTime = context.currentTime + delay + 0.01;
var offTime = context.currentTime + delay + 0.01 + length;
if (noteOffTime[id][note] > onTime) {
gain.setTargetAtTime(volume / 2, context.currentTime, 0.01);
gain.setTargetAtTime(volume, noteOffTime[id][note], 0.01);
}
noteOffTime[id][note] = offTime;
gain.setTargetAtTime(volume, onTime, 1);
gain.setTargetAtTime(0, offTime, 0);
}
}
gain.setTargetAtTime(volume, onTime: this is for attack
gain.setTargetAtTime(0, offTime: this is for decay (the 2nd interger)
if you plug this in the console then you can edit the 8 bit instruments more but it wont save to a sequence