AudioServer

package
v0.0.0-...-59761c8 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package AudioServer provides methods for working with AudioServer object instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBus

func AddBus()

Adds a bus at [param at_position].

func AddBusEffect

func AddBusEffect(bus_idx int, effect [1]gdclass.AudioEffect)

Adds an [AudioEffect] effect to the bus [param bus_idx] at [param at_position].

func Advanced

func Advanced() class

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

func BusCount

func BusCount() int

func GenerateBusLayout

func GenerateBusLayout() [1]gdclass.AudioBusLayout

Generates an [AudioBusLayout] using the available buses and effects.

func GetBusChannels

func GetBusChannels(bus_idx int) int

Returns the number of channels of the bus at index [param bus_idx].

func GetBusEffect

func GetBusEffect(bus_idx int, effect_idx int) [1]gdclass.AudioEffect

Returns the [AudioEffect] at position [param effect_idx] in bus [param bus_idx].

func GetBusEffectCount

func GetBusEffectCount(bus_idx int) int

Returns the number of effects on the bus at [param bus_idx].

func GetBusEffectInstance

func GetBusEffectInstance(bus_idx int, effect_idx int) [1]gdclass.AudioEffectInstance

Returns the [AudioEffectInstance] assigned to the given bus and effect indices (and optionally channel).

func GetBusIndex

func GetBusIndex(bus_name string) int

Returns the index of the bus with the name [param bus_name]. Returns [code]-1[/code] if no bus with the specified name exist.

func GetBusName

func GetBusName(bus_idx int) string

Returns the name of the bus with the index [param bus_idx].

func GetBusPeakVolumeLeftDb

func GetBusPeakVolumeLeftDb(bus_idx int, channel int) Float.X

Returns the peak volume of the left speaker at bus index [param bus_idx] and channel index [param channel].

func GetBusPeakVolumeRightDb

func GetBusPeakVolumeRightDb(bus_idx int, channel int) Float.X

Returns the peak volume of the right speaker at bus index [param bus_idx] and channel index [param channel].

func GetBusSend

func GetBusSend(bus_idx int) string

Returns the name of the bus that the bus at index [param bus_idx] sends to.

func GetBusVolumeDb

func GetBusVolumeDb(bus_idx int) Float.X

Returns the volume of the bus at index [param bus_idx] in dB.

func GetBusVolumeLinear

func GetBusVolumeLinear(bus_idx int) Float.X

Returns the volume of the bus at index [param bus_idx] as a linear value. [b]Note:[/b] The returned value is equivalent to the result of [method @GlobalScope.db_to_linear] on the result of [method get_bus_volume_db].

func GetDriverName

func GetDriverName() string

Returns the name of the current audio driver. The default usually depends on the operating system, but may be overridden via the [code]--audio-driver[/code] [url=$DOCS_URL/tutorials/editor/command_line_tutorial.html]command line argument[/url]. [code]--headless[/code] also automatically sets the audio driver to [code]Dummy[/code]. See also [member ProjectSettings.audio/driver/driver].

func GetInputDeviceList

func GetInputDeviceList() []string

Returns the names of all audio input devices detected on the system. [b]Note:[/b] [member ProjectSettings.audio/driver/enable_input] must be [code]true[/code] for audio input to work. See also that setting's description for caveats related to permissions and operating system privacy settings.

func GetInputMixRate

func GetInputMixRate() Float.X

Returns the sample rate at the input of the [AudioServer].

func GetMixRate

func GetMixRate() Float.X

Returns the sample rate at the output of the [AudioServer].

func GetOutputDeviceList

func GetOutputDeviceList() []string

Returns the names of all audio output devices detected on the system.

func GetOutputLatency

func GetOutputLatency() Float.X

Returns the audio driver's effective output latency. This is based on [member ProjectSettings.audio/driver/output_latency], but the exact returned value will differ depending on the operating system and audio driver. [b]Note:[/b] This can be expensive; it is not recommended to call [method get_output_latency] every frame.

func GetSpeakerMode

func GetSpeakerMode() gdclass.AudioServerSpeakerMode

Returns the speaker configuration.

func GetTimeSinceLastMix

func GetTimeSinceLastMix() Float.X

Returns the relative time since the last mix occurred.

func GetTimeToNextMix

func GetTimeToNextMix() Float.X

Returns the relative time until the next mix occurs.

func InputDevice

func InputDevice() string

func IsBusBypassingEffects

func IsBusBypassingEffects(bus_idx int) bool

If [code]true[/code], the bus at index [param bus_idx] is bypassing effects.

func IsBusEffectEnabled

func IsBusEffectEnabled(bus_idx int, effect_idx int) bool

If [code]true[/code], the effect at index [param effect_idx] on the bus at index [param bus_idx] is enabled.

func IsBusMute

func IsBusMute(bus_idx int) bool

If [code]true[/code], the bus at index [param bus_idx] is muted.

func IsBusSolo

func IsBusSolo(bus_idx int) bool

If [code]true[/code], the bus at index [param bus_idx] is in solo mode.

func IsStreamRegisteredAsSample

func IsStreamRegisteredAsSample(stream [1]gdclass.AudioStream) bool

If [code]true[/code], the stream is registered as a sample. The engine will not have to register it before playing the sample. If [code]false[/code], the stream will have to be registered before playing it. To prevent lag spikes, register the stream as sample with [method register_stream_as_sample].

func Lock

func Lock()

Locks the audio driver's main loop. [b]Note:[/b] Remember to unlock it afterwards.

func MoveBus

func MoveBus(index int, to_index int)

Moves the bus from index [param index] to index [param to_index].

func OnBusLayoutChanged

func OnBusLayoutChanged(cb func())

func OnBusRenamed

func OnBusRenamed(cb func(bus_index int, old_name string, new_name string))

func OutputDevice

func OutputDevice() string

func PlaybackSpeedScale

func PlaybackSpeedScale() Float.X

func RegisterStreamAsSample

func RegisterStreamAsSample(stream [1]gdclass.AudioStream)

Forces the registration of a stream as a sample. [b]Note:[/b] Lag spikes may occur when calling this method, especially on single-threaded builds. It is suggested to call this method while loading assets, where the lag spike could be masked, instead of registering the sample right before it needs to be played.

func RemoveBus

func RemoveBus(index int)

Removes the bus at index [param index].

func RemoveBusEffect

func RemoveBusEffect(bus_idx int, effect_idx int)

Removes the effect at index [param effect_idx] from the bus at index [param bus_idx].

func SetBusBypassEffects

func SetBusBypassEffects(bus_idx int, enable bool)

If [code]true[/code], the bus at index [param bus_idx] is bypassing effects.

func SetBusCount

func SetBusCount(value int)

func SetBusEffectEnabled

func SetBusEffectEnabled(bus_idx int, effect_idx int, enabled bool)

If [code]true[/code], the effect at index [param effect_idx] on the bus at index [param bus_idx] is enabled.

func SetBusLayout

func SetBusLayout(bus_layout [1]gdclass.AudioBusLayout)

Overwrites the currently used [AudioBusLayout].

func SetBusMute

func SetBusMute(bus_idx int, enable bool)

If [code]true[/code], the bus at index [param bus_idx] is muted.

func SetBusName

func SetBusName(bus_idx int, name string)

Sets the name of the bus at index [param bus_idx] to [param name].

func SetBusSend

func SetBusSend(bus_idx int, send string)

Connects the output of the bus at [param bus_idx] to the bus named [param send].

func SetBusSolo

func SetBusSolo(bus_idx int, enable bool)

If [code]true[/code], the bus at index [param bus_idx] is in solo mode.

func SetBusVolumeDb

func SetBusVolumeDb(bus_idx int, volume_db Float.X)

Sets the volume in decibels of the bus at index [param bus_idx] to [param volume_db].

func SetBusVolumeLinear

func SetBusVolumeLinear(bus_idx int, volume_linear Float.X)

Sets the volume as a linear value of the bus at index [param bus_idx] to [param volume_linear]. [b]Note:[/b] Using this method is equivalent to calling [method set_bus_volume_db] with the result of [method @GlobalScope.linear_to_db] on a value.

func SetEnableTaggingUsedAudioStreams

func SetEnableTaggingUsedAudioStreams(enable bool)

If set to [code]true[/code], all instances of [AudioStreamPlayback] will call [method AudioStreamPlayback._tag_used_streams] every mix step. [b]Note:[/b] This is enabled by default in the editor, as it is used by editor plugins for the audio stream previews.

func SetInputDevice

func SetInputDevice(value string)

func SetOutputDevice

func SetOutputDevice(value string)

func SetPlaybackSpeedScale

func SetPlaybackSpeedScale(value Float.X)

func SwapBusEffects

func SwapBusEffects(bus_idx int, effect_idx int, by_effect_idx int)

Swaps the position of two effects in bus [param bus_idx].

func Unlock

func Unlock()

Unlocks the audio driver's main loop. (After locking it, you should always unlock it.)

Types

type PlaybackType

type PlaybackType = gdclass.AudioServerPlaybackType //gd:AudioServer.PlaybackType
const (
	/*The playback will be considered of the type declared at [member ProjectSettings.audio/general/default_playback_type].*/
	PlaybackTypeDefault PlaybackType = 0
	/*Force the playback to be considered as a stream.*/
	PlaybackTypeStream PlaybackType = 1
	/*Force the playback to be considered as a sample. This can provide lower latency and more stable playback (with less risk of audio crackling), at the cost of having less flexibility.
	  [b]Note:[/b] Only currently supported on the web platform.
	  [b]Note:[/b] [AudioEffect]s are not supported when playback is considered as a sample.*/
	PlaybackTypeSample PlaybackType = 2
	/*Represents the size of the [enum PlaybackType] enum.*/
	PlaybackTypeMax PlaybackType = 3
)

type SpeakerMode

type SpeakerMode = gdclass.AudioServerSpeakerMode //gd:AudioServer.SpeakerMode
const (
	/*Two or fewer speakers were detected.*/
	SpeakerModeStereo SpeakerMode = 0
	/*A 3.1 channel surround setup was detected.*/
	SpeakerSurround31 SpeakerMode = 1
	/*A 5.1 channel surround setup was detected.*/
	SpeakerSurround51 SpeakerMode = 2
	/*A 7.1 channel surround setup was detected.*/
	SpeakerSurround71 SpeakerMode = 3
)

Jump to

Keyboard shortcuts

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