Tux Guitar

Problems

Subject GTPInputStream Code Problem



Author Message
Bujang
Post: Jan 13th 2010 at 4:23 PM

Hi,

I am trying to use Tux's code to export MIDI out of GP files. Below is my code, I couldn't get it working. I must have missed some basic settings. Could you please help, Thanks. I got it working with ptb file.

String filePathName = "C:hard_luck_woman.gp3";
InputStream is = null;
OutputStream os = null;
try {
is = new FileInputStream(filePathName);
os = new FileOutputStream(filePathName.replaceFirst(".gp3", Matcher.quoteReplacement(".mid")));

} catch (FileNotFoundException e1) {
e1.printStackTrace();
System.exit(0);
} catch (IOException e) {
e.printStackTrace();
System.exit(0);
}

TGFactory factory = new TGFactoryImpl();
TGSong song = null;
GTPInputStream gtpis = GP5InputStream(GTPSettingsUtil.instance().getSettings()); <== errored out here
gtpis.init(factory, is);
try {
song = gtpis.readSong();
} catch (GTPFormatException e) {
e.printStackTrace();
System.exit(0);
} catch (IOException e) {
e.printStackTrace();
System.exit(0);
} catch (TGFileFormatException e) {
e.printStackTrace();
System.exit(0);
}

MidiSongExporter mex = new MidiSongExporter();
mex.configure(true);
mex.init(factory, os);
mex.exportSong(song);


Below is the error
===================
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 255
at java.lang.String.checkBounds(Unknown Source)
at java.lang.String.(Unknown Source)
at org.herac.tuxguitar.io.gtp.GTPInputStream.newString(GTPInputStream.java:159)
at org.herac.tuxguitar.io.gtp.GTPInputStream.readString(GTPInputStream.java:110)
at org.herac.tuxguitar.io.gtp.GTPInputStream.readStringByte(GTPInputStream.java:130)
at org.herac.tuxguitar.io.gtp.GTPInputStream.readVersion(GTPInputStream.java:59)
at org.herac.tuxguitar.io.gtp.GP3InputStream.readSong(GP3InputStream.java:54)


Back to Top