@@ -77,7 +77,7 @@ private static Song parse(InputStream inputStream, File songFile) {
7777 short songHeight = readShort (dataInputStream );
7878 String title = readString (dataInputStream );
7979 String author = readString (dataInputStream );
80- readString (dataInputStream );
80+ readString (dataInputStream ); // original author
8181 String description = readString (dataInputStream );
8282 float speed = readShort (dataInputStream ) / 100f ;
8383 dataInputStream .readBoolean (); // auto-save
@@ -89,6 +89,11 @@ private static Song parse(InputStream inputStream, File songFile) {
8989 readInt (dataInputStream ); // blocks added
9090 readInt (dataInputStream ); // blocks removed
9191 readString (dataInputStream ); // .mid/.schematic file name
92+ if (nbsversion >= 4 ) {
93+ dataInputStream .readByte (); // loop on/off
94+ dataInputStream .readByte (); // max loop count
95+ readShort (dataInputStream ); // loop start tick
96+ }
9297 short tick = -1 ;
9398 while (true ) {
9499 short jumpTicks = readShort (dataInputStream ); // jumps till next tick
@@ -111,8 +116,17 @@ private static Song parse(InputStream inputStream, File songFile) {
111116 if (firstcustominstrumentdiff > 0 && instrument >= firstcustominstrument ){
112117 instrument += firstcustominstrumentdiff ;
113118 }
119+
120+ byte key = dataInputStream .readByte ();
121+
122+ if (nbsversion >= 4 ) {
123+ dataInputStream .readByte (); // note block velocity
124+ dataInputStream .readByte (); // note block panning
125+ readShort (dataInputStream ); // note block pitch
126+ }
127+
114128 setNote (layer , tick , instrument /* instrument */ ,
115- dataInputStream . readByte () /* note */ , layerHashMap );
129+ key /* note */ , layerHashMap );
116130 }
117131 }
118132
@@ -124,9 +138,13 @@ private static Song parse(InputStream inputStream, File songFile) {
124138 Layer layer = layerHashMap .get (i );
125139
126140 String name = readString (dataInputStream );
141+ if (nbsversion >= 4 ){
142+ dataInputStream .readByte (); // layer lock
143+ }
144+
127145 byte volume = dataInputStream .readByte ();
128- if (nbsversion >= 2 ){//layerstereo
129- dataInputStream .readByte ();
146+ if (nbsversion >= 2 ){
147+ dataInputStream .readByte (); // layer stereo
130148 }
131149 if (layer != null ) {
132150 layer .setName (name );
0 commit comments