Vital
Loading...
Searching...
No Matches
smooth_value.h
Go to the documentation of this file.
1
6#pragma once
7
8#include "value.h"
9
10namespace vital {
11
23 class SmoothValue : public Value {
24 public:
26 static constexpr mono_float kSmoothCutoff = 5.0f;
27
33
38 virtual Processor* clone() const override {
39 return new SmoothValue(*this);
40 }
41
46 virtual void process(int num_samples) override;
47
53 void linearInterpolate(int num_samples, poly_mask linear_mask);
54
59 void set(poly_float value) override {
60 enable(true);
61 value_ = value;
62 }
63
69 enable(true);
71 current_value_ = value;
72 }
73
74 private:
76 poly_float current_value_;
77 };
78
79 namespace cr {
91 class SmoothValue : public Value {
92 public:
94 static constexpr mono_float kSmoothCutoff = 20.0f;
95
101
106 virtual Processor* clone() const override {
107 return new SmoothValue(*this);
108 }
109
115 virtual void process(int num_samples) override;
116
123 current_value_ = value;
124 }
125
126 private:
128 poly_float current_value_;
129
130 JUCE_LEAK_DETECTOR(SmoothValue)
131 };
132 } // namespace cr
133} // namespace vital
Base class for all signal-processing units in Vital.
Definition processor.h:212
virtual void enable(bool enable)
Enables or disables this Processor.
Definition processor.h:318
A Value processor that smoothly transitions from its current value to a target value.
Definition smooth_value.h:23
void setHard(poly_float value)
Immediately sets the value without smoothing, and updates internal state.
Definition smooth_value.h:68
void linearInterpolate(int num_samples, poly_mask linear_mask)
Performs a linear interpolation if conditions are met for a smoother transition.
Definition smooth_value.cpp:43
virtual void process(int num_samples) override
Processes a block of samples, updating the smoothed value output.
Definition smooth_value.cpp:14
static constexpr mono_float kSmoothCutoff
The cutoff frequency for smoothing, controlling how fast the value settles.
Definition smooth_value.h:26
void set(poly_float value) override
Sets the new target value, enabling the processor and starting the smoothing process.
Definition smooth_value.h:59
SmoothValue(mono_float value=0.0f)
Constructs a new SmoothValue with an initial value.
Definition smooth_value.cpp:12
virtual Processor * clone() const override
Creates a clone of this SmoothValue processor.
Definition smooth_value.h:38
A Processor that maintains and outputs a constant poly_float value.
Definition value.h:24
virtual void set(poly_float value)
Sets the internal value to a new poly_float.
Definition value.cpp:17
poly_float value_
The constant output value.
Definition value.h:69
force_inline mono_float value() const
Returns the current mono_float value of the first lane.
Definition value.h:60
A control-rate version of the SmoothValue that smooths values at control rate instead of audio rate.
Definition smooth_value.h:91
virtual Processor * clone() const override
Creates a clone of this SmoothValue (control-rate) processor.
Definition smooth_value.h:106
static constexpr mono_float kSmoothCutoff
The cutoff frequency for smoothing at control rate.
Definition smooth_value.h:94
virtual void process(int num_samples) override
Processes the control-rate smoothing for the given number of samples.
Definition smooth_value.cpp:64
SmoothValue(mono_float value=0.0f)
Constructs a new SmoothValue (control-rate) with an initial value.
Definition smooth_value.cpp:62
void setHard(mono_float value)
Immediately sets the control-rate value without smoothing, and updates internal state.
Definition smooth_value.h:121
A control-rate variant of the Value processor.
Definition value.h:82
Contains classes and functions used within the Vital synthesizer framework.
float mono_float
Definition common.h:33
Represents a vector of floating-point values using SIMD instructions.
Definition poly_values.h:600
Represents a vector of integer values using SIMD instructions.
Definition poly_values.h:56
Declares Value processors that output a constant value and can be dynamically set.