Music Volume that Automatically Lowers?

nickadocker

Novice

Posts: 23

3+ Months Ago

Hi!

If anyone can help me it would be greatly appreciated! I'm working with Flash MX 2004 and I'm trying to lower the volume, at a specific time, of an mp3 that is playing during my flash movie. The 'music.mp3' begins playing at the start of the movie, then at one point, another sound effect of something falling and going boom ('boom.wav') plays but I can hardly hear it over the music. So I was wondering if there is a simple process to make it so that at the point the sound effect 'boom.wav' plays, the 'music.mp3' volume decreases enough, say down to 25% of the original volume or something, so that I can hear the 'boom.wav' effect. Is this a possibility?

Also, I'm not totally sure if I'm equipping (I guess that term works?) the sound files properly in my movie. Maybe someone can explain if the following way i got it to work is okay, or if there is a more solid way to do it. Here are the steps of how I got it to work:

1. Import 'music.mp3' into the library.
2. Create a new layer exclusively for 'music.mp3'.
3. Create a keyframe on that layer.
4. Go down to the Properties menu at the bottom of the screen and under sound, select 'music.mp3' from the dropdown menu.

This is also the way I installed the 'boom.wav' effect as well (except on a separate layer). Any help would be unbelievably helpful!

Thanks!

lostinbeta

Guru

Posts: 1402

Loc: Philadelphia, PA

3+ Months Ago

By using Sound() objects you have more control over your sound.

There are a few threads in this section already dealing with Sound() objects. And I always personally recommend reading up at http://www.kennybellew.com/tutorial It's the best Sound() objects tutorial you will find on the web.

However, i didnt see anything that explains how to have a sound to automatically lower its volume at certain points in the movie. i could see how a button clicked might be able to do that - whatever.setVolume(10);, ? but thats not what i want.

Is there anything that works like: song plays automatically when movie starts at volume(100), at frame 400 song plays at volume(10), then if i want fades out at frame 600.

if i cant figure this out through actionscripts, my other idea was to import the audio file into an audio editing program and try to lower the volumes at the right times. then save it as a new file and import it into flash like that. i think this would work but i have a feeling it would take a *plum* load of trial and error and im also concerned about losing audio quality.

i hope someone can please help.
thanks again!

lostinbeta

Guru

Posts: 1402

Loc: Philadelphia, PA

3+ Months Ago

you don't need to call all actions on a button command, if you put whatever.setVolume(10); on the frame itself (right click on the frame and open the actions panel) the action will get called when that frame is it.

And for a fade out on frame 600 I would recommend doing something like storing the volume value in a variable (lets call it soundVolume for thie example) then on frame 600 do something like

Wow you're amazing! it worked! thanks so much! ive almost got exactly what im trying to do. The code for the fade out worked great, now I was wondering how to fade the music back in again without stopping it. i tried the below code at one frame to quiet the music without stopping it:

Also, i was wondering if it is possible to control the speed at which the sound fades in and out? Can it fade faster? I feel so unbelievably grateful that you’re taking the time to answer my questions! You’re the man!
Thanks!

nickadocker

Novice

Posts: 23

3+ Months Ago

One last thing. i just noticed that when the music is set to volume15, all the other sound files that are playing simultaneously are also set to volume15. i want the music to be at vol15, but the other sound effects to be at 100, or whatever level i chose. i hope im not bugging you too much, so im going to check through the kennybellew sound tutorial again to see if he knows a solution.

lostinbeta

Guru

Posts: 1402

Loc: Philadelphia, PA

3+ Months Ago

Your problem is because soundVolume is never greater than 100 (as per what your if statement is checking) and you are still decrementing it.

Now for the faster fading soundVolume++ and soundVolume-- are incrementing and decrementing (respectively).

soundVolume++ is the same as soundVolume = soundVolume+1 or soundVolume += 1.

soundVolume-- is the same as soundVolume = soundVolume-1 or soundVolume -= 1.

If you use soundVolume += or soundVolume -= you can put in a higher value than 1 for a faster incrementation or decrementation.

And now for all sound being turned down. Erm.. this may be because your Sound Object doesn't target anything specific. Here is the part of the tutorial that goes over controlling individual sounds...

http://www.kennybellew.com/tutorial/independent.htm

nickadocker

Novice

Posts: 23

3+ Months Ago

Heres what i tried and its not working for some reason:

1. Started a brand new flash doc
2. imported 2 sound files – music.mp3, and boom.wav
3. right clicked music.mp3 file in the library > linkage > Identifier = music > check export for ActionScript
4. right clicked boom.mp3 file in the library > linkage > Identifier = boom > check export for ActionScript
5. created two new layers on the root timeline: one named ‘sound objects’, the other named ‘actions’
6. made each layer 60 frames long
7. at frame 60 on the actions layer, created a keyframe and assigned the action stop

*Okay i think this is where things get screwed up!

8. created a movie clip: Insert > New Symbol > name: musicMc > behavior: Movie clip > OK
9. created a movie clip: Insert > New Symbol > name: boomMc > behavior: Movie clip > OK
10. after hitting OK, im now in the edit movie clip area (or whatever you call it), so i click scene1 at the top above the timeline to go back to the root timeline.
11. on the root timeline, on frame1 of the layer named ‘sound objects’, i drag the movie clip musicMc onto the stage (a small icon of a black circle with a cross through it shows up)
12. on the root timeline, on frame30 of the layer named ‘sound objects’ i inserted a keyframe, then drag the movie clip boomMc onto the stage (a small icon of a black circle with a cross through it shows up)
13. on the root timeline, i clicked once on frame 1 of the layer ‘sound objects’ (where musicMc movie clip is), then opened the actions menu and inserted this:
firstSound = new Sound(musicMc);
firstSound.attachSound("music");
firstSound.setVolume(20);
firstSound.start(0, 1);
14. on the root timeline, i clicked once on frame 30 of the layer ‘sound objects’ (where boomMc movie clip is), then opened the actions menu and inserted this:
secondSound = new Sound(boomMc);
secondSound.attachSound("boom");
secondSound.setVolume(100);
secondSound.start(0, 1);
15. I hit Ctrl+Enter to Test the movie and... it successfully plays music.mp3 at volume20 until it reaches frame30 when suddenly the boom.wav plays at volume100, however this somehow triggers music.mp3 to jump up to volume100 as well sounding load and retarded!
My goal is to make it so that at frame30 when boom.wav plays at volume100, music.mp3 stays at volume20. I know this must be possible - i have faith!

Thanks for all your help!!

nickadocker

Novice

Posts: 23

3+ Months Ago

by the way, the fading in and out and the soundvolume options you suggested worked perfectly! Thanks! Now i think im down to my last challenge (the above post)

nickadocker

Novice

Posts: 23

3+ Months Ago

I was offered advice from someone else who suggested this script, which is NOT what i want but here it is for reference:

The above code seems much more complicated then the code you (lostinbeta) were suggesting and I have a feeling its not the direction I want. I want to understand how to get sound objects to work, for example: how did he get this to work http://www.kennybellew.com/tutorial/independent.htmif you, or someone, could write a step by step process of how to get this code to work from starting with a new document in flash, that would be totally awesome! i know i wouldn't be the only one benefiting from that! again, my goal is to make it so that at frame30 when boom.wav plays at volume100, music.mp3 stays at volume20. I want to have independent control over both sounds, and any other sounds i incorporate throughout the entire movie, so at any frame i want i can increase the volume of one sound and simultaneously decrease the volume of another. and i want this done without the viewer having to press any buttons, so it just happens (like when your watching a movie the sound volume just automatically changes). I hope there is still more help out there for me! and thanks again lostinbeta, you are a huge contribution to this site!