Beispiel #1
0
 private void ReadMixTableChangeDurations(MixTableChange tableChange)
 {
     if (tableChange.Volume != null)
     {
         tableChange.Volume.Duration = GpBase.ReadSignedByte()[0];
     }
     if (tableChange.Balance != null)
     {
         tableChange.Balance.Duration = GpBase.ReadSignedByte()[0];
     }
     if (tableChange.Chorus != null)
     {
         tableChange.Chorus.Duration = GpBase.ReadSignedByte()[0];
     }
     if (tableChange.Reverb != null)
     {
         tableChange.Reverb.Duration = GpBase.ReadSignedByte()[0];
     }
     if (tableChange.Phaser != null)
     {
         tableChange.Phaser.Duration = GpBase.ReadSignedByte()[0];
     }
     if (tableChange.Tremolo != null)
     {
         tableChange.Tremolo.Duration = GpBase.ReadSignedByte()[0];
     }
     if (tableChange.Tempo != null)
     {
         tableChange.Tempo.Duration = GpBase.ReadSignedByte()[0];
         tableChange.HideTempo      = false;
     }
 }
Beispiel #2
0
        private void ReadNotes(Track track, Beat.Beat beat, Duration duration, NoteEffect effect)
        {
            /* First byte lists played strings:
             *
             * - *0x01*: 7th string
             * - *0x02*: 6th string
             * - *0x04*: 5th string
             * - *0x08*: 4th string
             * - *0x10*: 3th string
             * - *0x20*: 2th string
             * - *0x40*: 1th string
             * - *0x80*: *blank**/

            var stringFlags = GpBase.ReadByte()[0];

            foreach (var str in track.Strings)
            {
                if ((stringFlags & 1 << (7 - str.Number)) != 0)
                {
                    var note = new Note(beat);
                    beat.Notes.Add(note);
                    ReadNote(note, str, track);
                }
                beat.Duration = duration;
            }
        }
Beispiel #3
0
        private BeatText ReadText()
        {
            var text = new BeatText();

            text.Value = GpBase.ReadIntByteSizeString();
            return(text);
        }
Beispiel #4
0
        private void ReadOldChord(Chord chord)
        {
            /*Read chord diagram encoded in GP3 format.
             *
             * Chord diagram is read as follows:
             *
             * - Name: :ref:`int-byte-size-string`. Name of the chord, e.g.
             * Em*.
             *
             * - First fret: :ref:`int`. The fret from which the chord is
             * displayed in chord editor.
             *
             * - List of frets: 6 :ref:`Ints <int>`. Frets are listed in order:
             * fret on the string 1, fret on the string 2, ..., fret on the
             * string 6. If string is untouched then the values of fret is
             *-1*.*/

            chord.Name      = GpBase.ReadIntByteSizeString();
            chord.FirstFret = GpBase.ReadInt()[0];
            if (chord.FirstFret > 0)
            {
                for (int i = 0; i < 6; i++)
                {
                    var fret = GpBase.ReadInt()[0];
                    if (i < chord.Strings.Length)
                    {
                        chord.Strings[i] = fret;
                    }
                }
            }
        }
Beispiel #5
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);
        }
Beispiel #6
0
        private List <SlideTypes> ReadSlides()
        {
            var retVal = new List <SlideTypes>();

            retVal.Add((SlideTypes)GpBase.ReadSignedByte()[0]);
            return(retVal);
        }
Beispiel #7
0
        private GraceEffect ReadGrace()
        {
            /*- Fret: :ref:`signed-byte`. Number of fret.
             *
             * - Dynamic: :ref:`byte`. Dynamic of a grace note, as in
             * :attr:`guitarpro.models.Note.velocity`.
             *
             * - Transition: :ref:`byte`. See
             * :class:`guitarpro.models.GraceEffectTransition`.
             *
             * - Duration: :ref:`byte`. Values are:
             *
             * - *1*: Thirty-second note.
             * - *2*: Twenty-fourth note.
             * - *3*: Sixteenth note.*/
            var grace = new GraceEffect();

            grace.Fret       = GpBase.ReadSignedByte()[0];
            grace.Velocity   = UnpackVelocity(GpBase.ReadByte()[0]);
            grace.Duration   = 1 << (7 - GpBase.ReadByte()[0]);
            grace.IsDead     = (grace.Fret == -1);
            grace.IsOnBeat   = false;
            grace.Transition = (GraceEffectTransitions)GpBase.ReadSignedByte()[0];
            return(grace);
        }
Beispiel #8
0
        private TrillEffect ReadTrill()
        {
            var trill = new TrillEffect();

            trill.Fret           = GpBase.ReadSignedByte()[0];
            trill.Duration.Value = FromTrillPeriod(GpBase.ReadSignedByte()[0]);
            return(trill);
        }
Beispiel #9
0
        private TremoloPickingEffect ReadTremoloPicking()
        {
            var value = GpBase.ReadSignedByte()[0];
            var tp    = new TremoloPickingEffect();

            tp.Duration.Value = FromTremoloValue(value);
            return(tp);
        }
Beispiel #10
0
        private NoteEffect ReadNoteEffects(Note note)
        {
            /*First byte is note effects flags:
             *
             * - *0x01*: bend presence
             * - *0x02*: hammer-on/pull-off
             * - *0x04*: slide
             * - *0x08*: let-ring
             * - *0x10*: grace note presence
             *
             * Flags are followed by:
             *
             * - Bend. See :meth:`readBend`.
             *
             * - Grace note. See :meth:`readGrace`.*/

            var noteEffect = note.Effect;

            if (noteEffect == null)
            {
                noteEffect = new NoteEffect();
            }
            var flags1 = GpBase.ReadSignedByte()[0];
            var flags2 = GpBase.ReadSignedByte()[0];

            noteEffect.Hammer   = ((flags1 & 0x02) != 0);
            noteEffect.LetRing  = ((flags1 & 0x08) != 0);
            noteEffect.Staccato = ((flags2 & 0x01) != 0);
            noteEffect.PalmMute = ((flags2 & 0x02) != 0);
            noteEffect.Vibrato  = ((flags2 & 0x40) != 0) || noteEffect.Vibrato;

            if ((flags1 & 0x01) != 0)
            {
                noteEffect.Bend = ReadBend();
            }
            if ((flags1 & 0x10) != 0)
            {
                noteEffect.Grace = ReadGrace();
            }
            if ((flags2 & 0x04) != 0)
            {
                noteEffect.TremoloPicking = ReadTremoloPicking();
            }
            if ((flags2 & 0x08) != 0)
            {
                noteEffect.Slides = ReadSlides();
            }
            if ((flags2 & 0x10) != 0)
            {
                noteEffect.Harmonic = ReadHarmonic(note);
            }
            if ((flags2 & 0x20) != 0)
            {
                noteEffect.Trill = ReadTrill();
            }

            return(noteEffect);
        }
Beispiel #11
0
        private BeatEffect ReadBeatEffects(NoteEffect effect)
        {
            /*
             * The first byte is effects flags:
             *
             * - *0x01*: vibrato
             * - *0x02*: wide vibrato
             * - *0x04*: natural harmonic
             * - *0x08*: artificial harmonic
             * - *0x10*: fade in
             * - *0x20*: tremolo bar or slap effect
             * - *0x40*: beat stroke direction
             * - *0x80*: *blank*
             *
             * - Tremolo bar or slap effect: :ref:`byte`. If it's 0 then
             * tremolo bar should be read (see :meth:`readTremoloBar`). Else
             * it's tapping and values of the byte map to:
             *
             * - *1*: tap
             * - *2*: slap
             * - *3*: pop
             *
             * - Beat stroke direction. See :meth:`readBeatStroke`.*/
            var beatEffects = new BeatEffect();
            var flags1      = GpBase.ReadByte()[0];

            effect.Vibrato      = ((flags1 & 0x01) != 0) || effect.Vibrato;
            beatEffects.Vibrato = ((flags1 & 0x02) != 0) || beatEffects.Vibrato;
            beatEffects.FadeIn  = ((flags1 & 0x10) != 0);
            if ((flags1 & 0x20) != 0)
            {
                var flags2 = GpBase.ReadByte()[0];
                beatEffects.SlapEffect = (SlapEffects)flags2;
                if (beatEffects.SlapEffect == SlapEffects.None)
                {
                    beatEffects.TremoloBar = ReadTremoloBar();
                }
                else
                {
                    GpBase.ReadInt();
                }
            }
            if ((flags1 & 0x40) != 0)
            {
                beatEffects.Stroke = ReadBeatStroke();
            }
            if ((flags1 & 0x04) != 0)
            {
                effect.Harmonic = new NaturalHarmonic();
            }
            if ((flags1 & 0x08) != 0)
            {
                effect.Harmonic = new ArtificialHarmonic();
            }

            return(beatEffects);
        }
Beispiel #12
0
        private Color ReadColor()
        {
            byte r = GpBase.ReadByte()[0];
            byte g = GpBase.ReadByte()[0];
            byte b = GpBase.ReadByte()[0];

            GpBase.Skip(1);
            return(new Color(r, g, b));
        }
Beispiel #13
0
        private void ReadVoice(int start, Voice voice)
        {
            //TODO: The pointer is 13 bytes too early here (when reading for measure 0xa of track 0x2, beats should return 1, not 898989)
            var beats = GpBase.ReadInt()[0];

            for (int beat = 0; beat < beats; beat++)
            {
                start += ReadBeat(start, voice);
            }
        }
Beispiel #14
0
        private Marker ReadMarker(MeasureHeader header)
        {
            Marker marker = new Marker();

            marker.Title         = GpBase.ReadIntByteSizeString();
            marker.Color         = ReadColor();
            marker.MeasureHeader = header;

            return(marker);
        }
Beispiel #15
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);
        }
Beispiel #16
0
        public Clipboard ReadClipboard()
        {
            if (!IsClipboard())
            {
                return(null);
            }
            var clipboard = new Clipboard();

            clipboard.StartMeasure = GpBase.ReadInt()[0];
            clipboard.StopMeasure  = GpBase.ReadInt()[0];
            clipboard.StartTrack   = GpBase.ReadInt()[0];
            clipboard.StopTrack    = GpBase.ReadInt()[0];
            return(clipboard);
        }
Beispiel #17
0
        private BeatStroke ReadBeatStroke()
        {
            var strokeDown = GpBase.ReadSignedByte()[0];
            var strokeUp   = GpBase.ReadSignedByte()[0];

            if (strokeUp > 0)
            {
                return(new BeatStroke(BeatStrokeDirections.Up, ToStrokeValue(strokeUp), 0.0f));
            }
            else
            {
                return(new BeatStroke(BeatStrokeDirections.Down, ToStrokeValue(strokeDown), 0.0f));
            }
        }
Beispiel #18
0
        private HarmonicEffect ReadHarmonic(Note note)
        {
            /*Harmonic is encoded in :ref:`signed-byte`. Values correspond to:
             *
             * - *1*: natural harmonic
             * - *3*: tapped harmonic
             * - *4*: pinch harmonic
             * - *5*: semi-harmonic
             * - *15*: artificial harmonic on (*n + 5*)th fret
             * - *17*: artificial harmonic on (*n + 7*)th fret
             * - *22*: artificial harmonic on (*n + 12*)th fret
             */
            var            harmonicType = GpBase.ReadSignedByte()[0];
            HarmonicEffect harmonic     = null;

            switch (harmonicType)
            {
            case 1:
                harmonic = new NaturalHarmonic(); break;

            case 3:
                harmonic = new TappedHarmonic(); break;

            case 4:
                harmonic = new PinchHarmonic(); break;

            case 5:
                harmonic = new SemiHarmonic(); break;

            case 15:
                var pitch  = new PitchClass((note.RealValue() + 7) % 12, -1, "", "", 7.0f);
                var octave = Octaves.Ottava;
                harmonic = new ArtificialHarmonic(pitch, octave);
                break;

            case 17:
                pitch    = new PitchClass(note.RealValue(), -1, "", "", 12.0f);
                octave   = Octaves.Quindicesima;
                harmonic = new ArtificialHarmonic(pitch, octave);
                break;

            case 22:
                pitch    = new PitchClass(note.RealValue(), -1, "", "", 5.0f);
                octave   = Octaves.Ottava;
                harmonic = new ArtificialHarmonic(pitch, octave);
                break;
            }
            return(harmonic);
        }
Beispiel #19
0
 private void ReadMidiChannels()
 {
     /*Read MIDI channels.
      *
      * Guitar Pro format provides 64 channels(4 MIDI ports by 16
      * channels), the channels are stored in this order:
      *
      * -port1 / channel1
      * - port1 / channel2
      * - ...
      * - port1 / channel16
      * - port2 / channel1
      * - ...
      * - port4 / channel16
      *
      * Each channel has the following form:
      * -Instrument: :ref:`int`.
      * -Volume: :ref:`byte`.
      * -Balance: :ref:`byte`.
      * -Chorus: :ref:`byte`.
      * -Reverb: :ref:`byte`.
      * -Phaser: :ref:`byte`.
      * -Tremolo: :ref:`byte`.
      * -blank1: :ref:`byte`.
      * -blank2: :ref:`byte`.*/
     MidiChannel[] channels = new MidiChannel[64];
     for (int i = 0; i < 64; i++)
     {
         var newChannel = new MidiChannel();
         newChannel.Channel       = i;
         newChannel.EffectChannel = i;
         var instrument = GpBase.ReadInt()[0];
         if (newChannel.IsPercussionChannel && instrument == -1)
         {
             instrument = 0;
         }
         newChannel.Instrument = instrument;
         newChannel.Volume     = ToChannelShort(GpBase.ReadByte()[0]);
         newChannel.Balance    = ToChannelShort(GpBase.ReadByte()[0]);
         newChannel.Chorus     = ToChannelShort(GpBase.ReadByte()[0]);
         newChannel.Reverb     = ToChannelShort(GpBase.ReadByte()[0]);
         newChannel.Phaser     = ToChannelShort(GpBase.ReadByte()[0]);
         newChannel.Tremolo    = ToChannelShort(GpBase.ReadByte()[0]);
         channels[i]           = newChannel;
         GpBase.Skip(2);
     }
     Channels = channels;
 }
Beispiel #20
0
        private int ReadRepeatAlternative(List <MeasureHeader> measureHeaders)
        {
            byte value = GpBase.ReadByte()[0];
            int  existingAlternatives = 0;

            for (int x = measureHeaders.Count - 1; x >= 0; x--)
            {
                if (measureHeaders[x].IsRepeatOpen)
                {
                    break;
                }
                existingAlternatives |= measureHeaders[x].RepeatAlternatives[0];
            }

            return((1 << value) - 1 ^ existingAlternatives);
        }
Beispiel #21
0
        private void ReadMixTableChangeValues(MixTableChange tableChange, Measure measure)
        {
            var instrument = GpBase.ReadSignedByte()[0];
            var volume     = GpBase.ReadSignedByte()[0];
            var balance    = GpBase.ReadSignedByte()[0];
            var chorus     = GpBase.ReadSignedByte()[0];
            var reverb     = GpBase.ReadSignedByte()[0];
            var phaser     = GpBase.ReadSignedByte()[0];
            var tremolo    = GpBase.ReadSignedByte()[0];
            var tempo      = GpBase.ReadInt()[0];

            if (instrument >= 0)
            {
                tableChange.Instrument = new MixTableItem(instrument);
            }
            if (volume >= 0)
            {
                tableChange.Volume = new MixTableItem(volume);
            }
            if (balance >= 0)
            {
                tableChange.Balance = new MixTableItem(balance);
            }
            if (chorus >= 0)
            {
                tableChange.Chorus = new MixTableItem(chorus);
            }
            if (reverb >= 0)
            {
                tableChange.Reverb = new MixTableItem(reverb);
            }
            if (phaser >= 0)
            {
                tableChange.Phaser = new MixTableItem(phaser);
            }
            if (tremolo >= 0)
            {
                tableChange.Tremolo = new MixTableItem(tremolo);
            }
            if (tempo >= 0)
            {
                tableChange.Tempo   = new MixTableItem(tempo);
                measure.Tempo.Value = tempo;
            }
        }
Beispiel #22
0
        private Duration ReadDuration(byte flags)
        {
            /*Duration is composed of byte signifying duration and an integer
             * that maps to :class:`guitarpro.models.Tuplet`.
             *
             * The byte maps to following values:
             *
             * - *-2*: whole note
             * - *-1*: half note
             * -  *0*: quarter note
             * -  *1*: eighth note
             * -  *2*: sixteenth note
             * -  *3*: thirty-second note
             *
             * If flag at *0x20* is true, the tuplet is read.*/

            var duration = new Duration();

            duration.Value    = 1 << (GpBase.ReadSignedByte()[0] + 2);
            duration.IsDotted = ((flags & 0x01) != 0);
            if ((flags & 0x20) != 0)
            {
                var iTuplet = GpBase.ReadInt()[0];
                switch (iTuplet)
                {
                case 3: duration.Tuplet.Enters = 3; duration.Tuplet.Times = 2; break;

                case 5: duration.Tuplet.Enters = 5; duration.Tuplet.Times = 4; break;

                case 6: duration.Tuplet.Enters = 6; duration.Tuplet.Times = 4; break;

                case 7: duration.Tuplet.Enters = 7; duration.Tuplet.Times = 4; break;

                case 9: duration.Tuplet.Enters = 9; duration.Tuplet.Times = 8; break;

                case 10: duration.Tuplet.Enters = 10; duration.Tuplet.Times = 8; break;

                case 11: duration.Tuplet.Enters = 11; duration.Tuplet.Times = 8; break;

                case 12: duration.Tuplet.Enters = 12; duration.Tuplet.Times = 8; break;
                }
            }
            return(duration);
        }
Beispiel #23
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);
        }
Beispiel #24
0
        private void ReadLyrics()
        {
            /*Read lyrics.
             * First, read an :ref:`int` that points to the track lyrics are
             * bound to. Then it is followed by 5 lyric lines. Each one
             * constists of number of starting measure encoded in :ref:`int`
             * and :ref:`int-size-string` holding text of the lyric line.*/

            Lyrics = new List <BE.Lyrics.Lyrics>();
            var lyrics = new BE.Lyrics.Lyrics();

            lyrics.TrackChoice = GpBase.ReadInt()[0];
            for (int x = 0; x < lyrics.Lines.Length; x++)
            {
                lyrics.Lines[x].StartingMeasure = GpBase.ReadInt()[0];
                lyrics.Lines[x].Lyrics          = GpBase.ReadIntSizeString();
            }
            Lyrics.Add(lyrics);
        }
Beispiel #25
0
        public override void ReadSong()
        {
            //HEADERS
            //VERSION
            Version      = ReadVersion();
            VersionTuple = ReadVersionTuple();
            //INFORMATION ABOUT THE PIECE
            ReadInfo();
            TripletFeel = GpBase.ReadBool()[0] ? TripletFeels.Eigth : TripletFeels.None;
            //readLyrics();
            Tempo = GpBase.ReadInt()[0];
            Key   = (KeySignatures)(GpBase.ReadInt()[0] * 10); //key + 0
                                                               //GpBase.readSignedByte(); //octave
            ReadMidiChannels();
            MeasureCount = GpBase.ReadInt()[0];
            TrackCount   = GpBase.ReadInt()[0];

            ReadMeasureHeaders(MeasureCount);
            ReadTracks(TrackCount, Channels);
            ReadMeasures();
        }
Beispiel #26
0
        private NoteEffect ReadNoteEffects(Note note)
        {
            /*First byte is note effects flags:
             *
             * - *0x01*: bend presence
             * - *0x02*: hammer-on/pull-off
             * - *0x04*: slide
             * - *0x08*: let-ring
             * - *0x10*: grace note presence
             *
             * Flags are followed by:
             *
             * - Bend. See :meth:`readBend`.
             *
             * - Grace note. See :meth:`readGrace`.*/

            var noteEffect = note.Effect;

            if (noteEffect == null)
            {
                noteEffect = new NoteEffect();
            }
            var flags = GpBase.ReadByte()[0];

            noteEffect.Hammer  = ((flags & 0x02) != 0);
            noteEffect.LetRing = ((flags & 0x08) != 0);
            if ((flags & 0x01) != 0)
            {
                noteEffect.Bend = ReadBend();
            }
            if ((flags & 0x10) != 0)
            {
                noteEffect.Grace = ReadGrace();
            }
            if ((flags & 0x04) != 0)
            {
                noteEffect.Slides = ReadSlides();
            }
            return(noteEffect);
        }
Beispiel #27
0
        private void ReadMixTableChangeFlags(MixTableChange tableChange)
        {
            /* The meaning of flags:
             *
             * - *0x01*: change volume for all tracks
             * - *0x02*: change balance for all tracks
             * - *0x04*: change chorus for all tracks
             * - *0x08*: change reverb for all tracks
             * - *0x10*: change phaser for all tracks
             * - *0x20*: change tremolo for all tracks*/

            var flags = GpBase.ReadSignedByte()[0];

            if (tableChange.Volume != null)
            {
                tableChange.Volume.AllTracks = ((flags & 0x01) != 0);
            }
            if (tableChange.Balance != null)
            {
                tableChange.Balance.AllTracks = ((flags & 0x02) != 0);
            }
            if (tableChange.Chorus != null)
            {
                tableChange.Chorus.AllTracks = ((flags & 0x04) != 0);
            }
            if (tableChange.Reverb != null)
            {
                tableChange.Reverb.AllTracks = ((flags & 0x08) != 0);
            }
            if (tableChange.Phaser != null)
            {
                tableChange.Phaser.AllTracks = ((flags & 0x10) != 0);
            }
            if (tableChange.Tremolo != null)
            {
                tableChange.Tremolo.AllTracks = ((flags & 0x20) != 0);
            }
        }
Beispiel #28
0
        private MidiChannel ReadChannel(MidiChannel[] channels)
        { /*Read MIDI channel.
           *
           * MIDI channel in Guitar Pro is represented by two integers. First
           * is zero-based number of channel, second is zero-based number of
           * channel used for effects.*/
            var         index         = GpBase.ReadInt()[0] - 1;
            MidiChannel trackChannel  = new MidiChannel();
            var         effectChannel = GpBase.ReadInt()[0] - 1;

            if (0 <= index && index < channels.Length)
            {
                trackChannel = channels[index];
                if (trackChannel.Instrument < 0)
                {
                    trackChannel.Instrument = 0;
                }
                if (!trackChannel.IsPercussionChannel)
                {
                    trackChannel.EffectChannel = effectChannel;
                }
            }
            return(trackChannel);
        }
Beispiel #29
0
        private void ReadInfo()
        {
            /*Read score information.
             *
             * Score information consists of sequence of
             * :ref:`IntByteSizeStrings <int-byte-size-string>`:
             *
             * - title
             * - subtitle
             * - artist
             * - album
             * - words
             * - copyright
             * - tabbed by
             * - instructions
             *
             * The sequence if followed by notice. Notice starts with the
             * number of notice lines stored in :ref:`int`. Each line is
             * encoded in :ref:`int-byte-size-string`.*/

            Title         = GpBase.ReadIntByteSizeString();
            Subtitle      = GpBase.ReadIntByteSizeString();
            Interpret     = GpBase.ReadIntByteSizeString();
            Album         = GpBase.ReadIntByteSizeString();
            Author        = GpBase.ReadIntByteSizeString();
            Copyright     = GpBase.ReadIntByteSizeString();
            TabAuthor     = GpBase.ReadIntByteSizeString();
            Instructional = GpBase.ReadIntByteSizeString();
            int notesCount = GpBase.ReadInt()[0];

            Notice = new string[notesCount];
            for (int x = 0; x < notesCount; x++)
            {
                Notice[x] = GpBase.ReadIntByteSizeString();
            }
        }
Beispiel #30
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      = (ChordTypes)GpBase.ReadByte()[0];
            chord.Extension = (ChordExtensions)GpBase.ReadByte()[0];
            chord.Bass      = new PitchClass(GpBase.ReadInt()[0], -1, "", intonation);
            chord.Tonality  = (ChordAlterations)GpBase.ReadInt()[0];
            chord.Add       = GpBase.ReadBool()[0];
            chord.Name      = GpBase.ReadByteSizeString(22);
            chord.Fifth     = (ChordAlterations)GpBase.ReadByte()[0];
            chord.Ninth     = (ChordAlterations)GpBase.ReadByte()[0];
            chord.Eleventh  = (ChordAlterations)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 <Fingerings> f = new List <Fingerings>();

            for (int x = 0; x < 7; x++)
            {
                f.Add((Fingerings)GpBase.ReadSignedByte()[0]);
            }
            chord.Fingerings = f;
            chord.Show       = GpBase.ReadBool()[0];
        }