Table Of Contents

Previous topic

17.13. The Shader Object

Next topic

17.16. The SoundDevice Object

This Page

17.15. The Sound Object

A Sound object contains sound samples ready for playback from a Source.

17.15.1. Constructor

A Sound object can be constructed with SoundDevice.createSound.

17.15.2. Methods

17.15.2.1. destroy

Summary

Releases the Sound resources; the object will be invalid after the method is called.

Syntax

sound.destroy();

17.15.3. Properties

17.15.3.1. name

Summary

The name of the sound. Must be specified on creation of the sound, unless a src is specified in which case the name will be the src e.g. “sounds/duck.ogg”. Sounds loaded from a sound archive will take the filename path specified in the archive directory listing.

Syntax

var name = sound.name;

OR

sound.name = "Sound1";

17.15.3.2. frequency

Summary

The number of samples per second.

Syntax

var frequency = sound.frequency;

Note

Read Only

17.15.3.3. channels

Summary

The number of channels, 1 means mono, 2 stereo, etc.

Syntax

var numChannels = sound.channels;

Note

Read Only

17.15.3.4. bitrate

Summary

The number of bits per second. This number is the result of calculating: samples per second * bits per sample * number of channels.

Syntax

var bitrate = sound.bitrate;

Note

Read Only

17.15.3.5. length

Summary

The duration of the sound in seconds.

Syntax

var length = sound.length;

Note

Read Only

17.15.3.6. compressed

Summary

True if the sampling data is in a compressed form, false otherwise. Playback of compressed sounds increases CPU usage but the storage of the sampling data requires far less memory.

Syntax

var compressed = sound.compressed;

Note

Read Only