I am trying to implement an SLM app for iOS using AudioKit. Therefore I need to determine different loudness values to a) display the current loudness (averaged over a second) and b) do further calculations (e.g. to calculate the "Equivalent Continuous Sound Level" over a longer time span). The app should be able to track frequency-weighted decibel values like dB(A) and dB(C).
I do understand that some of the issues im facing are related to my general lack of understanding in the field of signal and audio processing. My question is how one would approach this task with AudioKit. I will describe my current process and would like to get some input:
- Create an instance of
AKMicrophone
and aAKFrequencyTracker
on this microphone - Create a
Timer
instance with some interval (currently1/48_000.0
) - Inside the timer: retrieve the
amplitude
andfrequency
. Calculate a decibel value from the amplitude with20 * log10(amplitude) + calibrationOffset
(calibration offset will be determined per device model with the help of a professional SLM). Calculate offsets for the retrieved frequency according to frequency-weighting (A and C) and apply these to the initial dB value. Store dB, dB(A) and dB(C) values in an array. - Calculate the average for arrays over the give timeframe (1 second).
I read somewhere else that using a Timer this is not the best approach. What else is there that I could use for the "sampling"? What exactly is the frequency
of AKFrequencyTracker
? Will this frequency be sufficient to determine dB(A) and dB(C) values or will I need an AKFFTTap
for this? How are values retrieved from the AKFrequencyTracker
averaged, i.e. what time frame is used for the RMS?
Possibly related questions: Get dB(a) level from AudioKit in swift, AudioKit FFT conversion to dB?