Example #1
0
        public BendPoint Clone()
        {
            var point = new BendPoint();

            CopyTo(this, point);
            return(point);
        }
Example #2
0
        public override void DoLayout()
        {
            base.DoLayout();

            _isSimpleDip = Renderer.Settings.DisplayMode == DisplayMode.SongBook &&
                           _beat.WhammyBarType == WhammyType.Dip;

            //
            // Get the min and max values for all combined whammys
            BendPoint minValue = null;
            BendPoint maxValue = null;

            Beat beat = _beat;

            while (beat != null && beat.HasWhammyBar)
            {
                if (minValue == null || minValue.Value > beat.MinWhammyPoint.Value)
                {
                    minValue = beat.MinWhammyPoint;
                }

                if (maxValue == null || maxValue.Value < beat.MaxWhammyPoint.Value)
                {
                    maxValue = beat.MaxWhammyPoint;
                }

                beat = beat.NextBeat;
            }

            var topOffset = maxValue.Value > 0 ? Math.Abs(GetOffset(maxValue.Value)) : 0;

            if (topOffset > 0 || _beat.WhammyBarPoints[0].Value != 0 || Renderer.Settings.ShowZeroOnDiveWhammy)
            {
                topOffset += Renderer.Resources.TablatureFont.Size * 2f;
            }

            var bottomOffset = minValue.Value < 0 ? Math.Abs(GetOffset(minValue.Value)) : 0;

            Renderer.RegisterOverflowTop(topOffset + bottomOffset);

            var currentOffset = Renderer.Staff.GetSharedLayoutData(TopOffsetSharedDataKey, -1);

            if (topOffset > currentOffset)
            {
                Renderer.Staff.SetSharedLayoutData(TopOffsetSharedDataKey, topOffset);
            }
        }
Example #3
0
        public void ReadTremoloBarEffect(Beat beat)
        {
            _data.ReadByte(); // type
            ReadInt32();      // value
            var pointCount = ReadInt32();

            if (pointCount > 0)
            {
                for (int i = 0; i < pointCount; i++)
                {
                    var point = new BendPoint();
                    point.Offset = ReadInt32();            // 0...60
                    point.Value  = ReadInt32() / BendStep; // 0..12 (amount of quarters)
                    ReadBool();                            // vibrato
                    beat.WhammyBarPoints.Add(point);
                }
            }
        }
Example #4
0
        public void ReadBend(Note note)
        {
            _data.ReadByte(); // type
            ReadInt32();      // value
            var pointCount = ReadInt32();

            if (pointCount > 0)
            {
                for (int i = 0; i < pointCount; i++)
                {
                    var point = new BendPoint();
                    point.Offset = ReadInt32();            // 0...60
                    point.Value  = ReadInt32() / BendStep; // 0..12 (amount of quarters)
                    ReadBool();                            // vibrato
                    note.BendPoints.Add(point);
                }
            }
        }
Example #5
0
        private void PaintBend(BendPoint firstPt, BendPoint secondPt, float cx, float cy, float dX, ICanvas canvas)
        {
            var r   = (TabBarRenderer)Renderer;
            var res = Renderer.Resources;

            var overflowOffset = r.LineOffset / 2;

            var x1 = cx + (dX * firstPt.Offset);
            var y1 = cy - (_bendValueHeight * firstPt.Value);

            if (firstPt.Value == 0)
            {
                y1 += r.GetNoteY(_note);
            }
            else
            {
                y1 += overflowOffset;
            }
            var x2 = cx + (dX * secondPt.Offset);
            var y2 = cy - (_bendValueHeight * secondPt.Value);

            if (secondPt.Value == 0)
            {
                y2 += r.GetNoteY(_note);
            }
            else
            {
                y2 += overflowOffset;
            }

            // what type of arrow? (up/down)
            var arrowOffset = 0f;
            var arrowSize   = 6 * Scale;

            if (secondPt.Value > firstPt.Value)
            {
                canvas.BeginPath();
                canvas.MoveTo(x2, y2);
                canvas.LineTo(x2 - arrowSize * 0.5f, y2 + arrowSize);
                canvas.LineTo(x2 + arrowSize * 0.5f, y2 + arrowSize);
                canvas.ClosePath();
                canvas.Fill();
                arrowOffset = arrowSize;
            }
            else if (secondPt.Value != firstPt.Value)
            {
                canvas.BeginPath();
                canvas.MoveTo(x2, y2);
                canvas.LineTo(x2 - arrowSize * 0.5f, y2 - arrowSize);
                canvas.LineTo(x2 + arrowSize * 0.5f, y2 - arrowSize);
                canvas.ClosePath();
                canvas.Fill();
                arrowOffset = -arrowSize;
            }
            canvas.Stroke();

            if (firstPt.Value == secondPt.Value)
            {
                // draw horizontal line
                canvas.MoveTo(x1, y1);
                canvas.LineTo(x2, y2);
                canvas.Stroke();
            }
            else
            {
                if (x2 > x1)
                {
                    // draw bezier lien from first to second point
                    canvas.MoveTo(x1, y1);
                    canvas.BezierCurveTo(x2, y1, x2, y2 + arrowOffset, x2, y2 + arrowOffset);
                    canvas.Stroke();
                }
                else
                {
                    canvas.MoveTo(x1, y1);
                    canvas.LineTo(x2, y2);
                    canvas.Stroke();
                }
            }



            if (secondPt.Value != 0)
            {
                var dV = secondPt.Value;
                var up = secondPt.Value > firstPt.Value;
                dV = Math.Abs(dV);

                // calculate label
                var s = "";
                // Full Steps
                if (dV == 4 && up)
                {
                    s   = "full";
                    dV -= 4;
                }
                else if (dV >= 4)
                {
                    int steps = dV / 4;
                    s += steps;
                    // Quaters
                    dV -= steps * 4;
                }

                if (dV > 0)
                {
                    s += GetFractionSign(dV);
                }

                if (s != "")
                {
                    if (!up)
                    {
                        s = "-" + s;
                    }

                    // draw label
                    canvas.Font = res.TablatureFont;
                    var size = canvas.MeasureText(s);
                    var y    = up ? y2 - res.TablatureFont.Size - (2 * Scale) : y2 + (2 * Scale);
                    var x    = x2 - size / 2;

                    canvas.FillText(s, x, y);
                }
            }
        }
Example #6
0
 private int GetBendNoteValue(Note note, BendPoint bendPoint)
 {
     // NOTE: bendpoints are in 1/4 tones, but the note values are in 1/2 notes.
     return(note.DisplayValueWithoutBend + bendPoint.Value / 2);
 }
Example #7
0
        private static Note NoteFromNote(SongNote2014 srcNote, Single durationTime)
        {
            //DbgAssert(srcNote.LinkNext == 0);
            //DbgAssert(srcNote.Bend == 0);
            //DbgAssert(srcNote.HammerOn == 0);
            //DbgAssert(srcNote.Harmonic == 0);
            //DbgAssert(srcNote.Hopo == 0);
            //DbgAssert(srcNote.Ignore == 0);
            //DbgAssert(srcNote.Mute == 0);
            //DbgAssert(srcNote.PalmMute == 0);
            //DbgAssert(srcNote.Pluck == -1);
            //DbgAssert(srcNote.PullOff == 0);
            //DbgAssert(srcNote.Slap == -1);
            //DbgAssert(srcNote.Tremolo == 0);
            //DbgAssert(srcNote.HarmonicPinch == 0);
            //DbgAssert(srcNote.PickDirection == 0);
            //DbgAssert(srcNote.Tap == 0);
            //DbgAssert(srcNote.Vibrato == 0);

            var note1 = new Note();

            note1.Fret        = srcNote.Fret;
            note1.String      = srcNote.String + 1;
            note1.Accentuated = srcNote.Accent == 1 ? AccentuationType.Normal : AccentuationType.None;

            if (srcNote.BendValues != null)
            {
                foreach (var srcBend in srcNote.BendValues)
                {
                    var bp            = new BendPoint();
                    var srcBendOffset = srcBend.Time - srcNote.Time;
                    bp.Offset = (int)Math.Round((srcBendOffset / durationTime) * 60);
                    bp.Value  = (int)(srcBend.Step * 4);
                    note1.BendPoints.Insert(note1.BendPoints.Count, bp);
                    //note1.bendPoints.insert
                }
                if (note1.BendPoints.Count > 0)
                {
                    var lastbp = note1.BendPoints[note1.BendPoints.Count - 1] as BendPoint;
                    if (lastbp.Offset < 60)
                    {
                        var bp = new BendPoint();
                        bp.Offset = 60;
                        bp.Value  = lastbp.Value;
                        note1.BendPoints.Insert(note1.BendPoints.Count, bp);
                    }

                    var firstBp = note1.BendPoints[0] as BendPoint;
                    if (firstBp.Offset > 0)
                    {
                        var bp = new BendPoint();
                        bp.Offset = 0;
                        bp.Value  = 0;
                        note1.BendPoints.Insert(0, bp);
                    }
                }
            }

            if (srcNote.SlideTo > -1)
            {
                note1.SlideType = SlideType.Shift;
            }

            if (srcNote.SlideUnpitchTo > -1)
            {
                if (srcNote.SlideUnpitchTo > srcNote.Fret)
                {
                    note1.SlideType = SlideType.OutUp;
                }
                else
                {
                    note1.SlideType = SlideType.OutDown;
                }
            }

            //note1.bendPoints
            //src.bend
            //note1.durationPercent
            //note1.hammerPullOrigin
            //note1.harmonicType=HarmonicType.Natural
            //note1.harmonicValue
            //note1.isDead
            //note1.isFingering
            //note1.isGhost
            //note1.isHammerPullDestination
            //note1.isHammerPullOrigin
            //note1.isLetRing
            //note1.isPalmMute
            //note1.isStaccato
            //note1.isTieDestination
            //note1.isTieOrigin
            //note1.leftHandFinger
            //note1.octave
            //note1.slideTarget
            //note1.slideType=SlideType.IntoFromAbove
            //note1.tieOrigin
            //note1.trillSpeed
            //note1.trillValue
            //note1.vibrato

            return(note1);
        }
Example #8
0
 public static void CopyTo(BendPoint src, BendPoint dst)
 {
     dst.Offset = src.Offset;
     dst.Value  = src.Value;
 }
Example #9
0
        private void PaintWhammy(bool isFirst, BendPoint firstPt, BendPoint secondPt, BendPoint nextPt, float cx, float cy, float dx, ICanvas canvas, string slurText = null)
        {
            var x1 = cx + dx * firstPt.Offset;
            var x2 = cx + dx * secondPt.Offset;

            var y1 = cy - GetOffset(firstPt.Value);
            var y2 = cy - GetOffset(secondPt.Value);

            if (firstPt.Offset == secondPt.Offset)
            {
                var dashSize = DashSize * Scale;
                var dashes   = Math.Abs(y2 - y1) / (dashSize * 2);
                if (dashes < 1)
                {
                    canvas.MoveTo(x1, y1);
                    canvas.LineTo(x2, y2);
                }
                else
                {
                    var dashEndY   = Math.Max(y1, y2);
                    var dashStartY = Math.Min(y1, y2);

                    while (dashEndY > dashStartY)
                    {
                        canvas.MoveTo(x1, dashStartY);
                        canvas.LineTo(x1, dashStartY + dashSize);

                        dashStartY += dashSize * 2;
                    }
                }
                canvas.Stroke();
            }
            else if (firstPt.Value == secondPt.Value)
            {
                var dashSize = DashSize * Scale;
                var dashes   = Math.Abs(x2 - x1) / (dashSize * 2);
                if (dashes < 1)
                {
                    canvas.MoveTo(x1, y1);
                    canvas.LineTo(x2, y2);
                }
                else
                {
                    var dashEndX   = Math.Max(x1, x2);
                    var dashStartX = Math.Min(x1, x2);

                    while (dashEndX > dashStartX)
                    {
                        canvas.MoveTo(dashEndX, y1);
                        canvas.LineTo(dashEndX - dashSize, y1);

                        dashEndX -= dashSize * 2;
                    }
                }
                canvas.Stroke();
            }
            else
            {
                canvas.MoveTo(x1, y1);
                canvas.LineTo(x2, y2);
            }

            var res = canvas.Resources;

            if (isFirst && !_beat.IsContinuedWhammy && !_isSimpleDip)
            {
                float y = y1;
                y -= res.TablatureFont.Size + (2 * Scale);
                if (Renderer.Settings.ShowZeroOnDiveWhammy)
                {
                    canvas.FillText("0", x1, y);
                }

                if (slurText != null)
                {
                    y -= res.TablatureFont.Size + (2 * Scale);
                    canvas.FillText(slurText, x1, y);
                }
            }

            var dV = Math.Abs(secondPt.Value);

            if ((dV != 0 || (Renderer.Settings.ShowZeroOnDiveWhammy && !_isSimpleDip)) && firstPt.Value != secondPt.Value)
            {
                var s = "";
                if (secondPt.Value < 0)
                {
                    s += "-";
                }

                if (dV >= 4)
                {
                    int steps = dV / 4;
                    s += steps;
                    // Quaters
                    dV -= steps * 4;
                }
                else if (dV == 0)
                {
                    s += "0";
                }

                if (dV > 0)
                {
                    s += TabBendGlyph.GetFractionSign(dV);
                }

                float y;
                if (_isSimpleDip)
                {
                    y = Math.Min(y1, y2) - res.TablatureFont.Size - (2 * Scale);
                }
                else
                {
                    y  = firstPt.Offset == secondPt.Offset ? Math.Min(y1, y2) : y2;
                    y -= res.TablatureFont.Size + (2 * Scale);
                    if (nextPt != null && nextPt.Value > secondPt.Value)
                    {
                        y -= (2 * Scale);
                    }
                }

                var x = x2;

                canvas.FillText(s, x, y);
            }
        }
Example #10
0
 public BendPoint Clone()
 {
     var point = new BendPoint();
     CopyTo(this, point);
     return point;
 }
Example #11
0
 public static void CopyTo(BendPoint src, BendPoint dst)
 {
     dst.Offset = src.Offset;
     dst.Value = src.Value;
 }