AudioStreamGenerator
An audio stream with utilities for procedural sound generation.
AudioStreamGenerator.swift:26class AudioStreamGenerator
AudioStreamGenerator
is a type of audio stream that does not play back sounds on its own; instead, it expects a script to generate audio data for it. See also AudioStreamGeneratorPlayback
.
Here’s a sample on how to use it to generate a sine wave:
In the example above, the “AudioStreamPlayer” node must use an AudioStreamGenerator
as its stream. The fill_buffer
function provides audio data for approximating a sine wave.
See also AudioEffectSpectrumAnalyzer
for performing real-time audio spectrum analysis.
Superclasses
class AudioStream
Base class for audio streams.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
var bufferLength: Double
The length of the buffer to generate (in seconds). Lower values result in less latency, but require the script to generate audio data faster, resulting in increased CPU usage and more risk for audio cracking if the CPU can’t keep up.
var mixRate: Double
The sample rate to use (in Hz). Higher values are more demanding for the CPU to generate, but result in better quality.