You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've looked at your documentation and couldn't find a real situation example where the array is filled with data.So my question is how can I get the Spectrum values of a float32array filled with audio values.
Thanks in advance
The text was updated successfully, but these errors were encountered:
Recently I asked myself the same thing. Hope this helps:
// example audio valuesconstmyFloat32Array=newFloat32Array(4096).map(i=>Math.random()*2-1);constf=newFFT(4096);constout=f.createComplexArray();f.realTransform(out,myFloat32Array);constgetMagnitude=(arr)=>{// input "arr" contains [ real0, imaginary0, real1, imaginary1, ... ];// pairwise get scalar magnitude (power)returnarr.reduce((a,c,i)=>{if(i%2===0)a.push(Math.hypot(c,arr[i+1]));returna;},[]);};// "out" has length 4096*2, only use left half (containing the Fourier Transform's complex output)constspectrum=getMagnitude(out.slice(0,out.length/2));// result has now length 2048 (half the fftSize)
Recently I asked myself the same thing. Hope this helps:
// example audio valuesconstmyFloat32Array=newFloat32Array(4096).map(i=>Math.random()*2-1);constf=newFFT(4096);constout=f.createComplexArray();f.realTransform(out,myFloat32Array);constgetMagnitude=(arr)=>{// input "arr" contains [ real0, imaginary0, real1, imaginary1, ... ];// pairwise get scalar magnitude (power)returnarr.reduce((a,c,i)=>{if(i%2===0)a.push(Math.hypot(c,arr[i+1]));returna;},[]);};// "out" has length 4096*2, only use left half (containing the Fourier Transform's complex output)constspectrum=getMagnitude(out.slice(0,out.length/2));// result has now length 2048 (half the fftSize)
I've looked at your documentation and couldn't find a real situation example where the array is filled with data.So my question is how can I get the Spectrum values of a float32array filled with audio values.
Thanks in advance
The text was updated successfully, but these errors were encountered: