Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Adding ambient Sounds to a Prim

Miyuki Onmura
Miyuki Onmura
Join date: 15 Dec 2006
Posts: 9
04-13-2007 15:30
I've got some audio files I downloaded that I want to add to some objects to create ambient sounds around my parcel.

I've identified that I need the llLoopSound() function but have no idea how to create the script around it to set it off.

It's probably mindnumbingly easy but I cant even work out which event I need to put it into.

Some pointers would be great.
Soen Eber
Registered User
Join date: 3 Aug 2006
Posts: 428
04-13-2007 15:46
I don't have the code handy but it is maddeningly easy. You should be able to find full source in the WIKI with a two minute search - and I just remembered it may also be in your library already with the water textures and assorted. Search your inventory for play or song or sound.
Miyuki Onmura
Miyuki Onmura
Join date: 15 Dec 2006
Posts: 9
04-13-2007 15:51
Already searched the WIKI for over 45 minutes and I'm still no closer. Seems like it's one of those things that is so obvious it isn't mentioned (or I'm so blind and missed it) ;)

Had a quick check of the Library but didn't notice anythnig obvious... Looking further
Miyuki Onmura
Miyuki Onmura
Join date: 15 Dec 2006
Posts: 9
04-13-2007 16:06
Found something called "Waterfall scripts and Sounds" with a sound file and a script containing llLoopSound function...

default
{
state_entry()
{
llLoopSound(llGetInventoryName(INVENTORY_SOUND, 0), 1);
}
}

but guess what... It doesn't work.

Had already tried....

default
{
state_entry()
{
llLoopSound("mysound",1.0);
}
}


myself but that didn't work.
Vlad Bjornson
Virtual Gardener
Join date: 11 Nov 2005
Posts: 650
04-13-2007 16:07
Here is a script that will play a random sound from the objects inventory every 60 seconds, or when the object is touched. Should be easily adapted for your purposes.

Remeber that you will need to convert you audio files into the proper format before uploading them to SL. http://secondlife.com/knowledgebase/article.php?id=142


CODE
float SoundVolume = 0.5; // between 0 and 1.0
float TimeDelay = 60; // seconds between sounds

integer NumberOfSounds;
string CurrentSound;
integer RandomSoundNum;


PlayRandomSound()
{
RandomSoundNum = (integer)llFrand( NumberOfSounds );
CurrentSound = llGetInventoryName( INVENTORY_SOUND, RandomSoundNum );
llPlaySound( CurrentSound, SoundVolume );
}

default
{
state_entry()
{
NumberOfSounds = llGetInventoryNumber( INVENTORY_SOUND) ;
llSetTimerEvent( TimeDelay );
}

touch_start( integer total_number )
{
PlayRandomSound();
}

timer()

{
PlayRandomSound();
}
}
Buck Brentano
Registered User
Join date: 26 May 2006
Posts: 11
Script Verified & WOrks!
07-09-2007 21:02
Many thanks! it works great!!!!!!