Documentation
¶
Overview ¶
Plays audio that is attenuated with distance to the listener.
By default, audio is heard from the screen center. This can be changed by adding an AudioListener2D node to the scene and enabling it by calling AudioListener2D.MakeCurrent on it.
See also AudioStreamPlayer to play a sound non-positionally.
Note: Hiding an AudioStreamPlayer2D node does not disable its audio output. To temporarily disable an AudioStreamPlayer2D's audio output, set VolumeDb to a very low value like -100 (which isn't audible to human hearing).
Index ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- type ID
- type Instance
- func (self Instance) AreaMask() int
- func (self Instance) AsAudioStreamPlayer2D() Instance
- func (self Instance) AsCanvasItem() CanvasItem.Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsNode2D() Node2D.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) Attenuation() Float.X
- func (self Instance) Autoplay() bool
- func (self Instance) Bus() string
- func (self Instance) GetPlaybackPosition() Float.X
- func (self Instance) GetStreamPlayback() AudioStreamPlayback.Instance
- func (self Instance) HasStreamPlayback() bool
- func (self Instance) ID() ID
- func (self Instance) MaxDistance() Float.X
- func (self Instance) MaxPolyphony() int
- func (self Instance) MoreArgs() MoreArgs
- func (self Instance) OnFinished(cb func(), flags ...Signal.Flags)
- func (self Instance) PanningStrength() Float.X
- func (self Instance) PitchScale() Float.X
- func (self Instance) Play()
- func (self Instance) PlaybackType() AudioServer.PlaybackType
- func (self Instance) Playing() bool
- func (self Instance) SeekTo(to_position Float.X)
- func (self Instance) SetAreaMask(value int)
- func (self Instance) SetAttenuation(value Float.X)
- func (self Instance) SetAutoplay(value bool)
- func (self Instance) SetBus(value string)
- func (self Instance) SetMaxDistance(value Float.X)
- func (self Instance) SetMaxPolyphony(value int)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetPanningStrength(value Float.X)
- func (self Instance) SetPitchScale(value Float.X)
- func (self Instance) SetPlaybackType(value AudioServer.PlaybackType)
- func (self Instance) SetPlaying(value bool)
- func (self Instance) SetStream(value AudioStream.Instance)
- func (self Instance) SetStreamPaused(value bool)
- func (self Instance) SetVolumeDb(value Float.X)
- func (self Instance) SetVolumeLinear(value Float.X)
- func (self Instance) Stop()
- func (self Instance) Stream() AudioStream.Instance
- func (self Instance) StreamPaused() bool
- func (self Instance) Virtual(name string) reflect.Value
- func (self Instance) VolumeDb() Float.X
- func (self Instance) VolumeLinear() Float.X
- type MoreArgs
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 Extension ¶
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]) AsAudioStreamPlayer2D ¶
func (*Extension[T]) AsCanvasItem ¶
func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance
type 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.
type Instance ¶
type Instance [1]gdclass.AudioStreamPlayer2D
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 (Instance) AreaMask ¶
Determines which Area2D layers affect the sound for reverb and audio bus effects. Areas can be used to redirect AudioStreams so that they play in a certain audio bus. An example of how you might use this is making a "water" area so that sounds played in the water are redirected through an audio bus to make them sound like they are being played underwater.
func (Instance) AsAudioStreamPlayer2D ¶
func (Instance) AsCanvasItem ¶
func (self Instance) AsCanvasItem() CanvasItem.Instance
func (Instance) Attenuation ¶
The volume is attenuated over distance with this as an exponent.
func (Instance) Bus ¶
Bus on which this audio is playing.
Note: When setting this property, keep in mind that no validation is performed to see if the given name matches an existing bus. This is because audio bus layouts might be loaded after this property is set. If this given name can't be resolved at runtime, it will fall back to "Master".
func (Instance) GetPlaybackPosition ¶
Returns the position in the AudioStream.
func (Instance) GetStreamPlayback ¶
func (self Instance) GetStreamPlayback() AudioStreamPlayback.Instance
Returns the AudioStreamPlayback object associated with this AudioStreamPlayer2D.
func (Instance) HasStreamPlayback ¶
Returns whether the AudioStreamPlayer can return the AudioStreamPlayback object or not.
func (Instance) MaxDistance ¶
Maximum distance from which audio is still hearable.
func (Instance) MaxPolyphony ¶
The maximum number of sounds this node can play at the same time. Playing additional sounds after this value is reached will cut off the oldest sounds.
func (Instance) MoreArgs ¶
MoreArgs enables certain functions to be called with additional 'optional' arguments.
func (Instance) OnFinished ¶
Emitted when the audio stops playing.
func (Instance) PanningStrength ¶
Scales the panning strength for this node by multiplying the base ProjectSettings "audio/general/2d_panning_strength" with this factor. Higher values will pan audio from left to right more dramatically than lower values.
func (Instance) PitchScale ¶
The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate.
func (Instance) Play ¶
func (self Instance) Play()
Queues the audio to play on the next physics frame, from the given position '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) SetAreaMask ¶
SetAreaMask sets the property returned by [GetAreaMask].
func (Instance) SetAttenuation ¶
SetAttenuation sets the property returned by [GetAttenuation].
func (Instance) SetAutoplay ¶
SetAutoplay sets the property returned by [IsAutoplayEnabled].
func (Instance) SetMaxDistance ¶
SetMaxDistance sets the property returned by [GetMaxDistance].
func (Instance) SetMaxPolyphony ¶
SetMaxPolyphony sets the property returned by [GetMaxPolyphony].
func (Instance) SetPanningStrength ¶
SetPanningStrength sets the property returned by [GetPanningStrength].
func (Instance) SetPitchScale ¶
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 ¶
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 ¶
SetStreamPaused sets the property returned by [GetStreamPaused].
func (Instance) SetVolumeDb ¶
SetVolumeDb sets the property returned by [GetVolumeDb].
func (Instance) SetVolumeLinear ¶
SetVolumeLinear sets the property returned by [GetVolumeLinear].
func (Instance) Stream ¶
func (self Instance) Stream() AudioStream.Instance
The AudioStream object to be played.
func (Instance) StreamPaused ¶
If true, the playback is paused. You can resume it by setting StreamPaused to false.
func (Instance) VolumeLinear ¶
Base volume before attenuation, 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 MoreArgs ¶
type MoreArgs [1]gdclass.AudioStreamPlayer2D
MoreArgs is a container for Instance functions with additional 'optional' arguments.