コード例 #1
0
    void SendCommand(OscWave wave, float frequency, float amplitude, float cutoff, float q, float filterAmplitude, float pan)
    {
        DSPCommandBlock commandBlock = m_driver.m_graph.CreateCommandBlock();

        commandBlock.SetFloat <OscParameters, OscProviders, OscillatorNode>(m_oscNode, OscParameters.Wave, (float)wave);
        commandBlock.SetFloat <OscParameters, OscProviders, OscillatorNode>(m_oscNode, OscParameters.Frequency, frequency);
        commandBlock.SetFloat <SVFParameters, SVFProviders, SVFNode>(m_filterNode, SVFParameters.Cutoff, cutoff);
        commandBlock.SetFloat <SVFParameters, SVFProviders, SVFNode>(m_filterNode, SVFParameters.Q, q);
        commandBlock.SetFloat <SVFParameters, SVFProviders, SVFNode>(m_filterNode, SVFParameters.Amplitude, filterAmplitude);
        commandBlock.SetFloat <VCAParameters, VCAProviders, VCANode>(m_vcaNode, VCAParameters.Amplitude, amplitude);
        commandBlock.SetFloat <MonoToStereoParameters, MonoToStereoProviders, MonoToStereoNode>(m_stereoNode, MonoToStereoParameters.Pan, pan);
        commandBlock.Complete();
    }
コード例 #2
0
ファイル: OscillatorNode.cs プロジェクト: sgmackie/AudioToys
    // AudioKernel execution code
    public void Execute(ref ExecuteContext <OscParameters, OscProviders> context)
    {
        // Loop through all the active output contexts
        int outputCount = context.Outputs.Count;

        for (int outIdx = 0; outIdx < outputCount; ++outIdx)
        {
            // Get the context output buffer & format
            SampleBuffer outputBuffer = context.Outputs.GetSampleBuffer(outIdx);
            int          channels     = outputBuffer.Channels;
            int          bufferSize   = outputBuffer.Samples;
            int          sampleRate   = context.SampleRate;

            // Get the actual sample buffer
            NativeArray <float> buffer = outputBuffer.Buffer;

            // Switch on the wave type
            currentWave = (OscWave)context.Parameters.GetFloat(OscParameters.Wave, 0);
            switch (currentWave)
            {
            case OscWave.Sine:
            {
                Sine(ref context.Parameters, ref buffer, bufferSize, sampleRate);
                break;
            }

            case OscWave.Square:
            {
                Square(ref context.Parameters, ref buffer, bufferSize, sampleRate);
                break;
            }

            default:
            {
                Sine(ref context.Parameters, ref buffer, bufferSize, sampleRate);
                break;
            }
            }
        }
    }