Infinity MUGEN Team

IMT Main => M.U.G.E.N Help => Topic started by: Demongorne on March 12, 2015, 01:26:35 PM

Title: problem with playsnd
Post by: Demongorne on March 12, 2015, 01:26:35 PM
I would like have two sound effect for the same animation in such a way that the sounds effects are played randomly

I put this in statedef 3700  -   
[State 5300,PlaySnd]
type = PlaySnd
trigger1 = time= 0
value = 5300,1
Title: Re: problem with playsnd
Post by: Cyanide on March 13, 2015, 12:48:16 AM
That will, as is pretty obvious, only play one sound. Which is 5300,1. If you want 2, we'll make it simple

5300,1
5300,2

set the value to
value = 5300, 1+random%1

Alternatively
value = 5300,ifelse(random < 500, 1,2)
Title: Re: problem with playsnd
Post by: Demongorne on March 13, 2015, 06:15:20 AM
It works! Thanks a lot man just another thing: if I want have 3 sound effects for the same animation wich code I have use?
Title: Re: problem with playsnd
Post by: Chimoru on March 13, 2015, 09:59:50 AM
If you used this code:

value = 5300, 1+random%1

This randomly plays sounds 5300, 1 and 5300, 2

Then you just add another to the random, so

value = 5300, 1+random%2

Now it will randomly play  sounds 5300, 1 , 5300, 2 and 5300, 3 because you told it to play 5300,1 and the next two sounds in the 5300 category randomly.  (however if you were missing the 5300,2 & 5300,3 sounds in your SND file, it would play nothing because it looks for them numerically regardless of what is actually there. It doesn't just skip to whatever comes after 5300, 1 in the SND file)

in this case 5300, 2 & 5300, 3 are represented by the "+random%2"

So if you want to add more sounds in that order, perhaps a 5300, 4, then the random has to be a +random%3 now.

Does that make sense?

You can also use the +random% code for animations and POS as well.
Title: Re: problem with playsnd
Post by: Demongorne on March 13, 2015, 12:18:15 PM
I see yhank yu for your explanation also I would like that the sound is played for 120 ticks so I try this

[State 5300,PlaySnd]
type = PlaySnd
trigger1 = time= [0,120]
value = 5300,ifelse(random < 500, 1,2)

but the sound is not played correctly
Title: Re: problem with playsnd
Post by: Chimoru on March 13, 2015, 03:03:38 PM
Hmm.. Lemme think.
Maybe something like this?

    [State 5300, PlaySnd]
    type = PlaySnd
    trigger1 = time= 0
    value = 5300,ifelse(random < 500, 1,2)
    loop = 1
     
    [State 5300, StopSnd]
    type = stopsnd
    trigger1 = time = 120

That way the sound starts right away and repeats on loop, but then after 120 ticks, the StopSnd activates and turns it off. Though with a randomer in there, it might repeat random noises...

I'm not SURE on that, but worth a shot.
Title: Re: problem with playsnd
Post by: Demongorne on March 13, 2015, 05:40:07 PM
I typed this  but the sound is stopped a bit before the animation end

[State 6300, StopSnd]
type = StopSnd
trigger1 = time=120
value = 5300, 1
channel = 0
Title: Re: problem with playsnd
Post by: Chimoru on March 13, 2015, 05:57:17 PM
Well I don't know how long your animation is. If it's longer than 120 ticks, then keep increasing the time until it's at the length you need it at.
SimplePortal 2.3.5 © 2008-2012, SimplePortal