コード例 #1
0
ファイル: Sequencer.cs プロジェクト: simonwittber/fizzle
        public float Sample(float[] jacks, int sample)
        {
            if (sequence == null || lastCode != code || lastType != type)
            {
                Parse();
                ScheduleNoteTriggers(0);
            }
            position++;
            var gateValue = gate.Value(jacks);

            outputTrigger.Value(jacks, -1);
            if (gateValue > 0 && lastGate < 0)
            {
                beatDuration = (sample - lastBeat);
                lastBeat     = sample;
                NextBeat(jacks);
            }
            var hz = activeNote.hz;

            var N          = position * 1f / (beatDuration * activeNote.duration);
            var glideStart = (1f - glide.Value(jacks));

            if (N >= glideStart)
            {
                hz = Mathf.SmoothStep(activeNote.hz, nextNote.hz, Mathf.InverseLerp(glideStart, 1, N));
            }
            lastGate = gateValue;
            output.Value(jacks, hz);
            var e = beatDuration > 0 ? envelope.Evaluate(N) : 1;

            outputEnvelope.Value(jacks, activeNote.volume * e);
            return(activeNote.hz);
        }
コード例 #2
0
        public float Sample(float[] jacks, int t)
        {
            if (input.connectedId == 0)
            {
                output.Value(jacks, 0);
                return(0);
            }

            var bufferLength = buffer.Length;

            var timeTarget = delay.Value(jacks) * Osc.SAMPLERATE;

            time = 0.0001f * timeTarget + 0.9999f * time;
            var samples = (int)time;
            var frac    = time - samples;

            var pastIndex = index - samples;

            while (pastIndex < 0)
            {
                pastIndex = bufferLength + pastIndex;
            }

            var A   = buffer[pastIndex];
            var B   = buffer[(pastIndex + 1) % bufferLength];
            var smp = (B - A) * frac + A;

            var inp = input.Value(jacks);

            buffer[index] = inp + (smp * feedback.Value(jacks));
            index++;
            if (index >= bufferLength)
            {
                index -= bufferLength;
            }


            if (multiply.connectedId != 0)
            {
                smp *= multiply.Value(jacks);
            }
            if (add.connectedId != 0)
            {
                smp += add.Value(jacks);
            }
            smp = bias.Value(jacks) + (smp * gain.Value(jacks));
            output.Value(jacks, smp);
            return(smp);
        }
コード例 #3
0
ファイル: SynthBase.cs プロジェクト: simonwittber/fizzle
        public virtual float Sample(float[] jacks, int t)
        {
            var gateValue = gate.Value(jacks);

            if (gateValue > 0 && lastGate < 0)
            {
                position    = 0;
                sampleIndex = 0;
                OnGate();
            }
            else
            {
                position += (1f / Osc.SAMPLERATE);
                sampleIndex++;
            }
            lastGate = gateValue;
            var smp = GetSample(jacks);

            if (multiply.connectedId != 0)
            {
                smp *= multiply.Value(jacks);
            }
            if (add.connectedId != 0)
            {
                smp += add.Value(jacks);
            }

            smp = bias.Value(jacks) + (smp * gain.Value(jacks));
            output.Value(jacks, smp);
            return(smp);
        }
コード例 #4
0
 public float Sample(float[] jacks, int t)
 {
     if (input.connectedId == 0)
     {
         output.Value(jacks, 0);
         return 0;
     }
     var smp = _Update(jacks, input.Value(jacks));
     if (multiply.connectedId != 0)
         smp *= multiply.Value(jacks);
     if (add.connectedId != 0)
         smp += add.Value(jacks);
     smp = bias.Value(jacks) + (smp * gain.Value(jacks));
     output.Value(jacks, smp);
     return smp;
 }
コード例 #5
0
ファイル: Mixer.cs プロジェクト: simonwittber/fizzle
        public float Sample(float[] jacks, int t)
        {
            var smp = 0f;

            if (inputA.connectedId != 0)
            {
                smp += inputA.Value(jacks) * gainA.Value(jacks);
            }
            if (inputB.connectedId != 0)
            {
                smp += inputB.Value(jacks) * gainB.Value(jacks);
            }
            if (inputC.connectedId != 0)
            {
                smp += inputC.Value(jacks) * gainC.Value(jacks);
            }
            if (inputD.connectedId != 0)
            {
                smp += inputD.Value(jacks) * gainD.Value(jacks);
            }
            if (multiply.connectedId != 0)
            {
                smp *= multiply.Value(jacks);
            }
            if (add.connectedId != 0)
            {
                smp += add.Value(jacks);
            }
            smp = bias.Value(jacks) + (smp * gain.Value(jacks));
            output.Value(jacks, smp);
            return(smp);
        }
コード例 #6
0
ファイル: Osc.cs プロジェクト: simonwittber/fizzle
        public virtual float Sample(float[] jacks, int t)
        {
            if (!isReady)
            {
                return(0);
            }

            var smp = 0f;

            if (superSample)
            {
                var s = (1f / SAMPLERATE) / 8;
                var p = ph;
                for (var i = 0; i < 8; i++)
                {
                    smp += _Sample(jacks, p);
                    p   += s;
                    if (p > TWOPI)
                    {
                        p -= TWOPI;
                    }
                }
                smp /= 8;
            }
            else
            {
                smp = _Sample(jacks, phase);
            }
            if (bandlimited)
            {
                smp = BandLimit(smp);
            }

            if (multiply.connectedId != 0)
            {
                smp *= multiply.Value(jacks);
            }
            if (add.connectedId != 0)
            {
                smp += add.Value(jacks);
            }
            ph    = phase;
            phase = phase + ((TWOPI * (frequency.Value(jacks) + detune.Value(jacks))) / SAMPLERATE);
            if (phase > TWOPI)
            {
                phase -= TWOPI;
            }
            smp = bias.Value(jacks) + (smp * RampedGain(jacks, gain));

            output.Value((jacks), smp);
            return(smp);
        }
コード例 #7
0
ファイル: CrossFader.cs プロジェクト: simonwittber/fizzle
        public float Sample(float[] jacks, int t)
        {
            var smp  = 0f;
            var apos = ramp.Evaluate(position.Value(jacks));
            var fpos = (apos * 8) % 8;
            var ipos = (int)(fpos);
            var frac = fpos - ipos;
            var omf  = 1f - frac;

            if (quant)
            {
                omf  = 1;
                frac = 0;
            }
            output.Value(jacks, inputA.Value(jacks));
            smp += inputA.Value(jacks) * (ipos == 0 ? omf : ipos == 7 ? frac : 0);
            smp += inputB.Value(jacks) * (ipos == 1 ? omf : ipos == 0 ? frac : 0);
            smp += inputC.Value(jacks) * (ipos == 2 ? omf : ipos == 1 ? frac : 0);
            smp += inputD.Value(jacks) * (ipos == 3 ? omf : ipos == 2 ? frac : 0);
            smp += inputE.Value(jacks) * (ipos == 4 ? omf : ipos == 3 ? frac : 0);
            smp += inputF.Value(jacks) * (ipos == 5 ? omf : ipos == 4 ? frac : 0);
            smp += inputG.Value(jacks) * (ipos == 6 ? omf : ipos == 5 ? frac : 0);
            smp += inputH.Value(jacks) * (ipos == 7 ? omf : ipos == 6 ? frac : 0);

            if (multiply.connectedId != 0)
            {
                smp *= multiply.Value(jacks);
            }
            if (add.connectedId != 0)
            {
                smp += add.Value(jacks);
            }

            smp *= gain.Value(jacks);
            output.Value(jacks, smp);
            return(smp);
        }