Looping a custom sound then stopping it.

Post » Mon Dec 20, 2010 11:22 pm

How would I best go about starting a sound, letting it loop, then stopping it when I didn't want it any more?Would enabling a sound node then disabling it work?
User avatar
butterfly
 
Posts: 3467
Joined: Wed Aug 16, 2006 8:20 pm

Post » Mon Dec 20, 2010 8:43 pm

Hmm. Where is the sound being played? If its just in the gameworld then enable/disable it as you please. But if its running in 2d, just have a quest script with a timer and it runs it, then sets the timer to exactly how long the sound is, so it just played over and over as long as a variable is true, then just change the variable when you want it to stop. That should work, right?
User avatar
SamanthaLove
 
Posts: 3565
Joined: Mon Dec 11, 2006 3:54 am

Post » Mon Dec 20, 2010 12:06 pm

Its gunna be an ambient 2D sound. Not sure how well the timer idea would work, but I will look into that... The problem is the sound may be playing for a long time or a short time, cus it is "boss music" so...
User avatar
Bereket Fekadu
 
Posts: 3421
Joined: Thu Jul 12, 2007 10:41 pm

Post » Mon Dec 20, 2010 9:27 am

Well try this. Make your music, lets say its 30 seconds long. Then make the middle 20 seconds be able to loop and sound good. And break the song into 3 sound files (so 10, 10, 10) Then when the boss fight starts, it plays the first 10 seconds, then advances a variable, causing it to loop the middle 10 seconds every 10 seconds, and once you defeat the boss it advances the variable, making it play the ending part after the middle loop finishes. This way it loops the music, but at most the music keeps going up to 10 seconds after the bosses death before winding down. Other than this, I dont think you can stop a 2d sound from playing mid sound at all. And, any ingame music will still play during it, it kinda svcks. I have a cutscene in my mod (entirely scripted, no player movement) and it plays some music, but the 'dungeon music' still plays in the backround too, so it would be your boss music over the other music. Unless you set there to be no music, which would sound the best during the fight.
User avatar
Kellymarie Heppell
 
Posts: 3456
Joined: Mon Jul 24, 2006 4:37 am

Post » Mon Dec 20, 2010 4:20 pm

Yeah, I have no music set for the whole thing. And thanks, Ill give it a try, I think I can tinker it into working XD
User avatar
Miss Hayley
 
Posts: 3414
Joined: Tue Jun 27, 2006 2:31 am

Post » Mon Dec 20, 2010 11:29 am

Place the music in a sound object. Place the sound in the Render window, witn the flag 'Initially disabled' set.
Enable the sound object when you want the music to play. It will play from the sound object so you probably want to set it up with a large radius.
Disable the sound object when the boss is dead.
User avatar
Miranda Taylor
 
Posts: 3406
Joined: Sat Feb 24, 2007 3:39 pm

Post » Mon Dec 20, 2010 3:12 pm

Yea but that would give the music a directional sound, which would kinda whack the effect up.
User avatar
Taylor Thompson
 
Posts: 3350
Joined: Fri Nov 16, 2007 5:19 am

Post » Mon Dec 20, 2010 10:50 pm

Place the music in a sound object. Place the sound in the Render window, witn the flag 'Initially disabled' set.
Enable the sound object when you want the music to play. It will play from the sound object so you probably want to set it up with a large radius.
Disable the sound object when the boss is dead.

Can I safely set it to loop and have it stop as soon as its disabled? That is my concern.
User avatar
Nana Samboy
 
Posts: 3424
Joined: Thu Sep 14, 2006 4:29 pm

Post » Mon Dec 20, 2010 9:19 pm

As soon as you disable it, the sound will stop. Your biggest concern would be making the sound file in such a way so that it sounds good when the looping takes place, I would think.
User avatar
Kayla Bee
 
Posts: 3349
Joined: Fri Aug 24, 2007 5:34 pm

Post » Mon Dec 20, 2010 10:38 pm

Can I safely set it to loop and have it stop as soon as its disabled? That is my concern.

Actually it will. I have a part where you activate a hidden door, setting of a klaxon alarm sound loop sound object. I simply enable it, then after a certain amount of seconds it disables. Actually pretty much what your going for, just the seconds is exact, and always the same. But I would tweak the timer up a second or down, and it does stop instantly no matter where it is in the loop. So as long as you give it very high atenuation distance, and place it high above the center of the area, as to deter the directional part of it as much as possible, it might actually work out well.
User avatar
x_JeNnY_x
 
Posts: 3493
Joined: Wed Jul 05, 2006 3:52 pm

Post » Mon Dec 20, 2010 1:46 pm

Yes it will work. When you 'enable' it, it always starts at the beginning of the sound file loop. When you disable it, it ends no matter where it is in the loop.

Just give it an incredibly big radius (attenuation) and it will be fine for your whole level.
User avatar
Becky Cox
 
Posts: 3389
Joined: Thu Jun 22, 2006 8:38 am


Return to Fallout 3