一种在 iPhone 游戏中用小文件制作音乐的方法

发布于 2024-08-20 02:49:31 字数 1539 浏览 2 评论 0原文

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

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

发布评论

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

评论(3

陌生 2024-08-27 02:49:31

最压缩的方式是 trackerMIDI。这样您就可以只存储音乐的乐谱,而不是声音样本。

也许这个 就是您要寻找的内容。

The most compressed way would be a tracker or MIDI. That lets you store only the score for the music, not sound samples.

Maybe this is what you're looking for.

她比我温柔 2024-08-27 02:49:31

另一种选择是在您的游戏中编译开源合成器/sampler,并传达MIDI 播放器到合成器样本/声音,可以给你真正好的音乐(我是一名软件工程学生,几乎学习音乐(15 年的钢琴/合成器等),这可能有点复杂,但是,可以给你合成器用轻量级 MIDI 轨道播放很棒的声音,

祝你好运,我认为这实际上是一个非常好的(可能更复杂一点)的方法!

Another option would be to compile an open source synth/sampler in your game, and communicate a MIDI player to the synth samples/sounds, that could give you really good music ( I am a Software Engineering student and almost studied music ( 15 years of Piano/Synths etc ), that could be a bit more complex, BUT, can give you awesome sounds being played by the synth with light weight MIDI tracks to trigger the synth sounds.

Good luck, and I think this is actually a really nice ( a bit more complex maybe ) , way to go!

绅刃 2024-08-27 02:49:31

好的,我刚刚把一切都设置好了。

我将音频队列用于音乐流只是因为它是 iPhone SDK 中有详细记录的一个部分:

http://developer.apple.com/iphone/library/documentation/MusicAudio/Conceptual/AudioQueueProgrammingGuide/ AboutAudioQueues/AboutAudioQueues.html#//apple_ref/doc/uid/TP40005343-CH5-SW1

一般说明和

http://developer.apple.com/iphone/library/documentation/MusicAudio/ Conceptual/AudioQueueProgrammingGuide/AQPlayback/PlayingAudio.html#//apple_ref/doc/uid/TP40005343-CH3-SW1

是一个很好的例子(有点问题),

这似乎与 openAL 一起工作得很好。它似乎确实允许我们以样本精度水平在流中随机跳转。

唯一剩下要做的事情就是获取它,以便我们可以从内存中加载,这是通过将:

AudioFileOpenURL

的调用来完成的。

Call 替换为对AudioFileOpenWithCallbacks

不幸的是,音频文件服务的文档......很差......可以说至少。

阅读它需要您自担风险,然后在它莫名其妙地不起作用之后阅读:
http://developer.apple.com/iphone/library/qa/ qa2009/qa1676.html

告诉你回调实际上是可选的,通过提供一个 write 回调,你可以告诉它打开文件进行写入,而 MP4 则无法做到这一点,所以只需传递 NULL 即可write 和 setSize 回调。

我还想说,如果您确实想要最小的尺寸,那么这里推荐 MIDI 的两个答案几乎肯定是正确的方法。

不幸的是,我们很懒,只是想快速加入一些东西,但我们也发现我们可以适应适度压缩的音频。我还有点担心性能影响(我不知道这对 MIDI 来说意味着什么),但显然这种压缩音频的方法使用硬件解码。

如果您想走传统的压缩音频路线,希望这会有所帮助,如果您想使用 openal 的数据,您也可以尝试音频转换器服务,不幸的是,这个 API 也落入了令人尴尬的记录不足的参考手册中。我什至不知道它是否有效,如果有效,我不确定它是否使用硬件解码器。

Ok, I've just got it all set up.

I used Audio Queues for the music stream simply because it is the ONE part of the iPhone SDK that is well documented:

http://developer.apple.com/iphone/library/documentation/MusicAudio/Conceptual/AudioQueueProgrammingGuide/AboutAudioQueues/AboutAudioQueues.html#//apple_ref/doc/uid/TP40005343-CH5-SW1

for the general explanation and

http://developer.apple.com/iphone/library/documentation/MusicAudio/Conceptual/AudioQueueProgrammingGuide/AQPlayback/PlayingAudio.html#//apple_ref/doc/uid/TP40005343-CH3-SW1

for a great example (that is a bit buggy)

this seems to work fine along side openAL. and it does seem that it will allow us to jump randomly about the stream at a sample level of accuracy.

the only remaining thing to do is get it so we can load from memory, this is done by replacing the:

AudioFileOpenURL

Call with a call to:

AudioFileOpenWithCallbacks

Unfortunately the documentation for the Audio File Services is... poor... to say the least.

read it at your own risk, and then after it inexplicably doesn't work read:
http://developer.apple.com/iphone/library/qa/qa2009/qa1676.html

where it tells you that the callbacks are actually optional, and by supplying a write one you are telling it to open the file for writing which it can't do for MP4s, so just pass NULL for the write and setSize callback.

I would also like to say that the two answers here recommending MIDI are almost certainly the right way to go if you really want the smallest size.

Unfortunately we are lazy and just wanted something in quickly, it also came to light that we could fit in moderately compressed audio. I was also slightly worried about the performance implication (I don't know what that would be for midi) but apparently this method for compressed audio here uses hardware decoding.

If you want to go the traditional compressed audio route hopefully this helps, you could also try the Audio Converter Services if you want to use the data with openal, unfortunately this API also falls into the embarrassingly poorly documented reference manuals. I don't even know if it works, and if it does, I'm not sure if it uses the hardware decoders.

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