Skip to content

Commit ae90066

Browse files
author
Martin Klang
authored
test if value has changed before sending event
1 parent fac572c commit ae90066

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

Source/PatchProgram.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ PatchProcessor* getInitialisingPatchProcessor(){
1515
}
1616

1717
void doSetPatchParameter(uint8_t id, int16_t value){
18-
if(getProgramVector()->checksum >= PROGRAM_VECTOR_CHECKSUM_V12 &&
19-
getProgramVector()->setPatchParameter != NULL)
20-
getProgramVector()->setPatchParameter(id, value);
18+
ProgramVector vec = getProgramVector();
19+
if(vec->checksum >= PROGRAM_VECTOR_CHECKSUM_V12 &&
20+
vec->setPatchParameter != NULL && vec->parameters[id] != value)
21+
vec->setPatchParameter(id, value);
2122
}
2223

2324
void doSetButton(uint8_t id, uint16_t value, uint16_t samples){
24-
if(getProgramVector()->checksum >= PROGRAM_VECTOR_CHECKSUM_V12 &&
25-
getProgramVector()->setButton != NULL)
26-
getProgramVector()->setButton((PatchButtonId)id, value, samples);
25+
ProgramVector vec = getProgramVector();
26+
if(vec->checksum >= PROGRAM_VECTOR_CHECKSUM_V12 &&
27+
vec->setButton != NULL &&
28+
// if it is not a MIDI note, check that value has changed
29+
(id > 31 || (bool)(vec->buttons&(1<<id)) != (bool)value))
30+
vec->setButton((PatchButtonId)id, value, samples);
2731
}
2832

2933
void onButtonChanged(uint8_t id, uint16_t value, uint16_t samples){

0 commit comments

Comments
 (0)