使用 XNA 裁剪音频
我是 XNA 的新手,我试图允许用户编辑他们加载的音频文件。在 XNA 中,是否可以选择一个时间范围(例如 0:00 - 0:10)并“裁剪”该时间范围作为一个单独的实体的一部分?我想,本质上,它只是将数据复制到新文件中。可以使用 XNA Audio 库来完成此操作吗?如果可以,我应该考虑哪些方法? 谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您可以等待 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
我看不出有什么办法可以做到你所说的,但在寻找的过程中,我确实遇到了这个有用的音频概述 和此教程关于使用 Microsoft 的跨平台音频创建工具 (XACT)。由于您是 XNA 的新手,我希望这些链接能够提供一些帮助。
问题似乎是期望音频是预先创建的,而不是按照您的要求在游戏中创建的。当然,也不乏外部音频编辑器,例如Audacity, Aviary, waveosaur 和 Adobe 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
据我所知,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.