Jump to content

Loop sound - volume control?


Leoplod
 Share

You are about to reply to a thread that has been inactive for 1844 days.

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

Recommended Posts

I have little scripting experience, so please bear with me - I also searced the forums for a couple hours, but without result

I try to use a simple loop sound script, but it doesn't make any difference in sound volume whether I set "float vol" to 0.1 or 1.0

Can someone please help me with this? I need to make the faint fountain sound louder - it makes no difference whether I have the sound in the prim with the script or use the UUID

Thanks...

 

float min = 1;

float max = 30;

float vol = 0.5;

// Sound to play.
key sound = "Fountain";

default
{
    state_entry()
    {
          
       
        llLoopSound(sound, vol);
        

    }        
}

 

Link to comment
Share on other sites

7 minutes ago, Qie Niangao said:

What happens if you llStopSound() first, before starting to loop it again?

Also, be sure the sound is loud enough when you play it directly from inventory. Imported sounds tend to sound quieter in-world than they seem in, say, Audacity.

When SL compress the sound file on download it reduces the vol to about 50% of Audacity. At a guess i would say SL converts the file to mono.

Edited by steph Arnott
Link to comment
Share on other sites

Like Qie guessed, you have to first stop the sound before you can play it again with a different volume. (I think this is because playing a looping sound that is already playing is ignored.) Though, fun fact; there's a function called llAdjustSoundVolume which can change the volume of a looping sound without restarting it. It's not particularly helpful here, but maybe elsewhere.

Edited by Wulfie Reanimator
  • Like 1
Link to comment
Share on other sites

2 hours ago, Qie Niangao said:

What happens if you llStopSound() first, before starting to loop it again?

Also, be sure the sound is loud enough when you play it directly from inventory. Imported sounds tend to sound quieter in-world than they seem in, say, Audacity.

Thanks for the replies to all...

where in the script do I insert "llStopSound()"?

I don't have experience in scripting and get "syntax error" whatever I try

(I changed key sound = "Fountain";  to  string sound = "Fountain"; )

 

float min = 1;
float max = 30;
float vol = 0.5;

// Sound to play.
string sound = "Fountain";

default
{
    state_entry()
    {
          
       
        llLoopSound(sound, vol);
 

    }        
}

 

 

 

Link to comment
Share on other sites

7 minutes ago, Leoplod said:

 

float vol = 0.5;
string sound = "Fountain";

default
{
	state_entry()
	{
	}
	touch_start(integer total_number)
	{
		llLoopSound(sound, vol);
	}
}

This needs the sound in the object inventory. If you use the UUID key for the asset then  add the "this is the uuid key" and use that. It does not have to be in object if you use the key

Edited by steph Arnott
Link to comment
Share on other sites

1 minute ago, Leoplod said:

where in the script do I insert "llStopSound()"?

Wherever you want to stop it.

Depending on what you want the trigger to be, you might want
 

touch_start( integer num )
{
    llStopSound();
}

or
 

timer()
{
    llStopSound();
}

or
 

listen (integer channel, string name, key id, string message)
{
    if (message == "Stop")
    {
        llStopSound();
    }
}

or

sensor(integer num )
{
    llStopSound();
}

Each of those assumes that you have set up the event properly with llSetTimerEvent() or llListen() or llSensor().  Another question, which you haven't addressed, is how to turn the sound back on again.  The quickest (and clumsiest) way to do it is simply to restart the script.  It's not at all elegant, but it works.  If you are learning, though, it might be a good idea to search for examples of code that switches ON/OFF.

Link to comment
Share on other sites

For a quick fix of stopping the currently playing sound and restarting it with a new volume, Placing llStopSound(); on the line before the llLoopSound command in your state_entry event should work.

Make sure you don't forget to add a semicolon ( ; ) after the command - otherwise you'll get a syntax error.

Link to comment
Share on other sites

2 minutes ago, Fenix Eldritch said:

For a quick fix of stopping the currently playing sound and restarting it with a new volume, Placing llStopSound(); on the line before the llLoopSound command in your state_entry event should work.

Make sure you don't forget to add a semicolon ( ; ) after the command - otherwise you'll get a syntax error.

The OP was on about sound volume, not stopping a loop.

Link to comment
Share on other sites

3 minutes ago, Fenix Eldritch said:

Why are you so confrontational? I was responding to OP's most recent reply - in which they were asking where to place the llStopSound command in their sample script.

Not confrontational at all. The issue is the sound volume.

Link to comment
Share on other sites

16 minutes ago, Fenix Eldritch said:

For a quick fix of stopping the currently playing sound and restarting it with a new volume, Placing llStopSound(); on the line before the llLoopSound command in your state_entry event should work.

Make sure you don't forget to add a semicolon ( ; ) after the command - otherwise you'll get a syntax error.

Thank you Fenix... I can now control the volume

And thanks for reminding me about the semicolon, that's what had me beaten

Thanks again to all for helping

Link to comment
Share on other sites

34 minutes ago, Leoplod said:

Thank you Fenix... I can now control the volume

And thanks for reminding me about the semicolon, that's what had me beaten

Thanks again to all for helping

 float min = 1;

float max = 30;

float vol = 0.5;

// Sound to play.
key sound = "Fountain";//this is a string

default
{
    state_entry()
    {
        llLoopSound(sound, vol);
        
    }        
} 

So your script here is not the one used inworld. Which does clear up the fact that there is nothing wrong with this.

Link to comment
Share on other sites

2 minutes ago, steph Arnott said:

 float min = 1;

float max = 30;

float vol = 0.5;

// Sound to play.
key sound = "Fountain";//this is a string

default
{
    state_entry()
    {
        llLoopSound(sound, vol);
        
    }        
} 

So your script here is not the one used inworld. Which does clear up the fact that there is nothing wrong with this.

That is the script with which you couldn't control the volume - otherwise it workes, as long as you are happy with the preset volume

Below is the modified script with the stop command that let's me control the volume and raise it to 1.0

Thanks again

 

float min = 1;


float max = 30;


float vol = 1.0;

// Sound to play.
string sound = "bcb6dd68-1d01-5a32-9036-612c797373f9";

default
{
    state_entry()
    {
          
        llStopSound();
        llLoopSound(sound, vol);
        

    }        
}

 

Link to comment
Share on other sites

That's interesting. I wonder why llSound was deprecated, inasmuch as it seems to have almost all the functionality of the current suite of (attached) sound functions, so I wonder why they went to all the trouble of replacing it. The one current behavior the old function lacks is to silently do nothing if called while a sound is playing and llSetSoundQueuing is turned off; rather, at least as documented, llSound would either interrupt the current sound or queue the new one for after the first completes, depending on its queue parameter. (So now I'm wondering how one calls it in a way that makes it play multiple sounds; maybe that's the non-queuing behavior if the previous sound was looped? Can't really test that at the moment.)

Link to comment
Share on other sites

Here is how do it. Notice;  do not use the deprecated function llSound() - instead use the new sound functions.

// Example of using the deprecated llSound function
default
{    
    state_entry()
    {
        // Stop sound(s) after 30 seconds
        llSetTimerEvent(30.0);  
        // Play "master" sound
        llSound("f7ab57e1-299e-7828-3aa5-0a37f5ec19db",1.0,TRUE,TRUE);
        
        llSay(0, "Click me for a SNEEZE! - all sounds stop after 30 seconds");
    }    
    
    touch_start(integer total_number)
    {
        // Play "child" sound
        llSound("1bf70184-e383-1493-4e7f-25ff1155f953",1.0,FALSE,FALSE);    
    }
    
    timer()
    {
        // We are done
        llSetTimerEvent(0.0);
        llStopSound();
    }
}

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Qie, I spent some time messing with the old llSound on the beta grid and here are my findings:

  1. llSound seems to only loop if both the queue and loop parameters are TRUE.
  2. Calling llSound with the loop parameter set to FALSE will not interrupt an already playing attached sound (looping or not) set by llLoopSound llPlaySound, or a previous llSound call. The queue parameter doesn't seem to have any effect (that I could see) when loop is FALSE.
  3. Calling llSound with queue=FALSE and loop=TRUE will interrupt any currently playing/looping attached sound similar to llPlaySound's behavior.
  4. Calling llSound from a HUD will result in the sound emanating from the avatar's in-world position instead of the worn HUD.

As a side note, I did a little digging and discovered that llSound has been deprecated since early 2004 - and possibly earlier. That's astoundingly early... I'm really curious what happened back then to make them switch.

Edited by Fenix Eldritch
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1844 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
 Share

×
×
  • Create New...