Esempio n. 1
0
    private void readTrack(Track track, MidiChannel[] channels)
    {
        /*
         * Read track.
         *
         * The first byte is the track's flags. It presides the track's
         * attributes:
         *
         * - *0x01*: drums track
         * - *0x02*: 12 stringed guitar track
         * - *0x04*: banjo track
         * - *0x08*: *blank*
         * - *0x10*: *blank*
         * - *0x20*: *blank*
         * - *0x40*: *blank*
         * - *0x80*: *blank*
         *
         * Flags are followed by:
         *
         * - Name: :ref:`byte-size-string`. A 40 characters long string
         * containing the track's name.
         *
         * - Number of strings: :ref:`int`. An integer equal to the number
         *  of strings of the track.
         *
         * - Tuning of the strings: List of 7 :ref:`Ints <int>`. The tuning
         * of the strings is stored as a 7-integers table, the "Number of
         * strings" first integers being really used. The strings are
         * stored from the highest to the lowest.
         *
         * - Port: :ref:`int`. The number of the MIDI port used.
         *
         * - Channel. See :meth:`GP3File.readChannel`.
         *
         * - Number of frets: :ref:`int`. The number of frets of the
         * instrument.
         *
         * - Height of the capo: :ref:`int`. The number of the fret on
         * which a capo is set. If no capo is used, the value is 0.
         *
         * - Track's color. The track's displayed color in Guitar Pro.*/
        byte flags = GPBase.readByte()[0];

        track.isPercussionTrack       = ((flags & 0x01) != 0);
        track.is12StringedGuitarTrack = ((flags & 0x02) != 0);
        track.isBanjoTrack            = ((flags & 0x04) != 0);
        track.name = GPBase.readByteSizeString(40);
        var stringCount = GPBase.readInt()[0];

        for (int i = 0; i < 7; i++)
        {
            int iTuning = GPBase.readInt()[0];
            if (stringCount > i)
            {
                var oString = new GuitarString(i + 1, iTuning);
                track.strings.Add(oString);
            }
        }
        track.port    = GPBase.readInt()[0];
        track.channel = readChannel(channels);
        if (track.channel.channel == 9)
        {
            track.isPercussionTrack = true;
        }
        track.fretCount = GPBase.readInt()[0];
        track.offset    = GPBase.readInt()[0];
        track.color     = readColor();
    }
Esempio n. 2
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];
    }
Esempio n. 3
0
    private string readVersion()
    {
        var version = GPBase.readByteSizeString(30);

        return(version);
    }