Hatch Game Engine Documentation v1.4.0
The documentation for the Hatch Game Engine
Loading...
Searching...
No Matches
Sound Class Reference

Sound playback. More...

Public Member Functions

integer Play (integer sound, integer loopPoint, decimal panning=0.0, decimal speed=1.0, decimal volume=1.0)
 Plays a sound either once or in a loop.
void Stop (integer sound)
 Stops an actively playing sound.
void Pause (integer sound)
 Pauses an actively playing sound.
void Resume (integer sound)
 Unpauses a paused sound.
void StopAll ()
 Stops all actively playing sounds.
void PauseAll ()
 Pauses all actively playing sounds.
void ResumeAll ()
 Resumes all actively playing sounds.
boolean IsPlaying (integer sound)
 Checks whether a sound is currently playing.
integer PlayMultiple (integer sound, integer loopPoint, decimal panning=0.0, decimal speed=1.0, decimal volume=1.0)
 Plays a sound once or loops it, without interrupting channels playing the same sound.
void PlayAtChannel (integer channel, integer sound, integer loopPoint, decimal panning=0.0, decimal speed=1.0, decimal volume=1.0)
 Plays or loops a sound at the specified channel.
void StopChannel (integer channel)
 Stops a channel.
void PauseChannel (integer channel)
 Pauses a channel.
void ResumeChannel (integer channel)
 Unpauses a paused channel.
void AlterChannel (integer channel, decimal panning, decimal speed, decimal volume)
 Alters the playback conditions of the specified channel.
integer GetFreeChannel ()
 Gets the first channel index that is not currently playing any sound.
void IsChannelFree (integer sound)
 Checks whether a channel is currently playing any sound.
integer GetLoopPoint (integer sound)
 Gets the loop point of a sound index, if it has one.
void SetLoopPoint (integer sound, integer loopPoint)
 Sets the loop point of a sound index.

Detailed Description

Sound playback.

Member Function Documentation

◆ AlterChannel()

void Sound.AlterChannel ( integer channel,
decimal panning,
decimal speed,
decimal volume )

Alters the playback conditions of the specified channel.

Parameters
channelThe channel index to resume.
panningControl the panning of the sound. -1.0 makes it sound in left ear only, 1.0 makes it sound in right ear, and closer to 0.0 centers it.
speedControl the speed of the sound. Higher than 1.0 makes it faster, lesser than 1.0 is slower, 1.0 is normal speed.
volumeControls the volume of the sound. 0.0 is muted, 1.0 is normal volume.

◆ GetFreeChannel()

integer Sound.GetFreeChannel ( )

Gets the first channel index that is not currently playing any sound.

Returns
Returns the available channel index, or -1 if no channel was available.

◆ GetLoopPoint()

integer Sound.GetLoopPoint ( integer sound)

Gets the loop point of a sound index, if it has one.

Parameters
soundThe sound index to get the loop point.
Returns
Returns the loop point in samples, as an integer value, or null if the audio does not have one.

◆ IsChannelFree()

void Sound.IsChannelFree ( integer sound)

Checks whether a channel is currently playing any sound.

Parameters
soundThe channel index.

◆ IsPlaying()

boolean Sound.IsPlaying ( integer sound)

Checks whether a sound is currently playing.

Parameters
soundThe sound index.
Returns
Returns a boolean value.

◆ Pause()

void Sound.Pause ( integer sound)

Pauses an actively playing sound.

Parameters
soundThe sound index to pause.

◆ PauseChannel()

void Sound.PauseChannel ( integer channel)

Pauses a channel.

Parameters
channelThe channel index to pause.

◆ Play()

integer Sound.Play ( integer sound,
integer loopPoint,
decimal panning = 0.0,
decimal speed = 1.0,
decimal volume = 1.0 )

Plays a sound either once or in a loop.

Parameters
soundThe sound index to play.
loopPointLoop point in samples. Use AUDIO_LOOP_NONE to play the sound once or AUDIO_LOOP_DEFAULT to use the audio file's metadata. (default: AUDIO_LOOP_DEFAULT )
panningControl the panning of the audio. -1.0 makes it sound in left ear only, 1.0 makes it sound in right ear, and closer to 0.0 centers it.
speedControl the speed of the audio. Higher than 1.0 makes it faster, lesser than 1.0 is slower, 1.0 is normal speed.
volumeControls the volume of the audio. 0.0 is muted, 1.0 is normal volume.
Returns
Returns the channel index where the sound began to play, or -1 if no channel was available.

◆ PlayAtChannel()

void Sound.PlayAtChannel ( integer channel,
integer sound,
integer loopPoint,
decimal panning = 0.0,
decimal speed = 1.0,
decimal volume = 1.0 )

Plays or loops a sound at the specified channel.

Parameters
channelThe channel index.
soundThe sound index to play.
loopPointLoop point in samples. Use AUDIO_LOOP_NONE to play the sound once or AUDIO_LOOP_DEFAULT to use the audio file's metadata. (default: AUDIO_LOOP_DEFAULT)
panningControl the panning of the audio. -1.0 makes it sound in left ear only, 1.0 makes it sound in right ear, and closer to 0.0 centers it.
speedControl the speed of the audio. Higher than 1.0 makes it faster, lesser than 1.0 is slower, 1.0 is normal speed.
volumeControls the volume of the audio. 0.0 is muted, 1.0 is normal volume.

◆ PlayMultiple()

integer Sound.PlayMultiple ( integer sound,
integer loopPoint,
decimal panning = 0.0,
decimal speed = 1.0,
decimal volume = 1.0 )

Plays a sound once or loops it, without interrupting channels playing the same sound.

Parameters
soundThe sound index to play.
loopPointLoop point in samples. Use AUDIO_LOOP_NONE to play the sound once or AUDIO_LOOP_DEFAULT to use the audio file's metadata. (default: AUDIO_LOOP_DEFAULT)
panningControl the panning of the audio. -1.0 makes it sound in left ear only, 1.0 makes it sound in right ear, and closer to 0.0 centers it.
speedControl the speed of the audio. Higher than 1.0 makes it faster, lesser than 1.0 is slower, 1.0 is normal speed.
volumeControls the volume of the audio. 0.0 is muted, 1.0 is normal volume.
Returns
Returns the channel index where the sound began to play, or -1 if no channel was available.

◆ Resume()

void Sound.Resume ( integer sound)

Unpauses a paused sound.

Parameters
soundThe sound index to resume.

◆ ResumeChannel()

void Sound.ResumeChannel ( integer channel)

Unpauses a paused channel.

Parameters
channelThe channel index to resume.

◆ SetLoopPoint()

void Sound.SetLoopPoint ( integer sound,
integer loopPoint )

Sets the loop point of a sound index.

Parameters
soundThe sound index to set the loop point.
loopPointThe loop point in samples, or null to remove the audio's loop point.

◆ Stop()

void Sound.Stop ( integer sound)

Stops an actively playing sound.

Parameters
soundThe sound index to stop.

◆ StopChannel()

void Sound.StopChannel ( integer channel)

Stops a channel.

Parameters
channelThe channel index to stop.