私は時間の経過とともに振幅を取得し、グラフを作成するためにサウンドファイル(.m4a)を分析しようとしています。私は、素晴らしい(下記)コードをオンラインで見つけました。しかし、私はさらに、目標とする周波数範囲にないすべての音をフィルタリングしたいと思います。例えば。私は、1900〜2100 Hzの間の音だけをグラフにしたい。これどうやってするの?.m4aデータからの周波数のフィルタリング
var processingBuffer = [Float](repeating: 0.0, count: Int(readFile.arrayFloatValues.count))
let sampleCount = vDSP_Length(readFile.arrayFloatValues.count)
vDSP_vabs(readFile.arrayFloatValues, 1, &processingBuffer, 1, sampleCount);
let samplesPerPixel = 1
let filter = [Float](repeating: 1.0/Float(samplesPerPixel), count: Int(samplesPerPixel))
let downSampledLength = Int(readFile.arrayFloatValues.count/samplesPerPixel)
var downSampledData = [Float](repeating:0.0, count:downSampledLength)
vDSP_desamp(processingBuffer,
vDSP_Stride(samplesPerPixel),
filter, &downSampledData,
vDSP_Length(downSampledLength),
vDSP_Length(samplesPerPixel))
readFile.points = downSampledData.map{CGFloat($0)}
編集
記録は、実際には早い時点で、デバイスのマイクから記録されています。記録段階でフィルタを適用する方が簡単でしょうか?
周波数ドメインに入った振幅/時間データを変換して編集し、時間ドメインに戻します。 FFTが動作します。 – meggar
これを行う方法に関するヒントは?私はAccelerateフレームワークを使用しているようですが、おそらくこれが役立ちます:https://developer.apple.com/library/content/documentation/Performance/Conceptual/vDSP_Programming_Guide/Introduction/Introduction –
私は本当に処理のサウンドに新しいです。 .html – meggar