在iOS上更改AUGraph的采样率 [英] Changing sample rate of an AUGraph on iOS

查看:270
本文介绍了在iOS上更改AUGraph的采样率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了类似于 iOS开发人员库。但是,在我的应用程序中,我需要能够以不同的采样率(可能是两个不同的采样率)播放声音。

I've implemented an AUGraph similar to the one on the iOS Developer's Library. In my App, however, I need to be able to playback sound at different sample rates (probably two different ones).

我一直在寻找Apple的文档和避风港找不到在运行时设置采样率的方法。我一直在考虑三种可能的解决方法:

I've been looking around Apple's documentation and haven't found a way to set the sample rate at runtime. I've been thinking of three possible work-arounds:


  1. 每次我需要更改采样率时重新初始化AUGraph;

  2. 为每个不同的采样率初始化不同的AUGraph;

  3. 在播放前转换每个声音的采样率;

这些方法在处理器上看起来都很笨重。

These methods all seem really clunky and heavy on the processor.

什么是最好的方式在运行时改变AUGraph的采样率?

推荐答案

连续音频流方案通常为#1。

typically #1 for continuous audio streaming scenarios.

您的计划可能因使用您列出的其他方法而有特殊需要或好处:

your program may have a special need or benefit by using another approach you have listed:


  • #2:你需要处理不需要重新初始化的地方。

  • #3:你需要同时混合和处理两个具有不同输入采样率的流,特别是如果你发现自己多次SRCing信号。

但是,如果您只需要使用SRC播放并且不考虑最低延迟,则可能需要尝试使用AudioQueue。

but, if you just need playback with SRC and lowest latency is not a concern, you may want to try an AudioQueue instead.

这篇关于在iOS上更改AUGraph的采样率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆