views:

123

answers:

3

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

A: 

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

gmale
Hi thanks for the response. The audio loaded will be from the user themselves, so I won't be able to edit it outside the app. What methods do I use to save the 'cropped' audio out into a new file?
Skoder
A: 

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.

Brian S
Thanks. What methods and classes should I be looking at to set information such as the current selected time? As far as I can tell, I can only get the PlayPosition. Are there any other .NET classes that might help me write out to a WMA file (e.g. Silverlight)?
Skoder
A: 

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

John JJ Curtis