Struct DSPCommandBlock
DSPCommandBlock provides us with a set of Asynchronous APIs which allows us to schedule batches of DSPGraph commands
Inherited Members
Namespace: Unity.Audio
Syntax
public struct DSPCommandBlock : IHandle<DSPCommandBlock>, IDisposable
Properties
Valid
Whether this command block is valid
Declaration
public readonly bool Valid { get; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
AddAttenuationKey(DSPConnection, Int64, Single)
Used to add attenuation value to a DSPConnection
Declaration
public void AddAttenuationKey(DSPConnection connection, long dspClock, float value)
Parameters
Type | Name | Description |
---|---|---|
DSPConnection | connection | DSPConnection to which attenuation is applied |
Int64 | dspClock | Specifies the DSPClock time at which the attenuation value takes effect |
Single | value | Attenuation value to be applied |
AddAttenuationKey(DSPConnection, Int64, Single*, Byte)
Used to add attenuation value to a DSPConnection
Declaration
public void AddAttenuationKey(DSPConnection connection, long dspClock, float *value, byte dimension)
Parameters
Type | Name | Description |
---|---|---|
DSPConnection | connection | DSPConnection to which attenuation is applied |
Int64 | dspClock | Specifies the DSPClock time at which the attenuation value takes effect |
Single* | value | Per-channel attenuation values |
Byte | dimension | The number of values in |
AddAttenuationKey(DSPConnection, Int64, Single, Single)
Used to add attenuation value to a DSPConnection
Declaration
public void AddAttenuationKey(DSPConnection connection, long dspClock, float value1, float value2)
Parameters
Type | Name | Description |
---|---|---|
DSPConnection | connection | DSPConnection to which attenuation is applied |
Int64 | dspClock | Specifies the DSPClock time at which the attenuation value takes effect |
Single | value1 | Attenuation value to be applied to channel 0 |
Single | value2 | Attenuation value to be applied to channel 1 |
AddAttenuationKey(DSPConnection, Int64, Single, Single, Single)
Used to add attenuation value to a DSPConnection
Declaration
public void AddAttenuationKey(DSPConnection connection, long dspClock, float value1, float value2, float value3)
Parameters
Type | Name | Description |
---|---|---|
DSPConnection | connection | DSPConnection to which attenuation is applied |
Int64 | dspClock | Specifies the DSPClock time at which the attenuation value takes effect |
Single | value1 | Attenuation value to be applied to channel 0 |
Single | value2 | Attenuation value to be applied to channel 1 |
Single | value3 | Attenuation value to be applied to channel 2 |
AddAttenuationKey(DSPConnection, Int64, Single, Single, Single, Single)
Used to add attenuation value to a DSPConnection
Declaration
public void AddAttenuationKey(DSPConnection connection, long dspClock, float value1, float value2, float value3, float value4)
Parameters
Type | Name | Description |
---|---|---|
DSPConnection | connection | DSPConnection to which attenuation is applied |
Int64 | dspClock | Specifies the DSPClock time at which the attenuation value takes effect |
Single | value1 | Attenuation value to be applied to channel 0 |
Single | value2 | Attenuation value to be applied to channel 1 |
Single | value3 | Attenuation value to be applied to channel 2 |
Single | value4 | Attenuation value to be applied to channel 3 |
AddFloatKey<TParameters, TProviders, TAudioKernel>(DSPNode, TParameters, Int64, Single)
Add a parameter value at a particular DSP clock time.
Declaration
public void AddFloatKey<TParameters, TProviders, TAudioKernel>(DSPNode node, TParameters parameter, long dspClock, float value)
where TParameters : struct, Enum where TProviders : struct, Enum where TAudioKernel : struct, IAudioKernel<TParameters, TProviders>
Parameters
Type | Name | Description |
---|---|---|
DSPNode | node | The DSPNode to add the parameter key to |
TParameters | parameter | The parameter to set |
Int64 | dspClock | The clock value in the future that this parameter should reach the specified value |
Single | value | The desired value of the parameter at the specified time |
Type Parameters
Name | Description |
---|---|
TParameters | Enum type of the parameters of the node |
TProviders | Enum type of the sample providers of the node |
TAudioKernel | The kernel type of the node |
Remarks
This schedules a value of the specified parameter in the future. Multiple keys can be scheduled as long as they are scheduled monotonically. Use this to schedule parameter automation.
Exceptions
Type | Condition |
---|---|
ArgumentException | Throws exception when parameter is unknown |
AddInletPort(DSPNode, Int32)
Adds an inlet port to the node
Declaration
public void AddInletPort(DSPNode node, int channelCount)
Parameters
Type | Name | Description |
---|---|---|
DSPNode | node | DSPNode specifying the Node on which the inlet is added |
Int32 | channelCount | Int specifying the number of channels |
Remarks
Ports are where signal flow comes into and out of the DSP kernel
AddOutletPort(DSPNode, Int32)
Adds an outlet port to the node
Declaration
public void AddOutletPort(DSPNode node, int channelCount)
Parameters
Type | Name | Description |
---|---|---|
DSPNode | node | DSPNode specifying the node on which the outlet is added |
Int32 | channelCount | Int specifying the number of channels in the port |
Remarks
Ports are where signal flow comes into and out of the DSP kernel
Cancel()
Cancels a DSPCommandBlock and disposes its internal resources
Declaration
public void Cancel()
Complete()
Completes the DSPCommandBlock and sends it for asynchronous atomic handling by the DSPGraph. Once this is called, the DSPCommandBlock is disposed and cannot be used again.
Declaration
public void Complete()
Connect(DSPNode, Int32, DSPNode, Int32)
Connects 2 nodes
Declaration
public DSPConnection Connect(DSPNode source, int outputPort, DSPNode destination, int inputPort)
Parameters
Type | Name | Description |
---|---|---|
DSPNode | source | The source node for the connection |
Int32 | outputPort | The index of the source's output port |
DSPNode | destination | The destination node for the connection |
Int32 | inputPort | The index of the destination's input port |
Returns
Type | Description |
---|---|
DSPConnection | Returns a DSPConnection object |
Remarks
It is also necessary to ensure that the formats of the ports of both source and target are the same.
CreateDSPNode<TParameters, TProviders, TAudioKernel>()
Method to create a new DSPNode in the graph
Declaration
public DSPNode CreateDSPNode<TParameters, TProviders, TAudioKernel>()
where TParameters : struct, Enum where TProviders : struct, Enum where TAudioKernel : struct, IAudioKernel<TParameters, TProviders>
Returns
Type | Description |
---|---|
DSPNode | A DSPNode handle |
Type Parameters
Name | Description |
---|---|
TParameters | Enum defining the parameters of the node |
TProviders | Enum defining the sample providers of the node |
TAudioKernel | IAudioKernel which is the DSP kernel of the node |
Remarks
A kernel is created inside the graph. A handle in the form of DSPNode is returned for controlling the kernel. The created kernel will be bursted if its implementation is decorated with BurstCompileAttribute
CreateUpdateRequest<TAudioKernelUpdate, TParameters, TProviders, TAudioKernel>(TAudioKernelUpdate, DSPNode, Action<DSPNodeUpdateRequest<TAudioKernelUpdate, TParameters, TProviders, TAudioKernel>>)
This API will run the TAudioKernelUpdate on the target DSPNode asynchronously. Also returns a DSPNodeUpdateRequest<TAudioKernelUpdate, TParameters, TProviders, TAudioKernel> that can be used to track the progress of the update.
Declaration
public DSPNodeUpdateRequest<TAudioKernelUpdate, TParameters, TProviders, TAudioKernel> CreateUpdateRequest<TAudioKernelUpdate, TParameters, TProviders, TAudioKernel>(TAudioKernelUpdate updateJob, DSPNode node, Action<DSPNodeUpdateRequest<TAudioKernelUpdate, TParameters, TProviders, TAudioKernel>> callback)
where TAudioKernelUpdate : struct, IAudioKernelUpdate<TParameters, TProviders, TAudioKernel> where TParameters : struct, Enum where TProviders : struct, Enum where TAudioKernel : struct, IAudioKernel<TParameters, TProviders>
Parameters
Type | Name | Description |
---|---|---|
TAudioKernelUpdate | updateJob | The structure used to update the running DSP kernel |
DSPNode | node | The node that this update should operate on |
Action<DSPNodeUpdateRequest<TAudioKernelUpdate, TParameters, TProviders, TAudioKernel>> | callback | This will be executed on the main thread after the update job has run asynchronously |
Returns
Type | Description |
---|---|
DSPNodeUpdateRequest<TAudioKernelUpdate, TParameters, TProviders, TAudioKernel> | A struct that can query status and also retrieve the update structure after it has updated the node |
Type Parameters
Name | Description |
---|---|
TAudioKernelUpdate | The update kernel type |
TParameters | Enum type of the parameters of the node |
TProviders | Enum type of the sample providers of the node |
TAudioKernel | The kernel type of the node |
Remarks
The DSPNodeUpdateRequest<TAudioKernelUpdate, TParameters, TProviders, TAudioKernel> returned allow access to the update structure after it has updated the DSP kernel. This can be used to retrieve information from the DSP kernel and process it on the main thread.
Disconnect(DSPConnection)
Disconnects 2 nodes based on the DSPConnection handle.
Declaration
public void Disconnect(DSPConnection connection)
Parameters
Type | Name | Description |
---|---|---|
DSPConnection | connection | The handle specifying the connection between 2 nodes |
Disconnect(DSPNode, Int32, DSPNode, Int32)
Removes connection between two nodes
Declaration
public void Disconnect(DSPNode source, int outputPort, DSPNode destination, int inputPort)
Parameters
Type | Name | Description |
---|---|---|
DSPNode | source | The source node for the connection |
Int32 | outputPort | The index of the source's output port |
DSPNode | destination | The destination node for the connection |
Int32 | inputPort | The index of the destination's input port |
Remarks
The DSPConnection returned during the connection phase of the given relationship will also become invalid.
Dispose()
Completes a DSPCommandBlock and disposes its internal resources
Declaration
public void Dispose()
Implements
Equals(Object)
Whether this command block 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
Equals(DSPCommandBlock)
Whether this command block is the same as another instance
Declaration
public bool Equals(DSPCommandBlock other)
Parameters
Type | Name | Description |
---|---|---|
DSPCommandBlock | other | The other instance to compare |
Returns
Type | Description |
---|---|
Boolean |
GetHashCode()
Returns a unique hash code for this command block
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
Overrides
InsertSampleProvider<TParameters, TProviders, TAudioKernel>(AudioClip, DSPNode, TProviders, Int32, Int64, Int64, Boolean, Boolean, Boolean)
Inserts a sample provider to the list
Declaration
public void InsertSampleProvider<TParameters, TProviders, TAudioKernel>(AudioClip clip, DSPNode node, TProviders item, int index = -1, long startSampleFrameIndex = 0L, long endSampleFrameIndex = 0L, bool loop = false, bool enableSilencePadding = false, bool loopPointIsStart = false)
where TParameters : struct, Enum where TProviders : struct, Enum where TAudioKernel : struct, IAudioKernel<TParameters, TProviders>
Parameters
Type | Name | Description |
---|---|---|
AudioClip | clip | The provider to be inserted on the specified DSPNode |
DSPNode | node | The node to set the audio sample provider on |
TProviders | item | The sample provider 'slot' that the given provider should be inserted into |
Int32 | index | The index into the array that the provider should be set. This is if the sample provider slot is an array. |
Int64 | startSampleFrameIndex | The first frame of the audio clip to be used in the sample provider |
Int64 | endSampleFrameIndex | The last frame of the audio clip to be used in the sample provider |
Boolean | loop | Whether the clip should be looped |
Boolean | enableSilencePadding | Whether the provider should emit silence after clip playback ends |
Boolean | loopPointIsStart | Whether the provider should loop from the beginning of the clip instead of |
Type Parameters
Name | Description |
---|---|
TParameters | Enum type of the parameters of the node |
TProviders | Enum type of the sample providers of the node |
TAudioKernel | The kernel type of the node |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | If the passed AudioClipis null |
InvalidOperationException | If the passed index into the sample provider slot is invalid |
InsertSampleProvider<TParameters, TProviders, TAudioKernel>(VideoPlayer, DSPNode, TProviders, Int32, Int32)
Inserts a sample provider to the list
Declaration
public void InsertSampleProvider<TParameters, TProviders, TAudioKernel>(VideoPlayer video, DSPNode node, TProviders item, int index = -1, int trackIndex = 0)
where TParameters : struct, Enum where TProviders : struct, Enum where TAudioKernel : struct, IAudioKernel<TParameters, TProviders>
Parameters
Type | Name | Description |
---|---|---|
VideoPlayer | video | The provider to be inserted on the specified DSPNode |
DSPNode | node | The node to set the audio sample provider on |
TProviders | item | The sample provider 'slot' that the given provider should be inserted into |
Int32 | index | The index into the array that the provider should be set. This is if the sample provider slot is an array. |
Int32 | trackIndex | The index of the audio track from which to create the sample provider |
Type Parameters
Name | Description |
---|---|
TParameters | Enum type of the parameters of the node |
TProviders | Enum type of the sample providers of the node |
TAudioKernel | The kernel type of the node |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | If the passed VideoPlayeris null |
InvalidOperationException | If the passed index into the sample provider slot is invalid |
ReleaseDSPNode(DSPNode)
Asynchronously releases the DSPNode and automatically disconnects all inputs and outputs.
Declaration
public void ReleaseDSPNode(DSPNode node)
Parameters
Type | Name | Description |
---|---|---|
DSPNode | node | The node to release |
Remarks
It also releases all the resources allocation through the resource context.
RemoveSampleProvider<TParameters, TProviders, TAudioKernel>(DSPNode, TProviders, Int32)
Removes AudioSampleProvider from the specified DSPNode. If index is not passed or is -1 then it is removed from the last.
Declaration
public void RemoveSampleProvider<TParameters, TProviders, TAudioKernel>(DSPNode node, TProviders item, int index = -1)
where TParameters : struct, Enum where TProviders : struct, Enum where TAudioKernel : struct, IAudioKernel<TParameters, TProviders>
Parameters
Type | Name | Description |
---|---|---|
DSPNode | node | The node to remove the AudioSampleProvider from |
TProviders | item | The sample provider 'slot' that should have the sample provider removed from |
Int32 | index | The index into the array that the provider should be removed from. This is if the sample provider slot is an array. |
Type Parameters
Name | Description |
---|---|
TParameters | Enum type of the parameters of the node |
TProviders | Enum type of the sample providers of the node |
TAudioKernel | The kernel type of the node |
Exceptions
Type | Condition |
---|---|
ArgumentException | Unknown SampleProvider |
InvalidOperationException | Can only remove from variable-size array |
SetAttenuation(DSPConnection, Single*, Byte, Int32)
Sets the attenuation of a connection. Attenuation will be applied when the samples are routed to the next node through the associated connection
Declaration
public void SetAttenuation(DSPConnection connection, float *value, byte dimension, int interpolationLength = 0)
Parameters
Type | Name | Description |
---|---|---|
DSPConnection | connection | DSPConnection on which the attenuation is set |
Single* | value | Per-channel attenuation values |
Byte | dimension | The number of values in |
Int32 | interpolationLength | The interpolation length in samples |
SetAttenuation(DSPConnection, Single, Int32)
Sets the attenuation of a connection. Attenuation will be applied when the samples are routed to the next node through the associated connection
Declaration
public void SetAttenuation(DSPConnection connection, float value, int interpolationLength = 0)
Parameters
Type | Name | Description |
---|---|---|
DSPConnection | connection | DSPConnection on which the attenuation is set |
Single | value | The attenuation to be applied |
Int32 | interpolationLength | The interpolation length in samples |
SetAttenuation(DSPConnection, Single, Single, Int32)
Sets the attenuation of a connection. Attenuation will be applied when the samples are routed to the next node through the associated connection
Declaration
public void SetAttenuation(DSPConnection connection, float value1, float value2, int interpolationLength = 0)
Parameters
Type | Name | Description |
---|---|---|
DSPConnection | connection | DSPConnection on which the attenuation is set |
Single | value1 | Attenuation value to be applied to channel 0 |
Single | value2 | Attenuation value to be applied to channel 1 |
Int32 | interpolationLength | The interpolation length in samples |
SetAttenuation(DSPConnection, Single, Single, Single, Int32)
Sets the attenuation of a connection. Attenuation will be applied when the samples are routed to the next node through the associated connection
Declaration
public void SetAttenuation(DSPConnection connection, float value1, float value2, float value3, int interpolationLength = 0)
Parameters
Type | Name | Description |
---|---|---|
DSPConnection | connection | DSPConnection on which the attenuation is set |
Single | value1 | Attenuation value to be applied to channel 0 |
Single | value2 | Attenuation value to be applied to channel 1 |
Single | value3 | Attenuation value to be applied to channel 2 |
Int32 | interpolationLength | The interpolation length in samples |
SetAttenuation(DSPConnection, Single, Single, Single, Single, Int32)
Sets the attenuation of a connection. Attenuation will be applied when the samples are routed to the next node through the associated connection
Declaration
public void SetAttenuation(DSPConnection connection, float value1, float value2, float value3, float value4, int interpolationLength = 0)
Parameters
Type | Name | Description |
---|---|---|
DSPConnection | connection | DSPConnection on which the attenuation is set |
Single | value1 | Attenuation value to be applied to channel 0 |
Single | value2 | Attenuation value to be applied to channel 1 |
Single | value3 | Attenuation value to be applied to channel 2 |
Single | value4 | Attenuation value to be applied to channel 3 |
Int32 | interpolationLength | The interpolation length in samples |
SetFloat<TParameters, TProviders, TAudioKernel>(DSPNode, TParameters, Single, Int32)
Sets the value of a parameter on the specified node
Declaration
public void SetFloat<TParameters, TProviders, TAudioKernel>(DSPNode node, TParameters parameter, float value, int interpolationLength = 0)
where TParameters : struct, Enum where TProviders : struct, Enum where TAudioKernel : struct, IAudioKernel<TParameters, TProviders>
Parameters
Type | Name | Description |
---|---|---|
DSPNode | node | DSPNode in which the parameter value is set |
TParameters | parameter | Enum which specifies the parameter |
Single | value | Target value to be set |
Int32 | interpolationLength | The number of samples to reach the desired value |
Type Parameters
Name | Description |
---|---|
TParameters | Enum type of the parameters of the node |
TProviders | Enum type of the sample providers of the node |
TAudioKernel | The kernel type of the node |
Exceptions
Type | Condition |
---|---|
ArgumentException | Exception thrown when parameter is unknown |
SetSampleProvider<TParameters, TProviders, TAudioKernel>(AudioClip, DSPNode, TProviders, Int32, Int64, Int64, Boolean, Boolean, Boolean)
Sets the audio sample provider for a node. To clear an existing entry, set the provider to null. If the provider is not an array, then index is ignored.
Declaration
public void SetSampleProvider<TParameters, TProviders, TAudioKernel>(AudioClip clip, DSPNode node, TProviders item, int index = 0, long startSampleFrameIndex = 0L, long endSampleFrameIndex = 0L, bool loop = false, bool enableSilencePadding = false, bool loopPointIsStart = false)
where TParameters : struct, Enum where TProviders : struct, Enum where TAudioKernel : struct, IAudioKernel<TParameters, TProviders>
Parameters
Type | Name | Description |
---|---|---|
AudioClip | clip | The provider to be set on the specified DSPNode |
DSPNode | node | The node to set the audio sample provider on |
TProviders | item | The sample provider 'slot' that the given provider should be assigned to |
Int32 | index | The index into the array that the provider should be set. This is if the sample provider slot is an array. |
Int64 | startSampleFrameIndex | |
Int64 | endSampleFrameIndex | |
Boolean | loop | |
Boolean | enableSilencePadding | |
Boolean | loopPointIsStart | Whether the provider should loop from the beginning of the clip instead of |
Type Parameters
Name | Description |
---|---|
TParameters | Enum type of the parameters of the node |
TProviders | Enum type of the sample providers of the node |
TAudioKernel | The kernel type of the node |
Remarks
The provider can be null to clear an existing entry.
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | If the passed index into the sample provider slot is invalid |
SetSampleProvider<TParameters, TProviders, TAudioKernel>(VideoPlayer, DSPNode, TProviders, Int32, Int32)
Sets the audio sample provider for a node. To clear an existing entry, set the provider to null. If the provider is not an array, then index is ignored.
Declaration
public void SetSampleProvider<TParameters, TProviders, TAudioKernel>(VideoPlayer video, DSPNode node, TProviders item, int index = 0, int trackIndex = 0)
where TParameters : struct, Enum where TProviders : struct, Enum where TAudioKernel : struct, IAudioKernel<TParameters, TProviders>
Parameters
Type | Name | Description |
---|---|---|
VideoPlayer | video | The provider to be set on the specified DSPNode |
DSPNode | node | The node to set the audio sample provider on |
TProviders | item | The sample provider 'slot' that the given provider should be assigned to |
Int32 | index | The index into the array that the provider should be set. This is if the sample provider slot is an array. |
Int32 | trackIndex |
Type Parameters
Name | Description |
---|---|
TParameters | Enum type of the parameters of the node |
TProviders | Enum type of the sample providers of the node |
TAudioKernel | The kernel type of the node |
Remarks
The provider can be null to clear an existing entry.
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | If the passed index into the sample provider slot is invalid |
SustainAttenuation(DSPConnection, Int64)
Retains the same attenuation value till the specified DSPClock time is reached
Declaration
public void SustainAttenuation(DSPConnection connection, long dspClock)
Parameters
Type | Name | Description |
---|---|---|
DSPConnection | connection | The DSPConnection on which the attenuation is retained |
Int64 | dspClock | The DSPClock time upto which attenuation value is kept unchanged |
SustainFloat<TParameters, TProviders, TAudioKernel>(DSPNode, TParameters, Int64)
This API will sustain the previous parameter value until the dspclock time is reached
Declaration
public void SustainFloat<TParameters, TProviders, TAudioKernel>(DSPNode node, TParameters parameter, long dspClock)
where TParameters : struct, Enum where TProviders : struct, Enum where TAudioKernel : struct, IAudioKernel<TParameters, TProviders>
Parameters
Type | Name | Description |
---|---|---|
DSPNode | node | The node that should have its parameter sustained |
TParameters | parameter | The parameter to sustain |
Int64 | dspClock | The time in which the parameter should be sustained until |
Type Parameters
Name | Description |
---|---|
TParameters | Enum type of the parameters of the node |
TProviders | Enum type of the sample providers of the node |
TAudioKernel | The kernel type of the node |
Exceptions
Type | Condition |
---|---|
ArgumentException | Throws exception when parameter is unknown |
UpdateAudioKernel<TAudioKernelUpdate, TParameters, TProviders, TAudioKernel>(TAudioKernelUpdate, DSPNode)
This API will run an update kernel on the target DSPNode asynchronously.
Declaration
public void UpdateAudioKernel<TAudioKernelUpdate, TParameters, TProviders, TAudioKernel>(TAudioKernelUpdate updateJob, DSPNode node)
where TAudioKernelUpdate : struct, IAudioKernelUpdate<TParameters, TProviders, TAudioKernel> where TParameters : struct, Enum where TProviders : struct, Enum where TAudioKernel : struct, IAudioKernel<TParameters, TProviders>
Parameters
Type | Name | Description |
---|---|---|
TAudioKernelUpdate | updateJob | The structure used to update the running DSP kernel |
DSPNode | node | The node that this update should operate on |
Type Parameters
Name | Description |
---|---|
TAudioKernelUpdate | The update kernel type |
TParameters | Enum type of the parameters of the node |
TProviders | Enum type of the sample providers of the node |
TAudioKernel | The kernel type of the node |
Remarks
This version simply applies the update kernel to the specified DSP kernel. The DSP kernel is passed as a ref to the update structure so that it can be modified.