Mix multiple sounds in flash

末鹿安然 提交于 2020-01-02 10:20:55

问题


I have several sound objects in flash, I would like to mix different points in these sound files to create a single masterpiece and save it as an mp3. I've seen various "mixer" applications online and would like to know what area(s) to look at to be able to do this myself.


回答1:


To create the music or whatever you're trying to create, you'll have to Import your wav and mp3 files into your library and drag them onto the movie area to add them to your timeline. Use multiple layers to help organize them. To test your song out you can hit Enter to run from whatever frame your on forward to the end.

Don't forget you have a few effects you can apply if you have the sound selected in your timeline. Also, there's an "Edit" button on the Properties panel (at the bottom by default) you can use to trim your audio clips to whatever you need them to be.

Once you're done, you'll have to publish your flash movie to a swf. Then you'll have to use a Swf to Mp3 converter like this one:

http://3d2f.com/programs/25-187-swf-to-mp3-converter-download.shtml

(I'm not vouching for this software, it's just an example)

If you're trying to do all of this from code, with ActionScript 2.0, you're going to have a hard road ahead.

Essentially, you'd have to build an array full of trimmed sound bytes you've loaded into your movie. Then in an onEnterFrame you'd have to call them at the appropriate times:

(I didn't test this code at all, it's just to give you a basic idea, lol)

var sounds = new Array();
var s0 = new Sound(this);
s0.attachSound("someLinkedSound0");
sounds.push({sound : s0, frame : 100});
var s1 = new Sound(this);
s1.attachSound("someLinkedSound1");
sounds.push({sound : s1, frame : 200});
var s2 = new Sound(this);
s2.attachSound("someLinkedSound2");
sounds.push({sound : s2, frame : 300});
var currentSound = 0;

this.onEnterFrame = function(e) {
    if(currentSound < sounds.length && sounds[currentSound].frame == _root.currentFrame) {
        sounds[currentSound].start(0,1);
        currentSound++;
    }
    frame++;
}

My example uses sounds that are imported to your library and "linked" but you can load a sounds via url with a little modification.

You could also accomplish something similar with a method called from a setInterval, if due to your application's structure onEnterFrame isn't being called. I hope that helps.




回答2:


For mixing sounds in ActionScript 2 have a look at this link. It's an elaborate explanation of how to achieve sound mixing with AS2. Next you need to check out this link to get some more info on the subject.

Saving out the mixed version of your sound out as a MP3 is not going to be possible directly from AS2. You'd have to resort to some elaborate server side script that knows when the mixed sounds are started and stopped and with that info can generate an MP3 on the server. Tricky, but not impossible.

Or you could just switch to AS3 where you can create sound at runtime (scroll all the way down for an example) and save out the result as a byte stream.




回答3:


Read a bit about flash SoundChannel, Sound and SoundTransform class. All you have to do is load your different sounds (You have examples there on how to do that in the flash docs I've linked), and play the sounds according to your timeline. Each sound can be played on a different channel, and by this you can 'mix' them. Maintain a array of channels and do whatever you want with them at whatever time you need.

To save them is a bit more work to be done but not impossible. Here you can find another example that saves a mp3 into a swf. Other methods I can't say I know but from what i've seen, you can use Alchemy and compile LAME MP3 Encoder as a flash library. You will also need a bit of backend because you cannot download files using flash. You must send them to the server then the server should initialize the download.



来源:https://stackoverflow.com/questions/1254403/mix-multiple-sounds-in-flash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!