Jump to content

Loop sound from object issue


Starla Metaller
 Share

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

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

Recommended Posts

Hi, I am new to scripting and I am trying to make a prim play a looped audio sample in a particular space.

I have the file attached and have tried two scripts:

http://wiki.secondlife.com/wiki/Play_and_Loop_Sound

http://wiki.secondlife.com/wiki/LlPlaySound (just to check whether the audio file is working)

but I still cannot hear the audio, even when I am not getting any errors in the script.

I've tried removing prims with other sounds (purchased from the marketplace) which are nearby in case their volume is too high.

Any help very much appreciated!

Link to comment
Share on other sites

It's hard to tell what's wrong from your description.  Playing a sound is extremely simple, so there's no magic in making a sound audible if the sound file itself is any good. Start with the basics:
 

default
{
    touch_start(integer num)
    {
        llPlaySound("Put the name of your sound file here", 1.0);
    }
}

Drop that into a prim along with the sound file itself and click it.  You'll hear the sound.  If you don't, then either the sound file is no good or you are standing too far away.  If it works, then replace llPlaySound with llLoopSound.  That will make the sound play continually (and annoyingly, since the basic script has no way to turn it off). So modify the script by adding a toggle switch:

integer iSwitch;

default 
{
    touch_start(integer num) 
    {
        iSwitch = !iSwitch;
        if (iSwitch)
        {
            llLoopSound("Put the name of your sound file here", 1.0); 
        }
        else
        {
            llStopSound();
        }
    } 
}

That's all there is to a basic looping script.

Edited by Rolig Loon
Link to comment
Share on other sites

Thanks - the audio file is playing (albeit very quietly).  I think it is the proximity to the prim with the sound that is the issue.  Can the 'throw' of the sound be modified?

Also, I want the audio to play continually without being manually switched on and off (it's an installation).  Can another action be used other than touch_start?

Link to comment
Share on other sites

5 minutes ago, Starla Metaller said:

Can the 'throw' of the sound be modified?

No.  Sound in SL works the same way it does in RL.  Volume decreases as the square of your distance from the source.  The only way to make it louder at a distance is to make it louder at the source.  And your maximum volume is 1.0, so you can't make a sound louder than it was when you  uploaded it to SL.  If you want it louder, you'll have to use Audacity or some other external program to make it louder, and then upload it again.

8 minutes ago, Starla Metaller said:

I want the audio to play continually without being manually switched on and off

So don't put a switch in it.  Just use llLoopSound in place of llPlaySound and it will keep playing your sound incessantly until you destroy the prim it's in.  The purpose of a toggle switch is so you can turn it off when/if you want to.  If you don't want other people to mess with the switch, you can make it respond only to you.  That's probably smarter than creating a device with no On/Off switch. ;)

Link to comment
Share on other sites

  • 2 years later...

I have this problem too.  I've copied and pasted the scripts in this article and nothing happens.   I've had some experience with coding... only bad experiences though.  Never managed to get things to work.   Can any one give a from the ground up explanation without assuming any prior knowledge? 

"Drop that into a prim along with the sound file itself and click it. "  How does one do this? I have dragged the sound file into the contents folder, and created a new script with the code stated. 

 

"If you don't, then either the sound file is no good "  Not sure what this means either so this is making me doubt myself.  I uploaded the file i am testing myself and it works great with gestures or when playing.  Something in the instructions is missing surely.

 

Edited by thedude2514
incomplete
Link to comment
Share on other sites

Did you actually type the exact name of your sound file where the script says, "Put the name of your sound file here", or did you just use the sample script verbatim?  Remember, spelling and capitalization count.  And is your file in an acceptable file type and format (PCM WAV format, 16-bit, 44.1kHz, mono, less than 10.0 seconds long)? And is your script running (look at the check box that says "Running")?

Link to comment
Share on other sites

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