开发者

Cropping audio with XNA

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


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:

https://blogs.msdn.com/b/ashtat/archive/2010/06/03/soundeffect-creation-in-xna-game-studio-4.aspx


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜