docs.unity3d.com
    Show / Hide Table of Contents

    Struct DSPGraph

    DSPGraph is the low level mixing engine container which provides methods to create DSPNodes and DSPConnections. The DSPNodes and DSPConnections created in a DSPGraph is local to that graph.

    Inherited Members
    ValueType.ToString()
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    Namespace: Unity.Audio
    Syntax
    public struct DSPGraph : IDisposable, IHandle<DSPGraph>

    Properties

    DSPBufferSize

    The DSP buffer size being used for the graph

    Declaration
    public readonly int DSPBufferSize { get; }
    Property Value
    Type Description
    Int32

    DSPClock

    The number of samples that was processed since the DSPGraph was created

    Declaration
    public readonly long DSPClock { get; }
    Property Value
    Type Description
    Int64

    The current DSP clock time

    OutputChannelCount

    The number of channels being output by the graph

    Declaration
    public readonly int OutputChannelCount { get; }
    Property Value
    Type Description
    Int32

    OutputFormat

    The sound format being output by the graph

    Declaration
    public readonly SoundFormat OutputFormat { get; }
    Property Value
    Type Description
    SoundFormat

    OutputMixer

    An accessor for mixer thread operations. Throws InvalidOperationException if called from a thread that is not the mixer thread for this graph.

    Declaration
    public readonly DSPGraph.OutputMixerHandle OutputMixer { get; }
    Property Value
    Type Description
    DSPGraph.OutputMixerHandle
    Exceptions
    Type Condition
    InvalidOperationException

    RootDSP

    Method to get the root DSPNode of the DSPGraph its called on.

    Declaration
    public readonly DSPNode RootDSP { get; }
    Property Value
    Type Description
    DSPNode

    A DSPNode object

    SampleRate

    The sample rate being used for the graph

    Declaration
    public readonly int SampleRate { get; }
    Property Value
    Type Description
    Int32

    Valid

    Whether this graph is valid

    Declaration
    public readonly bool Valid { get; }
    Property Value
    Type Description
    Boolean

    Methods

    AddNodeEventHandler<TNodeEvent>(Action<DSPNode, TNodeEvent>)

    Adds an event handler to the DSPNode in DSPGraph. This callback is invoked asynchronously on the main thread after the DSPNode posts a matching event.

    Declaration
    public int AddNodeEventHandler<TNodeEvent>(Action<DSPNode, TNodeEvent> handler)
        where TNodeEvent : struct
    Parameters
    Type Name Description
    Action<DSPNode, TNodeEvent> handler
    Returns
    Type Description
    Int32

    An event handler ID

    Type Parameters
    Name Description
    TNodeEvent

    BeginMix(Int32, DSPGraph.ExecutionMode)

    This method is called before reading the samples from the mix

    Declaration
    public void BeginMix(int frameCount, DSPGraph.ExecutionMode executionMode = DSPGraph.ExecutionMode.Jobified)
    Parameters
    Type Name Description
    Int32 frameCount

    The number of frames to mix

    DSPGraph.ExecutionMode executionMode

    The execution mode to be used for audio kernels

    Remarks

    This method will be bursted if the owning IAudioOutputJob is decorated with BurstCompileAttribute

    Create(SoundFormat, Int32, Int32, Int32)

    Create and return a DSPGraph container

    Declaration
    public static DSPGraph Create(SoundFormat outputFormat, int outputChannels, int dspBufferSize, int sampleRate)
    Parameters
    Type Name Description
    SoundFormat outputFormat

    SoundFormat of type Enum whose values are: Raw, Mono, Stereo, Quad, Surround, FiveDot1 or SevenDot1

    Int32 outputChannels

    Specify the number of output channels

    Int32 dspBufferSize

    Specify the buffer size

    Int32 sampleRate

    Specify the sample rate of the graph

    Returns
    Type Description
    DSPGraph

    A DSPGraph object

    CreateCommandBlock()

    Create and return a DSPCommandBlock object that is used to pass commands to the DSPGraph. A command block queues commands which are submitted atomically to the graph once Complete() is called.

    Declaration
    public DSPCommandBlock CreateCommandBlock()
    Returns
    Type Description
    DSPCommandBlock

    A DSPCommandBlock object

    Dispose()

    Method to clean up resources after execution

    Declaration
    public void Dispose()
    Implements
    IDisposable.Dispose()
    Remarks

    This method will be bursted if the owning IAudioOutputJob is decorated with BurstCompileAttribute

    Equals(Object)

    Whether this graph is the same as another instance

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj

    The other instance to compare

    Returns
    Type Description
    Boolean
    Overrides
    ValueType.Equals(Object)

    Equals(DSPGraph)

    Whether this graph is the same as another instance

    Declaration
    public bool Equals(DSPGraph other)
    Parameters
    Type Name Description
    DSPGraph other

    The other instance to compare

    Returns
    Type Description
    Boolean

    GetHashCode()

    Returns a unique hash for this graph

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32
    Overrides
    ValueType.GetHashCode()

    ReadMix(NativeArray<Single>, Int32, Int32)

    Read the samples from the mix. Always call after BeginMix.

    Declaration
    public void ReadMix(NativeArray<float> buffer, int frameCount, int channelCount)
    Parameters
    Type Name Description
    NativeArray<Single> buffer

    A Float array of the samples

    Int32 frameCount

    The number of frames to read

    Int32 channelCount

    The number of channels to read

    Remarks

    This method will be bursted if the owning IAudioOutputJob is decorated with BurstCompileAttribute

    RemoveNodeEventHandler(Int32)

    Remove the event handler on the DSPNode to stop receiving updates.

    Declaration
    public bool RemoveNodeEventHandler(int handlerId)
    Parameters
    Type Name Description
    Int32 handlerId

    Handler ID that needs to be removed

    Returns
    Type Description
    Boolean

    True if the handle exists and was removed else False

    Update()

    Called every frame as part of MonoBehavior.Update

    Declaration
    public void Update()
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023