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_AudioParameterBool.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 AudioParameterBoolAttributes : public RangedAudioParameterAttributes<AudioParameterBoolAttributes, bool> {};
36
37//==============================================================================
46{
47public:
65 AudioParameterBool (const ParameterID& parameterID,
66 const String& parameterName,
67 bool defaultValue,
68 const AudioParameterBoolAttributes& attributes = {});
69
83 [[deprecated ("Prefer the signature taking an Attributes argument")]]
84 AudioParameterBool (const ParameterID& parameterID,
85 const String& parameterName,
86 bool defaultValue,
87 const String& parameterLabel,
88 std::function<String (bool value, int maximumStringLength)> stringFromBool = nullptr,
89 std::function<bool (const String& text)> boolFromString = nullptr)
90 : AudioParameterBool (parameterID,
91 parameterName,
92 defaultValue,
93 AudioParameterBoolAttributes().withLabel (parameterLabel)
94 .withStringFromValueFunction (std::move (stringFromBool))
95 .withValueFromStringFunction (std::move (boolFromString)))
96 {
97 }
98
100 ~AudioParameterBool() override;
101
103 bool get() const noexcept { return value >= 0.5f; }
104
106 operator bool() const noexcept { return get(); }
107
109 AudioParameterBool& operator= (bool newValue);
110
112 const NormalisableRange<float>& getNormalisableRange() const override { return range; }
113
114protected:
118 virtual void valueChanged (bool newValue);
119
120private:
121 //==============================================================================
122 float getValue() const override;
123 void setValue (float newValue) override;
124 float getDefaultValue() const override;
125 int getNumSteps() const override;
126 bool isDiscrete() const override;
127 bool isBoolean() const override;
128 String getText (float, int) const override;
129 float getValueForText (const String&) const override;
130
131 const NormalisableRange<float> range { 0.0f, 1.0f, 1.0f };
132 std::atomic<float> value;
133 const float valueDefault;
134 std::function<String (bool, int)> stringFromBoolFunction;
135 std::function<bool (const String&)> boolFromStringFunction;
136
138};
139
140} // namespace juce
Properties of an AudioParameterBool.
Provides a class of AudioProcessorParameter that can be used as a boolean value.
bool get() const noexcept
Returns the parameter's current boolean value.
AudioParameterBool(const ParameterID &parameterID, const String &parameterName, bool defaultValue, const String &parameterLabel, std::function< String(bool value, int maximumStringLength)> stringFromBool=nullptr, std::function< bool(const String &text)> boolFromString=nullptr)
Creates a AudioParameterBool with the specified parameters.
const NormalisableRange< float > & getNormalisableRange() const override
Returns the range of values that the parameter can take.
Represents a mapping between an arbitrary range of values and a normalised 0->1 range.
Combines a parameter ID and a version hint.
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 ...
JUCE Namespace.
@ valueChanged
Indicates that the UI element's value has changed.