简体   繁体   中英

iOS AudioKit / EZAudio FFT values

I have a Web Audio API based signal process application and I have to port it to iOS with AudioKit(based on EZAudio) framework.

I need only the FrequencyDomain that is contains numbers between 0-255 in Web Audio API.

But in the AudioKit the AKFFTTap fftData gives me back floats between -6 to 6 and sometimes <1000.

Here is what I have already tried on ios:

init process ...

let mic = AKMicrophone()
let fftTap = AKFFTTap.init(mic)

request ...

return fftTap.fftData

on Web Audio API: init...

var analyser = audioContext.createAnalyser();

request...

let freqDomain = new Uint8Array(analyser.frequencyBinCount);
analyser.getByteFrequencyData(freqDomain);
return freqDomain

How can I get back the same data?

There are two things on your web's scenario that differs from AKFFTap... Firstly it returns an 256 sized array. This probably means that the bufferSize being catched is of 512 samples. You can solve this by using this custom AKFFTTap:

https://gist.github.com/denisb411/3e832a592ff8b79cca2afdbed432a0d0

Second, seems that the way that the WebAudio is reading the binary of the samples are different. I suggest you to use Float32 on the web as AudioKit uses this format. Reference for this to understand more about.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM