iPhone sdk 中的 OGG Vorbis

发布于 2024-10-12 19:34:40 字数 118 浏览 5 评论 0原文

我想知道是否可以使用 iPhone SDK 播放 Ogg Vorbis 音频文件,或者是否存在允许这样做的库或框架。

我读过一些有关 OpenAL 的内容,但没有找到任何教程...... 有人可以帮助我吗?

I want 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.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

送你一个梦 2024-10-19 19:34:40

迟到总比不到好;)
我在这里找到了答案在我的项目中使用cocos2d播放ogg文件?

PASoundMgr 是一个不同的声音引擎,支持 ogg 文件
播放。然而,自 iOS 2.x 以来,它就没有更新过,并且有
从那时起,出现了许多问题,但它并没有
句柄。

为什么需要播放ogg文件?如果你将它们转换为 aac 你会
能够使用硬件解码来播放它们,这要多得多
从CPU使用的角度来看是高效的。

他们提到了 PASoundMgr。这对我有用。我刚刚从 cocos2d 框架复制了 SoundEngineTest 所基于的所有文件 -> 库。并删除了不必要的代码。

这是我的 demoProject,展示了如何在 ios 上玩 ogg。

请小心 iOS 5.* 模拟器,它们在声音库方面存在一些问题 。我的演示适用于 4.3 模拟器和设备。


以下是我创建演示的步骤:

  1. 首先,您需要 cocos2d-iphone 框架。我已经有了它,但你可以在这里找到它 cocos-2d_download

  2. 正如您所注意到的,SoundEngineTest 依赖于 libvorbis.a。它是一个由 external/Tremor 组的文件组成的库。它还依赖于 OpenAl、AudioToolbox 框架。

  3. 我将所有文件从tremor组复制到我的项目中。创建了“vorbis”Cocoa Touch 静态库,没有 ARC。并将所有源文件和标头添加到构建阶段选项卡中的“vorbis”目标。

  4. 在 OggPlayDemo 的构建阶段中,将库(libvorbis、OpenAl、AudioToolbox)添加到链接二进制文件与库框中。

  5. 向项目添加了 PA 类。并检查 OggPlayDemo 作为目标。为了避免 ARC 出现问题,我禁用了这 3 个 PA 文件的 ARC 编译。 (请参阅禁用单个文件的 ARC< /a>)

  6. 删除了所有 cocos2d 引用。有一些与根据方向纠正侦听器位置相关的代码......我评论了它。我不需要这个功能来播放音频。

  7. 已复制的音频文件。

  8. 最后将这段代码添加到 ViewController 中:

    - (void)viewDidLoad
    {
        [超级viewDidLoad];
        //初始化
        [PASoundMgr 共享声音管理器];
        [[[PASoundMgr shareSoundManager] 监听器] setPosition:CGPointMake(0, 0)];
        self.audioSource = [[PASoundMgr shareSoundManager] addSound:@"trance-loop" withExtension:@"ogg" 位置:CGPointMake(0, 0) 循环:YES];
    
        // 降低音乐曲目音量并播放
        [self.audioSource setGain:0.5f];
    }
    -(IBAction)播放:(id)发送者{
        [self.audioSource playAtListenerPosition];   
    }
    

Better late than never ;)
I have found the answer here Use cocos2d for playing ogg file in my project?.

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.

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.

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.

Here is my demoProject that shows how to play ogg on ios.

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. First you will need cocos2d-iphone framework. I've already had it, but you can find it here cocos-2d_download.

  2. 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.

  3. 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.

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

  5. 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)

  6. 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.

  7. Copied audio file.

  8. 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];   
    }
    
极度宠爱 2024-10-19 19:34:40

Cricket Audio 将播放 ogg 文件等,并适用于 iOS/Android/WP8。

Cricket Audio will play ogg files, among others, and works on iOS/Android/WP8.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文