11namespace tracktion {
inline namespace engine
14namespace PredefinedWavetable
16 static inline float getSinSample (
float phase)
21 static inline float getTriangleSample (
float phase)
23 return (phase < 0.5f) ? (2.0f * phase) : (-2.0f * phase + 2.0f);
26 static inline float getSawUpSample (
float phase)
31 static inline float getSawDownSample (
float phase)
36 static inline float getSquareSample (
float phase)
38 return phase < 0.5f ? 1.0f : 0.0f;
41 static inline float getStepsUpSample (
float phase,
int totalNumSteps)
44 const float stageAmmount = 1.0f / (totalNumSteps - 1);
48 return stageAmmount * stage;
51 static inline float getStepsDownSample (
float phase,
int totalNumStages)
53 return getStepsUpSample (1.0f - phase, totalNumStages);
62 void setDuration (
float newDuration)
noexcept
65 rampDuration = newDuration;
69 void setPosition (
float newPosition)
noexcept
72 rampPos =
juce::jlimit (0.0f, rampDuration, newPosition) / rampDuration;
75 void process (
float duration)
noexcept
77 rampPos += (duration / rampDuration);
79 while (rampPos > 1.0f)
83 float getPosition()
const noexcept
85 return rampPos * rampDuration;
88 float getProportion()
const noexcept
94 float rampPos = 0.0f, rampDuration = 1.0f;
114 int numStatesToUse = 0,
117 numStates (numStatesToUse), labels (labelsToUse)
124 notifyListenersOfDeletion();
127 bool isDiscrete()
const override {
return numStates != 0; }
128 int getNumberOfStates()
const override {
return numStates; }
130 float getValueForState (
int i)
const override
135 return juce::jmap ((
float) i, 0.0f,
float (numStates - 1), valueRange.
start, valueRange.
end);
138 int getStateForValue (
float value)
const override
146 bool hasLabels()
const override {
return labels.
size() > 0; }
149 juce::String getLabelForValue (
float val)
const override
151 const int s = getStateForValue (val);
156 float snapToState (
float val)
const override
162 const int numStates = 0;
181 notifyListenersOfDeletion();
189 return AutomatableParameter::valueToString (value);
208 p->attachToCurrentValue (val);
221 p->attachToCurrentValue (val);
void setSkewForCentre(ValueType centrePointValue) noexcept
int size() const noexcept
bool isEmpty() const noexcept
Base class for elements that have some kind of automatable parameters.
#define NEEDS_TRANS(stringLiteral)
constexpr Type jmap(Type value0To1, Type targetRangeMin, Type targetRangeMax)
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
int roundToInt(const FloatType value) noexcept
A ramp which goes between 0 and 1 over a set duration.