Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion js/midi/plugin.webaudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
var effects = {};
var masterVolume = 127;
var audioBuffers = {};
var detuneCents=0;
///
midi.audioBuffers = audioBuffers;
midi.send = function(data, delay) { };
Expand Down Expand Up @@ -55,6 +56,11 @@
channel.pitchBend = program;
// }
};

midi.setDetune = function(cents)
{
detuneCents = cents;
};

midi.noteOn = function(channelId, noteId, velocity, delay) {
delay = delay || 0;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -323,4 +330,4 @@
return new (window.AudioContext || window.webkitAudioContext)();
};
})();
})(MIDI);
})(MIDI);