Jump to content
You are about to reply to a thread that has been inactive for 1522 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Posted
// Play a sound whenever the owner is walking
integer   gWasWalking;             // TRUE when wearer is already walking
string    gSound = "Sleepwalk";    // name of soundfile in inventory
default
{
    state_entry()
    {
        // Start a timer to continuously check if the owner is walking
        llSetTimerEvent(0.25);
    }
    timer()
    {
        integer NowWalking = llGetAgentInfo(llGetOwner()) & AGENT_WALKING;
        if  (NowWalking != gWasWalking)        // walking has stopped or started
        {
            llStopSound();
            if (NowWalking)
                llLoopSound(gSound, 1.0);
        }
        gWasWalking = NowWalking;
    }
}

 

Posted (edited)

You cannot easy, as we do not have independent volume control in LSL. As the wiki states: "If a second call to loop the same sound at a different volume is made from within the same script NO volume change is made. llStopSound set just previous to the second call for a new volume allows the volume change with no discernible pause."

One way to handle it, is using !NowWalking and add a control variable to handle the timer events walking with max volume or walking with fading sound correct. Decrease volume with 10% or 25% (so either 10 or 4 times less sound volume ), you need to stop the sound and the call llLoopSound with the new volume value until it is <=10%, then stop the sound and the timer.

Specify volume with a float value fVolume and use this to control, when sound fading and the timer has to stop. Remember to set fVolume= 1.0, when walking is resumed.

Using 0.250 ms looks a little like an overkill to me, are you walking sound only 250 ms long?

Edited by Rachel1206
  • Confused 1
Posted (edited)
1 hour ago, Rachel1206 said:

You cannot easy, as we do not have independent volume control in LSL. As the wiki states: "If a second call to loop the same sound at a different volume is made from within the same script NO volume change is made. llStopSound set just previous to the second call for a new volume allows the volume change with no discernible pause."

One way to handle it, is using !NowWalking and add a control variable to handle the timer events walking with max volume or walking with fading sound correct. Decrease volume with 10% or 25% (so either 10 or 4 times less sound volume ), you need to stop the sound and the call llLoopSound with the new volume value until it is <=10%, then stop the sound and the timer.

Specify volume with a float value fVolume and use this to control, when sound fading and the timer has to stop. Remember to set fVolume= 1.0, when walking is resumed.

Using 0.250 ms looks a little like an overkill to me, are you walking sound only 250 ms long?

My music player uses llAdjustSoundVolume for volume control. A "fade out" is still not very elegant. The simplest method would be to put that function into the timer event, and set the sound based on current velocity. Or you could just have a little loop to gradually lower the volume after movement stops.

Edited by Wulfie Reanimator
  • Like 1
Posted
8 hours ago, Wulfie Reanimator said:

My music player uses llAdjustSoundVolume for volume control. A "fade out" is still not very elegant. The simplest method would be to put that function into the timer event, and set the sound based on current velocity. Or you could just have a little loop to gradually lower the volume after movement stops.

Well more or less, what I described...

Anyway, I would suggest, when LL has finished their current cloud lifting, we suggest better media handling possibilities (basic is for example a media length in milliseconds) including being able to call a sound volume from a script.

Posted (edited)
18 minutes ago, Rachel1206 said:

Well more or less, what I described...

I was responding to your first paragraph.

18 minutes ago, Rachel1206 said:

better media handling possibilities (basic is for example a media length in milliseconds) including being able to call a sound volume from a script.

What do you mean by "media length in milliseconds" and "being able to call a sound volume"?

Edited by Wulfie Reanimator
You are about to reply to a thread that has been inactive for 1522 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...