Ejemplo n.º 1
0
 unsafe public abstract void AccumulateImpl(float *data, int start, int size, int prefBuffSz, FPCMFactoryGenLimit pcmFactory);
Ejemplo n.º 2
0
            unsafe public override void AccumulateImpl(float *data, int start, int size, int prefBuffSz, FPCMFactoryGenLimit pcmFactory)
            {
                FPCM fa = pcmFactory.GetZeroedFPCM(start, size);
                FPCM fb = pcmFactory.GetZeroedFPCM(start, size);

                float [] a = fa.buffer;
                float [] b = fb.buffer;

                fixed(float *pa = a, pb = b)
                {
                    gma.Accumulate(pa, start, size, prefBuffSz, pcmFactory);
                    gmb.Accumulate(pb, start, size, prefBuffSz, pcmFactory);

                    for (int i = start; i < start + size; ++i)
                    {
                        data[i] = pa[i] * pb[i];
                    }
                }
            }
Ejemplo n.º 3
0
            unsafe public override void AccumulateImpl(float *data, int start, int size, int prefBufSz, FPCMFactoryGenLimit pcmFactory)
            {
                // Early release
                if (this.released == true)
                {
                    if (this.releaseLeft > 0)
                    {
                        FPCM    fpcmRl = pcmFactory.GetZeroedFPCM(start, size);
                        float[] fprl   = fpcmRl.buffer;

                        fixed(float *pfprl = fprl)
                        {
                            // We could probably optimize this by only calling AccumulateImpl_NonReleasePart()
                            // when we're not in sustain yet.
                            this.AccumulateImpl_NonReleasePart(pfprl, start, size, prefBufSz, pcmFactory);

                            float total   = this.releaseTotal;
                            float left    = this.releaseLeft;
                            int   sampsCt = Mathf.Min(this.releaseLeft, size);

                            for (int ei = start; ei < start + sampsCt; ++ei)
                            {
                                data[ei] = pfprl[ei] * (left / total);
                                left    -= 1.0f;
                            }
                            this.releaseLeft -= sampsCt;
                            return;
                        }
                    }
                    else if (this.saftey > 0)
                    {
                        this.saftey -= size;
                    }
                }
                else
                {
                    this.AccumulateImpl_NonReleasePart(data, start, size, prefBufSz, pcmFactory);
                }
            }
Ejemplo n.º 4
0
            unsafe public void AccumulateImpl_NonReleasePart(float *data, int start, int size, int prefBufSz, FPCMFactoryGenLimit pcmFactory)
            {
                if (this.offset > 0)
                {
                    int ofrm = Mathf.Min(this.offset, size);
                    this.offset -= ofrm;
                    start       += ofrm;
                    size        -= ofrm;

                    if (size <= 0)
                    {
                        return;
                    }
                }

                // ATTACK
                if (this.attackIt < this.attackTotal)
                {
                    int   atrm    = Mathf.Min(this.attackTotal - this.attackIt, size);
                    int   end     = start + atrm;
                    float totalAt = this.attackTotal;
                    float at      = this.attackIt;
                    for (int i = start; i < end; ++i)
                    {
                        data[i] = (at / totalAt);
                        at     += 1.0f;
                    }

                    this.attackIt += atrm;

                    size  -= atrm;
                    start += atrm;
                    if (size <= 0)
                    {
                        return;
                    }
                }

                // DECAY
                if (this.decayLeft > 0)
                {
                    int   dcrm    = Mathf.Min(this.decayLeft, size);
                    int   dcend   = start + dcrm;
                    float totalDc = this.decayTotal;
                    float cd      = this.decayLeft;
                    float susDiff = 1.0f - this.sustain;
                    for (int i = start; i < dcend; ++i)
                    {
                        data[i] = (this.sustain + (cd / totalDc) * susDiff);
                        cd     -= 1.0f;
                    }

                    this.decayLeft -= dcrm;

                    size  -= dcrm;
                    start += dcrm;
                    if (size <= 0)
                    {
                        return;
                    }
                }

                // If we're still here, all that's left is sustain
                for (int i = start; i < start + size; ++i)
                {
                    data[i] = this.sustain;
                }
            }
Ejemplo n.º 5
0
            unsafe public override void AccumulateImpl(float *data, int start, int size, int prefBuffSz, FPCMFactoryGenLimit pcmFactory)
            {
                double tIt  = this.CurTime;
                double incr = this.TimePerSample;

                for (int i = start; i < start + size; ++i)
                {
                    data[i] = -1.0f + (float)((tIt * this.Freq) % 1.0) * 2.0f;
                    tIt    += incr;
                }
            }
Ejemplo n.º 6
0
            unsafe public override void AccumulateImpl(float *data, int start, int size, int prefBuffSz, FPCMFactoryGenLimit pcmFactory)
            {
                this.input.Accumulate(data, start, size, prefBuffSz, pcmFactory);

                if (this.clearOnProcessing == true)
                {
                    this.meter.min = 0.0f;
                    this.meter.max = 0.0f;
                }

                int msIdx = 0;

                for (
                    int i = start; i < start + size;
                    i += MeterValue.MeterSkips[msIdx % MeterValue.MeterSkips.Length],
                    ++msIdx)
                {
                    float val = data[i];

                    if (val > this.meter.max)
                    {
                        this.meter.max = val;
                    }
                    else if (val < this.meter.min)
                    {
                        this.meter.min = val;
                    }

                    ++msIdx;
                }
            }