mirror of
https://code.chipmunk.land/ChomeNS/chipmunkmod.git
synced 2026-03-30 22:51:58 +00:00
feat: support v6 format in nbs converter
This commit is contained in:
parent
9e26853847
commit
624d87c381
2 changed files with 16 additions and 4 deletions
|
|
@ -17,7 +17,14 @@ public class Instrument {
|
|||
public static final Instrument BIT = new Instrument(13, "bit", 54);
|
||||
public static final Instrument BANJO = new Instrument(14, "banjo", 54);
|
||||
public static final Instrument PLING = new Instrument(15, "pling", 54);
|
||||
private static final Instrument[] VALUES = { HARP, BASEDRUM, SNARE, HAT, BASS, FLUTE, BELL, GUITAR, CHIME, XYLOPHONE, IRON_XYLOPHONE, COW_BELL, DIDGERIDOO, BIT, BANJO, PLING };
|
||||
public static final Instrument TRUMPET = new Instrument(15, "trumpet", 54);
|
||||
public static final Instrument TRUMPET_EXPOSED = new Instrument(16, "trumpet_exposed", 54);
|
||||
public static final Instrument TRUMPET_WEATHERED = new Instrument(17, "trumpet_weathered", 54);
|
||||
public static final Instrument TRUMPET_OXIDIZED = new Instrument(18, "trumpet_oxidized", 54);
|
||||
private static final Instrument[] VALUES = {
|
||||
HARP, BASEDRUM, SNARE, HAT, BASS, FLUTE, BELL, GUITAR, CHIME, XYLOPHONE, IRON_XYLOPHONE, COW_BELL, DIDGERIDOO,
|
||||
BIT, BANJO, PLING, TRUMPET, TRUMPET_EXPOSED, TRUMPET_WEATHERED, TRUMPET_OXIDIZED
|
||||
};
|
||||
public final int id;
|
||||
public final String name;
|
||||
public final int offset;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ public class NBSConverter {
|
|||
Instrument.BIT,
|
||||
Instrument.BANJO,
|
||||
Instrument.PLING,
|
||||
Instrument.TRUMPET,
|
||||
Instrument.TRUMPET_EXPOSED,
|
||||
Instrument.TRUMPET_WEATHERED,
|
||||
Instrument.TRUMPET_OXIDIZED,
|
||||
};
|
||||
|
||||
public static Song getSongFromBytes (final byte[] bytes, final String fileName) throws IOException {
|
||||
|
|
@ -32,7 +36,7 @@ public class NBSConverter {
|
|||
|
||||
short songLength = 0;
|
||||
byte format = 0;
|
||||
byte vanillaInstrumentCount = 0;
|
||||
byte vanillaInstrumentCount = 10; // Before v1, we had 10 vanilla instruments
|
||||
songLength = buffer.getShort(); // If it's not 0, then it uses the old format
|
||||
if (songLength == 0) {
|
||||
format = buffer.get();
|
||||
|
|
@ -134,12 +138,13 @@ public class NBSConverter {
|
|||
for (final NBSNote note : nbsNotes) {
|
||||
final Instrument instrument;
|
||||
double key;
|
||||
if (note.instrument < instrumentIndex.length) {
|
||||
if (note.instrument < vanillaInstrumentCount) {
|
||||
if (note.instrument >= instrumentIndex.length) continue;
|
||||
instrument = instrumentIndex[note.instrument];
|
||||
|
||||
key = (double) ((note.key * 100) + note.pitch) / 100;
|
||||
} else {
|
||||
final int index = note.instrument - instrumentIndex.length;
|
||||
final int index = note.instrument - vanillaInstrumentCount;
|
||||
|
||||
if (index >= customInstruments.size()) continue;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue