Skip to content

Pitch Bend pots with individual map ranges? #483

Answered by tttapa
PuttyStudios asked this question in Q&A
Discussion options

You must be logged in to vote

You could use something like this:

#include <Control_Surface.h>

USBMIDI_Interface midi;

PBPotentiometer potentiometers[] = {
  { A0, CHANNEL_1, },
  { A1, CHANNEL_2, },
};
 
template <analog_t MinVal, analog_t MaxVal>
analog_t mappingFunction(analog_t raw) {
    raw = constrain(raw, MinVal, MaxVal);
    return map(raw, MinVal, MaxVal, 0, FilteredAnalog<>::getMaxRawValue());
}

void setup() {
  potentiometers[0].map(mappingFunction<10000, 12000>);
  potentiometers[1].map(mappingFunction<8000, 14000>);
  Control_Surface.begin();
}
 
void loop() {
  Control_Surface.loop();
}

Replies: 3 comments 10 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@klausnielsen
Comment options

@tttapa
Comment options

@klausnielsen
Comment options

@tttapa
Comment options

@klausnielsen
Comment options

Answer selected by PuttyStudios
Comment options

You must be logged in to vote
4 replies
@tttapa
Comment options

@mattibatti
Comment options

@tttapa
Comment options

@mattibatti
Comment options

# for free to join this conversation on GitHub. Already have an account? # to comment
Category
Q&A
Labels
None yet
4 participants