Answer the question
In order to leave comments, you need to log in
ScriptProcessorNode is deprecated. Instead, use AudioWorkletNode. How to use correctly?
Tried to get an Audiocontext fingerprint. Yesterday showed everything correctly. It returned an array like this [-145.835968,-136.51010,-130.71459,-126.36395...] length=1024. Now in firefox it gives out such an array Array(1024) [ -Infinity, -Infinity, -Infinity...] and in Google nothing is displayed and the warning "ScriptProcessorNode is deprecated. Use AudioWorkletNode instead." I did not find how to replace it. When I just changed AudioWorklet instead of ScriptProcessor it didn't help. Who faced such problem?
let freq_data = [];
// Create nodes
const ctx = new AudioContext(); // AudioContext Object
const oscillator = ctx.createOscillator(); // OscillatorNode
const analyser = ctx.createAnalyser(); // AnalyserNode
const gain = ctx.createGain(); // GainNode
const scriptProcessor = ctx.createScriptProcessor(4096, 1, 1); // ScriptProcessorNode
gain.gain.value = 0;
oscillator.connect(analyser);
analyser.connect(scriptProcessor);
scriptProcessor.connect(gain);
gain.connect(ctx.destination);
scriptProcessor.onaudioprocess = function(bins) {
bins = new Float32Array(analyser.frequencyBinCount);
analyser.getFloatFrequencyData(bins);
for (var i = 0; i < bins.length; i = i + 1) {
freq_data.push(bins[i]);
}
analyser.disconnect();
scriptProcessor.disconnect();
gain.disconnect();
console.log(freq_data);
oscillator.start(0);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question