Hi,
Just a quick note to mention that I have updated the code previously posted. You will see the update as follows in the previous post -
// Duane B 08/11/2012
// change the function to take an unmapped analog input
// and do the mapping to the note range of the scale inside the function
// instead of in loop
unsigned int getPentatonicPhaseIncrement(unsigned int nAnalogInput)
{
// map the analog input value from 0,1024 to 0 to the number of notes in our scale
uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,PENTATONIC_NOTES);
uint8_t sMidiIndex = pgm_read_byte(sPentatonicNotes + sPentatonicNote);
return pgm_read_word(midiNoteToWavePhaseIncrement + sMidiIndex);
}
As you can see the getPentatonicPhaseIncrement now accepts a value from an analogInput i.e. 0 to 1024
unsigned int getPentatonicPhaseIncrement(unsigned int nAnalogInput)
and internally does the mapping to the number of notes in the given scale -
uint8_t sPentatonicNote = map(nAnalogInput,0,1024,0,PENTATONIC_NOTES);
which it then uses to acces the PROGMEM array which maps from scale note number to midi note number
Which it then uses to fetch the required phase increment for play back at an 8Mhz sample rate which is the interrupt rate of the Auduino, IllutronB and most other Arduino based synths.
I have not had chance to test this, but the logic is right, if anyone is able to test and finds a problem, let me know.
Duane B