hello,
I have been working on creating midi notes and other midi commands from a softPot ribbon potentiometer. The only issue I am having, is that it is not very accurate. I achieve precise accuracy with rotary pots; however, I am having difficulty with optimizing my code for a softpot. Essentially, I wish to know exactly where middle C is everytime and have equal intervals between each note (this right now is a bit erratic)...
As seen in the code below, I am attempting to define a starting note and an ending note for an interval range on a 500mm pot. I have seen this quote from tom scarff: "For a 18 inch (500 mm) long ribbon controller with 3/4" finger, number of notes would be 24"
This statement makes sense, but I need to figure out some equation or subroutine to calibrate this. For now I am using a -1 to t range so that I don't hit notes too close to each other; however, this is not musically accurate.
#include <ardumidi.h>
/* Pin constants */
const int positionSensorPin = A0;
#define START_NOTE 60
#define END_NOTE 84 //24 note range
#define RIBBON_MIDI_CHANNEL_0 1
//----------VARIABLES----------//
int note; //0-1023 position from positionSensorPin
int notePrev = 0;
int velocity = 100;
//int noteStateFlag = 0;
/* 0= noNote 1=midi_on 2=pitch_bend 3=noteOff */
void setup() {
Serial.begin(115200);
}
void loop() {
note = analogRead(positionSensorPin) / 8;
note = map(note, 0, 127, 50, 100);
// potentiometer could be too sensitive and give different (+-1) values.
if ((note - notePrev) > 1 || (note - notePrev) < -1) {
// has the value changed?
if (note != notePrev) {
midi_note_on(RIBBON_MIDI_CHANNEL_0, note, velocity);
notePrev = note;
}
else {
midi_note_off(RIBBON_MIDI_CHANNEL_0, note, velocity);
}
}
}[code]