var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
var button = document.querySelector('button');
var pre = document.querySelector('pre');
var myScript = document.querySelector('script');
var input = audioCtx.createGain();
var feedback = audioCtx.createGain();
var delay = audioCtx.createDelay();
var leftDelay = audioCtx.createDelay();
var rightDelay = audioCtx.createDelay();
var outputmix = audioCtx.createGain();
var errorCallback = function(e) {
alert("Error in getUserMedia: " + e);
};
// Check if there is microphone input.
try {
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia;
var hasMicrophoneInput = (navigator.getUserMedia || navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia || navigator.msGetUserMedia);
} catch(e) {
alert("getUserMedia() is not supported in your browser");
}
navigator.getUserMedia({audio: true}, function(stream) {
// microphone -> myPCMProcessingNode -> destination.
var microphone = audioCtx.createMediaStreamSource(stream);
var scriptNodes = {};
var keep = (function () {
var nextNodeID = 1;
return function (node) {
node.id = node.id || (nextNodeID++);
scriptNodes[node.id] = node;
return node;
};
}());
var scriptNode = keep(audioCtx.createScriptProcessor());
scriptNode.onaudioprocess = function(audioProcessingEvent) {
// The input buffer is the song we loaded earlier
var inputBuffer = audioProcessingEvent.inputBuffer;
// The output buffer contains the samples that will be modified and played
var outputBuffer = audioProcessingEvent.outputBuffer;
// Loop through the output channels (in this case there is only one)
for (var channel = 0; channel < outputBuffer.numberOfChannels; channel++) {
var inputData =...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.