コード例 #1
0
    void OnAudioFilterRead(float[] data, int channels)
    {
        // Asserts channels == 2
        for (var i = 0; i < data.Length; i += 2)
        {
            if (isRunning && seq.Run())
            {
                osc.SetNote(seq.currentNote);
                if (seq.currentTrigger)
                {
                    env.Bang();
                }
            }
            if (isRunning && drumSeq.Run())
            {
                for (var tr = 0; tr < drumSeq.triggers.GetLength(0); tr++)
                {
                    if (drumSeq.GetCurrent(tr))
                    {
                        drums[tr].Bang();
                    }
                }
            }

            var x = amp.Run(lpf.Run(osc.Run()));
            foreach (var sampler in drums)
            {
                x += sampler.Run();
            }
            data[i] = data[i + 1] = x;
            env.Update();
        }
    }