iOS AudioKit 高通滤波器

iOS AudioKit Hight Pass Filter

我正在尝试使用 AudioKit 检测来自 iOS 麦克风的音高,这是代码

    init() {
        guard let input = engine.input else {
            fatalError()
        }

        mic = input

        filter = HighPassFilter(mic, cutoffFrequency: 200, resonance: 40)
        silence = Fader(filter, gain: 0)
        tracker = PitchTap(silence) { pitch , amp in
            DispatchQueue.main.async {
                print(pitch[0], amp[0])
                self.update(pitch[0], amp[0])
            }
        }
        engine.output = filter
    }

    func start() {
        recordFrequency = []
        do {
            try engine.start()
            tracker.start()
        } catch let err {
            Log(err)
        }
    }

因为我不发声的时候总有一些检测(频率20到200), 我添加了一个高通滤波器来过滤低于 40 dB 和 200 个频率的声音, 但是好像不行,怎么办?

谢谢。

您似乎只是遇到了一些连接点问题。在信号静音之前尝试放置跟踪器:

    filter = HighPassFilter(mic, cutoffFrequency: 200, resonance: 40)
    tracker = PitchTap(filter) { pitch , amp in
        DispatchQueue.main.async {
            print(pitch[0], amp[0])
            self.update(pitch[0], amp[0])
        }
    }
    silence = Fader(tracker, gain: 0)
    engine.output = filter