Exemplo n.º 1
0
        public void EditModeUpdate()
        {
            if (!Enabled)
            {
                return;
            }
            if (ShowRawChord)
            {
                DrawRawChords();
            }
            double curTime = TL.CurrentTime;

            pointLeftBeatID  = BeatEditor.GetPreviousBeatID(curTime);
            pointRightBeatID = BeatEditor.GetNextBeatID(curTime);

            //Fix for bound detect
            if (FixBoundOption)
            {
                if (pointRightBeatID < Info.beats.Count - 1 && pointLeftBeatID >= 0)
                {
                    double time1 = Info.beats[pointLeftBeatID].Time,
                           time2 = Info.beats[pointRightBeatID].Time;
                    if ((time2 - curTime) / (time2 - time1) < NEXT_CHORD_START_PERCENT &&
                        time2 - curTime < NEXT_CHORD_START_TIME)
                    {
                        pointLeftBeatID++;
                        pointRightBeatID++;
                    }
                }
            }
            pointRightBeatID = RightExpandBound(pointRightBeatID, AlignBeat);
            if (ForceFrontAlign)
            {
                pointLeftBeatID = LeftExpandBound(pointLeftBeatID, AlignBeat);
            }
            if (ValidPointer)
            {
                double time1   = Info.beats[pointLeftBeatID].Time,
                       time2   = Info.beats[pointRightBeatID].Time;
                int pos1       = TL.Time2Pos(time1),
                    pos2       = TL.Time2Pos(time2);
                Rectangle rect = new Rectangle(pos1, TL.HorizonHeight - 30, pos2 - pos1, 30);
                TL.G.FillRectangle(transbrush, rect);
                TL.G.DrawRectangle(pointPen, rect);
            }
            if (ValidSelection)
            {
                double time1   = Info.beats[selectionLeftBeatID].Time,
                       time2   = Info.beats[selectionRightBeatID].Time;
                int pos1       = TL.Time2Pos(time1),
                    pos2       = TL.Time2Pos(time2);
                Rectangle rect = new Rectangle(pos1, TL.HorizonHeight - 30, pos2 - pos1, 30);
                //TL.G.FillRectangle(transbrush, rect);
                TL.G.DrawRectangle(selectionPen, rect);
            }
        }
Exemplo n.º 2
0
        public void DrawTonalty()
        {
            double tempLeftMostTime = TL.LeftMostTime, tempRightMostTime = TL.RightMostTime;
            int    left = BeatEditor.GetPreviousBeatID(tempLeftMostTime) - 1, right = BeatEditor.GetNextBeatID(tempRightMostTime);

            // Get the previous of previous beat of the left bound and the next beat of the right bound.
            if (left < 0)
            {
                left = 0;
            }
            // Tonalty of the last beat is wrong and useless
            if (right >= Info.beats.Count - 1)
            {
                right = Info.beats.Count - 2;
            }
            Tonalty lastTonalty = null;
            int     rightPos    = TL.TargetRightPos;

            for (int i = right; i >= left; --i)
            {
                int pos = TL.Time2Pos(Info.beats[i].Time);
                if (pos <= 0)
                {
                    lastTonalty = Info.beats[i].Tonalty;
                    break;
                }
                if (i == 0 || Info.beats[i - 1].Tonalty.ToString() != Info.beats[i].Tonalty.ToString())
                {
                    DrawTonaltyAt(Info.beats[i].Tonalty, pos, rightPos - pos);
                    rightPos = pos;
                }
            }
            if (lastTonalty != null)
            {
                DrawTonaltyAt(lastTonalty, 0, rightPos);
            }
        }
Exemplo n.º 3
0
        public void DrawChords()
        {
            double tempLeftMostTime = TL.LeftMostTime, tempRightMostTime = TL.RightMostTime;
            int    left = BeatEditor.GetPreviousBeatID(tempLeftMostTime) - 1, right = BeatEditor.GetNextBeatID(tempRightMostTime);

            // Get the previous of previous beat of the left bound and the next beat of the right bound.
            if (left < 0)
            {
                left = 0;
            }
            if (right >= Info.beats.Count)
            {
                right = Info.beats.Count - 1;
            }
            BeatInfo leftSameChord = Info.beats[left];

            for (int i = left; i <= right; ++i)
            {
                BeatInfo beat = Info.beats[i];
                if (beat.ChordTag?.ToString() != leftSameChord.ChordTag?.ToString() || i == right)
                {
                    DrawChordAt(leftSameChord, Info.beats[i]);
                    leftSameChord = beat;
                }
            }
            //Play chord parts
            if (AutoPlayMidi)
            {
                double curTime = TL.CurrentTime;
                pointLeftBeatID = BeatEditor.GetPreviousBeatID(curTime);
                if (pointLeftBeatID == -1)
                {
                    CurrentChord = null;
                }
                else
                {
                    Chord newChord = Info.beats[pointLeftBeatID].ChordTag;
                    if (CurrentChord?.ToString() != newChord?.ToString())
                    {
                        CurrentChord = newChord;
                        if (TL.Playing)
                        {
                            Program.MidiManager.PlayChordNotes(CurrentChord);
                        }
                    }
                }
            }
        }