I tried with AVFoundation, AudioKit and EZAudio. But I could not. I want some way to get all the amplitudes of the whole song (without play the music), to have the average amplitude. Does anyone know how? I do not need the whole algorithm. Examples and a way forward are welcome.
do {
let file = try AKAudioFile(forReading: URL.init(string: Bundle.main.path(forResource: "TFB9", ofType: "mp3")!)!)
self.analyzedPlayer = try AKAudioPlayer(file: file)
self.player = try AKAudioPlayer(file: file)
}
catch {
print(error)
}
let equalizerFilter = AKEqualizerFilter(analyzedPlayer, centerFrequency: 9000, bandwidth: 1000, gain: 9)
let lowPassFilter = AKLowPassFilter.init(equalizerFilter, cutoffFrequency: 10000, resonance: 0)
hightPassFilter = AKHighPassFilter.init(lowPassFilter, cutoffFrequency: 8000, resonance: 0)
AKAmplitudeTracker.init(hightPassFilter, threshold: 0.42, thresholdCallback: {_ in
self.delegate?.signal()
})