Conversation
1b2c337 to
38f6555
Compare
1c2dc80 to
aa7d3d7
Compare
Add support for generating frequency spectrum snapshots of audio buffers using FFT analysis. This includes: - New spectrum view for visualizing frequency data using SwiftUI Charts - Extension for AVAudioPCMBuffer to compute spectrum data - Test coverage for various waveforms including pure tones and noise
aa7d3d7 to
6af7978
Compare
| func spectrum(window: [Float]) -> [FrequencyAmplitude] { | ||
| let mono = mixToMono() | ||
| guard let data = mono.floatChannelData?[0] else { | ||
| fatalError("Not a float audio format") |
There was a problem hiding this comment.
Should we throw an error here instead of exiting the process here?
There was a problem hiding this comment.
I would like to avoid making API throwing. mixToMono returns float channel data, so this is just a limitation of API that we are using. This case should never happen.
| } | ||
| } | ||
|
|
||
| private func fft( |
There was a problem hiding this comment.
Maybe to have the method name written in full instead of abbreviation. I had to google it :D
| private func fft( | |
| private func fastFourierTransform( |
There was a problem hiding this comment.
FFT is a well-known abbreviation in DSP. As you can see in the implementation of this function, Accelerate also uses vDSP.FFT, so I feel it is ok to keep it as is
| } | ||
|
|
||
| private func fft( | ||
| n: Int, |
There was a problem hiding this comment.
should we call this n frameLength or something that is more user friendly?
There was a problem hiding this comment.
I think I would like to keep this one too. Notice how vDSP.FFT uses log2n in parameter name. I think it is worth keeping it this way in our code for clarity and consistency.
Add support for generating frequency spectrum snapshots of audio buffers using FFT analysis.
This includes: