iOS音频操作 - 向后播放本地.caf文件 [英] iOS audio manipulation - play local .caf file backwards

查看:400
本文介绍了iOS音频操作 - 向后播放本地.caf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想加载本地.caf音频文件并反转音频(向后播放)。我已经收集到了我基本上需要从这个的帖子中翻转一系列缓冲区数据/ p>

但是,我不确定如何从给定的音频文件访问此缓冲区数据。我有一点使用AVaudioPlayer和ObjectAL(一个obj-c openAL库)播放声音的经验,但我不知道如何访问像这个缓冲区数据数组这样的低级别。



我可以举个例子来了解如何访问该数组吗?

解决方案

你的问题减少了与此处描述的问题相同,该问题由Pi Kiran 回答了这个问题,并在此重新发布了他的答案。 Kiran的答案是准确的,但您可能需要更多细节才能决定如何继续,因为您从一个CAF文件开始。



最简单的音频文件格式,线性脉冲编码调制(LPCM),是逐字节或样本采样最容易读取的格式。这意味着它最容易逆转。 Kiran的解决方案正是如此。



然而,CAF格式是容器/包装器格式。虽然您的CAF文件可能包含WAV文件,但它也可能包含无法以相同方式操作的压缩文件格式。



您应该考虑首先将CAF文件转换为WAV,然后将其反转,如另一个解决方案中所示。有各种各样的库可以为你做这个转换,但是一个好的起点可能是 AudioToolbox框架,其中包括音频转换器服务。或者,如果您可以从一开始就使用WAV文件格式,则可以防止转换为WAV。



如果您找到Kiran的样本,您可能需要了解更多信息代码会给你一个错误(Core Audio很挑剔)。一个很好的起点是核心音频'圣经',学习核心音频,由 Chris Adamson 和Kevin Avila撰写。那本书使用很棒的样本来建立你对数字声音的了解。您还应该查看由 Michael Tyson 撰写的任何内容,他们开始惊人的音频引擎项目,并写了AudioBus。


I'm wanting to load a local .caf audio file and reverse the audio (play it backwards). I've gathered that I basically need to flip an array of buffer data from posts like this

However, I'm not sure how to access this buffer data from a given audio file. I have a little experience playing sounds back with AVaudioPlayer and ObjectAL(an obj-c openAL library), but I don't know how to access something lower level like this buffer data array.

Could I please get an example of how I would go about getting access to that array?

解决方案

Your problem reduces to the same problem described here, which was linked by P-i in the comment under your question. Kiran answered that question and re-posted his answer for you here. Kiran's answer is accurate, but you may need a few more details to be able to decide how to proceed because you're starting with a CAF file.

The simplest audio file format, linear pulse-code modulation (LPCM), is the easiest to read byte-for-byte or sample-for-sample. This means it's the easiest to reverse. Kiran's solution does just that.

The CAF format is a container/wrapper format, however. While your CAF file could contain a WAV file, it could also contain a compressed file format that cannot be manipulated in the same fashion.

You should consider first converting the CAF file to WAV, then reversing it as shown in the other solution. There are various libraries that will do this conversion for you, but a good place to start might be with the AudioToolbox framework, which includes Audio Converter Services. Alternately, if you can use the WAV file format from the start, you can prevent the need to convert to WAV.

You may need to know more if you find Kiran's sample code gives you an error (Core Audio is finicky). A great place to start is with the Core Audio 'Bible', "Learning Core Audio", written by Chris Adamson and Kevin Avila. That book builds your knowledge of digital sound using great samples. You should also check out anything written by Michael Tyson, who started the Amazing Audio Engine project on github, and wrote AudioBus.

这篇关于iOS音频操作 - 向后播放本地.caf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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