Language Guide / Controls and Parameters
Presets
klang::Presets
Collection of named factory presets.
Each preset pairs a name with values in control order. Use the units declared by each control. Entries shorter than the control list leave the trailing controls as they are. Preset loading skips input-only controls.
Example ยท Define two starting points
Here, the controls are Cutoff in Hz and Resonance.
presets = {
{ "Soft", { 700, 0.7 } },
{ "Bright", { 4200, 1.2 } }
};
Factory presets.
More...
#include <klang.h>
|
| void | operator+= (const Preset &preset) |
| |
| void | operator= (const Presets &presets) |
| |
| void | operator= (std::initializer_list< Preset > presets) |
| |
| template<typename... Values> |
| void | add (const char *name, const Values... values) |
| |
| unsigned int | size () const |
| | The current number of items in the array.
|
| |
| void | add (const Preset &item) |
| | Add the specified item to the end of the array.
|
| |
| Preset * | add () |
| | Add a blank item to the end of the array, returning a pointer that allows the item to be modified.
|
| |
| void | clear () |
| | Clear the array contents. Only resets the item count, without wiping memory.
|
| |
| float | max () const |
| | Find the maximum value in the array.
|
| |
| float | mean () const |
| | Find the mean average of values in the array.
|
| |
| float | rms () const |
| | Find the root mean squared (RMS) average of values in the array.
|
| |
| void | normalise (float target=1.f, int mode=Peak) |
| | Normalises values in the array to the specified target, based on peak, mean, or RMS value;.
|
| |
| Preset & | operator[] (int index) |
| | Returns a reference to the array item at the given index.
|
| |
| const Preset & | operator[] (int index) const |
| | Returns a read-only reference to the array item at the given index.
|
| |
|
| static int | capacity () |
| | The maximum capacity of the array.
|
| |
Definition at line 2582 of file klang.h.
◆ add() [1/3]
Definition at line 324 of file klang.h.
324 {
325 if (
count < CAPACITY)
327 return nullptr;
328 }
◆ add() [2/3]
Definition at line 318 of file klang.h.
318 {
319 if (
count < CAPACITY)
321 }
◆ add() [3/3]
template<typename... Values>
| void klang::Presets::add |
( |
const char * | name, |
|
|
const Values... | values ) |
|
inline |
◆ capacity()
◆ clear()
◆ max()
Definition at line 334 of file klang.h.
334 {
335 float max = 0.f;
336 for (
unsigned int i = 0; i <
count; i++)
337 if (abs(
items[i]) > max)
340 }
◆ mean()
Definition at line 343 of file klang.h.
343 {
344 float sum = 0.f;
345 for (
unsigned int i = 0; i <
count; i++)
346 sum += abs(
items[i]);
348 }
◆ normalise()
Definition at line 359 of file klang.h.
359 {
361
363 const float scale = current == 0.f ? 0.f : target / current;
364 for (
int i = 0; i <
count; i++)
366 }
◆ operator+=()
| void klang::Presets::operator+= |
( |
const Preset & | preset | ) |
|
|
inline |
◆ operator=() [1/2]
| void klang::Presets::operator= |
( |
const Presets & | presets | ) |
|
|
inline |
Definition at line 2587 of file klang.h.
2587 {
2588 for (int p = 0; p < 128 && presets[p].name[0]; p++)
2589 operator+=(presets[p]);
2590 }
◆ operator=() [2/2]
| void klang::Presets::operator= |
( |
std::initializer_list< Preset > | presets | ) |
|
|
inline |
Definition at line 2592 of file klang.h.
2592 {
2593 for (auto preset : presets)
2595 }
void operator+=(const Preset &preset)
References operator+=().
◆ operator[]() [1/2]
◆ operator[]() [2/2]
◆ rms()
Definition at line 351 of file klang.h.
351 {
352 float sum = 0.f;
353 for (
unsigned int i = 0; i <
count; i++)
355 return sqrt(sum /
count);
356 }
◆ size()
◆ count
◆ items