首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何从iPhone 11或iPhone 11专业版Max获得采样率为44100的音频

如何从iPhone 11或iPhone 11专业版Max获得采样率为44100的音频
EN

Stack Overflow用户
提问于 2019-11-19 14:23:12
回答 1查看 1K关注 0票数 0

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

代码语言:javascript
运行
复制
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)
    }

我得到的音频数据为空。

EN

回答 1

Stack Overflow用户

发布于 2019-11-19 15:46:40

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

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58927822

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档