예제 #1
0
        private void Update(EvaluationContext context)
        {
            var count = Count.GetValue(context).Clamp(1, 10000);

            if (_points.Length != count)
            {
                _points = new T3.Core.DataTypes.Point[count];
            }

            var scale     = Scale.GetValue(context);
            var frequency = Frequency.GetValue(context);
            var phase     = Phase.GetValue(context);

            var amplitude = Amplitude.GetValue(context);
            var index     = 0;
            var thickness = Thickness.GetValue(context);
            int seed      = 1337;

            for (var x = 0; x < count; x++)
            {
                var fX       = x / (float)count;
                var position = new Vector3(
                    MathUtils.PerlinNoise(phase + 0.234f + fX, frequency, 2, seed) * amplitude * scale.X,
                    MathUtils.PerlinNoise(phase + 110.637f + fX, frequency, 2, seed) * amplitude * scale.Y,
                    MathUtils.PerlinNoise(phase + 241.221f + fX, frequency, 2, seed) * amplitude * scale.Z);
                _points[index].Position = position;
                _points[index].W        = thickness;
                index++;
            }


            Result.Value = _points;
        }
예제 #2
0
        private void Update(EvaluationContext context)
        {
            var t = (float)EvaluationContext.BeatTime * SpeedFactor.GetValue(context);

            //var value = Value.GetValue(context);
            var amplitude      = Amplitude.GetValue(context);
            var period         = Period.GetValue(context);
            var offset         = Offset.GetValue(context);
            var phase          = Phase.GetValue(context);
            var amplitudeScale = AmplitudeScale.GetValue(context);

            Result.Value = new System.Numerics.Vector2(
                (float)Math.Sin(t / period.X + phase.X) * amplitude.X * amplitudeScale + offset.X,
                (float)Math.Sin(t / period.Y + phase.Y) * amplitude.Y * amplitudeScale + offset.Y
                );
        }
예제 #3
0
        private void Update(EvaluationContext context)
        {
            var t = OverrideTime.IsConnected
                        ? OverrideTime.GetValue(context)
                        : (float)context.LocalFxTime * SpeedFactor.GetValue(context);

            //var value = Value.GetValue(context);
            var amplitude      = Amplitude.GetValue(context);
            var period         = Period.GetValue(context);
            var offset         = Offset.GetValue(context);
            var phase          = Phase.GetValue(context);
            var amplitudeScale = AmplitudeScale.GetValue(context);

            Result.Value = new Vector3(
                (float)Math.Sin(t / period.X + phase.X) * amplitude.X * amplitudeScale + offset.X,
                (float)Math.Sin(t / period.Y + phase.Y) * amplitude.Y * amplitudeScale + offset.Y,
                (float)Math.Sin(t / period.Z + phase.Z) * amplitude.Z * amplitudeScale + offset.Z
                );
        }
예제 #4
0
        private void Update(EvaluationContext context)
        {
            _phase = Phase.GetValue(context);
            _bias  = Bias.GetValue(context);
            _shape = (Shapes)Shape.GetValue(context);
            _ratio = Ratio.GetValue(context);
            var time = OverrideTime.IsConnected
                           ? OverrideTime.GetValue(context)
                           : EvaluationContext.BeatTime;

            var rate = Rate.GetValue(context);

            var t = time * rate;

            LastFraction = (float)MathUtils.Fmod(t, 1);

            var normalizedValue = CalcNormalizedValueForFraction(t);

            Result.Value = normalizedValue * Amplitude.GetValue(context) + Offset.GetValue(context);
        }
예제 #5
0
        private void Update(EvaluationContext context)
        {
            var bang = Trigger.GetValue(context);

            if (bang != _lastBang)
            {
                if (bang)
                {
                    _lastTriggerTime = (float)EvaluationContext.BeatTime;
                }
                _lastBang = bang;
            }

            var timeSinceTrigger = (float)EvaluationContext.BeatTime - _lastTriggerTime;

            if (timeSinceTrigger < 0)
            {
                timeSinceTrigger = 0;
            }
            Result.Value = Math.Max(Amplitude.GetValue(context) - timeSinceTrigger * Decay.GetValue(context), 0);
        }
예제 #6
0
 private void Update(EvaluationContext context)
 {
     Result.Value = (float)Math.Sin(Input.GetValue(context) / Period.GetValue(context) + Phase.GetValue(context))
                    * Amplitude.GetValue(context)
                    + Offset.GetValue(context);
 }
예제 #7
0
        private void Update(EvaluationContext context)
        {
            var band   = (FrequencyBands)Band.GetValue(context);
            var mode   = (Modes)Mode.GetValue(context);
            var decay  = Decay.GetValue(context);
            var modulo = UseModulo.GetValue(context);

            var t = context.LocalFxTime;

            if (Math.Abs(t - _lastEvalTime) < 0.001f)
            {
                return;
            }

            _lastEvalTime = t;

            //var a = _SetAudioAnalysis.AudioAnalysisResult;

            var results = band == FrequencyBands.Bass
                              ? AudioAnalysisResult.Bass
                              : AudioAnalysisResult.HiHats;

            var peakDetected = results.PeakCount > _lastPeakCount;

            var usingModulo  = modulo > 0;
            var isModuloPeak = peakDetected && (!usingModulo || results.PeakCount % modulo == 0);

            if (peakDetected && isModuloPeak)
            {
                _lastModuloPeakTime = context.Playback.FxTimeInBars;
            }
            var timeSinceModuloPeak = (float)(context.Playback.FxTimeInBars - _lastModuloPeakTime);
            var timeSincePeak       = usingModulo
                                    ? timeSinceModuloPeak
                                    : results.TimeSincePeak;

            float value = 0;

            switch (mode)
            {
            case Modes.TimeSincePeak:

                value = timeSincePeak;
                break;

            case Modes.Count:
                value = usingModulo
                        ? results.PeakCount / modulo
                        : results.PeakCount;
                break;

            case Modes.Peaks:
                value = (float)Math.Max(0, 1 - timeSincePeak * decay);
                break;

            case Modes.PeaksDecaying:
                value = (float)Math.Pow(decay + 1, -timeSincePeak);
                break;

            case Modes.Level:
                value = (float)results.AccumulatedEnergy;
                break;

            case Modes.MovingSum:
                if (double.IsNaN(_movingSum))
                {
                    _movingSum = 0;
                }

                var step = Math.Pow(results.AccumulatedEnergy, decay);
                if (!double.IsNaN(step))
                {
                    _movingSum += step;
                }

                value = (float)(_movingSum % 10000);
                break;

            case Modes.RandomValue:
                if (isModuloPeak)
                {
                    _lastRandomValue = (float)_random.NextDouble();
                }
                value = _lastRandomValue;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            Level.Value = value * Amplitude.GetValue(context);

            PeakCount.Value = results.PeakCount;

            PeakDetected.Value = isModuloPeak;
            _lastPeakCount     = results.PeakCount;

            Level.DirtyFlag.Clear();
            PeakCount.DirtyFlag.Clear();
            PeakDetected.DirtyFlag.Clear();
        }