FLATLAND TUTORIAL Flatland home
texture styles orientation guide tips,tricks more blocks actions sprites popups lighting sound linking orientation textures navigation mulitilevels body tag head tag starting welcome
10 | INVISIBLE AUDIBLES: ADDING SOUND

There are four different ways that sounds can be used in spots: Ambient sounds, the SOUND Block, sounds attached to blocks in the <CREATE> tag, and sounds assigned to particular locations in the map. We've already discussed the <AMBIENT_SOUND> tag that goes in the Head of your spot file. Your visitors will hear the ambient sound at the same volume throughout the entire spot. The other two methods of using sound are attached to blocks or locations, and therefore the sound will get louder as your visitors aproach the block or location that holds the sound. Currently, all sounds used in spots must be in .wav format. Most sound processing software will save files in .wav format.

New Blocks
The SOUND Block "~"
The SOUND Block has no 3D model. You can't see it at all. You can only hear it. If you ever had an adult tell you that a child should be seen and not heard, it's time to take revenge. This block would drive them crazy.

If you want to have a sound that appears to come from an object, then you want to use the <CREATE> tag to add a sound to whatever block you want. If you just want a sound to emanate from a general area in a SPOT, then you want to use a SOUND Block or assign it to a particular location in your map. Even when you are using the SOUND Block, you still need to use the <CREATE> tag to assign the correct sound to your block, so lets look at how that works.

Using Sound in the <CREATE> tag
The tag for sound has seven attributes:
FILE, VOLUME, PLAYBACK, DELAY, FLOOD, RADIUS, and ROLLOFF. The syntax is as follows:

<CREATE SYMBOL="x" BLOCK="SOUND">
<SOUND FILE="sounds/noise.wav" VOLUME="number%" PLAYBACK="looped|random|once|single" DELAY="minimum..maximum" FLOOD="yes|no" RADIUS="number of blocks" ROLLOFF="1.0"/>
</CREATE>

Be sure to include the path when you name the FILE, if your sounds aren't in the same folder as your .3dml file.

VOLUME is expressed as a whole number percentage.

PLAYBACK determines how a sound will be played. There are 4 different PLAYBACK options: PLAYBACK="looped" will cause the sound to play continuously. If PLAYBACK="once" the sound will of course play only once. If PLAYBACK="single", then the sound will play once every time the player enters the specified RADIUS. If PLAYBACK=random", the sound will play at random intervals.

If PLAYBACK="random", you can also specify a range of DELAY times between playbacks. DELAY times are measured in seconds, and are measured from the time that the sound begins, rather than when it ends. For example, if your sound is 5 seconds long, PLAYBACK="random", and DELAY="5..10", then sometimes the sound will play back to back, (as the length of the sound file is the same as the minimum delay time), and no more than 5 seconds will ever elapse between when the sound ends and when it begins again. (The maximum DELAY time, 10 seconds, minus the length of the sound itself, 5 seconds, leaves a maximum silence of 5 seconds.)

The volume of a sound will drop off gradually as you get farther away from the source. But if FLOOD="yes", then the sound will play at the specified volume throughout the specified RADIUS, rather than dropping off gradually.

RADIUS is measured in blocks, and has two different roles. On a sound with FLOOD="yes", the RADIUS defines how large an area will be filled with that sound. If VOLUME="100%", FLOOD="yes", and RADIUS="5", then the sound will be heard at full volume right up to the edge of the 5 block border, at which point it will turn off completely. On a sound with PLAYBACK="once" or PLAYBACK="single", the RADIUS acts as a trigger. The sound will be played when the user enters the specified RADIUS.

ROLLOFF determines how quickly the sound volume will taper off as you move away from the sound source. In most cases, the default value (ROLLOFF="1.0") is the most natural setting for this parameter. But if you need more control over how the sound drops off, you can change the ROLLOFF value. If ROLLOFF="2.0", then the sound will drop off twice as fast (meaning it will be audible only half as far away from the source.) If ROLLOFF="0.5", then the sound will drop off half as fast (meaning it will be audible twice as far away.)

The default values for these attributes are as follows: VOLUME="100%" PLAYBACK="looped" DELAY="5..10" RADIUS="1" ROLLOFF="1.0"

Note that a block can only have one sound attached to it.

Using Sounds in the <BODY>
You can also assign sounds to a specific location in the map by simply adding a LOCATION parameter to the SOUND tag and placing it in the BODY of the 3DML file (usually at the end) rather than in the <CREATE> tag:


<SOUND FILE="sounds/noise.wav" VOLUME="number%" PLAYBACK="looped|random" DELAY="minimum..maximum" FLOOD="yes|no" RADIUS="number of blocks" LOCATION="(column,row,level)"/>

Improving Performance
Having lots of sound sources in a spot can tax the performance of Rover on slower machines. If you attach a sound to your floor block for instance, and that block appears 25 times in your spot, Rover has to keep track of 25 different sound sources. Visitors to your spot will get much better performance out of Rover if you place that sound on one location, or scatter a few sounds sources around the spot. If you set FLOOD="yes", and your radii overlap, the sound will play at a consistent volume throughout the area.

Just like custom textures, sound files will be downloaded in the order in which they appear in the 3DML file. Because sound files are often quite large, it is a good idea to list any <CREATE> tags that include sounds last. On the other hand, if you want your visitors to hear a sound immediately upon entering a SPOT (or at least as soon as possible) then put the tag for that sound first before the other <CREATE> tags.

Add a sound to your spot
In tallspot.3dml, add the following code after the <BODY>:

<CREATE SYMBOL="~" BLOCK="SOUND">
<SOUND FILE="sounds/giggle.wav" VOLUME="75%" RADIUS="5" FLOOD="yes" PLAYBACK="looped" />
</CREATE>

<CREATE SYMBOL="c" BLOCK="ceiling">
<PART NAME="top" TEXTURE="images/smiley.gif" />
<PART NAME="bottom" TEXTURE="@edgetop.gif" />
<SOUND FILE="sounds/guffaw.wav" VOLUME="100%" PLAYBACK="random" DELAY="3..6"/>
</CREATE>

Change Level 2 to look like this:

<LEVEL NUMBER="2"> 
###---### 
#c-----c# 
#N------# 
#.------# 
#-------# 
#-------# 
#-------# 
#c-----c# 
######### 
</LEVEL> 

And change Level 3 to look like this:

<LEVEL NUMBER="3"> 
......... 
......... 
......... 
......... 
....~.... 
......... 
......@.. 
......... 
......... 
</LEVEL> 

Listen to the smileyface...

Save your file and open it in your browser. Go up to the roof of the spot, move around and listen to the different ways the sounds work. You should be able to hear 3 different sounds: the constant ambient sound (unless you took this tag out), the guffaws that you hear intermittently and are louder if you are close to a smiley, and the giggle that plays at a constant volume throughout the area.

code spot next

 



Copyright 1999, 2000 Flatland Online, Inc.