From 13a7b96fab94555858d987103b7e0a0d082d8fc7 Mon Sep 17 00:00:00 2001 From: Alex Iadicicco Date: Mon, 5 Dec 2022 01:06:37 -0800 Subject: [PATCH] Identified FmtVorbis and FmtSynth --- .../funorb/audio/AudioSamplePlayback_idk.java | 8 +- .../java/funorb/audio/AudioSource_idk.java | 2 +- src/main/java/funorb/audio/FmtSynth.java | 73 ++++ ...meBufferReader_idk.java => FmtVorbis.java} | 20 +- .../java/funorb/audio/MidiInstrument.java | 4 +- src/main/java/funorb/audio/MidiPlayer.java | 2 +- .../funorb/audio/MidiPlayerNoteState_idk.java | 2 +- src/main/java/funorb/audio/Oscillator.java | 317 ++++++++++++++++++ ...orConfig_idk.java => OscillatorState.java} | 8 +- .../java/funorb/audio/Oscillator_idk.java | 312 ----------------- ...ioSampleData_idk.java => RawSampleS8.java} | 6 +- .../funorb/audio/SampledAudioChannel.java | 2 +- src/main/java/funorb/audio/SoundEffect.java | 4 +- src/main/java/funorb/audio/SoundLoader.java | 74 ++-- src/main/java/funorb/audio/dq_.java | 73 ---- src/main/java/funorb/audio/fh_.java | 2 +- src/main/java/funorb/audio/fq_.java | 18 +- src/main/java/funorb/audio/kn_.java | 30 +- src/main/java/funorb/audio/to_.java | 26 +- src/main/java/funorb/audio/vb_.java | 32 +- .../client/intro/JagexLogoIntroAnimation.java | 6 +- src/main/java/funorb/io/Buffer.java | 2 +- .../shatteredplans/client/JagexApplet.java | 2 +- .../funorb/shatteredplans/client/Sounds.java | 4 +- 24 files changed, 517 insertions(+), 512 deletions(-) create mode 100644 src/main/java/funorb/audio/FmtSynth.java rename src/main/java/funorb/audio/{SomeBufferReader_idk.java => FmtVorbis.java} (96%) create mode 100644 src/main/java/funorb/audio/Oscillator.java rename src/main/java/funorb/audio/{OscillatorConfig_idk.java => OscillatorState.java} (90%) delete mode 100644 src/main/java/funorb/audio/Oscillator_idk.java rename src/main/java/funorb/audio/{AudioSampleData_idk.java => RawSampleS8.java} (78%) delete mode 100644 src/main/java/funorb/audio/dq_.java diff --git a/src/main/java/funorb/audio/AudioSamplePlayback_idk.java b/src/main/java/funorb/audio/AudioSamplePlayback_idk.java index 11a1d31..4439da8 100644 --- a/src/main/java/funorb/audio/AudioSamplePlayback_idk.java +++ b/src/main/java/funorb/audio/AudioSamplePlayback_idk.java @@ -22,7 +22,7 @@ public final class AudioSamplePlayback_idk extends AudioSource_idk { private int volActualRateX; private int ampR; - private AudioSamplePlayback_idk(final AudioSampleData_idk var1, final int pitchX, final int volX, final int panX) { + private AudioSamplePlayback_idk(final RawSampleS8 var1, final int pitchX, final int volX, final int panX) { this.sampleData = var1; this.loopStart_idfk = var1.loopStart_idfk; this.loopEnd_idfk = var1.loopEnd_idfk; @@ -73,7 +73,7 @@ public final class AudioSamplePlayback_idk extends AudioSource_idk { return var5 >> 1; } - public static AudioSamplePlayback_idk start(final AudioSampleData_idk sampleData, final int pitchX, final int volX, final int panX) { + public static AudioSamplePlayback_idk start(final RawSampleS8 sampleData, final int pitchX, final int volX, final int panX) { return (sampleData.data == null || sampleData.data.length == 0) ? null : new AudioSamplePlayback_idk(sampleData, pitchX, volX, panX); @@ -299,7 +299,7 @@ public final class AudioSamplePlayback_idk extends AudioSource_idk { return var5 >> 1; } - public static AudioSamplePlayback_idk a638(final AudioSampleData_idk var0, final int volume) { + public static AudioSamplePlayback_idk a638(final RawSampleS8 var0, final int volume) { if (var0.data == null || var0.data.length == 0) { return null; } else { @@ -628,7 +628,7 @@ public final class AudioSamplePlayback_idk extends AudioSource_idk { } } - final AudioSampleData_idk sampleData = this.sampleData; + final RawSampleS8 sampleData = this.sampleData; final int loopStart_idfk = this.loopStart_idfk << 8; final int loopEnd_idfk = this.loopEnd_idfk << 8; final int sampleLength = sampleData.data.length << 8; diff --git a/src/main/java/funorb/audio/AudioSource_idk.java b/src/main/java/funorb/audio/AudioSource_idk.java index eb7d2aa..84e596a 100644 --- a/src/main/java/funorb/audio/AudioSource_idk.java +++ b/src/main/java/funorb/audio/AudioSource_idk.java @@ -6,7 +6,7 @@ public abstract class AudioSource_idk extends NodeList.Node implements Iterable< public volatile boolean enabled = true; public int _i; public AudioSource_idk _h; - public AudioSampleData_idk sampleData; + public RawSampleS8 sampleData; protected AudioSource_idk() {} diff --git a/src/main/java/funorb/audio/FmtSynth.java b/src/main/java/funorb/audio/FmtSynth.java new file mode 100644 index 0000000..5eea1fa --- /dev/null +++ b/src/main/java/funorb/audio/FmtSynth.java @@ -0,0 +1,73 @@ +package funorb.audio; + +import funorb.cache.ResourceLoader; +import funorb.io.Buffer; + +public final class FmtSynth { + private final Oscillator[] oscs = new Oscillator[10]; + private final int loopStartMs; + private final int loopEndMs; + + private FmtSynth(final Buffer data) { + for (int i = 0; i < 10; ++i) { + final int peekByte = data.readUByte(); + if (peekByte != 0) { + --data.pos; + this.oscs[i] = new Oscillator(); + this.oscs[i].initialize(data); + } + } + + this.loopStartMs = data.readUShort(); + this.loopEndMs = data.readUShort(); + } + + public static FmtSynth load(final ResourceLoader loader, final int groupId, final int itemId) { + final byte[] data = loader.getResource(groupId, itemId); + return data == null ? null : new FmtSynth(new Buffer(data)); + } + + private byte[] toSampleDataS8() { + int totalDurMs = 0; + + for (int i = 0; i < 10; ++i) { + if (this.oscs[i] != null && totalDurMs < this.oscs[i].durMs + this.oscs[i].delayMs) { + totalDurMs = this.oscs[i].durMs + this.oscs[i].delayMs; + } + } + + if (totalDurMs == 0) { + return new byte[0]; + } + final int len = SampledAudioChannel.SAMPLES_PER_SECOND * totalDurMs / 1000; + final byte[] dataS8 = new byte[len]; + + for (int i = 0; i < 10; ++i) { + if (this.oscs[i] != null) { + final int durSamples = this.oscs[i].durMs * SampledAudioChannel.SAMPLES_PER_SECOND / 1000; + final int delaySamples = this.oscs[i].delayMs * SampledAudioChannel.SAMPLES_PER_SECOND / 1000; + final int[] s16buf = this.oscs[i].generateS16(durSamples, this.oscs[i].durMs); + + for (int j = 0; j < durSamples; ++j) { + int sample = dataS8[j + delaySamples] + (s16buf[j] >> 8); + if ((sample + 128 & 0xffffff00) != 0) { + // clamp to s8 + sample = sample >> 31 ^ 127; + } + dataS8[j + delaySamples] = (byte) sample; + } + } + } + + return dataS8; + } + + public RawSampleS8 toRawSample() { + final byte[] sampleData = this.toSampleDataS8(); + return new RawSampleS8( + sampleData, + SampledAudioChannel.SAMPLES_PER_SECOND * this.loopStartMs / 1000, + SampledAudioChannel.SAMPLES_PER_SECOND * this.loopEndMs / 1000 + ); + } +} diff --git a/src/main/java/funorb/audio/SomeBufferReader_idk.java b/src/main/java/funorb/audio/FmtVorbis.java similarity index 96% rename from src/main/java/funorb/audio/SomeBufferReader_idk.java rename to src/main/java/funorb/audio/FmtVorbis.java index 62f99fa..d2a1739 100644 --- a/src/main/java/funorb/audio/SomeBufferReader_idk.java +++ b/src/main/java/funorb/audio/FmtVorbis.java @@ -7,7 +7,7 @@ import funorb.util.BitMath; import java.io.IOException; import java.util.stream.IntStream; -public final class SomeBufferReader_idk { +public final class FmtVorbis { public static vb_[] _L; private static float[] _k; private static to_[] _o; @@ -43,7 +43,7 @@ public final class SomeBufferReader_idk { private float[] _n; private int sectionIndex; - private SomeBufferReader_idk(final byte[] data) throws IOException { + private FmtVorbis(final byte[] data) throws IOException { this.load(data); } @@ -167,16 +167,16 @@ public final class SomeBufferReader_idk { } @SuppressWarnings("SameParameterValue") - public static SomeBufferReader_idk a968(final ResourceLoader loader, final String group, final String item) { + public static FmtVorbis 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 { - SomeBufferReader_idk var4 = null; + FmtVorbis var4 = null; try { - var4 = new SomeBufferReader_idk(var3); + var4 = new FmtVorbis(var3); } catch (final IOException var6) { var6.printStackTrace(); } @@ -231,16 +231,16 @@ public final class SomeBufferReader_idk { return result; } - public static SomeBufferReader_idk a740(final ResourceLoader loader, final int groupId, final int itemId) { + public static FmtVorbis load(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 { - SomeBufferReader_idk var4 = null; + FmtVorbis var4 = null; try { - var4 = new SomeBufferReader_idk(var3); + var4 = new FmtVorbis(var3); } catch (final IOException var6) { var6.printStackTrace(); } @@ -262,7 +262,7 @@ public final class SomeBufferReader_idk { return i; } - public AudioSampleData_idk a582() { + public RawSampleS8 toRawSample() { if (this.sampleData == null) { this._M = 0; this._n = new float[_r]; @@ -297,7 +297,7 @@ public final class SomeBufferReader_idk { this._n = null; final byte[] sampleData = this.sampleData; this.sampleData = null; - return new AudioSampleData_idk(this.sampleRate, sampleData, this.loopStart, this.loopEnd, this.isLooped); + return new RawSampleS8(this.sampleRate, sampleData, this.loopStart, this.loopEnd, this.isLooped); } private float[] e875(final int sectionIndex) { diff --git a/src/main/java/funorb/audio/MidiInstrument.java b/src/main/java/funorb/audio/MidiInstrument.java index 53b64ae..ff954d5 100644 --- a/src/main/java/funorb/audio/MidiInstrument.java +++ b/src/main/java/funorb/audio/MidiInstrument.java @@ -3,7 +3,7 @@ package funorb.audio; import funorb.io.Buffer; public final class MidiInstrument { - public final AudioSampleData_idk[] noteSample = new AudioSampleData_idk[128]; + public final RawSampleS8[] noteSample = new RawSampleS8[128]; public final KeyParams_idk[] keyParams_idk = new KeyParams_idk[128]; public final byte[] notePan_idk = new byte[128]; public final int mainVolume_idk; @@ -454,7 +454,7 @@ public final class MidiInstrument { public boolean loadNoteSamples(final SoundLoader loader, final byte[] restrictNotes) { boolean success = true; int var6 = 0; - AudioSampleData_idk sampleData = null; + RawSampleS8 sampleData = null; for (int noteNumber = 0; noteNumber < 128; ++noteNumber) { if (restrictNotes == null || restrictNotes[noteNumber] != 0) { diff --git a/src/main/java/funorb/audio/MidiPlayer.java b/src/main/java/funorb/audio/MidiPlayer.java index f0a7d0a..1ea1458 100644 --- a/src/main/java/funorb/audio/MidiPlayer.java +++ b/src/main/java/funorb/audio/MidiPlayer.java @@ -543,7 +543,7 @@ public final class MidiPlayer extends AudioSource_idk { final MidiInstrument instrument = this.instruments.get(this.chCurrentProgram[channel]); if (instrument != null) { - final AudioSampleData_idk sample = instrument.noteSample[noteNumber]; + final RawSampleS8 sample = instrument.noteSample[noteNumber]; if (sample != null) { final MidiPlayerNoteState_idk note = new MidiPlayerNoteState_idk(); note.channel = channel; diff --git a/src/main/java/funorb/audio/MidiPlayerNoteState_idk.java b/src/main/java/funorb/audio/MidiPlayerNoteState_idk.java index 1550554..c9625d4 100644 --- a/src/main/java/funorb/audio/MidiPlayerNoteState_idk.java +++ b/src/main/java/funorb/audio/MidiPlayerNoteState_idk.java @@ -9,7 +9,7 @@ public final class MidiPlayerNoteState_idk extends NodeList.Node { public int _v; public int _F; public int note; - public AudioSampleData_idk sampleData; + public RawSampleS8 sampleData; public KeyParams_idk keyParams_idk; public AudioSamplePlayback_idk playback; public MidiInstrument instrument; diff --git a/src/main/java/funorb/audio/Oscillator.java b/src/main/java/funorb/audio/Oscillator.java new file mode 100644 index 0000000..ef159ca --- /dev/null +++ b/src/main/java/funorb/audio/Oscillator.java @@ -0,0 +1,317 @@ +package funorb.audio; + +import funorb.io.Buffer; + +import java.util.Arrays; +import java.util.Random; + +public final class Oscillator { + private static final int[] NOISE = new int[0x8000]; + private static final int[] SINE = new int[0x8000]; + private static final int[] buf; + private static final int[] _p; + private static final int[] _q; + private static final int[] _t; + private static final int[] _c; + private static final int[] _w; + + static { + final Random var0 = new Random(0L); + for (int i = 0; i < 0x8000; ++i) { + NOISE[i] = (var0.nextInt() & 2) - 1; + } + for (int i = 0; i < 0x8000; ++i) { + SINE[i] = (int) (Math.sin((double) i * Math.PI / 0x4000) * 0x4000); + } + + buf = new int[220500]; + _q = new int[5]; + _t = new int[5]; + _p = new int[5]; + _w = new int[5]; + _c = new int[5]; + } + + private final int[] _y = new int[]{0, 0, 0, 0, 0}; + private final int[] _x = new int[]{0, 0, 0, 0, 0}; + private final int[] _h = new int[]{0, 0, 0, 0, 0}; + public int delayMs = 0; + public int durMs = 500; + private fh_ _k; + private OscillatorState osc5_; + private int _f = 0; + private OscillatorState osc7_; + private OscillatorState osc4_; + private OscillatorState osc3_; + private OscillatorState osc0_; + private int _b = 100; + private OscillatorState osc8_; + private OscillatorState osc6_; + private OscillatorState osc2_; + private OscillatorState osc1_; + + public int[] generateS16(final int len, final int lenMs) { + Arrays.fill(buf, 0, len, 0); + + if (lenMs < 10) { + return buf; + } + + final double samplesPerMs = (double) len / ((double) lenMs + 0.0D); + + this.osc0_.reset(); + this.osc1_.reset(); + int var5 = 0; + int var6 = 0; + int var7 = 0; + if (this.osc2_ != null) { + this.osc2_.reset(); + this.osc3_.reset(); + var5 = (int) ((double) (this.osc2_._i - this.osc2_._d) * 32.768D / samplesPerMs); + var6 = (int) ((double) this.osc2_._d * 32.768D / samplesPerMs); + } + + int var8 = 0; + int var9 = 0; + int var10 = 0; + if (this.osc4_ != null) { + this.osc4_.reset(); + this.osc5_.reset(); + var8 = (int) ((double) (this.osc4_._i - this.osc4_._d) * 32.768D / samplesPerMs); + var9 = (int) ((double) this.osc4_._d * 32.768D / samplesPerMs); + } + + for (int i = 0; i < 5; ++i) { + if (this._y[i] != 0) { + _c[i] = 0; + _q[i] = (int) ((double) this._h[i] * samplesPerMs); + _p[i] = (this._y[i] << 14) / 100; + _t[i] = (int) ((double) (this.osc0_._i - this.osc0_._d) * 32.768D * Math.pow(1.0057929410678534D, this._x[i]) / samplesPerMs); + _w[i] = (int) ((double) this.osc0_._d * 32.768D / samplesPerMs); + } + } + + for (int i = 0; i < len; ++i) { + int var12 = this.osc0_.next(len); + int var13 = this.osc1_.next(len); + int var14; + int var15; + if (this.osc2_ != null) { + var14 = this.osc2_.next(len); + var15 = this.osc3_.next(len); + var12 += this.sample(this.osc2_.waveform, var7, var15) >> 1; + var7 += (var14 * var5 >> 16) + var6; + } + + if (this.osc4_ != null) { + var14 = this.osc4_.next(len); + var15 = this.osc5_.next(len); + var13 = var13 * ((this.sample(this.osc4_.waveform, var10, var15) >> 1) + 0x8000) >> 15; + var10 += (var14 * var8 >> 16) + var9; + } + + for (var14 = 0; var14 < 5; ++var14) { + if (this._y[var14] != 0) { + var15 = i + _q[var14]; + if (var15 < len) { + buf[var15] += this.sample(this.osc0_.waveform, _c[var14], var13 * _p[var14] >> 15); + _c[var14] += (var12 * _t[var14] >> 16) + _w[var14]; + } + } + } + } + + if (this.osc6_ != null) { + this.osc6_.reset(); + this.osc7_.reset(); + int var11 = 0; + boolean var19 = true; + + for (int i = 0; i < len; ++i) { + final int var15 = this.osc6_.next(len); + final int var16 = this.osc7_.next(len); + final int var12; + if (var19) { + var12 = this.osc6_._d + ((this.osc6_._i - this.osc6_._d) * var15 >> 8); + } else { + var12 = this.osc6_._d + ((this.osc6_._i - this.osc6_._d) * var16 >> 8); + } + + var11 += 256; + if (var11 >= var12) { + var11 = 0; + var19 = !var19; + } + + if (var19) { + buf[i] = 0; + } + } + } + + if (this._f > 0 && this._b > 0) { + final int var11 = (int) ((double) this._f * samplesPerMs); + for (int i = var11; i < len; ++i) { + buf[i] += buf[i - var11] * this._b / 100; + } + } + + if (this._k._d[0] > 0 || this._k._d[1] > 0) { + this.osc8_.reset(); + int var11 = this.osc8_.next(len + 1); + int var12 = this._k.a197(0, (float) var11 / 65536.0F); + int var13 = this._k.a197(1, (float) var11 / 65536.0F); + if (len >= var12 + var13) { + int var14 = 0; + final int var15 = Math.min(var13, len - var12); + + while (var14 < var15) { + int var16 = (int) ((long) buf[var14 + var12] * (long) fh_._g >> 16); + + for (int var17 = 0; var17 < var12; ++var17) { + var16 += (int) ((long) buf[var14 + var12 - 1 - var17] * (long) fh_._e[0][var17] >> 16); + } + + for (int var17 = 0; var17 < var14; ++var17) { + var16 -= (int) ((long) buf[var14 - 1 - var17] * (long) fh_._e[1][var17] >> 16); + } + + buf[var14] = var16; + var11 = this.osc8_.next(len + 1); + ++var14; + } + + int var15a = 128; + while (true) { + if (var15a > len - var12) { + var15a = len - var12; + } + + while (var14 < var15a) { + int var16 = (int) ((long) buf[var14 + var12] * (long) fh_._g >> 16); + + for (int var17 = 0; var17 < var12; ++var17) { + var16 += (int) ((long) buf[var14 + var12 - 1 - var17] * (long) fh_._e[0][var17] >> 16); + } + + for (int var17 = 0; var17 < var13; ++var17) { + var16 -= (int) ((long) buf[var14 - 1 - var17] * (long) fh_._e[1][var17] >> 16); + } + + buf[var14] = var16; + var11 = this.osc8_.next(len + 1); + ++var14; + } + + if (var14 >= len - var12) { + while (var14 < len) { + int var16 = 0; + + for (int var17 = var14 + var12 - len; var17 < var12; ++var17) { + var16 += (int) ((long) buf[var14 + var12 - 1 - var17] * (long) fh_._e[0][var17] >> 16); + } + + for (int var17 = 0; var17 < var13; ++var17) { + var16 -= (int) ((long) buf[var14 - 1 - var17] * (long) fh_._e[1][var17] >> 16); + } + + buf[var14] = var16; + this.osc8_.next(len + 1); + ++var14; + } + break; + } + + var12 = this._k.a197(0, (float) var11 / 65536.0F); + var13 = this._k.a197(1, (float) var11 / 65536.0F); + var15a += 128; + } + } + } + + for (int i = 0; i < len; ++i) { + if (buf[i] < -32768) { + buf[i] = -32768; + } + if (buf[i] > 32767) { + buf[i] = 32767; + } + } + return buf; + } + + public void initialize(final Buffer buf) { + this.osc0_ = new OscillatorState(); + this.osc0_.initialize(buf); + this.osc1_ = new OscillatorState(); + this.osc1_.initialize(buf); + + final int peek1 = buf.readUByte(); + if (peek1 != 0) { + --buf.pos; + this.osc2_ = new OscillatorState(); + this.osc2_.initialize(buf); + this.osc3_ = new OscillatorState(); + this.osc3_.initialize(buf); + } + + final int peek2 = buf.readUByte(); + if (peek2 != 0) { + --buf.pos; + this.osc4_ = new OscillatorState(); + this.osc4_.initialize(buf); + this.osc5_ = new OscillatorState(); + this.osc5_.initialize(buf); + } + + final int peek3 = buf.readUByte(); + if (peek3 != 0) { + --buf.pos; + this.osc6_ = new OscillatorState(); + this.osc6_.initialize(buf); + this.osc7_ = new OscillatorState(); + this.osc7_.initialize(buf); + } + + for (int i = 0; i < 10; ++i) { + final int peek4 = buf.readVariable8_16(); + if (peek4 == 0) { + break; + } + + this._y[i] = peek4; + this._x[i] = buf.readBiasedVariable8_16(); + this._h[i] = buf.readVariable8_16(); + } + + this._f = buf.readVariable8_16(); + this._b = buf.readVariable8_16(); + this.durMs = buf.readUShort(); + this.delayMs = buf.readUShort(); + this._k = new fh_(); + this.osc8_ = new OscillatorState(); + this._k.a086(buf, this.osc8_); + } + + private int sample(final int type, final int phase, final int amplitude) { + if (type == Waveform.SQUARE) { + return ((phase & 0x7fff) < 0x4000) ? amplitude : -amplitude; + } else if (type == Waveform.SINE) { + return (SINE[phase & 0x7fff] * amplitude) >> 14; + } else if (type == Waveform.SAWTOOTH) { + return (((phase & 0x7fff) * amplitude) >> 14) - amplitude; + } else if (type == Waveform.NOISE) { + return NOISE[(phase / 2607) & 0x7fff] * amplitude; + } else { + return 0; + } + } + + @SuppressWarnings("WeakerAccess") + private static final class Waveform { + public static final int SQUARE = 1; + public static final int SINE = 2; + public static final int SAWTOOTH = 3; + public static final int NOISE = 4; + } +} diff --git a/src/main/java/funorb/audio/OscillatorConfig_idk.java b/src/main/java/funorb/audio/OscillatorState.java similarity index 90% rename from src/main/java/funorb/audio/OscillatorConfig_idk.java rename to src/main/java/funorb/audio/OscillatorState.java index 99d8bfb..1c7087e 100644 --- a/src/main/java/funorb/audio/OscillatorConfig_idk.java +++ b/src/main/java/funorb/audio/OscillatorState.java @@ -2,7 +2,7 @@ package funorb.audio; import funorb.io.Buffer; -public final class OscillatorConfig_idk { +public final class OscillatorState { public int _d; public int _i; public int waveform; @@ -15,7 +15,7 @@ public final class OscillatorConfig_idk { private int _j; private int pos; - public OscillatorConfig_idk() { + public OscillatorState() { this.values1[1] = 65535; this.values2[1] = 65535; } @@ -45,14 +45,14 @@ public final class OscillatorConfig_idk { this._g = 0; } - public int next(final int volume) { + public int next(final int len) { if (this._g >= this._e) { this._j = this.values2[this.pos++] << 15; if (this.pos >= this.count) { this.pos = this.count - 1; } - this._e = (int) (((double) this.values1[this.pos] / 65536.0D) * (double) volume); + this._e = (int) (((double) this.values1[this.pos] / 65536.0D) * (double) len); if (this._e > this._g) { this._b = ((this.values2[this.pos] << 15) - this._j) / (this._e - this._g); } diff --git a/src/main/java/funorb/audio/Oscillator_idk.java b/src/main/java/funorb/audio/Oscillator_idk.java deleted file mode 100644 index 0cee180..0000000 --- a/src/main/java/funorb/audio/Oscillator_idk.java +++ /dev/null @@ -1,312 +0,0 @@ -package funorb.audio; - -import funorb.io.Buffer; - -import java.util.Arrays; -import java.util.Random; - -public final class Oscillator_idk { - private static final int[] NOISE = new int[0x8000]; - private static final int[] SINE = new int[0x8000]; - private static final int[] _u; - private static final int[] _p; - private static final int[] _q; - private static final int[] _t; - private static final int[] _c; - private static final int[] _w; - - static { - final Random var0 = new Random(0L); - for (int i = 0; i < 0x8000; ++i) { - NOISE[i] = (var0.nextInt() & 2) - 1; - } - for (int i = 0; i < 0x8000; ++i) { - SINE[i] = (int) (Math.sin((double) i * Math.PI / 0x4000) * 0x4000); - } - - _u = new int[220500]; - _q = new int[5]; - _t = new int[5]; - _p = new int[5]; - _w = new int[5]; - _c = new int[5]; - } - - private final int[] _y = new int[]{0, 0, 0, 0, 0}; - private final int[] _x = new int[]{0, 0, 0, 0, 0}; - private final int[] _h = new int[]{0, 0, 0, 0, 0}; - public int _s = 0; - public int _a = 500; - private fh_ _k; - private OscillatorConfig_idk osc1; - private int _f = 0; - private OscillatorConfig_idk osc2; - private OscillatorConfig_idk osc3; - private OscillatorConfig_idk osc4; - private OscillatorConfig_idk osc5; - private int _b = 100; - private OscillatorConfig_idk osc6; - private OscillatorConfig_idk osc7; - private OscillatorConfig_idk osc8; - private OscillatorConfig_idk osc9; - - public int[] a111(final int var1, final int var2) { - Arrays.fill(_u, 0, var1, 0); - if (var2 >= 10) { - final double var3 = (double) var1 / ((double) var2 + 0.0D); - this.osc5.reset(); - this.osc9.reset(); - int var5 = 0; - int var6 = 0; - int var7 = 0; - if (this.osc8 != null) { - this.osc8.reset(); - this.osc4.reset(); - var5 = (int) ((double) (this.osc8._i - this.osc8._d) * 32.768D / var3); - var6 = (int) ((double) this.osc8._d * 32.768D / var3); - } - - int var8 = 0; - int var9 = 0; - int var10 = 0; - if (this.osc3 != null) { - this.osc3.reset(); - this.osc1.reset(); - var8 = (int) ((double) (this.osc3._i - this.osc3._d) * 32.768D / var3); - var9 = (int) ((double) this.osc3._d * 32.768D / var3); - } - - for (int i = 0; i < 5; ++i) { - if (this._y[i] != 0) { - _c[i] = 0; - _q[i] = (int) ((double) this._h[i] * var3); - _p[i] = (this._y[i] << 14) / 100; - _t[i] = (int) ((double) (this.osc5._i - this.osc5._d) * 32.768D * Math.pow(1.0057929410678534D, this._x[i]) / var3); - _w[i] = (int) ((double) this.osc5._d * 32.768D / var3); - } - } - - for (int i = 0; i < var1; ++i) { - int var12 = this.osc5.next(var1); - int var13 = this.osc9.next(var1); - int var14; - int var15; - if (this.osc8 != null) { - var14 = this.osc8.next(var1); - var15 = this.osc4.next(var1); - var12 += this.sample(this.osc8.waveform, var7, var15) >> 1; - var7 += (var14 * var5 >> 16) + var6; - } - - if (this.osc3 != null) { - var14 = this.osc3.next(var1); - var15 = this.osc1.next(var1); - var13 = var13 * ((this.sample(this.osc3.waveform, var10, var15) >> 1) + 0x8000) >> 15; - var10 += (var14 * var8 >> 16) + var9; - } - - for (var14 = 0; var14 < 5; ++var14) { - if (this._y[var14] != 0) { - var15 = i + _q[var14]; - if (var15 < var1) { - _u[var15] += this.sample(this.osc5.waveform, _c[var14], var13 * _p[var14] >> 15); - _c[var14] += (var12 * _t[var14] >> 16) + _w[var14]; - } - } - } - } - - if (this.osc7 != null) { - this.osc7.reset(); - this.osc2.reset(); - int var11 = 0; - boolean var19 = true; - - for (int i = 0; i < var1; ++i) { - final int var15 = this.osc7.next(var1); - final int var16 = this.osc2.next(var1); - final int var12; - if (var19) { - var12 = this.osc7._d + ((this.osc7._i - this.osc7._d) * var15 >> 8); - } else { - var12 = this.osc7._d + ((this.osc7._i - this.osc7._d) * var16 >> 8); - } - - var11 += 256; - if (var11 >= var12) { - var11 = 0; - var19 = !var19; - } - - if (var19) { - _u[i] = 0; - } - } - } - - if (this._f > 0 && this._b > 0) { - final int var11 = (int) ((double) this._f * var3); - for (int i = var11; i < var1; ++i) { - _u[i] += _u[i - var11] * this._b / 100; - } - } - - if (this._k._d[0] > 0 || this._k._d[1] > 0) { - this.osc6.reset(); - int var11 = this.osc6.next(var1 + 1); - int var12 = this._k.a197(0, (float) var11 / 65536.0F); - int var13 = this._k.a197(1, (float) var11 / 65536.0F); - if (var1 >= var12 + var13) { - int var14 = 0; - final int var15 = Math.min(var13, var1 - var12); - - while (var14 < var15) { - int var16 = (int) ((long) _u[var14 + var12] * (long) fh_._g >> 16); - - for (int var17 = 0; var17 < var12; ++var17) { - var16 += (int) ((long) _u[var14 + var12 - 1 - var17] * (long) fh_._e[0][var17] >> 16); - } - - for (int var17 = 0; var17 < var14; ++var17) { - var16 -= (int) ((long) _u[var14 - 1 - var17] * (long) fh_._e[1][var17] >> 16); - } - - _u[var14] = var16; - var11 = this.osc6.next(var1 + 1); - ++var14; - } - - int var15a = 128; - while (true) { - if (var15a > var1 - var12) { - var15a = var1 - var12; - } - - while (var14 < var15a) { - int var16 = (int) ((long) _u[var14 + var12] * (long) fh_._g >> 16); - - for (int var17 = 0; var17 < var12; ++var17) { - var16 += (int) ((long) _u[var14 + var12 - 1 - var17] * (long) fh_._e[0][var17] >> 16); - } - - for (int var17 = 0; var17 < var13; ++var17) { - var16 -= (int) ((long) _u[var14 - 1 - var17] * (long) fh_._e[1][var17] >> 16); - } - - _u[var14] = var16; - var11 = this.osc6.next(var1 + 1); - ++var14; - } - - if (var14 >= var1 - var12) { - while (var14 < var1) { - int var16 = 0; - - for (int var17 = var14 + var12 - var1; var17 < var12; ++var17) { - var16 += (int) ((long) _u[var14 + var12 - 1 - var17] * (long) fh_._e[0][var17] >> 16); - } - - for (int var17 = 0; var17 < var13; ++var17) { - var16 -= (int) ((long) _u[var14 - 1 - var17] * (long) fh_._e[1][var17] >> 16); - } - - _u[var14] = var16; - this.osc6.next(var1 + 1); - ++var14; - } - break; - } - - var12 = this._k.a197(0, (float) var11 / 65536.0F); - var13 = this._k.a197(1, (float) var11 / 65536.0F); - var15a += 128; - } - } - } - - for (int i = 0; i < var1; ++i) { - if (_u[i] < 0xffff8000) { - _u[i] = 0xffff8000; - } - if (_u[i] > 0x7fff) { - _u[i] = 0x7fff; - } - } - } - return _u; - } - - public void initialize(final Buffer buffer) { - this.osc5 = new OscillatorConfig_idk(); - this.osc5.initialize(buffer); - this.osc9 = new OscillatorConfig_idk(); - this.osc9.initialize(buffer); - final int var2 = buffer.readUByte(); - if (var2 != 0) { - --buffer.pos; - this.osc8 = new OscillatorConfig_idk(); - this.osc8.initialize(buffer); - this.osc4 = new OscillatorConfig_idk(); - this.osc4.initialize(buffer); - } - - final int var2a = buffer.readUByte(); - if (var2a != 0) { - --buffer.pos; - this.osc3 = new OscillatorConfig_idk(); - this.osc3.initialize(buffer); - this.osc1 = new OscillatorConfig_idk(); - this.osc1.initialize(buffer); - } - - final int j137 = buffer.readUByte(); - if (j137 != 0) { - --buffer.pos; - this.osc7 = new OscillatorConfig_idk(); - this.osc7.initialize(buffer); - this.osc2 = new OscillatorConfig_idk(); - this.osc2.initialize(buffer); - } - - for (int i = 0; i < 10; ++i) { - final int var4 = buffer.readVariable8_16(); - if (var4 == 0) { - break; - } - - this._y[i] = var4; - this._x[i] = buffer.d410(); - this._h[i] = buffer.readVariable8_16(); - } - - this._f = buffer.readVariable8_16(); - this._b = buffer.readVariable8_16(); - this._a = buffer.readUShort(); - this._s = buffer.readUShort(); - this._k = new fh_(); - this.osc6 = new OscillatorConfig_idk(); - this._k.a086(buffer, this.osc6); - } - - private int sample(final int type, final int phase, final int volume) { - if (type == Waveform.SQUARE) { - return ((phase & 0x7fff) < 0x4000) ? volume : -volume; - } else if (type == Waveform.SINE) { - return (SINE[phase & 0x7fff] * volume) >> 14; - } else if (type == Waveform.SAWTOOTH) { - return (((phase & 0x7fff) * volume) >> 14) - volume; - } else if (type == Waveform.NOISE) { - return NOISE[(phase / 2607) & 0x7fff] * volume; - } else { - return 0; - } - } - - @SuppressWarnings("WeakerAccess") - private static final class Waveform { - public static final int SQUARE = 1; - public static final int SINE = 2; - public static final int SAWTOOTH = 3; - public static final int NOISE = 4; - } -} diff --git a/src/main/java/funorb/audio/AudioSampleData_idk.java b/src/main/java/funorb/audio/RawSampleS8.java similarity index 78% rename from src/main/java/funorb/audio/AudioSampleData_idk.java rename to src/main/java/funorb/audio/RawSampleS8.java index ace2fc7..72c14ad 100644 --- a/src/main/java/funorb/audio/AudioSampleData_idk.java +++ b/src/main/java/funorb/audio/RawSampleS8.java @@ -1,6 +1,6 @@ package funorb.audio; -public final class AudioSampleData_idk { +public final class RawSampleS8 { public final int loopEnd_idfk; public final int loopStart_idfk; public final int sampleRate; @@ -8,11 +8,11 @@ public final class AudioSampleData_idk { public final boolean isLooped_idk; public int _h; - public AudioSampleData_idk(final byte[] data, final int loopStart, final int loopEnd) { + public RawSampleS8(final byte[] data, final int loopStart, final int loopEnd) { this(SampledAudioChannel.SAMPLES_PER_SECOND, data, loopStart, loopEnd, false); } - public AudioSampleData_idk( + public RawSampleS8( final int sampleRate, final byte[] data, final int loopStart, diff --git a/src/main/java/funorb/audio/SampledAudioChannel.java b/src/main/java/funorb/audio/SampledAudioChannel.java index 9b7913d..0bded2c 100644 --- a/src/main/java/funorb/audio/SampledAudioChannel.java +++ b/src/main/java/funorb/audio/SampledAudioChannel.java @@ -132,7 +132,7 @@ public final class SampledAudioChannel implements Closeable { break label100; } - final AudioSampleData_idk var12 = var11.sampleData; + final RawSampleS8 var12 = var11.sampleData; if (var12 != null && var12._h > var8) { var5 |= 1 << var7; var10 = var11; diff --git a/src/main/java/funorb/audio/SoundEffect.java b/src/main/java/funorb/audio/SoundEffect.java index 9839524..91e99f9 100644 --- a/src/main/java/funorb/audio/SoundEffect.java +++ b/src/main/java/funorb/audio/SoundEffect.java @@ -2,9 +2,9 @@ package funorb.audio; public final class SoundEffect { public final int volume; - public final AudioSampleData_idk sample; + public final RawSampleS8 sample; - private SoundEffect(final AudioSampleData_idk sample, final int volume) { + private SoundEffect(final RawSampleS8 sample, final int volume) { this.volume = volume; this.sample = sample; } diff --git a/src/main/java/funorb/audio/SoundLoader.java b/src/main/java/funorb/audio/SoundLoader.java index a63a90c..5262088 100644 --- a/src/main/java/funorb/audio/SoundLoader.java +++ b/src/main/java/funorb/audio/SoundLoader.java @@ -7,8 +7,8 @@ import java.util.Map; public final class SoundLoader { public static SoundLoader globalLoader; - private final Map _a = new HashMap<>(); - private final Map _d = new HashMap<>(); + private final Map cache2 = new HashMap<>(); + private final Map cache1 = new HashMap<>(); private final ResourceLoader loader1; private final ResourceLoader loader2; @@ -17,67 +17,67 @@ public final class SoundLoader { this.loader2 = loader2; } - private AudioSampleData_idk load1(final int groupId, final int itemId) { - final int var5 = (itemId ^ (((groupId << 4) & 0xfff3) | (groupId >>> 12))) | (groupId << 16); - final AudioSampleData_idk var8 = this._d.get((long) var5); - if (var8 == null) { - final dq_ var9 = dq_.load(this.loader1, groupId, itemId); - if (var9 == null) { + private RawSampleS8 load1(final int groupId, final int itemId) { + final int cacheKey = (itemId ^ (((groupId << 4) & 0xfff3) | (groupId >>> 12))) | (groupId << 16); + final RawSampleS8 cachedRaw = this.cache1.get((long) cacheKey); + if (cachedRaw == null) { + final FmtSynth file = FmtSynth.load(this.loader1, groupId, itemId); + if (file == null) { return null; } else { - final AudioSampleData_idk kk_ = var9.b720(); - this._d.put((long) var5, kk_); - return kk_; + final RawSampleS8 raw = file.toRawSample(); + this.cache1.put((long) cacheKey, raw); + return raw; } } else { - return var8; + return cachedRaw; } } - public AudioSampleData_idk loadSingleton2(final int var3) { + public RawSampleS8 loadSingleton2(final int id) { if (this.loader2.groupCount() == 1) { - return this.load2(0, var3); - } else if (this.loader2.itemCount(var3) == 1) { - return this.load2(var3, 0); + return this.load2(0, id); + } else if (this.loader2.itemCount(id) == 1) { + return this.load2(id, 0); } else { throw new RuntimeException(); } } - public AudioSampleData_idk loadSingleton1(final int var1) { + public RawSampleS8 loadSingleton1(final int id) { if (this.loader1.groupCount() == 1) { - return this.load1(0, var1); - } else if (this.loader1.itemCount(var1) == 1) { - return this.load1(var1, 0); + return this.load1(0, id); + } else if (this.loader1.itemCount(id) == 1) { + return this.load1(id, 0); } else { throw new RuntimeException(); } } - private AudioSampleData_idk load2(final int var3, final int var2) { - final int var5 = (((var3 >>> 12) | (0xfff0 & (var3 << 4))) ^ var2) | (var3 << 16); - final long var6 = 0x100000000L ^ (long) var5; - AudioSampleData_idk var8 = this._d.get(var6); - if (var8 == null) { - SomeBufferReader_idk var9 = this._a.get(var6); - if (var9 == null) { - var9 = SomeBufferReader_idk.a740(this.loader2, var3, var2); - if (var9 == null) { + private RawSampleS8 load2(final int groupId, final int itemId) { + final int var5 = (((groupId >>> 12) | (0xfff0 & (groupId << 4))) ^ itemId) | (groupId << 16); + final long cacheKey = 0x100000000L ^ (long) var5; + RawSampleS8 raw = this.cache1.get(cacheKey); + if (raw == null) { + FmtVorbis file = this.cache2.get(cacheKey); + if (file == null) { + file = FmtVorbis.load(this.loader2, groupId, itemId); + if (file == null) { return null; } - this._a.put(var6, var9); + this.cache2.put(cacheKey, file); } - var8 = var9.a582(); - this._a.remove(var6); - this._d.put(var6, var8); + raw = file.toRawSample(); + this.cache2.remove(cacheKey); + this.cache1.put(cacheKey, raw); } - return var8; + return raw; } @SuppressWarnings("SameParameterValue") - public AudioSampleData_idk load2(final String item) { + public RawSampleS8 load2(final String item) { final int groupId = this.loader2.lookupGroup(""); if (groupId < 0) { return null; @@ -87,11 +87,11 @@ public final class SoundLoader { } } - public AudioSampleData_idk load1(final String item) { + public RawSampleS8 load1(final String item) { final int groupId = this.loader1.lookupGroup(""); if (groupId >= 0) { final int itemId = this.loader1.lookupItem(groupId, item); - return itemId >= 0 ? this.load1(groupId, itemId) : null; + return itemId < 0 ? null : this.load1(groupId, itemId); } else { return null; } diff --git a/src/main/java/funorb/audio/dq_.java b/src/main/java/funorb/audio/dq_.java deleted file mode 100644 index 55ec40b..0000000 --- a/src/main/java/funorb/audio/dq_.java +++ /dev/null @@ -1,73 +0,0 @@ -package funorb.audio; - -import funorb.cache.ResourceLoader; -import funorb.io.Buffer; - -public final class dq_ { - private final Oscillator_idk[] oscillators = new Oscillator_idk[10]; - private final int _c; - private final int _a; - - private dq_(final Buffer data) { - for (int i = 0; i < 10; ++i) { - final int peekByte = data.readUByte(); - if (peekByte != 0) { - --data.pos; - this.oscillators[i] = new Oscillator_idk(); - this.oscillators[i].initialize(data); - } - } - - this._c = data.readUShort(); - this._a = data.readUShort(); - } - - public static dq_ load(final ResourceLoader loader, final int groupId, final int itemId) { - final byte[] data = loader.getResource(groupId, itemId); - return data == null ? null : new dq_(new Buffer(data)); - } - - private byte[] a928() { - int var1 = 0; - - for (int i = 0; i < 10; ++i) { - if (this.oscillators[i] != null && var1 < this.oscillators[i]._a + this.oscillators[i]._s) { - var1 = this.oscillators[i]._a + this.oscillators[i]._s; - } - } - - if (var1 == 0) { - return new byte[0]; - } - final int var2 = SampledAudioChannel.SAMPLES_PER_SECOND * var1 / 1000; - final byte[] var3 = new byte[var2]; - - for (int i = 0; i < 10; ++i) { - if (this.oscillators[i] != null) { - final int var5 = this.oscillators[i]._a * SampledAudioChannel.SAMPLES_PER_SECOND / 1000; - final int var6 = this.oscillators[i]._s * SampledAudioChannel.SAMPLES_PER_SECOND / 1000; - final int[] var7 = this.oscillators[i].a111(var5, this.oscillators[i]._a); - - for (int j = 0; j < var5; ++j) { - int var9 = var3[j + var6] + (var7[j] >> 8); - if ((var9 + 128 & -256) != 0) { - var9 = var9 >> 31 ^ 127; - } - - var3[j + var6] = (byte) var9; - } - } - } - - return var3; - } - - public AudioSampleData_idk b720() { - final byte[] var1 = this.a928(); - return new AudioSampleData_idk( - var1, - SampledAudioChannel.SAMPLES_PER_SECOND * this._c / 1000, - SampledAudioChannel.SAMPLES_PER_SECOND * this._a / 1000 - ); - } -} diff --git a/src/main/java/funorb/audio/fh_.java b/src/main/java/funorb/audio/fh_.java index ea96912..9744b8a 100644 --- a/src/main/java/funorb/audio/fh_.java +++ b/src/main/java/funorb/audio/fh_.java @@ -17,7 +17,7 @@ public final class fh_ { return var1 * 3.1415927F / 11025.0F; } - public void a086(final Buffer var1, final OscillatorConfig_idk var2) { + public void a086(final Buffer var1, final OscillatorState var2) { final int var3 = var1.readUByte(); this._d[0] = var3 >> 4; this._d[1] = var3 & 15; diff --git a/src/main/java/funorb/audio/fq_.java b/src/main/java/funorb/audio/fq_.java index 8572837..605f63c 100644 --- a/src/main/java/funorb/audio/fq_.java +++ b/src/main/java/funorb/audio/fq_.java @@ -7,24 +7,24 @@ public final class fq_ { public int _d; public fq_() { - 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); + FmtVorbis.readBits(16); + this._c = FmtVorbis.readBit() != 0 ? FmtVorbis.readBits(4) + 1 : 1; + if (FmtVorbis.readBit() != 0) { + FmtVorbis.readBits(8); } - SomeBufferReader_idk.readBits(2); + FmtVorbis.readBits(2); if (this._c > 1) { - this._d = SomeBufferReader_idk.readBits(4); + this._d = FmtVorbis.readBits(4); } this._b = new int[this._c]; this._a = new int[this._c]; for (int var1 = 0; var1 < this._c; ++var1) { - SomeBufferReader_idk.readBits(8); - this._b[var1] = SomeBufferReader_idk.readBits(8); - this._a[var1] = SomeBufferReader_idk.readBits(8); + FmtVorbis.readBits(8); + this._b[var1] = FmtVorbis.readBits(8); + this._a[var1] = FmtVorbis.readBits(8); } } diff --git a/src/main/java/funorb/audio/kn_.java b/src/main/java/funorb/audio/kn_.java index d793859..b7f50c0 100644 --- a/src/main/java/funorb/audio/kn_.java +++ b/src/main/java/funorb/audio/kn_.java @@ -88,16 +88,16 @@ public final class kn_ { private final int[] _e; public kn_() { - final int var1 = SomeBufferReader_idk.readBits(16); + final int var1 = FmtVorbis.readBits(16); if (var1 == 1) { - final int var2 = SomeBufferReader_idk.readBits(5); + final int var2 = FmtVorbis.readBits(5); int var3 = 0; this._l = new int[var2]; int var4; int var5; for (var4 = 0; var4 < var2; ++var4) { - var5 = SomeBufferReader_idk.readBits(4); + var5 = FmtVorbis.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] = SomeBufferReader_idk.readBits(3) + 1; - var5 = this._c[var4] = SomeBufferReader_idk.readBits(2); + this._e[var4] = FmtVorbis.readBits(3) + 1; + var5 = this._c[var4] = FmtVorbis.readBits(2); if (var5 != 0) { - this._h[var4] = SomeBufferReader_idk.readBits(8); + this._h[var4] = FmtVorbis.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] = SomeBufferReader_idk.readBits(8) - 1; + var6[var7] = FmtVorbis.readBits(8) - 1; } } - this._b = SomeBufferReader_idk.readBits(2) + 1; - var4 = SomeBufferReader_idk.readBits(4); + this._b = FmtVorbis.readBits(2) + 1; + var4 = FmtVorbis.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++] = SomeBufferReader_idk.readBits(var4); + this._f[var5++] = FmtVorbis.readBits(var4); } } @@ -192,7 +192,7 @@ public final class kn_ { } public boolean b801() { - final boolean var1 = SomeBufferReader_idk.readBit() != 0; + final boolean var1 = FmtVorbis.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] = SomeBufferReader_idk.readBits(var4); - _i[1] = SomeBufferReader_idk.readBits(var4); + _i[0] = FmtVorbis.readBits(var4); + _i[1] = FmtVorbis.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 = SomeBufferReader_idk._L[this._h[var7]].a784(); + var11 = FmtVorbis._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 ? SomeBufferReader_idk._L[var13].a784() : 0; + _i[var5++] = var13 >= 0 ? FmtVorbis._L[var13].a784() : 0; } } diff --git a/src/main/java/funorb/audio/to_.java b/src/main/java/funorb/audio/to_.java index 5319a78..58b947b 100644 --- a/src/main/java/funorb/audio/to_.java +++ b/src/main/java/funorb/audio/to_.java @@ -10,22 +10,22 @@ public final class to_ { 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); + this._c = FmtVorbis.readBits(16); + this._g = FmtVorbis.readBits(24); + this._d = FmtVorbis.readBits(24); + this._b = FmtVorbis.readBits(24) + 1; + this._a = FmtVorbis.readBits(6) + 1; + this._f = FmtVorbis.readBits(8); final int[] var1 = new int[this._a]; int var2; for (var2 = 0; var2 < this._a; ++var2) { int var3 = 0; - final int var4 = SomeBufferReader_idk.readBits(3); - final boolean var5 = SomeBufferReader_idk.readBit() != 0; + final int var4 = FmtVorbis.readBits(3); + final boolean var5 = FmtVorbis.readBit() != 0; if (var5) { - var3 = SomeBufferReader_idk.readBits(5); + var3 = FmtVorbis.readBits(5); } var1[var2] = var3 << 3 | var4; @@ -34,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 ? SomeBufferReader_idk.readBits(8) : -1; + this._e[var2] = (var1[var2 >> 3] & 1 << (var2 & 7)) != 0 ? FmtVorbis.readBits(8) : -1; } } @@ -46,7 +46,7 @@ public final class to_ { } if (!var3) { - var4 = SomeBufferReader_idk._L[this._f]._a; + var4 = FmtVorbis._L[this._f]._a; final int var5 = this._d - this._g; final int var6 = var5 / this._b; final int[] var7 = new int[var6]; @@ -58,7 +58,7 @@ public final class to_ { int var10; int var11; if (var8 == 0) { - var10 = SomeBufferReader_idk._L[this._f].a784(); + var10 = FmtVorbis._L[this._f].a784(); for (var11 = var4 - 1; var11 >= 0; --var11) { if (var9 + var11 < var6) { @@ -74,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 = SomeBufferReader_idk._L[var12]; + final vb_ var14 = FmtVorbis._L[var12]; int var15; if (this._c == 0) { var15 = this._b / var14._a; diff --git a/src/main/java/funorb/audio/vb_.java b/src/main/java/funorb/audio/vb_.java index 9622248..668fed3 100644 --- a/src/main/java/funorb/audio/vb_.java +++ b/src/main/java/funorb/audio/vb_.java @@ -10,43 +10,43 @@ public final class vb_ { private int[] _f; public vb_() { - SomeBufferReader_idk.readBits(24); - this._a = SomeBufferReader_idk.readBits(16); - this._c = SomeBufferReader_idk.readBits(24); + FmtVorbis.readBits(24); + this._a = FmtVorbis.readBits(16); + this._c = FmtVorbis.readBits(24); this._b = new int[this._c]; - final boolean var1 = SomeBufferReader_idk.readBit() != 0; + final boolean var1 = FmtVorbis.readBit() != 0; int var2; int var3; int var5; if (var1) { var2 = 0; - for (var3 = SomeBufferReader_idk.readBits(5) + 1; var2 < this._c; ++var3) { - final int var4 = SomeBufferReader_idk.readBits(BitMath.lastSet(this._c - var2)); + for (var3 = FmtVorbis.readBits(5) + 1; var2 < this._c; ++var3) { + final int var4 = FmtVorbis.readBits(BitMath.lastSet(this._c - var2)); for (var5 = 0; var5 < var4; ++var5) { this._b[var2++] = var3; } } } else { - final boolean var14 = SomeBufferReader_idk.readBit() != 0; + final boolean var14 = FmtVorbis.readBit() != 0; for (var3 = 0; var3 < this._c; ++var3) { - if (var14 && SomeBufferReader_idk.readBit() == 0) { + if (var14 && FmtVorbis.readBit() == 0) { this._b[var3] = 0; } else { - this._b[var3] = SomeBufferReader_idk.readBits(5) + 1; + this._b[var3] = FmtVorbis.readBits(5) + 1; } } } this.b797(); - var2 = SomeBufferReader_idk.readBits(4); + var2 = FmtVorbis.readBits(4); if (var2 > 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 float var15 = FmtVorbis.parseAsFloat(FmtVorbis.readBits(32)); + final float var16 = FmtVorbis.parseAsFloat(FmtVorbis.readBits(32)); + var5 = FmtVorbis.readBits(4) + 1; + final boolean var6 = FmtVorbis.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] = SomeBufferReader_idk.readBits(var5); + _e[var8] = FmtVorbis.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 = SomeBufferReader_idk.readBit() != 0 ? this._f[var1] : var1 + 1; + var1 = FmtVorbis.readBit() != 0 ? this._f[var1] : var1 + 1; } return ~this._f[var1]; } diff --git a/src/main/java/funorb/client/intro/JagexLogoIntroAnimation.java b/src/main/java/funorb/client/intro/JagexLogoIntroAnimation.java index da6b9b3..8ad3220 100644 --- a/src/main/java/funorb/client/intro/JagexLogoIntroAnimation.java +++ b/src/main/java/funorb/client/intro/JagexLogoIntroAnimation.java @@ -1,6 +1,6 @@ package funorb.client.intro; -import funorb.audio.SomeBufferReader_idk; +import funorb.audio.FmtVorbis; 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) { - SomeBufferReader_idk.b604(loader.getResource("headers.packvorbis", "")); - final SomeBufferReader_idk var2 = SomeBufferReader_idk.a968(loader, "jagex logo2.packvorbis", ""); + FmtVorbis.b604(loader.getResource("headers.packvorbis", "")); + final FmtVorbis var2 = FmtVorbis.a968(loader, "jagex logo2.packvorbis", ""); assert var2 != null; var2.b720(); } diff --git a/src/main/java/funorb/io/Buffer.java b/src/main/java/funorb/io/Buffer.java index 44ad707..a269045 100644 --- a/src/main/java/funorb/io/Buffer.java +++ b/src/main/java/funorb/io/Buffer.java @@ -125,7 +125,7 @@ public class Buffer implements ReadableBuffer, WritableBuffer { this.writeInt(computeCrc(this.data, startPos, this.pos)); } - public final int d410() { + public final int readBiasedVariable8_16() { final int nextByte = this.data[this.pos] & 255; if (nextByte < 128) { return this.readUByte() - 64; diff --git a/src/main/java/funorb/shatteredplans/client/JagexApplet.java b/src/main/java/funorb/shatteredplans/client/JagexApplet.java index f8a41ae..a9ed741 100644 --- a/src/main/java/funorb/shatteredplans/client/JagexApplet.java +++ b/src/main/java/funorb/shatteredplans/client/JagexApplet.java @@ -1218,7 +1218,7 @@ public abstract class JagexApplet extends JagexBaseApplet { if (var2 == 0) { shutdownServerConnection(); } else if (var2 == 1) { - var1.d410(); + var1.readBiasedVariable8_16(); shutdownServerConnection(); } else { clientError(null, "LR1: " + a738w()); diff --git a/src/main/java/funorb/shatteredplans/client/Sounds.java b/src/main/java/funorb/shatteredplans/client/Sounds.java index d684dd3..2d1d8b3 100644 --- a/src/main/java/funorb/shatteredplans/client/Sounds.java +++ b/src/main/java/funorb/shatteredplans/client/Sounds.java @@ -7,7 +7,7 @@ import funorb.audio.SoundEffect; import funorb.audio.SoundLoader; import funorb.audio.AudioSamplePlayback_idk; import funorb.audio.h_; -import funorb.audio.AudioSampleData_idk; +import funorb.audio.RawSampleS8; import funorb.audio.AudioSourceSum_idk; import funorb.cache.ResourceLoader; @@ -75,7 +75,7 @@ public final class Sounds { return play(effect.sample, effect.volume * volume / 96); } - private static PlayingSound play(final AudioSampleData_idk var1, final int volume) { + private static PlayingSound play(final RawSampleS8 var1, final int volume) { final AudioSamplePlayback_idk var01 = AudioSamplePlayback_idk.a638(var1, volume); assert var01 != null; final PlayingSound sound = new PlayingSound(var01);