How do you make one sound louder then the other?

7 posts

Flag Post

http://daddyfile.com/download.php?file=6da373434552b6be61673dcbbb6041a1

Thats the demo zip which has the swf and fla.
http://img294.imageshack.us/my.php?image=demorm9.swf
See the problem is that the generated sound is quieter then the BGM. I’m working out the songs, this is just a poor poor demo. lol

But how do I set the generated sound to be louder then the music sound?

 
Flag Post

the sound interface in flash uses the MovieClip hierarchy, i.e. each sound object is assigned to a MovieClip and controls all the sound in that clip.
you can assign a MovieClip to a sound object by passing the MovieClip as a variable to the sounds constructor.
for example if i have 2 MovieClips mc1 and mc2 were mc2 is nested inside mc1, i.e.


var mc1:MovieClip = root.createEmptyMovieClip(‘mc1_mc’,_root.getNextHighestDepth());
var mc2:MovieClip = mc1.createEmptyMovieClip(’mc2
mc’,mc1.getNextHighestDepth());

i can create 2 sound objects for them sound1 and sound2:


var sound1:Sound = new Sound(mc1);
var sound2:Sound = new Sound(mc2);

the volume hierarchy works a lot like alpha in MovieClips, so:

if i set the volume for sound1 to 50 and the volume for sound2 to 100 sounds played with sound2 will play at 50%

if i set the volume for sound1 to 50 and the volume for sound2 to 40 sounds played with sound2 will play at 20%

now if you don’t send a MovieClip to the sound constructor that sound object will control the sound for _root, that means that it controls the sound for the whole movie

in your case all you need to do is replace this:


music = new Sound();
music.setVolume(25);

with this:

music = new Sound(musicplayer);
music.setVolume(25);

and get rid of this:

audio = new Sound();
audio.setVolume(25);

thanks for giving me a reason to finally learn how sound works in flash

good luck

 
Flag Post

you should also change this:



root.nowPlaying = 0;
sound = new Sound();
sound.attachSound(_root.playList[
root.nowPlaying]);


to this:


root.nowPlaying = 0;
sound = new Sound(this);
sound.attachSound(_root.playList[
root.nowPlaying]);


in the code i gave you in your previous post

 
Flag Post

Alright thanks a lot. That worked.

 
Flag Post

OK, I thought I understood how sounds were meant to work, but I’ve hit a snag.

I have several different sounds, which I don’t want to load in the first frame (because of preloading).

I want to be able to play different sounds at different volumes, at the same time.

Previously I created four sound objects without targets- trying to have a pool of four objects which could play any of a range of sounds at once. And copies of the sounds were on the main timeline after the preloader. This doesn’t work properly, because the sounds interfere with each other.

OK, this is because they don’t have targets. So I created four movieclips in code, and attach the sound objects to these. Now the sounds don’t interfere with each other, but I can’t shut up the damn timeline versions, so there is a cacophany of sound just after loading.

  1. I tried creating one global sound object just to mute those (using soundx.stop() on that frame) then deleting it. But it seems to mute everything, not just that frame. If I don’t delete it then only some sounds don’t play.
  2. I tried putting all the sounds in a movieclip to get them to load, but it made them all play together!

So what is going on?

 
Flag Post

Put the sounds on a frame after your pre-loader, then skip the frame when loading reaches 100%.

ie. sounds on frame 4, but frame 4 never gets displayed. Works also for graphics if you want to attach them from the library, but don’t want to export in frame 1 (because it ruins your pre-loader).

 
Flag Post

Hmmm. I thought I tried that… Guess I didn’t wait for it to be loaded before skipping the frame. Thanks for the tip!