나는 사운드 파일 (.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