public Tonalty GetCurrentTonalty() { int id = BeatEditor.GetPreviousBeatID(Program.TL.CurrentTime); if (id == -1) { id = 0; } return(Info.beats[id].Tonalty); }
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); } }
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); } } } } }