string RootToChord() { string chord = ""; uint root = instrument.GetRootNote() % 12; switch (root) { case 0: chord = "C"; break; case 1: chord = "C#"; break; case 2: chord = "D"; break; case 3: chord = "D#"; break; case 4: chord = "E"; break; case 5: chord = "F"; break; case 6: chord = "F#"; break; case 7: chord = "G"; break; case 8: chord = "G#"; break; case 9: chord = "A"; break; case 10: chord = "A#"; break; case 11: chord = "B"; break; } bool isMinor = instrument.thirdOffset == -1; if (isMinor) { chord += "m"; } switch (instrument.highOffset) { case -3: chord += "6"; break; case -2: chord += "7"; break; case -1: chord += "M7"; break; case 1: chord += "b9"; break; case 2: chord += "9"; break; } return(chord); }
void Update() { rootSinger.SetOffset(instrument.GetRootNote()); thirdSinger.SetOffset(instrument.GetThirdNote()); fifthSinger.SetOffset(instrument.GetFifthNote()); highSinger.SetOffset(instrument.GetHighNote()); if (Input.GetKeyDown(KeyCode.Alpha1)) { instrument.rootOffset = 0; } else if (Input.GetKeyDown(KeyCode.Alpha2)) { instrument.rootOffset = 2; } else if (Input.GetKeyDown(KeyCode.Alpha3)) { instrument.rootOffset = 4; } else if (Input.GetKeyDown(KeyCode.Alpha4)) { instrument.rootOffset = 5; } else if (Input.GetKeyDown(KeyCode.Alpha5)) { instrument.rootOffset = 7; } else if (Input.GetKeyDown(KeyCode.Alpha6)) { instrument.rootOffset = 9; } else if (Input.GetKeyDown(KeyCode.Alpha7)) { instrument.rootOffset = 11; } else if (Input.GetKeyDown(KeyCode.Alpha8)) { instrument.rootOffset = 12; } if (Input.GetKeyDown(KeyCode.Space)) { instrument.thirdOffset = -1; } else if (Input.GetKeyUp(KeyCode.Space)) { instrument.thirdOffset = 0; } if (Input.GetKeyDown(KeyCode.RightArrow)) { instrument.triangular = !instrument.triangular; } if (Input.GetKeyDown(KeyCode.LeftArrow)) { instrument.glissando = !instrument.glissando; } if (Input.GetKeyDown(KeyCode.DownArrow)) { instrument.sustain = !instrument.sustain; } if (Input.GetKey(KeyCode.R)) { instrument.highOffset = 4; } else if (Input.GetKey(KeyCode.E)) { instrument.highOffset = 3; } else if (Input.GetKey(KeyCode.W)) { instrument.highOffset = 2; } else if (Input.GetKey(KeyCode.Q)) { instrument.highOffset = 1; } else if (Input.GetKey(KeyCode.F)) { instrument.highOffset = -1; } else if (Input.GetKey(KeyCode.D)) { instrument.highOffset = -2; } else if (Input.GetKey(KeyCode.S)) { instrument.highOffset = -3; } else if (Input.GetKey(KeyCode.A)) { instrument.highOffset = -4; } else { instrument.highOffset = 0; } if (Input.GetKeyDown(KeyCode.U)) { PlayRootNote(); } else if (Input.GetKeyUp(KeyCode.U)) { StopRootNote(); } if (Input.GetKeyDown(KeyCode.I)) { PlayThirdNote(); } else if (Input.GetKeyUp(KeyCode.I)) { StopThirdNote(); } if (Input.GetKeyDown(KeyCode.O)) { PlayFifthNote(); } else if (Input.GetKeyUp(KeyCode.O)) { StopFifthNote(); } if (Input.GetKeyDown(KeyCode.P)) { PlayHighNote(); } else if (Input.GetKeyUp(KeyCode.P)) { StopHighNote(); } if (Input.GetKeyDown(KeyCode.Return)) { PlayRootNote(); PlayThirdNote(); PlayFifthNote(); } else if (Input.GetKeyUp(KeyCode.Return)) { StopRootNote(); StopThirdNote(); StopFifthNote(); } #if UNITY_STANDALONE if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } #endif }