byte note;

//byte numRemainder;

int scaleMode = 1;  // 1 = Maj, 2 = min, etc.

bool sharpKeyFLAG = true;


void setup() {

  Serial.begin(9600);
  
}

void loop() {

  note = random(8, 127);

  findNoteName(note);

	makeChord();

	makeScale();

  delay(2345);

}



void findNoteName(byte nowNote) {

  //Serial.print("the note is: ");
 
  byte numRemainder = nowNote % 12;  // this is the money maker
  
  switch (numRemainder) {
  
  case 0:
		Serial.print("A"); // should be C, change others accordingly
		Serial.print("  ");
		break;
	case 1:
	  if (sharpKeyFLAG == true) Serial.print("A#");
		else Serial.print("Bb");
		Serial.print("  ");
		break;
	case 2:
		Serial.print("B");
		Serial.print("  ");
		break;
	case 3:
		Serial.print("C");
		Serial.print("  ");
		break;
	case 4:
		if (sharpKeyFLAG == true) Serial.print("C#");
    else Serial.print("Db");
		Serial.print("  ");
		break;
	case 5:
		Serial.print("D");
		Serial.print("  ");
		break;
	case 6:
		if (sharpKeyFLAG == true) Serial.print("D#");
		else Serial.print("Eb");
		Serial.print("  ");
		break;
	case 7:
		Serial.print("E");
		Serial.print("  ");
		break;
	case 8:
		Serial.print("F");
		Serial.print("  ");
		break;
	case 9:
		if (sharpKeyFLAG == true) Serial.print("F#");
		else Serial.print("Gb");
		Serial.print("  ");
		break;
	case 10:
		Serial.print("G");
		Serial.print("  ");
		break;
	case 11:
		if (sharpKeyFLAG == true) Serial.print("G#");
	else Serial.print("Ab");
		Serial.print("  ");
		break;
  
  } // switch numRemainder

}




void makeChord() {

  // M7 CHORD
	byte c_3  = (note + 4);
	findNoteName(c_3);
	byte c_5  = (note + 7);
	findNoteName(c_5);
	byte c_7  = (note + 11); 
	findNoteName(c_7);
	byte c_9  = (note + 14); 
	findNoteName(c_9);
	byte c_11 = (note + 17);
	findNoteName(c_11);
	byte c_13 = (note + 21);
	findNoteName(c_13);

	Serial.println();

} // makeChord




void makeScale() {

	byte s_2;
	byte s_3;
	byte s_4;
	byte s_5;
	byte s_6;
	byte s_7;


// make this a switch statement with other scales:
	if (scaleMode == 1) {
		s_2 = note + 2;
		s_3 = note + 4;
		s_4 = note + 5;
		s_5 = note + 7;
		s_6 = note + 9;
		s_7 = note + 11;
	}

  findNoteName(note);
  findNoteName(s_2);
  findNoteName(s_3);
  findNoteName(s_4);
  findNoteName(s_5);
  findNoteName(s_6);
  findNoteName(s_7);	

	Serial.println();

} // makeScale