Example #1
0
        public void HandleChannelMessageKeys(int chnl, int NoteID, int Velocity, bool NoteOn = true)
        {
            //
            // Keyboard Key Pressed Channel Messages
            //
            if (NoteID < MinNote || NoteID > MaxNote)
            {
                return;
            }

            NoteMsg.SetText(NoteID.ToString());                     //display note value
            Entity CurrentKey;                                      //get the key entity

            CurrentKey = this.FindEntity("pkey" + NoteID.ToString());
            if (CurrentKey == null)
            {
                return;
            }

            SpriteRenderer sp = CurrentKey.GetComponent <SpriteRenderer>();

            //sp.renderLayer = -8;                    //same render layer for black or white key
            if (NoteOn)
            {
                outDevice.Send(new ChannelMessage(ChannelCommand.NoteOn, 0, NoteID, Velocity));
                sp.Color = Color.Blue;                                          //current key turned blue
            }
            else
            {
                outDevice.Send(new ChannelMessage(ChannelCommand.NoteOff, 0, NoteID, Velocity));
                sp.Color = Color.Yellow;                                          //current key turned white
            }
        }
Example #2
0
        public void HandleOctaveColor(int NoteID)
        {
            Color          clr = Color.White;
            Entity         CurrentKey;          //the key entity
            SpriteRenderer sp;                  //the key sprite
            //
            // reset all keys to white
            //
            int MinNote = 24;
            int MaxNote = 99;

            for (int i = MinNote; i <= MaxNote; i++)
            {
                CurrentKey = this.FindEntity("pkey" + i.ToString());
                if (CurrentKey == null)
                {
                    continue;
                }

                sp       = CurrentKey.GetComponent <SpriteRenderer>();
                sp.Color = Color.White;                                         //current key turned white
            }
            //
            // turn the octave keys to yellow starting at NoteID
            //
            MinNote = NoteID;
            MaxNote = MinNote + 12;
            for (int i = MinNote; i <= MaxNote; i++)
            {
                CurrentKey = this.FindEntity("pkey" + i.ToString());
                if (CurrentKey == null)
                {
                    continue;
                }

                sp       = CurrentKey.GetComponent <SpriteRenderer>();
                sp.Color = Color.Yellow;                                         //current key turned white
            }
        }