Exemplo n.º 1
0
        void OnAudioFilterRead(float[] data, int channels)
        {
                        #if UNITY_EDITOR
            if (!runEffect)
            {
                return;
            }
            stopwatch.Reset();
            stopwatch.Start();
                        #endif

            float dry;
            float wet;

            for (var i = 0; i < data.Length; i = i + channels)
            {
                for (var c = 0; c < channels; c++)
                {
                    dry         = data[i + c];
                    wet         = dry * carrierLFO.GetValue();
                    data[i + c] = dry * (1 - DryWet) + wet * DryWet;
                }
                carrierLFO.MoveIndex();
            }
                        #if UNITY_EDITOR
            stopwatch.Stop();
            runTime = Mathf.Round((float)stopwatch.Elapsed.TotalMilliseconds * 100) / 100;        // stopwatch.ElapsedMilliseconds;
                        #endif
        }
Exemplo n.º 2
0
        void OnAudioFilterRead(float[] data, int channels)
        {
                        #if UNITY_EDITOR
            if (!runEffect)
            {
                return;
            }
            stopwatch.Reset();
            stopwatch.Start();
                        #endif

            float dry;
            float wet;

            for (var i = 0; i < data.Length; i = i + channels)
            {
                combFilter.Offset = (int)Mathf.Lerp(1 * sampleRate / 1000, 5 * sampleRate / 1000, lfo.GetValue());
                for (var c = 0; c < channels; c++)
                {
                    dry         = data[i + c];
                    wet         = combFilter.ProcessSample(c, dry);
                    output      = dry * (1 - DryWet / 2) + wet * DryWet / 2;
                    data[i + c] = output;
                }
                combFilter.MoveIndex();
                lfo.MoveIndex();
            }
                        #if UNITY_EDITOR
            stopwatch.Stop();
            runTime = Mathf.Round((float)stopwatch.Elapsed.TotalMilliseconds * 100) / 100;        // stopwatch.ElapsedMilliseconds;
                        #endif
        }
Exemplo n.º 3
0
        void OnAudioFilterRead(float[] data, int channels)
        {
                        #if UNITY_EDITOR
            if (!runEffect)
            {
                return;
            }
            stopwatch.Reset();
            stopwatch.Start();
                        #endif

            float dry;
            float wet;

            for (var i = 0; i < data.Length; i = i + channels)
            {
                float newOffset = Mathf.Lerp(Mathf.Lerp(fromMin, fromMax, Width), Mathf.Lerp(toMin, toMax, Width), lfo.GetValue()) * sampleRate / 1000;
                for (var a = 0; a < allPassFilters.Length; a++)
                {
                    allPassFilters[a].Offset = (int)newOffset;
                    for (var c = 0; c < channels; c++)
                    {
                        dry         = data[i + c];
                        wet         = allPassFilters[a].ProcessSample(c, dry);
                        output      = dry * (1 - DryWet / 2) + wet * DryWet / 2;
                        data[i + c] = output;
                    }
                    allPassFilters[a].MoveIndex();
                }
                lfo.MoveIndex();
            }
                        #if UNITY_EDITOR
            stopwatch.Stop();
            runTime = Mathf.Round((float)stopwatch.Elapsed.TotalMilliseconds * 100) / 100;        // stopwatch.ElapsedMilliseconds;
                        #endif
        }