Playing Sounds in VRML/X3D
You can use the VRML97 Sound node to play sounds. With the Sound node
you can play wav files and for contact you can play short mp3 files but
you can not with contact play long mp3 files or midi files.
However with contact there is another way you can play sound files
including long mp3 files and midi files using the MovieTexture node. Using
the MovieTexture node to play music causes windows media player to play
the sounds. This can be nice and reliable but the disadvantage with this
is you don't have control over how loud media player plays the songs were
as when you use the Sound node to play sounds it will be more 3d like in
that sounds will be louder the closer you are to them.
In short if you want back round sounds in your world like birds tweeting
or frogs croaking use the Sound node to play wav files.
If you want to play mp3 or midi songs use the MovieTexture node.
Making a simple world that plays a wav file.
First create a new smls file and delete the Seamless node (the
hoppy)
Right click on the Scene node and select paste/children/new/Sound
Right click on the Sound node and select paste/source/new/AudioClip
Select the AudioClip node and in the AudioClip node's control panel
make count = 1 for the url field
In the url field paste in the url for
you wav file.
To make the wav file play continuously check the loop field.
Now if you output the world and open it in contact you should hear
the wav file play.
Making a simple world that plays mp3 or midi songs.
First create a new smls file and delete the Seamless node (the
hoppy)
Right click on the Scene node and select paste/children/new/Shape
Right click on the Shape node and select paste/geometry/new/Box
Select the Box node.
Change the Box node's size field to 0 0 0 so that we see no box
Right click on the Shape node and select paste/appearance/new/Appearance
Right click on the Appearance node and select paste/texture/new/MovieTexture
Select the MovieTexture node and in the MovieTexture node's control
panel make count = 1 for the url field
In the url field paste in the url for
you mp3/midi file.
To make the wav file play continuously check the loop field.
Now if you output the world and open it in contact you should hear
the wav mp3/midi play.
Making sounds play when you click on an object.
You of course do not have to have a empty world to play sounds and
it is easy to make it so a sound only playes when someone clicks on an
object.
In seamless if u want to keep a Seamless node in your smls file and
want the geometry from the Seamless node to be the object the user can
click on to play the music this is easy to do.
To do this you must uncheck the loop field and add a TouchSensor node
as a sibling directly above the Seamless node.
Now we need to add a ROUTE from the TouchSensor's field touchTime to
the Movietexture's field startTime
Remember we copy the MovieTexture node first because its the destination
for the ROUTE then we right click on the TouchSensor and select paste/touchTime/TO
movieTexture/startTime
Now if you output this world and click on the object that was created
from the Seamless node the TouchSensor node will send a signal via the
ROUTE to the MovieTexture causing it to play our song.
Copyright © 2000-2005 Graham Perrett thyme@seamless3d.com