Ejemplo n.º 1
0
        public void SetScaleNotes()
        {
            int      counter            = 0;
            PianoKey previousKeyInScale = null;

            foreach (PianoKey key in allKeys)
            {
                if (counter == 0 && key.note == rootNote && key.octave == 4)
                {
                    Console.WriteLine("Adding the root note + " + key.note + "...");
                    keys.Add(key);
                    previousKeyInScale = key;
                    counter++;
                }
            }

            foreach (string interval in intervalString)
            {
                Console.WriteLine(interval);
            }

            foreach (PianoKey k in allKeys)
            {
                Console.WriteLine(k.midiNoteNumber);
            }

            counter = 0;

            foreach (string interval in intervalString)
            {
                Console.WriteLine(counter);
                if (intervalString[counter] == "W")
                {
                    Console.WriteLine("Adding a whole step...");
                    keys.Add(allKeys.Find(item => item.midiNoteNumber == (previousKeyInScale.midiNoteNumber + 2)));
                    Console.WriteLine(keys.Count + " keys in the scale");
                    //previousKeyInScale = keys[keys.Count - 1];
                }
                else if (intervalString[counter] == "H")
                {
                    Console.WriteLine("Adding a half step...");
                    keys.Add(allKeys.Find(item => item.midiNoteNumber == (previousKeyInScale.midiNoteNumber + 1)));
                    Console.WriteLine(keys.Count + " keys in the scale");
                    //previousKeyInScale = keys[keys.Count - 1];
                }

                Console.WriteLine("There are: " + keys.Count + " Keys in the scale right now");

                Console.WriteLine("Just added the note: " + keys[keys.Count - 1].note);
                previousKeyInScale = keys[keys.Count - 1];
                counter++;
            }
        }
Ejemplo n.º 2
0
        public void SetupChord()
        {
            if (chordType == "Major" || chordType == "Minor")
            {
                keys.Add(scaleKeys[0]);
                keys.Add(scaleKeys[2]);
                keys.Add(scaleKeys[4]);
            }
            else if (chordType == "Augmented")
            {
                keys.Add(scaleKeys[0]);
                keys.Add(scaleKeys[2]);

                PianoKey keyToRaise = scaleKeys[4];

                foreach (PianoKey k in allKeys)
                {
                    //Console.WriteLine("Comparing : " + k.midiNoteNumber + " and " + keyToRaise.midiNoteNumber);
                    if (k.midiNoteNumber - 1 == keyToRaise.midiNoteNumber)
                    {
                        keys.Add(k);
                    }
                }
            }
            else if (chordType == "Diminished")
            {
                keys.Add(scaleKeys[0]);


                PianoKey keyToLower = scaleKeys[2];

                foreach (PianoKey k in allKeys)
                {
                    //Console.WriteLine("Comparing : " + k.midiNoteNumber + " and " + keyToRaise.midiNoteNumber);
                    if (k.midiNoteNumber + 1 == keyToLower.midiNoteNumber)
                    {
                        keys.Add(k);
                    }
                }


                keyToLower = scaleKeys[4];

                foreach (PianoKey k in allKeys)
                {
                    //Console.WriteLine("Comparing : " + k.midiNoteNumber + " and " + keyToRaise.midiNoteNumber);
                    if (k.midiNoteNumber + 1 == keyToLower.midiNoteNumber)
                    {
                        keys.Add(k);
                    }
                }
            }
        }