Class: SoundChannel

(package) rune.media.SoundChannel(sharedopt)

The SoundChannel class represents an sound channel for playing sound effects and / or music. The class is used to create and bind Sound objects to the channel. Each Sound object must be connected to an audio channel in order to be played. There are two types of Sound objects; unique and shared. With shared Sound objects, it is possible to reuse the same object for several different sound sources. Note that there can be no multiple playbacks of a shared audio object at one time, in which case a unique object must be used.

Constructor

(package) new SoundChannel(sharedopt)

Creates a new sound channel.
Parameters:
Name Type Attributes Default Description
shared boolean <optional>
false Whether the channel should only use shared audio objects (true) or not (false).
Source:

Members

(readonly) length :number

Returns the number of Sound objects registered in the sound channel.
Type:
  • number
Source:

(readonly) paused :boolean

Whether all sounds in the sound channel are paused (true) or not (false).
Type:
  • boolean
Source:

rate :number

Sets the rate at which the audio is being played back. The normal playback rate is multiplied by this value to obtain the current rate, so a value of 1.0 indicates normal speed.
Type:
  • number
Source:

(readonly) shared :boolean

Returns whether the sound channel is limited to shared Sound objects only (true) or not (false). If the channel is "shared", all requests for unique Sound objects are denied.
Type:
  • boolean
Source:

volume :number

The global sound level for all Sound objects requested by this channel.
Type:
  • number
Source:

Methods

clear() → {undefined}

Clears the current audio channel on Sound objects. This means that ongoing playback of Sound objects is stopped and all object references are destroyed.
Source:
Returns:
Type
undefined

fade(to, duration) → {undefined}

Adjust the volume of the audio channel to a certain level.
Parameters:
Name Type Description
to number Target volume.
duration number Fade duration.
Source:
Returns:
Type
undefined

get(name, uniqueopt) → {rune.media.Sound}

Gets (and binds) a Sound object to the channel. The returned Sound object contains an interface for handling that particular sound, but all playback will be tied to the channel from which the object was created.
Parameters:
Name Type Attributes Default Description
name string The name of the resource file that the Sound object will use.
unique boolean <optional>
false Whether the object should be unique (true) or shared (false).
Source:
Returns:
Type
rune.media.Sound

pause() → {undefined}

Pauses playback of all Sound objects on this channel.
Source:
Returns:
Type
undefined

remove(sound, dispose) → {rune.media.Sound}

Removes a Sound object from the channel. By default, objects are removed from the channel, but retained in memory. Set the dispose argument to true to destroy the object as it is removed from the channel. If the object is destroyed, a null reference is returned.
Parameters:
Name Type Description
sound rune.media.Sound Sound object to remove.
dispose boolean Whether the object should be deallocated.
Source:
Returns:
Type
rune.media.Sound

resume() → {undefined}

Resumes playback of all Sound objects on this channel.
Source:
Returns:
Type
undefined