Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Do people map a synth potentiometer with an array for atypical situations?

  1. #1

    Do people map a synth potentiometer with an array for atypical situations?


    I'm making a synth and would like for a potentiometer to read analog values but I want behaviors that aren't linear.

    I want the first half-turn of the pot (the values used, for example, to go from 0-500 or so) to set an amount of chorus effect, then a 'gutter' in the middle that will represent 'off' (maybe 500-530 or so), then from 530 - 1023 I want the knob to control an amount of reverb instead.

    Is it typical in this case to create an array of 1023 elements to describe your desired values at all of these positions, and then have the analogRead values correspond to the index of that array?

    Or is there a simpler, more conventional approach?

    I plan to use knobs for multiple exclusive functions rather often from here on out in my synth designs. I'm constraining myself to knob-per-function control panels and sometimes I've already soldered up pots to every single pin of my Teensies. So I know there are other solutions possible with encoders, an LCD, some LEDs, whatever but I would also specifically know how this is done.


  2. #2
    For example, this would map what I want a potentiometer to do (and show me the table in the serial monitor so I could make sure):

    void setup() {
    float potmap[1023];
    for(int i=0;i<500;i++){
    potmap[i] = i + 0.002;
    for(int i=500;i<523;i++){
    potmap[i] = 0;
    for(int i=523;i<1024;i++){
    potmap[i] = i - 523 + 0.002;
    for(int i=0; i<1024; i++){
    void loop() {

  3. #3
    Senior Member
    Join Date
    Nov 2012
    No need for an array. You could have a function to read the pot similar to this:
    int last_pot = 0;
    void read_pot(void)
      int i = analogRead(POT);
      if(i == last_pot)return;
      last_pot = i;    
      if(i < 500) {
      if(i < 523)return;
      set_reverb(i - 523 + 0.002);
    You'll have to add the functions to set the chorus and reverb.


  4. #4
    Awesome, thanks!

  5. #5
    I do something kind of similar for case 112 (as example) at line 578 here:

    This is actually receiving MIDI CC values 0..127 but that could just as easily be a linear ADC reading. I map it into two ranges over the travel of the control (probably an encoder or a pot on a MIDI controller keyboard).

    Oh and mapf() is just my float version of Arduino's standard map():

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts