【问题标题】:How can get audio with sample rate of 44100 from iPhone 11 or iPhone 11 Pro Max如何从 iPhone 11 或 iPhone 11 Pro Max 获取采样率为 44100 的音频
【发布时间】:2019-11-19 06:23:12
【问题描述】:

我正在使用以下代码从 iPhone 11 获取 44100 采样率的音频样本。 iPhone 11 默认采样率为 48000。

let audioEngine = AVAudioEngine()
    let inputNode = audioEngine.inputNode
    let main = audioEngine.mainMixerNode
    let inputFormat = inputNode.inputFormat(forBus: 0)
    let outputFormat = AVAudioFormat(commonFormat: AVAudioCommonFormat.pcmFormatInt16, sampleRate: 44100, channels: 1, interleaved: true)
    audioEngine.attach(downMixer)
    audioEngine.connect(inputNode, to: downMixer, format: inputFormat)
    audioEngine.connect(downMixer, to: main, format: outputFormat)
    downMixer.installTap(onBus: 0, bufferSize: 2048, format: outputFormat) { (buffer, time) -> Void in
        print(buffer)
    }

我得到空音频数据。

【问题讨论】:

    标签: audio pcm avaudioengine downsampling sample-rate


    【解决方案1】:

    您可以使用音频转换器服务将 48 K Hz 转换为 44.1 K Hz 采样频率。由于iOS/iphone平台不支持所有的采样频率。

    https://developer.apple.com/documentation/audiotoolbox/audio_converter_services

    【讨论】:

    猜你喜欢
    • 2011-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-26
    相关资源
    最近更新 更多