Exemple #1
0
    public Vector4[] Read(AudioContext ac)
    {
        var data = new Vector4[ac.length];

        //float[] beatphase = beatPh.Read(ac.clock.BPM/60.0,ac);
        //float[] oscphase = oscPh.Read((double)freq, ac);



        for (int n = 0; n < data.Length; n += ac.channels)
        {
            //float[] barphase = phase;
            float loopphase = (float)Clock.Phase(ac.clock.BarPosition, 1.0);
            var   phase     = ac.clock.readCache(n);

            float beatphase = (float)Clock.Beat4th(phase);
            float envA      = (float)DSP.Env(0.001f, 0.99f, 1, beatphase, ac);
            float envP      = (float)DSP.Env(0.001f, 0.8f, 6, beatphase, ac);
            var   osc       = oscPh.read(0.5 * ac.baseFreq * envP, ac);
            // float s = Sine(oscPh.read(freq, ac), ac) * amp * sawsq;
            float o = DSP.Sine((float)osc, ac) * envA;

            for (int i = 0; i < ac.channels; i++)
            {
                data[n + i] = new Vector4(o, beatphase, envA, loopphase);
            }
        }
        return(data);
    }