Skip to content

Instantly share code, notes, and snippets.

@nevosegal
Created September 8, 2016 14:09
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 nevosegal/9483e1ea7fb7036d295e70a40242d7bb to your computer and use it in GitHub Desktop.
Save nevosegal/9483e1ea7fb7036d295e70a40242d7bb to your computer and use it in GitHub Desktop.
white noise meyda
var bufferSize = 4096;
var whiteNoise = ac.createScriptProcessor(bufferSize, 1, 1);
var m = ac.createScriptProcessor(bufferSize,1,1);
whiteNoise.onaudioprocess = function(e) {
var output = e.outputBuffer.getChannelData(0);
for (var i = 0; i < bufferSize; i++) {
output[i] = Math.random() * 2 - 1;
}
}
let meyda = Meyda.createMeydaAnalyzer({
"audioContext":ac, // audio context
"source":whiteNoise, // input
"bufferSize": bS, // buffer size
"callback": onFeatureExtracted //callback function
});
// window.source = ac.createMediaStreamSource(e.outputBuffer)
m.onaudioprocess = function(e){
meyda.start(['amplitudeSpectrum', 'spectralFlatness']); //extract the amplitudeSpectrum
}
whiteNoise.connect(m);
m.connect(ac.destination);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment