Store file on app and compare it with a recorded file.

How would I store a file inside an app and when another sound file is recorded compare it with the saved sound? For example, I have a file named "file.mp3" when the user hits the record button and records a sound imitating the sound in "file.mp3". I would then tell the user how simular the recorded sound is to the saved sound . So how would I do this. I am already able to record and save the sounds locally on the app but how would I then do this other stuff?

Replies

There’s a bunch of parts to this but the key component is DSP Magic™. Comparing two sounds to see how similar they are is a very specialist technical field. iOS certainly does not provide APIs for that. You’ll have to write (or acquire) the code to do it. It’s possible that someone here has some specific experience to share but, if not, you’re going to have to research this independently.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I researched a little and it seems that getting the fft of a file seems to be the quickest option to try out. What is the best way to do this in Swift? I am a javascript developer and have not messed with swift.

Apple does provide Fourier tranform APIs as part of the Accelerate framework. Specifically, you’ll want to look at the vDSP subsystem. It’s possible to call these APIs from Swift but, as they’re low-level C APIs, it’s not particularly pleasant. Moreover, there’s a big gap between a working Fourier transform and an audio comparison library.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"