![]() |
Klang C++ 0.7.15
Language Reference (draft)
|
Language Guide / Controls and Parameters
klang::Controls
Collection of a model’s controls.
Declare the collection when constructing the model. A control supplies its label, range and initial value to Studio. Read the current value by index in declaration order, or borrow a named Control member when several parts of the model need to refer to it.
Dial("Level") uses the default range of 0 to 1 and starts at 0. Turn it up to hear the input.
struct Level : Effect {
Level() {
controls = {
Dial("Level")
};
}
void process() {
in * controls[0] >> out;
}
};Use a Dial or Slider for continuous values, Toggle for an on/off state, Button for a momentary action, and Menu for a choice. A Meter displays a value supplied by the model.
controls = {
Slider("Mix"),
Toggle("Enabled"),
Button("Reset"),
Menu("Shape", "Sine", "Saw"),
Meter("Output")
};The optional size supplies x, y, width, and height for placement in Studio. Omit it to use automatic layout. Put related controls in a Group to give them a shared label.
controls = {
{ "Tone",
Dial("Cutoff", 20, 12000, 1000, { 0, 0, 45, 45 }),
Dial("Resonance", 0.1, 4, 0.7)
}
};A plugin can expose controls from another plugin instance it can access. Here the first control on source is its level. Pass it by reference to share that value. The two interfaces then address the same control.
struct LevelPanel : Sound {
LevelPanel(Sound& source) {
controls = { source.controls[0] };
}
};Pass the whole collection to expose all of the source plugin’s controls. Keep the source plugin alive for as long as the borrowing plugin uses them.
struct FullPanel : Sound {
FullPanel(Sound& source) {
controls = { source.controls };
}
};#include <klang.h>
Inheritance diagram for klang::Controls:Public Member Functions | |
| Controls () | |
| Controls (const Controls &other) | |
| Controls (Controls &&other) | |
| ~Controls () | |
| Control & | operator[] (int index) |
| Resolve one actual control; ordinary owned collections take the direct path. | |
| const Control & | operator[] (int index) const |
| void | clear () |
| Controls & | operator= (const Controls &) &&=delete |
| template<class Source , std::enable_if_t< std::is_same_v< std::decay_t< Source >, Controls >, int > = 0> | |
| Controls & | operator= (Source &&source) & |
| Controls & | operator= (std::initializer_list< klang::Group > declaration) |
| void | operator+= (Control &control) |
| void | operator+= (const Control &control) |
| void | operator+= (Control &&control) |
| void | operator+= (Controls &controls) |
| void | add (const Control &control) |
| Control * | add () |
| void | add (const char *name, Control::Type type=Control::ROTARY, float min=0.f, float max=1.f, float initial=0.f, Control::Size size=Automatic) |
| void | add (const char *name, Control::Type type, std::initializer_list< const char * > options, Control::Size size=Automatic) |
| bool | inGroup (int index) const |
| const Control::Group * | getGroup (int index) const |
| bool | changed () |
| float | max () const |
| float | mean () const |
| float | rms () const |
| void | normalise (float target=1, int mode=Peak) |
| void | group (const char *name, unsigned int start, unsigned int length, Control::Size size=Automatic) |
| template<class... Args> | |
| void | set (Args... args) |
| void | set (const Preset &preset) |
| Controls & | operator= (const Preset &preset) |
| const char * | key (int index) const |
| Stable declaration key for metadata/retention; never a pointer or a default value. | |
| const char * | scope (int index) const |
| int | scopeStart (int index) const |
| int | scopeSize (int index) const |
| bool | isInput (int index) const |
| void | markInput (int index, bool state=true) |
| bool | hasReferences () const |
| void | setMetadata (int index, const char *identity, const char *block, int start, int length, bool gameInput) |
| Preserve original identities when a proxy reconstructs a flat schema. | |
| void | bindAlias (int index, int canonicalIndex) |
| Reconstruct an earlier canonical slot when a proxy flattens aliases. | |
| const Control * | snapshot () |
| Refresh only the legacy contiguous metadata/value snapshot before raw ABI export. | |
| const Control * | snapshot () const |
| unsigned int | size () const |
| The current number of items in the array. | |
Static Public Member Functions | |
| static int | capacity () |
| The maximum capacity of the array. | |
Public Attributes | |
| float | value [128] = { 0 } |
| Array< Control::Group, 10 > | groups |
| unsigned int | count |
| Control | items [CAPACITY] |
An owned control collection with optional borrowed value entries. Mutable Control and Controls lvalues in a declaration borrow their values; temporary factory results are owned. Referenced schemas are fixed while borrowed. An individual borrowed Control must outlive this collection. DSP code normally continues reading the child's original Controls object. The legacy count/items/value/groups prefix and Control layout are retained; the binding sidecar is internal, never the MiniPlugin host ABI record.
|
inline |
Definition at line 2311 of file klang.h.
References klang::Array< Control, 128 >::items.
|
inline |
|
inline |
Definition at line 2320 of file klang.h.
|
inline |
Definition at line 2402 of file klang.h.
References klang::Array< Control, 128 >::count, and klang::Array< Control, 128 >::items.
|
inline |
Definition at line 2417 of file klang.h.
References klang::Text< 32 >::from(), klang::Control::name, and klang::Array< Control, 128 >::size().
|
inline |
Definition at line 2408 of file klang.h.
References max(), klang::Control::name, klang::Array< Control, 128 >::size(), and klang::signal::value.
|
inline |
|
inline |
Definition at line 2529 of file klang.h.
References klang::Array< Control, 128 >::count, klang::Array< Control, 128 >::items, and markInput().
|
inlinestaticinherited |
|
inline |
Definition at line 2439 of file klang.h.
References klang::Array< Control, 128 >::count, and value.
|
inline |
Definition at line 2343 of file klang.h.
References klang::Array< Control, 128 >::count, and groups.
Referenced by operator=(), and operator=().
|
inline |
Definition at line 2434 of file klang.h.
|
inline |
Definition at line 2473 of file klang.h.
References klang::Array< Control, 128 >::count, klang::Text< 32 >::from(), groups, and klang::Array< Control, 128 >::size().
Referenced by getGroup(), inGroup(), and operator=().
|
inline |
|
inline |
|
inline |
Definition at line 2494 of file klang.h.
Referenced by operator=(), and set().
|
inline |
|
inline |
Definition at line 2495 of file klang.h.
References klang::Array< Control, 128 >::count.
Referenced by bindAlias(), and setMetadata().
|
inline |
Definition at line 2447 of file klang.h.
References klang::Array< Control, 128 >::count.
Referenced by add(), and normalise().
|
inline |
Definition at line 2452 of file klang.h.
References klang::Array< Control, 128 >::count.
Referenced by normalise().
|
inline |
Definition at line 2462 of file klang.h.
References klang::Array< Control, 128 >::count, max(), klang::Mean, mean(), klang::Peak, and rms().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 2360 of file klang.h.
References clear(), klang::Array< TYPE, CAPACITY >::count, klang::Array< Control, 128 >::count, groups, and isInput().
|
inline |
Definition at line 2369 of file klang.h.
References clear(), klang::ControlEntry::Collection, klang::Array< Control, 128 >::count, klang::Text< 32 >::from(), group(), groups, and klang::ControlEntry::Reference.
|
inline |
Definition at line 2329 of file klang.h.
References klang::Array< Control, 128 >::items.
Referenced by set().
|
inline |
Definition at line 2336 of file klang.h.
References klang::Array< Control, 128 >::items.
|
inline |
Definition at line 2457 of file klang.h.
References klang::Array< Control, 128 >::count.
Referenced by normalise().
|
inline |
Definition at line 2491 of file klang.h.
Referenced by setMetadata().
|
inline |
Definition at line 2493 of file klang.h.
References klang::Array< Control, 128 >::count.
|
inline |
|
inline |
Definition at line 2480 of file klang.h.
References klang::Array< Control, 128 >::count.
Referenced by operator=().
|
inline |
Definition at line 2561 of file klang.h.
References klang::Array< TYPE, CAPACITY >::count, klang::Array< Control, 128 >::count, isInput(), operator[](), klang::Control::set(), and klang::Preset::values.
|
inline |
Definition at line 2505 of file klang.h.
References klang::Array< Control, 128 >::count, markInput(), and scope().
|
inlineinherited |
|
inline |
Definition at line 2544 of file klang.h.
References klang::Array< Control, 128 >::count, and klang::Array< Control, 128 >::items.
|
inline |
Definition at line 2549 of file klang.h.
References snapshot().
Referenced by snapshot().
|
inherited |
Definition at line 308 of file klang.h.
Referenced by add(), bindAlias(), changed(), clear(), group(), markInput(), max(), mean(), normalise(), operator=(), operator=(), rms(), scopeSize(), set(), set(), setMetadata(), and snapshot().
| Array<Control::Group, 10> klang::Controls::groups |
Definition at line 2081 of file klang.h.
Referenced by clear(), getGroup(), group(), inGroup(), operator=(), and operator=().
|
inherited |
Definition at line 309 of file klang.h.
Referenced by Controls(), add(), bindAlias(), operator[](), operator[](), and snapshot().