diff --git a/js/midi/plugin.webaudio.js b/js/midi/plugin.webaudio.js index 15a6f0a7..dfa1f62d 100644 --- a/js/midi/plugin.webaudio.js +++ b/js/midi/plugin.webaudio.js @@ -17,6 +17,7 @@ var effects = {}; var masterVolume = 127; var audioBuffers = {}; + var detuneCents=0; /// midi.audioBuffers = audioBuffers; midi.send = function(data, delay) { }; @@ -55,6 +56,11 @@ channel.pitchBend = program; // } }; + + midi.setDetune = function(cents) + { + detuneCents = cents; + }; midi.noteOn = function(channelId, noteId, velocity, delay) { delay = delay || 0; @@ -94,6 +100,7 @@ /// add gain + pitchShift var gain = (velocity / 127) * (masterVolume / 127) * 2 - 1; source.connect(ctx.destination); + source.detune.value = detuneCents; source.playbackRate.value = 1; // pitch shift source.gainNode = ctx.createGain(); // gain source.gainNode.connect(ctx.destination); @@ -323,4 +330,4 @@ return new (window.AudioContext || window.webkitAudioContext)(); }; })(); -})(MIDI); \ No newline at end of file +})(MIDI);