Flex Sound extract and save mp3
I'm trying to rig up a basic mp3 cutter in Flash (using the Flex framework)
I have gotten so far:
var ba:ByteArray=new ByteArray();
sound.extract(ba, playEnd - pla开发者_如何转开发yStart, playStart);
This extracts the relevant bytes from the sound
object and stores them in ba
Then, I do this:
saveFile=new FileReference();
saveFile.save(ba, sound.id3.artist + " - " + sound.id3.songName + ".mp3");
The file saves properly, but it can not be played (Players say it is corrupted)
Any pointers as to how I can create a valid mp3 file from the byteArray obtained after the extraction?
Thanks,
PranavI have written many articles on audio processing with Flash on my blog. Here is one that you might find helpful:
http://labs.makemachine.net/2010/07/slice-tool-looper/
This article outlines how to use the microphone to record audio and also includes some info on saving audio files:
http://labs.makemachine.net/2011/04/record-visualize-save-microphone-input/
I would suggest using the wave format to save your file rather the mp3, it will save you a lot of time. Just look up the wave format and make your own class. You can have a look at this guy's class (henke37 post) : http://www.actionscript.org/forums/showthread.php3?t=256774 which can give you a start on how to do it. If you want to play your sound back later on, you will need to make a wave loader though.
精彩评论