dguitar.codecs.guitarPro.version2
Class GP2InputStream

java.lang.Object
  extended bydguitar.codecs.guitarPro.GPInputStream
      extended bydguitar.codecs.guitarPro.version2.GP2InputStream
All Implemented Interfaces:
Codec, CodecInputStream

public class GP2InputStream
extends GPInputStream

The class GP2InputStream allows to parse an InputStream containing a GTP file which is encoded in the 2.20 or 2.21 format.

Author:
Matthieu Wipliez

Field Summary
private static java.util.List _files
           
private static int _total
           
private static java.lang.String[] supportedVersions
          The versions this parser supports.
 
Fields inherited from class dguitar.codecs.guitarPro.GPInputStream
__fileName, __version
 
Constructor Summary
GP2InputStream(GPInputStream gpIn)
          Creates a new GP4InputStream by cloning an existing GPInputStream.
GP2InputStream(java.io.InputStream in)
          Creates a new GP2InputStream from an existing stream.
 
Method Summary
private static void decodeGP2InDirectory(java.io.File dir)
          Decode recursively all the GP2 files in the directory specified.
static void main(java.lang.String[] args)
          The main function.
private  GPBeat readBeat(int trackNumberOfStrings)
          Returns a beat read from a GP2 file.
private  GPBend readBend(GPBendType bendType)
          Reads a bend from the stream.
private  GPChordDiagram readChordDiagram()
          Reads a ChordDiagram from the stream.
private  void readEffectsOnBeat(GP2EffectsOnBeat gp2effects, GPEffectsOnBeat eob)
          Reads effects on the current beat from the stream.
private  GPEffectsOnNote readEffectsOnNote()
          Reads effects on the current note from the stream.
private  GPGraceNote readGraceNote()
          The grace notes are stored in the file with 4 variables, written in the followingorder.
private  void readMeasureTrackPairs(java.util.List tracks, GPMeasure measure, java.util.List mtpList)
          Reads a pair of "measure-track".
private  GPMixTableChange readMixTableChange()
          Reads a mix table change event from the stream.
private  GPNote readNote()
          Reads a note (which here means only the fret and the dynamic).
 GPSong readPiece()
          Reads a piece from the stream.
private  GPMIDIChannel readTrack(GPTrack track)
          Reads a track from the stream.
static boolean supportedVersion(java.lang.String version)
          This method checks if the String version if supported.
static java.lang.String supportedVersions()
          This methods returns a String with the supported versions separated by '\n'.
 
Methods inherited from class dguitar.codecs.guitarPro.GPInputStream
assertBytesEqualTo, close, dumpBytes, dumpInts, read, read, readBoolean, readByte, readDouble, readFloat, readInt, readLong, readObject, readStringByte, readStringByteMaxLengthPlusOne, readStringInteger, readStringIntegerPlusOne, readUnsignedByte, skip, supportedExtension
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

supportedVersions

private static final java.lang.String[] supportedVersions
The versions this parser supports.


_files

private static final java.util.List _files

_total

private static int _total
Constructor Detail

GP2InputStream

public GP2InputStream(java.io.InputStream in)
Creates a new GP2InputStream from an existing stream.


GP2InputStream

public GP2InputStream(GPInputStream gpIn)
Creates a new GP4InputStream by cloning an existing GPInputStream.

Parameters:
gpIn - the original GPInputStream.
Method Detail

supportedVersion

public static boolean supportedVersion(java.lang.String version)
This method checks if the String version if supported.

Parameters:
version - the version described by a string.
Returns:
true if the version is supported.

supportedVersions

public static java.lang.String supportedVersions()
This methods returns a String with the supported versions separated by '\n'.

Returns:
"FICHIER GUITAR PRO v2.20", "FICHIER GUITAR PRO v2.21"

readPiece

public GPSong readPiece()
                 throws java.io.IOException
Reads a piece from the stream.

Returns:
the GPSong read.
Throws:
java.io.IOException

readBeat

private GPBeat readBeat(int trackNumberOfStrings)
                 throws java.io.IOException
Returns a beat read from a GP2 file.

Parameters:
trackNumberOfStrings - the number of strings of the track we are currently reading.
Returns:
a GPBeat read from a GP2 file.
Throws:
java.io.IOException

readBend

private GPBend readBend(GPBendType bendType)
                 throws java.io.IOException
Reads a bend from the stream.

Returns:
the Bend read.
Throws:
java.io.IOException

readChordDiagram

private GPChordDiagram readChordDiagram()
                                 throws java.io.IOException
Reads a ChordDiagram from the stream.

Returns:
the ChordDiagram read.
Throws:
java.io.IOException
GPFormatException

readEffectsOnBeat

private void readEffectsOnBeat(GP2EffectsOnBeat gp2effects,
                               GPEffectsOnBeat eob)
                        throws java.io.IOException
Reads effects on the current beat from the stream.

Returns:
the GPEffectsOnBeat read.
Throws:
java.io.IOException

readEffectsOnNote

private GPEffectsOnNote readEffectsOnNote()
                                   throws java.io.IOException
Reads effects on the current note from the stream.

Returns:
the GPEffectsOnNote read.
Throws:
java.io.IOException

readGraceNote

private GPGraceNote readGraceNote()
                           throws java.io.IOException
The grace notes are stored in the file with 4 variables, written in the followingorder. Fret: byte The fret number the grace note is made from. GPDynamic: byte The grace note dynamic is coded like this: - 1: ppp - 2: pp - 3: p - 4: mp - 5: mf - 6: f - 7: ff - 8: fff The default value is 6. Transition: byte this variable determines the transition type used to make the grace note: - 0: None - 1: GPSlide - 2: GPBend - 3: Hammer GPDuration: byte Determines the grace note duration, coded this way: - 1: Sixteenth note. - 2: Twenty-fourth note. - 3: Thirty-second note.

Returns:
the GPGraceNote read.
Throws:
java.io.IOException

readMeasureTrackPairs

private void readMeasureTrackPairs(java.util.List tracks,
                                   GPMeasure measure,
                                   java.util.List mtpList)
                            throws java.io.IOException
Reads a pair of "measure-track".

Parameters:
tracks - a list containing the information about the tracks.
measure - the GPMeasure that will hold the data read from the file.
mtpList - the list of GPMeasureTrackPair.
Returns:
the GPMeasureTrackPair read.
Throws:
java.io.IOException

readMixTableChange

private GPMixTableChange readMixTableChange()
                                     throws java.io.IOException
Reads a mix table change event from the stream.

Returns:
The MixTableChange read.
Throws:
java.io.IOException

readNote

private GPNote readNote()
                 throws java.io.IOException
Reads a note (which here means only the fret and the dynamic).

Returns:
the GPNote read.
Throws:
java.io.IOException

readTrack

private GPMIDIChannel readTrack(GPTrack track)
                         throws java.io.IOException
Reads a track from the stream. The GPTrack is given as a parameter rather than being created and returned by the function, as some of the data contained in the GPTrack have already been read earlier. Additionally, it creates a GPMIDIChannel to be used by this track.

Parameters:
track - a GPTrack where the data will be written
Returns:
the MIDI channel used by this track.
Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
The main function.

Parameters:
args -

decodeGP2InDirectory

private static void decodeGP2InDirectory(java.io.File dir)
Decode recursively all the GP2 files in the directory specified.

Parameters:
dir - The directory to decode files from.