Table Of Contents

Previous topic

9.24. The SoundDevice Object

Next topic

9.26. The Source Object

This Page

9.25. The Sound Object

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

9.25.1. Constructor

A Sound object can be constructed with SoundDevice.createSound.

9.25.2. Properties

9.25.2.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";

9.25.2.2. frequency

Summary

The number of samples per second.

Syntax

var frequency = sound.frequency;

Note

Read Only

9.25.2.3. channels

Summary

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

Syntax

var numChannels = sound.channels;

Note

Read Only

9.25.2.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

9.25.2.5. length

Summary

The duration of the sound in seconds.

Syntax

var length = sound.length;

Note

Read Only

9.25.2.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