This is San Sebastian in Spain. Have a close look to the yachts in the marina, hear the clattering of lanyards and seagulls. Near the barge you will hear the engine rumbling and if you follow the dock to the left you will hear the clatter of cutlery in one of the many restaurants. To the far left near the boatramp there is an accordion playing. You may be close enough to the rocks to hear the waves crashing into them. Make sure you checkout the helicopter on the beach too.
A new unit sound3d.js manages a collection of sound sources. Essentially Sound Sources are geolocated sounds with a limited range. The sound3D manager calculates volume and pan for each sound source when the position of the listener has changed.
sound3D manages a collection of soundSource objects that have knowledge of the location they are at. A soundSource has a collection of channels. Each channel represents a sound file with associated falloff range. Outside this range the channel can not be heard.
Multiple sound channels per sound source enables you to use different sounding audio files for nearby and far away. The "far" file should sound more muffled and have a longer falloff range. These audio effects can be prepared in a sound editor such as Audacity.
The helicopter on the beach is a great example showing how this works. Move in close and notice how the engine sounds louder but also sharper.
The listener coordinates are updated by simply passing the kmlCamera object in an updateCamera call. A listener position update causes the volume and pan setting for the sound sources to be updated which is then passsed on to all it's channels.
The sound3D manager automatically starts a channel in a soundSource when the listener comes within falloff range for the channel. A sound source can have looping turned on in which case the audio will restart when finished provided the listener remains in range.
The sound3D.listener.volume property ranges from 0 - 100 and is used to control how much the listener can hear. Set this value to control the overall volume.
This demo makes use of 7 sound sources that use 9 distinct audio files.
©2009 All Rights Reserved • by PlanetInAction.com