예제 #1
0
    void AddProviderToNode <TKernel>(DSPCommandBlock block, DSPNode node, int index = -1, float value = kSignalValueA, Providers item = Providers.VariableSizeArray, bool insert = true)
        where TKernel : struct, IAudioKernel <NoParameters, Providers>
    {
        var provider = AudioSampleProvider.Create(kChannelCount, kSampleRate);

        provider.enableSilencePadding = false;
        var inputBuff = new NativeArray <float>(2 * kChannelCount * kDspBufferSize, Allocator.Temp, NativeArrayOptions.UninitializedMemory);

        for (int i = 0; i < inputBuff.Length; ++i)
        {
            inputBuff[i] = value;
        }
        provider.QueueSampleFrames(inputBuff);
        inputBuff.Dispose();
        if (insert)
        {
            block.InsertSampleProvider <NoParameters, Providers, TKernel>(provider.id, node, item, index);
        }
        else
        {
            block.SetSampleProvider <NoParameters, Providers, TKernel>(provider.id, node, item, index);
        }
    }