I have this code but I'm trying to learn how to make it more concise. Each function does the same thing only with a different array of notes (numbers) Does anyone see a good way to go about making it more concise, while being easy to follow? It's one function that calls 1 of 4 others, but the 4 others are almost identical.
thanks.
ps.
SeventhMode() & MinorMode() simple return true or false...
void autoArpeggio(int i) { //play arpeggio for the note (i) automatically
if (SeventhMode()) { //play 7th mode
if (MinorMode()) playMinorSeventh(i); //play the minor seventh scale
else playSeventh(i); //play the seventh scale
}
else if (MinorMode()) playMinor(i); //play the minor scale
else playNormal(i); //play the normal scale
}
void playNormal(int theNote){
byte autoScale[] = {
0,4,7,12,16,19,24,28,31,36 };
int s = sizeof(autoScale);
for (int i = 0; i < s; i++) {
int j = theNote + autoScale[i];
midiOut(j);
delay(autoDelay);
}
}
void playMinor(int theNote){
byte autoScale[] = {
0,3,7,12,15,19,24,27,31,36 };
int s = sizeof(autoScale);
for (int i = 0; i < s; i++) {
int j = theNote + autoScale[i];
midiOut(j);
delay(autoDelay);
}
}
void playSeventh(int theNote){
byte autoScale[] = {
0,4,7,10,12,16,19,22,24,28,31,34,36 };
int s = sizeof(autoScale);
for (int i = 0; i < s; i++) {
int j = theNote + autoScale[i];
midiOut(j);
delay(autoDelay);
}
}
void playMinorSeventh(int theNote){
byte autoScale[] = {
0,3,7,10,12,15,19,22,24,27,31,34,36 };
int s = sizeof(autoScale);
for (int i = 0; i < s; i++) {
int j = theNote + autoScale[i];
midiOut(j);
delay(autoDelay);
}
}