Parameter changes and correct value displays
This commit is contained in:
parent
4dd9d55c62
commit
b4412624a9
@ -148,11 +148,34 @@ struct Plugin : public clap_plugin {
|
||||
std::vector<float *> outputBuffers;
|
||||
|
||||
void processEvent(const clap_event_header *header) {
|
||||
LOG_EXPR(header->size);
|
||||
LOG_EXPR(header->time);
|
||||
LOG_EXPR(header->space_id);
|
||||
LOG_EXPR(header->type);
|
||||
LOG_EXPR(header->flags);
|
||||
if (header->space_id != CLAP_CORE_EVENT_SPACE_ID) return; // only core events supported atm
|
||||
if (header->type == CLAP_EVENT_PARAM_VALUE) {
|
||||
auto *event = (clap_event_param_value *)header;
|
||||
auto *param = (Param *)event->cookie;
|
||||
if (!param) {
|
||||
auto paramId = event->param_id;
|
||||
for (auto &p : params) {
|
||||
if (p.id == paramId) {
|
||||
param = &p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!param) return; // invalid parameter
|
||||
} else if (param->id != event->param_id) {
|
||||
return; // inconsistent ID / cookie
|
||||
}
|
||||
if (param->rangeParam) {
|
||||
*param->rangeParam = param->rangeInfo->fromUnit(event->value);
|
||||
} else {
|
||||
*param->steppedParam = int(std::round(event->value));
|
||||
}
|
||||
} else {
|
||||
LOG_EXPR(header->size);
|
||||
LOG_EXPR(header->time);
|
||||
LOG_EXPR(header->space_id);
|
||||
LOG_EXPR(header->type);
|
||||
LOG_EXPR(header->flags);
|
||||
}
|
||||
}
|
||||
|
||||
// CLAP plugin methods
|
||||
@ -253,7 +276,7 @@ struct Plugin : public clap_plugin {
|
||||
plugin.processEvent(event);
|
||||
++nextEventIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
inputBuffers.resize(0);
|
||||
outputBuffers.resize(0);
|
||||
return CLAP_PROCESS_CONTINUE;
|
||||
@ -361,7 +384,7 @@ struct Plugin : public clap_plugin {
|
||||
for (auto ¶m : plugin.params) {
|
||||
if (param.id == paramId) {
|
||||
if (param.rangeParam) {
|
||||
auto str = param.rangeInfo->toString(value);
|
||||
auto str = param.rangeInfo->toString(param.rangeInfo->fromUnit(value));
|
||||
std::strncpy(text, str.c_str(), textCapacity);
|
||||
} else {
|
||||
auto str = param.steppedInfo->toString(int(std::round(value)));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user