Example #1
0
        public ReverbState(ref ReverbParameter parameter, ulong workBuffer, bool isLongSizePreDelaySupported)
        {
            FdnDelayLines  = new DelayLine[4];
            DecayDelays    = new DecayDelay[4];
            EarlyDelayTime = new uint[EarlyModeCount];
            EarlyGain      = new float[EarlyModeCount];
            HighFrequencyDecayDirectGain   = new float[4];
            HighFrequencyDecayPreviousGain = new float[4];
            PreviousFeedbackOutput         = new float[4];

            ReadOnlySpan <float> fdnDelayTimes   = GetFdnDelayTimesByLateMode(ReverbLateMode.Limit);
            ReadOnlySpan <float> decayDelayTimes = GetDecayDelayTimesByLateMode(ReverbLateMode.Limit);

            uint sampleRate = (uint)FixedPointHelper.ToFloat((uint)parameter.SampleRate, FixedPointPrecision);

            for (int i = 0; i < 4; i++)
            {
                FdnDelayLines[i] = new DelayLine(sampleRate, fdnDelayTimes[i]);
                DecayDelays[i]   = new DecayDelay(new DelayLine(sampleRate, decayDelayTimes[i]));
            }

            float preDelayTimeMax = 150.0f;

            if (isLongSizePreDelaySupported)
            {
                preDelayTimeMax = 350.0f;
            }

            PreDelayLine         = new DelayLine(sampleRate, preDelayTimeMax);
            FrontCenterDelayLine = new DelayLine(sampleRate, 5.0f);

            UpdateParameter(ref parameter);
        }
        // Constructor.
        public PRCReverb(float decayTime)
        {
            // Delay length for 44100 Hz sample rate.
            int[] delays = { 341, 613, 1557, 2137 };

            // Scale the delay lengths if necessary.
            if (Config.SampleRate != 44100)
            {
                var scaler = Config.SampleRate / 44100.0f;
                for (var i = 0; i < delays.Length; i++)
                {
                    var delay = (int)(scaler * delays [i]);
                    if ((delay & 1) == 0)
                    {
                        delay++;
                    }
                    while (!Math.IsPrime(delay))
                    {
                        delay += 2;
                    }
                    delays [i] = delay;
                }
            }

            allpassLine1 = new DelayLine(delays [0]);
            allpassLine2 = new DelayLine(delays [1]);
            combLine1    = new DelayLine(delays [2]);
            combLine2    = new DelayLine(delays [3]);

            DecayTime = decayTime;
        }
Example #3
0
    void Awake()
    {
        allpassLines = new DelayLine[6];
        combLines = new DelayLine[6];
        combCoeffs = new float[6];

        int[] delays = {
            1433, 1601, 1867, 2053, 2251, 2399,
            347, 113, 37, 59, 53, 43
        };

        float scaler = AudioSettings.outputSampleRate / 25641.0f;
        for (var i = 0; i < delays.Length; i++) {
            var delay = Mathf.FloorToInt (scaler * delays [i]);
            if ((delay & 1) == 0)
                delay++;
            while (!MathUtil.IsPrime(delay))
                delay += 2;
            delays [i] = delay;
        }

        for (var i = 0; i < 6; i++) {
            combLines [i] = new DelayLine (delays [i]);
        }

        for (var i = 0; i < 6; i++) {
            allpassLines [i] = new DelayLine (delays [i + 6]);
        }

        UpdateParameters ();
    }
        // Constructor.
        public NReverb(float decayTime)
        {
            allpassLines = new DelayLine[6];
            combLines = new DelayLine[6];
            combCoeffs = new float[6];

            int[] delays = {
                1433, 1601, 1867, 2053, 2251, 2399,
                347, 113, 37, 59, 53, 43
            };

            var scaler = Config.SampleRate / 25641.0f;
            for (var i = 0; i < delays.Length; i++) {
                var delay = (int)(scaler * delays [i]);
                if ((delay & 1) == 0)
                    delay++;
                while (!Math.IsPrime(delay))
                    delay += 2;
                delays [i] = delay;
            }

            for (var i = 0; i < 6; i++) {
                combLines [i] = new DelayLine (delays [i], delays [i]);
            }

            for (var i = 0; i < 6; i++) {
                allpassLines [i] = new DelayLine (delays [i + 6], delays [i + 6]);
            }

            DecayTime = decayTime;
        }
Example #5
0
    void Awake()
    {
        // Delay length for 44100 Hz sample rate.
        int[] delays = { 341, 613, 1557, 2137 };

        // Scale the delay lengths if necessary.
        var sampleRate = AudioSettings.outputSampleRate;

        if (sampleRate != 44100)
        {
            var scaler = sampleRate / 44100.0f;
            for (var i = 0; i < delays.Length; i++)
            {
                var delay = Mathf.FloorToInt(scaler * delays [i]);
                if ((delay & 1) == 0)
                {
                    delay++;
                }
                while (!MathUtil.IsPrime(delay))
                {
                    delay += 2;
                }
                delays [i] = delay;
            }
        }

        allpass1 = new DelayLine(delays [0]);
        allpass2 = new DelayLine(delays [1]);
        comb1    = new DelayLine(delays [2]);
        comb2    = new DelayLine(delays [3]);

        UpdateParameters();
    }
Example #6
0
    void Awake()
    {
        // Delay length for 44100 Hz sample rate.
        int[] delays = {341, 613, 1557, 2137};

        // Scale the delay lengths if necessary.
        var sampleRate = AudioSettings.outputSampleRate;
        if (sampleRate != 44100) {
            var scaler = sampleRate / 44100.0f;
            for (var i = 0; i < delays.Length; i++) {
                var delay = Mathf.FloorToInt (scaler * delays [i]);
                if ((delay & 1) == 0) {
                    delay++;
                }
                while (!MathUtil.IsPrime(delay))
                    delay += 2;
                delays [i] = delay;
            }
        }

        allpass1 = new DelayLine (delays [0]);
        allpass2 = new DelayLine (delays [1]);
        comb1 = new DelayLine (delays [2]);
        comb2 = new DelayLine (delays [3]);

        UpdateParameters ();
    }
        // Constructor.
        public PRCReverb(float decayTime)
        {
            // Delay length for 44100 Hz sample rate.
            int[] delays = { 341, 613, 1557, 2137 };

            // Scale the delay lengths if necessary.
            if (Config.SampleRate != 44100) {
                var scaler = Config.SampleRate / 44100.0f;
                for (var i = 0; i < delays.Length; i++) {
                    var delay = (int)(scaler * delays [i]);
                    if ((delay & 1) == 0)
                        delay++;
                    while (!Math.IsPrime(delay))
                        delay += 2;
                    delays [i] = delay;
                }
            }

            allpassLine1 = new DelayLine (delays [0]);
            allpassLine2 = new DelayLine (delays [1]);
            combLine1 = new DelayLine (delays [2]);
            combLine2 = new DelayLine (delays [3]);

            DecayTime = decayTime;
        }
Example #8
0
        public DelayState(ref DelayParameter parameter, ulong workBuffer)
        {
            DelayLines = new DelayLine[parameter.ChannelCount];
            LowPassZ   = new float[parameter.ChannelCount];

            uint sampleRate = (uint)FixedPointHelper.ToInt(parameter.SampleRate, FixedPointPrecision) / 1000;

            for (int i = 0; i < DelayLines.Length; i++)
            {
                DelayLines[i] = new DelayLine(sampleRate, parameter.DelayTimeMax);
                DelayLines[i].SetDelay(parameter.DelayTime);
            }

            UpdateParameter(ref parameter);
        }
    void Awake()
    {
        sal = Listener.GetComponent <SpatialAudioListener> ();

        phaseLeftAngle  = 90 + (sal.phaseWidth / 2);
        phaseRightAngle = 90 - (sal.phaseWidth / 2);
        listener        = GameObject.FindObjectOfType <AudioListener> ().transform;
        sampleRate      = AudioSettings.outputSampleRate;
        var samplesPerMillisecond = 88;

        if (sampleRate != 44100)
        {
            var scaler = sampleRate / 44100.0f;
            samplesPerMillisecond = Mathf.FloorToInt(scaler * samplesPerMillisecond);
            for (var i = 0; i < reverbDelay.Length; i++)
            {
                var delay = Mathf.FloorToInt(scaler * reverbDelay [i]);
                if ((delay & 1) == 0)
                {
                    delay++;
                }
                while (!IsPrime(delay))
                {
                    delay += 2;
                }
                reverbDelay [i] = delay;
            }
        }
        allpass1 = new DelayLine(reverbDelay [0]);
        allpass2 = new DelayLine(reverbDelay [1]);
        comb1    = new DelayLine(reverbDelay [2]);
        comb2    = new DelayLine(reverbDelay [3]);
        var combScale = -3.0f / (sal.decayTime * sampleRate);

        comb1Coeff = Mathf.Pow(10.0f, combScale * comb1.Length);
        comb2Coeff = Mathf.Pow(10.0f, combScale * comb2.Length);
        left       = new VariableDelayLine(samplesPerMillisecond * sal.interauralDelay);
        right      = new VariableDelayLine(samplesPerMillisecond * sal.interauralDelay);
        eL         = Equalizer.Default();
        eR         = Equalizer.Default();
    }
Example #10
0
    void Awake()
    {
        allpassLines = new DelayLine[6];
        combLines    = new DelayLine[6];
        combCoeffs   = new float[6];

        int[] delays =
        {
            1433, 1601, 1867, 2053, 2251, 2399,
            347,   113,   37,   59,   53, 43
        };

        float scaler = AudioSettings.outputSampleRate / 25641.0f;

        for (var i = 0; i < delays.Length; i++)
        {
            var delay = Mathf.FloorToInt(scaler * delays [i]);
            if ((delay & 1) == 0)
            {
                delay++;
            }
            while (!MathUtil.IsPrime(delay))
            {
                delay += 2;
            }
            delays [i] = delay;
        }

        for (var i = 0; i < 6; i++)
        {
            combLines [i] = new DelayLine(delays [i]);
        }

        for (var i = 0; i < 6; i++)
        {
            allpassLines [i] = new DelayLine(delays [i + 6]);
        }

        UpdateParameters();
    }
Example #11
0
        // Constructor.
        public NReverb(float decayTime)
        {
            allpassLines = new DelayLine[6];
            combLines    = new DelayLine[6];
            combCoeffs   = new float[6];

            int[] delays =
            {
                1433, 1601, 1867, 2053, 2251, 2399,
                347,   113,   37,   59,   53, 43
            };

            var scaler = Config.SampleRate / 25641.0f;

            for (var i = 0; i < delays.Length; i++)
            {
                var delay = (int)(scaler * delays [i]);
                if ((delay & 1) == 0)
                {
                    delay++;
                }
                while (!Math.IsPrime(delay))
                {
                    delay += 2;
                }
                delays [i] = delay;
            }

            for (var i = 0; i < 6; i++)
            {
                combLines [i] = new DelayLine(delays [i], delays [i]);
            }

            for (var i = 0; i < 6; i++)
            {
                allpassLines [i] = new DelayLine(delays [i + 6], delays [i + 6]);
            }

            DecayTime = decayTime;
        }
Example #12
0
 /// <summary>
 /// Инициализирует новый объект типа PingPongDelay.
 /// </summary>
 public PingPongDelay()
 {
     delayL = new DelayLine();
     delayR = new DelayLine();
 }