Example #1
0
        private void CreateKeys()
        {
            _listKey = new List<Key>();
            ListUIChildren = new List<UIComponent>();
            countWhite = 0;

            for (int octave = 0; octave < 8; octave++)
            {
                for (int note = 0; note < 12; note++)
                {
                    if (octave * 12 + note < 88)
                    {
                        int realOctave = GetRealOctave(octave, note);
                        Key key = new Key(this, UI, GetNewTimeSpan(), _noteTable[note], realOctave, octave * 12 + note, countWhite, GetFrequency(octave, note + 1));
                        key.ClickKey += new Key.ClickKeyHandler(key_ClickKey);

                        _listKey.Add(key);
                        ListUIChildren.Add(key);

                        if (key.White)
                            countWhite++;
                    }
                }
            }

            ListUIChildren.Sort((x, y) => (((Key)x).White ? 0 : 1) - (((Key)y).White ? 0 : 1));

            foreach (UIComponent component in ListUIChildren)
            {
                component.CreationTime = GetNewTimeSpan();
            }
        }
Example #2
0
 void key_ClickKey(Key key, MouseState mouseState, GameTime gameTime)
 {
     PerformNote(key);
 }
Example #3
0
 public void PerformNote(Key key)
 {
     PerformNote(key.NoteKey, key.NoteName);
 }
Example #4
0
 public void AddNote(Key key)
 {
     AddNote(key.NoteKey, 1f, key.NoteName);
 }