Exemple #1
0
        // For when the Keyboard Note or Mouse Note is released
        private void PianoControl_PianoKeyUp(object sender, PianoKeyEventArgs e)
        {
            oldTimers[e.NoteID].Stop();
            outDevice.Send(new ChannelMessage(ChannelCommand.NoteOff, 0, e.NoteID, 0));
            currentTimers[e.NoteID] = oldTimers[e.NoteID];
            long duration = currentTimers[e.NoteID].ElapsedMilliseconds.Round(100);

            // Checking for Thirds
            Timing symbols = noteEstimator.GetNoteFromDuration(duration);

            if (symbols == Timing.ThirdHalf || symbols == Timing.ThirdQuart ||
                symbols == Timing.ThirdEigth || symbols == Timing.ThirdWhole || symbols == Timing.ThirdSixteen)
            {
                thirds = true;
            }
            else
            {
                thirds = false;
            }

            System.Diagnostics.Debug.WriteLine($"{symbols } timing");

            // System.Diagnostics.Debug.WriteLine($"{whitePressed } white note");
            // System.Diagnostics.Debug.WriteLine($"{blackPressed } black note");

            whitePressed = keys.WhiteKeyPress(e.NoteID, out chrom);
            blackPressed = keys.BlackKeyPress(e.NoteID, out chrom);

            // Setting the Positions
            keys.SetPositions(blackPressed, whitePressed, chromatic, chrom);


            sheetForm.SetChromatic(chrom, chromatic);

            // Globally shared variables
            Global.Symbol    = note.GetNoteSymbol(symbols);
            Global.Chromatic = note.GetChromaticSymbol(chromatic);
            Timing time;

            Global.Image = note.GetImage(symbols, out time);
            Global.Time  = time;

            sheetForm.UpdatePaint(offset, shiftX, thirds, keys.GetPosition(e.NoteID));

            oldTimers[e.NoteID].Reset();
        }
Exemple #2
0
        // For when the Keyboard Note or Mouse Note is released
        private void PianoControl_PianoKeyUp(object sender, PianoKeyEventArgs e)
        {
            if (Global.Handy == Hand.Left)
            {
                leftHand--;
            }
            else if (Global.Handy == Hand.Right)
            {
                rightHand--;
            }

            if (leftHand < 0)
            {
                leftHand = 0;
            }
            if (rightHand < 0)
            {
                rightHand = 0;
            }

            // Setting the Positions
            blackPressed = keys.BlackKeyPress(e.NoteID, out chrom);
            whitePressed = keys.WhiteKeyPress(e.NoteID, out chrom);

            Chromatic oldValue = chromatic;
            int       shiftX   = keys.ChangePosition(oldY, newY, numberPlayed, chrom, oldValue, out chromatic);

            keys.SetPositions(blackPressed, whitePressed, chromatic, chrom);

            sheetForm.SetChromatic(chrom, chromatic);
            oldY = keys.GetPosition(e.NoteID);

            oldTimers[e.NoteID].Stop();
            outDevice.Send(new ChannelMessage(ChannelCommand.NoteOff, 0, e.NoteID, 0));

            currentTimers[e.NoteID] = oldTimers[e.NoteID];
            long duration = currentTimers[e.NoteID].ElapsedMilliseconds.Round(100);

            // Checking for Thirds
            Timing symbols = noteEstimator.GetNoteFromDuration(duration);

            if (symbols == Timing.ThirdHalf || symbols == Timing.ThirdQuart ||
                symbols == Timing.ThirdEigth || symbols == Timing.ThirdSixteen)
            {
                thirds = true;
            }
            else
            {
                thirds = false;
            }

            System.Diagnostics.Debug.WriteLine($"{symbols } timing");
            System.Diagnostics.Debug.WriteLine($"{oldY } old Y Position");
            System.Diagnostics.Debug.WriteLine($"{newY } new Y Position");

            newY = oldY;

            // Globally shared variables
            Global.Symbol    = drawn.GetNoteSymbol(symbols);
            Global.Chromatic = drawn.GetChromaticSymbol(chromatic);
            Timing time;

            Global.Image = drawn.GetImage(symbols, out time);
            Global.Time  = time;

            sheetForm.UpdatePaint(offset + shiftX, thirds, oldY);

            oldTimers[e.NoteID].Reset();
        }