public GuitarSlide(GuitarChord chord, bool isReversed) : base(chord, isReversed ? ChordModifierType.SlideReverse : ChordModifierType.Slide, GuitarMessageType.GuitarSlide) { Data1 = Utility.GetSlideData1(chord.Difficulty); Data2 = Utility.Data2Default; Channel = isReversed ? Utility.ChannelSlideReversed : Utility.ChannelSlide; }
public GuitarHammeron(GuitarChord chord) : base(chord, ChordModifierType.Hammeron, GuitarMessageType.GuitarHammeron) { Data1 = Utility.GetHammeronData1(chord.Difficulty); Data2 = Utility.Data2Default; Channel = Utility.ChannelDefault; SetTicks(chord.TickPair); }
public void NoMininumOfNotes() { var noteList = new List <IMusicalNote>(); noteList.Add(new MusicalNoteMock(NoteValue.G, 3, "G3")); var chord = new GuitarChord(noteList); Assert.AreEqual("G", chord.ToString()); }
public static GuitarSlide CreateSlide(GuitarChord chord, bool reversed) { GuitarSlide ret = null; if (!chord.HasSlide && Utility.GetSlideData1(chord.Difficulty).IsNotNull()) { ret = new GuitarSlide(chord, reversed); ret.IsNew = true; ret.CreateEvents(); } return ret; }
public static GuitarHammeron CreateHammeron(GuitarChord chord) { GuitarHammeron ret = null; if (!chord.HasHammeron && Utility.GetHammeronData1(chord.Difficulty).IsNotNull()) { ret = new GuitarHammeron(chord); ret.IsNew = true; ret.SetTicks(chord.TickPair); ret.CreateEvents(); } return ret; }
void RemapGuitarChords() { for (int i = 0; i < 32; i++) { for (int j = 0; j < 9; j++) { if (guitarMapIndexRootPairs[i][j].Root == 0xFF) { if (guitarMapIndexRootPairs[i][j].index == 0xFF) { continue; } remappedGuitar[i, j] = guitarOriginal[guitarMapIndexRootPairs[i][j].index]; } else { remappedGuitar[i, j] = new GuitarChord(guitarMapIndexRootPairs[i][j].Root, guitarMapIndexRootPairs[i][j].index); } } } }
public void Trivial_Cb5() { var noteList = new List <IMusicalNote>(); noteList.Add(new MusicalNoteMock(NoteValue.C, 4, "C4")); noteList.Add(new MusicalNoteMock(NoteValue.E, 4, "E4")); noteList.Add(new MusicalNoteMock(NoteValue.Gb, 4, "Gb4")); var chord = new GuitarChord(noteList); Assert.AreEqual(NoteValue.C, chord.TonicNote); Assert.AreEqual(Interval.DiminishedFifth, chord.FifthInterval); Assert.AreEqual(Interval.MajorThird, chord.ThirdInterval); Assert.IsNull(chord.SeventhInterval); Assert.IsNull(chord.FourthInterval); Assert.IsNull(chord.SixthInterval); Assert.IsNull(chord.NinthInterval); Assert.AreEqual("C(b5)", chord.ToString()); }
public void Guitar_Dm7() { var noteList = new List <IMusicalNote>(); noteList.Add(new MusicalNoteMock(NoteValue.D, 4, "D4")); noteList.Add(new MusicalNoteMock(NoteValue.A, 4, "A4")); noteList.Add(new MusicalNoteMock(NoteValue.C, 5, "C5")); noteList.Add(new MusicalNoteMock(NoteValue.F, 5, "F5")); var chord = new GuitarChord(noteList); Assert.AreEqual(NoteValue.D, chord.TonicNote); Assert.AreEqual(Interval.PerfectFifth, chord.FifthInterval); Assert.AreEqual(Interval.MinorThird, chord.ThirdInterval); Assert.AreEqual(Interval.MinorSeventh, chord.SeventhInterval); Assert.IsNull(chord.FourthInterval); Assert.IsNull(chord.SixthInterval); Assert.IsNull(chord.NinthInterval); Assert.AreEqual("Dm7", chord.ToString()); }
public void Guitar_B479() { var noteList = new List <IMusicalNote>(); noteList.Add(new MusicalNoteMock(NoteValue.B, 3, "B3")); noteList.Add(new MusicalNoteMock(NoteValue.E, 4, "E4")); noteList.Add(new MusicalNoteMock(NoteValue.A, 4, "A4")); noteList.Add(new MusicalNoteMock(NoteValue.Db, 5, "Db5")); noteList.Add(new MusicalNoteMock(NoteValue.Gb, 5, "Gb5")); var chord = new GuitarChord(noteList); Assert.AreEqual(NoteValue.B, chord.TonicNote); Assert.AreEqual(Interval.PerfectFifth, chord.FifthInterval); Assert.IsNull(chord.ThirdInterval); Assert.AreEqual(Interval.PerfectFourth, chord.FourthInterval); Assert.AreEqual(Interval.MinorSeventh, chord.SeventhInterval); Assert.AreEqual(Interval.MajorSecond, chord.NinthInterval); Assert.AreEqual("B4/7/9", chord.ToString()); }
public static ChordModifier CreateModifier(GuitarChord chord, ChordModifierType type) { ChordModifier ret = null; switch (type) { case ChordModifierType.ChordStrumLow: { ret = GuitarChordStrum.CreateStrum(chord, ChordStrum.Low); } break; case ChordModifierType.ChordStrumMed: { ret = GuitarChordStrum.CreateStrum(chord, ChordStrum.Mid); } break; case ChordModifierType.ChordStrumHigh: { ret = GuitarChordStrum.CreateStrum(chord, ChordStrum.High); } break; case ChordModifierType.Hammeron: { ret = GuitarHammeron.CreateHammeron(chord); } break; case ChordModifierType.Slide: { ret = GuitarSlide.CreateSlide(chord, false); } break; case ChordModifierType.SlideReverse: { ret = GuitarSlide.CreateSlide(chord, true); } break; } return ret; }
public void Guitar_Em7() { var noteList = new List <IMusicalNote>(); noteList.Add(new MusicalNoteMock(NoteValue.E, 3, "E4")); noteList.Add(new MusicalNoteMock(NoteValue.B, 3, "B3")); noteList.Add(new MusicalNoteMock(NoteValue.E, 4, "E4")); noteList.Add(new MusicalNoteMock(NoteValue.G, 4, "G4")); noteList.Add(new MusicalNoteMock(NoteValue.D, 5, "D5")); noteList.Add(new MusicalNoteMock(NoteValue.E, 5, "E5")); var chord = new GuitarChord(noteList); Assert.AreEqual(NoteValue.E, chord.TonicNote); Assert.AreEqual(Interval.PerfectFifth, chord.FifthInterval); Assert.AreEqual(Interval.MinorThird, chord.ThirdInterval); Assert.AreEqual(Interval.MinorSeventh, chord.SeventhInterval); Assert.IsNull(chord.FourthInterval); Assert.IsNull(chord.SixthInterval); Assert.IsNull(chord.NinthInterval); Assert.AreEqual("Em7", chord.ToString()); }
public GuitarChord GetStaleChord(GuitarChord chord, bool nextIfNotFound) { GuitarChord ret = null; if (!IsLoaded) return null; if (chord != null) { var c = guitarTrack.Messages.Chords.FirstOrDefault( x => x.IsDownEventClose(chord) && x.IsUpEventClose(chord)); if (c != null) { ret = c; } else if (nextIfNotFound == true) { c = guitarTrack.Messages.Chords.FirstOrDefault( x => x.DownTick >= chord.DownTick); if (c != null) { ret = c; } } } return ret; }
public GuitarChord SelectNextChord(GuitarChord sel) { if (!IsLoaded) return null; GuitarChord ret = null; if (sel != null) { ret = GetNextChord(sel); if (ret != null) { ClearSelection(); ret.Selected = true; } } Invalidate(); return sel; }
public int GetChordMinYOffset(GuitarChord c) { return c.Notes.Min(n => GetNoteMinYOffset(n)); }
public GuitarChord GetPreviousChord(GuitarChord sel) { GuitarChord ret = null; if (sel != null) { return guitarTrack.Messages.Chords.LastOrDefault(x => x.DownTick < sel.DownTick); } return ret; }
public int GetChordMinYOffset(GuitarChord c) { if (c.Notes.Any()) { return c.Notes.Min(n => GetNoteMinYOffset(n)); } else { return Int32.MinValue; } }
private int ReplaceNotes(GuitarMessageList list, GuitarChord[] oChords6, double deltaTimeStart, int minTime, GuitarChord[] m, int startTick, int endTick, out int numReplaced) { numReplaced = 0; var replaceConfig = GetNewCopyPatternPresetFromScreen(); TickPair tp = m.GetTickPair(); if (replaceConfig.RemoveExisting) { list.Chords.GetBetweenTick( new TickPair(tp.Down + Utility.NoteCloseWidth / 2, tp.Up - Utility.NoteCloseWidth / 2)) .ToList().ForEach(x => x.DeleteAll()); } if (replaceConfig.KeepLengths && m.Length == oChords6.Length) { int iochord6 = 0; foreach (var oC in oChords6) { var nn = oC.CloneAtTime(list, m[iochord6].TickPair); if (nn != null) { numReplaced++; iochord6++; nn.Selected = true; } } } else { GuitarChord prev = null; var currentTime = list.Owner.GuitarTrack.TickToTime(startTick); int currentTick = list.Owner.GuitarTrack.TimeToTick(currentTime); foreach (var oC in oChords6) { int space = 0; if (prev != null) { space = oC.DownTick - prev.UpTick; } TickPair newTicks; CalcStartEndTick(oC.TickPair, space, currentTick, currentTime, deltaTimeStart, out newTicks); if (!(newTicks.Down < oC.UpTick && newTicks.Up > oC.DownTick)) { if (newTicks.Down >= minTime) { var nn = oC.CloneAtTime(list, newTicks); if (nn != null) { endTick = nn.UpTick; numReplaced++; nn.Selected = true; } minTime = endTick; deltaTimeStart = 0; } } prev = oC; currentTime = list.Owner.GuitarTrack.TickToTime(minTime); } } return minTime; }
public void SetChordToScreen(GuitarChord gc, bool allowKeepSelection = true, bool ignoreKeepSelection = false) { var keepSel = (allowKeepSelection && checkKeepSelection.Checked); if (gc != null && (keepSel == false || ignoreKeepSelection)) { var hb = GetHoldBoxes(); hb.ForEach(x => x.Text = ""); NoteChannelBoxes.ForEach(x => x.Text = ""); foreach (var n in gc.Notes) { hb[5 - n.NoteString].Text = n.NoteFretDown.ToStringEx(); NoteChannelBoxes[5 - n.NoteString].Text = n.Channel.ToStringEx(); } var sb = GetChordStartBox(); var eb = GetChordEndBox(); sb.Text = gc.DownTick.ToStringEx(); eb.Text = gc.UpTick.ToStringEx(); checkIsSlide.Checked = gc.HasSlide; checkIsSlideReversed.Checked = gc.HasSlideReversed; checkIsHammeron.Checked = gc.HasHammeron; checkIsTap.Checked = gc.IsTap; checkIsX.Checked = gc.IsXNote; checkStrumHigh.Checked = gc.HasStrumMode(ChordStrum.High); checkStrumMid.Checked = gc.HasStrumMode(ChordStrum.Mid); checkStrumLow.Checked = gc.HasStrumMode(ChordStrum.Low); } else if (gc != null) { var sb = GetChordStartBox(); var eb = GetChordEndBox(); sb.Text = gc.DownTick.ToStringEx(); eb.Text = gc.UpTick.ToStringEx(); } SetChordScaleBoxes(gc); int iStart = GetChordStartBox().Text.ToInt(); int iEnd = GetChordEndBox().Text.ToInt(); if (!iStart.IsNull() && !iEnd.IsNull()) { textBoxNoteEditorSelectedChordTickLength.Text = (iEnd - iStart).ToStringEx(); } CheckQuickEditFocus(); }
void DrawChord(GuitarChord chord, Graphics g, bool drawSelected) { foreach (var note in chord.Notes) { var i = note.NoteString; var startEnd = new TickPair(GetClientPointFromTime(note.StartTime), GetClientPointFromTime(note.EndTime)); if (CurrentSelectionState == EditorSelectionState.MovingSelector) { var sel = CurrentSelector; if (sel != null && chord.Selected && drawSelected) { if (sel.IsRight) { startEnd.Up = sel.CurrentPoint.X + Utility.SelectorWidth; } else { startEnd.Down = sel.CurrentPoint.X; } } } int noteX = startEnd.Down; int noteY = GetNoteMinYOffset(note); var width = startEnd.Up - startEnd.Down; if (CurrentSelectionState != EditorSelectionState.MovingSelector) { if (drawSelected == false) { if (width < Utility.MinimumNoteWidth) { width = Utility.MinimumNoteWidth; } } } var noteRect = new Rectangle(noteX, noteY, width, NoteHeight); if (width > 0) { int minus = 2; int plus = 5; if (chord.Selected) { minus = 1; plus = 3; } if ((chord.StrumMode & ChordStrum.Low) > 0) { if (i == 0 || i == 1) { g.FillRectangle(Utility.noteStrumBrush, noteX - minus, noteY - minus, width + plus, NoteHeight + plus); } } if ((chord.StrumMode & ChordStrum.Mid) > 0) { if (i == 2 || i == 3) { g.FillRectangle(Utility.noteStrumBrush, noteX - minus, noteY - minus, width + plus, NoteHeight + plus); } } if ((chord.StrumMode & ChordStrum.High) > 0) { if (i == 4 || i == 5) { g.FillRectangle(Utility.noteStrumBrush, noteX - minus, noteY - minus, width + plus, NoteHeight + plus); } } var sb = Utility.noteBGBrush; string noteTxt = note.NoteFretDown.ToString(); if (note.IsArpeggioNote) { noteTxt = Utility.ArpeggioHelperPrefix + noteTxt + Utility.ArpeggioHelperSuffix; sb = Utility.noteArpeggioBrush; } if (chord.IsXNote) { sb = Utility.noteXBrush; } else if (note.IsTapNote) { sb = Utility.noteTapBrush; } g.FillRectangle(sb, noteX, noteY, width, NoteHeight); if (width > 3) { var rectPen = Utility.noteBoundPen; g.DrawRectangle(rectPen, noteRect); var len = GetClientPointFromTick(chord.UpTick) - GetClientPointFromTick(chord.DownTick); if (len > 4) { if (chord.HasHammeron && chord.HasSlide) { using (var slb = new SolidBrush(Color.FromArgb(Utility.hammerOnPen.Color.A, Utility.hammerOnPen.Color))) { g.FillPolygon(slb, new Point[] { new Point(noteX, noteY), new Point(noteX + width, noteY), new Point(noteX, noteY + NoteHeight) }); } using (var slb = new SolidBrush(Color.FromArgb(Utility.slidePen.Color.A, Utility.slidePen.Color))) { g.FillPolygon(slb, new Point[] { new Point(noteX + width, noteY), new Point(noteX + width, noteY + NoteHeight), new Point(noteX, noteY + NoteHeight) }); } } else if (chord.HasHammeron) { using (var slb = new SolidBrush(Color.FromArgb(Utility.hammerOnPen.Color.A, Utility.hammerOnPen.Color))) { g.FillRectangle(slb, noteRect); } } else if (chord.HasSlide) { using (var slb = new SolidBrush(Color.FromArgb(Utility.slidePen.Color.A, Utility.slidePen.Color))) { g.FillRectangle(slb, noteRect); } } if (width > 4) { using (var slb = new Pen(Color.FromArgb(80, Color.White))) { g.DrawLine(slb, new Point(noteX, noteY + 1), new Point(noteX + width - 1, noteY + 1)); g.DrawLine(slb, new Point(noteX + 1, noteY + 1), new Point(noteX + 1, noteY + NoteHeight - 1)); } using (var slb = new Pen(Color.FromArgb(40, Color.White))) { g.DrawLine(slb, new Point(noteX + 1, noteY + 2), new Point(noteX + width - 1, noteY + 2)); g.DrawLine(slb, new Point(noteX + 2, noteY + 1), new Point(noteX + 1, noteY + NoteHeight - 1)); } using (var slb = new Pen(Color.FromArgb(40, Color.White))) { g.DrawLine(slb, new Point(noteX + 1, noteY + 3), new Point(noteX + 4, noteY + 3)); g.DrawLine(slb, new Point(noteX + 1, noteY + 4), new Point(noteX + 3, noteY + 4)); g.DrawLine(slb, new Point(noteX + 1, noteY + 5), new Point(noteX + 2, noteY + 5)); g.DrawLine(slb, new Point(noteX + 1, noteY + 6), new Point(noteX + 2, noteY + 6)); } using (var slb = new Pen(Color.FromArgb(40, Color.Black))) { g.DrawLine(slb, new Point(noteX + width + 1, noteY + 1), new Point(noteX + width + 1, noteY + NoteHeight + 1)); g.DrawLine(slb, new Point(noteX + 1, noteY + NoteHeight + 1), new Point(noteX + width, noteY + NoteHeight + 1)); } using (var slb = new Pen(Color.FromArgb(10, Color.Black))) { g.DrawLine(slb, new Point(noteX + width + 2, noteY + 2), new Point(noteX + width + 2, noteY + NoteHeight + 2)); g.DrawLine(slb, new Point(noteX + 3, noteY + NoteHeight + 2), new Point(noteX + width + 1, noteY + NoteHeight + 2)); } float fontSize = (float)NoteHeight; if (width < fontSize) { fontSize = width; } if (fontSize / 2.0f - (int)(fontSize / 2.0f) > 0) { fontSize = fontSize - 1; } var font = GetFontForRect(noteRect); if (font != null) { if (chord.IsXNote && Utility.XNoteText.Trim().IsNotEmpty()) { noteTxt = Utility.XNoteText.Trim(); } if (note.IsArpeggioNote) { noteY--; } noteX += Utility.NoteTextXOffset; noteY += Utility.NoteTextYOffset; g.DrawString(noteTxt, font, Utility.fretBrush, new RectangleF(new PointF(noteX, noteY - 1), new SizeF(width + 20, NoteHeight)), Utility.GetStringFormatNoWrap()); } } } } if (chord.Selected) { using (var brush = new SolidBrush(Color.FromArgb(200, Utility.noteBGBrushSel.Color))) { g.FillRectangle(Utility.noteBGBrushSel, noteRect); } } } } }
public void ContructorParameterCantBeNull() { var chord = new GuitarChord(null); }
public GuitarChord GetPreviousChord(GuitarChord sel) { GuitarChord ret = null; if (sel != null) { ret = guitarTrack.Messages.Chords.LastOrDefault( x => x.IsBefore(sel)); } return ret; }
void DrawPasteChord(PastePointParam param, GuitarChord chord, Graphics g) { int alpha = 120; foreach(var note in chord.Notes) { var i = note.NoteString; var start = GetScreenPointFromTick(note.DownTick); var end = GetScreenPointFromTick(note.UpTick); int noteX = param.MousePos.X; noteX = noteX + (int)(start - param.MinChordX) + param.Offset.X; int noteY = TopLineOffset + LineSpacing * (5-(param.MousePos.Y -param.MinNoteString + note.NoteString )) - NoteHeight / 2 + param.Offset.Y; var width = end - start; using (var p = new Pen(Color.FromArgb(alpha, Utility.noteBGBrushSel.Color))) { g.DrawRectangle(p, noteX + Utility.NoteSelectionOffsetLeft, noteY + Utility.NoteSelectionOffsetUp, width + Utility.NoteSelectionOffsetRight-1, NoteHeight + Utility.NoteSelectionOffsetDown-1); } Color bgColor = Utility.noteBGBrush.Color; if (note.Channel == Utility.ChannelX) { bgColor = Utility.noteXBrush.Color; } else if (note.Channel == Utility.ChannelTap) { bgColor = Utility.noteTapBrush.Color; } using (var sb = new SolidBrush(Color.FromArgb(alpha, bgColor))) { g.FillRectangle(sb, noteX, noteY, width, NoteHeight); } using (var rectPen = new Pen(Color.FromArgb(alpha, Utility.noteBoundPen.Color))) { g.DrawRectangle(rectPen, noteX, noteY, width, NoteHeight); } using (var selPen = new Pen(Color.FromArgb(alpha, Utility.selectedPen.Color))) { g.DrawRectangle(selPen, noteX, noteY, width, NoteHeight); } using (var fb = new SolidBrush(Color.FromArgb(alpha, Utility.fretBrush.Color))) { string noteTxt = note.NoteFretDown.ToString(); if (note.Channel == Utility.ChannelX) { noteTxt = Utility.XNoteText; } g.DrawString(noteTxt, Utility.fretFont, fb, noteX + Utility.NoteTextXOffset, noteY - (int)(Utility.fontHeight / 4.0 + Utility.NoteTextYOffset)); } } }
public ChordModifier(GuitarChord chord, ChordModifierType type, GuitarMessageType gt) : base(chord.Owner, chord.TickPair, gt) { ModifierType = type; Chord = chord; }
public static ChordModifier GetModifier(GuitarChord chord, ChordModifierType type) { ChordModifier ret = null; switch (type) { case ChordModifierType.ChordStrumHigh: case ChordModifierType.ChordStrumMed: case ChordModifierType.ChordStrumLow: if (Utility.GetStrumData1(chord.Difficulty).IsNotNull()) { ret = new GuitarChordStrum(chord, type); } break; case ChordModifierType.Hammeron: if (Utility.GetHammeronData1(chord.Difficulty).IsNotNull()) { ret = new GuitarHammeron(chord); } break; case ChordModifierType.Slide: case ChordModifierType.SlideReverse: if (Utility.GetSlideData1(chord.Difficulty).IsNotNull()) { ret = new GuitarSlide(chord, type == ChordModifierType.SlideReverse); } break; } return ret; }
public void SetChordToClipboard(GuitarChord gc) { CopyChords.Clear(); if (gc != null) { CurrentSelectionState = EditorSelectionState.PastingNotes; CopyChords.Add(gc); CopyChords.BeginPaste(PointToClient(MousePosition)); } }
void DrawChord(GuitarChord chord, Graphics g, bool drawSelected) { foreach(var note in chord.Notes) { var i = note.NoteString; var start = GetScreenPointFromTick(note.DownTick); var end = GetScreenPointFromTick(note.UpTick); if (CurrentSelectionState == EditorSelectionState.MovingSelector) { var sel = CurrentSelector; if (sel != null && chord.Selected && drawSelected) { if (sel.IsRight) { end = sel.CurrentPoint.X + Utility.SelectorWidth; } else { start = sel.CurrentPoint.X; } } } int noteX = start; int noteY = GetNoteMinYOffset(note); var width = end - start; if (CurrentSelectionState != EditorSelectionState.MovingSelector) { if (drawSelected == false) { if (width < Utility.MinimumNoteWidth) { width = Utility.MinimumNoteWidth; } } } var noteRect = new Rectangle(noteX, noteY, width, NoteHeight); using (var bs = new SolidBrush(Color.FromArgb(20, Utility.noteBGBrushShadow.Color))) { var shadowRect = noteRect; shadowRect.Width += 2; shadowRect.Height += 2; g.FillRectangle(bs, shadowRect); } if (chord.Selected) { g.FillRectangle(Utility.noteBGBrushSel, noteX + Utility.NoteSelectionOffsetLeft, noteY + Utility.NoteSelectionOffsetUp, width + Utility.NoteSelectionOffsetRight, NoteHeight + Utility.NoteSelectionOffsetDown); } int minus = 2; int plus = 5; if (chord.Selected) { minus = 1; plus = 3; } if ((chord.StrumMode & ChordStrum.Low) > 0) { if (i == 0 || i == 1) { g.FillRectangle(Utility.noteStrumBrush, noteX - minus, noteY - minus, width + plus, NoteHeight + plus); } } if ((chord.StrumMode & ChordStrum.Mid) > 0) { if (i == 2 || i == 3) { g.FillRectangle(Utility.noteStrumBrush, noteX - minus, noteY - minus, width + plus, NoteHeight + plus); } } if ((chord.StrumMode & ChordStrum.High) > 0) { if (i == 4 || i == 5) { g.FillRectangle(Utility.noteStrumBrush, noteX - minus, noteY - minus, width + plus, NoteHeight + plus); } } var sb = Utility.noteBGBrush; string noteTxt = note.NoteFretDown.ToString(); if (note.IsArpeggioNote) { noteTxt = Utility.ArpeggioHelperPrefix + noteTxt + Utility.ArpeggioHelperSuffix; sb = Utility.noteArpeggioBrush; } if (chord.IsXNote) { sb = Utility.noteXBrush; } else if (note.IsTapNote) { sb = Utility.noteTapBrush; } g.FillRectangle(sb, noteX, noteY, width, NoteHeight); var rectPen = Utility.noteBoundPen; if (!ZoomedOutRealFar) { g.DrawRectangle(rectPen, noteRect); } var len = GetScreenPointFromTick(chord.UpTick) - GetScreenPointFromTick(chord.DownTick); if (len > 5 && !ZoomedOutRealFar) { if (chord.IsHammeron && chord.IsSlide) { rectPen = Utility.hammerOnPen; int hw = (int)rectPen.Width; g.DrawRectangle(rectPen, noteRect); rectPen = Utility.slidePen; g.DrawRectangle(rectPen, noteX - hw, noteY - hw, width + hw * 2, NoteHeight + hw * 2); } else if (chord.IsHammeron) { rectPen = Utility.hammerOnPen; g.DrawRectangle(rectPen, noteRect); } else if (chord.IsSlide) { rectPen = Utility.slidePen; g.DrawRectangle(rectPen, noteRect); } if(width > 2) { float fontSize = (float)NoteHeight; if (width < fontSize) { fontSize = width; } if (fontSize/2.0f - (int)(fontSize/2.0f) > 0) { fontSize = fontSize - 1; } var font = GetFontForRect(noteRect); if (font != null) { g.DrawString(noteTxt, font, Utility.fretBrush, new RectangleF(new PointF(noteX, noteY), new SizeF(width+20, NoteHeight)), Utility.GetStringFormatNoWrap()); } } } } }
public void SetSelectedChord(GuitarChord gc, bool clicked, bool ignoreKeepSelection = false) { bool wasSelected = gc == null ? false : gc.Selected; ClearSelection(); if (gc != null) { gc.Selected = true; if (OnSetChordToScreen != null) { OnSetChordToScreen(this, gc, ignoreKeepSelection); } if (ScrollToSelectionEnabled && !clicked) { ScrollToSelection(); } Invalidate(); } }
public void SetSelectedChord(GuitarChord gc, bool clicked, bool ignoreKeepSelection = false) { bool wasSelected = gc == null ? false : gc.Selected; EditorPro.ClearSelection(); if (gc != null) { gc.Selected = true; SetChordToScreen(gc, clicked || checkKeepSelection.Checked == true, ignoreKeepSelection || wasSelected); if (checkScrollToSelection.Checked && !clicked) { ScrollToSelection(); } } EditorPro.Invalidate(); }
private Point GetChordYMinMax(GuitarChord c) { return new Point(GetChordMinYOffset(c), GetChordMaxYOffset(c)); }
public void SetChordToClipboard(GuitarChord gc) { CopyChords.Clear(); if (gc != null) { CurrentSelectionState = EditorSelectionState.PastingNotes; CopyChords.Add(gc); } }
public GuitarChord GetNextChord(GuitarChord sel) { if (guitarTrack == null) return null; if (sel != null) { return guitarTrack.Messages.Chords.FirstOrDefault( x => x.IsAfter(sel)); } return null; }
public GuitarChord GetNextChord(GuitarChord sel) { if (!IsLoaded) return null; if (sel != null) { return guitarTrack.Messages.Chords.FirstOrDefault(x => x.DownTick > sel.DownTick); } return null; }
MatchingCopyPattern internalFindMatchingCopyPattern( FindMatchingPatternConfig findConfig, CopyPatternPreset replaceConfig) { var ret = new MatchingCopyPattern(); bool matchG5Lengths = replaceConfig.MatchLengths5; bool matchG6Lengths = replaceConfig.MatchLengths6; bool matchSpacing = replaceConfig.MatchSpacing; bool matchBeat = replaceConfig.MatchBeat; TickPair ticks; if (!getPatternMatchTicks(out ticks)) return ret; var track5 = EditorG5.GuitarTrack; var track6 = EditorPro.GuitarTrack; var chords5 = track5.Messages.Chords.ToArray(); var nchords6 = track6.Messages.Chords.ToArray(); var matchChords5 = track5.Messages.Chords.GetBetweenTick(ticks).ToArray(); if (matchChords5.Length == 0) return ret; var oChords6 = track6.Messages.Chords.GetBetweenTick(ticks).ToArray(); if (oChords6.Length == 0) return ret; if (replaceConfig.ForwardOnly && !findConfig.FindPrevious) { chords5 = chords5.Where(x => x.DownTick >= ticks.Up).ToArray(); nchords6 = nchords6.Where(x => x.DownTick >= ticks.Up).ToArray(); } int minMatchTick5 = matchChords5.GetMinTick(); int minMatchTick6 = oChords6.GetMinTick(); int maxMatchTick6 = oChords6.GetMaxTick(); ret.DeltaTimeStart = track6.TickToTime(minMatchTick6) - track5.TickToTime(minMatchTick5); if (matchChords5.Any() == false) return ret; int numMatchChords5 = matchChords5.Count(); int numMatchChords6 = oChords6.Count(); ret.OriginalChords6 = oChords6.ToArray(); ret.StartTick = ticks.Down; ret.EndTick = ticks.Up; var checkStrings = new cmpNoteFunc( (n1, n2) => { return n1.NoteString != n2.NoteString; }); var checkData1 = new cmpNoteFunc( (n1, n2) => { return n1.NoteFretDown != n2.NoteFretDown; }); var checkLength = new cmpNoteFunc( (n1, n2) => { return Utility.IsCloseTick(n1.TickLength, n2.TickLength) == false; }); var checkNull = new cmpNoteFunc((a, b) => { return ((a == null) || (b == null)); }); var testBeat = new cmpChordFunc((co, cn) => { var ob32 = ProGuitarTrack.GetTempo(co.DownTick).SecondsPerThirtySecondNote; var ob = ProGuitarTrack.GetTempo(co.DownTick).SecondsPerQuarterNote; var nb = ProGuitarTrack.GetTempo(cn.DownTick).SecondsPerQuarterNote; var diff = Math.Abs(ob - nb); if (diff > ob32) { return false; } return true; }); var chordsEqual = new cmpChordFunc( (a, b) => { if (matchBeat && testBeat(a, b) == false) return false; for (int x = 0; x < 6; x++) { var an = a.Notes[x]; var bn = b.Notes[x]; if (an == null && bn == null) continue; if (checkNull(an, bn) || checkData1(an, bn) || checkStrings(an, bn) || (matchG5Lengths && checkLength(an, bn))) { return false; } } return true; }); var testSpacing = new matchFunc((mfmatch, mfmca) => { for (int y = 0; y < mfmca.Length - 1; y++) { var nc = mfmatch[y]; var oc = mfmca[y]; var timeTillNext5 = track5.TickToTime(mfmca[y + 1].DownTick) - track5.TickToTime(oc.UpTick); var timeTillNext52 = track5.TickToTime(mfmatch[y + 1].DownTick) - track5.TickToTime(nc.UpTick); var diff = Math.Abs(timeTillNext52 - timeTillNext5); double spb = ProGuitarTrack.GetTempo(oc.DownTick).SecondsPerThirtySecondNote; if (diff > spb) { return false; } } return true; }); var mca = matchChords5.ToArray(); var match = new GuitarChord[mca.Length]; var matches = new List<GuitarChord[]>(); for (int ci = 0; ci < chords5.Length - mca.Length; ci++) { for (int mc = 0; mc < mca.Length; mc++) { var cc = chords5[ci + mc]; if (cc.DownTick < mca[mca.Length - 1].UpTick && cc.UpTick > mca[0].DownTick) { break; } if (chordsEqual(cc, mca[mc])) { match[mc] = cc; if (mc == mca.Length - 1) { if (matchSpacing) { if (testSpacing(match, mca) == true) { matches.Add(match.ToArray()); ci += mca.Length - 1; } } else { matches.Add(match.ToArray()); ci += mca.Length - 1; } } } else { break; } } } var goodMatches = new List<GuitarChord[]>(); foreach (var m in matches) { var c6 = track6.Messages.Chords.GetBetweenTick(m.GetTickPair()).ToArray(); bool matching = true; if (replaceConfig.MatchLengths6) { if (c6.Length == oChords6.Length) { for (int x = 0; x < c6.Length; x++) { if (!Utility.IsCloseTick(c6[x].TickPair.TickLength, oChords6[x].TickPair.TickLength)) { matching = false; break; } } } else { matching = false; } } if (matching) { goodMatches.Add(c6); } } foreach (var m in goodMatches) { ret.Matches.Add(m); } return ret; }
public int GetChordMaxYOffset(GuitarChord c) { return c.Notes.Max(n => GetNoteMaxYOffset(n)); }
public void SetChordScaleBoxes(GuitarChord chord) { comboBoxNoteEditorChordName.BeginUpdate(); comboBoxNoteEditorChordName.Items.Clear(); comboBoxNoteEditorChordName.SelectedIndex = -1; ChordScaleBoxes.ForEach(x => x.Checked = false); if (chord != null) { if(EditorPro.IsLoaded && EditorPro.SelectedTrack.IsNotNull()) { var tuning = EditorPro.IsEditingBass ? BassTuning : GuitarTuning; var names = chord.GetTunedChordNames(CurrentTuning); if (names.IsNotEmpty()) { GetChordScaleBox(names.First().ToneName.ToToneNameData1()).IfNotNull(x => x.Checked = true); } comboBoxNoteEditorChordName.Items.AddRange(names.ToArray()); if (comboBoxNoteEditorChordName.Items.Count > 0) { comboBoxNoteEditorChordName.SelectedIndex = 0; } if (chord.RootNoteConfig.IsNotNull()) { var rc = chord.RootNoteConfig; GetChordScaleBox((ToneNameData1)rc.RootNoteData1).IfNotNull(x => x.Checked = true); if (rc.UseUserChordName) { var match = names.Where(n => n.ToString().EqualsEx(rc.UserChordName)); if (match.Any()) { comboBoxNoteEditorChordName.SelectedItem = null; comboBoxNoteEditorChordName.SelectedText = match.First().ToStringEx(); } else { comboBoxNoteEditorChordName.SelectedItem = null; comboBoxNoteEditorChordName.Text = rc.UserChordName ?? ""; } } checkChordNameHide.Checked = rc.HideNoteName; } } } comboBoxNoteEditorChordName.EndUpdate(); }
public GuitarChord SelectNextChord(GuitarChord sel) { if (guitarTrack == null) return null; var n = GetNextChord(sel); ClearSelection(); if(sel != null) { var gc = guitarTrack.Messages.Chords.FirstOrDefault( c => c.IsAfter(sel)); if (gc != null) { gc.Selected = true; sel = gc; } } return sel; }