使用 XNA 裁剪音频

发布于 2024-09-07 23:03:23 字数 160 浏览 5 评论 0 原文

我是 XNA 的新手,我试图允许用户编辑他们加载的音频文件。在 XNA 中,是否可以选择一个时间范围(例如 0:00 - 0:10)并“裁剪”该时间范围作为一个单独的实体的一部分?我想,本质上,它只是将数据复制到新文件中。可以使用 XNA Audio 库来完成此操作吗?如果可以,我应该考虑哪些方法? 谢谢

I'm new to XNA and am trying to allow the user to edit an audio file they've loaded in. In XNA, is it possible to select a time frame (e.g. 0:00 - 0:10) and 'crop' that part as a separate entity? I guess, essentially, it's simply copying that data to a new file. Can this be done using the XNA Audio library and, if so, what methods should I be looking at?
Thank you

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

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

发布评论

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

评论(3

耳钉梦 2024-09-14 23:03:23

如果您可以等待 XNA 4,那么对声音缓冲区的访问级别较低,您可以根据需要裁剪它。谷歌搜索“C# wav file”会显示大量链接,这些链接将向您展示如何操作内存中的数据。

在此下载 XNA 4.0 beta:

http://creators.xna.com/en-US/launchcenter< /a>

以下链接解释了如何使用新 API:

链接

If you can wait for XNA 4, there is low level access to sound buffers, and you can crop it however you want. A google search of "C# wav file" reveals plenty of links that will show you how to manipulate the data in memory.

Download XNA 4.0 beta here:

http://creators.xna.com/en-US/launchcenter

Here is a link that explains how to use the new API:

Link

‘画卷フ 2024-09-14 23:03:23

我看不出有什么办法可以做到你所说的,但在寻找的过程中,我确实遇到了这个有用的音频概述 和此教程关于使用 Microsoft 的跨平台音频创建工具 (XACT)。由于您是 XNA 的新手,我希望这些链接能够提供一些帮助。

问题似乎是期望音频是预先创建的,而不是按照您的要求在游戏中创建的。当然,也不乏外部音频编辑器,例如Audacity, Aviary, waveosaurAdobe SoundBooth 帮助在游戏外进行编辑。或者,您可以使用 XNA / XACT 库的播放功能来“模拟”裁剪,方法是将用户的时间范围选择存储为变量,然后仅播放音频的相应部分。

我希望其中一些能有所帮助。

-gMale

I don't see a way to do what you're saying but in the process of looking, I did come across this helpful Audio Overview and this tutorial on using Microsoft's Cross-platform Audio Creation Tool (XACT). Since you are new to XNA, I hope those links provide some help.

The problem seems to be that the expectation is that audio is created before-hand instead of in-game, as you require. Of course, there is no shortage of external audio editors such as Audacity, Aviary, waveosaur and Adobe SoundBooth to help with editing outside of the game. Alternatively, you may be able to use the playback features of the XNA / XACT libraries to "simulate" croping by storing the user's time frame selections as variables and only playing back the correspoding portions of the audio, later.

I hope some of that helps in some capacity.

-gMale

伤痕我心 2024-09-14 23:03:23

据我所知,XNA 不包含任何简单地将音乐或提示对象写入文件的方法。

如果您希望用户在 XNA 游戏中编辑音频并将其保存为仍然可用的音频文件,您必须找到正确的文件格式并直接写入。但是,如果您只想让他们操纵音频以在您的游戏中使用,我相信您还有另一种选择。

您可以序列化对象(以便在游戏之间保存状态)。您可以存储代表您对音频的操作的值(例如,开始和结束时间),并将它们与提示一起序列化。我必须承认,我从未尝试过序列化音频提示,但您可以尝试将数据推送到 XNA 内容管道中,强制它在运行时为您创建 XNB 文件。

As far as I know, XNA does not contain any means to simply write a music or cue object to a file.

If you want the user to edit the audio within your XNA game and save it as a still-usable audio file, you'll have to discover the correct file format and write it directly. However, if you just want them to manipulate the audio for use within your game, I believe you have another option.

You can serialize objects (in order to save your state between games). You can store values representing your manipulations of the audio (eg, start and end times), and serialize them along with the cue. I must admit that I've never tried serializing an audio cue, but you could try pushing your data into the XNA content pipeline, forcing it to create a XNB file for you at runtime.

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