Annotated MIDI loader and reader code

This commit is contained in:
Alex Iadicicco 2022-12-02 23:14:49 -08:00 committed by Alexis King
parent aaf1227e32
commit 28f6797686
17 changed files with 955 additions and 896 deletions

View File

@ -8,18 +8,18 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public final class ga_ extends tn_ {
public final class MidiPlayer_idk extends MixerInterface_idk {
public final int[] _t = new int[16];
public final int[] _F = new int[16];
private final int[] _p = new int[16];
private final int[] _y = new int[16];
private final int[] _q = new int[16];
private final qq_[][] _N = new qq_[16][128];
private final MixerTrackConfig_idk[][] _N = new MixerTrackConfig_idk[16][128];
private final int[] _r = new int[16];
private final int[] _m = new int[16];
private final Map<Integer, br_> _Q;
private final int[] _G = new int[16];
private final pi_ _x = new pi_();
private final MidiReader midiReader = new MidiReader();
private final int[] _I = new int[16];
private final int[] _P = new int[16];
private final int[] _E = new int[16];
@ -29,24 +29,24 @@ public final class ga_ extends tn_ {
private final rc_ _l = new rc_(this);
public final int[] _u = new int[16];
private int volume = 256;
private final qq_[][] _K = new qq_[16][128];
private final MixerTrackConfig_idk[][] _K = new MixerTrackConfig_idk[16][128];
private int _M = 1000000;
private final int[] _s = new int[16];
private int _C;
private int trackWithSoonestEvent;
private long _O;
private int _D;
private long _n;
private int nextEventTicks;
private long currentPlayTime;
private boolean _v;
private MusicTrack _z;
private SongData _z;
public ga_() {
public MidiPlayer_idk() {
this._Q = new HashMap<>();
this.a679();
this.a430(true);
}
@SuppressWarnings("CopyConstructorMissesField")
public ga_(final ga_ var1) {
public MidiPlayer_idk(final MidiPlayer_idk var1) {
this._Q = var1._Q;
this.a679();
this.a430(true);
@ -66,8 +66,8 @@ public final class ga_ extends tn_ {
}
@Override
public @NotNull Iterator<tn_> iterator() {
return Collections.<tn_>singletonList(this._l).iterator();
public @NotNull Iterator<MixerInterface_idk> iterator() {
return Collections.<MixerInterface_idk>singletonList(this._l).iterator();
}
private void a326(final int var2, final int var3) {
@ -75,7 +75,7 @@ public final class ga_ extends tn_ {
this._u[var3] = (int) (0.5D + 2097152.0D * Math.pow(2.0D, 5.4931640625E-4D * (double) var2));
}
private int b237(final qq_ var1) {
private int b237(final MixerTrackConfig_idk var1) {
int var3 = (var1._r * var1._G >> 12) + var1._J;
var3 += this._r[var1._y] * (this._T[var1._y] - 8192) >> 12;
final kc_ var4 = var1._u;
@ -103,7 +103,7 @@ public final class ga_ extends tn_ {
}
private void a093(final int var1) {
for (final qq_ var3 : this._l._n) {
for (final MixerTrackConfig_idk var3 : this._l._n) {
if ((var1 < 0 || var3._y == var1) && var3._E < 0) {
this._N[var3._y][var3._H] = null;
var3._E = 0;
@ -112,7 +112,7 @@ public final class ga_ extends tn_ {
}
private void a172(final int var3, final int var4) {
final qq_ var5 = this._N[var3][var4];
final MixerTrackConfig_idk var5 = this._N[var3][var4];
if (var5 != null) {
this._N[var3][var4] = null;
if ((2 & this._F[var3]) == 0) {
@ -133,12 +133,12 @@ public final class ga_ extends tn_ {
}
}
public synchronized void a350(final SoundLoader soundLoader, final ResourceLoader loader, final MusicTrack track) {
track.a797();
public synchronized void a350(final SoundLoader soundLoader, final ResourceLoader loader, final SongData track) {
track.analyzeNotesUsedPerProgram();
boolean var6 = true;
for (final Map.Entry<Integer, byte[]> var8 : track._i.entrySet()) {
for (final Map.Entry<Integer, byte[]> var8 : track.notesUsedPerProgram.entrySet()) {
final int var9 = var8.getKey();
br_ var10 = this._Q.get(var9);
if (var10 == null) {
@ -157,31 +157,55 @@ public final class ga_ extends tn_ {
}
if (var6) {
track.b797();
track.resetNotesUsedPerProgram();
}
}
@Override
public synchronized void a150(int len) {
if (this._x.f801()) {
final int var2 = this._x._e * this._M / SampledAudioChannel.SAMPLES_PER_SECOND;
public synchronized void generateAudio1_idk(final int[] dest, int offset, int len) {
if (this.midiReader.isLoaded()) {
final int var4 = this.midiReader.ticksPerQuarterNote * this._M / SampledAudioChannel.SAMPLES_PER_SECOND;
do {
final long var5 = this._O + (long) len * (long) var4;
if (this.currentPlayTime - var5 >= 0L) {
this._O = var5;
break;
}
final int var7 = (int) ((-this._O + (this.currentPlayTime - (-((long) var4) + 1L))) / (long) var4);
this._O += (long) var7 * (long) var4;
this._l.generateAudio1_idk(dest, offset, var7);
offset += var7;
len -= var7;
this.a423();
} while (this.midiReader.isLoaded());
}
this._l.generateAudio1_idk(dest, offset, len);
}
@Override
public synchronized void generateAudio2_idk(int len) {
if (this.midiReader.isLoaded()) {
final int var2 = this.midiReader.ticksPerQuarterNote * this._M / SampledAudioChannel.SAMPLES_PER_SECOND;
do {
final long var3 = (long) len * (long) var2 + this._O;
if (this._n - var3 >= 0L) {
if (this.currentPlayTime - var3 >= 0L) {
this._O = var3;
break;
}
final int var5 = (int) ((-1L - this._O + this._n + (long) var2) / (long) var2);
final int var5 = (int) ((-1L - this._O + this.currentPlayTime + (long) var2) / (long) var2);
this._O += (long) var5 * (long) var2;
this._l.a150(var5);
this._l.generateAudio2_idk(var5);
len -= var5;
this.a423();
} while (this._x.f801());
} while (this.midiReader.isLoaded());
}
this._l.a150(len);
this._l.generateAudio2_idk(len);
}
@SuppressWarnings("SameParameterValue")
@ -190,13 +214,13 @@ public final class ga_ extends tn_ {
}
private synchronized void b430(final boolean var2) {
this._x.d797();
this.midiReader.unload();
this._z = null;
this.a430(var2);
}
private void b366(final int var1) {
for (final qq_ var3 : this._l._n) {
for (final MixerTrackConfig_idk var3 : this._l._n) {
if (var1 < 0 || var1 == var3._y) {
if (var3._K != null) {
var3._K.g150(SampledAudioChannel.SAMPLES_PER_SECOND / 100);
@ -218,7 +242,7 @@ public final class ga_ extends tn_ {
private void a540(final int var2) {
if ((2 & this._F[var2]) != 0) {
for (final qq_ var3 : this._l._n) {
for (final MixerTrackConfig_idk var3 : this._l._n) {
if (var3._y == var2 && this._N[var2][var3._H] == null && var3._E < 0) {
var3._E = 0;
}
@ -226,34 +250,10 @@ public final class ga_ extends tn_ {
}
}
public synchronized void a077(final MusicTrack var1, final boolean var3) {
public synchronized void a077(final SongData var1, final boolean var3) {
this.a918(var3, var1, true);
}
@Override
public synchronized void b397(final int[] dest, int offset, int len) {
if (this._x.f801()) {
final int var4 = this._x._e * this._M / SampledAudioChannel.SAMPLES_PER_SECOND;
do {
final long var5 = this._O + (long) len * (long) var4;
if (this._n - var5 >= 0L) {
this._O = var5;
break;
}
final int var7 = (int) ((-this._O + (this._n - (-((long) var4) + 1L))) / (long) var4);
this._O += (long) var7 * (long) var4;
this._l.b397(dest, offset, var7);
offset += var7;
len -= var7;
this.a423();
} while (this._x.f801());
}
this._l.b397(dest, offset, len);
}
private void a556(int var2) {
if (var2 >= 0) {
this._y[var2] = 12800;
@ -298,7 +298,7 @@ public final class ga_ extends tn_ {
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean a258(final qq_ var2) {
public boolean a258(final MixerTrackConfig_idk var2) {
if (var2._K == null) {
if (var2._E >= 0) {
var2.unlink();
@ -498,27 +498,27 @@ public final class ga_ extends tn_ {
return 0;
}
private synchronized void a918(final boolean var1, final MusicTrack var2, final boolean var4) {
private synchronized void a918(final boolean var1, final SongData songData, final boolean var4) {
this.b430(var4);
this._x.a604(var2._h);
this.midiReader.load(songData.midiData);
this._v = var1;
this._O = 0L;
final int var5 = this._x.c784();
final int numTracks = this.midiReader.numTracks();
for (int var6 = 0; var5 > var6; ++var6) {
this._x.b150(var6);
this._x.d150(var6);
this._x.e150(var6);
for (int track = 0; track < numTracks; ++track) {
this.midiReader.setCursorToTrackPlaybackPos(track);
this.midiReader.advanceTrackTicks(track);
this.midiReader.setTrackPlaybackPosToCursor(track);
}
this._C = this._x.g784();
this._D = this._x._b[this._C];
this._n = this._x.c138(this._D);
this.trackWithSoonestEvent = this.midiReader.trackWithSoonestNextTick();
this.nextEventTicks = this.midiReader.trackNextTick[this.trackWithSoonestEvent];
this.currentPlayTime = this.midiReader.getPlayTime(this.nextEventTicks);
}
private void d093(final int var2) {
if ((4 & this._F[var2]) != 0) {
for (final qq_ var3 : this._l._n) {
for (final MixerTrackConfig_idk var3 : this._l._n) {
if (var3._y == var2) {
var3._j = 0;
}
@ -530,8 +530,8 @@ public final class ga_ extends tn_ {
private void a842(final int var1, final int var2, final int var3) {
this.a172(var2, var1);
if ((this._F[var2] & 2) != 0) {
for (final Iterator<qq_> it = this._l._n.descendingIterator(); it.hasNext(); ) {
final qq_ var5 = it.next();
for (final Iterator<MixerTrackConfig_idk> it = this._l._n.descendingIterator(); it.hasNext(); ) {
final MixerTrackConfig_idk var5 = it.next();
if (var5._y == var2 && var5._E < 0) {
this._N[var2][var5._H] = null;
this._N[var2][var1] = var5;
@ -549,7 +549,7 @@ public final class ga_ extends tn_ {
if (var10 != null) {
final kk_ var11 = var10._h[var1];
if (var11 != null) {
final qq_ var7 = new qq_();
final MixerTrackConfig_idk var7 = new MixerTrackConfig_idk();
var7._y = var2;
var7._A = var10;
var7._M = var11;
@ -565,7 +565,7 @@ public final class ga_ extends tn_ {
var7._h = 0;
var7._v = 0;
if (this._t[var2] == 0) {
var7._K = al_.a771(var11, this.b237(var7), this.a510(var7), this.a237(var7));
var7._K = al_.a771(var11, this.b237(var7), this.generateSample(var7), this.a237(var7));
} else {
var7._K = al_.a771(var11, this.b237(var7), 0, this.a237(var7));
this.a559(var7, var10._k[var1] < 0);
@ -577,7 +577,7 @@ public final class ga_ extends tn_ {
}
if (var7._z >= 0) {
final qq_ var9 = this._K[var2][var7._z];
final MixerTrackConfig_idk var9 = this._K[var2][var7._z];
if (var9 != null && var9._E < 0) {
this._N[var2][var9._H] = null;
var9._E = 0;
@ -593,7 +593,7 @@ public final class ga_ extends tn_ {
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean a543(final int var1, final int[] var2, final qq_ var4, final int var5) {
public boolean a543(final int var1, final int[] var2, final MixerTrackConfig_idk var4, final int var5) {
var4._p = SampledAudioChannel.SAMPLES_PER_SECOND / 100;
if (var4._E < 0 || var4._K != null && !var4._K.g801()) {
int var6 = var4._G;
@ -659,9 +659,9 @@ public final class ga_ extends tn_ {
if (var8) {
var4._K.g150(var4._p);
if (var2 == null) {
var4._K.a150(var5);
var4._K.generateAudio2_idk(var5);
} else {
var4._K.b397(var2, var1, var5);
var4._K.generateAudio1_idk(var2, var1, var5);
}
if (var4._K.e801()) {
@ -679,7 +679,7 @@ public final class ga_ extends tn_ {
return true;
} else {
var4._K.a326(var4._p, this.a510(var4), this.a237(var4));
var4._K.a326(var4._p, this.generateSample(var4), this.a237(var4));
return false;
}
} else {
@ -702,70 +702,72 @@ public final class ga_ extends tn_ {
}
}
private int a237(final qq_ var1) {
private int a237(final MixerTrackConfig_idk var1) {
final int var3 = this._G[var1._y];
return var3 >= 8192 ? -(32 + (128 - var1._q) * (-var3 + 16384) >> 6) + 16384 : 32 + var1._q * var3 >> 6;
}
private void a423() {
int var2 = this._C;
int var3 = this._D;
long var4 = this._n;
if (this._z != null && var3 == 0) {
int track = this.trackWithSoonestEvent;
int ticks = this.nextEventTicks;
long var4 = this.currentPlayTime;
if (this._z != null && ticks == 0) {
this.a918(this._v, this._z, false);
this.a423();
} else {
while (var3 == this._D) {
while (this._x._b[var2] == var3) {
this._x.b150(var2);
final int var7 = this._x.a137(var2);
if (var7 == 1) {
this._x.e797();
this._x.e150(var2);
if (this._x.a801()) {
while (ticks == this.nextEventTicks) {
while (this.midiReader.trackNextTick[track] == ticks) {
this.midiReader.setCursorToTrackPlaybackPos(track);
final int event = this.midiReader.readNextTrackEvent(track);
if (event == MidiReader.EVENT_TRACK_END) {
this.midiReader.resetCursor();
this.midiReader.setTrackPlaybackPosToCursor(track);
if (this.midiReader.allTracksStopped()) {
if (this._z != null) {
this.a077(this._z, this._v);
this.a423();
return;
}
if (!this._v || var3 == 0) {
if (!this._v || ticks == 0) {
this.a430(true);
this._x.d797();
this.midiReader.unload();
return;
}
this._x.a111(var4);
this.midiReader.resetPlayback(var4);
}
break;
}
if ((var7 & 128) != 0) {
this.a366(var7);
if ((event & 128) != 0) {
this.a366(event);
}
this._x.d150(var2);
this._x.e150(var2);
this.midiReader.advanceTrackTicks(track);
this.midiReader.setTrackPlaybackPosToCursor(track);
}
var2 = this._x.g784();
var3 = this._x._b[var2];
var4 = this._x.c138(var3);
track = this.midiReader.trackWithSoonestNextTick();
ticks = this.midiReader.trackNextTick[track];
var4 = this.midiReader.getPlayTime(ticks);
}
this._C = var2;
this._D = var3;
this._n = var4;
if (this._z != null && var3 > 0) {
this._C = -1;
this._D = 0;
this._n = this._x.c138(this._D);
this.trackWithSoonestEvent = track;
this.nextEventTicks = ticks;
this.currentPlayTime = var4;
if (this._z != null && ticks > 0) {
this.trackWithSoonestEvent = -1;
this.nextEventTicks = 0;
this.currentPlayTime = this.midiReader.getPlayTime(this.nextEventTicks);
}
}
}
public void a559(final qq_ var2, final boolean var3) {
public void a559(final MixerTrackConfig_idk var2, final boolean var3) {
int var4 = var2._M.data.length;
int var5;
@ -784,50 +786,50 @@ public final class ga_ extends tn_ {
var2._K.h150(var5);
}
private int a510(final qq_ var1) {
private int generateSample(final MixerTrackConfig_idk var1) {
if (this._A[var1._y] == 0) {
return 0;
} else {
final kc_ var3 = var1._u;
int var4 = this._y[var1._y] * this._s[var1._y] + 4096 >> 13;
var4 = var4 * var4 + 16384 >> 15;
var4 = var1._k * var4 + 16384 >> 15;
var4 = 128 + this.volume * var4 >> 8;
var4 = this._A[var1._y] * var4 + 128 >> 8;
if (var3._h > 0) {
var4 = (int) (0.5D + (double) var4 * Math.pow(0.5D, (double) var1._h * 1.953125E-5D * (double) var3._h));
}
int var5;
int var6;
int var7;
int var8;
if (var3._n != null) {
var5 = var1._F;
var6 = var3._n[1 + var1._B];
if (var1._B < var3._n.length - 2) {
var7 = var3._n[var1._B] << 8 & '\uff00';
var8 = (255 & var3._n[2 + var1._B]) << 8;
var6 += (-var6 + var3._n[var1._B + 3]) * (-var7 + var5) / (-var7 + var8);
}
var4 = var6 * var4 + 32 >> 6;
}
if (var1._E > 0 && var3._e != null) {
var5 = var1._E;
var6 = var3._e[1 + var1._v];
if (var3._e.length - 2 > var1._v) {
var7 = (255 & var3._e[var1._v]) << 8;
var8 = var3._e[2 + var1._v] << 8 & '\uff00';
var6 += (var3._e[var1._v + 3] - var6) * (-var7 + var5) / (-var7 + var8);
}
var4 = 32 + var4 * var6 >> 6;
}
return var4;
}
final kc_ var3 = var1._u;
int x = this._y[var1._y] * this._s[var1._y] + 4096 >> 13;
x = x * x + 16384 >> 15;
x = var1._k * x + 16384 >> 15;
x = 128 + this.volume * x >> 8;
x = this._A[var1._y] * x + 128 >> 8;
if (var3._h > 0) {
x = (int) (0.5D + (double) x * Math.pow(0.5D, (double) var1._h * 1.953125E-5D * (double) var3._h));
}
int var5;
int var6;
int var7;
int var8;
if (var3._n != null) {
var5 = var1._F;
var6 = var3._n[1 + var1._B];
if (var1._B < var3._n.length - 2) {
var7 = var3._n[var1._B] << 8 & '\uff00';
var8 = (255 & var3._n[2 + var1._B]) << 8;
var6 += (-var6 + var3._n[var1._B + 3]) * (-var7 + var5) / (-var7 + var8);
}
x = var6 * x + 32 >> 6;
}
if (var1._E > 0 && var3._e != null) {
var5 = var1._E;
var6 = var3._e[1 + var1._v];
if (var3._e.length - 2 > var1._v) {
var7 = (255 & var3._e[var1._v]) << 8;
var8 = var3._e[2 + var1._v] << 8 & '\uff00';
var6 += (var3._e[var1._v + 3] - var6) * (-var7 + var5) / (-var7 + var8);
}
x = 32 + x * var6 >> 6;
}
return x;
}
public synchronized void initialize() {
@ -838,6 +840,6 @@ public final class ga_ extends tn_ {
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public synchronized boolean h154() {
return this._x.f801();
return this.midiReader.isLoaded();
}
}

View File

@ -0,0 +1,237 @@
package funorb.audio;
import funorb.io.Buffer;
import java.util.Arrays;
public final class MidiReader {
public static final int EVENT_SYSEX = 0;
public static final int EVENT_TRACK_END = 1;
public static final int EVENT_TEMPO_CHANGE = 2;
public static final int EVENT_UNKNOWN_META = 3;
private static final byte[] STATUS_BYTE_TO_DATA_BYTE_COUNT = new byte[] {
// channel voice messages
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 1000nnnn 0kkkkkkk 0vvvvvvv - note off
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 1001nnnn 0kkkkkkk 0vvvvvvv - note on
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 1010nnnn 0kkkkkkk 0vvvvvvv - polyphonic aftertouch
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 1011nnnn 0ccccccc 0vvvvvvv - control change
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1100nnnn 0ppppppp - program change
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1101nnnn 0vvvvvvv - channel aftertouch
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 1110nnnn 0lllllll 0hhhhhhh - pitch wheel
// system common messages
0, // 11110000 - sysex start
1, // 11110001 - undefined
2, // 11110010 0lllllll 0mmmmmmm - song position pointer
1, // 11110011 0sssssss - song select
0, // 11110100 - undefined
0, // 11110101 - undefined
0, // 11110110 - tune request
0, // 11110111 - sysex end
// system realtime messages
0, // 11111000 - sync clock
0, // 11111001 - undefined
0, // 11111010 - start
0, // 11111011 - continue
0, // 11111100 - stop
0, // 11111101 - undefined
0, // 11111110 - active sensing
0, // 11111111 - meta event
};
private final Buffer midi = new Buffer(null);
public int ticksPerQuarterNote;
public int[] trackNextTick;
private int[] trackPlaybackPos;
private int[] trackStartPos;
private int[] lastTrackStatusByte;
/** play time units appear to be "tick-microseconds per quarter note" */
private long playTimeOrigin;
/** microseconds per quarter note */
private int tempo;
public MidiReader() {
}
public MidiReader(final byte[] midiData) {
this.load(midiData);
}
public boolean allTracksStopped() {
return Arrays.stream(this.trackPlaybackPos).noneMatch(i -> i >= 0);
}
public int readNextTrackEvent(final int track) {
return this.readNextTrackEventInner(track);
}
public void resetPlayback(final long playTimeOrigin) {
this.playTimeOrigin = playTimeOrigin;
final int numTracks = this.trackPlaybackPos.length;
for (int track = 0; track < numTracks; ++track) {
this.trackNextTick[track] = 0;
this.lastTrackStatusByte[track] = 0;
this.midi.pos = this.trackStartPos[track];
this.advanceTrackTicks(track);
this.trackPlaybackPos[track] = this.midi.pos;
}
}
public long getPlayTime(final int ticks) {
return this.playTimeOrigin + (long) ticks * (long) this.tempo;
}
public void resetCursor() {
this.midi.pos = -1;
}
public void setCursorToTrackPlaybackPos(final int track) {
this.midi.pos = this.trackPlaybackPos[track];
}
public void setTrackPlaybackPosToCursor(final int track) {
this.trackPlaybackPos[track] = this.midi.pos;
}
private int readNextTrackEventWithStatus(final int track, final int statusByte) {
if (statusByte == 0xff) {
final int metaEvent = this.midi.readUByte();
int metaLength = this.midi.readVariableInt();
if (metaEvent == 0x2f) { // end of track
this.midi.pos += metaLength;
return EVENT_TRACK_END;
} else if (metaEvent == 0x51) { // set tempo
final int newTempo = this.midi.readU24();
metaLength -= 3;
this.playTimeOrigin += (long) this.trackNextTick[track] * (long) (this.tempo - newTempo);
this.tempo = newTempo;
this.midi.pos += metaLength;
return EVENT_TEMPO_CHANGE;
} else {
this.midi.pos += metaLength;
return EVENT_UNKNOWN_META;
}
}
final byte numDataBytes = STATUS_BYTE_TO_DATA_BYTE_COUNT[statusByte - 128];
int event = statusByte;
if (numDataBytes >= 1) event |= this.midi.readUByte() << 8;
if (numDataBytes >= 2) event |= this.midi.readUByte() << 16;
return event;
}
public int trackWithSoonestNextTick() {
final int numTracks = this.trackPlaybackPos.length;
int minIndex = -1;
int minValue = Integer.MAX_VALUE;
for (int track = 0; track < numTracks; ++track) {
if (this.trackPlaybackPos[track] >= 0 && this.trackNextTick[track] < minValue) {
minIndex = track;
minValue = this.trackNextTick[track];
}
}
return minIndex;
}
public int numTracks() {
return this.trackPlaybackPos.length;
}
private int readNextTrackEventInner(final int track) {
final byte nextTrackByte = this.midi.data[this.midi.pos];
final int statusByte;
if (nextTrackByte < 0) { // high bit set
statusByte = nextTrackByte & 255;
this.lastTrackStatusByte[track] = statusByte;
++this.midi.pos;
} else {
statusByte = this.lastTrackStatusByte[track];
}
if (statusByte == 0xf0 || statusByte == 0xf7) {
final int sysexLength = this.midi.readVariableInt();
if (statusByte == 0xf7 && sysexLength > 0) {
final int firstSysexByte = this.midi.data[this.midi.pos] & 0xff;
switch (firstSysexByte) {
case 241:
case 242:
case 243:
case 246:
case 248:
case 250:
case 252:
case 254:
++this.midi.pos;
this.lastTrackStatusByte[track] = firstSysexByte;
return this.readNextTrackEventWithStatus(track, firstSysexByte);
default:
break;
}
}
this.midi.pos += sysexLength;
return EVENT_SYSEX;
} else {
return this.readNextTrackEventWithStatus(track, statusByte);
}
}
public void unload() {
this.midi.data = null;
this.trackStartPos = null;
this.trackPlaybackPos = null;
this.trackNextTick = null;
this.lastTrackStatusByte = null;
}
public boolean isLoaded() {
return this.midi.data != null;
}
public void advanceTrackTicks(final int track) {
final int timeDelta = this.midi.readVariableInt();
this.trackNextTick[track] += timeDelta;
}
public void load(final byte[] midiData) {
this.midi.data = midiData;
this.midi.pos = 10; // skip to count of MTrk chunks in MThd
final int numTracks = this.midi.readUShort();
this.ticksPerQuarterNote = this.midi.readUShort();
this.tempo = 500000; // 120 bpm
this.trackStartPos = new int[numTracks];
Buffer midi;
int track;
int chunkSize;
for (track = 0; track < numTracks; midi.pos += chunkSize) {
final int chunkHeader = this.midi.readInt();
chunkSize = this.midi.readInt();
if (chunkHeader == 0x4d54726b) { // 'MTrk'
this.trackStartPos[track] = this.midi.pos;
++track;
}
midi = this.midi;
}
this.playTimeOrigin = 0L;
this.trackPlaybackPos = new int[numTracks];
for (track = 0; track < numTracks; ++track) {
this.trackPlaybackPos[track] = this.trackStartPos[track];
}
this.trackNextTick = new int[numTracks];
this.lastTrackStatusByte = new int[numTracks];
}
}

View File

@ -0,0 +1,30 @@
package funorb.audio;
import funorb.data.NodeList;
public abstract class MixerInterface_idk extends NodeList.Node implements Iterable<MixerInterface_idk> {
public volatile boolean useGenerateAudio1_idk = true;
public int _i;
public MixerInterface_idk _h;
public kk_ _k;
protected MixerInterface_idk() {}
public abstract void generateAudio1_idk(int[] dest, int offset, int len);
public abstract void generateAudio2_idk(int len);
protected final void generateAudio(final int[] dest, final int offset, final int len) {
if (this.useGenerateAudio1_idk) {
this.generateAudio1_idk(dest, offset, len);
} else {
this.generateAudio2_idk(len);
}
}
public abstract int a784();
public int c784() {
return 255;
}
}

View File

@ -2,7 +2,7 @@ package funorb.audio;
import funorb.data.NodeList;
public final class qq_ extends NodeList.Node {
public final class MixerTrackConfig_idk extends NodeList.Node {
public int _E;
public int _G;
public int _v;

View File

@ -1,408 +0,0 @@
package funorb.audio;
import funorb.cache.ResourceLoader;
import funorb.io.Buffer;
import java.util.HashMap;
import java.util.Map;
public final class MusicTrack {
public byte[] _h;
public Map<Integer, byte[]> _i;
private MusicTrack(final Buffer var1) {
var1.pos = var1.data.length - 3;
final int var2 = var1.readUByte();
final int var3 = var1.readUShort();
int var4 = 14 + var2 * 10;
var1.pos = 0;
int var5 = 0;
int var6 = 0;
int var7 = 0;
int var8 = 0;
int var9 = 0;
int var10 = 0;
int var11 = 0;
int var12 = 0;
int var13;
int var14;
int var15;
for (var13 = 0; var13 < var2; ++var13) {
var14 = -1;
while (true) {
var15 = var1.readUByte();
if (var15 != var14) {
++var4;
}
var14 = var15 & 15;
if (var15 == 7) {
break;
}
if (var15 == 23) {
++var5;
} else if (var14 == 0) {
++var7;
} else if (var14 == 1) {
++var8;
} else if (var14 == 2) {
++var6;
} else if (var14 == 3) {
++var9;
} else if (var14 == 4) {
++var10;
} else if (var14 == 5) {
++var11;
} else {
if (var14 != 6) {
throw new RuntimeException();
}
++var12;
}
}
}
var4 += 5 * var5;
var4 += 2 * (var7 + var8 + var6 + var9 + var11);
var4 += var10 + var12;
var13 = var1.pos;
var14 = var2 + var5 + var6 + var7 + var8 + var9 + var10 + var11 + var12;
for (var15 = 0; var15 < var14; ++var15) {
var1.readVariableInt();
}
var4 += var1.pos - var13;
var15 = var1.pos;
int var16 = 0;
int var17 = 0;
int var18 = 0;
int var19 = 0;
int var20 = 0;
int var21 = 0;
int var22 = 0;
int var23 = 0;
int var24 = 0;
int var25 = 0;
int var26 = 0;
int var27 = 0;
int var28 = 0;
int var29;
for (var29 = 0; var29 < var6; ++var29) {
var28 = var28 + var1.readUByte() & 127;
if (var28 == 0 || var28 == 32) {
++var12;
} else if (var28 == 1) {
++var16;
} else if (var28 == 33) {
++var17;
} else if (var28 == 7) {
++var18;
} else if (var28 == 39) {
++var19;
} else if (var28 == 10) {
++var20;
} else if (var28 == 42) {
++var21;
} else if (var28 == 99) {
++var22;
} else if (var28 == 98) {
++var23;
} else if (var28 == 101) {
++var24;
} else if (var28 == 100) {
++var25;
} else if (var28 == 64 || var28 == 65 || var28 == 120 || var28 == 121 || var28 == 123) {
++var26;
} else {
++var27;
}
}
var29 = 0;
int var30 = var1.pos;
var1.pos += var26;
int var31 = var1.pos;
var1.pos += var11;
int var32 = var1.pos;
var1.pos += var10;
int var33 = var1.pos;
var1.pos += var9;
int var34 = var1.pos;
var1.pos += var16;
int var35 = var1.pos;
var1.pos += var18;
int var36 = var1.pos;
var1.pos += var20;
int var37 = var1.pos;
var1.pos += var7 + var8 + var11;
int var38 = var1.pos;
var1.pos += var7;
int var39 = var1.pos;
var1.pos += var27;
int var40 = var1.pos;
var1.pos += var8;
int var41 = var1.pos;
var1.pos += var17;
int var42 = var1.pos;
var1.pos += var19;
int var43 = var1.pos;
var1.pos += var21;
int var44 = var1.pos;
var1.pos += var12;
int var45 = var1.pos;
var1.pos += var9;
int var46 = var1.pos;
var1.pos += var22;
int var47 = var1.pos;
var1.pos += var23;
int var48 = var1.pos;
var1.pos += var24;
int var49 = var1.pos;
var1.pos += var25;
int var50 = var1.pos;
var1.pos += var5 * 3;
this._h = new byte[var4];
final Buffer var51 = new Buffer(this._h);
var51.writeInt(1297377380);
var51.writeInt(6);
var51.writeShort(var2 > 1 ? 1 : 0);
var51.writeShort(var2);
var51.writeShort(var3);
var1.pos = var13;
int var52 = 0;
int var53 = 0;
int var54 = 0;
int var55 = 0;
int var56 = 0;
int var57 = 0;
int var58 = 0;
final int[] var59 = new int[128];
int i = 0;
label221:
for (int var60 = 0; var60 < var2; ++var60) {
var51.writeInt(1297379947);
var51.pos += 4;
final int var61 = var51.pos;
int var62 = -1;
while (true) {
while (true) {
final int var63 = var1.readVariableInt();
var51.a556(var63);
final int var64 = var1.data[var29++] & 255;
final boolean var65 = var64 != var62;
var62 = var64 & 15;
if (var64 == 7) {
if (var65) {
var51.writeByte(255);
}
var51.writeByte(47);
var51.writeByte(0);
var51.c093(var51.pos - var61);
continue label221;
}
if (var64 == 23) {
if (var65) {
var51.writeByte(255);
}
var51.writeByte(81);
var51.writeByte(3);
var51.writeByte(var1.data[var50++]);
var51.writeByte(var1.data[var50++]);
var51.writeByte(var1.data[var50++]);
} else {
var52 ^= var64 >> 4;
if (var62 == 0) {
if (var65) {
var51.writeByte(144 + var52);
}
var53 += var1.data[var37++];
var54 += var1.data[var38++];
var51.writeByte(var53 & 127);
var51.writeByte(var54 & 127);
} else if (var62 == 1) {
if (var65) {
var51.writeByte(128 + var52);
}
var53 += var1.data[var37++];
var55 += var1.data[var40++];
var51.writeByte(var53 & 127);
var51.writeByte(var55 & 127);
} else if (var62 == 2) {
if (var65) {
var51.writeByte(176 + var52);
}
i = i + var1.data[var15++] & 127;
var51.writeByte(i);
final byte var66;
if (i == 0 || i == 32) {
var66 = var1.data[var44++];
} else if (i == 1) {
var66 = var1.data[var34++];
} else if (i == 33) {
var66 = var1.data[var41++];
} else if (i == 7) {
var66 = var1.data[var35++];
} else if (i == 39) {
var66 = var1.data[var42++];
} else if (i == 10) {
var66 = var1.data[var36++];
} else if (i == 42) {
var66 = var1.data[var43++];
} else if (i == 99) {
var66 = var1.data[var46++];
} else if (i == 98) {
var66 = var1.data[var47++];
} else if (i == 101) {
var66 = var1.data[var48++];
} else if (i == 100) {
var66 = var1.data[var49++];
} else if (i == 64 || i == 65 || i == 120 || i == 121 || i == 123) {
var66 = var1.data[var30++];
} else {
var66 = var1.data[var39++];
}
final int var67 = var66 + var59[i];
var59[i] = var67;
var51.writeByte(var67 & 127);
} else if (var62 == 3) {
if (var65) {
var51.writeByte(224 + var52);
}
var56 += var1.data[var45++];
var56 += var1.data[var33++] << 7;
var51.writeByte(var56 & 127);
var51.writeByte(var56 >> 7 & 127);
} else if (var62 == 4) {
if (var65) {
var51.writeByte(208 + var52);
}
var57 += var1.data[var32++];
var51.writeByte(var57 & 127);
} else if (var62 == 5) {
if (var65) {
var51.writeByte(160 + var52);
}
var53 += var1.data[var37++];
var58 += var1.data[var31++];
var51.writeByte(var53 & 127);
var51.writeByte(var58 & 127);
} else {
if (var62 != 6) {
throw new RuntimeException();
}
if (var65) {
var51.writeByte(192 + var52);
}
var51.writeByte(var1.data[var44++]);
}
}
}
}
}
}
public static MusicTrack load(final ResourceLoader loader, final String item) {
final byte[] data = loader.getResource("", item);
return data == null ? null : new MusicTrack(new Buffer(data));
}
public void a797() {
if (this._i == null) {
this._i = new HashMap<>();
final int[] var1 = new int[16];
final int[] var2 = new int[16];
var2[9] = 128;
var1[9] = 128;
final pi_ var4 = new pi_(this._h);
final int var5 = var4.c784();
int var6;
for (var6 = 0; var6 < var5; ++var6) {
var4.b150(var6);
var4.d150(var6);
var4.e150(var6);
}
label53:
do {
while (true) {
var6 = var4.g784();
final int var7 = var4._b[var6];
while (var4._b[var6] == var7) {
var4.b150(var6);
final int var8 = var4.a137(var6);
if (var8 == 1) {
var4.e797();
var4.e150(var6);
continue label53;
}
final int var9 = var8 & 240;
int var10;
int var11;
int var12;
if (var9 == 176) {
var10 = var8 & 15;
var11 = var8 >> 8 & 127;
var12 = var8 >> 16 & 127;
if (var11 == 0) {
var1[var10] = (var1[var10] & -2080769) + (var12 << 14);
}
if (var11 == 32) {
var1[var10] = (var1[var10] & -16257) + (var12 << 7);
}
}
if (var9 == 192) {
var10 = var8 & 15;
var11 = var8 >> 8 & 127;
var2[var10] = var1[var10] + var11;
}
if (var9 == 144) {
var10 = var8 & 15;
var11 = var8 >> 8 & 127;
var12 = var8 >> 16 & 127;
if (var12 > 0) {
final int var13 = var2[var10];
final byte[] var14 = this._i.computeIfAbsent(var13, k -> new byte[128]);
var14[var11] = 1;
}
}
var4.d150(var6);
var4.e150(var6);
}
}
} while (!var4.a801());
}
}
public void b797() {
this._i = null;
}
}

View File

@ -0,0 +1 @@
* High quality MIDI format reference: http://www.music.mcgill.ca/~ich/classes/mumt306/StandardMIDIfileformat.html

View File

@ -18,8 +18,8 @@ public final class SampledAudioChannel implements Closeable {
private final AudioFormat format = new AudioFormat(SAMPLES_PER_SECOND, 16, 2, true, false);
private final byte[] buffer = new byte[1024];
private final tn_[] _o = new tn_[8];
private final tn_[] _s = new tn_[8];
private final MixerInterface_idk[] _o = new MixerInterface_idk[8];
private final MixerInterface_idk[] _s = new MixerInterface_idk[8];
public int[] data;
public int _g;
public int _b;
@ -27,7 +27,7 @@ public final class SampledAudioChannel implements Closeable {
private int lineBufferSizeInInts;
private boolean isShutdown = false;
private long _m = PseudoMonotonicClock.currentTimeMillis();
private tn_ source;
private MixerInterface_idk source;
private int _r = 0;
private int _l = 0;
private boolean _n = true;
@ -37,7 +37,7 @@ public final class SampledAudioChannel implements Closeable {
private int _u;
private long _q = 0L;
private static int a080lc(final int var1) {
private static int popcount(final int var1) {
final int var2 = (var1 & 0x55555555) + ((var1 >>> 1) & 0xd5555555);
final int var3 = (var2 & 0x33333333) + ((var2 & 0xcccccccc) >>> 2);
final int var4 = (var3 + (var3 >>> 4)) & 0xf0f0f0f;
@ -46,8 +46,8 @@ public final class SampledAudioChannel implements Closeable {
return var6 & 255;
}
private static void b446(final tn_ var0) {
var0._j = false;
private static void b446(final MixerInterface_idk var0) {
var0.useGenerateAudio1_idk = false;
if (var0._k != null) {
var0._k._h = 0;
}
@ -87,7 +87,7 @@ public final class SampledAudioChannel implements Closeable {
this.line.start();
this.lineBufferSizeInInts = size;
} catch (final LineUnavailableException var3) {
if (a080lc(size) == 1) {
if (popcount(size) == 1) {
this.line = null;
throw var3;
} else {
@ -106,7 +106,7 @@ public final class SampledAudioChannel implements Closeable {
int var4 = 0;
int var5 = 255;
tn_ var10;
MixerInterface_idk var10;
label106:
for (int var6 = 7; var5 != 0; --var6) {
int var7;
@ -123,7 +123,7 @@ public final class SampledAudioChannel implements Closeable {
if ((var9 & 1) != 0) {
var5 &= ~(1 << var7);
var10 = null;
tn_ var11 = this._o[var7];
MixerInterface_idk var11 = this._o[var7];
label100:
while (true) {
@ -138,7 +138,7 @@ public final class SampledAudioChannel implements Closeable {
var10 = var11;
var11 = var11._h;
} else {
var11._j = true;
var11.useGenerateAudio1_idk = true;
final int var13 = var11.a784();
var4 += var13;
if (var12 != null) {
@ -152,7 +152,7 @@ public final class SampledAudioChannel implements Closeable {
final int var15 = var11._i;
var11.forEach(var14 -> this.a607(var14, var15 * var14.c784() >> 8));
final tn_ var18 = var11._h;
final MixerInterface_idk var18 = var11._h;
var11._h = null;
if (var10 == null) {
this._o[var7] = var18;
@ -176,7 +176,7 @@ public final class SampledAudioChannel implements Closeable {
}
for (int var6 = 0; var6 < 8; ++var6) {
tn_ var16 = this._o[var6];
MixerInterface_idk var16 = this._o[var6];
this._s[var6] = null;
for (this._o[var6] = null; var16 != null; var16 = var10) {
@ -191,7 +191,7 @@ public final class SampledAudioChannel implements Closeable {
}
if (this.source != null) {
this.source.b397(data, 0, 256);
this.source.generateAudio1_idk(data, 0, 256);
}
this._m = PseudoMonotonicClock.currentTimeMillis();
@ -203,13 +203,13 @@ public final class SampledAudioChannel implements Closeable {
this._a = 0;
}
if (this.source != null) {
this.source.a150(256);
this.source.generateAudio2_idk(256);
}
}
private void a607(final tn_ var1, final int var2) {
private void a607(final MixerInterface_idk var1, final int var2) {
final int i = var2 >> 5;
final tn_ var4 = this._s[i];
final MixerInterface_idk var4 = this._s[i];
if (var4 == null) {
this._o[i] = var1;
} else {
@ -309,7 +309,7 @@ public final class SampledAudioChannel implements Closeable {
}
}
public synchronized void setSource(final tn_ source) {
public synchronized void setSource(final MixerInterface_idk source) {
this.source = source;
}

View File

@ -0,0 +1,431 @@
package funorb.audio;
import funorb.cache.ResourceLoader;
import funorb.io.Buffer;
import java.util.HashMap;
import java.util.Map;
/** Parses a custom song format into a standard MIDI file */
public final class SongData {
public byte[] midiData;
public Map<Integer, byte[]> notesUsedPerProgram;
private SongData(final Buffer input) {
input.pos = input.data.length - 3;
final int numTracks = input.readUByte();
final int pulsesPerQuarterNote = input.readUShort();
input.pos = 0;
int midiSize = 14 + numTracks * 10;
int nTempos = 0;
int nCommands = 0;
int nVelocityDeltas = 0;
int nNoteOffVelocityDeltas = 0;
int nPitchWheelMsbDeltas = 0;
int nChannelAftertouchDeltas = 0;
int nPolyAftertouchDeltas = 0;
int nPatchChangeDeltas = 0;
int nModWheelMsbDeltas = 0;
int nModWheelLsbDeltas = 0;
int nVolumeMsbDeltas = 0;
int nVolumeLsbDeltas = 0;
int nPanMsbDeltas = 0;
int nPanLsbDeltas = 0;
int nNrpnMsbDeltas = 0;
int nNrpnLsbDeltas = 0;
int nRpnMsbDeltas = 0;
int nRpnLsbDeltas = 0;
int nOnOffDeltas = 0;
int nOtherControlDeltas = 0;
for (int track = 0; track < numTracks; ++track) {
int inputCommand;
int command = -1;
while (true) {
inputCommand = input.readUByte();
if (inputCommand != command) {
++midiSize;
}
command = inputCommand & 15;
if (inputCommand == 7) {
break;
}
if (inputCommand == 23) {
++nTempos;
} else if (command == 0) {
++nVelocityDeltas;
} else if (command == 1) {
++nNoteOffVelocityDeltas;
} else if (command == 2) {
++nCommands;
} else if (command == 3) {
++nPitchWheelMsbDeltas;
} else if (command == 4) {
++nChannelAftertouchDeltas;
} else if (command == 5) {
++nPolyAftertouchDeltas;
} else {
if (command != 6) {
throw new RuntimeException();
}
++nPatchChangeDeltas;
}
}
}
midiSize += 5 * nTempos;
midiSize += 2 * (
nVelocityDeltas
+ nNoteOffVelocityDeltas
+ nCommands
+ nPitchWheelMsbDeltas
+ nPolyAftertouchDeltas);
midiSize += nChannelAftertouchDeltas + nPatchChangeDeltas;
int startOfTicksTable = input.pos;
int numEvents =
numTracks
+ nTempos
+ nCommands
+ nVelocityDeltas
+ nNoteOffVelocityDeltas
+ nPitchWheelMsbDeltas
+ nChannelAftertouchDeltas
+ nPolyAftertouchDeltas
+ nPatchChangeDeltas;
for (int i = 0; i < numEvents; ++i) {
input.readVariableInt();
}
midiSize += input.pos - startOfTicksTable;
int posControlDeltas = input.pos;
int cmd = 0;
for (int i = 0; i < nCommands; ++i) {
cmd = cmd + input.readUByte() & 127;
if (cmd == 0 || cmd == 32) {
++nPatchChangeDeltas;
} else if (cmd == 1) {
++nModWheelMsbDeltas;
} else if (cmd == 33) {
++nModWheelLsbDeltas;
} else if (cmd == 7) {
++nVolumeMsbDeltas;
} else if (cmd == 39) {
++nVolumeLsbDeltas;
} else if (cmd == 10) {
++nPanMsbDeltas;
} else if (cmd == 42) {
++nPanLsbDeltas;
} else if (cmd == 99) {
++nNrpnMsbDeltas;
} else if (cmd == 98) {
++nNrpnLsbDeltas;
} else if (cmd == 101) {
++nRpnMsbDeltas;
} else if (cmd == 100) {
++nRpnLsbDeltas;
} else if (cmd == 64 || cmd == 65 || cmd == 120 || cmd == 121 || cmd == 123) {
++nOnOffDeltas;
} else {
++nOtherControlDeltas;
}
}
int posCommands = 0;
int posOnOffDeltas = input.pos;
input.pos += nOnOffDeltas;
int posPolyAftertouchDeltas = input.pos;
input.pos += nPolyAftertouchDeltas;
int posChannelAftertouchDeltas = input.pos;
input.pos += nChannelAftertouchDeltas;
int posPitchWheelMsbDeltas = input.pos;
input.pos += nPitchWheelMsbDeltas;
int posModWheelMsbDeltas = input.pos;
input.pos += nModWheelMsbDeltas;
int posVolumeMsbDeltas = input.pos;
input.pos += nVolumeMsbDeltas;
int posPanMsbDeltas = input.pos;
input.pos += nPanMsbDeltas;
int posKeyDeltas = input.pos;
input.pos += nVelocityDeltas + nNoteOffVelocityDeltas + nPolyAftertouchDeltas;
int posVelocityDeltas = input.pos;
input.pos += nVelocityDeltas;
int posOtherControllerDeltas = input.pos;
input.pos += nOtherControlDeltas;
int posNoteOffVelocityDeltas = input.pos;
input.pos += nNoteOffVelocityDeltas;
int posModWheelLsbDeltas = input.pos;
input.pos += nModWheelLsbDeltas;
int posVolumeLsbDeltas = input.pos;
input.pos += nVolumeLsbDeltas;
int posPanLsbDeltas = input.pos;
input.pos += nPanLsbDeltas;
int posPatchChangeDeltas = input.pos;
input.pos += nPatchChangeDeltas;
int posPitchWheelLsbDeltas = input.pos;
input.pos += nPitchWheelMsbDeltas;
int posNrpnMsbDeltas = input.pos;
input.pos += nNrpnMsbDeltas;
int posNrpnLsbDeltas = input.pos;
input.pos += nNrpnLsbDeltas;
int posRpnMsbDeltas = input.pos;
input.pos += nRpnMsbDeltas;
int posRpnLsbDeltas = input.pos;
input.pos += nRpnLsbDeltas;
int posTempos = input.pos;
input.pos += nTempos * 3;
this.midiData = new byte[midiSize];
final Buffer midi = new Buffer(this.midiData);
midi.writeInt(0x4d546864); // MThd
midi.writeInt(6);
midi.writeShort(numTracks > 1 ? 1 : 0);
midi.writeShort(numTracks);
midi.writeShort(pulsesPerQuarterNote);
input.pos = startOfTicksTable;
int midiChannel = 0;
int key = 0;
int velocity = 0;
int noteOffVelocity = 0;
int pitchWheel = 0;
int channelAftertouch = 0;
int polyAftertouch = 0;
final int[] controllerValues = new int[128];
int controller = 0;
label221:
for (int track = 0; track < numTracks; ++track) {
midi.writeInt(0x4d54726b); // MTrk
midi.pos += 4; // skip MTrk length field
final int trackStartPos = midi.pos;
int command = -1;
while (true) {
while (true) {
final int ticks = input.readVariableInt();
midi.writeVariableInt_v2(ticks);
final int inputCommand = input.data[posCommands++] & 255;
final boolean statusChanged = inputCommand != command;
command = inputCommand & 15;
if (inputCommand == 7) {
if (statusChanged) {
midi.writeByte(0xff); // meta event
}
midi.writeByte(0x2f); // track end
midi.writeByte(0);
midi.writeSizePrefixBackwards(midi.pos - trackStartPos);
continue label221;
}
if (inputCommand == 23) {
if (statusChanged) {
midi.writeByte(0xff); // meta event
}
midi.writeByte(0x51); // set tempo
midi.writeByte(3);
midi.writeByte(input.data[posTempos++]);
midi.writeByte(input.data[posTempos++]);
midi.writeByte(input.data[posTempos++]);
} else {
midiChannel ^= inputCommand >> 4; // ????
if (command == 0) {
if (statusChanged) {
midi.writeByte(0x90 + midiChannel); // note on
}
key += input.data[posKeyDeltas++];
velocity += input.data[posVelocityDeltas++];
midi.writeByte(key & 127);
midi.writeByte(velocity & 127);
} else if (command == 1) {
if (statusChanged) {
midi.writeByte(0x80 + midiChannel); // note off
}
key += input.data[posKeyDeltas++];
noteOffVelocity += input.data[posNoteOffVelocityDeltas++];
midi.writeByte(key & 127);
midi.writeByte(noteOffVelocity & 127);
} else if (command == 2) {
if (statusChanged) {
midi.writeByte(0xb0 + midiChannel); // control change
}
controller += input.data[posControlDeltas++] & 127;
midi.writeByte(controller);
final byte valueDelta;
if (controller == 0 || controller == 32) { // bank switch msb/lsb
valueDelta = input.data[posPatchChangeDeltas++];
} else if (controller == 1) { // mod wheel msb
valueDelta = input.data[posModWheelMsbDeltas++];
} else if (controller == 33) { // mod wheel lsb
valueDelta = input.data[posModWheelLsbDeltas++];
} else if (controller == 7) { // channel volume msb
valueDelta = input.data[posVolumeMsbDeltas++];
} else if (controller == 39) { // channel volume lsb
valueDelta = input.data[posVolumeLsbDeltas++];
} else if (controller == 10) { // pan msb
valueDelta = input.data[posPanMsbDeltas++];
} else if (controller == 42) { // pan lsb
valueDelta = input.data[posPanLsbDeltas++];
} else if (controller == 99) { // nrpn msb
valueDelta = input.data[posNrpnMsbDeltas++];
} else if (controller == 98) { // nrpn lsb
valueDelta = input.data[posNrpnLsbDeltas++];
} else if (controller == 101) { // rpn msb
valueDelta = input.data[posRpnMsbDeltas++];
} else if (controller == 100) { // rpn lsb
valueDelta = input.data[posRpnLsbDeltas++];
} else if (
controller == 64 // sustain pedal on/off
|| controller == 65 // portamento on/of
|| controller == 120 // all sound off
|| controller == 121 // reset all controllers
|| controller == 123) { // all notes off
valueDelta = input.data[posOnOffDeltas++];
} else {
valueDelta = input.data[posOtherControllerDeltas++];
}
final int value = valueDelta + controllerValues[controller];
controllerValues[controller] = value;
midi.writeByte(value & 127);
} else if (command == 3) {
if (statusChanged) {
midi.writeByte(0xe0 + midiChannel); // pitch wheel
}
pitchWheel += input.data[posPitchWheelLsbDeltas++];
pitchWheel += input.data[posPitchWheelMsbDeltas++] << 7;
midi.writeByte(pitchWheel & 127);
midi.writeByte(pitchWheel >> 7 & 127);
} else if (command == 4) {
if (statusChanged) {
midi.writeByte(0xd0 + midiChannel); // channel aftertouch
}
channelAftertouch += input.data[posChannelAftertouchDeltas++];
midi.writeByte(channelAftertouch & 127);
} else if (command == 5) {
if (statusChanged) {
midi.writeByte(0xa0 + midiChannel); // polyphonic aftertouch
}
key += input.data[posKeyDeltas++];
polyAftertouch += input.data[posPolyAftertouchDeltas++];
midi.writeByte(key & 127);
midi.writeByte(polyAftertouch & 127);
} else {
if (command != 6) {
throw new RuntimeException();
}
if (statusChanged) {
midi.writeByte(0xc0 + midiChannel); // program change
}
midi.writeByte(input.data[posPatchChangeDeltas++]);
}
}
}
}
}
}
public static SongData load(final ResourceLoader loader, final String item) {
final byte[] data = loader.getResource("", item);
return data == null ? null : new SongData(new Buffer(data));
}
public void analyzeNotesUsedPerProgram() {
if (this.notesUsedPerProgram == null) {
this.notesUsedPerProgram = new HashMap<>();
final int[] bank = new int[16];
final int[] program = new int[16];
program[9] = 128;
bank[9] = 128;
final MidiReader midiReader = new MidiReader(this.midiData);
final int numTracks = midiReader.numTracks();
int track;
for (track = 0; track < numTracks; ++track) {
midiReader.setCursorToTrackPlaybackPos(track);
midiReader.advanceTrackTicks(track);
midiReader.setTrackPlaybackPosToCursor(track);
}
label53:
do {
while (true) {
track = midiReader.trackWithSoonestNextTick();
final int thisTick = midiReader.trackNextTick[track];
while (midiReader.trackNextTick[track] == thisTick) {
midiReader.setCursorToTrackPlaybackPos(track);
final int event = midiReader.readNextTrackEvent(track);
if (event == MidiReader.EVENT_TRACK_END) {
midiReader.resetCursor();
midiReader.setTrackPlaybackPosToCursor(track);
continue label53;
}
final int nibble = event & 0xf0;
int channel;
int param1;
int param2;
if (nibble == 0xb0) { // control change
channel = event & 0xf;
param1 = event >> 8 & 0x7f; // controller number
param2 = event >> 16 & 0x7f; // value
if (param1 == 0) { // CC0 = bank select, high 7 bits
bank[channel] = (bank[channel] & 0xffe03fff) + (param2 << 14);
}
if (param1 == 32) { // CC32 = bank select, low 7 bits
bank[channel] = (bank[channel] & 0xffffc07f) + (param2 << 7);
}
}
if (nibble == 0xc0) { // program change
channel = event & 0xf;
param1 = event >> 8 & 127; // program number
program[channel] = bank[channel] + param1;
}
if (nibble == 0x90) { // note on
channel = event & 0xf;
param1 = event >> 8 & 127;
param2 = event >> 16 & 127;
if (param2 > 0) {
final int prog = program[channel];
final byte[] notesUsed = this.notesUsedPerProgram.computeIfAbsent(prog, k -> new byte[128]);
notesUsed[param1] = 1;
}
}
midiReader.advanceTrackTicks(track);
midiReader.setTrackPlaybackPosToCursor(track);
}
}
} while (!midiReader.allTracksStopped());
}
}
public void resetNotesUsedPerProgram() {
this.notesUsedPerProgram = null;
}
}

View File

@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.Iterator;
public final class al_ extends tn_ {
public final class al_ extends MixerInterface_idk {
private final int _u;
private final boolean _o;
private final int _r;
@ -579,7 +579,7 @@ public final class al_ extends tn_ {
}
@Override
public synchronized void a150(int len) {
public synchronized void generateAudio2_idk(int len) {
if (this._v > 0) {
if (len >= this._v) {
if (this.volume == Integer.MIN_VALUE) {
@ -766,7 +766,7 @@ public final class al_ extends tn_ {
}
@Override
public @NotNull Iterator<tn_> iterator() {
public @NotNull Iterator<MixerInterface_idk> iterator() {
return Collections.emptyIterator();
}
@ -785,9 +785,9 @@ public final class al_ extends tn_ {
}
@Override
public synchronized void b397(final int[] dest, final int offset, final int len) {
public synchronized void generateAudio1_idk(final int[] dest, final int offset, final int len) {
if (this.volume == 0 && this._v == 0) {
this.a150(len);
this.generateAudio2_idk(len);
return;
}

View File

@ -6,32 +6,32 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
public final class h_ extends tn_ {
public final ga_ _r;
public final ga_ _u;
public final class h_ extends MixerInterface_idk {
public final MidiPlayer_idk _r;
public final MidiPlayer_idk _u;
private int[] _D;
private MusicTrack _E;
private SongData _E;
private int _l;
private int _n = 0x100000;
private MusicTrack _z;
private SongData _z;
private int[] _p;
private int volume = 256;
private boolean _C;
public h_() {
final ga_ var1 = new ga_();
final MidiPlayer_idk var1 = new MidiPlayer_idk();
this._u = var1;
this._r = new ga_(var1);
this._r = new MidiPlayer_idk(var1);
}
public boolean a419(final MusicTrack var1) {
public boolean a419(final SongData var1) {
return var1 == this._z || var1 == this._E;
}
@Override
public void b397(final int[] dest, final int offset, final int len) {
public void generateAudio1_idk(final int[] dest, final int offset, final int len) {
if (this.volume <= 0) {
this.a150(len);
this.generateAudio2_idk(len);
} else {
if (this._C) {
if (this._l > 0 && !this._u.h154()) {
@ -77,9 +77,9 @@ public final class h_ extends tn_ {
int var8;
if (this._z != null || this._E != null) {
if (var4 == 256) {
this._u.b397(dest, offset, len);
this._u.generateAudio1_idk(dest, offset, len);
} else if (var5 == 256) {
this._r.b397(dest, offset, len);
this._r.generateAudio1_idk(dest, offset, len);
} else {
if (this._D != null && this._D.length >= var6) {
Arrays.fill(this._D, 0, var6, 0);
@ -89,8 +89,8 @@ public final class h_ extends tn_ {
this._D = new int[var6];
}
this._u.b397(this._D, 0, len);
this._r.b397(this._p, 0, len);
this._u.generateAudio1_idk(this._D, 0, len);
this._r.generateAudio1_idk(this._p, 0, len);
var7 = offset << 1;
for (var8 = 0; var6 > var8; ++var8) {
@ -103,13 +103,13 @@ public final class h_ extends tn_ {
}
@Override
public synchronized void a150(final int len) {
public synchronized void generateAudio2_idk(final int len) {
if (this._n > 0 && this._z != null) {
this._u.a150(len);
this._u.generateAudio2_idk(len);
}
if (this._n < 1048576 && this._E != null) {
this._r.a150(len);
this._r.generateAudio2_idk(len);
}
if (this._C) {
@ -151,7 +151,7 @@ public final class h_ extends tn_ {
}
private void a633(final ga_ var3) {
private void a633(final MidiPlayer_idk var3) {
var3.a679();
var3.c430();
}
@ -166,11 +166,11 @@ public final class h_ extends tn_ {
}
@Override
public @NotNull Iterator<tn_> iterator() {
public @NotNull Iterator<MixerInterface_idk> iterator() {
return Collections.emptyIterator();
}
public synchronized void a180(final MusicTrack track, final int var5, final boolean var4) {
public synchronized void a180(final SongData track, final int var5, final boolean var4) {
if (this._C && var4) {
if (this._l > 0) {
if (this._z != null) {

View File

@ -1,200 +0,0 @@
package funorb.audio;
import funorb.io.Buffer;
import java.util.Arrays;
public final class pi_ {
private static final byte[] _g = new byte[]{2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
private final Buffer _i = new Buffer(null);
public int _e;
public int[] _b;
private int[] _h;
private int[] _c;
private int[] _d;
private long _f;
private int _a;
public pi_() {
}
public pi_(final byte[] var1) {
this.a604(var1);
}
public boolean a801() {
return Arrays.stream(this._h).noneMatch(i -> i >= 0);
}
public int a137(final int var1) {
return this.f137(var1);
}
public void a111(final long var1) {
this._f = var1;
final int var3 = this._h.length;
for (int var4 = 0; var4 < var3; ++var4) {
this._b[var4] = 0;
this._d[var4] = 0;
this._i.pos = this._c[var4];
this.d150(var4);
this._h[var4] = this._i.pos;
}
}
public long c138(final int var1) {
return this._f + (long) var1 * (long) this._a;
}
public void b150(final int var1) {
this._i.pos = this._h[var1];
}
private int a080(final int var1, final int var2) {
int var4;
if (var2 == 255) {
final int var7 = this._i.readUByte();
var4 = this._i.readVariableInt();
final Buffer var10000;
if (var7 == 47) {
var10000 = this._i;
var10000.pos += var4;
return 1;
} else if (var7 == 81) {
final int var5 = this._i.readU24();
var4 -= 3;
final int var6 = this._b[var1];
this._f += (long) var6 * (long) (this._a - var5);
this._a = var5;
var10000 = this._i;
var10000.pos += var4;
return 2;
} else {
var10000 = this._i;
var10000.pos += var4;
return 3;
}
} else {
final byte var3 = _g[var2 - 128];
var4 = var2;
if (var3 >= 1) {
var4 = var2 | this._i.readUByte() << 8;
}
if (var3 >= 2) {
var4 |= this._i.readUByte() << 16;
}
return var4;
}
}
public int g784() {
final int var1 = this._h.length;
int var2 = -1;
int var3 = Integer.MAX_VALUE;
for (int var4 = 0; var4 < var1; ++var4) {
if (this._h[var4] >= 0 && this._b[var4] < var3) {
var2 = var4;
var3 = this._b[var4];
}
}
return var2;
}
public void e797() {
this._i.pos = -1;
}
public void e150(final int var1) {
this._h[var1] = this._i.pos;
}
public int c784() {
return this._h.length;
}
private int f137(final int var1) {
final byte var2 = this._i.data[this._i.pos];
final int var5;
if (var2 < 0) {
var5 = var2 & 255;
this._d[var1] = var5;
++this._i.pos;
} else {
var5 = this._d[var1];
}
if (var5 == 240 || var5 == 247) {
final int var3 = this._i.readVariableInt();
if (var5 == 247 && var3 > 0) {
final int var4 = this._i.data[this._i.pos] & 255;
if (var4 >= 241 && var4 <= 243 || var4 == 246 || var4 == 248 || var4 >= 250 && var4 <= 252 || var4 == 254) {
++this._i.pos;
this._d[var1] = var4;
return this.a080(var1, var4);
}
}
this._i.pos += var3;
return 0;
} else {
return this.a080(var1, var5);
}
}
public void d797() {
this._i.data = null;
this._c = null;
this._h = null;
this._b = null;
this._d = null;
}
public boolean f801() {
return this._i.data != null;
}
public void d150(final int var1) {
final int var2 = this._i.readVariableInt();
final int[] var10000 = this._b;
var10000[var1] += var2;
}
public void a604(final byte[] var1) {
this._i.data = var1;
this._i.pos = 10;
final int var2 = this._i.readUShort();
this._e = this._i.readUShort();
this._a = 500000;
this._c = new int[var2];
Buffer var10000;
int var3;
int var5;
for (var3 = 0; var3 < var2; var10000.pos += var5) {
final int var4 = this._i.readInt();
var5 = this._i.readInt();
if (var4 == 1297379947) {
this._c[var3] = this._i.pos;
++var3;
}
var10000 = this._i;
}
this._f = 0L;
this._h = new int[var2];
for (var3 = 0; var3 < var2; ++var3) {
this._h[var3] = this._c[var3];
}
this._b = new int[var2];
this._d = new int[var2];
}
}

View File

@ -6,18 +6,18 @@ import org.jetbrains.annotations.NotNull;
import java.util.Iterator;
import java.util.Objects;
public final class rc_ extends tn_ {
public final NodeList<qq_> _n = new NodeList<>();
public final class rc_ extends MixerInterface_idk {
public final NodeList<MixerTrackConfig_idk> _n = new NodeList<>();
public final vk_ _o = new vk_();
private final ga_ _m;
private final MidiPlayer_idk _m;
public rc_(final ga_ var1) {
public rc_(final MidiPlayer_idk var1) {
this._m = var1;
}
@Override
public @NotNull Iterator<tn_> iterator() {
return this._n.stream().<tn_>map(var1 -> var1._K).filter(Objects::nonNull).iterator();
public @NotNull Iterator<MixerInterface_idk> iterator() {
return this._n.stream().<MixerInterface_idk>map(var1 -> var1._K).filter(Objects::nonNull).iterator();
}
@Override
@ -26,10 +26,10 @@ public final class rc_ extends tn_ {
}
@Override
public void a150(final int len) {
this._o.a150(len);
public void generateAudio2_idk(final int len) {
this._o.generateAudio2_idk(len);
for (final qq_ var3 : this._n) {
for (final MixerTrackConfig_idk var3 : this._n) {
if (!this._m.a258(var3)) {
int var2 = len;
@ -49,10 +49,10 @@ public final class rc_ extends tn_ {
}
@Override
public void b397(final int[] dest, final int offset, final int len) {
this._o.b397(dest, offset, len);
public void generateAudio1_idk(final int[] dest, final int offset, final int len) {
this._o.generateAudio1_idk(dest, offset, len);
for (final qq_ var6 : this._n) {
for (final MixerTrackConfig_idk var6 : this._n) {
if (!this._m.a258(var6)) {
int var4 = offset;
int var5 = len;
@ -73,7 +73,7 @@ public final class rc_ extends tn_ {
}
private void a222(final qq_ var2, int var3) {
private void a222(final MixerTrackConfig_idk var2, int var3) {
if ((4 & this._m._F[var2._y]) != 0 && var2._E < 0) {
final int var4 = this._m._u[var2._y] / SampledAudioChannel.SAMPLES_PER_SECOND;
final int var5 = (1048575 + var4 - var2._j) / var4;
@ -96,10 +96,10 @@ public final class rc_ extends tn_ {
}
assert var2._K != null;
var2._K.a150(var3);
var2._K.generateAudio2_idk(var3);
}
private void a829(final int[] var1, int var2, final qq_ var3, int var4, final int var6) {
private void a829(final int[] var1, int var2, final MixerTrackConfig_idk var3, int var4, final int var6) {
if ((4 & this._m._F[var3._y]) != 0 && var3._E < 0) {
final int var7 = this._m._u[var3._y] / SampledAudioChannel.SAMPLES_PER_SECOND;
@ -110,7 +110,7 @@ public final class rc_ extends tn_ {
break;
}
var3._K.b397(var1, var2, var8);
var3._K.generateAudio1_idk(var1, var2, var8);
var3._j += var8 * var7 - 1048576;
var2 += var8;
var4 -= var8;
@ -135,13 +135,13 @@ public final class rc_ extends tn_ {
}
var11.g150(var9);
var11.b397(var1, var2, var6 - var2);
var11.generateAudio1_idk(var1, var2, var6 - var2);
if (var11.e801()) {
this._o.addFirst(var11);
}
}
}
var3._K.b397(var1, var2, var4);
var3._K.generateAudio1_idk(var1, var2, var4);
}
}

View File

@ -1,30 +0,0 @@
package funorb.audio;
import funorb.data.NodeList;
public abstract class tn_ extends NodeList.Node implements Iterable<tn_> {
public volatile boolean _j = true;
public int _i;
public tn_ _h;
public kk_ _k;
protected tn_() {}
public abstract void b397(int[] dest, int offset, int len);
protected final void a397(final int[] dest, final int offset, final int len) {
if (this._j) {
this.b397(dest, offset, len);
} else {
this.a150(len);
}
}
public abstract void a150(int len);
public abstract int a784();
public int c784() {
return 255;
}
}

View File

@ -5,11 +5,11 @@ import org.jetbrains.annotations.NotNull;
import java.util.Iterator;
public final class vk_ extends tn_ {
private final NodeList<tn_> _l = new NodeList<>();
public final class vk_ extends MixerInterface_idk {
private final NodeList<MixerInterface_idk> _l = new NodeList<>();
@Override
public @NotNull Iterator<tn_> iterator() {
public @NotNull Iterator<MixerInterface_idk> iterator() {
return this._l.iterator();
}
@ -19,9 +19,9 @@ public final class vk_ extends tn_ {
}
@Override
public synchronized void a150(final int len) {
for (final tn_ var2 : this._l) {
var2.a150(len);
public synchronized void generateAudio2_idk(final int len) {
for (final MixerInterface_idk var2 : this._l) {
var2.generateAudio2_idk(len);
}
}
@ -30,9 +30,9 @@ public final class vk_ extends tn_ {
}
@Override
public synchronized void b397(final int[] dest, final int offset, final int len) {
for (final tn_ var4 : this._l) {
var4.a397(dest, offset, len);
public synchronized void generateAudio1_idk(final int[] dest, final int offset, final int len) {
for (final MixerInterface_idk var4 : this._l) {
var4.generateAudio(dest, offset, len);
}
}
}

View File

@ -103,11 +103,11 @@ public class Buffer implements ReadableBuffer, WritableBuffer {
}
}
public final void c093(final int var1) {
this.data[-var1 + this.pos - 4] = (byte) (var1 >> 24);
this.data[-3 + this.pos - var1] = (byte) (var1 >> 16);
this.data[-var1 + this.pos - 2] = (byte) (var1 >> 8);
this.data[this.pos + (-var1 - 1)] = (byte) var1;
public final void writeSizePrefixBackwards(final int length) {
this.data[this.pos - length - 4] = (byte) (length >> 24);
this.data[this.pos - length - 3] = (byte) (length >> 16);
this.data[this.pos - length - 2] = (byte) (length >> 8);
this.data[this.pos - length - 1] = (byte) length;
}
@Override
@ -154,6 +154,22 @@ public class Buffer implements ReadableBuffer, WritableBuffer {
this.data[this.pos++] = (byte) (val & 0x7f);
}
public final void writeVariableInt_v2(final int val) {
if ((val & 0xffffff80) != 0) {
if ((val & 0xffffc000) != 0) {
if ((0xffe00000 & val) != 0) {
if ((0xf0000000 & val) != 0) {
this.writeByte(val >>> 28 | 0x80);
}
this.writeByte(val >>> 21 | 0x80);
}
this.writeByte(val >>> 14 | 0x80);
}
this.writeByte(val >>> 7 | 0x80);
}
this.writeByte(0x7f & val);
}
@Override
public final byte readByte() {
return this.data[this.pos++];
@ -339,26 +355,6 @@ public class Buffer implements ReadableBuffer, WritableBuffer {
}
}
public final void a556(final int var2) {
if ((var2 & -128) != 0) {
if ((var2 & -16384) != 0) {
if ((-2097152 & var2) != 0) {
if ((-268435456 & var2) != 0) {
this.writeByte(var2 >>> 28 | 128);
}
this.writeByte(var2 >>> 21 | 128);
}
this.writeByte((2107852 | var2) >>> 14);
}
this.writeByte(var2 >>> 7 | 128);
}
this.writeByte(127 & var2);
}
@Override
public final int readInt() {
this.pos += 4;

View File

@ -2,7 +2,7 @@ package funorb.shatteredplans.client;
import funorb.Strings;
import funorb.audio.AudioThread;
import funorb.audio.MusicTrack;
import funorb.audio.SongData;
import funorb.audio.SampledAudioChannel;
import funorb.audio.h_;
import funorb.audio.vk_;
@ -223,7 +223,7 @@ public final class ShatteredPlansClient extends JagexApplet {
public static int thirdPreviousS2cPacketType = -1;
private static boolean _sbh;
public static boolean _isa;
public static MusicTrack currentTrack;
public static SongData currentTrack;
public static String MUSIC_OPT_NEW;
public static String MUSIC_OPT_OLD;
public static boolean accountCreationDisabled;
@ -3762,7 +3762,7 @@ public final class ShatteredPlansClient extends JagexApplet {
}
}
public static void a827jo(final MusicTrack track, final int var3, final boolean var2) {
public static void a827jo(final SongData track, final int var3, final boolean var2) {
Sounds.musicTn.a180(track, var3, !var2);
}

View File

@ -1,6 +1,6 @@
package funorb.shatteredplans.client;
import funorb.audio.MusicTrack;
import funorb.audio.SongData;
import funorb.audio.PlayingSound;
import funorb.audio.SampledAudioChannel;
import funorb.audio.SoundEffect;
@ -24,11 +24,11 @@ public final class Sounds {
public static SoundEffect SFX_EXPLOSION;
public static SoundEffect SFX_NEXT_OPEN;
public static SoundEffect SFX_NEXT_CLOSE;
public static MusicTrack MUSIC_INTRO;
public static MusicTrack MUSIC_IN_GAME_2;
public static MusicTrack MUSIC_IN_GAME_1;
public static MusicTrack MUSIC_WIN;
public static MusicTrack MUSIC_LOSE;
public static SongData MUSIC_INTRO;
public static SongData MUSIC_IN_GAME_2;
public static SongData MUSIC_IN_GAME_1;
public static SongData MUSIC_WIN;
public static SongData MUSIC_LOSE;
public static int soundVolume = 256;
public static int musicVolume = 256;
@ -52,11 +52,11 @@ public final class Sounds {
}
public static void loadMusic(final ResourceLoader loader1, final ResourceLoader loader2) {
MUSIC_INTRO = MusicTrack.load(loader1, "shattered_plans_intro");
MUSIC_IN_GAME_1 = MusicTrack.load(loader1, "shattered_plans_ingame");
MUSIC_IN_GAME_2 = MusicTrack.load(loader1, "shattered_plans_ingame_two");
MUSIC_WIN = MusicTrack.load(loader1, "shattered_plans_win");
MUSIC_LOSE = MusicTrack.load(loader1, "shattered_plans_lose");
MUSIC_INTRO = SongData.load(loader1, "shattered_plans_intro");
MUSIC_IN_GAME_1 = SongData.load(loader1, "shattered_plans_ingame");
MUSIC_IN_GAME_2 = SongData.load(loader1, "shattered_plans_ingame_two");
MUSIC_WIN = SongData.load(loader1, "shattered_plans_win");
MUSIC_LOSE = SongData.load(loader1, "shattered_plans_lose");
ShatteredPlansClient.currentTrack = MUSIC_IN_GAME_2;
musicTn._u.a350(SoundLoader.globalLoader, loader2, MUSIC_INTRO);