Online Sequencer Forums
Pitch Bending - Printable Version

+- Online Sequencer Forums (https://onlinesequencer.net/forum)
+-- Forum: Online Sequencer (https://onlinesequencer.net/forum/forum-3.html)
+--- Forum: Suggestions (https://onlinesequencer.net/forum/forum-6.html)
+---- Forum: Completed Suggestions (https://onlinesequencer.net/forum/forum-22.html)
+---- Thread: Pitch Bending (/thread-2461.html)



Pitch Bending - Syntax - 04-20-2018

You know what Online Sequencer needs? That's right. PITCH BENDING. It would make it so much cooler to do 8 bit music with pitch bending. Everyone spam _Jacob's PM with "PITCH BENDING!!"


RE: Pitch Bending - act55555 - 11-09-2018

Hi, seeing this thread being under 'Completed', where is the pitch bend tool located in the interface? Thanks.


RE: Pitch Bending - Frank - 11-10-2018

Actually, this would not be hard to implement, because of the way 8-bit instruments are coded. The only problem would be actually making a cool-looking and functional UI.
https://developer.mozilla.org/en-US/docs/Web/API/OscillatorNode/detune
1 hour of coding a prototype without UI later
whoops, this isn't even bug-free to my knowledge
it's actually hard-ish
Code:
pitchAuto = [0, 25, 50, 75];

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;
        var cents = pitchAuto[Math.floor(playTime / 16)];
        if (typeof cents != "undefined") oscillator.detune.setValueAtTime(cents, onTime);
        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, 0.01);
        gain.setTargetAtTime(0, offTime, 0.01);
    }
}