예제 #1
0
        private void UpdateGuess()
        {
            List <Note> notes = new List <Note>();
            byte        root  = 0;

            if (chkNote1.Checked)
            {
                switch (chordNote1.Text)
                {
                case "C":
                    root = 0;
                    break;

                case "D":
                    root = 2;
                    break;

                case "E":
                    root = 4;
                    break;

                case "F":
                    root = 5;
                    break;

                case "G":
                    root = 7;
                    break;

                case "A":
                    root = 9;
                    break;

                case "B":
                    root = 11;
                    break;
                }
                if (cna1.Text == "sharp")
                {
                    root++;
                }
                else if (cna1.Text == "flat")
                {
                    root--;
                }
                notes.Add(new Note(root));
            }
            if (chkNote2.Checked)
            {
                switch (chordNote2.Text)
                {
                case "C":
                    root = 0;
                    break;

                case "D":
                    root = 2;
                    break;

                case "E":
                    root = 4;
                    break;

                case "F":
                    root = 5;
                    break;

                case "G":
                    root = 7;
                    break;

                case "A":
                    root = 9;
                    break;

                case "B":
                    root = 11;
                    break;
                }
                if (cna2.Text == "sharp")
                {
                    root++;
                }
                else if (cna2.Text == "flat")
                {
                    root--;
                }
                notes.Add(new Note(root));
            }
            if (chkNote3.Checked)
            {
                switch (chordNote3.Text)
                {
                case "C":
                    root = 0;
                    break;

                case "D":
                    root = 2;
                    break;

                case "E":
                    root = 4;
                    break;

                case "F":
                    root = 5;
                    break;

                case "G":
                    root = 7;
                    break;

                case "A":
                    root = 9;
                    break;

                case "B":
                    root = 11;
                    break;
                }
                if (cna3.Text == "sharp")
                {
                    root++;
                }
                else if (cna3.Text == "flat")
                {
                    root--;
                }
                notes.Add(new Note(root));
            }
            if (chkNote4.Checked)
            {
                switch (chordNote4.Text)
                {
                case "C":
                    root = 0;
                    break;

                case "D":
                    root = 2;
                    break;

                case "E":
                    root = 4;
                    break;

                case "F":
                    root = 5;
                    break;

                case "G":
                    root = 7;
                    break;

                case "A":
                    root = 9;
                    break;

                case "B":
                    root = 11;
                    break;
                }
                if (cna4.Text == "sharp")
                {
                    root++;
                }
                else if (cna4.Text == "flat")
                {
                    root--;
                }
                notes.Add(new Note(root));
            }

            Chord cTest, cGot;

            cGot = new Chord(notes);

            possibleChords.Items.Clear();

            foreach (Note n in notes)
            {
                for (byte t = 0; t < 15; t++)
                {
                    cTest = new Chord(n, t, new Scale(0, ScaleNames.Any));
                    if (cTest.IsSameAs(cGot))
                    {
                        possibleChords.Items.Add(cTest.ToString());
                    }
                }
            }
        }