我怎样才能用碳或可可播放存档的音频

发布于 2024-09-30 21:35:45 字数 560 浏览 0 评论 0原文

我有一个包含多个 .mp3 格式的音频文件的存档文件。 我可以查找指定的文件并以块的形式检索该文件。

我想连续播放其中几个文件。看起来这应该是一件简单的事情,但我很难找到如何做到这一点的可靠示例。

我尝试过使用 matt gallagher 的 AudioStreamer 示例以及苹果 aqplay 和 afsplay 示例,它们看起来过于复杂,我只是无法让它们做我需要的事情。

那么有人对我如何实现这一目标有任何指示吗?

将文件提取到磁盘并播放它们是我想避免的解决方案。

更新:

最初的问题对此并不清楚,但格式是自定义存档格式,我可以逐块读取。由于各种原因,我无法/不会将文件保存到临时文件中。所以我正在寻找一种将块输入音频库来播放它们的方法。

AudioStreamer 和 afsplay 示例几乎做到了这一点 - 第一个轨道工作得很好 - 但然后在第二个轨道上窒息 - 可能是因为它们是为单个流设计的,而不是一个接一个地来自多个文件的流......更改应该很简单,但是我对coreaudio的了解为零。我怀疑核心音频对于此类问题也太过分了(但也许不是......再次零经验对我不利)

I've got an archive file containing multiple audio files in .mp3 format.
I can seek to a specified file and retrieve that file in blocks.

I'd like to play several of these files in succession. It seems like this should be a simple thing to do, but I'm having difficulty finding a solid example of how to do this.

I've tried using the AudioStreamer example by matt gallagher and the apple aqplay and afsplay examples and they seem excessively complicated and I just cant get them to do what I need.

So does anyone have any pointers on how I can achieve this?

Extracting the files to disk and playing them is a solution I'd like to avoid.

UPDATE:

The original question isn't clear about this, but the format is a custom archive format, which I can read chunk by chunk. For various reasons I cant/wont save the files out to temporaries. So what I'm looking for is a way to feed the chunks into an audio library to play them.

The AudioStreamer and afsplay examples almost do this - working beautifully for the first track - but then choke on the second track - probably as they are designed for single streams, not streams from multiple files one after the other... the changes should be simple, but my knowledge of coreaudio is zero. I suspect that core audio is also overkill for this kind of problem ( but then again maybe not .. again zero experience working against me)

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

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

发布评论

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

评论(2

澉约 2024-10-07 21:35:45

[修改答案]

哦,好的。无论如何,您都会对存档进行解码,因此这基本上与您从源连续接收/检索多个连续曲目的内容的任何其他情况没有什么不同。本质上是流媒体,除非不是通过网络。

您应该能够使用音频队列来做到这一点。

请注意,如果文件的比特率或采样率不同,您可能必须更改文件之间的音频配置 (ASBD)。

不过,我不是核心音频专家。其他人可能可以提供更具体的答案。

[Revised answer]

Oh, OK. You're decoding the archive anyway, so this is basically no different than any other situation where you're continuously receiving/retrieving the contents of multiple successive tracks from a source. Essentially, streaming, except not over the network.

You should be able to do this with an Audio Queue.

Note that you may have to change audio configurations (ASBD) between files, if, say, their bit rates or sample rates differ.

I'm not a Core Audio expert, though. Somebody else could probably provide a more specific answer.

一梦等七年七年为一梦 2024-10-07 21:35:45

您需要确保为每个不同的 MP3 文件重新初始化或创建音频转换器的新实例。如果需要,您可以重新创建整个音频链直至音频队列。除非出现性能问题,否则我认为这很好。

You need to make sure you reinitialize or create a new instance of the audio converter for each MP3 file that's different. You can just recreate the entire audio chain down to the AudioQueue if you want. Unless there's performance problems, I think that's fine.

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