Content¶
Documentation¶
Object¶
-
class
Effects
::
Object
¶ Basis for any Effect related object
Subclassed by Effects::Div, Effects::DropDown, Effects::DynamicsSlider, Effects::Parameter, Effects::RadioButton, Effects::ToggleButton, Effects::XYController
Div¶
-
struct
Effects
::
Div
: public Effects::Object¶ Public Types
Public Functions
-
Div
(Alignment t = Alignment::Horizontal)¶ Constructor.
- Parameters
t
: alignment
-
void
Align
(Alignment a)¶ Depending on the Div type: Set the alignment of the Divs contained in this Div or the alignment of the Object in this Div.
- Parameters
a
: alignment
-
void
Dividers
(bool s)¶ When Dividers is set to true, the interpretter will put dividers between the Divs contained in this Div.
- Parameters
s
: dividers
-
bool
Dividers
()¶ Returns true when dividers should be displayed between the Divs inside this Div.
- Return
true if has dividers
-
auto
Divs
() -> std::vector<std::unique_ptr<Div>>&¶ Returns all the Divs inside this Div.
- Return
all the Divs in this Div
-
void
Divs
(int i) Set the amount of Divs in this Div.
- Parameters
i
: amount of Divs
-
Parameter¶
-
class
Effects
::
Parameter
: public Effects::Object¶ Parameter base class, anything that has a range and a value, slider/knob etc.
Subclassed by Effects::VolumeSlider
Public Functions
-
Parameter
(const std::string &name = "", ParameterType t = ParameterType::Knob)¶ Constructor.
- Parameters
name
: namet
: type
-
void
NormalizedValue
(double v)¶ Set the normalized value of this Parameter.
- Parameters
v
: normalized value
-
void
Multiplier
(double v)¶ Set a Multiplier for the speed at which the parameter value changes per pixel dragged with the mouse.
- Parameters
v
: multiplier
-
double
Multiplier
()¶ Get the Multiplier for the speed at which the parameter value changes per pixel dragged with the mouse.
- Return
multiplier
-
void
Power
(double v)¶ Set a power to this parameter’s value range, useful when a range is non-linear.
- Parameters
v
: power
-
double
Power
()¶ Get the power to this parameter’s value range.
- Return
power
-
bool
Vertical
()¶ Is this parameter displayed/dragged vertically?
-
void
Vertical
(bool v)¶ Is this parameter displayed/dragged vertically?
- Parameters
v
: vertical
-
void
Unit
(const std::string &str, int tenp = 0)¶ Set a Unit to display behind the value of this Parameter. the ‘tenp’ determines the power of 10 at which this unit is displayed. For example, (“kHz”, 3) and (“Hz”, 0) will display Hz up to 1000, and after that kHz.
- Parameters
str
: unittenp
: power of 10
-
auto
Units
() -> std::unordered_map<int, std::string>&¶ Get a map of all units defined for this Parameter.
- Return
all units
-
void
Decimals
(int d)¶ Set the amount of decimals that should be displayed for this Parameter.
- Parameters
d
: decimals
-
int
Decimals
()¶ Get the amount of decimals that will be displayed for this Parameter.
- Return
decimals
-
bool
DisplayValue
()¶ Returns true when the value should be displayed.
- Return
true when value should be displayed
-
void
DisplayValue
(bool v)¶ Enable/Disable the displaying of the value.
- Parameters
v
: display value
-
bool
DisplayName
()¶ Returns true when the name should be displayed.
- Return
true when value should be displayed
-
void
DisplayName
(bool v)¶ Enable/Disable the displaying of the name.
- Parameters
v
: display name
-
VolumeSlider¶
-
class
Effects
::
VolumeSlider
: public Effects::Parameter¶ A volume slider, with a display of a level meter with variable amount of channels.
Public Functions
-
void
Channels
(int n)¶ Set the amount of channels.
- Parameters
n
: channels.
-
int
Channels
()¶ Get the amount of channels for this VolumeSlider.
- Return
amount of channels
-
auto
Values
() -> std::vector<float>¶ Get the list of levels of all channels in this VolumeSlider. These will be displayed behind the adjusted levels.
- Return
levels
-
auto
Reduces
() -> std::vector<float>¶ Get the list of adjusted levels of all channels in this VolumeSlider. These will be displayed in front of the levels.
- Return
adjusted levels
-
void
SetValue
(int i, float v)¶ Set a level for channel i.
- Parameters
i
: channelv
: level
-
void
SetReduce
(int i, float v)¶ Set an adjusted level for channel i.
- Parameters
i
: channelv
: adjusted level
-
void
DropDown¶
-
class
Effects
::
DropDown
: public Effects::Object¶ DropDown button with a group of radio buttons inside.
Public Functions
-
void
AddOption
(const std::string &name, int i)¶ Add an option to the dropdown
- Parameters
name
: namei
: value of this option
-
void
Select
(int i)¶ Select the option with value i.
- Parameters
i
: value of option to select
-
int
Selected
()¶ Get the selected option.
- Return
value of selected option
-
void
ToggleButton¶
-
class
Effects
::
ToggleButton
: public Effects::Object¶ Simple toggleable button.
Public Functions
-
ToggleButton
(const std::string &n)¶ Constructor.
- Parameters
n
: name
-
void
State
(bool s)¶ Set the state of this button.
- Parameters
s
: state
-
bool
State
()¶ Get the state of this button.
- Return
state
-
auto
Name
() -> std::string&¶ Get the name of this button.
- Return
name
Public Members
-
bool
state
= false¶ The state of this toggle button.
-
RadioButton¶
-
class
Effects
::
RadioButton
: public Effects::Object¶ Simple radio button.
Public Functions
-
RadioButton
(const std::string &n, int id, std::function<void()> callback = [] {})¶ Constructor
- Parameters
n
: nameid
: id of the group of buttons this is part ofcallback
: callback
-
void
Selected
(bool s)¶ Select this button in the group of buttons with the same id. Will call the callback!
- Parameters
s
: select
-
bool
Selected
()¶ Returns true when this button is selected.
- Return
true when selected
-
int
Id
()¶ Returns the id of the group of buttons this button is part of.
- Return
id
-
auto
Name
() -> std::string&¶ Returns name
- Return
name
Public Members
-
std::function<void()>
Callback
¶ The callback.
-
bool
selected
= false¶ True when this button is selected. Use Selected(bool s) when changing the state! This is simply exposed so the Gui component can directly link with this boolean.
-
XYController¶
EffectBase¶
-
class
Effects
::
EffectBase
¶ Base for any Effect.
Public Functions
-
EffectBase
(const std::string &name)¶ Constructor
- Parameters
name
: name
-
void
Update
()¶ This is called each frame.
-
float
NextSample
(float in, int c) = 0¶ Generate the next sample.
- Return
next sample
- Parameters
in
: samplec
: channel
-
void
Channels
(int c)¶ This is called whenever the amount of channels changes. Use this to update any buffers you have to make sure you have enough space for ‘c’ channels
- Parameters
c
: channels
-
operator nlohmann::json
() = 0¶ This operator is used to save the settings of this Effect.
-
void
operator=
(const nlohmann::json &json) = 0¶ This operator is used to load the settings of this Effect.
-
void
SampleRate
(double s)¶ Set the samplerate.
- Parameters
s
: samplerate
-
double
SampleRate
()¶ Get the samplerate.
- Return
samplerate
-
auto
Name
() -> const std::string&¶ Get the name of this Effect.
- Return
name
-
void
Height
(int h)¶ Set the height of this Effect.
- Parameters
h
: height
-
int
Height
()¶ Get the height of this Effect.
- Return
height
-
int
Width
()¶ Get the width of this Effect.
- Return
width
-
Effects::Parameter &
Parameter
(const std::string &name, ParameterType type)¶ Emplace a Parameter.
- Parameters
name
: nametype
: type
-
Effects::ToggleButton &
Toggle
(const std::string &name)¶ Emplace a Toggle Button.
- Parameters
name
: name
-
Effects::VolumeSlider &
VolumeSlider
()¶ Emplace a VolumeSlider.
-
Effects::DynamicsSlider &
DynamicsSlider
()¶ Emplace a DynamicsSlider.
-
Effects::RadioButton &
RadioButton
(const std::string &name, int id, std::function<void()> callback = [] {})¶ Emplace a RadioButton.
- Parameters
name
: nameid
: group idcallback
: callback
-
Effects::XYController &
XYController
(Effects::Parameter &p1, Effects::Parameter &p2)¶ Emplace a XYController.
- Parameters
p1
: x-axis parameterp2
: y-axis parameter
-
Examples¶
Simple Volume Effect¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #include <EffectBase.hpp>
namespace Effects
{
/**
* Simple Volume effect example.
*/
class Volume : public EffectBase
{
public:
Volume()
:
// Initialize the volume knob
m_Volume(Parameter("Volume", ParameterType::Knob)),
EffectBase("Volume") // Set name of effect in EffectBase constructor
{
// Set the height of the effect to 80.
Height(80);
// Some settings for the volume knob
m_Volume.Size({ 30, 30 });
m_Volume.Range({ 0, 100 });
m_Volume.Unit("%");
m_Volume.Decimals(1);
m_Volume.ResetValue(100);
m_Volume.ResetValue();
m_Volume.Multiplier(0.4);
// Put the volume knob in the center of the entire Div.
Div().Align(Div::Alignment::Center);
Div() = m_Volume;
}
float NextSample(float in, int c)
{
// Multiply the incoming sample with the volume knob
return in * m_Volume.Value() * 0.01;
}
operator nlohmann::json()
{
// Save the value of the volume knob.
nlohmann::json _json = nlohmann::json::object();
_json["volume"] = m_Volume.Value();
return _json;
}
void operator=(const nlohmann::json& json)
{
// Load the value of the volume knob.
m_Volume.Value(json.at("volume").get<double>());
}
private:
// The volume parameter
Effects::Parameter& m_Volume;
};
}
/**
* MAKE SURE TO ADD THIS METHOD!!
* This allows the Gui to create an instance of the effect.
*/
extern "C"
{
DLLDIR void* NewInstance()
{
return new Effects::Volume();
}
}
|