dguitar.codecs.guitarPro.version1
Class GP1InputStream

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

public class GP1InputStream
extends GPInputStream

The class GP1InputStream allows to parse an InputStream containing a GTP file which is encoded in the 1, 1.01, 1.02, 1.03, 1.04 format.

Author:
Matthieu Wipliez

Field Summary
private static java.util.List _files
           
private  int _numTracks
          The number of tracks.
private static int _total
           
private  int _versionNumber
          The version number read from the stream.
private static java.lang.String[] supportedVersions
          The versions this parser supports.
 
Fields inherited from class dguitar.codecs.guitarPro.GPInputStream
__fileName, __version
 
Constructor Summary
GP1InputStream(GPInputStream gpIn)
          Creates a new GP4InputStream by cloning an existing GPInputStream.
GP1InputStream(java.io.InputStream in)
          Creates a new GP2InputStream from an existing stream.
 
Method Summary
private  void checkVersionNumber()
          Sets the _versionNumber attribute, according to the version read from the file, and sets attributes that are version-dependant.
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(GP1EffectsOnBeat gp1effects, GPEffectsOnBeat eob)
          Reads effects on the current beat from the stream.
private  GPEffectsOnNote readEffectsOnNote()
          Reads effects on the current note from the stream.
private  void readMeasureTrackPairs(java.util.List tracks, GPMeasure measure, java.util.List mtpList)
          Reads a pair of "measure-track".
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.


_numTracks

private int _numTracks
The number of tracks. In versions from 1 to 1.02 included, it is 1; it is 8 for versions 1.03 and 1.04.


_versionNumber

private int _versionNumber
The version number read from the stream. Allows the parser to take different paths according to the file version.


_files

private static final java.util.List _files

_total

private static int _total
Constructor Detail

GP1InputStream

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


GP1InputStream

public GP1InputStream(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 GUITARE PRO v1"
"FICHIER GUITARE PRO v1.01"
"FICHIER GUITARE PRO v1.02"
"FICHIER GUITARE PRO v1.03"
"FICHIER GUITARE PRO v1.04"

readPiece

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

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

checkVersionNumber

private void checkVersionNumber()
Sets the _versionNumber attribute, according to the version read from the file, and sets attributes that are version-dependant.


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(GP1EffectsOnBeat gp1effects,
                               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

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

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)
                                  throws java.io.FileNotFoundException
Decode recursively all the GP2 files in the directory specified.

Parameters:
dir - The directory to decode files from.
Throws:
java.io.FileNotFoundException