Skip to content

Instantly share code, notes, and snippets.

@FBerthelot
Created November 5, 2015 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FBerthelot/1fbb559d097472179555 to your computer and use it in GitHub Desktop.
Save FBerthelot/1fbb559d097472179555 to your computer and use it in GitHub Desktop.
// Création du ScriptProcessorNode avec un buffer de 4096, 1 entrée et 1 sortie
var ScriptProcessorNode = audioCtx.createScriptProcessor(4096, 1, 1);
ScriptProcessorNode.onaudioprocess = function(audioProcessingEvent){
var inputBuffer = audioProcessingEvent.inputBuffer;
var outputBuffer = audioProcessingEvent.outputBuffer;
//Parcours de channel de la source audio (par exemple: gauche et droite en stéréo)
for (var i=0; i < outputBuffer.numberOfChannels; i++) {
var inputData = inputBuffer.getChannelData(i);
var outputData = outputBuffer.getChannelData(i);
//Parcours de l'ensemble du buffer
for (var j=0; j < inputBuffer.length; j++) {
outputData[j] = inputData[j] * 2; //Multiplication de l'amplitude par 2
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment