的Ogg Vorbis在iPhone SDK [英] OGG Vorbis in iPhone sdk

查看:144
本文介绍了的Ogg Vorbis在iPhone SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不会知道是否有可能发挥的Ogg Vorbis与iPhone SDK的音频文件或是否存在一个库或一个框架,允许这一点。

i wont to know if it's possible to play ogg vorbis audio file with iphone sdk or if exist a library or a framework that allow this.

我读过一些有关OpenAL的,但我没有找到任何教程...
谁能帮我?

I've read something about OpenAl but i don't find any tutorial... Can anyone help me??

推荐答案

总比不做好迟到;)

我已经在这里找到了答案使用cocos2d的播放OGG文件在我的项目?

PASoundMgr是一个不同的声音引擎,有对OGG格式文件的支持
  回放。然而,它并没有被自的iOS 2.x的更新,并有
  从那时起,它那岂不是也出现了许多问题
  处理的。

PASoundMgr is a different sound engine that had support for ogg file playback. However, it hasn't been updated since iOS 2.x and there are numerous issues that have cropped up since then that it doesn't handle.

为什么你需要发挥OGG文件?如果将它们转换为AAC你会
  能够将它们回放使用这是更为硬件解码
  高效的从一个CPU使用率点。

Why do you need to play ogg files? If you convert them to aac you will be able to play them back using hardware decoding which is much more efficient from a cpu usage point of view.

他们提到PASoundMgr。它为我工作。我刚刚从cocos2d的框架复制的 SoundEngineTest 的是基于所有文件 - >库。而摆脱了不必要的code的。

They mentioned PASoundMgr. It worked for me. I just copied from cocos2d framework all files->libraries that SoundEngineTest was based on. And got rid of unnecessary code.

小心与iOS 5 *模拟器,他们有一些 的问题有声图书馆。我的演示工作在4.3的模拟器和设备。

Be careful with iOS 5.* simulators, they have some problems with sound library. My demo works on 4.3 simulator and on Device.

下面是步骤,我把创建演示:

Here are steps that I made to create demo:


  1. 首先,你需要的cocos2d-iphone框架。我已经知道答案,但是你可以在这里找到茯苓,2d_download

正如你可以看到的 SoundEngineTest 的依赖libvorbis.a。这是从外部/震颤组提出的文件库。此外,它依赖于OpenAL的,AudioToolbox框架。

As you can notice SoundEngineTest depends on libvorbis.a. It's a library that made of files from external/Tremor group. Also it depends on OpenAl, AudioToolbox frameworks.

我从复制的震颤的组中的所有文件到我的项目。 CreartedVorbis格式的可可触摸静态库的,没有ARC。并添加所有的源文件和头的Vorbis的目标中的构建阶段的标签。

I copied all files from tremor group to my project. Crearted "vorbis" Cocoa Touch Static Library, without ARC. And added all source files and header to the "vorbis" target in Build Phases tab.

构建阶段的OggPlayDemo添加的库(libvorbis,OpenAL的,AudioToolbox)来的的链接二进制库的框。

In the Build Phases of OggPlayDemo Added libraries (libvorbis, OpenAl, AudioToolbox) to the Link Binary with Libraries box.

新增的 PA 的类项目。并检查OggPlayDemo作为目标。为了避免与ARC,我禁用ARC编译此3的 PA 的文件的问题。 (见<一href=\"http://stackoverflow.com/questions/6646052/how-can-i-disable-arc-for-a-single-file-in-a-project\">disable ARC单个文件)

Added PA classes to project. And checked OggPlayDemo as a target. To avoid problems with ARC, I disabled ARC compilation for this 3 PA files. (see disable ARC for single file)

删除所有的cocos2d引用。有相关的纠正取决于听者方向的位置有些code ......我评论了。我不需要这个功能只是播放音频。

Removed all cocos2d references. There were some code related to correcting position of listener depending on orientation... I commented it. I don't need this feature for just playing audio.

复制的音频文件。

和最后添加了这个$​​ C $ C到ViewController中:

And finally added this code to ViewController:

- (void)viewDidLoad
{
    [super viewDidLoad];
    //init
    [PASoundMgr sharedSoundManager];
    [[[PASoundMgr sharedSoundManager] listener] setPosition:CGPointMake(0, 0)];
    self.audioSource = [[PASoundMgr sharedSoundManager] addSound:@"trance-loop" withExtension:@"ogg" position:CGPointMake(0, 0) looped:YES];

    // lower music track volume and play it
    [self.audioSource setGain:0.5f];
}
- (IBAction)play:(id)sender {
    [self.audioSource playAtListenerPosition];   
}


这篇关于的Ogg Vorbis在iPhone SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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