iPhone - 将mp3转换为wav? [英] iPhone - convert mp3 to wav?

查看:184
本文介绍了iPhone - 将mp3转换为wav?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法可以在我的iPhone应用程序中将mp3文件转换为wav / aiff?我有一个mp3,但我希望将它与其他文件结合起来,我知道这可以做到的唯一方法就是使用PCM格式。

Is there a way I can convert an mp3 file into a wav/aiff in my iPhone app? I have an mp3 but I want to combine it with other files and the only way I know this can be done is when using PCM formats.

任何人都可以帮助我?

谢谢。

我试过的一些事情

我尝试使用AudioConverterFillComplexBuffer()方法及其回调将mp3转换为caf,但每个数据包和每帧的字节数读为0.任何想法我怎么能或我是否可以使用这个功能?

I tried using the AudioConverterFillComplexBuffer() method and its callback to convert the mp3 to caf but the bytes per packet and per frame are read as 0. Any ideas how I can or whether I can use this function?

再次感谢。

推荐答案

WAV和AIFF经常(通常?)包含PCM,那么有什么异议呢?或者您是说要将MP3数据传输到PCM以便将其混合(可能是在多声道混音器音频单元中)。如果您真的想这样做,请查看Core Audio,具体来说:

WAV and AIFF often (usually?) contain PCM, so what's the objection there? Or are you saying that you have to get your MP3 data to PCM in order to mix it (perhaps in a multichannel mixer audio unit). If you seriously want to do this, look at Core Audio, specifically:


  • 音频文件服务(读取MP3格式并写入AIFF或WAV)

  • 音频文件转换服务(如果您要写文件,则将MP3数据转换为PCM,和/或从PCM编码到其他编解码器)。请注意,给定的转换器无法在两种编码格式之间进行转换;你可以做MP3到PCM或PCM到AAC,但做MP3到AAC,你需要两个转换器。

  • 扩展音频文件服务,它们结合了两者上面提到的。

查看 ConvertFile示例。这将打开一个用于读取的源文件,描述目标文件的所需格式,从一个读取缓冲区并将它们写入另一个。代码展示了文件服务+转换服务的单独使用,以及ExtAudioFiles的方便使用。

Check out the ConvertFile example in the Core Audio SDK. This opens a source file for reading, describes the desired format of the target file, reads buffers from one and writes them to the other. The code exhibits both the separate use of file services + conversion services, and the convenient use of ExtAudioFiles.

另外,请务必了解编解码器和文件格式之间的区别,什么编解码器/格式组合是合法的。我第一次发现PCM必须是WAV中的little-endian,AIFF中的big-endian时,我感到很惊讶。

Also, be sure to understand the difference between codecs and file formats, and what codec/format combinations are legal. I was surprised the first time I found out that PCM must be little-endian in a WAV, big-endian in an AIFF.

这篇关于iPhone - 将mp3转换为wav?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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