LMMS
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
33class AudioParameterBoolAttributes : public RangedAudioParameterAttributes<AudioParameterBoolAttributes, bool> {};
34
35//==============================================================================
44{
45public:
63 AudioParameterBool (const ParameterID& parameterID,
64 const String& parameterName,
65 bool defaultValue,
66 const AudioParameterBoolAttributes& attributes = {});
67
81 [[deprecated ("Prefer the signature taking an Attributes argument")]]
82 AudioParameterBool (const ParameterID& parameterID,
83 const String& parameterName,
84 bool defaultValue,
85 const String& parameterLabel,
86 std::function<String (bool value, int maximumStringLength)> stringFromBool = nullptr,
87 std::function<bool (const String& text)> boolFromString = nullptr)
88 : AudioParameterBool (parameterID,
89 parameterName,
90 defaultValue,
91 AudioParameterBoolAttributes().withLabel (parameterLabel)
92 .withStringFromValueFunction (std::move (stringFromBool))
93 .withValueFromStringFunction (std::move (boolFromString)))
94 {
95 }
96
98 ~AudioParameterBool() override;
99
101 bool get() const noexcept { return value >= 0.5f; }
102
104 operator bool() const noexcept { return get(); }
105
107 AudioParameterBool& operator= (bool newValue);
108
110 const NormalisableRange<float>& getNormalisableRange() const override { return range; }
111
112protected:
116 virtual void valueChanged (bool newValue);
117
118private:
119 //==============================================================================
120 float getValue() const override;
121 void setValue (float newValue) override;
122 float getDefaultValue() const override;
123 int getNumSteps() const override;
124 bool isDiscrete() const override;
125 bool isBoolean() const override;
126 String getText (float, int) const override;
127 float getValueForText (const String&) const override;
128
129 const NormalisableRange<float> range { 0.0f, 1.0f, 1.0f };
130 std::atomic<float> value;
131 const float valueDefault;
132 std::function<String (bool, int)> stringFromBoolFunction;
133 std::function<bool (const String&)> boolFromStringFunction;
134
136};
137
138} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
Definition juce_AudioParameterBool.h:33
Definition juce_AudioParameterBool.h:44
bool get() const noexcept
Definition juce_AudioParameterBool.h:101
std::atomic< float > value
Definition juce_AudioParameterBool.h:130
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)
Definition juce_AudioParameterBool.h:82
const float valueDefault
Definition juce_AudioParameterBool.h:131
std::function< String(bool, int)> stringFromBoolFunction
Definition juce_AudioParameterBool.h:132
std::function< bool(const String &)> boolFromStringFunction
Definition juce_AudioParameterBool.h:133
AudioParameterBool(const ParameterID &parameterID, const String &parameterName, bool defaultValue, const AudioParameterBoolAttributes &attributes={})
Definition juce_AudioParameterBool.cpp:29
const NormalisableRange< float > & getNormalisableRange() const override
Definition juce_AudioParameterBool.h:110
const NormalisableRange< float > range
Definition juce_AudioParameterBool.h:129
Definition juce_NormalisableRange.h:40
Definition juce_AudioProcessorParameterWithID.h:33
Definition juce_RangedAudioParameter.h:42
Definition juce_RangedAudioParameter.h:98
Definition juce_String.h:53
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
#define JUCE_API
Definition juce_StandardHeader.h:152
Definition carla_juce.cpp:31
@ valueChanged
Definition juce_AccessibilityEvent.h:44
Definition juce_Uuid.h:141
const char * text
Definition swell-functions.h:167
#define const
Definition zconf.h:137