Difference between revisions of "Environment Sounds"
Silent Mole (talk | contribs) |
m (language tags to <source>) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 18: | Line 18: | ||
Looping a sound clip can add ambiance. Consider it for nighttime bugs by a lake, a crowd murmuring, or the hum of electric signs. | Looping a sound clip can add ambiance. Consider it for nighttime bugs by a lake, a crowd murmuring, or the hum of electric signs. | ||
< | <source lang="lsl2"> | ||
default | default | ||
{ | { | ||
Line 26: | Line 26: | ||
} | } | ||
} | } | ||
</ | </source> | ||
Shift-drag will allow you to create multiple copies of an object that will have their looping sounds synched together. | Shift-drag will allow you to create multiple copies of an object that will have their looping sounds synched together. | ||
Line 48: | Line 48: | ||
Some sounds are best played during certain times of day. Consider birdsong, or bats and owls. If your build is taking advantage of a region's natural day/night cycle, you can alter your ambient sound selection by the time of day your region shows. | Some sounds are best played during certain times of day. Consider birdsong, or bats and owls. If your build is taking advantage of a region's natural day/night cycle, you can alter your ambient sound selection by the time of day your region shows. | ||
< | <source lang="lsl2"> | ||
integer IsSunUp() | integer IsSunUp() | ||
{ | { | ||
Line 62: | Line 62: | ||
return FALSE; | return FALSE; | ||
} | } | ||
</ | </source> | ||
Try this [[Script:Day_Random_Sounds|daytime random sounds script]]. | Try this [[Script:Day_Random_Sounds|daytime random sounds script]]. | ||
Line 70: | Line 70: | ||
Do your bushes rustle more or louder when the wind blows? What about wind chimes? | Do your bushes rustle more or louder when the wind blows? What about wind chimes? | ||
< | <source lang="lsl2"> | ||
float GetWindStrength() | float GetWindStrength() | ||
{ | { | ||
return llVecMag(llWind(ZERO_VECTOR)); | return llVecMag(llWind(ZERO_VECTOR)); | ||
} | } | ||
</ | </source> | ||
Try this [[Script:Wind_Powered_Random_Sounds|wind powered sounds script]]. | Try this [[Script:Wind_Powered_Random_Sounds|wind powered sounds script]]. | ||
Line 83: | Line 83: | ||
Using llTriggerSound multiple times in a row can make a sound seem much louder than calling it once. This can be useful for tower bells and explosions. Be careful using this; too many times can cause an unpleasant echo-like effect. | Using llTriggerSound multiple times in a row can make a sound seem much louder than calling it once. This can be useful for tower bells and explosions. Be careful using this; too many times can cause an unpleasant echo-like effect. | ||
< | <source lang="lsl2"> | ||
integer n; | integer n; | ||
for (n = 0; n < 5; ++n) | for (n = 0; n < 5; ++n) | ||
Line 89: | Line 89: | ||
llTriggerSound(soundname, 1.0); | llTriggerSound(soundname, 1.0); | ||
} | } | ||
</ | </source> | ||
=== Scripting comments === | === Scripting comments === | ||
==== Sound clips ==== | ==== Sound clips ==== | ||
*llTriggerSound() | *[[LlTriggerSound|llTriggerSound()]] | ||
** Unattached - sounds occur where they're triggered. | ** Unattached - sounds occur where they're triggered. | ||
*llPlaySound() | ** Cannot be stopped with [[LlStopSound|llStopSound()]]. | ||
*[[LlPlaySound|llPlaySound()]] | |||
** Attached - sounds follow the object they are in if it moves. | ** Attached - sounds follow the object they are in if it moves. | ||
** Only one at a time per prim. Playing another will stop the current sound. | ** Only one at a time per prim. Playing another will stop the current sound. | ||
* llLoopSound() | *[[LlLoopSound|llLoopSound()]] | ||
** Attached - sounds follow the object they are in if it moves. | ** Attached - sounds follow the object they are in if it moves. | ||
** This continuously loops the sound. | ** This continuously loops the sound. | ||
** Only one at a time per prim. Playing another will stop the current sound. | ** Only one at a time per prim. Playing another will stop the current sound. | ||
---- | |||
Return to [[Good_Building_Practices]] |
Latest revision as of 14:37, 25 January 2015
Environmental Sounds
There's a handful of ways to generate sound without an avatar in Second Life.
- Sound clips
- a parcel's music stream
- a web page displayed on a prim
You can change all of them via scripting. The latter two can be set up without using scripts.
Soundtrack
If your build has a soundtrack or theme music that you want heard clearly across the parcel, consider using streaming music. It can be set in the About Land window. The llSetParcelMusicURL() call lets you change it via script.
You can play a series of sound clips in order, but there's no guarantee that the "song" will be heard as seamless.
Looping
Looping a sound clip can add ambiance. Consider it for nighttime bugs by a lake, a crowd murmuring, or the hum of electric signs.
default
{
state_entry()
{
llLoopSound( llGetInventoryName( INVENTORY_SOUND, 0 ), 0.5 );
}
}
Shift-drag will allow you to create multiple copies of an object that will have their looping sounds synched together.
Synchronized
Do you want your ocean wave sounds to all synch up? Does your surreal build have a slow steady heartbeat?
Try this synchronized sound script.
Random
Short ambient sounds played randomly can make a space feel more alive.
Some good choices for this would be frogs, underbrush rustles and snaps, a distant car horn or squealing brakes.
Try this random sounds script.
Day/Night
Some sounds are best played during certain times of day. Consider birdsong, or bats and owls. If your build is taking advantage of a region's natural day/night cycle, you can alter your ambient sound selection by the time of day your region shows.
integer IsSunUp()
{
vector sunPosition = llGetSunDirection();
return ( sunPosition.z > 0 );
}
integer IsTwilight()
{
vector sunPosition = llGetSunDirection();
if ( sunPosition.z > 0.0 && sunPosition.z < 0.15 )
return TRUE;
return FALSE;
}
Try this daytime random sounds script.
Wind activated
Do your bushes rustle more or louder when the wind blows? What about wind chimes?
float GetWindStrength()
{
return llVecMag(llWind(ZERO_VECTOR));
}
Try this wind powered sounds script.
Loud
Using llTriggerSound multiple times in a row can make a sound seem much louder than calling it once. This can be useful for tower bells and explosions. Be careful using this; too many times can cause an unpleasant echo-like effect.
integer n;
for (n = 0; n < 5; ++n)
{
llTriggerSound(soundname, 1.0);
}
Scripting comments
Sound clips
- llTriggerSound()
- Unattached - sounds occur where they're triggered.
- Cannot be stopped with llStopSound().
- llPlaySound()
- Attached - sounds follow the object they are in if it moves.
- Only one at a time per prim. Playing another will stop the current sound.
- llLoopSound()
- Attached - sounds follow the object they are in if it moves.
- This continuously loops the sound.
- Only one at a time per prim. Playing another will stop the current sound.
Return to Good_Building_Practices