Mac 上的 AVAudioEngine 输入,扰乱低优先级声音

问题描述 投票:0回答:1

我正在通过点击 Mac 上的麦克风并打印识别的声音来分析声音。

一切都运行良好,但它扰乱了其他(我认为的)低优先级的声音,例如界面听起来就像将项目拖离扩展坞、在 Outlook 中发送消息、在快捷方式或终端中说出某些内容。 其他声音(如 music.app 播放、Siri 说话)不会受到干扰。这种干扰听起来就像声音的最后部分被重复了两次,非常明显。这是代码(直接从这里:https://developer.apple.com/documentation/soundanalysis/classifying_sounds_in_an_audio_stream):

import Cocoa
import AVFAudio

func startAudioEngine() {
    // Create a new audio engine.
    audioEngine = AVAudioEngine()


    // Get the native audio format of the engine's input bus.
    inputBus = AVAudioNodeBus(0)
    inputFormat = audioEngine.inputNode.inputFormat(forBus: inputBus)
    
    do {
        // Start the stream of audio data.
        try audioEngine.start()
    } catch {
        print("Unable to start AVAudioEngine: \(error.localizedDescription)")
    }
}

我尝试过增加缓冲区,将QoS更改为实用程序(希望声音分析变得不如系统声音重要),在非主线程上运行。

问题出在 100% AVAudioEngine,如有任何帮助,我们将不胜感激。

swift macos avaudioengine
1个回答
0
投票

我已与 Apple 开发团队讨论过此问题,他们已复制并已将其作为 AVAudioEngine 的错误提交。

© www.soinside.com 2019 - 2024. All rights reserved.