public void ReleasingNode_InvalidatesHandle() { DSPNode node = default; using (var setup = new GraphSetup((graphSetup, graph, block) => { node = graphSetup.CreateDSPNode <NoParameters, NoProviders, LifecycleTracking>(); block.AddOutletPort(node, kChannelCount, kSoundFormat); block.Connect(node, 0, graph.RootDSP, 0); graphSetup.CleanupNodes = false; })) { // Ensure that node is created setup.PumpGraph(); Assert.True(node.Valid); // Release node using (var block = setup.Graph.CreateCommandBlock()) block.ReleaseDSPNode(node); setup.PumpGraph(); // Ensure that node handle is no longer valid Assert.False(node.Valid); } }
public unsafe void InterpolatesEmptyRange() { DSPNode node = default; using (var setup = new GraphSetup((graphSetup, graph, block) => { node = graphSetup.CreateDSPNode <SingleParameterKernel.Parameters, NoProviders, SingleParameterKernel>(); })) { setup.PumpGraph(); long dspClock = 0; float4 value = 10.0f; // Get copy of node with populated fields node = setup.Graph.LookupNode(node.Handle); var nodeParameters = node.Parameters; var parameter = nodeParameters[(int)SingleParameterKernel.Parameters.Parameter]; var newKeyIndex = setup.Graph.AppendKey(parameter.KeyIndex, DSPParameterKey.NullIndex, dspClock, value); for (int sampleOffset = 0; sampleOffset < 10; ++sampleOffset) { Assert.AreEqual(value[0], DSPParameterInterpolator.Generate(sampleOffset, setup.Graph.ParameterKeys.UnsafeDataPointer, newKeyIndex, dspClock, float.MinValue, float.MaxValue, value)[0], 0.001f); } } }
public void DSPClockIncrementsByLength(DSPGraph.ExecutionMode executionMode) { using (var setup = new GraphSetup()) { for (int i = 0; i < 10; ++i) { Assert.AreEqual(i * setup.Graph.DSPBufferSize, setup.Graph.DSPClock); setup.PumpGraph(); } } }
public void AllocatingKernel_Works() { using (var setup = new GraphSetup((graphSetup, graph, block) => { DSPNode node = graphSetup.CreateDSPNode <NoParameters, NoProviders, AllocatingKernel>(); block.AddOutletPort(node, kChannelCount, kSoundFormat); block.Connect(node, 0, graph.RootDSP, 0); })) { setup.PumpGraph(); } }
public void LeakyKernel_EmitsWarning() { using (var setup = new GraphSetup((graphSetup, graph, block) => { DSPNode node = graphSetup.CreateDSPNode <NoParameters, NoProviders, LeakyKernel>(); block.AddOutletPort(node, kChannelCount, kSoundFormat); block.Connect(node, 0, graph.RootDSP, 0); })) { setup.PumpGraph(); LogAssert.Expect(LogType.Warning, "1 leaked DSP node allocations"); } }
public void DSPNode_WithNoInputsOrOutputs_IsNotExecuted(DSPGraph.ExecutionMode executionMode) { DSPNode node = default; using (var setup = new GraphSetup((graphSetup, graph, block) => { node = graphSetup.CreateDSPNode <NoParameters, NoProviders, LifecycleTracking>(); })) { setup.PumpGraph(); Assert.AreEqual(0, LifecycleTracking.Executed); } }
public void LeakyGraph_DoesntCrash() { using (var setup = new GraphSetup((graphSetup, graph, block) => { DSPNode node = graphSetup.CreateDSPNode <NoParameters, NoProviders, LifecycleTracking>(); block.AddOutletPort(node, kChannelCount, kSoundFormat); block.Connect(node, 0, graph.RootDSP, 0); })) { setup.CleanupNodes = false; LogAssert.Expect(LogType.Warning, kNodeLeakMessage); setup.PumpGraph(); } }
public void AllocatingKernelMemory_DuringUpdateJob_Works() { var node = new DSPNode(); using (var setup = new GraphSetup((graphSetup, graph, block) => { node = graphSetup.CreateDSPNode <NoParameters, NoProviders, LifecycleTracking>(); block.AddOutletPort(node, kChannelCount, kSoundFormat); block.Connect(node, 0, graph.RootDSP, 0); })) { using (var block = setup.Graph.CreateCommandBlock()) block.CreateUpdateRequest <AllocatingUpdateJob, NoParameters, NoProviders, LifecycleTracking>(new AllocatingUpdateJob(), node, null); setup.PumpGraph(); } }
public void StateChange_InvokesLifecycleCallbacks() { using (var setup = new GraphSetup((graphSetup, graph, block) => { DSPNode node = graphSetup.CreateDSPNode <NoParameters, NoProviders, LifecycleTracking>(); block.AddOutletPort(node, kChannelCount, kSoundFormat); block.Connect(node, 0, graph.RootDSP, 0); })) { setup.PumpGraph(); Assert.Greater(LifecycleTracking.Initialized, 0); Assert.Greater(LifecycleTracking.Executed, 0); Assert.AreEqual(LifecycleTracking.LifecyclePhase.Executing, LifecycleTracking.Phase); } Assert.AreEqual(LifecycleTracking.LifecyclePhase.Disposed, LifecycleTracking.Phase); }