Exemplo n.º 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  = (BendType)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);
    }
Exemplo n.º 2
0
    private Chord readChord(int stringCount)
    {
        var chord = new Chord(stringCount);

        chord.newFormat = GPBase.readBool()[0];
        if (!chord.newFormat)
        {
            readOldChord(chord);
        }
        else
        {
            readNewChord(chord);
        }
        if ((chord.notes().Length) > 0)
        {
            return(chord);
        }
        return(null);
    }
Exemplo n.º 3
0
    public override void readSong()
    {
        //HEADERS
        //VERSION
        version      = readVersion();
        versionTuple = readVersionTuple();
        //INFORMATION ABOUT THE PIECE
        readInfo();
        _tripletFeel = GPBase.readBool()[0] ? TripletFeel.eigth : TripletFeel.none;
        //readLyrics();
        tempo = GPBase.readInt()[0];
        key   = (KeySignature)(GPBase.readInt()[0] * 10); //key + 0
        //GPBase.readSignedByte(); //octave
        readMidiChannels();
        measureCount = GPBase.readInt()[0];
        trackCount   = GPBase.readInt()[0];

        readMeasureHeaders(measureCount);
        readTracks(trackCount, channels);
        readMeasures();
    }
Exemplo n.º 4
0
    private void readNewChord(Chord chord)
    {
        /*Read new-style (GP4) chord diagram.
         *
         * New-style chord diagram is read as follows:
         *
         * - Sharp: :ref:`bool`. If true, display all semitones as sharps,
         * otherwise display as flats.
         *
         * - Blank space, 3 :ref:`Bytes <byte>`.
         *
         * - Root: :ref:`int`. Values are:
         *
         * -1 for customized chords
         *  0: C
         *  1: C#
         * ...
         *
         * - Type: :ref:`int`. Determines the chord type as followed. See
         * :class:`guitarpro.models.ChordType` for mapping.
         *
         * - Chord extension: :ref:`int`. See
         * :class:`guitarpro.models.ChordExtension` for mapping.
         *
         * - Bass note: :ref:`int`. Lowest note of chord as in *C/Am*.
         *
         * - Tonality: :ref:`int`. See
         * :class:`guitarpro.models.ChordAlteration` for mapping.
         *
         * - Add: :ref:`bool`. Determines if an "add" (added note) is
         * present in the chord.
         *
         * - Name: :ref:`byte-size-string`. Max length is 22.
         *
         * - Fifth alteration: :ref:`int`. Maps to
         * :class:`guitarpro.models.ChordAlteration`.
         *
         * - Ninth alteration: :ref:`int`. Maps to
         * :class:`guitarpro.models.ChordAlteration`.
         *
         * - Eleventh alteration: :ref:`int`. Maps to
         * :class:`guitarpro.models.ChordAlteration`.
         *
         * - List of frets: 6 :ref:`Ints <int>`. Fret values are saved as
         * in default format.
         *
         * - Count of barres: :ref:`int`. Maximum count is 2.
         *
         * - Barre frets: 2 :ref:`Ints <int>`.
         *
         * - Barre start strings: 2 :ref:`Ints <int>`.
         *
         * - Barre end string: 2 :ref:`Ints <int>`.
         *
         * - Omissions: 7 :ref:`Bools <bool>`. If the value is true then
         * note is played in chord.
         *
         * - Blank space, 1 :ref:`byte`.*/

        chord.sharp = GPBase.readBool()[0];
        var intonation = chord.sharp ? "sharp" : "flat";

        GPBase.skip(3);
        chord.root      = new PitchClass(GPBase.readByte()[0], -1, "", intonation);
        chord.type      = (ChordType)GPBase.readByte()[0];
        chord.extension = (ChordExtension)GPBase.readByte()[0];
        chord.bass      = new PitchClass(GPBase.readInt()[0], -1, "", intonation);
        chord.tonality  = (ChordAlteration)GPBase.readInt()[0];
        chord.add       = GPBase.readBool()[0];
        chord.name      = GPBase.readByteSizeString(22);
        chord.fifth     = (ChordAlteration)GPBase.readByte()[0];
        chord.ninth     = (ChordAlteration)GPBase.readByte()[0];
        chord.eleventh  = (ChordAlteration)GPBase.readByte()[0];
        chord.firstFret = GPBase.readInt()[0];
        for (int i = 0; i < 7; i++)
        {
            var fret = GPBase.readInt()[0];
            if (i < chord.strings.Length)
            {
                chord.strings[i] = fret;
            }
        }
        chord.barres.Clear();
        var barresCount = GPBase.readByte()[0];
        var barreFrets  = GPBase.readByte(5);
        var barreStarts = GPBase.readByte(5);
        var barreEnds   = GPBase.readByte(5);

        for (int x = 0; x < Math.Min(5, (int)barresCount); x++)
        {
            var barre = new Barre(barreFrets[x], barreStarts[x], barreEnds[x]);
            chord.barres.Add(barre);
        }
        chord.omissions = GPBase.readBool(7);
        GPBase.skip(1);
        List <Fingering> f = new List <Fingering>();

        for (int x = 0; x < 7; x++)
        {
            f.Add((Fingering)GPBase.readSignedByte()[0]);
        }
        chord.fingerings = f;
        chord.show       = GPBase.readBool()[0];
    }