int controlChange = 176; // MIDI Channel 1
int controllerNumber = 21;
int indexOld = 0;
int index = 0;
int potiValue = 0;
int scalePoti=0;
int scaleValue=0;
// *********************************
// SCALE INFORMATION:
// *********************************
// *** A Major *** COUNT: 0
const int Amaj0[] = {57,59,61,62,64,66,68,69};
const char *Amaj0Names[] = {"A6", "B6", "C#6", "C6", "E6", "F#6", "G#6", "A7"};
// *** A Major 1*** COUNT: 1
int Amaj1[] = {69,71,73,74,76,78,80,81};
// *** B Major *** COUNT: 2
int Bmaj0[] = {59,61,63,64,66,68,70,71};
// *** B Major 1*** COUNT: 3
int Bmaj1[] = {71,73,75,76,78,80,82,83};
// *** C Major *** COUNT: 4
int Cmaj0[] = {60,62,64,65,67,69,71,72};
// *** C Major 1 *** COUNT: 5
int Cmaj1[] = {72,74,76,77,79,81,83,84};
// *** D Major *** COUNT: 6
int Dmaj0[] = {62,64,66,67,69,71,73,74};
// *** D Major 1*** COUNT: 7
int Dmaj1[] = {74,76,78,79,81,83,85,86};
// *** E Major *** COUNT: 8
int Emaj0[] = {64,66,68,69,71,73,75,76};
// *** E Major 1*** COUNT: 9
int Emaj1[] = {76,78,80,81,83,85,87,88};
// *** F Major *** COUNT: 10
int Fmaj0[] = {65,67,69,70,72,74,76,77};
// *** F Major 1*** COUNT: 11
int Fmaj1[] = {77,79,81,82,84,86,88,89};
// *** G Major *** COUNT: 12
int Gmaj0[] = {55,57,59,60,62,64,66,67};
// *** G Major 1*** COUNT: 13
int Gmaj1[] = {67,69,71,72,74,76,78,79};
// *** G Mixolydian*** COUNT: 14
int Gmix[] = {81,83,84,86,88,89,79,81};
// *** Pentatonic*** COUNT: 15
int Pent[] = {0,2,4,7,9};
// *** Pentatonic 8*** COUNT: 16
int Pent8[] = {84,86,88,91,93};
// *** Blues*** COUNT: 17
int Blue[] = {0,2,3,4,5,7,9,10,11};
// *** Bluz 10*** COUNT: 18
int Bluz[] = {108,110,111,112,113,115,117,118,119};
// *** Phrygian 5*** COUNT: 19
int Phry5[] = {48,49,51,53,55,56,58};
// **********************************************
// ******* END OF SCALE INFORMATION ********
// **********************************************
void setup() {
Serial.begin(31250);
}
void loop() {
scalePoti = analogRead(A1);
scaleValue = (scalePoti * 19) / 1024;
// Display scaleValue
if (scaleValue = 0) {
potiValue = analogRead(A0);
int index = (potiValue * 8) / 1024;
// Play this note: Amaj0[index]
// Display this name: Amaj0Names[index]
}
if (index != indexOld) {
Serial.write((byte)0x91); // NoteOn, Channel 1
Serial.write((byte)Amaj0[index]);
Serial.write((byte)127); // Maximum Velocity (loud)
}
indexOld = index;
}
Would this work if I wrote if-orders for all the other scales (like I did it wit A Major -> Amaj0)?
Or is there a better or easier way to do that (Choose musical scale from 0 - 19 and play the corresponding notes via a potentiometer)?