#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
int maVariable = 10;
const char* nomVariable = TOSTRING(maVariable);
const int CHORD_SIZE = 3;
const int SCALE_SIZE = 3;
const int MODE_SIZE = 3;
int C1[CHORD_SIZE] = {1, 2, 3};
int C2[CHORD_SIZE] = {4, 5, 6};
int C3[CHORD_SIZE] = {7, 8, 9};
int C4[CHORD_SIZE] = {11, 12, 13};
int* S1[SCALE_SIZE] = {C1, C2, C3};
int* S2[SCALE_SIZE] = {C2, C3, C1};
int* S3[SCALE_SIZE] = {C3, C1, C4};
int** Modes[MODE_SIZE] = {S1, S2, S3};
const char* scaleNames[] = {"Mode A", "Mode B ", "Mode C "};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
// list all modes by scale and chord
for (int i = 0; i < MODE_SIZE; i++) {
Serial.print("Mode ");
Serial.println(i + 1);
for (int j = 0; j < SCALE_SIZE; j++) {
Serial.print(" Scale ");
Serial.print(j + 1);
Serial.print(" Scale Name : ");
Serial.println(scaleNames[j]);
for (int k = 0; k < CHORD_SIZE; k++) {
Serial.print(" Chord ");
Serial.print(k + 1);
Serial.print(": ");
for (int l = 0; l < CHORD_SIZE; l++) {
Serial.print(Modes[i][j][l]);
Serial.print(" ");
}
Serial.println();
}
}
}
Serial.println("-------------------------------------------");
// access to a particular chord
Serial.println("Extract value ");
Serial.println(Modes[2][2][2]); // should output 13
Serial.println("Extract whole array ");
int extractedArray = Modes[2][2] ;
printArrayAsString(extractedArray, CHORD_SIZE); // should output 13
Serial.println("var string from var name ");
Serial.println(nomVariable);
}
void loop() {
// put your main code here, to run repeatedly:
}
void printArrayAsString(int array[], int size) {
String result = "[";
for (int i = 0; i < size; i++) {
result += String(array[i]);
if (i < size - 1) {
result += ", ";
}
}
result += "]";
Serial.println(result);
}