Miguel de Sousa
Miguel de Sousa

Reputation: 303

How can I resample an audio file programatically in swift?

I would like to know if it's possible to resample an already written AVAudioFile.

All the references that I found don't work on this particular problem, since:

The point is that I would like to resample my audio file regardless of the recording process.

The harder approach would be to upsample the signal by a L factor and applying decimation by a factor of M, using vDSP:

Audio on Compact Disc has a sampling rate of 44.1 kHz; to transfer it to a digital medium that uses 48 kHz, method 1 above can be used with L = 160, M = 147 (since 48000/44100 = 160/147). For the reverse conversion, the values of L and M are swapped. Per above, in both cases, the low-pass filter should be set to 22.05 kHz. [3]

The last one obviously seems like a too hard coded way to solve it. I hope there's a way to resample it with AVAudioConverter, but it lacks documentation :(

Upvotes: 3

Views: 735

Answers (0)

Related Questions