Difference between revisions of "Environment Sounds"
Silent Mole (talk | contribs) |
m (language tags to <source>) |
||
(12 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
* a web page displayed on a prim | * a web page displayed on a prim | ||
You can change all of them | You can change all of them via scripting. The latter two can be set up without using scripts. | ||
=== Soundtrack === | === Soundtrack === | ||
If your build has a soundtrack or theme music that you want heard clearly across the parcel, consider using [[Streaming_Music|streaming music]]. | If your build has a soundtrack or theme music that you want heard clearly across the parcel, consider using [[Streaming_Music|streaming music]]. It can be set in the About Land window. The [[LlSetParcelMusicURL|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. | 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 === | ||
Looping a sound clip can add | 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. | |||
=== Synchronized === | |||
=== Random | Do you want your ocean wave sounds to all synch up? Does your surreal build have a slow steady heartbeat? | ||
Try this [[Script:Synch_Sound|synchronized sound script]]. | |||
=== Random === | |||
Short ambient sounds played randomly can make a space feel more alive. | Short ambient sounds played randomly can make a space feel more alive. | ||
Line 40: | Line 44: | ||
Try this [[Script:Random_Sounds|random sounds script]]. | Try this [[Script:Random_Sounds|random sounds script]]. | ||
=== Day/Night | === 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. | 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() | ||
{ | { | ||
sunPosition = llGetSunDirection(); | vector sunPosition = llGetSunDirection(); | ||
return ( sunPosition.z > 0 ); | return ( sunPosition.z > 0 ); | ||
} | } | ||
Line 53: | Line 57: | ||
integer IsTwilight() | integer IsTwilight() | ||
{ | { | ||
sunPosition = llGetSunDirection(); | vector sunPosition = llGetSunDirection(); | ||
if ( sunPosition.z > 0.0 && sunPosition.z < 0.15 ) | if ( sunPosition.z > 0.0 && sunPosition.z < 0.15 ) | ||
return TRUE; | return TRUE; | ||
return FALSE; | return FALSE; | ||
} | } | ||
</ | </source> | ||
Try this [[Script:Day_Random_Sounds|daytime random sounds script]]. | |||
=== Wind activated | === Wind activated === | ||
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]]. | ||
=== | === 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. | |||
<source lang="lsl2"> | |||
integer n; | |||
for (n = 0; n < 5; ++n) | |||
{ | |||
llTriggerSound(soundname, 1.0); | |||
} | |||
</source> | |||
=== Scripting comments === | |||
==== Sound clips ==== | |||
*[[LlTriggerSound|llTriggerSound()]] | |||
** Unattached - sounds occur where they're triggered. | |||
** Cannot be stopped with [[LlStopSound|llStopSound()]]. | |||
*[[LlPlaySound|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|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]] |
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