I have built a synth controller instrument with Teensy 3.5 and the audio library as its basis. I am using a custom analog voltage divider as an input to an ADC on the teensy, which is then fed to a waveform object after scaling to usable frequency range via the map() function like this:
float EinputToPitch(float input)
{
float n = map(input, 16500, 32400, 164.81/2, 164.81);
return n;
}
'input' is the raw ADC data and the numbers 16500 and 32400 are empirically determined per the voltage divider's characteristics. The output drives the frequency of a waveform fuction from the teensy audio library:
void loop()
{
// read the pitch pot position
int eNewPitch = analogRead(E_PITCH_POT);
waveform1.frequency(EinputToPitch(eNewPitch));
This affords a very lovely and accurate control of the pitch, but I would also like to play the instrument with pitches quantized to the western musical scale (or other scale).
This is my question: I assume I'm not the first person to want to quantize pitch in a DIY musical instrument controller. I've looked here and in Arduino forums but haven't found a solution, and I'm not really a programmer. So...
Does anyone have or know where to look for a function to quantize a data stream to values in a musical scale?
Appreciate any attention you can give to this. First post (I think)... Apologies if this is not the proper forum for it.
Cheers,
Brandon
float EinputToPitch(float input)
{
float n = map(input, 16500, 32400, 164.81/2, 164.81);
return n;
}
'input' is the raw ADC data and the numbers 16500 and 32400 are empirically determined per the voltage divider's characteristics. The output drives the frequency of a waveform fuction from the teensy audio library:
void loop()
{
// read the pitch pot position
int eNewPitch = analogRead(E_PITCH_POT);
waveform1.frequency(EinputToPitch(eNewPitch));
This affords a very lovely and accurate control of the pitch, but I would also like to play the instrument with pitches quantized to the western musical scale (or other scale).
This is my question: I assume I'm not the first person to want to quantize pitch in a DIY musical instrument controller. I've looked here and in Arduino forums but haven't found a solution, and I'm not really a programmer. So...
Does anyone have or know where to look for a function to quantize a data stream to values in a musical scale?
Appreciate any attention you can give to this. First post (I think)... Apologies if this is not the proper forum for it.
Cheers,
Brandon