Identify more sample playback components

This commit is contained in:
Alex Iadicicco 2022-12-04 00:20:01 -08:00 committed by Alexis King
parent ebe346235b
commit 6aefbd9e2a
13 changed files with 326 additions and 315 deletions

View File

@ -1,22 +1,28 @@
package funorb.audio;
public final class AudioSampleData_idk {
public final int _k;
public final int _l;
public final int loopEnd_idfk;
public final int loopStart_idfk;
public final int sampleRate;
public final byte[] data;
public final boolean _i;
public final boolean isLooped_idk;
public int _h;
public AudioSampleData_idk(final byte[] data, final int var3, final int var4) {
this(SampledAudioChannel.SAMPLES_PER_SECOND, data, var3, var4, false);
public AudioSampleData_idk(final byte[] data, final int loopStart, final int loopEnd) {
this(SampledAudioChannel.SAMPLES_PER_SECOND, data, loopStart, loopEnd, false);
}
public AudioSampleData_idk(final int sampleRate, final byte[] data, final int var3, final int var4, final boolean var5) {
public AudioSampleData_idk(
final int sampleRate,
final byte[] data,
final int loopStart,
final int loopEnd,
final boolean isLooped
) {
this.sampleRate = sampleRate;
this.data = data;
this._l = var3;
this._k = var4;
this._i = var5;
this.loopStart_idfk = loopStart;
this.loopEnd_idfk = loopEnd;
this.isLooped_idk = isLooped;
}
}

View File

@ -14,7 +14,7 @@ public final class AudioSamplePlayback_idk extends AudioSource_idk {
private int volActualX;
private int ampRateR;
private int ampRateL;
private int playhead;
private int playhead; // sample data index << 8
private int volX;
private int volDeltaX;
private int loopDirection_idk;
@ -24,9 +24,9 @@ public final class AudioSamplePlayback_idk extends AudioSource_idk {
private AudioSamplePlayback_idk(final AudioSampleData_idk var1, final int pitchX, final int volX, final int panX) {
this.sampleData = var1;
this.loopStart_idfk = var1._l;
this.loopEnd_idfk = var1._k;
this._o = var1._i;
this.loopStart_idfk = var1.loopStart_idfk;
this.loopEnd_idfk = var1.loopEnd_idfk;
this._o = var1.isLooped_idk;
this.pitchX = pitchX;
this.volX = volX;
this.panX = panX;
@ -528,25 +528,23 @@ public final class AudioSamplePlayback_idk extends AudioSource_idk {
}
}
public synchronized int getVolume() {
public synchronized int getVolX() {
return this.volX == Integer.MIN_VALUE ? 0 : this.volX;
}
public synchronized void a093(final int var1, final int var2) {
this.a326(var1, var2, this.panClampedX());
public synchronized void a093(final int var1, final int volX) {
this.a326(var1, volX, this.getPanX());
}
public synchronized void h150(int var1) {
final int var2 = this.sampleData.data.length << 8;
if (var1 < -1) {
var1 = -1;
public synchronized void setPlayhead(int playhead) {
final int maxPlayhead = this.sampleData.data.length << 8;
if (playhead < -1) {
playhead = -1;
}
if (var1 > var2) {
var1 = var2;
if (playhead > maxPlayhead) {
playhead = maxPlayhead;
}
this.playhead = var1;
this.playhead = playhead;
}
public synchronized void g150(int var1) {
@ -746,7 +744,7 @@ public final class AudioSamplePlayback_idk extends AudioSource_idk {
}
}
public synchronized boolean g801() {
public synchronized boolean isPlayheadOutOfBounds() {
return this.playhead < 0 || this.playhead >= this.sampleData.data.length << 8;
}
@ -1018,7 +1016,7 @@ public final class AudioSamplePlayback_idk extends AudioSource_idk {
}
public synchronized int f784() {
public synchronized int getPitchX() {
return this.pitchX < 0 ? -this.pitchX : this.pitchX;
}
@ -1125,12 +1123,12 @@ public final class AudioSamplePlayback_idk extends AudioSource_idk {
}
}
public synchronized int panClampedX() {
public synchronized int getPanX() {
return this.panX < 0 ? -1 : this.panX;
}
public synchronized void setVolume(final int volume) {
this.setVolAndPanX(volume, this.panClampedX());
this.setVolAndPanX(volume, this.getPanX());
}
public synchronized void f150() {

View File

@ -8,6 +8,8 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
// "play time" has units of tick-microseconds per quarter note, i.e. it has an extra factor of ticks per
// quarter note in it, which is constant for any given song
public final class MidiPlayer extends AudioSource_idk {
private static final double PHASE_512_TO_RADIANS = 0.01227184630308513D;
@ -36,26 +38,26 @@ public final class MidiPlayer extends AudioSource_idk {
public final int[] _u = new int[16];
private int volume = 256;
private final MidiPlayerNoteState_idk[][] noteOffStates_idk = new MidiPlayerNoteState_idk[16][128];
private int _M = 1000000;
private int microsecondsPerSecond = 1000000;
private final int[] chExpression = new int[16];
private int trackWithSoonestEvent;
private long _O;
private long lastBufferPlayTime;
private int nextEventTicks;
private long currentPlayTime;
private boolean _v;
private SongData _z;
private boolean looped;
private SongData songData;
public MidiPlayer() {
this.instruments = new HashMap<>();
this.a679();
this.handleMidiMetaEvent(true);
this.handleReset(true);
}
@SuppressWarnings("CopyConstructorMissesField")
public MidiPlayer(final MidiPlayer copyInstruments) {
this.instruments = copyInstruments.instruments;
this.a679();
this.handleMidiMetaEvent(true);
this.handleReset(true);
}
private static MidiInstrument loadInstrument(final ResourceLoader loader, final int instrumentId) {
@ -64,7 +66,7 @@ public final class MidiPlayer extends AudioSource_idk {
}
public synchronized void e150() {
this.b430(true);
this.reset(true);
}
private void handlePitchWheel(final int channel, final int value) {
@ -108,9 +110,9 @@ public final class MidiPlayer extends AudioSource_idk {
}
}
private void handleAllNotesOff(final int var1) {
private void handleAllNotesOff(final int channel) {
for (final MidiPlayerNoteState_idk state : this.noteSet.notes) {
if ((var1 < 0 || state.channel == var1) && state.notePlaying_idfk < 0) {
if ((channel < 0 || state.channel == channel) && state.notePlaying_idfk < 0) {
this.noteStates[state.channel][state.note] = null;
state.notePlaying_idfk = 0;
}
@ -130,7 +132,7 @@ public final class MidiPlayer extends AudioSource_idk {
}
public synchronized void c430() {
this._M = 1000000;
this.microsecondsPerSecond = 1000000;
}
public synchronized void a679() {
@ -170,21 +172,21 @@ public final class MidiPlayer extends AudioSource_idk {
@Override
public synchronized void processAndWrite(final int[] dest, int offset, int len) {
if (this.midiReader.isLoaded()) {
final int var4 = this.midiReader.ticksPerQuarterNote * this._M / SampledAudioChannel.SAMPLES_PER_SECOND;
final int var4 = this.midiReader.ticksPerQuarterNote * this.microsecondsPerSecond / SampledAudioChannel.SAMPLES_PER_SECOND;
do {
final long var5 = this._O + (long) len * (long) var4;
final long var5 = this.lastBufferPlayTime + (long) len * (long) var4;
if (this.currentPlayTime - var5 >= 0L) {
this._O = var5;
this.lastBufferPlayTime = var5;
break;
}
final int var7 = (int) ((-this._O + (this.currentPlayTime - (-((long) var4) + 1L))) / (long) var4);
this._O += (long) var7 * (long) var4;
final int var7 = (int) ((-this.lastBufferPlayTime + (this.currentPlayTime - (-((long) var4) + 1L))) / (long) var4);
this.lastBufferPlayTime += (long) var7 * (long) var4;
this.noteSet.processAndWrite(dest, offset, var7);
offset += var7;
len -= var7;
this.a423();
this.pumpEvents();
} while (this.midiReader.isLoaded());
}
@ -194,20 +196,20 @@ public final class MidiPlayer extends AudioSource_idk {
@Override
public synchronized void processAndDiscard(int len) {
if (this.midiReader.isLoaded()) {
final int var2 = this.midiReader.ticksPerQuarterNote * this._M / SampledAudioChannel.SAMPLES_PER_SECOND;
final int samplesToPlayTime = this.midiReader.ticksPerQuarterNote * this.microsecondsPerSecond / SampledAudioChannel.SAMPLES_PER_SECOND;
do {
final long var3 = (long) len * (long) var2 + this._O;
if (this.currentPlayTime - var3 >= 0L) {
this._O = var3;
final long bufferPlayTime = (long) len * (long) samplesToPlayTime + this.lastBufferPlayTime;
if (this.currentPlayTime - bufferPlayTime >= 0L) {
this.lastBufferPlayTime = bufferPlayTime;
break;
}
final int var5 = (int) ((-1L - this._O + this.currentPlayTime + (long) var2) / (long) var2);
this._O += (long) var5 * (long) var2;
final int var5 = (int) ((-1L - this.lastBufferPlayTime + this.currentPlayTime + (long) samplesToPlayTime) / (long) samplesToPlayTime);
this.lastBufferPlayTime += (long) var5 * (long) samplesToPlayTime;
this.noteSet.processAndDiscard(var5);
len -= var5;
this.a423();
this.pumpEvents();
} while (this.midiReader.isLoaded());
}
@ -219,10 +221,10 @@ public final class MidiPlayer extends AudioSource_idk {
this.volume = volume;
}
private synchronized void b430(final boolean var2) {
private synchronized void reset(final boolean doSoundOff) {
this.midiReader.unload();
this._z = null;
this.handleMidiMetaEvent(var2);
this.songData = null;
this.handleReset(doSoundOff);
}
private void handleAllSoundOff(final int channel) {
@ -256,8 +258,8 @@ public final class MidiPlayer extends AudioSource_idk {
}
}
public synchronized void a077(final SongData var1, final boolean var3) {
this.a918(var3, var1, true);
public synchronized void a077(final SongData songData, final boolean looped) {
this.changeSong(looped, songData, true);
}
private void handleResetAllControllers(int channel) {
@ -283,8 +285,8 @@ public final class MidiPlayer extends AudioSource_idk {
}
}
private void handleMidiMetaEvent(final boolean var2) {
if (var2) {
private void handleReset(final boolean doSoundOff) {
if (doSoundOff) {
this.handleAllSoundOff(-1);
} else {
this.handleAllNotesOff(-1);
@ -480,7 +482,7 @@ public final class MidiPlayer extends AudioSource_idk {
}
default: {
if ((event & 255) == 255) {
this.handleMidiMetaEvent(true);
this.handleReset(true);
}
break;
}
@ -492,11 +494,11 @@ public final class MidiPlayer extends AudioSource_idk {
return 0;
}
private synchronized void a918(final boolean var1, final SongData songData, final boolean var4) {
this.b430(var4);
private synchronized void changeSong(final boolean looped, final SongData songData, final boolean doSoundOff) {
this.reset(doSoundOff);
this.midiReader.load(songData.midiData);
this._v = var1;
this._O = 0L;
this.looped = looped;
this.lastBufferPlayTime = 0L;
final int numTracks = this.midiReader.numTracks();
for (int track = 0; track < numTracks; ++track) {
@ -589,7 +591,7 @@ public final class MidiPlayer extends AudioSource_idk {
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean a543(final int var1, final int[] var2, final MidiPlayerNoteState_idk var4, final int var5) {
var4._p = SampledAudioChannel.SAMPLES_PER_SECOND / 100;
if (var4.notePlaying_idfk < 0 || var4.playback != null && !var4.playback.g801()) {
if (var4.notePlaying_idfk < 0 || var4.playback != null && !var4.playback.isPlayheadOutOfBounds()) {
int var6 = var4._pitch_fac_2;
if (var6 > 0) {
var6 -= (int) (Math.pow(2.0D, (double) this.chPortaTime[var4.channel] * 4.921259842519685E-4D) * 16.0D + 0.5D);
@ -703,14 +705,14 @@ public final class MidiPlayer extends AudioSource_idk {
: 32 + note.pan_idk * midiPan >> 6;
}
private void a423() {
private void pumpEvents() {
int track = this.trackWithSoonestEvent;
int ticks = this.nextEventTicks;
long var4 = this.currentPlayTime;
long playTime = this.currentPlayTime;
if (this._z != null && ticks == 0) {
this.a918(this._v, this._z, false);
this.a423();
if (this.songData != null && ticks == 0) {
this.changeSong(this.looped, this.songData, false);
this.pumpEvents();
} else {
while (ticks == this.nextEventTicks) {
while (this.midiReader.trackNextTick[track] == ticks) {
@ -721,19 +723,19 @@ public final class MidiPlayer extends AudioSource_idk {
this.midiReader.resetCursor();
this.midiReader.setTrackPlaybackPosToCursor(track);
if (this.midiReader.allTracksStopped()) {
if (this._z != null) {
this.a077(this._z, this._v);
this.a423();
if (this.songData != null) {
this.a077(this.songData, this.looped);
this.pumpEvents();
return;
}
if (!this._v || ticks == 0) {
this.handleMidiMetaEvent(true);
if (!this.looped || ticks == 0) {
this.handleReset(true);
this.midiReader.unload();
return;
}
this.midiReader.resetPlayback(var4);
this.midiReader.resetPlayback(playTime);
}
break;
}
@ -748,13 +750,13 @@ public final class MidiPlayer extends AudioSource_idk {
track = this.midiReader.trackWithSoonestNextTick();
ticks = this.midiReader.trackNextTick[track];
var4 = this.midiReader.getPlayTime(ticks);
playTime = this.midiReader.getPlayTime(ticks);
}
this.trackWithSoonestEvent = track;
this.nextEventTicks = ticks;
this.currentPlayTime = var4;
if (this._z != null && ticks > 0) {
this.currentPlayTime = playTime;
if (this.songData != null && ticks > 0) {
this.trackWithSoonestEvent = -1;
this.nextEventTicks = 0;
this.currentPlayTime = this.midiReader.getPlayTime(this.nextEventTicks);
@ -765,21 +767,21 @@ public final class MidiPlayer extends AudioSource_idk {
public void a559(final MidiPlayerNoteState_idk note, final boolean var3) {
int var4 = note.sampleData.data.length;
int var5;
if (var3 && note.sampleData._i) {
final int var6 = -note.sampleData._l + var4 + var4;
var5 = (int) ((long) this.chGeneral1[note.channel] * (long) var6 >> 6);
var4 <<= 8;
if (var5 >= var4) {
int sampleLength = note.sampleData.data.length;
int playhead;
if (var3 && note.sampleData.isLooped_idk) {
final int var6 = -note.sampleData.loopStart_idfk + sampleLength + sampleLength;
playhead = (int) ((long) this.chGeneral1[note.channel] * (long) var6 >> 6);
sampleLength <<= 8;
if (playhead >= sampleLength) {
note.playback.setPitchXNegAbs_idk();
var5 = -var5 + var4 + var4 - 1;
playhead = -playhead + sampleLength + sampleLength - 1;
}
} else {
var5 = (int) ((long) this.chGeneral1[note.channel] * (long) var4 >> 6);
playhead = (int) ((long) this.chGeneral1[note.channel] * (long) sampleLength >> 6);
}
note.playback.h150(var5);
note.playback.setPlayhead(playhead);
}
private int calcVolumeX_idk(final MidiPlayerNoteState_idk note) {

View File

@ -73,75 +73,75 @@ public final class MidiPlayerNoteSet_idk extends AudioSource_idk {
}
private void a222(final MidiPlayerNoteState_idk var2, int var3) {
if ((4 & this.midiPlayer.chFlags[var2.channel]) != 0 && var2.notePlaying_idfk < 0) {
final int var4 = this.midiPlayer._u[var2.channel] / SampledAudioChannel.SAMPLES_PER_SECOND;
final int var5 = (1048575 + var4 - var2._j) / var4;
var2._j = 1048575 & var2._j + var3 * var4;
if (var5 <= var3) {
if (this.midiPlayer.chGeneral1[var2.channel] == 0) {
var2.playback = AudioSamplePlayback_idk.start(var2.sampleData, var2.playback.f784(), var2.playback.getVolume(), var2.playback.panClampedX());
private void a222(final MidiPlayerNoteState_idk note, int totalLen) {
if ((MidiPlayer.FLAG_GENERAL_6 & this.midiPlayer.chFlags[note.channel]) != 0 && note.notePlaying_idfk < 0) {
final int var4 = this.midiPlayer._u[note.channel] / SampledAudioChannel.SAMPLES_PER_SECOND;
final int var5 = (1048575 + var4 - note._j) / var4;
note._j = 1048575 & note._j + totalLen * var4;
if (var5 <= totalLen) {
if (this.midiPlayer.chGeneral1[note.channel] == 0) {
note.playback = AudioSamplePlayback_idk.start(note.sampleData, note.playback.getPitchX(), note.playback.getVolX(), note.playback.getPanX());
} else {
var2.playback = AudioSamplePlayback_idk.start(var2.sampleData, var2.playback.f784(), 0, var2.playback.panClampedX());
this.midiPlayer.a559(var2, var2.instrument.noteTuning_idk[var2.note] < 0);
note.playback = AudioSamplePlayback_idk.start(note.sampleData, note.playback.getPitchX(), 0, note.playback.getPanX());
this.midiPlayer.a559(note, note.instrument.noteTuning_idk[note.note] < 0);
}
if (var2.instrument.noteTuning_idk[var2.note] < 0) {
assert var2.playback != null;
var2.playback.f150();
if (note.instrument.noteTuning_idk[note.note] < 0) {
assert note.playback != null;
note.playback.f150();
}
var3 = var2._j / var4;
totalLen = note._j / var4;
}
}
assert var2.playback != null;
var2.playback.processAndDiscard(var3);
assert note.playback != null;
note.playback.processAndDiscard(totalLen);
}
private void a829(final int[] var1, int var2, final MidiPlayerNoteState_idk var3, int var4, final int var6) {
if ((4 & this.midiPlayer.chFlags[var3.channel]) != 0 && var3.notePlaying_idfk < 0) {
final int var7 = this.midiPlayer._u[var3.channel] / SampledAudioChannel.SAMPLES_PER_SECOND;
private void a829(final int[] dest, int offset, final MidiPlayerNoteState_idk note, int totalLen, final int var6) {
if ((MidiPlayer.FLAG_GENERAL_6 & this.midiPlayer.chFlags[note.channel]) != 0 && note.notePlaying_idfk < 0) {
final int var7 = this.midiPlayer._u[note.channel] / SampledAudioChannel.SAMPLES_PER_SECOND;
while (true) {
final int var8 = (-var3._j + 1048575 + var7) / var7;
if (var8 > var4) {
var3._j += var7 * var4;
final int len = (-note._j + 0xfffff + var7) / var7;
if (len > totalLen) {
note._j += var7 * totalLen;
break;
}
var3.playback.processAndWrite(var1, var2, var8);
var3._j += var8 * var7 - 1048576;
var2 += var8;
var4 -= var8;
note.playback.processAndWrite(dest, offset, len);
note._j += len * var7 - 0x100000;
offset += len;
totalLen -= len;
int var9 = SampledAudioChannel.SAMPLES_PER_SECOND / 100;
final int var10 = 262144 / var7;
final int var10 = 0x40000 / var7;
if (var10 < var9) {
var9 = var10;
}
final AudioSamplePlayback_idk var11 = var3.playback;
if (this.midiPlayer.chGeneral1[var3.channel] == 0) {
var3.playback = AudioSamplePlayback_idk.start(var3.sampleData, var11.f784(), var11.getVolume(), var11.panClampedX());
final AudioSamplePlayback_idk playback = note.playback;
if (this.midiPlayer.chGeneral1[note.channel] == 0) {
note.playback = AudioSamplePlayback_idk.start(note.sampleData, playback.getPitchX(), playback.getVolX(), playback.getPanX());
} else {
var3.playback = AudioSamplePlayback_idk.start(var3.sampleData, var11.f784(), 0, var11.panClampedX());
this.midiPlayer.a559(var3, var3.instrument.noteTuning_idk[var3.note] < 0);
var3.playback.a093(var9, var11.getVolume());
note.playback = AudioSamplePlayback_idk.start(note.sampleData, playback.getPitchX(), 0, playback.getPanX());
this.midiPlayer.a559(note, note.instrument.noteTuning_idk[note.note] < 0);
note.playback.a093(var9, playback.getVolX());
}
if (var3.instrument.noteTuning_idk[var3.note] < 0) {
assert var3.playback != null;
var3.playback.f150();
if (note.instrument.noteTuning_idk[note.note] < 0) {
assert note.playback != null;
note.playback.f150();
}
var11.g150(var9);
var11.processAndWrite(var1, var2, var6 - var2);
if (var11.volDeltaNonZero()) {
this.sum.addFirst(var11);
playback.g150(var9);
playback.processAndWrite(dest, offset, var6 - offset);
if (playback.volDeltaNonZero()) {
this.sum.addFirst(playback);
}
}
}
var3.playback.processAndWrite(var1, var2, var4);
note.playback.processAndWrite(dest, offset, totalLen);
}
}

View File

@ -8,7 +8,7 @@ public final class PlayingSound {
public PlayingSound(final AudioSamplePlayback_idk var1) {
this._p = var1;
this.volume = var1.getVolume();
this.volume = var1.getVolX();
this._p.setVolume((128 + (this.volume * Sounds.soundVolume)) >> 8);
}

View File

@ -7,7 +7,7 @@ import funorb.util.BitMath;
import java.io.IOException;
import java.util.stream.IntStream;
public final class fd_ {
public final class SomeBufferReader_idk {
public static vb_[] _L;
private static float[] _k;
private static to_[] _o;
@ -17,59 +17,58 @@ public final class fd_ {
private static float[] _u;
private static float[] _C;
private static boolean _x = false;
private static byte[] _w;
private static byte[] buffer;
private static float[] _z;
private static boolean[] _t;
private static float[] _y;
private static float[] _j;
private static int _r;
private static float[] _l;
private static int _K;
private static int curBit;
private static int[] _F;
private static int _E;
private static kn_[] _h;
private static int _p;
private int _q;
private int _G;
private boolean _I;
private int _H;
private static int curByte;
private int sampleLength;
private int loopEnd;
private boolean isLooped;
private int loopStart;
private int _i;
private int _s;
private boolean _A;
private byte[][] _v;
private byte[][] sections;
private int _M;
private int _B;
private byte[] _N;
private int sampleRate;
private byte[] sampleData;
private float[] _n;
private int _m;
private int sectionIndex;
private fd_(final byte[] var1) throws IOException {
this.a604(var1);
private SomeBufferReader_idk(final byte[] data) throws IOException {
this.load(data);
}
public static float d134(final int var0) {
int var1 = var0 & 2097151;
final int var2 = var0 & Integer.MIN_VALUE;
final int var3 = (var0 & 2145386496) >> 21;
if (var2 != 0) {
var1 = -var1;
public static float parseAsFloat(final int value) {
int significand = value & 0x1fffff;
final int sign = value & Integer.MIN_VALUE;
final int exponent = (value & 0x7fe00000) >> 21;
if (sign != 0) {
significand = -significand;
}
return (float) ((double) var1 * Math.pow(2.0D, var3 - 788));
return (float) ((double) significand * Math.pow(2.0D, exponent - 788));
}
public static int c784() {
final int var0 = _w[_p] >> _K & 1;
++_K;
_p += _K >> 3;
_K &= 7;
return var0;
public static int readBit() {
final int bit = buffer[curByte] >> curBit & 1;
++curBit;
curByte += curBit >> 3;
curBit &= 7;
return bit;
}
public static void b604(final byte[] var0) {
a167(var0);
_E = 1 << a137(4);
_r = 1 << a137(4);
public static void b604(final byte[] section) {
setBuffer(section);
_E = 1 << readBits(4);
_r = 1 << readBits(4);
_k = new float[_r];
int var1;
@ -104,7 +103,7 @@ public final class fd_ {
}
final int var10 = BitMath.lastSet(var5 - 1);
final int[] var15 = IntStream.range(0, var5).map(var11 -> a586js(var11, var10)).toArray();
final int[] var15 = IntStream.range(0, var5).map(var11 -> reverseBits(var11, var10)).toArray();
if (var1 == 0) {
_l = var6;
@ -119,65 +118,65 @@ public final class fd_ {
}
}
var1 = a137(8) + 1;
var1 = readBits(8) + 1;
_L = new vb_[var1];
for (var2 = 0; var2 < var1; ++var2) {
_L[var2] = new vb_();
}
var2 = a137(6) + 1;
var2 = readBits(6) + 1;
for (var3 = 0; var3 < var2; ++var3) {
a137(16);
readBits(16);
}
var2 = a137(6) + 1;
var2 = readBits(6) + 1;
_h = new kn_[var2];
for (var3 = 0; var3 < var2; ++var3) {
_h[var3] = new kn_();
}
var3 = a137(6) + 1;
var3 = readBits(6) + 1;
_o = new to_[var3];
for (var4 = 0; var4 < var3; ++var4) {
_o[var4] = new to_();
}
var4 = a137(6) + 1;
var4 = readBits(6) + 1;
_O = new fq_[var4];
for (var5 = 0; var5 < var4; ++var5) {
_O[var5] = new fq_();
}
var5 = a137(6) + 1;
var5 = readBits(6) + 1;
_t = new boolean[var5];
_J = new int[var5];
for (int var12 = 0; var12 < var5; ++var12) {
_t[var12] = c784() != 0;
a137(16);
a137(16);
_J[var12] = a137(8);
_t[var12] = readBit() != 0;
readBits(16);
readBits(16);
_J[var12] = readBits(8);
}
_x = true;
}
@SuppressWarnings("SameParameterValue")
public static fd_ a968(final ResourceLoader loader, final String group, final String item) {
public static SomeBufferReader_idk a968(final ResourceLoader loader, final String group, final String item) {
if (a521(loader)) {
final byte[] var3 = loader.getResource(group, item);
if (var3 == null) {
return null;
} else {
fd_ var4 = null;
SomeBufferReader_idk var4 = null;
try {
var4 = new fd_(var3);
var4 = new SomeBufferReader_idk(var3);
} catch (final IOException var6) {
var6.printStackTrace();
}
@ -190,58 +189,58 @@ public final class fd_ {
}
}
private static boolean a521(final ResourceLoader var0) {
private static boolean a521(final ResourceLoader loader) {
if (!_x) {
final byte[] var1 = var0.getResource(0, 0);
if (var1 == null) {
final byte[] data = loader.getResource(0, 0);
if (data == null) {
return false;
}
b604(var1);
b604(data);
}
return true;
}
private static void a167(final byte[] var0) {
_w = var0;
_p = 0;
_K = 0;
private static void setBuffer(final byte[] section) {
buffer = section;
curByte = 0;
curBit = 0;
}
public static int a137(int var0) {
int var1 = 0;
public static int readBits(int numBits) {
int result = 0;
int var2;
int var3;
for (var2 = 0; var0 >= 8 - _K; var0 -= var3) {
var3 = 8 - _K;
final int var4 = (1 << var3) - 1;
var1 += (_w[_p] >> _K & var4) << var2;
_K = 0;
++_p;
var2 += var3;
int bitsUsed;
int bitsLeft;
for (bitsUsed = 0; 8 - curBit <= numBits; numBits -= bitsLeft) {
bitsLeft = 8 - curBit;
final int mask = (1 << bitsLeft) - 1;
result += (buffer[curByte] >> curBit & mask) << bitsUsed;
curBit = 0;
++curByte;
bitsUsed += bitsLeft;
}
if (var0 > 0) {
var3 = (1 << var0) - 1;
var1 += (_w[_p] >> _K & var3) << var2;
_K += var0;
if (numBits > 0) {
bitsLeft = (1 << numBits) - 1;
result += (buffer[curByte] >> curBit & bitsLeft) << bitsUsed;
curBit += numBits;
}
return var1;
return result;
}
public static fd_ a740(final ResourceLoader var0, final int var1, final int var2) {
if (a521(var0)) {
final byte[] var3 = var0.getResource(var1, var2);
public static SomeBufferReader_idk a740(final ResourceLoader loader, final int groupId, final int itemId) {
if (a521(loader)) {
final byte[] var3 = loader.getResource(groupId, itemId);
if (var3 == null) {
return null;
} else {
fd_ var4 = null;
SomeBufferReader_idk var4 = null;
try {
var4 = new fd_(var3);
var4 = new SomeBufferReader_idk(var3);
} catch (final IOException var6) {
var6.printStackTrace();
}
@ -249,38 +248,37 @@ public final class fd_ {
return var4;
}
} else {
var0.loadGroupDataForItem(var1, var2);
loader.loadGroupDataForItem(groupId, itemId);
return null;
}
}
private static int a586js(int var0, int var1) {
int var2;
for (var2 = 0; var1 > 0; var0 >>>= 1) {
var2 = var2 << 1 | 1 & var0;
--var1;
private static int reverseBits(int value, int count) {
int i = 0;
for (; count > 0; --count) {
i = (i << 1) | (1 & value);
value >>>= 1;
}
return var2;
return i;
}
public AudioSampleData_idk a582() {
if (this._N == null) {
if (this.sampleData == null) {
this._M = 0;
this._n = new float[_r];
this._N = new byte[this._q];
this.sampleData = new byte[this.sampleLength];
this._s = 0;
this._m = 0;
this.sectionIndex = 0;
}
for (; this._m < this._v.length; ++this._m) {
for (; this.sectionIndex < this.sections.length; ++this.sectionIndex) {
final float[] var2 = this.e875(this._m);
final float[] var2 = this.e875(this.sectionIndex);
if (var2 != null) {
int var3 = this._s;
int var4 = var2.length;
if (var4 > this._q - var3) {
var4 = this._q - var3;
if (var4 > this.sampleLength - var3) {
var4 = this.sampleLength - var3;
}
for (int var5 = 0; var5 < var4; ++var5) {
@ -289,7 +287,7 @@ public final class fd_ {
var6 = ~var6 >> 31;
}
this._N[var3++] = (byte) (var6 - 128);
this.sampleData[var3++] = (byte) (var6 - 128);
}
this._s = var3;
@ -297,22 +295,22 @@ public final class fd_ {
}
this._n = null;
final byte[] var7 = this._N;
this._N = null;
return new AudioSampleData_idk(this._B, var7, this._H, this._G, this._I);
final byte[] sampleData = this.sampleData;
this.sampleData = null;
return new AudioSampleData_idk(this.sampleRate, sampleData, this.loopStart, this.loopEnd, this.isLooped);
}
private float[] e875(final int var1) {
a167(this._v[var1]);
c784();
final int var2 = a137(BitMath.lastSet(_J.length - 1));
private float[] e875(final int sectionIndex) {
setBuffer(this.sections[sectionIndex]);
readBit();
final int var2 = readBits(BitMath.lastSet(_J.length - 1));
final boolean var3 = _t[var2];
final int var4 = var3 ? _r : _E;
boolean var5 = false;
boolean var6 = false;
if (var3) {
var5 = c784() != 0;
var6 = c784() != 0;
var5 = readBit() != 0;
var6 = readBit() != 0;
}
final int var7 = var4 >> 1;
@ -554,35 +552,35 @@ public final class fd_ {
return var43;
}
private void a604(final byte[] var1) throws IOException {
final Buffer var2 = new Buffer(var1);
this._B = var2.readInt();
this._q = var2.readInt();
this._H = var2.readInt();
this._G = var2.readInt();
if (this._G < 0) {
this._G = ~this._G;
this._I = true;
private void load(final byte[] data) throws IOException {
final Buffer buf = new Buffer(data);
this.sampleRate = buf.readInt();
this.sampleLength = buf.readInt();
this.loopStart = buf.readInt();
this.loopEnd = buf.readInt();
if (this.loopEnd < 0) {
this.loopEnd = ~this.loopEnd;
this.isLooped = true;
}
final int var3 = var2.readInt();
if (var3 < 0) {
final int count = buf.readInt();
if (count < 0) {
throw new IOException();
} else {
this._v = new byte[var3][];
this.sections = new byte[count][];
for (int var4 = 0; var4 < var3; ++var4) {
int var5 = 0;
for (int i = 0; i < count; ++i) {
int total = 0;
int var6;
int x;
do {
var6 = var2.readUByte();
var5 += var6;
} while (var6 >= 255);
x = buf.readUByte();
total += x;
} while (x >= 255);
final byte[] var7 = new byte[var5];
var2.readBytes(var7, var5);
this._v[var4] = var7;
final byte[] section = new byte[total];
buf.readBytes(section, total);
this.sections[i] = section;
}
}
@ -591,8 +589,8 @@ public final class fd_ {
public void b720() {
this._M = 0;
this._n = new float[_r];
for (int var3 = 0; var3 < this._v.length; ++var3) {
this.e875(var3);
for (int i = 0; i < this.sections.length; ++i) {
this.e875(i);
}
}
}

View File

@ -7,7 +7,7 @@ import java.util.Map;
public final class SoundLoader {
public static SoundLoader globalLoader;
private final Map<Long, fd_> _a = new HashMap<>();
private final Map<Long, SomeBufferReader_idk> _a = new HashMap<>();
private final Map<Long, AudioSampleData_idk> _d = new HashMap<>();
private final ResourceLoader loader1;
private final ResourceLoader loader2;
@ -59,9 +59,9 @@ public final class SoundLoader {
final long var6 = 0x100000000L ^ (long) var5;
AudioSampleData_idk var8 = this._d.get(var6);
if (var8 == null) {
fd_ var9 = this._a.get(var6);
SomeBufferReader_idk var9 = this._a.get(var6);
if (var9 == null) {
var9 = fd_.a740(this.loader2, var3, var2);
var9 = SomeBufferReader_idk.a740(this.loader2, var3, var2);
if (var9 == null) {
return null;
}

View File

@ -7,24 +7,24 @@ public final class fq_ {
public int _d;
public fq_() {
fd_.a137(16);
this._c = fd_.c784() != 0 ? fd_.a137(4) + 1 : 1;
if (fd_.c784() != 0) {
fd_.a137(8);
SomeBufferReader_idk.readBits(16);
this._c = SomeBufferReader_idk.readBit() != 0 ? SomeBufferReader_idk.readBits(4) + 1 : 1;
if (SomeBufferReader_idk.readBit() != 0) {
SomeBufferReader_idk.readBits(8);
}
fd_.a137(2);
SomeBufferReader_idk.readBits(2);
if (this._c > 1) {
this._d = fd_.a137(4);
this._d = SomeBufferReader_idk.readBits(4);
}
this._b = new int[this._c];
this._a = new int[this._c];
for (int var1 = 0; var1 < this._c; ++var1) {
fd_.a137(8);
this._b[var1] = fd_.a137(8);
this._a[var1] = fd_.a137(8);
SomeBufferReader_idk.readBits(8);
this._b[var1] = SomeBufferReader_idk.readBits(8);
this._a[var1] = SomeBufferReader_idk.readBits(8);
}
}

View File

@ -207,7 +207,7 @@ public final class h_ extends AudioSource_idk {
} else if (this.song1 == null) {
var7 = false;
} else {
var7 = this.crossfade < 524288;
var7 = this.crossfade < 0x80000;
}
if (var7) {

View File

@ -88,16 +88,16 @@ public final class kn_ {
private final int[] _e;
public kn_() {
final int var1 = fd_.a137(16);
final int var1 = SomeBufferReader_idk.readBits(16);
if (var1 == 1) {
final int var2 = fd_.a137(5);
final int var2 = SomeBufferReader_idk.readBits(5);
int var3 = 0;
this._l = new int[var2];
int var4;
int var5;
for (var4 = 0; var4 < var2; ++var4) {
var5 = fd_.a137(4);
var5 = SomeBufferReader_idk.readBits(4);
this._l[var4] = var5;
if (var5 >= var3) {
var3 = var5 + 1;
@ -111,10 +111,10 @@ public final class kn_ {
int var7;
for (var4 = 0; var4 < var3; ++var4) {
this._e[var4] = fd_.a137(3) + 1;
var5 = this._c[var4] = fd_.a137(2);
this._e[var4] = SomeBufferReader_idk.readBits(3) + 1;
var5 = this._c[var4] = SomeBufferReader_idk.readBits(2);
if (var5 != 0) {
this._h[var4] = fd_.a137(8);
this._h[var4] = SomeBufferReader_idk.readBits(8);
}
var5 = 1 << var5;
@ -122,12 +122,12 @@ public final class kn_ {
this._k[var4] = var6;
for (var7 = 0; var7 < var5; ++var7) {
var6[var7] = fd_.a137(8) - 1;
var6[var7] = SomeBufferReader_idk.readBits(8) - 1;
}
}
this._b = fd_.a137(2) + 1;
var4 = fd_.a137(4);
this._b = SomeBufferReader_idk.readBits(2) + 1;
var4 = SomeBufferReader_idk.readBits(4);
var5 = 2;
int var9;
@ -144,7 +144,7 @@ public final class kn_ {
var7 = this._l[var9];
for (int var8 = 0; var8 < this._e[var7]; ++var8) {
this._f[var5++] = fd_.a137(var4);
this._f[var5++] = SomeBufferReader_idk.readBits(var4);
}
}
@ -192,7 +192,7 @@ public final class kn_ {
}
public boolean b801() {
final boolean var1 = fd_.c784() != 0;
final boolean var1 = SomeBufferReader_idk.readBit() != 0;
if (var1) {
final int var2 = this._f.length;
@ -203,8 +203,8 @@ public final class kn_ {
var3 = _a[this._b - 1];
final int var4 = BitMath.lastSet(var3 - 1);
_i[0] = fd_.a137(var4);
_i[1] = fd_.a137(var4);
_i[0] = SomeBufferReader_idk.readBits(var4);
_i[1] = SomeBufferReader_idk.readBits(var4);
int var5 = 2;
for (final int var7 : this._l) {
@ -213,13 +213,13 @@ public final class kn_ {
final int var10 = (1 << var9) - 1;
int var11 = 0;
if (var9 > 0) {
var11 = fd_._L[this._h[var7]].a784();
var11 = SomeBufferReader_idk._L[this._h[var7]].a784();
}
for (int var12 = 0; var12 < var8; ++var12) {
final int var13 = this._k[var7][var11 & var10];
var11 >>>= var9;
_i[var5++] = var13 >= 0 ? fd_._L[var13].a784() : 0;
_i[var5++] = var13 >= 0 ? SomeBufferReader_idk._L[var13].a784() : 0;
}
}

View File

@ -2,23 +2,30 @@ package funorb.audio;
public final class to_ {
private final int[] _e;
private final int _c = fd_.a137(16);
private final int _g = fd_.a137(24);
private final int _d = fd_.a137(24);
private final int _b = fd_.a137(24) + 1;
private final int _a = fd_.a137(6) + 1;
private final int _f = fd_.a137(8);
private final int _c;
private final int _g;
private final int _d;
private final int _b;
private final int _a;
private final int _f;
public to_() {
this._c = SomeBufferReader_idk.readBits(16);
this._g = SomeBufferReader_idk.readBits(24);
this._d = SomeBufferReader_idk.readBits(24);
this._b = SomeBufferReader_idk.readBits(24) + 1;
this._a = SomeBufferReader_idk.readBits(6) + 1;
this._f = SomeBufferReader_idk.readBits(8);
final int[] var1 = new int[this._a];
int var2;
for (var2 = 0; var2 < this._a; ++var2) {
int var3 = 0;
final int var4 = fd_.a137(3);
final boolean var5 = fd_.c784() != 0;
final int var4 = SomeBufferReader_idk.readBits(3);
final boolean var5 = SomeBufferReader_idk.readBit() != 0;
if (var5) {
var3 = fd_.a137(5);
var3 = SomeBufferReader_idk.readBits(5);
}
var1[var2] = var3 << 3 | var4;
@ -27,7 +34,7 @@ public final class to_ {
this._e = new int[this._a * 8];
for (var2 = 0; var2 < this._a * 8; ++var2) {
this._e[var2] = (var1[var2 >> 3] & 1 << (var2 & 7)) != 0 ? fd_.a137(8) : -1;
this._e[var2] = (var1[var2 >> 3] & 1 << (var2 & 7)) != 0 ? SomeBufferReader_idk.readBits(8) : -1;
}
}
@ -39,7 +46,7 @@ public final class to_ {
}
if (!var3) {
var4 = fd_._L[this._f]._a;
var4 = SomeBufferReader_idk._L[this._f]._a;
final int var5 = this._d - this._g;
final int var6 = var5 / this._b;
final int[] var7 = new int[var6];
@ -51,7 +58,7 @@ public final class to_ {
int var10;
int var11;
if (var8 == 0) {
var10 = fd_._L[this._f].a784();
var10 = SomeBufferReader_idk._L[this._f].a784();
for (var11 = var4 - 1; var11 >= 0; --var11) {
if (var9 + var11 < var6) {
@ -67,7 +74,7 @@ public final class to_ {
final int var12 = this._e[var11 * 8 + var8];
if (var12 >= 0) {
final int var13 = this._g + var9 * this._b;
final vb_ var14 = fd_._L[var12];
final vb_ var14 = SomeBufferReader_idk._L[var12];
int var15;
if (this._c == 0) {
var15 = this._b / var14._a;

View File

@ -10,43 +10,43 @@ public final class vb_ {
private int[] _f;
public vb_() {
fd_.a137(24);
this._a = fd_.a137(16);
this._c = fd_.a137(24);
SomeBufferReader_idk.readBits(24);
this._a = SomeBufferReader_idk.readBits(16);
this._c = SomeBufferReader_idk.readBits(24);
this._b = new int[this._c];
final boolean var1 = fd_.c784() != 0;
final boolean var1 = SomeBufferReader_idk.readBit() != 0;
int var2;
int var3;
int var5;
if (var1) {
var2 = 0;
for (var3 = fd_.a137(5) + 1; var2 < this._c; ++var3) {
final int var4 = fd_.a137(BitMath.lastSet(this._c - var2));
for (var3 = SomeBufferReader_idk.readBits(5) + 1; var2 < this._c; ++var3) {
final int var4 = SomeBufferReader_idk.readBits(BitMath.lastSet(this._c - var2));
for (var5 = 0; var5 < var4; ++var5) {
this._b[var2++] = var3;
}
}
} else {
final boolean var14 = fd_.c784() != 0;
final boolean var14 = SomeBufferReader_idk.readBit() != 0;
for (var3 = 0; var3 < this._c; ++var3) {
if (var14 && fd_.c784() == 0) {
if (var14 && SomeBufferReader_idk.readBit() == 0) {
this._b[var3] = 0;
} else {
this._b[var3] = fd_.a137(5) + 1;
this._b[var3] = SomeBufferReader_idk.readBits(5) + 1;
}
}
}
this.b797();
var2 = fd_.a137(4);
var2 = SomeBufferReader_idk.readBits(4);
if (var2 > 0) {
final float var15 = fd_.d134(fd_.a137(32));
final float var16 = fd_.d134(fd_.a137(32));
var5 = fd_.a137(4) + 1;
final boolean var6 = fd_.c784() != 0;
final float var15 = SomeBufferReader_idk.parseAsFloat(SomeBufferReader_idk.readBits(32));
final float var16 = SomeBufferReader_idk.parseAsFloat(SomeBufferReader_idk.readBits(32));
var5 = SomeBufferReader_idk.readBits(4) + 1;
final boolean var6 = SomeBufferReader_idk.readBit() != 0;
final int var7;
if (var2 == 1) {
var7 = a080(this._c, this._a);
@ -58,7 +58,7 @@ public final class vb_ {
int var8;
for (var8 = 0; var8 < var7; ++var8) {
_e[var8] = fd_.a137(var5);
_e[var8] = SomeBufferReader_idk.readBits(var5);
}
this._d = new float[this._c][this._a];
@ -133,7 +133,7 @@ public final class vb_ {
public int a784() {
int var1 = 0;
while (this._f[var1] >= 0) {
var1 = fd_.c784() != 0 ? this._f[var1] : var1 + 1;
var1 = SomeBufferReader_idk.readBit() != 0 ? this._f[var1] : var1 + 1;
}
return ~this._f[var1];
}

View File

@ -1,6 +1,6 @@
package funorb.client.intro;
import funorb.audio.fd_;
import funorb.audio.SomeBufferReader_idk;
import funorb.cache.ResourceLoader;
import funorb.client.JagexBaseApplet;
import funorb.graphics.Drawing;
@ -57,8 +57,8 @@ public final class JagexLogoIntroAnimation {
}
private static void load1(final ResourceLoader loader) {
fd_.b604(loader.getResource("headers.packvorbis", ""));
final fd_ var2 = fd_.a968(loader, "jagex logo2.packvorbis", "");
SomeBufferReader_idk.b604(loader.getResource("headers.packvorbis", ""));
final SomeBufferReader_idk var2 = SomeBufferReader_idk.a968(loader, "jagex logo2.packvorbis", "");
assert var2 != null;
var2.b720();
}