Example #1
0
        /// <summary>
        /// This API will run the TAudioKernelUpdate on the target DSPNode asynchronously. Also returns
        /// a <typeparamref name="DSPNodeUpdateRequest"/> that can be used to track the progress of
        /// the update.
        /// </summary>
        /// <remarks>
        /// The <typeparamref name="DSPNodeUpdateRequest"/> 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.
        /// </remarks>
        /// <typeparam name="TAudioKernelUpdate">The update kernel type</typeparam>
        /// <typeparam name="TParameters">Enum type of the parameters of the node</typeparam>
        /// <typeparam name="TProviders">Enum type of the sample providers of the node</typeparam>
        /// <typeparam name="TAudioKernel">The kernel type of the node</typeparam>
        /// <param name="updateJob">The structure used to update the running DSP kernel</param>
        /// <param name="node">The node that this update should operate on</param>
        /// <param name="callback">This will be executed on the main thread after the update job has run asynchronously</param>
        /// <returns>A struct that can query status and also retrieve the update structure after it has updated the node</returns>
        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        : unmanaged, Enum
            where TProviders         : unmanaged, Enum
            where TAudioKernel       : struct, IAudioKernel <TParameters, TProviders>
        {
            AssertSameGraphAsNode(node);

            AudioKernelExtensions.GetReflectionData <TAudioKernel, TParameters, TProviders>(out void *nodeReflectionData, out AudioKernelExtensions.ParameterDescriptionData dummy);
            AudioKernelUpdateExtensions.GetReflectionData <TAudioKernelUpdate, TParameters, TProviders, TAudioKernel>(out void *updateJobReflectionData);

            var request = new DSPNodeUpdateRequest <TAudioKernelUpdate, TParameters, TProviders, TAudioKernel>(node);

            m_Graph.RegisterUpdateRequest(request, DSPGraphExtensions.WrapAction(callback, request));

            QueueCommand(new UpdateAudioKernelRequestCommand
            {
                m_Type   = DSPCommandType.UpdateAudioKernelRequest,
                m_Graph  = m_Graph,
                m_Handle = m_Handle,
                m_Node   = node.Handle,
                m_UpdateRequestHandle  = request.Handle,
                m_JobStructMemory      = Utility.CopyToPersistentAllocation(ref updateJob),
                m_JobReflectionData    = nodeReflectionData,
                m_UpdateReflectionData = updateJobReflectionData,
            });

            return(request);
        }
Example #2
0
        /// <summary>
        /// Method to create a new <typeparamref name="DSPNode"/> in the graph
        /// </summary>
        /// <remarks>
        /// A kernel of type <typeparamref name="TAudioKernel"/> is created inside the graph.
        /// A handle in the form of <typeparamref name="DSPNode"/> is returned
        /// for controlling the kernel.
        /// The created kernel will be bursted if its implementation is decorated with BurstCompileAttribute
        /// </remarks>
        /// <typeparam name="TParameters">Enum defining the parameters of the node</typeparam>
        /// <typeparam name="TProviders">Enum defining the sample providers of the node</typeparam>
        /// <typeparam name="TAudioKernel">IAudioKernel which is the DSP kernel of the node</typeparam>
        /// <returns>A DSPNode handle </returns>
        public DSPNode CreateDSPNode <TParameters, TProviders, TAudioKernel>()
            where TParameters  : unmanaged, Enum
            where TProviders   : unmanaged, Enum
            where TAudioKernel : struct, IAudioKernel <TParameters, TProviders>
        {
            AudioKernelExtensions.GetReflectionData <TAudioKernel, TParameters, TProviders>(out void *jobReflectionData, out AudioKernelExtensions.ParameterDescriptionData parameterDescriptionData, out AudioKernelExtensions.SampleProviderDescriptionData sampleProviderDescriptionData);
            var kernel = new TAudioKernel();
            var node   = new DSPNode
            {
                Graph  = m_Graph.Handle,
                Handle = m_Graph.AllocateHandle(),
            };

            QueueCommand(new CreateDSPNodeCommand
            {
                m_Type                          = DSPCommandType.CreateDSPNode,
                m_Graph                         = m_Graph,
                m_Handle                        = m_Handle,
                m_JobReflectionData             = jobReflectionData,
                m_ParameterDescriptionData      = parameterDescriptionData,
                m_SampleProviderDescriptionData = sampleProviderDescriptionData,
                m_JobStructMemory               = Utility.CopyToPersistentAllocation(ref kernel),
                m_KernelAlignment               = UnsafeUtility.AlignOf <TAudioKernel>(),
                m_KernelSize                    = UnsafeUtility.SizeOf <TAudioKernel>(),
                m_NodeHandle                    = node.Handle,
            });

            return(node);
        }
Example #3
0
        internal void SetSampleProvider <TParameters, TProviders, TAudioKernel>(
            uint providerId, DSPNode node, TProviders item, int index = 0, bool destroyOnRemove = false)
            where TParameters  : unmanaged, Enum
            where TProviders   : unmanaged, Enum
            where TAudioKernel : struct, IAudioKernel <TParameters, TProviders>
        {
            AssertSameGraphAsNode(node);

            AudioKernelExtensions.GetReflectionData <TAudioKernel, TParameters, TProviders>(out AudioKernelExtensions.SampleProviderDescriptionData sampleProviderDescriptionData);
            var providerIndex = GetProviderIndex(item, sampleProviderDescriptionData);

            // Index validation for fixed-size array items can be performed here. For variable-array,
            // it can only be performed in the job threads, where the array size is known and stable.
            if (sampleProviderDescriptionData.Descriptions[providerIndex].m_IsArray &&
                sampleProviderDescriptionData.Descriptions[providerIndex].m_Size >= 0 &&
                (sampleProviderDescriptionData.Descriptions[providerIndex].m_Size < index || index < 0))
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }

            QueueCommand(new SetSampleProviderCommand
            {
                m_Type   = DSPCommandType.SetSampleProvider,
                m_Graph  = m_Graph,
                m_Handle = m_Handle,
                m_Node   = node.Handle,
                m_SampleProviderDescriptionData = sampleProviderDescriptionData,
                m_ProviderId      = providerId,
                m_Item            = UnsafeUtility.EnumToInt(item),
                m_Index           = index,
                m_DestroyOnRemove = destroyOnRemove,
            });
        }
Example #4
0
        internal void InsertSampleProvider <TParameters, TProviders, TAudioKernel>(
            uint providerId, DSPNode node, TProviders item, int index = -1, bool destroyOnRemove = false)
            where TParameters  : unmanaged, Enum
            where TProviders   : unmanaged, Enum
            where TAudioKernel : struct, IAudioKernel <TParameters, TProviders>
        {
            AssertSameGraphAsNode(node);

            AudioKernelExtensions.GetReflectionData <TAudioKernel, TParameters, TProviders>(out AudioKernelExtensions.SampleProviderDescriptionData sampleProviderDescriptionData);
            var providerIndex = GetProviderIndex(item, sampleProviderDescriptionData);

            // Can only insert into variable-size arrays.
            if (!sampleProviderDescriptionData.Descriptions[providerIndex].m_IsArray ||
                sampleProviderDescriptionData.Descriptions[providerIndex].m_Size >= 0)
            {
                throw new InvalidOperationException("Can only insert into variable-size array.");
            }

            QueueCommand(new InsertSampleProviderCommand
            {
                m_Type   = DSPCommandType.InsertSampleProvider,
                m_Graph  = m_Graph,
                m_Handle = m_Handle,
                m_Node   = node.Handle,
                m_SampleProviderDescriptionData = sampleProviderDescriptionData,
                m_ProviderId      = providerId,
                m_Item            = UnsafeUtility.EnumToInt(item),
                m_Index           = index,
                m_DestroyOnRemove = destroyOnRemove,
            });
        }
Example #5
0
        /// <summary>
        /// Removes <typeparamref name="AudioSampleProvider"/> from the specified <typeparamref name="DSPNode"/>. If index is not passed or is -1 then it is removed from the last.
        /// </summary>
        /// <param name="node">The node to remove the <typeparamref name="AudioSampleProvider"/> from</param>
        /// <param name="item">The sample provider 'slot' that should have the sample provider removed from</param>
        /// <param name="index">The index into the array that the provider should be removed from. This is if the sample provider slot is an array.</param>
        /// <typeparam name="TParameters">Enum type of the parameters of the node</typeparam>
        /// <typeparam name="TProviders">Enum type of the sample providers of the node</typeparam>
        /// <typeparam name="TAudioKernel">The kernel type of the node</typeparam>
        /// <exception cref="ArgumentException">Unknown SampleProvider</exception>
        /// <exception cref="InvalidOperationException">Can only remove from variable-size array</exception>
        public void RemoveSampleProvider <TParameters, TProviders, TAudioKernel>(DSPNode node, TProviders item, int index = -1)
            where TParameters  : unmanaged, Enum
            where TProviders   : unmanaged, Enum
            where TAudioKernel : struct, IAudioKernel <TParameters, TProviders>
        {
            AssertSameGraphAsNode(node);

            AudioKernelExtensions.GetReflectionData <TAudioKernel, TParameters, TProviders>(out AudioKernelExtensions.SampleProviderDescriptionData sampleProviderDescriptionData);
            var itemIndex = UnsafeUtility.EnumToInt(item);

            // Can only remove from variable-size arrays.
            if (!sampleProviderDescriptionData.Descriptions[itemIndex].m_IsArray ||
                sampleProviderDescriptionData.Descriptions[itemIndex].m_Size >= 0)
            {
                throw new InvalidOperationException("Can only remove sample providers from variable-size array");
            }

            QueueCommand(new RemoveSampleProviderCommand
            {
                m_Type   = DSPCommandType.RemoveSampleProvider,
                m_Graph  = m_Graph,
                m_Handle = m_Handle,
                m_Node   = node.Handle,
                m_SampleProviderDescriptionData = sampleProviderDescriptionData,
                m_Item  = UnsafeUtility.EnumToInt(item),
                m_Index = index,
            });
        }
Example #6
0
        /// <summary>
        /// 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.
        /// </summary>
        /// <remarks>
        /// The provider can be null to clear an existing entry.
        /// </remarks>
        /// <param name="video">The provider to be set on the specified <typeparamref name="DSPNode"/></param>
        /// <param name="node">The node to set the audio sample provider on</param>
        /// <param name="item">The sample provider 'slot' that the given provider should be assigned to</param>
        /// <param name="index">The index into the array that the provider should be set. This is if the sample provider slot is an array.</param>
        /// <param name="trackIndex"></param>
        /// <typeparam name="TParameters">Enum type of the parameters of the node</typeparam>
        /// <typeparam name="TProviders">Enum type of the sample providers of the node</typeparam>
        /// <typeparam name="TAudioKernel">The kernel type of the node</typeparam>
        /// <exception cref="IndexOutOfRangeException">If the passed index into the sample provider slot is invalid</exception>
        public void SetSampleProvider <TParameters, TProviders, TAudioKernel>(
            VideoPlayer video, DSPNode node, TProviders item, int index = 0, int trackIndex = 0)
            where TParameters  : unmanaged, Enum
            where TProviders   : unmanaged, Enum
            where TAudioKernel : struct, IAudioKernel <TParameters, TProviders>
        {
            uint sampleProviderId = (video == null) ? 0 : video.InternalGetAudioSampleProviderId((ushort)trackIndex);

            SetSampleProvider <TParameters, TProviders, TAudioKernel>(sampleProviderId, node, item, index);
        }
Example #7
0
 internal void ClearDSPNode(DSPNode node)
 {
     AssertSameGraphAsNode(node);
     QueueCommand(new ClearDSPNodeCommand
     {
         m_Type   = DSPCommandType.ClearDSPNode,
         m_Graph  = m_Graph,
         m_Handle = m_Handle,
         m_Node   = node,
     });
 }
Example #8
0
 /// <summary>
 /// Asynchronously releases the DSPNode and automatically disconnects all inputs and outputs.
 /// </summary>
 /// <remarks>
 /// It also releases all the resources allocation through the resource context.
 /// </remarks>
 /// <param name="node">The node to release</param>
 public void ReleaseDSPNode(DSPNode node)
 {
     AssertSameGraphAsNode(node);
     QueueCommand(new ReleaseDSPNodeCommand
     {
         m_Type       = DSPCommandType.ReleaseDSPNode,
         m_Graph      = m_Graph,
         m_Handle     = m_Handle,
         m_NodeHandle = node.Handle,
     });
 }
Example #9
0
        /// <summary>
        /// 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.
        /// </summary>
        /// <remarks>
        /// The provider can be null to clear an existing entry.
        /// </remarks>
        /// <param name="clip">The provider to be set on the specified <typeparamref name="DSPNode"/></param>
        /// <param name="node">The node to set the audio sample provider on</param>
        /// <param name="item">The sample provider 'slot' that the given provider should be assigned to</param>
        /// <param name="index">The index into the array that the provider should be set. This is if the sample provider slot is an array.</param>
        /// <param name="startSampleFrameIndex"></param>
        /// <param name="endSampleFrameIndex"></param>
        /// <param name="loop"></param>
        /// <param name="enableSilencePadding"></param>
        /// <typeparam name="TParameters">Enum type of the parameters of the node</typeparam>
        /// <typeparam name="TProviders">Enum type of the sample providers of the node</typeparam>
        /// <typeparam name="TAudioKernel">The kernel type of the node</typeparam>
        /// <exception cref="IndexOutOfRangeException">If the passed index into the sample provider slot is invalid</exception>
        public void SetSampleProvider <TParameters, TProviders, TAudioKernel>(
            AudioClip clip, DSPNode node, TProviders item, int index = 0,
            long startSampleFrameIndex = 0, long endSampleFrameIndex = 0, bool loop = false, bool enableSilencePadding = false)
            where TParameters  : unmanaged, Enum
            where TProviders   : unmanaged, Enum
            where TAudioKernel : struct, IAudioKernel <TParameters, TProviders>
        {
            uint sampleProviderId = (clip == null) ? 0 : clip.Internal_CreateAudioClipSampleProvider((ulong)startSampleFrameIndex, endSampleFrameIndex, loop, enableSilencePadding);

            SetSampleProvider <TParameters, TProviders, TAudioKernel>(sampleProviderId, node, item, index, true);
        }
Example #10
0
 /// <summary>
 /// Adds an outlet port to the node
 /// </summary>
 /// <remarks>
 /// Ports are where signal flow comes into and out of the DSP kernel
 /// </remarks>
 /// <param name="node">DSPNode specifying the node on which the outlet is added</param>
 /// <param name="portIndex">Int specifying port index</param>
 public void RemoveOutletPort(DSPNode node, int portIndex)
 {
     AssertSameGraphAsNode(node);
     QueueCommand(new RemoveOutletPortCommand
     {
         m_Type      = DSPCommandType.RemoveOutletPort,
         m_Graph     = m_Graph,
         m_Handle    = m_Handle,
         m_Node      = node.Handle,
         m_PortIndex = portIndex,
     });
 }
Example #11
0
 /// <summary>
 /// Inserts a sample provider to the list
 /// </summary>
 /// <param name="video">The provider to be inserted on the specified <typeparamref name="DSPNode"/></param>
 /// <param name="node">The node to set the audio sample provider on</param>
 /// <param name="item">The sample provider 'slot' that the given provider should be inserted into</param>
 /// <param name="index">The index into the array that the provider should be set. This is if the sample provider slot is an array.</param>
 /// <param name="trackIndex">The index of the audio track from which to create the sample provider</param>
 /// <typeparam name="TParameters">Enum type of the parameters of the node</typeparam>
 /// <typeparam name="TProviders">Enum type of the sample providers of the node</typeparam>
 /// <typeparam name="TAudioKernel">The kernel type of the node</typeparam>
 /// <exception cref="ArgumentNullException">If the passed <typeparamref name="VideoPlayer"/>is null</exception>
 /// <exception cref="InvalidOperationException">If the passed index into the sample provider slot is invalid</exception>
 public void InsertSampleProvider <TParameters, TProviders, TAudioKernel>(
     VideoPlayer video, DSPNode node, TProviders item, int index = -1, int trackIndex = 0)
     where TParameters   : unmanaged, Enum
     where TProviders    : unmanaged, Enum
     where TAudioKernel : struct, IAudioKernel <TParameters, TProviders>
 {
     if (video == null)
     {
         throw new ArgumentNullException(nameof(video));
     }
     InsertSampleProvider <TParameters, TProviders, TAudioKernel>(video.InternalGetAudioSampleProviderId((ushort)trackIndex),
                                                                  node, item, index);
 }
Example #12
0
 /// <summary>
 /// Adds an outlet port to the node
 /// </summary>
 /// <remarks>
 /// Ports are where signal flow comes into and out of the DSP kernel
 /// </remarks>
 /// <param name="node">DSPNode specifying the node on which the outlet is added</param>
 /// <param name="channelCount">Int specifying the number of channels in the port</param>
 /// <param name="format">SoundFormat specifying the speaker support</param>
 public void AddOutletPort(DSPNode node, int channelCount, SoundFormat format)
 {
     AssertSameGraphAsNode(node);
     QueueCommand(new AddOutletPortCommand
     {
         m_Type         = DSPCommandType.AddOutletPort,
         m_Graph        = m_Graph,
         m_Handle       = m_Handle,
         m_Node         = node.Handle,
         m_ChannelCount = channelCount,
         m_Format       = (int)format,
     });
 }
Example #13
0
 /// <summary>
 /// Inserts a sample provider to the list
 /// </summary>
 /// <param name="clip">The provider to be inserted on the specified <typeparamref name="DSPNode"/></param>
 /// <param name="node">The node to set the audio sample provider on</param>
 /// <param name="item">The sample provider 'slot' that the given provider should be inserted into</param>
 /// <param name="index">The index into the array that the provider should be set. This is if the sample provider slot is an array.</param>
 /// <param name="startSampleFrameIndex">The first frame of the audio clip to be used in the sample provider</param>
 /// <param name="endSampleFrameIndex">The last frame of the audio clip to be used in the sample provider</param>
 /// <param name="loop">Whether the clip should be looped</param>
 /// <param name="enableSilencePadding">Whether the provider should emit silence after clip playback ends</param>
 /// <typeparam name="TParameters">Enum type of the parameters of the node</typeparam>
 /// <typeparam name="TProviders">Enum type of the sample providers of the node</typeparam>
 /// <typeparam name="TAudioKernel">The kernel type of the node</typeparam>
 /// <exception cref="ArgumentNullException">If the passed <typeparamref name="AudioClip"/>is null</exception>
 /// <exception cref="InvalidOperationException">If the passed index into the sample provider slot is invalid</exception>
 public void InsertSampleProvider <TParameters, TProviders, TAudioKernel>(
     AudioClip clip, DSPNode node, TProviders item, int index = -1,
     long startSampleFrameIndex = 0, long endSampleFrameIndex = 0, bool loop = false, bool enableSilencePadding = false)
     where TParameters   : unmanaged, Enum
     where TProviders    : unmanaged, Enum
     where TAudioKernel : struct, IAudioKernel <TParameters, TProviders>
 {
     if (clip == null)
     {
         throw new ArgumentNullException(nameof(clip));
     }
     InsertSampleProvider <TParameters, TProviders, TAudioKernel>(clip.Internal_CreateAudioClipSampleProvider((ulong)startSampleFrameIndex, endSampleFrameIndex, loop, enableSilencePadding),
                                                                  node, item, index, true);
 }
Example #14
0
 /// <summary>
 /// Removes connection between two nodes
 /// </summary>
 /// <remarks>
 /// The <typeparamref name="DSPConnection"/> returned during the connection phase
 /// of the given relationship will also become invalid.
 /// </remarks>
 /// <param name="source">The source node for the connection</param>
 /// <param name="outputPort">The index of the source's output port </param>
 /// <param name="destination">The destination node for the connection</param>
 /// <param name="inputPort">The index of the destination's input port</param>
 public void Disconnect(DSPNode source, int outputPort, DSPNode destination, int inputPort)
 {
     AssertSameGraph(source.Graph, "The block and output node passed must be from the same parent DSPGraph");
     AssertSameGraph(destination.Graph, "The block and input node passed must be from the same parent DSPGraph");
     QueueCommand(new DisconnectCommand
     {
         m_Type        = DSPCommandType.Disconnect,
         m_Graph       = m_Graph,
         m_Handle      = m_Handle,
         m_Source      = source.Handle,
         m_OutputPort  = outputPort,
         m_Destination = destination.Handle,
         m_InputPort   = inputPort,
     });
 }
Example #15
0
        /// <summary>
        /// This API will sustain the previous parameter value until the dspclock time is reached
        /// </summary>
        /// <typeparam name="TParameters">Enum type of the parameters of the node</typeparam>
        /// <typeparam name="TProviders">Enum type of the sample providers of the node</typeparam>
        /// <typeparam name="TAudioKernel">The kernel type of the node</typeparam>
        /// <param name="node">The node that should have its parameter sustained</param>
        /// <param name="parameter">The parameter to sustain</param>
        /// <param name="dspClock">The time in which the parameter should be sustained until</param>
        /// <exception cref="ArgumentException">Throws exception when parameter is unknown</exception>
        public void SustainFloat <TParameters, TProviders, TAudioKernel>(DSPNode node, TParameters parameter, long dspClock)
            where TParameters  : unmanaged, Enum
            where TProviders   : unmanaged, Enum
            where TAudioKernel : struct, IAudioKernel <TParameters, TProviders>
        {
            AssertSameGraphAsNode(node);

            AudioKernelExtensions.GetReflectionData <TAudioKernel, TParameters, TProviders>(out void *jobReflectionData, out AudioKernelExtensions.ParameterDescriptionData parameterDescriptionData);
            QueueCommand(new SustainFloatCommand
            {
                m_Type                     = DSPCommandType.SustainFloat,
                m_Graph                    = m_Graph,
                m_Handle                   = m_Handle,
                m_Node                     = node.Handle,
                m_JobReflectionData        = jobReflectionData,
                m_ParameterDescriptionData = parameterDescriptionData,
                m_Parameter                = (uint)UnsafeUtility.EnumToInt(parameter),
                m_DSPClock                 = (ulong)dspClock,
            });
        }
Example #16
0
        /// <summary>
        /// Sets the value of a parameter on the specified node
        /// </summary>
        /// <param name="node">DSPNode in which the parameter value is set</param>
        /// <param name="parameter">Enum which specifies the parameter</param>
        /// <param name="value">Target value to be set</param>
        /// <param name="interpolationLength">The number of samples to reach the desired value</param>
        /// <typeparam name="TParameters">Enum type of the parameters of the node</typeparam>
        /// <typeparam name="TProviders">Enum type of the sample providers of the node</typeparam>
        /// <typeparam name="TAudioKernel">The kernel type of the node</typeparam>
        /// <exception cref="ArgumentException">Exception thrown when parameter is unknown</exception>
        public void SetFloat <TParameters, TProviders, TAudioKernel>(DSPNode node, TParameters parameter, float value, int interpolationLength = 0)
            where TParameters  : unmanaged, Enum
            where TProviders   : unmanaged, Enum
            where TAudioKernel : struct, IAudioKernel <TParameters, TProviders>
        {
            AssertSameGraphAsNode(node);

            AudioKernelExtensions.GetReflectionData <TAudioKernel, TParameters, TProviders>(out void *jobReflectionData, out AudioKernelExtensions.ParameterDescriptionData parameterDescriptionData);

            QueueCommand(new SetFloatCommand
            {
                m_Type   = DSPCommandType.SetFloat,
                m_Graph  = m_Graph,
                m_Handle = m_Handle,
                m_InterpolationLength = (uint)interpolationLength,
                m_JobReflectionData   = jobReflectionData,
                m_Node      = node.Handle,
                m_Parameter = (uint)UnsafeUtility.EnumToInt(parameter),
                m_ParameterDescriptionData = parameterDescriptionData,
                m_Value = value,
            });
        }
Example #17
0
        /// <summary>
        /// Connects 2 nodes
        /// </summary>
        /// <remarks>
        /// It is also necessary to ensure that the formats of the ports of both source and target are the same.
        /// </remarks>
        /// <param name="source">The source node for the connection</param>
        /// <param name="outputPort">The index of the source's output port </param>
        /// <param name="destination">The destination node for the connection</param>
        /// <param name="inputPort">The index of the destination's input port</param>
        /// <returns>Returns a DSPConnection object</returns>
        public DSPConnection Connect(DSPNode source, int outputPort, DSPNode destination, int inputPort)
        {
            AssertSameGraph(source.Graph, "The block and output node passed must be from the same parent DSPGraph");
            AssertSameGraph(destination.Graph, "The block and input node passed must be from the same parent DSPGraph");

            var connection = new DSPConnection
            {
                Graph  = m_Graph.Handle,
                Handle = m_Graph.AllocateHandle(),
            };

            QueueCommand(new ConnectCommand
            {
                m_Type        = DSPCommandType.Connect,
                m_Graph       = m_Graph,
                m_Handle      = m_Handle,
                m_Connection  = connection.Handle,
                m_Source      = source.Handle,
                m_OutputPort  = outputPort,
                m_Destination = destination.Handle,
                m_InputPort   = inputPort,
            });
            return(connection);
        }
Example #18
0
        /// <summary>
        /// This API will run the <see cref="TAudioKernelUpdate"/> on the target DSPNode asynchronously.
        /// </summary>
        /// <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.
        /// </remarks>
        /// <typeparam name="TAudioKernelUpdate">The update kernel type</typeparam>
        /// <typeparam name="TParameters">Enum type of the parameters of the node</typeparam>
        /// <typeparam name="TProviders">Enum type of the sample providers of the node</typeparam>
        /// <typeparam name="TAudioKernel">The kernel type of the node</typeparam>
        /// <param name="updateJob">The structure used to update the running DSP kernel</param>
        /// <param name="node">The node that this update should operate on</param>
        public void UpdateAudioKernel <TAudioKernelUpdate, TParameters, TProviders, TAudioKernel>(TAudioKernelUpdate updateJob, DSPNode node)
            where TAudioKernelUpdate : struct, IAudioKernelUpdate <TParameters, TProviders, TAudioKernel>
            where TParameters        : unmanaged, Enum
            where TProviders         : unmanaged, Enum
            where TAudioKernel       : struct, IAudioKernel <TParameters, TProviders>
        {
            AssertSameGraphAsNode(node);

            AudioKernelExtensions.GetReflectionData <TAudioKernel, TParameters, TProviders>(out void *nodeReflectionData, out AudioKernelExtensions.ParameterDescriptionData dummy);
            AudioKernelUpdateExtensions.GetReflectionData <TAudioKernelUpdate, TParameters, TProviders, TAudioKernel>(out void *updateJobReflectionData);

            QueueCommand(new UpdateAudioKernelCommand
            {
                m_Type                 = DSPCommandType.UpdateAudioKernel,
                m_Graph                = m_Graph,
                m_Handle               = m_Handle,
                m_Node                 = node.Handle,
                m_JobReflectionData    = nodeReflectionData,
                m_JobStructMemory      = Utility.CopyToPersistentAllocation(ref updateJob),
                m_UpdateReflectionData = updateJobReflectionData,
            });
        }
Example #19
0
 private void AssertSameGraphAsNode(DSPNode node)
 {
     AssertSameGraph(node.Graph, "The block and node passed must be from the same parent DSPGraph");
 }
Example #20
0
 public DSPNodeUpdateRequest(DSPNode node)
 {
     m_Graph    = node.Graph;
     m_Handle   = DSPGraphExtensions.Lookup(m_Graph).AllocateHandle();
     OwningNode = node.Handle;
 }
 public void InvokeCallback(DSPNode node, void *nodeEventPointer)
 {
     m_Callback.Invoke(node, *(TNodeEvent *)nodeEventPointer);
 }