Skip to content

Commit

Permalink
Truncation and DC offset compensation
Browse files Browse the repository at this point in the history
  • Loading branch information
antisvin committed Apr 9, 2023
1 parent 9bc37e3 commit a180745
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Bluemchen/Inc/BluemchenParameterController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,8 @@ class ParameterController {

// called by MIDI cc and/or from patch
void setValue(uint8_t pid, int16_t value) {
if (pid >= NOF_ADC_VALUES)
user[pid] = value;
// if (pid >= NOF_ADC_VALUES / 2)
// user[pid] = value;
// reset encoder value if associated through selectedPid to avoid skipping
for (int i = 0; i < NOF_ENCODERS; ++i)
if (selectedPid[i] == pid)
Expand Down
4 changes: 2 additions & 2 deletions Bluemchen/Src/Bluemchen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int16_t getParameterValue(uint8_t pid) {
void setParameterValue(uint8_t pid, int16_t value) {
if (pid < NOF_PARAMETERS) {
if (pid < NOF_ADC_VALUES / 2) {
takeover.set(pid, value);
takeover.set(pid, __USAT(value, 12));
takeover.reset(pid, false);
graphics.params.setValue(pid, takeover.get(pid));
}
Expand Down Expand Up @@ -80,7 +80,7 @@ void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t*
#endif
for (int i = 0; i < NOF_ADC_VALUES / 2; i++) {
// CV ADC channels are inverted
takeover.update(i, smooth_adc_values[i * 2] + 4095 - smooth_adc_values[i * 2 + 1] * 2, 31);
takeover.update(i, __USAT(smooth_adc_values[i * 2] + 4220 - smooth_adc_values[i * 2 + 1] * 2, 12), 31); // We don't quite cover full range with 4095 due to DC offset?
graphics.params.updateValue(i, takeover.get(i));
}
}
Expand Down

0 comments on commit a180745

Please sign in to comment.