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

Status
Not open for further replies.

trevorbryden

Active member
Hi!

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.

Thanks!
 
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):

Code:
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++){
Serial.println(potmap[i]);
}
}


void loop() {
    
}
 
No need for an array. You could have a function to read the pot similar to this:
Code:
int last_pot = 0;
void read_pot(void)
{
  int i = analogRead(POT);
  if(i == last_pot)return;
  last_pot = i;    
  if(i < 500) {
    set_chorus(i+0.002);
    return;
  }
  if(i < 523)return;
  set_reverb(i - 523 + 0.002);
}

You'll have to add the functions to set the chorus and reverb.

Pete
 
Status
Not open for further replies.
Back
Top