예제 #1
0
        public static ObservableCollection<int> Create_DefaultVoicing(PianoKey.KeyTypes keyType, PianoLibrary.Model.Chords.ChordDefinition.Modes mode)
        {
            ObservableCollection<int> notes = new ObservableCollection<int>();

            int offset = Piano.GetOffset(keyType);

            // Add Base (1 at Octave 3)
            notes.Add((12 * 2) + offset);

            // Chord root
            notes.Add((12 * 3 ) + offset);

            // Chord 3rd
            if (mode == PianoLibrary.Model.Chords.ChordDefinition.Modes.Major)
            {
                notes.Add((12 * 3)+ offset + 4);
            }
            else
            {
                notes.Add((12 * 3) + offset + 3);
            }

            // Chord 5th
            notes.Add((12 * 3) + offset + 7);

            return notes;
        }
예제 #2
0
 public static int GetKeyOffset(PianoKey.KeyTypes keyType)
 {
     switch (keyType)
     {
         case PianoKey.KeyTypes.A:
             {
                 return 0;
             }
         case PianoKey.KeyTypes.ASharp:
             {
                 return 8;
             }
         case PianoKey.KeyTypes.B:
             {
                 return 10;
             }
         case PianoKey.KeyTypes.C:
             {
                 return 20;
             }
         case PianoKey.KeyTypes.CSharp:
             {
                 return 26;
             }
         case PianoKey.KeyTypes.D:
             {
                 return 30;
             }
         case PianoKey.KeyTypes.DSharp:
             {
                 return 38;
             }
         case PianoKey.KeyTypes.E:
             {
                 return 40;
             }
         case PianoKey.KeyTypes.F:
             {
                 return 50;
             }
         case PianoKey.KeyTypes.FSharp:
             {
                 return 56;
             }
         case PianoKey.KeyTypes.G:
             {
                 return 60;
             }
         case PianoKey.KeyTypes.GSharp:
             {
                 return 67;
             }
         default:
             {
                 return 10000;
             }
     }
 }
예제 #3
0
        public static Polygon GetKeyShape(PianoKey.KeyTypes keyType, bool isLeftEdge, bool isRightEdge)
        {
            // White 10 width
            // Black 6 with
            // black 4 inside the white in the outside. (...?)

            Polygon p = new Polygon();
            p.Stroke = Brushes.Black;

            if (isLeftEdge)
            {
                return LeftKey();
            }
            if (isRightEdge)
            {
                return NormalKey();
            }

            switch (keyType)
            {
                case PianoKey.KeyTypes.C:
                    {
                        return LeftKey();
                    }
                case PianoKey.KeyTypes.D:
                    {
                        return MiddleKey();
                    }
                case PianoKey.KeyTypes.E:
                    {
                        return RightKey();
                    }
                case PianoKey.KeyTypes.F:
                    {
                        return LeftKey();
                    }
                case PianoKey.KeyTypes.G:
                    {
                        return G();
                    }
                case PianoKey.KeyTypes.A:
                    {
                        return A();
                    }
                case PianoKey.KeyTypes.B:
                    {
                        return RightKey();
                    }
                default:
                    {
                        return BlackKey();
                    }

            }
        }
예제 #4
0
        protected virtual void GeneratePiano()
        {
            PianoKey.KeyTypes currentKey = PianoKey.KeyTypes.A;
            short octave = 0;

            for (int i = 0; i < 88; i++)
            {
                if (currentKey == PianoKey.KeyTypes.A) { octave++; }
                Keys[i] = new PianoKey(currentKey, octave);
                currentKey = PianoKey.NextKey(currentKey);
            }
        }
예제 #5
0
 public static int GetOffset(PianoKey.KeyTypes key)
 {
     IList<PianoKey.KeyTypes> keys = Enum.GetValues(typeof(PianoKey.KeyTypes)).Cast<PianoKey.KeyTypes>().ToList<PianoKey.KeyTypes>();
     return keys.ToList<PianoKey.KeyTypes>().IndexOf(key);
 }