cacophony
    Preparing search index...

    Class Synth

    The base interface for any sound-producing entity, including individual sounds, groups, and playbacks. BaseSound

    Hierarchy

    • RoutableSource
      • Synth

    Implements

    Index
    _filters: BiquadFilterNode[] = []
    _oscillatorOptions: Partial<OscillatorOptions>
    _position: Position
    _routeTarget: Bus | null = null

    Primary route target. null is the canonical master route.

    _sends: Map<Bus, number> = ...

    Additional send target to gain-value mappings.

    _stereoPan: number
    _threeDOptions: ThreeDOptions
    _volume: number
    context: BaseContext
    globalGainNode: GainNode
    panType: PanType = "HRTF"
    playbacks: SynthPlayback[] = []
    soundType: SoundType = "oscillator"
    spatialSmoothingTau: number

    Spatial time constant in seconds; assigning changes current and future voices.

    • get detune(): number

      Returns number

    • set detune(detune: number): void

      Parameters

      • detune: number

      Returns void

    • get frequency(): number

      Returns number

    • set frequency(frequency: number): void

      Parameters

      • frequency: number

      Returns void

    • get oscillatorOptions(): Partial<OscillatorOptions>

      Returns Partial<OscillatorOptions>

    • set oscillatorOptions(options: Partial<OscillatorOptions>): void

      Parameters

      • options: Partial<OscillatorOptions>

      Returns void

    • get stereoPan(): number

      Returns number

    • set stereoPan(value: number): void

      Parameters

      • value: number

      Returns void

    • get type(): OscillatorType

      Returns OscillatorType

    • set type(type: OscillatorType): void

      Parameters

      • type: OscillatorType

      Returns void

    • Called by Bus.drainTo to move this source off the draining bus onto target. The source reroutes its primary route and/or any send that targeted bus.

      Parameters

      Returns void

    • Materialize all declared recipes, then establish this playback's sends.

      Parameters

      • playback: BasePlayback

      Returns void

    • Resolve the node used by future playbacks for their primary output. Sources left on a subsequently destroyed bus fall back to master.

      Returns GainNode

    • Internal

      Validate a broadcast, including every voice, without mutation.

      Parameters

      • options: SpatialOptions

      Returns void

    • Establish every configured send on a newly created playback.

      Parameters

      • playback: BasePlayback

      Returns void

    • Clones the current Synth instance, creating a deep copy with the option to override specific properties. This method allows for the creation of a new, independent Synth instance based on the current one, with the flexibility to modify certain attributes through the overrides parameter. This is particularly useful for creating variations of a synth without affecting the original instance. The cloned instance includes all properties, playback settings, and filters of the original, unless explicitly overridden.

      Parameters

      • overrides: Partial<SynthCloneOverrides> = {}

        An object specifying properties to override in the cloned instance. This can include audio settings like volume, playback rate, and spatial positioning, as well as more complex configurations like 3D audio options and filter adjustments.

      Returns Synth

    • Type Parameters

      • K extends
            | "play"
            | "stop"
            | "pause"
            | "resume"
            | "ended"
            | "volumeChange"
            | "error"
            | "fadeStart"
            | "fadeEnd"
            | "fadeCancel"
            | "frequencyChange"
            | "typeChange"
            | "detuneChange"

      Parameters

      Returns void

    • Type Parameters

      • K extends
            | "play"
            | "stop"
            | "pause"
            | "resume"
            | "ended"
            | "volumeChange"
            | "error"
            | "fadeStart"
            | "fadeEnd"
            | "fadeCancel"
            | "frequencyChange"
            | "typeChange"
            | "detuneChange"

      Parameters

      Returns Promise<void>

    • Parameters

      • value: number
      • duration: number
      • Optionaltype: FadeType

      Returns Promise<void>

    • Remove event listener.

      Type Parameters

      • K extends
            | "play"
            | "stop"
            | "pause"
            | "resume"
            | "ended"
            | "volumeChange"
            | "error"
            | "fadeStart"
            | "fadeEnd"
            | "fadeCancel"
            | "frequencyChange"
            | "typeChange"
            | "detuneChange"

      Parameters

      Returns void

    • Register event listener.

      Type Parameters

      • K extends
            | "play"
            | "stop"
            | "pause"
            | "resume"
            | "ended"
            | "volumeChange"
            | "error"
            | "fadeStart"
            | "fadeEnd"
            | "fadeCancel"
            | "frequencyChange"
            | "typeChange"
            | "detuneChange"

      Parameters

      Returns () => void

      Cleanup function

    • Generates a Playback instance for the synth without starting playback. This allows for pre-configuration of playback properties such as volume and position before the synth is actually played.

      Returns SynthPlayback[]

    • Remove this source's aux send from current and future playbacks without changing its primary route. No-op if no send exists, including when the bus reference is destroyed. Names must still resolve to a registered bus; retain the bus reference to remove a send after destroying a named bus.

      Parameters

      • target: string | Bus

      Returns void

    • Route this source to a bus, or add an independent send when sendGain is provided. options ramps existing sends in place; new sends and future playbacks start at sendGain. Prior automation is canceled and re-anchored. Exponential ramps to zero approach 0.0001, then become exactly silent at the endpoint. Ramps from zero or involving negative gains use linear interpolation.

      Parameters

      Returns void

      RangeError for non-finite gain or negative/non-finite duration.

      TypeError when options is given without sendGain; primary routes do not ramp.