Harry
Member
|
Sound Fading
Why sound can't fade-in when initial sound volume is equal 0? I tried sound.fadeIn and sound.fadeInFromSilence but both didn't work. It looks like fading is from 0 to actual volume. For example this code:
Code:
sound.play("../data/sound/water.ogg",true,[b]0.5f[/b]);
if(Kb.bp(KB_A))sound.fadeInFromSilence(2.0f);
will fade sound from 0 to 0.5f. But if I want make this:
Code:
sound.play("../data/sound/water.ogg",true,[b]0[/b]);
if(Kb.bp(KB_A))sound.fadeInFromSilence(2.0f);
nothing will happen. In this situation the best option is:
Code:
sound.play("../data/sound/water.ogg",true,[b]0[/b]);
if(Kb.bp(KB_A))
{
sound.volume(1);
sound.fadeInFromSilence(2.0f);
}
but couldn't it be as one method? Or I don't understand it well?
|
|
07-09-2011 11:49 PM |
|
Esenthel
Administrator
|
RE: Sound Fading
Code:
Sound sound;
Bool Init()
{
sound.create("sound.wav");
sound.fadeInFromSilence(..);
sound.play();
}
|
|
07-10-2011 03:18 PM |
|
Harry
Member
|
RE: Sound Fading
Yes, but you show me it on Init. But what if I want on some situation start sound which will fade from 0? For example sometime during playing weather change to rainy. So I want start play rain sound and fade it from 0 to 1 volume. There is some error when I make something like this (single 'pop' sound at start):
Code:
sound.play("../data/sound/water.ogg",true,1);
if(Kb.bp(KB_A))sound.fadeInFromSilence(4.0f);
But when I'll make this:
Code:
sound.play("../data/sound/water.ogg",true,0);
if(Kb.bp(KB_A))
{
sound.volume(1);
sound.fadeInFromSilence(2.0f);
}
it works, but couldn't it be inside one function? For example: fadeInFrom Silence(duration, max volume) and it will fade not from 0 to actual volume but from 0 to max volume.
|
|
07-10-2011 09:22 PM |
|
Driklyn
Member
|
RE: Sound Fading
Wait, I'm confused... Where are you calling sound.play() at and how often are you calling it? From the testing I just did, sound.play() is meant to be called only once.
So, do as Esenthel says: create, fade, then play.
Most likely the reason you occasionally hear a 'popping' noise is because the sound begins to play at a volume of 1 when you call sound.play(), then the volume suddenly drops to 0. If you create the sound first, then tell it to fade before playing, this will never happen (my testing confirms this).
Even if Esenthel were to add the method you requested, the 'popping' noise would still occur. It's the way you're coding it, not the fadeInFromSilence method.
|
|
07-10-2011 11:53 PM |
|
Harry
Member
|
RE: Sound Fading
Ok thanks, I made something wrong yesterday in codes and what should works didn't want work Now it's ok.
I always call sound only once
Thank you both for help.
|
|
07-11-2011 09:51 AM |
|