Hi all…
I have been designing a small synth with the Dsp g1 synth chip with the arduino. I need to keep hardware UI small and so keep buttons and knobs to a minimum.
I have set up a sketch to control the midi cc via potnetiometers and there are 16 midi cc to control in total.
Rather than use 16 pots to control everything i was hoping it might be possible to setup just 4 potentiometers and switch between the midi cc…
for example…
if pots 1-4 are set to midi cc 77, 70, 79, 71 then at the touch of a button the pots set to different group of 4 midi cc…
This way i can use just 4 Pots to control all 16 Parameters of the synth…
Could someone give me some help or pointers on how i might implements a way to switch the 4 pots to different midi controllers… i have included my sketch that uses 4 knobs set to control 4 different midi cc’s
im new to programming in the arduino and programming in general so im sorry for my ignorance if this is a trivial task…
thanks in advance.
nathan
/*
* edited from roguescience sketch
*
*
* digital pin 11 (OUTPUT/PWM) --> LED
* digital pin 2 (INPUT) <-- button
* analog pin 0 <-- pot
* tx1 <-- pin 5 (5 PIN DIN aka MIDI jack)
*
* Send a MIDI note when the button is pressed and sends MIDI
* CC data when a potentiometer is turned.
*/
int ledPin = 11; //choose the pin for the LED - needs to be (3,5,6,9,10, or 11)
int ledPin2 = 10; //choose the pin for the LED - needs to be (3,5,6,9,10, or 11)
int ledPin3 = 9; //choose the pin for the LED - needs to be (3,5,6,9,10, or 11)
int ledPin4 = 6; //choose the pin for the LED - needs to be (3,5,6,9,10, or 11)
int buttonPin = 2; //choose the input pin for a pushbutton
int potPin = 0; //choose the input pin for a potentometer
int potPin2 = 1; //choose the input pin for a potentometer 2 filter
int potPin3 = 2; //choose the input pin for a potentometer 3
int potPin4 = 3; //choose the input pin for a potentometer 4
int buttonVal = 0; //variable for reading the button status
int buttonState = 0; //variable to hold the buttons current state
int bounceCheck = 0; //variable for debouncing
int potVal = 0; //variable for reading potentiometer value
int potVal2 = 0; //variable for reading potentiometer 2 filter value
int potVal3 = 0; //variable for reading potentiometer 3 value
int potVal4 = 0; //variable for reading potentiometer 3 value
int mappedPotVal = 0; //variable for holding remapped pot filter value
int mappedPotVal2 = 0; //variable for holding remapped pot 2 filter value
int mappedPotVal3 = 0; //variable for holding remapped pot 3 value
int mappedPotVal4 = 0; //variable for holding remapped pot 3 value
int prevPotVal = 0; //variable for storing our prev pot value
int prevPotVal2 = 0; //variable for storing our prev pot value
int prevPotVal3 = 0; //variable for storing our prev pot value
int prevPotVal4 = 0; //variable for storing our prev pot value LAST PHYSICAL POT
int THRESHOLD = 2; //threshold amount
void setup() {
pinMode(ledPin, OUTPUT); //declare LED as output
pinMode(ledPin2, OUTPUT); //declare LED as output
pinMode(ledPin3, OUTPUT); //declare LED as output
pinMode(ledPin4, OUTPUT); //declare LED as output
pinMode(buttonPin, INPUT); //declare pushbutton as input
Serial.begin(31250); //MIDI communicates at 31250 baud
}
void loop(){
buttonVal = digitalRead(buttonPin); //read input value from button
delay(10); //wait 10ms
bounceCheck = digitalRead(buttonPin); //check again
if(buttonVal == bounceCheck){ //if val is the same then not a bounce
if (buttonVal == HIGH && buttonState == 1) { //check if the input is HIGH
digitalWrite(ledPin, LOW); //turn LED OFF
midiOUT(0x90, 1, 0); //Note ON (CH 1), middle C, zero velocity turns note off
buttonState = 0;
}
if(buttonVal == LOW && buttonState == 0){
digitalWrite(ledPin, HIGH); //turn LED ON
midiOUT(0x90, 1, 127); //Note ON (CH 1), middle C, velocity 127
buttonState = 1;
}
}
potVal = analogRead(potPin); //read input from potentiometer
mappedPotVal = map(potVal, 0, 1023, 0, 127); //map value to 0-127
if(abs(mappedPotVal - prevPotVal) >= THRESHOLD){
midiOUT(0xB0, 7, mappedPotVal); //Control Change (Ch 1), Controller 7 - default control for volume.
digitalWrite(ledPin, HIGH);
prevPotVal = mappedPotVal;
}
else{
digitalWrite(ledPin, LOW);
}
potVal2 = analogRead(potPin2); //read input from potentiometer
mappedPotVal2 = map(potVal2, 0, 1023, 0, 127); //map value to 0-127
if(abs(mappedPotVal2 - prevPotVal2) >= THRESHOLD){
midiOUT(0xB0, 74, mappedPotVal2); //Control Change (Ch 1), Controller 7 - default control for volume.
digitalWrite(ledPin2, HIGH);
prevPotVal2 = mappedPotVal2;
}
else{
digitalWrite(ledPin2, LOW);
}
potVal3 = analogRead(potPin3); //read input from potentiometer
mappedPotVal3 = map(potVal3, 0, 1023, 0, 127); //map value to 0-127
if(abs(mappedPotVal3 - prevPotVal3) >= THRESHOLD){
midiOUT(0xB0, 71, mappedPotVal3); //Control Change (Ch 1), Controller 7 - default control for volume.
digitalWrite(ledPin3, HIGH);
prevPotVal3 = mappedPotVal3;
}
else{
digitalWrite(ledPin3, LOW);
}
potVal4 = analogRead(potPin4); //read input from potentiometer
mappedPotVal4 = map(potVal4, 0, 1023, 0, 127); //map value to 0-127
if(abs(mappedPotVal4 - prevPotVal4) >= THRESHOLD){
midiOUT(0xB0, 0x4C, mappedPotVal4); //Control Change (Ch 1), Controller 7 - default control for volume.
digitalWrite(ledPin4, HIGH);
prevPotVal4 = mappedPotVal4;
}
else{
digitalWrite(ledPin4, LOW);
}
}
void midiOUT(char command, char value1, char value2) {
Serial.write(command);
Serial.write(value1);
Serial.write(value2);
}