Example #1
0
        private BendEffect ReadBend()
        {
            /*Encoded as:
             *
             * -Bend type: :ref:`signed - byte`. See
             * :class:`guitarpro.models.BendType`.
             *
             * - Bend value: :ref:`int`.
             *
             * - Number of bend points: :ref:`int`.
             *
             * - List of points.Each point consists of:
             *
             * Position: :ref:`int`. Shows where point is set along
             * x*-axis.
             *
             * Value: :ref:`int`. Shows where point is set along *y*-axis.
             *
             * Vibrato: :ref:`bool`. */
            var bendEffect = new BendEffect();

            bendEffect.Type  = (BendTypes)GpBase.ReadSignedByte()[0];
            bendEffect.Value = GpBase.ReadInt()[0];
            var pointCount = GpBase.ReadInt()[0];

            for (int x = 0; x < pointCount; x++)
            {
                var position = (int)Math.Round(GpBase.ReadInt()[0] * BendEffect.MaxPosition / (float)GpBase.BendPosition);
                var value    = (int)Math.Round(GpBase.ReadInt()[0] * BendEffect.SemitoneLength / (float)GpBase.BendSemitone);
                var vibrato  = GpBase.ReadBool()[0];
                bendEffect.Points.Add(new BendPoint(position, value, vibrato));
            }
            return(bendEffect);
        }
Example #2
0
        private BendEffect ReadTremoloBar()
        {
            var barEffect = new BendEffect();

            barEffect.Type   = BendTypes.Dip;
            barEffect.Value  = GpBase.ReadInt()[0];
            barEffect.Points = new List <BendPoint>();
            barEffect.Points.Add(new BendPoint(0, 0));
            barEffect.Points.Add(new BendPoint((int)Math.Round(BendEffect.MaxPosition / 2.0f), (int)Math.Round(-barEffect.Value / (double)GpBase.BendSemitone)));
            barEffect.Points.Add(new BendPoint(BendEffect.MaxPosition, 0));

            return(barEffect);
        }
Example #3
0
    private BendEffect readTremoloBar()
    {
        var barEffect = new BendEffect();

        barEffect.type   = BendType.dip;
        barEffect.value  = GPBase.readInt()[0];
        barEffect.points = new List <BendPoint>();
        barEffect.points.Add(new BendPoint(0, 0));
        barEffect.points.Add(new BendPoint((int)Math.Round(BendEffect.maxPosition / 2.0f), (int)Math.Round(-barEffect.value / (double)GPBase.bendSemitone)));
        barEffect.points.Add(new BendPoint(BendEffect.maxPosition, 0));

        return(barEffect);
    }
Example #4
0
        public List <BendPoint> GetBendPoints(int index, int duration, BendEffect bend)
        {
            List <BendPoint> ret = new List <BendPoint>();
            int at;

            foreach (GP.BendPoint bp in bend.Points)
            {
                at = index + (int)(bp.Gp6Position * duration / 100.0f);
                var point = new BendPoint();
                point.Index = at;
                point.Value = bp.Gp6Value;
                ret.Add(point);
            }

            return(ret);
        }
Example #5
0
        public void AddToTremoloBarList(int index, int duration, BendEffect bend, Track myTrack)
        {
            int at;

            myTrack.TremoloPoints.Add(new TremoloPoint(0.0f, index)); //So that it can later be recognized as the beginning
            foreach (GP.BendPoint bp in bend.Points)
            {
                at = index + (int)(bp.Gp6Position * duration / 100.0f);
                var point = new TremoloPoint();
                point.Index = at;
                point.Value = bp.Gp6Value;
                myTrack.TremoloPoints.Add(point);
            }
            var tp = new TremoloPoint();

            tp.Index = index + duration;
            tp.Value = 0;
            myTrack.TremoloPoints.Add(tp); //Back to 0 -> Worst case there will be on the same index the final of tone 1, 0, and the beginning of tone 2.
        }