diff options
author | falkTX <falktx@gmail.com> | 2018-08-04 00:36:55 +0200 |
---|---|---|
committer | falkTX <falktx@gmail.com> | 2018-08-04 00:36:55 +0200 |
commit | f2ed265a003e5d426953bb9d91aec7de093986e0 (patch) | |
tree | a3c64aa35e7ce3e1f6206a5d8653decc062e8de5 /distrho/DistrhoPlugin.hpp | |
parent | 2786991ed9423fdfdb984f40946748e725efa933 (diff) |
Add parameter trigger and enumeration definitions
Diffstat (limited to 'distrho/DistrhoPlugin.hpp')
-rw-r--r-- | distrho/DistrhoPlugin.hpp | 100 |
1 files changed, 99 insertions, 1 deletions
diff --git a/distrho/DistrhoPlugin.hpp b/distrho/DistrhoPlugin.hpp index fcb40dd5..9974aeaf 100644 --- a/distrho/DistrhoPlugin.hpp +++ b/distrho/DistrhoPlugin.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com> + * Copyright (C) 2012-2018 Filipe Coelho <falktx@falktx.com> * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -89,6 +89,12 @@ static const uint32_t kParameterIsLogarithmic = 0x08; */ static const uint32_t kParameterIsOutput = 0x10; +/** + Parameter value is a trigger. + @note Cannot be used for output parameters +*/ +static const uint32_t kParameterIsTrigger = 0x20 | kParameterIsBoolean; + /** @} */ /* ------------------------------------------------------------------------------------------------------------ @@ -275,6 +281,90 @@ struct ParameterRanges { }; /** + Parameter enumeration value.@n + A string representation of a plugin parameter value.@n + Used together can be used to give meaning to parameter values, working as an enumeration. + */ +struct ParameterEnumerationValue { + /** + Parameter value. + */ + float value; + + /** + String representation of this value. + */ + String label; + + /** + Default constructor, using 0.0 as value and empty label. + */ + ParameterEnumerationValue() noexcept + : value(0.0f), + label() {} + + /** + Constructor using custom values. + */ + ParameterEnumerationValue(float v, const char* l) noexcept + : value(v), + label(l) {} +}; + +/** + Collection of parameter enumeration values.@n + Handy class to handle the lifetime and count of all enumeration values. + */ +struct ParameterEnumerationValues { + /** + Number of elements allocated in @values. + */ + uint8_t count; + + /** + Wherever the host is to be restricted to only use enumeration values. + + @note This mode is only a hint! Not all hosts and plugin formats support this mode. + */ + bool restrictedMode; + + /** + Array of @ParameterEnumerationValue items.@n + This pointer must be null or have been allocated on the heap with `new`. + */ + const ParameterEnumerationValue* values; + + /** + Default constructor, for zero enumeration values. + */ + ParameterEnumerationValues() noexcept + : count(0), + restrictedMode(false), + values() {} + + /** + Constructor using custom values.@n + The pointer to @values must have been allocated on the heap with `new`. + */ + ParameterEnumerationValues(uint32_t c, bool r, const ParameterEnumerationValue* v) noexcept + : count(c), + restrictedMode(r), + values(v) {} + + ~ParameterEnumerationValues() noexcept + { + count = 0; + restrictedMode = false; + + if (values != nullptr) + { + delete[] values; + values = nullptr; + } + } +}; + +/** Parameter. */ struct Parameter { @@ -313,6 +403,12 @@ struct Parameter { ParameterRanges ranges; /** + Enumeration values.@n + Can be used to give meaning to parameter values, working as an enumeration. + */ + ParameterEnumerationValues enumValues; + + /** Designation for this parameter. */ ParameterDesignation designation; @@ -334,6 +430,7 @@ struct Parameter { symbol(), unit(), ranges(), + enumValues(), designation(kParameterDesignationNull), midiCC(0) {} @@ -346,6 +443,7 @@ struct Parameter { symbol(s), unit(u), ranges(def, min, max), + enumValues(), designation(kParameterDesignationNull), midiCC(0) {} |