AudioStreamPlayer

package
v0.0.0-...-357ca8a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

The AudioStreamPlayer node plays an audio stream non-positionally. It is ideal for user interfaces, menus, or background music.

To use this node, Stream needs to be set to a valid AudioStream resource. Playing more than one sound at the same time is also supported, see MaxPolyphony.

If you need to play audio at a specific position, use AudioStreamPlayer2D or AudioStreamPlayer3D instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsAudioStreamPlayer() Instance
}

type Expanded

type Expanded = MoreArgs

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsAudioStreamPlayer

func (self *Extension[T]) AsAudioStreamPlayer() Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.AudioStreamPlayer

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsAudioStreamPlayer

func (self Instance) AsAudioStreamPlayer() Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) Autoplay

func (self Instance) Autoplay() bool

If true, this node calls Play when entering the tree.

func (Instance) Bus

func (self Instance) Bus() string

The target bus name. All sounds from this node will be playing on this bus.

Note: At runtime, if no bus with the given name exists, all sounds will fall back on "Master". See also AudioServer.GetBusName.

func (Instance) GetPlaybackPosition

func (self Instance) GetPlaybackPosition() Float.X

Returns the position in the AudioStream of the latest sound, in seconds. Returns 0.0 if no sounds are playing.

Note: The position is not always accurate, as the AudioServer does not mix audio every processed frame. To get more accurate results, add AudioServer.GetTimeSinceLastMix to the returned position.

Note: This method always returns 0.0 if the Stream is an AudioStreamInteractive, since it can have multiple clips playing at once.

func (Instance) GetStreamPlayback

func (self Instance) GetStreamPlayback() AudioStreamPlayback.Instance

Returns the latest AudioStreamPlayback of this node, usually the most recently created by Play. If no sounds are playing, this method fails and returns an empty playback.

func (Instance) HasStreamPlayback

func (self Instance) HasStreamPlayback() bool

Returns true if any sound is active, even if StreamPaused is set to true. See also Playing and GetStreamPlayback.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) MaxPolyphony

func (self Instance) MaxPolyphony() int

The maximum number of sounds this node can play at the same time. Calling Play after this value is reached will cut off the oldest sounds.

func (Instance) MixTarget

func (self Instance) MixTarget() MixTarget

The mix target channels. Has no effect when two speakers or less are detected (see [AudioServer.SpeakerMode]).

func (Instance) MoreArgs

func (self Instance) MoreArgs() MoreArgs

MoreArgs enables certain functions to be called with additional 'optional' arguments.

func (Instance) OnFinished

func (self Instance) OnFinished(cb func(), flags ...Signal.Flags)

Emitted when a sound finishes playing without interruptions. This signal is not emitted when calling Stop, or when exiting the tree while sounds are playing.

func (Instance) PitchScale

func (self Instance) PitchScale() Float.X

The audio's pitch and tempo, as a multiplier of the Stream's sample rate. A value of 2.0 doubles the audio's pitch, while a value of 0.5 halves the pitch.

func (Instance) Play

func (self Instance) Play()

Plays a sound from the beginning, or the given 'from_position' in seconds.

func (Instance) PlaybackType

func (self Instance) PlaybackType() AudioServer.PlaybackType

The playback type of the stream player. If set other than to the default value, it will force that playback type.

func (Instance) Playing

func (self Instance) Playing() bool

If true, this node is playing sounds. Setting this property has the same effect as Play and Stop.

func (Instance) SeekTo

func (self Instance) SeekTo(to_position Float.X)

Restarts all sounds to be played from the given 'to_position', in seconds. Does nothing if no sounds are playing.

func (Instance) SetAutoplay

func (self Instance) SetAutoplay(value bool)

SetAutoplay sets the property returned by [IsAutoplayEnabled].

func (Instance) SetBus

func (self Instance) SetBus(value string)

SetBus sets the property returned by [GetBus].

func (Instance) SetMaxPolyphony

func (self Instance) SetMaxPolyphony(value int)

SetMaxPolyphony sets the property returned by [GetMaxPolyphony].

func (Instance) SetMixTarget

func (self Instance) SetMixTarget(value MixTarget)

SetMixTarget sets the property returned by [GetMixTarget].

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetPitchScale

func (self Instance) SetPitchScale(value Float.X)

SetPitchScale sets the property returned by [GetPitchScale].

func (Instance) SetPlaybackType

func (self Instance) SetPlaybackType(value AudioServer.PlaybackType)

SetPlaybackType sets the property returned by [GetPlaybackType].

func (Instance) SetPlaying

func (self Instance) SetPlaying(value bool)

SetPlaying sets the property returned by [IsPlaying].

func (Instance) SetStream

func (self Instance) SetStream(value AudioStream.Instance)

SetStream sets the property returned by [GetStream].

func (Instance) SetStreamPaused

func (self Instance) SetStreamPaused(value bool)

SetStreamPaused sets the property returned by [GetStreamPaused].

func (Instance) SetVolumeDb

func (self Instance) SetVolumeDb(value Float.X)

SetVolumeDb sets the property returned by [GetVolumeDb].

func (Instance) SetVolumeLinear

func (self Instance) SetVolumeLinear(value Float.X)

SetVolumeLinear sets the property returned by [GetVolumeLinear].

func (Instance) Stop

func (self Instance) Stop()

Stops all sounds from this node.

func (Instance) Stream

func (self Instance) Stream() AudioStream.Instance

The AudioStream resource to be played. Setting this property stops all currently playing sounds. If left empty, the AudioStreamPlayer does not work.

func (Instance) StreamPaused

func (self Instance) StreamPaused() bool

If true, the sounds are paused. Setting StreamPaused to false resumes all sounds.

Note: This property is automatically changed when exiting or entering the tree, or this node is paused (see Node.ProcessMode).

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

func (Instance) VolumeDb

func (self Instance) VolumeDb() Float.X

Volume of sound, in decibels. This is an offset of the Stream's volume.

Note: To convert between decibel and linear energy (like most volume sliders do), use VolumeLinear, or @GlobalScope.DbToLinear and @GlobalScope.LinearToDb.

func (Instance) VolumeLinear

func (self Instance) VolumeLinear() Float.X

Volume of sound, as a linear value.

Note: This member modifies VolumeDb for convenience. The returned value is equivalent to the result of @GlobalScope.DbToLinear on VolumeDb. Setting this member is equivalent to setting VolumeDb to the result of @GlobalScope.LinearToDb on a value.

type MixTarget

type MixTarget int //gd:AudioStreamPlayer.MixTarget
const (
	// The audio will be played only on the first channel. This is the default.
	MixTargetStereo MixTarget = 0
	// The audio will be played on all surround channels.
	MixTargetSurround MixTarget = 1
	// The audio will be played on the second channel, which is usually the center.
	MixTargetCenter MixTarget = 2
)

type MoreArgs

type MoreArgs [1]gdclass.AudioStreamPlayer

MoreArgs is a container for Instance functions with additional 'optional' arguments.

func (MoreArgs) Play

func (self MoreArgs) Play(from_position Float.X)

Plays a sound from the beginning, or the given 'from_position' in seconds.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL