private void CreateNoteGlyphs(Note n) { if (n.IsTrill) { AddGlyph(new SpacingGlyph(0, 0, 4 * Scale)); var trillNote = new Note(); trillNote.IsGhost = true; trillNote.Fret = n.TrillFret; trillNote.String = n.String; var tr = (TabBarRenderer)Renderer; var trillNumberGlyph = new NoteNumberGlyph(0, 0, trillNote, true); var l = n.Beat.Voice.Bar.Track.Tuning.Length - n.String; trillNumberGlyph.Y = tr.GetTabY(l); AddGlyph(trillNumberGlyph); } if (n.HasBend) { var bendValueHeight = 6; var bendHeight = n.MaxBendPoint.Value * bendValueHeight; Renderer.RegisterOverflowTop(bendHeight); AddGlyph(new BendGlyph(n, BeatDurationWidth * Scale, bendValueHeight)); } }
protected override void CreateTies(Note n) { // create a tie if any effect requires it // NOTE: we create 2 tie glyphs if we have a line break inbetween // the two notes if (n.IsTieOrigin) { var tie = new ScoreTieGlyph(n, n.TieDestination, this); Ties.Add(tie); } if (n.IsTieDestination) { var tie = new ScoreTieGlyph(n.TieOrigin, n, this, true); Ties.Add(tie); } else if (n.IsHammerPullOrigin) { var tie = new ScoreTieGlyph(n, n.HammerPullDestination, this); Ties.Add(tie); } else if (n.SlideType == SlideType.Legato) { var tie = new ScoreTieGlyph(n, n.SlideTarget, this); Ties.Add(tie); } // TODO: depending on the type we have other positioning // we should place glyphs in the preNotesGlyph or postNotesGlyph if needed if (n.SlideType != SlideType.None) { var l = new ScoreSlideLineGlyph(n.SlideType, n, this); Ties.Add(l); } }
public TabSlideLineGlyph(SlideType type, Note startNote, BeatContainerGlyph parent) : base(0, 0) { _type = type; _startNote = startNote; _parent = parent; }
public BendGlyph(Note n, float width, float bendValueHeight) : base(0, 0) { _note = n; Width = width; _bendValueHeight = bendValueHeight; }
public BendGlyph(Note n, float width, float height) : base(0, 0) { _note = n; Width = width; _height = height; }
public NoteNumberGlyph(float x, float y, Note n) : base(x, y) { if (!n.IsTieDestination) { _noteString = n.IsDead ? "x" : n.Fret.ToString(); if (n.IsGhost) { _noteString = "(" + _noteString + ")"; } } else if (n.Beat.Index == 0 || n.HasBend) { _noteString = "(" + n.TieOrigin.Fret + ")"; } else { _noteString = ""; } if (n.IsTrill) { _trillNoteString = "(" + n.TrillFret + ")"; } else { _trillNoteString = ""; } }
public float GetNoteY(Note note) { if (_noteLookup.ContainsKey(note.String)) { return Y + _noteLookup[note.String].Y; } return 0; }
public TieGlyph(Note startNote, Note endNote, Glyph parent, bool forEnd) : base(0, 0) { StartNote = startNote; EndNote = endNote; Parent = parent; _forEnd = forEnd; }
public override float GetNoteX(Note note, bool onEnd = true) { ScoreBeatGlyph g = (ScoreBeatGlyph)GetOnNotesPosition(note.Beat.Voice.Index, note.Beat.Index); if (g != null) { return g.Container.X + g.X + g.NoteHeads.GetNoteX(note, onEnd); } return 0; }
public override float GetNoteY(Note note) { var beat = (TabBeatGlyph)GetOnNotesPosition(note.Beat.Voice.Index, note.Beat.Index); if (beat != null) { return beat.NoteNumbers.GetNoteY(note); } return 0; }
public override float GetNoteX(Note note, bool onEnd = true) { var beat = (TabBeatGlyph)GetOnNotesPosition(note.Beat.Voice.Index, note.Beat.Index); if (beat != null) { return beat.Container.X + beat.X + beat.NoteNumbers.GetNoteX(note, onEnd); } return PostBeatGlyphsStart; }
protected override bool ShouldCreateGlyphForNote(EffectBarRenderer renderer, Note note) { if (!note.IsHarmonic) return false; if (note.Beat != _beat || note.HarmonicType > _beatType) { _beatType = note.HarmonicType; } return true; }
public override float GetNoteY(Note note) { ScoreBeatGlyph beat = (ScoreBeatGlyph)GetOnNotesPosition(note.Beat.Voice.Index, note.Beat.Index); if (beat != null) { return beat.NoteHeads.GetNoteY(note); } return 0; }
public override float GetNoteX(Note note, bool onEnd = true) { var beat = (TabBeatGlyph)GetOnNotesGlyphForBeat(note.Beat); if (beat != null) { return beat.Container.X + beat.X + beat.NoteNumbers.GetNoteX(note, onEnd); } return 0; }
private static void ParseTied(IXmlNode element, Note note) { if (element.GetAttribute("type") == "start") { note.IsTieOrigin = true; } else { note.IsTieDestination = true; } }
public float GetNoteX(Note note, bool onEnd = true) { if (_noteLookup.ContainsKey(note.String)) { var n = _noteLookup[note.String]; var pos = X + n.X; if (onEnd) { pos += n.Width; } return pos; } return 0; }
/// <summary> /// Maps the given note to a normal note value to place the note at the /// correct line on score notation /// </summary> /// <param name="note"></param> /// <returns></returns> public static int MapNoteForDisplay(Note note) { var value = note.RealValue; if (value == 61 || value == 66) { return 50; } else if (value == 60 || value == 65) { return 52; } else if ((value >= 35 && value <= 36) || value == 44) { return 53; } else if (value == 41 || value == 64) { return 55; } else if (value == 43 || value == 62) { return 57; } else if (value == 45 || value == 63) { return 59; } else if (value == 47 || value == 54) { return 62; } else if (value == 48 || value == 56) { return 64; } else if (value == 50) { return 65; } else if (value == 42 || value == 46 || (value >= 49 && value <= 53) || value == 57 || value == 59) { return 67; } return 60; }
protected override void CreateTies(Note n) { if (n.IsHammerPullOrigin) { var tie = new TabTieGlyph(n, n.HammerPullDestination, this); Ties.Add(tie); } else if (n.SlideType == SlideType.Legato) { var tie = new TabTieGlyph(n, n.SlideTarget, this); Ties.Add(tie); } if (n.SlideType != SlideType.None) { var l = new TabSlideLineGlyph(n.SlideType, n, this); Ties.Add(l); } }
private void CreateAccidentalGlyph(Note n, AccidentalGroupGlyph accidentals) { var sr = (ScoreBarRenderer)Renderer; var accidental = sr.AccidentalHelper.ApplyAccidental(n); var noteLine = sr.GetNoteLine(n); var isGrace = Container.Beat.GraceType != GraceType.None; switch (accidental) { case AccidentalType.Sharp: accidentals.AddGlyph(new SharpGlyph(0, sr.GetScoreY(noteLine), isGrace)); break; case AccidentalType.Flat: accidentals.AddGlyph(new FlatGlyph(0, sr.GetScoreY(noteLine), isGrace)); break; case AccidentalType.Natural: accidentals.AddGlyph(new NaturalizeGlyph(0, sr.GetScoreY(noteLine + 1), isGrace)); break; } }
public NoteNumberGlyph(float x, float y, Note n, bool isGrace) : base(x, y) { _isGrace = isGrace; if (!n.IsTieDestination) { _noteString = n.IsDead ? "X" : n.Fret.ToString(); if (n.IsGhost) { _noteString = "(" + _noteString + ")"; } } else if (n.Beat.Index == 0) { _noteString = "(" + n.TieOrigin.Fret + ")"; } else { _noteString = ""; } }
private void Note(Beat beat) { // fret.string var syData = _syData.ToString().ToLower(); if (_sy != AlphaTexSymbols.Number && !(_sy == AlphaTexSymbols.String && (syData == "x" || syData == "-"))) { Error("note-fret", AlphaTexSymbols.Number); } var isDead = syData == "x"; var isTie = syData == "-"; int fret = (int)(isDead || isTie ? 0 : _syData); NewSy(); // Fret done if (_sy != AlphaTexSymbols.Dot) { Error("note", AlphaTexSymbols.Dot); } NewSy(); // dot done if (_sy != AlphaTexSymbols.Number) { Error("note-string", AlphaTexSymbols.Number); } int @string = (int)_syData; if (@string < 1 || @string > _track.Tuning.Length) { Error("note-string", AlphaTexSymbols.Number, false); } NewSy(); // string done // read effects var note = new Note(); beat.AddNote(note); note.String = _track.Tuning.Length - (@string - 1); note.IsDead = isDead; note.IsTieDestination = isTie; if (!isTie) { note.Fret = fret; } NoteEffects(note); }
public void AddNote(Note note) { note.Beat = this; Notes.Add(note); }
private Glyph CreateNoteHeadGlyph(Note n) { var isGrace = Container.Beat.GraceType != GraceType.None; if (n.Beat.Voice.Bar.Staff.Track.IsPercussion) { var value = n.RealValue; if (value <= 30 || value >= 67 || NormalKeys.ContainsKey(value)) { return new NoteHeadGlyph(0, 0, Duration.Quarter, isGrace); } if (XKeys.ContainsKey(value)) { return new DrumSticksGlyph(0, 0, isGrace); } if (value == 46) { return new HiHatGlyph(0, 0, isGrace); } if (value == 49 || value == 57) { return new DiamondNoteHeadGlyph(0, 0, isGrace); } if (value == 52) { return new ChineseCymbalGlyph(0, 0, isGrace); } if (value == 51 || value == 53 || value == 59) { return new RideCymbalGlyph(0, 0, isGrace); } return new NoteHeadGlyph(0, 0, Duration.Quarter, isGrace); } if (n.IsDead) { return new DeadNoteHeadGlyph(0, 0, isGrace); } if (n.HarmonicType == HarmonicType.None) { return new NoteHeadGlyph(0, 0, n.Beat.Duration, isGrace); } return new DiamondNoteHeadGlyph(0, 0, isGrace); }
private void NoteEffects(Note note) { if (_sy != AlphaTexSymbols.LBrace) { return; } NewSy(); while (_sy == AlphaTexSymbols.String) { var syData = _syData.ToString().ToLower(); _syData = syData; if (syData == "b") { // read points NewSy(); if (_sy != AlphaTexSymbols.LParensis) { Error("bend-effect", AlphaTexSymbols.LParensis); } NewSy(); while (_sy != AlphaTexSymbols.RParensis && _sy != AlphaTexSymbols.Eof) { if (_sy != AlphaTexSymbols.Number) { Error("bend-effect-value", AlphaTexSymbols.Number); } var bendValue = (int)_syData; note.AddBendPoint(new BendPoint(0, (Math.Abs(bendValue)))); NewSy(); } while (note.BendPoints.Count > 60) { note.BendPoints.RemoveAt(note.BendPoints.Count - 1); } // set positions var count = note.BendPoints.Count; var step = 60 / count; var i = 0; while (i < count) { note.BendPoints[i].Offset = Math.Min(60, (i * step)); i++; } if (_sy != AlphaTexSymbols.RParensis) { Error("bend-effect", AlphaTexSymbols.RParensis); } NewSy(); } else if (syData == "nh") { note.HarmonicType = HarmonicType.Natural; NewSy(); } else if (syData == "ah") { // todo: Artificial Key note.HarmonicType = HarmonicType.Artificial; NewSy(); } else if (syData == "th") { // todo: store tapped fret in data note.HarmonicType = HarmonicType.Tap; NewSy(); } else if (syData == "ph") { note.HarmonicType = HarmonicType.Pinch; NewSy(); } else if (syData == "sh") { note.HarmonicType = HarmonicType.Semi; NewSy(); } else if (syData == "gr") // TODO: Make this a beat effect! { NewSy(); if (_syData.ToString().ToLower() == "ob") { note.Beat.GraceType = GraceType.OnBeat; NewSy(); } else { note.Beat.GraceType = GraceType.BeforeBeat; } } else if (syData == "tr") { NewSy(); if (_sy != AlphaTexSymbols.Number) { Error("trill-effect", AlphaTexSymbols.Number); } int fret = (int)_syData; NewSy(); var duration = Duration.Sixteenth; if (_sy == AlphaTexSymbols.Number) { switch ((int)_syData) { case 16: duration = Duration.Sixteenth; break; case 32: duration = Duration.ThirtySecond; break; case 64: duration = Duration.ThirtySecond; break; default: duration = Duration.Sixteenth; break; } NewSy(); } note.TrillValue = fret + note.StringTuning; note.TrillSpeed = duration; } else if (syData == "tp") { NewSy(); var duration = Duration.Eighth; if (_sy == AlphaTexSymbols.Number) { switch ((int)_syData) { case 8: duration = Duration.Eighth; break; case 16: duration = Duration.Sixteenth; break; case 32: duration = Duration.ThirtySecond; break; default: duration = Duration.Eighth; break; } NewSy(); } note.Beat.TremoloSpeed = duration; } else if (syData == "v") { NewSy(); note.Vibrato = VibratoType.Slight; } else if (syData == "sl") { NewSy(); note.SlideType = SlideType.Legato; } else if (syData == "ss") { NewSy(); note.SlideType = SlideType.Shift; } else if (syData == "h") { NewSy(); note.IsHammerPullOrigin = true; } else if (syData == "g") { NewSy(); note.IsGhost = true; } else if (syData == "ac") { NewSy(); note.Accentuated = AccentuationType.Normal; } else if (syData == "hac") { NewSy(); note.Accentuated = AccentuationType.Heavy; } else if (syData == "pm") { NewSy(); note.IsPalmMute = true; } else if (syData == "st") { NewSy(); note.IsStaccato = true; } else if (syData == "lr") { NewSy(); note.IsLetRing = true; } else if (syData == "x") { NewSy(); note.Fret = 0; note.IsDead = true; } else if (ApplyBeatEffect(note.Beat)) // also try beat effects { // Success } else { Error(syData, AlphaTexSymbols.String, false); } } if (_sy != AlphaTexSymbols.RBrace) { Error("note-effect", AlphaTexSymbols.RBrace, false); } NewSy(); }
public void AddNoteGlyph(NoteNumberGlyph noteGlyph, Note note) { _notes.Add(noteGlyph); _noteLookup[note.String] = noteGlyph; if (_minNote == null || note.String < _minNote.String) _minNote = note; }
private void CreateNoteGlyph(Note n) { var sr = (ScoreBarRenderer)Renderer; var noteHeadGlyph = CreateNoteHeadGlyph(n); // calculate y position var line = sr.GetNoteLine(n); noteHeadGlyph.Y = sr.GetScoreY(line); NoteHeads.AddNoteGlyph(noteHeadGlyph, n, line); if (n.IsStaccato && !NoteHeads.BeatEffects.ContainsKey("Staccato")) { NoteHeads.BeatEffects["Staccato"] = new CircleGlyph(0, 0, 1.5f); } if (n.Accentuated == AccentuationType.Normal && !NoteHeads.BeatEffects.ContainsKey("Accent")) { NoteHeads.BeatEffects["Accent"] = new AccentuationGlyph(0, 0, AccentuationType.Normal); } if (n.Accentuated == AccentuationType.Heavy && !NoteHeads.BeatEffects.ContainsKey("HAccent")) { NoteHeads.BeatEffects["HAccent"] = new AccentuationGlyph(0, 0, AccentuationType.Heavy); } }
private void ParsePitch(IXmlNode element, Track track, Beat beat, Note note) { string step = null; int semitones = 0; int octave = 0; element.IterateChildren(c => { if (c.NodeType == XmlNodeType.Element) { switch (c.LocalName) { case "step": step = Std.GetNodeValue(c); break; case "alter": semitones = Std.ParseInt(Std.GetNodeValue(c)); break; case "octave": // 0-9, 4 for middle C octave = Std.ParseInt(Std.GetNodeValue(c)); break; } } }); var fullNoteName = step + octave; var fullNoteValue = TuningParser.GetTuningForText(fullNoteName) + semitones; ApplyNoteStringFrets(track, beat, note, fullNoteValue); }
private void ApplyNoteStringFrets(Track track, Beat beat, Note note, int fullNoteValue) { note.String = FindStringForValue(track, beat, fullNoteValue); note.Fret = fullNoteValue - Note.GetStringTuning(track, note.String); }
private bool ParseNoteBeat(IXmlNode element, Track track, Bar bar, bool chord, bool isFirstBeat) { int voiceIndex = 0; var voiceNodes = element.GetElementsByTagName("voice"); if (voiceNodes.Length > 0) { voiceIndex = Std.ParseInt(Std.GetNodeValue(voiceNodes[0])) - 1; } Beat beat; var voice = GetOrCreateVoice(bar, voiceIndex); if (chord || (isFirstBeat && voice.Beats.Count == 1)) { beat = voice.Beats[voice.Beats.Count - 1]; } else { beat = new Beat(); voice.AddBeat(beat); } var note = new Note(); beat.AddNote(note); beat.IsEmpty = false; element.IterateChildren(c => { if (c.NodeType == XmlNodeType.Element) { switch (c.LocalName) { case "grace": //var slash = e.GetAttribute("slash"); //var makeTime = Std.ParseInt(e.GetAttribute("make-time")); //var stealTimePrevious = Std.ParseInt(e.GetAttribute("steal-time-previous")); //var stealTimeFollowing = Std.ParseInt(e.GetAttribute("steal-time-following")); beat.GraceType = GraceType.BeforeBeat; beat.Duration = Duration.ThirtySecond; break; case "duration": beat.Duration = (Duration)Std.ParseInt(Std.GetNodeValue(c)); break; case "tie": ParseTied(c, note); break; case "cue": // not supported break; case "instrument": // not supported break; case "type": switch (Std.GetNodeValue(c)) { case "256th": beat.Duration = Duration.TwoHundredFiftySixth; break; case "128th": beat.Duration = Duration.OneHundredTwentyEighth; break; case "breve": beat.Duration = Duration.DoubleWhole; break; case "long": beat.Duration = Duration.QuadrupleWhole; break; case "64th": beat.Duration = Duration.SixtyFourth; break; case "32nd": beat.Duration = Duration.ThirtySecond; break; case "16th": beat.Duration = Duration.Sixteenth; break; case "eighth": beat.Duration = Duration.Eighth; break; case "quarter": beat.Duration = Duration.Quarter; break; case "half": beat.Duration = Duration.Half; break; case "whole": beat.Duration = Duration.Whole; break; } break; case "dot": note.IsStaccato = true; break; case "accidental": ParseAccidental(c, note); break; case "time-modification": ParseTimeModification(c, beat); break; case "stem": // not supported break; case "notehead": if (c.GetAttribute("parentheses") == "yes") { note.IsGhost = true; } break; case "beam": // not supported break; case "notations": ParseNotations(c, beat, note); break; case "lyric": // not supported break; // "full-note" case "chord": chord = true; break; case "pitch": ParsePitch(c, track, beat, note); break; case "unpitched": // TODO: not yet fully supported note.String = 0; note.Fret = 0; break; case "rest": beat.IsEmpty = false; break; } } }); return chord; }
private void ParseAccidental(IXmlNode element, Note note) { switch (Std.GetNodeValue(element)) { case "sharp": note.AccidentalMode = NoteAccidentalMode.ForceSharp; break; case "natural": note.AccidentalMode = NoteAccidentalMode.ForceNatural; break; case "flat": note.AccidentalMode = NoteAccidentalMode.ForceFlat; break; //case "double-sharp": // break; //case "sharp-sharp": // break; //case "flat-flat": // break; //case "natural-sharp": // break; //case "natural-flat": // break; //case "quarter-flat": // break; //case "quarter-sharp": // break; //case "three-quarters-flat": // break; //case "three-quarters-sharp": // break; } }
private void ParseNotations(IXmlNode element, Beat beat, Note note) { element.IterateChildren(c => { if (c.NodeType == XmlNodeType.Element) { switch (c.LocalName) { case "tied": ParseTied(c, note); break; case "slide": if (c.GetAttribute("type") == "start") { note.SlideType = SlideType.Legato; } break; case "dynamics": ParseDynamics(c, beat); break; } } }); }