Browse Source

Add parameter trigger and enumeration definitions

pull/61/head
falkTX 6 years ago
parent
commit
f2ed265a00
1 changed files with 99 additions and 1 deletions
  1. +99
    -1
      distrho/DistrhoPlugin.hpp

+ 99
- 1
distrho/DistrhoPlugin.hpp View File

@@ -1,6 +1,6 @@
/* /*
* DISTRHO Plugin Framework (DPF) * 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 * 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 * 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; 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;

/** @} */ /** @} */


/* ------------------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------------------
@@ -274,6 +280,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. Parameter.
*/ */
@@ -312,6 +402,12 @@ struct Parameter {
*/ */
ParameterRanges ranges; ParameterRanges ranges;


/**
Enumeration values.@n
Can be used to give meaning to parameter values, working as an enumeration.
*/
ParameterEnumerationValues enumValues;

/** /**
Designation for this parameter. Designation for this parameter.
*/ */
@@ -334,6 +430,7 @@ struct Parameter {
symbol(), symbol(),
unit(), unit(),
ranges(), ranges(),
enumValues(),
designation(kParameterDesignationNull), designation(kParameterDesignationNull),
midiCC(0) {} midiCC(0) {}


@@ -346,6 +443,7 @@ struct Parameter {
symbol(s), symbol(s),
unit(u), unit(u),
ranges(def, min, max), ranges(def, min, max),
enumValues(),
designation(kParameterDesignationNull), designation(kParameterDesignationNull),
midiCC(0) {} midiCC(0) {}




Loading…
Cancel
Save