JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_AudioParameterInt.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
35class AudioParameterIntAttributes : public RangedAudioParameterAttributes<AudioParameterIntAttributes, int> {};
36
37//==============================================================================
47{
48public:
68 AudioParameterInt (const ParameterID& parameterID,
69 const String& parameterName,
70 int minValue,
71 int maxValue,
72 int defaultValue,
73 const AudioParameterIntAttributes& attributes = {});
74
90 [[deprecated ("Prefer the signature taking an Attributes argument")]]
91 AudioParameterInt (const ParameterID& parameterID,
92 const String& parameterName,
93 int minValue,
94 int maxValue,
95 int defaultValueIn,
96 const String& parameterLabel,
97 std::function<String (int value, int maximumStringLength)> stringFromInt = nullptr,
98 std::function<int (const String& text)> intFromString = nullptr)
99 : AudioParameterInt (parameterID,
100 parameterName,
101 minValue,
102 maxValue,
103 defaultValueIn,
104 AudioParameterIntAttributes().withLabel (parameterLabel)
105 .withStringFromValueFunction (std::move (stringFromInt))
106 .withValueFromStringFunction (std::move (intFromString)))
107 {
108 }
109
111 ~AudioParameterInt() override;
112
114 int get() const noexcept { return roundToInt (value.load()); }
115
117 operator int() const noexcept { return get(); }
118
122 AudioParameterInt& operator= (int newValue);
123
125 Range<int> getRange() const noexcept { return { (int) getNormalisableRange().start, (int) getNormalisableRange().end }; }
126
128 const NormalisableRange<float>& getNormalisableRange() const override { return range; }
129
130protected:
134 virtual void valueChanged (int newValue);
135
136private:
137 //==============================================================================
138 float getValue() const override;
139 void setValue (float newValue) override;
140 float getDefaultValue() const override;
141 int getNumSteps() const override;
142 String getText (float, int) const override;
143 float getValueForText (const String&) const override;
144
145 const NormalisableRange<float> range;
146 std::atomic<float> value;
147 const float defaultValue;
148 std::function<String (int, int)> stringFromIntFunction;
149 std::function<int (const String&)> intFromStringFunction;
150
152};
153
154} // namespace juce
Properties of an AudioParameterInt.
Provides a class of AudioProcessorParameter that can be used as an integer value with a given range.
int get() const noexcept
Returns the parameter's current value as an integer.
AudioParameterInt(const ParameterID &parameterID, const String &parameterName, int minValue, int maxValue, int defaultValueIn, const String &parameterLabel, std::function< String(int value, int maximumStringLength)> stringFromInt=nullptr, std::function< int(const String &text)> intFromString=nullptr)
Creates a AudioParameterInt with the specified parameters.
const NormalisableRange< float > & getNormalisableRange() const override
Returns the range of values that the parameter can take.
Range< int > getRange() const noexcept
Returns the parameter's range.
Represents a mapping between an arbitrary range of values and a normalised 0->1 range.
Combines a parameter ID and a version hint.
A general-purpose range object, that simply represents any linear range with a start and end point.
Definition juce_Range.h:40
This abstract base class is used by some AudioProcessorParameter helper classes.
The JUCE String class!
Definition juce_String.h:53
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
typedef int
JUCE Namespace.
@ valueChanged
Indicates that the UI element's value has changed.
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.