Significant progress on AudioSamplePlayback

This commit is contained in:
Alex Iadicicco 2022-12-03 06:10:49 -08:00 committed by Alexis King
parent 28f6797686
commit ebe346235b
30 changed files with 2689 additions and 2590 deletions

View File

@ -0,0 +1,22 @@
package funorb.audio;
public final class AudioSampleData_idk {
public final int _k;
public final int _l;
public final int sampleRate;
public final byte[] data;
public final boolean _i;
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 int sampleRate, final byte[] data, final int var3, final int var4, final boolean var5) {
this.sampleRate = sampleRate;
this.data = data;
this._l = var3;
this._k = var4;
this._i = var5;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,38 @@
package funorb.audio;
import funorb.data.NodeList;
import org.jetbrains.annotations.NotNull;
import java.util.Iterator;
public final class AudioSourceSum_idk extends AudioSource_idk {
private final NodeList<AudioSource_idk> inner = new NodeList<>();
@Override
public @NotNull Iterator<AudioSource_idk> iterator() {
return this.inner.iterator();
}
@Override
public int a784() {
return 0;
}
@Override
public synchronized void processAndDiscard(final int len) {
for (final AudioSource_idk gen : this.inner) {
gen.processAndDiscard(len);
}
}
public synchronized void addFirst(final AudioSamplePlayback_idk var1) {
this.inner.addFirst(var1);
}
@Override
public synchronized void processAndWrite(final int[] dest, final int offset, final int len) {
for (final AudioSource_idk gen : this.inner) {
gen.processAndWriteIfEnabled(dest, offset, len);
}
}
}

View File

@ -0,0 +1,30 @@
package funorb.audio;
import funorb.data.NodeList;
public abstract class AudioSource_idk extends NodeList.Node implements Iterable<AudioSource_idk> {
public volatile boolean enabled = true;
public int _i;
public AudioSource_idk _h;
public AudioSampleData_idk sampleData;
protected AudioSource_idk() {}
public abstract void processAndWrite(int[] dest, int offset, int len);
public abstract void processAndDiscard(int len);
protected final void processAndWriteIfEnabled(final int[] dest, final int offset, final int len) {
if (this.enabled) {
this.processAndWrite(dest, offset, len);
} else {
this.processAndDiscard(len);
}
}
public abstract int a784();
public int c784() {
return 255;
}
}

View File

@ -1,6 +1,6 @@
package funorb.audio;
public final class kc_ {
public final class KeyParams_idk {
public int _j;
public int _c;
public int _a;
@ -9,5 +9,5 @@ public final class kc_ {
public int _k;
public byte[] _n;
public int _f;
public int _o;
public int vibratoPhaseSpeed_idk;
}

View File

@ -2,21 +2,21 @@ package funorb.audio;
import funorb.io.Buffer;
public final class br_ {
public final kk_[] _h = new kk_[128];
public final kc_[] _j = new kc_[128];
public final byte[] _t = new byte[128];
public final int _q;
public final short[] _k = new short[128];
public final byte[] _r = new byte[128];
public final byte[] _s = new byte[128];
private int[] _n = new int[128];
public final class MidiInstrument {
public final AudioSampleData_idk[] noteSample = new AudioSampleData_idk[128];
public final KeyParams_idk[] keyParams_idk = new KeyParams_idk[128];
public final byte[] notePan_idk = new byte[128];
public final int mainVolume_idk;
public final short[] noteTuning_idk = new short[128];
public final byte[] noteOffNote_idk = new byte[128];
public final byte[] noteVolume_idk = new byte[128];
private int[] noteSampleIds_idk = new int[128];
public br_(final byte[] var1) {
final Buffer var2 = new Buffer(var1);
public MidiInstrument(final byte[] instrumentData) {
final Buffer buf = new Buffer(instrumentData);
int var3 = 0;
while (var2.data[var3 + var2.pos] != 0) {
while (buf.data[var3 + buf.pos] != 0) {
++var3;
}
@ -24,16 +24,16 @@ public final class br_ {
int var5;
for (var5 = 0; var5 < var3; ++var5) {
var4[var5] = var2.readByte();
var4[var5] = buf.readByte();
}
++var3;
++var2.pos;
var5 = var2.pos;
var2.pos += var3;
++buf.pos;
var5 = buf.pos;
buf.pos += var3;
int var6 = 0;
while (var2.data[var6 + var2.pos] != 0) {
while (buf.data[var6 + buf.pos] != 0) {
++var6;
}
@ -41,27 +41,27 @@ public final class br_ {
int var8;
for (var8 = 0; var8 < var6; ++var8) {
var7[var8] = var2.readByte();
var7[var8] = buf.readByte();
}
++var2.pos;
++buf.pos;
++var6;
var8 = var2.pos;
var2.pos += var6;
var8 = buf.pos;
buf.pos += var6;
int var9 = 0;
while (var2.data[var9 + var2.pos] != 0) {
while (buf.data[var9 + buf.pos] != 0) {
++var9;
}
final byte[] var10 = new byte[var9];
for (int var11 = 0; var11 < var9; ++var11) {
var10[var11] = var2.readByte();
var10[var11] = buf.readByte();
}
++var9;
++var2.pos;
++buf.pos;
final byte[] var36 = new byte[var9];
int var12;
int var14;
@ -73,7 +73,7 @@ public final class br_ {
int var13 = 1;
for (var14 = 2; var9 > var14; ++var14) {
int var15 = var2.readUByte();
int var15 = buf.readUByte();
if (var15 == 0) {
var13 = var12++;
} else {
@ -88,30 +88,30 @@ public final class br_ {
}
}
final kc_[] var37 = new kc_[var12];
final KeyParams_idk[] var37 = new KeyParams_idk[var12];
kc_ var38;
KeyParams_idk var38;
for (var14 = 0; var14 < var37.length; ++var14) {
var38 = var37[var14] = new kc_();
final int var16 = var2.readUByte();
var38 = var37[var14] = new KeyParams_idk();
final int var16 = buf.readUByte();
if (var16 > 0) {
var38._n = new byte[var16 * 2];
}
final int j137 = var2.readUByte();
final int j137 = buf.readUByte();
if (j137 > 0) {
var38._e = new byte[2 * j137 + 2];
var38._e[1] = 64;
}
}
var14 = var2.readUByte();
var14 = buf.readUByte();
final byte[] var39 = var14 > 0 ? new byte[2 * var14] : null;
var14 = var2.readUByte();
var14 = buf.readUByte();
final byte[] var40 = var14 <= 0 ? null : new byte[var14 * 2];
int var17 = 0;
while (var2.data[var2.pos + var17] != 0) {
while (buf.data[buf.pos + var17] != 0) {
++var17;
}
@ -119,24 +119,24 @@ public final class br_ {
int var19;
for (var19 = 0; var19 < var17; ++var19) {
var18[var19] = var2.readByte();
var18[var19] = buf.readByte();
}
++var17;
++var2.pos;
++buf.pos;
var19 = 0;
int var20;
for (var20 = 0; var20 < 128; ++var20) {
var19 += var2.readUByte();
this._k[var20] = (short) var19;
var19 += buf.readUByte();
this.noteTuning_idk[var20] = (short) var19;
}
var19 = 0;
for (var20 = 0; var20 < 128; ++var20) {
var19 += var2.readUByte();
this._k[var20] = (short) (this._k[var20] + (var19 << 8));
var19 += buf.readUByte();
this.noteTuning_idk[var20] = (short) (this.noteTuning_idk[var20] + (var19 << 8));
}
var20 = 0;
@ -152,12 +152,12 @@ public final class br_ {
var20 = var18[var21++];
}
var22 = var2.readVariableInt();
var22 = buf.readVariableInt();
}
this._k[var23] = (short) (this._k[var23] + ((var22 - 1 & 2) << 14));
this.noteTuning_idk[var23] = (short) (this.noteTuning_idk[var23] + ((var22 - 1 & 2) << 14));
--var20;
this._n[var23] = var22;
this.noteSampleIds_idk[var23] = var22;
}
int i = 0;
@ -166,7 +166,7 @@ public final class br_ {
int var24;
for (var24 = 0; var24 < 128; ++var24) {
if (this._n[var24] != 0) {
if (this.noteSampleIds_idk[var24] != 0) {
if (var20 == 0) {
if (i < var4.length) {
var20 = var4[i++];
@ -174,11 +174,11 @@ public final class br_ {
var20 = -1;
}
var23 = var2.data[var5++] - 1;
var23 = buf.data[var5++] - 1;
}
--var20;
this._r[var24] = (byte) var23;
this.noteOffNote_idk[var24] = (byte) var23;
}
}
@ -187,7 +187,7 @@ public final class br_ {
var24 = 0;
for (int var25 = 0; var25 < 128; ++var25) {
if (this._n[var25] != 0) {
if (this.noteSampleIds_idk[var25] != 0) {
if (var20 == 0) {
if (i1 >= var7.length) {
var20 = -1;
@ -195,21 +195,21 @@ public final class br_ {
var20 = var7[i1++];
}
var24 = 16 + var2.data[var8++] << 2;
var24 = 16 + buf.data[var8++] << 2;
}
--var20;
this._t[var25] = (byte) var24;
this.notePan_idk[var25] = (byte) var24;
}
}
int i2 = 0;
var20 = 0;
kc_ var42 = null;
KeyParams_idk var42 = null;
int var26;
for (var26 = 0; var26 < 128; ++var26) {
if (this._n[var26] != 0) {
if (this.noteSampleIds_idk[var26] != 0) {
if (var20 == 0) {
var42 = var37[var36[i2]];
if (var10.length <= i2) {
@ -220,7 +220,7 @@ public final class br_ {
}
--var20;
this._j[var26] = var42;
this.keyParams_idk[var26] = var42;
}
}
@ -237,43 +237,43 @@ public final class br_ {
var20 = -1;
}
if (this._n[var27] > 0) {
var26 = var2.readUByte() + 1;
if (this.noteSampleIds_idk[var27] > 0) {
var26 = buf.readUByte() + 1;
}
}
--var20;
this._s[var27] = (byte) var26;
this.noteVolume_idk[var27] = (byte) var26;
}
this._q = var2.readUByte() + 1;
this.mainVolume_idk = buf.readUByte() + 1;
kc_ var28;
KeyParams_idk var28;
int var29;
for (var27 = 0; var27 < var12; ++var27) {
var28 = var37[var27];
if (var28._n != null) {
for (var29 = 1; var29 < var28._n.length; var29 += 2) {
var28._n[var29] = var2.readByte();
var28._n[var29] = buf.readByte();
}
}
if (var28._e != null) {
for (var29 = 3; var28._e.length - 2 > var29; var29 += 2) {
var28._e[var29] = var2.readByte();
var28._e[var29] = buf.readByte();
}
}
}
if (var39 != null) {
for (var27 = 1; var39.length > var27; var27 += 2) {
var39[var27] = var2.readByte();
var39[var27] = buf.readByte();
}
}
if (var40 != null) {
for (var27 = 1; var27 < var40.length; var27 += 2) {
var40[var27] = var2.readByte();
var40[var27] = buf.readByte();
}
}
@ -283,7 +283,7 @@ public final class br_ {
var19 = 0;
for (var29 = 2; var29 < var28._e.length; var29 += 2) {
var19 = var2.readUByte() + var19 + 1;
var19 = buf.readUByte() + var19 + 1;
var28._e[var29] = (byte) var19;
}
}
@ -295,7 +295,7 @@ public final class br_ {
var19 = 0;
for (var29 = 2; var29 < var28._n.length; var29 += 2) {
var19 = var2.readUByte() + var19 + 1;
var19 = buf.readUByte() + var19 + 1;
var28._n[var29] = (byte) var19;
}
}
@ -308,11 +308,11 @@ public final class br_ {
int var45;
byte var47;
if (var39 != null) {
var19 = var2.readUByte();
var19 = buf.readUByte();
var39[0] = (byte) var19;
for (var27 = 2; var27 < var39.length; var27 += 2) {
var19 = var2.readUByte() + var19 + 1;
var19 = buf.readUByte() + var19 + 1;
var39[var27] = (byte) var19;
}
@ -320,7 +320,7 @@ public final class br_ {
byte var43 = var39[1];
for (var29 = 0; var29 < var47; ++var29) {
this._s[var29] = (byte) (32 + this._s[var29] * var43 >> 6);
this.noteVolume_idk[var29] = (byte) (32 + this.noteVolume_idk[var29] * var43 >> 6);
}
for (var29 = 2; var29 < var39.length; var47 = var30) {
@ -330,7 +330,7 @@ public final class br_ {
for (var33 = var47; var30 > var33; ++var33) {
var34 = a666ql(var32, var30 - var47);
this._s[var33] = (byte) (32 + this._s[var33] * var34 >> 6);
this.noteVolume_idk[var33] = (byte) (32 + this.noteVolume_idk[var33] * var34 >> 6);
var32 += -var43 + var31;
}
@ -339,16 +339,16 @@ public final class br_ {
}
for (var45 = var47; var45 < 128; ++var45) {
this._s[var45] = (byte) (32 + this._s[var45] * var43 >> 6);
this.noteVolume_idk[var45] = (byte) (32 + this.noteVolume_idk[var45] * var43 >> 6);
}
}
if (var40 != null) {
var19 = var2.readUByte();
var19 = buf.readUByte();
var40[0] = (byte) var19;
for (var27 = 2; var40.length > var27; var27 += 2) {
var19 = 1 + var19 + var2.readUByte();
var19 = 1 + var19 + buf.readUByte();
var40[var27] = (byte) var19;
}
@ -356,7 +356,7 @@ public final class br_ {
int var44 = var40[1] << 1;
for (var29 = 0; var29 < var47; ++var29) {
var45 = (this._t[var29] & 255) + var44;
var45 = (this.notePan_idk[var29] & 255) + var44;
if (var45 < 0) {
var45 = 0;
}
@ -365,7 +365,7 @@ public final class br_ {
var45 = 128;
}
this._t[var29] = (byte) var45;
this.notePan_idk[var29] = (byte) var45;
}
int var46;
@ -376,7 +376,7 @@ public final class br_ {
for (var33 = var47; var33 < var30; ++var33) {
var34 = a666ql(var32, -var47 + var30);
int var35 = var34 + (255 & this._t[var33]);
int var35 = var34 + (255 & this.notePan_idk[var33]);
if (var35 < 0) {
var35 = 0;
}
@ -385,7 +385,7 @@ public final class br_ {
var35 = 128;
}
this._t[var33] = (byte) var35;
this.notePan_idk[var33] = (byte) var35;
var32 += -var44 + var46;
}
@ -394,7 +394,7 @@ public final class br_ {
}
for (var45 = var47; var45 < 128; ++var45) {
var46 = var44 + (this._t[var45] & 255);
var46 = var44 + (this.notePan_idk[var45] & 255);
if (var46 < 0) {
var46 = 0;
}
@ -403,44 +403,44 @@ public final class br_ {
var46 = 128;
}
this._t[var45] = (byte) var46;
this.notePan_idk[var45] = (byte) var46;
}
}
for (var27 = 0; var12 > var27; ++var27) {
var37[var27]._h = var2.readUByte();
var37[var27]._h = buf.readUByte();
}
for (var27 = 0; var12 > var27; ++var27) {
var28 = var37[var27];
if (var28._n != null) {
var28._k = var2.readUByte();
var28._k = buf.readUByte();
}
if (var28._e != null) {
var28._c = var2.readUByte();
var28._c = buf.readUByte();
}
if (var28._h > 0) {
var28._a = var2.readUByte();
var28._a = buf.readUByte();
}
}
for (var27 = 0; var27 < var12; ++var27) {
var37[var27]._o = var2.readUByte();
var37[var27].vibratoPhaseSpeed_idk = buf.readUByte();
}
for (var27 = 0; var12 > var27; ++var27) {
var28 = var37[var27];
if (var28._o > 0) {
var28._f = var2.readUByte();
if (var28.vibratoPhaseSpeed_idk > 0) {
var28._f = buf.readUByte();
}
}
for (var27 = 0; var12 > var27; ++var27) {
var28 = var37[var27];
if (var28._f > 0) {
var28._j = var2.readUByte();
var28._j = buf.readUByte();
}
}
@ -451,40 +451,40 @@ public final class br_ {
return -var2 + (var0 + var2) / var1;
}
public boolean a972(final SoundLoader var1, final byte[] var2) {
boolean var5 = true;
public boolean loadNoteSamples(final SoundLoader loader, final byte[] restrictNotes) {
boolean success = true;
int var6 = 0;
kk_ var7 = null;
AudioSampleData_idk sampleData = null;
for (int var8 = 0; var8 < 128; ++var8) {
if (var2 == null || var2[var8] != 0) {
int var9 = this._n[var8];
if (var9 != 0) {
if (var9 != var6) {
var6 = var9--;
if ((1 & var9) == 0) {
var7 = var1.loadSingleton1(var9 >> 2);
for (int noteNumber = 0; noteNumber < 128; ++noteNumber) {
if (restrictNotes == null || restrictNotes[noteNumber] != 0) {
int sampleId = this.noteSampleIds_idk[noteNumber];
if (sampleId != 0) {
if (sampleId != var6) {
var6 = sampleId--;
if ((1 & sampleId) == 0) {
sampleData = loader.loadSingleton1(sampleId >> 2);
} else {
var7 = var1.loadSingleton2(var9 >> 2);
sampleData = loader.loadSingleton2(sampleId >> 2);
}
if (var7 == null) {
var5 = false;
if (sampleData == null) {
success = false;
}
}
if (var7 != null) {
this._h[var8] = var7;
this._n[var8] = 0;
if (sampleData != null) {
this.noteSample[noteNumber] = sampleData;
this.noteSampleIds_idk[noteNumber] = 0;
}
}
}
}
return var5;
return success;
}
public void e150() {
this._n = null;
this.noteSampleIds_idk = null;
}
}

View File

@ -0,0 +1,841 @@
package funorb.audio;
import funorb.cache.ResourceLoader;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public final class MidiPlayer extends AudioSource_idk {
private static final double PHASE_512_TO_RADIANS = 0.01227184630308513D;
public static final int FLAG_SUSTAIN = 0x0001;
public static final int FLAG_PORTAMENTO = 0x0002;
public static final int FLAG_GENERAL_6 = 0x0004;
public final int[] chGeneral1 = new int[16];
public final int[] chFlags = new int[16];
private final int[] chModWheel = new int[16];
private final int[] chVolume = new int[16];
private final int[] chRpn = new int[16];
private final MidiPlayerNoteState_idk[][] noteStates = new MidiPlayerNoteState_idk[16][128];
private final int[] chPitchBendRange = new int[16];
private final int[] chDefaultBank_idk = new int[16];
private final Map<Integer, MidiInstrument> instruments;
private final int[] chPan = new int[16];
private final MidiReader midiReader = new MidiReader();
private final int[] chCurrentProgram = new int[16];
private final int[] chBank = new int[16];
private final int[] chGeneral2 = new int[16];
private final int[] chPortaTime = new int[16];
private final int[] chVolumeAgainForSomeReason_idk = new int[16];
private final int[] chPitchWheel = new int[16];
private final MidiPlayerNoteSet_idk noteSet = new MidiPlayerNoteSet_idk(this);
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 final int[] chExpression = new int[16];
private int trackWithSoonestEvent;
private long _O;
private int nextEventTicks;
private long currentPlayTime;
private boolean _v;
private SongData _z;
public MidiPlayer() {
this.instruments = new HashMap<>();
this.a679();
this.handleMidiMetaEvent(true);
}
@SuppressWarnings("CopyConstructorMissesField")
public MidiPlayer(final MidiPlayer copyInstruments) {
this.instruments = copyInstruments.instruments;
this.a679();
this.handleMidiMetaEvent(true);
}
private static MidiInstrument loadInstrument(final ResourceLoader loader, final int instrumentId) {
final byte[] instrumentData = loader.getSingletonResource(instrumentId);
return instrumentData == null ? null : new MidiInstrument(instrumentData);
}
public synchronized void e150() {
this.b430(true);
}
private void handlePitchWheel(final int channel, final int value) {
this.chPitchWheel[channel] = value;
}
@Override
public @NotNull Iterator<AudioSource_idk> iterator() {
return Collections.<AudioSource_idk>singletonList(this.noteSet).iterator();
}
private void handleGeneral2(final int value, final int channel) {
this.chGeneral2[channel] = value;
this._u[channel] = (int) (0.5D + 2097152.0D * Math.pow(2.0D, 5.4931640625E-4D * (double) value));
}
private int calcPitchX_idk(final MidiPlayerNoteState_idk note) {
int var3 = (note._pitch_fac_1 * note._pitch_fac_2 >> 12) + note.pitch_idk;
var3 += this.chPitchBendRange[note.channel] * (this.chPitchWheel[note.channel] - 8192) >> 12;
final KeyParams_idk var4 = note.keyParams_idk;
int pitch;
if (var4.vibratoPhaseSpeed_idk > 0 && (var4._f > 0 || this.chModWheel[note.channel] > 0)) {
pitch = var4._f << 2;
final int var7 = var4._j << 1;
if (var7 > note._C) {
pitch = note._C * pitch / var7;
}
pitch += this.chModWheel[note.channel] >> 7;
final double vibrato = Math.sin((double) (note.vibratoPhase_idk & 0x1ff) * PHASE_512_TO_RADIANS);
var3 += (int) ((double) pitch * vibrato);
}
pitch = (int) ((double) (256 * note.sampleData.sampleRate) * Math.pow(2.0D, 3.255208333333333E-4D * (double) var3) / (double) SampledAudioChannel.SAMPLES_PER_SECOND + 0.5D);
return Math.max(pitch, 1);
}
public synchronized void f150() {
for (final MidiInstrument instr : this.instruments.values()) {
instr.e150();
}
}
private void handleAllNotesOff(final int var1) {
for (final MidiPlayerNoteState_idk state : this.noteSet.notes) {
if ((var1 < 0 || state.channel == var1) && state.notePlaying_idfk < 0) {
this.noteStates[state.channel][state.note] = null;
state.notePlaying_idfk = 0;
}
}
}
private void handleNoteOff(final int channel, final int note) {
final MidiPlayerNoteState_idk state = this.noteStates[channel][note];
if (state != null) {
this.noteStates[channel][note] = null;
if ((FLAG_PORTAMENTO & this.chFlags[channel]) == 0) {
state.notePlaying_idfk = 0;
} else if (this.noteSet.notes.stream().anyMatch(var6 -> state.channel == var6.channel && var6.notePlaying_idfk < 0 && var6 != state)) {
state.notePlaying_idfk = 0;
}
}
}
public synchronized void c430() {
this._M = 1000000;
}
public synchronized void a679() {
for (int channel = 0; channel < 16; ++channel) {
this.chVolumeAgainForSomeReason_idk[channel] = 256;
}
}
public synchronized void a350(final SoundLoader soundLoader, final ResourceLoader loader, final SongData track) {
track.analyzeNotesUsedPerProgram();
boolean success = true;
for (final Map.Entry<Integer, byte[]> notesUsed : track.notesUsedPerProgram.entrySet()) {
final int programNumber = notesUsed.getKey();
MidiInstrument instrument = this.instruments.get(programNumber);
if (instrument == null) {
instrument = loadInstrument(loader, programNumber);
if (instrument == null) {
success = false;
continue;
}
this.instruments.put(programNumber, instrument);
}
if (!instrument.loadNoteSamples(soundLoader, notesUsed.getValue())) {
success = false;
}
}
if (success) {
track.resetNotesUsedPerProgram();
}
}
@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;
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.noteSet.processAndWrite(dest, offset, var7);
offset += var7;
len -= var7;
this.a423();
} while (this.midiReader.isLoaded());
}
this.noteSet.processAndWrite(dest, offset, len);
}
@Override
public synchronized void processAndDiscard(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.currentPlayTime - var3 >= 0L) {
this._O = var3;
break;
}
final int var5 = (int) ((-1L - this._O + this.currentPlayTime + (long) var2) / (long) var2);
this._O += (long) var5 * (long) var2;
this.noteSet.processAndDiscard(var5);
len -= var5;
this.a423();
} while (this.midiReader.isLoaded());
}
this.noteSet.processAndDiscard(len);
}
@SuppressWarnings("SameParameterValue")
public synchronized void setVolume(final int volume) {
this.volume = volume;
}
private synchronized void b430(final boolean var2) {
this.midiReader.unload();
this._z = null;
this.handleMidiMetaEvent(var2);
}
private void handleAllSoundOff(final int channel) {
for (final MidiPlayerNoteState_idk note : this.noteSet.notes) {
if (channel < 0 || channel == note.channel) {
if (note.playback != null) {
note.playback.g150(SampledAudioChannel.SAMPLES_PER_SECOND / 100);
if (note.playback.volDeltaNonZero()) {
this.noteSet.sum.addFirst(note.playback);
}
note.reset_idk();
}
if (note.notePlaying_idfk < 0) {
this.noteStates[note.channel][note.note] = null;
}
note.unlink();
}
}
}
private void handlePortamentoOff(final int channel) {
if ((FLAG_PORTAMENTO & this.chFlags[channel]) != 0) {
for (final MidiPlayerNoteState_idk var3 : this.noteSet.notes) {
if (var3.channel == channel && this.noteStates[channel][var3.note] == null && var3.notePlaying_idfk < 0) {
var3.notePlaying_idfk = 0;
}
}
}
}
public synchronized void a077(final SongData var1, final boolean var3) {
this.a918(var3, var1, true);
}
private void handleResetAllControllers(int channel) {
if (channel >= 0) {
this.chVolume[channel] = 12800;
this.chPan[channel] = 8192;
this.chExpression[channel] = 16383;
this.chPitchWheel[channel] = 8192;
this.chModWheel[channel] = 0;
this.chPortaTime[channel] = 8192;
this.handlePortamentoOff(channel);
this.handleGeneral6Off(channel);
this.chFlags[channel] = 0;
this.chRpn[channel] = 32767;
this.chPitchBendRange[channel] = 256;
this.chGeneral1[channel] = 0;
this.handleGeneral2(8192, channel);
} else {
for (channel = 0; channel < 16; ++channel) {
this.handleResetAllControllers(channel);
}
}
}
private void handleMidiMetaEvent(final boolean var2) {
if (var2) {
this.handleAllSoundOff(-1);
} else {
this.handleAllNotesOff(-1);
}
this.handleResetAllControllers(-1);
int channel;
for (channel = 0; channel < 16; ++channel) {
this.chCurrentProgram[channel] = this.chDefaultBank_idk[channel];
}
for (channel = 0; channel < 16; ++channel) {
this.chBank[channel] = this.chDefaultBank_idk[channel] & 0xffffff80;
}
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean a258(final MidiPlayerNoteState_idk note) {
if (note.playback == null) {
if (note.notePlaying_idfk >= 0) {
note.unlink();
if (note.noteOffNote_idk > 0 && note == this.noteOffStates_idk[note.channel][note.noteOffNote_idk]) {
this.noteOffStates_idk[note.channel][note.noteOffNote_idk] = null;
}
}
return true;
} else {
return false;
}
}
private void handleMidiEvent(final int event) {
switch (event & 0xf0) {
case 0x80: { // note off
this.handleNoteOff(0xf & event, (0x7fa0 & event) >> 8);
break;
}
case 0x90: { // note on
final int channel = event & 0xf;
final int note = (event >> 8) & 0x7f;
final int velocity = 0x7f & (event >> 16);
if (velocity > 0) {
this.handleNoteOn(note, channel, velocity);
} else {
this.handleNoteOff(channel, note);
}
break;
}
case 0xa0: // polyphonic aftertouch
case 0xd0: // channel aftertouch
break;
case 0xb0: { // control change
final int channel = 0xf & event;
final int controller = 0x7f & (event >> 8);
final int value = 0x7f & (event >> 16);
if (controller == 0) { // bank switch msb
this.chBank[channel] = (value << 14) + (0xffe03fff & this.chBank[channel]);
}
if (controller == 32) { // bank switch lsb
this.chBank[channel] = (value << 7) + (0xffffc07f & this.chBank[channel]);
}
if (controller == 1) { // mod wheel msb
this.chModWheel[channel] = (0xffffc07f & this.chModWheel[channel]) + (value << 7);
}
if (controller == 33) { // mod wheel lsb
this.chModWheel[channel] = value + (this.chModWheel[channel] & 0xffffff80);
}
if (controller == 5) { // portamento time msb
this.chPortaTime[channel] = (0xffffc07f & this.chPortaTime[channel]) + (value << 7);
}
if (controller == 37) { // portamento time lsb
this.chPortaTime[channel] = value + (this.chPortaTime[channel] & 0xffffff80);
}
if (controller == 7) { // volume msb
this.chVolume[channel] = (value << 7) + (0xffffc07f & this.chVolume[channel]);
}
if (controller == 39) { // volume lsb
this.chVolume[channel] = (0xffffff80 & this.chVolume[channel]) + value;
}
if (controller == 10) { // pan msb
this.chPan[channel] = (value << 7) + (this.chPan[channel] & 0xffffc07f);
}
if (controller == 42) { // pan lsb
this.chPan[channel] = (this.chPan[channel] & 0xffffff80) + value;
}
if (controller == 11) { // expression msb
this.chExpression[channel] = (value << 7) + (0xffffc07f & this.chExpression[channel]);
}
if (controller == 43) { // expression lsb
this.chExpression[channel] = value + (this.chExpression[channel] & 0xffffff80);
}
if (controller == 64) { // sustain on/off
if (value >= 64) {
this.chFlags[channel] = this.chFlags[channel] | FLAG_SUSTAIN;
} else {
this.chFlags[channel] = this.chFlags[channel] & ~FLAG_SUSTAIN;
}
}
if (controller == 65) { // portamento on/off
if (value >= 64) {
this.chFlags[channel] = this.chFlags[channel] | FLAG_PORTAMENTO;
} else {
this.handlePortamentoOff(channel);
this.chFlags[channel] = this.chFlags[channel] & ~FLAG_PORTAMENTO;
}
}
if (controller == 99) { // nrpn msb
this.chRpn[channel] = (value << 7) + (0x7f & this.chRpn[channel]);
}
if (controller == 98) { // nrpn lsb
this.chRpn[channel] = value + (0x3f80 & this.chRpn[channel]);
}
if (controller == 101) { // rpn msb
this.chRpn[channel] = (this.chRpn[channel] & 0x7f) + 0x4000 + (value << 7);
}
if (controller == 100) { // rpn lsb
this.chRpn[channel] = 0x4000 + (this.chRpn[channel] & 0x3f80) + value;
}
if (controller == 120) {
this.handleAllSoundOff(channel);
}
if (controller == 121) {
this.handleResetAllControllers(channel);
}
if (controller == 123) {
this.handleAllNotesOff(channel);
}
if (controller == 6) { // data entry msb
int rpn = this.chRpn[channel];
if (rpn == 0x4000) {
this.chPitchBendRange[channel] = (this.chPitchBendRange[channel] & 0xffffc07f) + (value << 7);
}
}
if (controller == 38) { // data entry lsb
int rpn = this.chRpn[channel];
if (rpn == 0x4000) {
this.chPitchBendRange[channel] = value + (this.chPitchBendRange[channel] & 0xffffff80);
}
}
if (controller == 16) { // gp controller #1 msb
this.chGeneral1[channel] = (value << 7) + (this.chGeneral1[channel] & 0xffffc07f);
}
if (controller == 48) { // gp controller #1 lsb
this.chGeneral1[channel] = (this.chGeneral1[channel] & 0xffffff80) + value;
}
if (controller == 81) { // gp controller #6 lsb
if (value >= 64) {
this.chFlags[channel] = this.chFlags[channel] | FLAG_GENERAL_6;
} else {
this.handleGeneral6Off(channel);
this.chFlags[channel] = this.chFlags[channel] & ~FLAG_GENERAL_6;
}
}
if (controller == 17) { // gp controller #2 msb
this.handleGeneral2((value << 7) + (0xffffc07f & this.chGeneral2[channel]), channel);
}
if (controller == 49) { // gp controller #2 lsb
this.handleGeneral2((this.chGeneral2[channel] & 0xffffff80) + value, channel);
}
break;
}
case 0xc0: { // program change
final int channel = event & 0xf;
final int program = (0x7f39 & event) >> 8;
this.handleProgramChange(channel, this.chBank[channel] + program);
break;
}
case 0xe0: { // pitch wheel
final int channel = 0xf & event;
final int value = (0x7f & event >> 8) + (event >> 9 & 0x3f80);
this.handlePitchWheel(channel, value);
break;
}
default: {
if ((event & 255) == 255) {
this.handleMidiMetaEvent(true);
}
break;
}
}
}
@Override
public synchronized int a784() {
return 0;
}
private synchronized void a918(final boolean var1, final SongData songData, final boolean var4) {
this.b430(var4);
this.midiReader.load(songData.midiData);
this._v = var1;
this._O = 0L;
final int numTracks = this.midiReader.numTracks();
for (int track = 0; track < numTracks; ++track) {
this.midiReader.setCursorToTrackPlaybackPos(track);
this.midiReader.advanceTrackTicks(track);
this.midiReader.setTrackPlaybackPosToCursor(track);
}
this.trackWithSoonestEvent = this.midiReader.trackWithSoonestNextTick();
this.nextEventTicks = this.midiReader.trackNextTick[this.trackWithSoonestEvent];
this.currentPlayTime = this.midiReader.getPlayTime(this.nextEventTicks);
}
private void handleGeneral6Off(final int var2) {
if ((FLAG_GENERAL_6 & this.chFlags[var2]) != 0) {
for (final MidiPlayerNoteState_idk var3 : this.noteSet.notes) {
if (var3.channel == var2) {
var3._j = 0;
}
}
}
}
private void handleNoteOn(final int noteNumber, final int channel, final int velocity) {
this.handleNoteOff(channel, noteNumber);
if ((this.chFlags[channel] & FLAG_PORTAMENTO) != 0) {
for (final Iterator<MidiPlayerNoteState_idk> it = this.noteSet.notes.descendingIterator(); it.hasNext(); ) {
final MidiPlayerNoteState_idk note = it.next();
if (note.channel == channel && note.notePlaying_idfk < 0) {
this.noteStates[channel][note.note] = null;
this.noteStates[channel][noteNumber] = note;
final int var6 = (note._pitch_fac_2 * note._pitch_fac_1 >> 12) + note.pitch_idk;
note.pitch_idk += -note.note + noteNumber << 8;
note._pitch_fac_2 = 4096;
note._pitch_fac_1 = -note.pitch_idk + var6;
note.note = noteNumber;
return;
}
}
}
final MidiInstrument instrument = this.instruments.get(this.chCurrentProgram[channel]);
if (instrument != null) {
final AudioSampleData_idk sample = instrument.noteSample[noteNumber];
if (sample != null) {
final MidiPlayerNoteState_idk note = new MidiPlayerNoteState_idk();
note.channel = channel;
note.instrument = instrument;
note.sampleData = sample;
note.keyParams_idk = instrument.keyParams_idk[noteNumber];
note.noteOffNote_idk = instrument.noteOffNote_idk[noteNumber];
note.note = noteNumber;
note.volume_idk = instrument.noteVolume_idk[noteNumber] * velocity * velocity * instrument.mainVolume_idk + 1024 >> 11;
note.pan_idk = instrument.notePan_idk[noteNumber] & 255;
note.pitch_idk = (noteNumber << 8) - (instrument.noteTuning_idk[noteNumber] & 32767);
note._B = 0;
note.notePlaying_idfk = -1;
note._F = 0;
note._h = 0;
note._v = 0;
if (this.chGeneral1[channel] == 0) {
note.playback = AudioSamplePlayback_idk.start(sample, this.calcPitchX_idk(note), this.calcVolumeX_idk(note), this.calcPanX_idk(note));
} else {
note.playback = AudioSamplePlayback_idk.start(sample, this.calcPitchX_idk(note), 0, this.calcPanX_idk(note));
this.a559(note, instrument.noteTuning_idk[noteNumber] < 0);
}
if (instrument.noteTuning_idk[noteNumber] < 0) {
assert note.playback != null;
note.playback.f150();
}
if (note.noteOffNote_idk >= 0) {
final MidiPlayerNoteState_idk noteOff = this.noteOffStates_idk[channel][note.noteOffNote_idk];
if (noteOff != null && noteOff.notePlaying_idfk < 0) {
this.noteStates[channel][noteOff.note] = null;
noteOff.notePlaying_idfk = 0;
}
this.noteOffStates_idk[channel][note.noteOffNote_idk] = note;
}
this.noteSet.notes.addLast(note);
this.noteStates[channel][noteNumber] = note;
}
}
}
@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()) {
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);
if (var6 < 0) {
var6 = 0;
}
var4._pitch_fac_2 = var6;
}
var4.playback.d150(this.calcPitchX_idk(var4));
final KeyParams_idk var7 = var4.keyParams_idk;
var4.vibratoPhase_idk += var7.vibratoPhaseSpeed_idk;
++var4._C;
boolean var8 = false;
final double var9 = 5.086263020833333E-6D * (double) ((var4.note - 60 << 8) + (var4._pitch_fac_2 * var4._pitch_fac_1 >> 12));
if (var7._h > 0) {
if (var7._a > 0) {
var4._h += (int) (Math.pow(2.0D, var9 * (double) var7._a) * 128.0D + 0.5D);
} else {
var4._h += 128;
}
if (var7._h * var4._h >= 819200) {
var8 = true;
}
}
if (var7._n != null) {
if (var7._k <= 0) {
var4._F += 128;
} else {
var4._F += (int) (0.5D + Math.pow(2.0D, var9 * (double) var7._k) * 128.0D);
}
while (var4._B < var7._n.length - 2 && ('\uff00' & var7._n[2 + var4._B] << 8) < var4._F) {
var4._B += 2;
}
if (var7._n.length - 2 == var4._B && var7._n[1 + var4._B] == 0) {
var8 = true;
}
}
if (var4.notePlaying_idfk >= 0 && var7._e != null && (FLAG_SUSTAIN & this.chFlags[var4.channel]) == 0 && (var4.noteOffNote_idk < 0 || this.noteOffStates_idk[var4.channel][var4.noteOffNote_idk] != var4)) {
if (var7._c <= 0) {
var4.notePlaying_idfk += 128;
} else {
var4.notePlaying_idfk += (int) (0.5D + 128.0D * Math.pow(2.0D, (double) var7._c * var9));
}
while (var4._v < var7._e.length - 2 && var4.notePlaying_idfk > (255 & var7._e[2 + var4._v]) << 8) {
var4._v += 2;
}
if (var7._e.length - 2 == var4._v) {
var8 = true;
}
}
if (var8) {
var4.playback.g150(var4._p);
if (var2 == null) {
var4.playback.processAndDiscard(var5);
} else {
var4.playback.processAndWrite(var2, var1, var5);
}
if (var4.playback.volDeltaNonZero()) {
this.noteSet.sum.addFirst(var4.playback);
}
var4.reset_idk();
if (var4.notePlaying_idfk >= 0) {
var4.unlink();
if (var4.noteOffNote_idk > 0 && this.noteOffStates_idk[var4.channel][var4.noteOffNote_idk] == var4) {
this.noteOffStates_idk[var4.channel][var4.noteOffNote_idk] = null;
}
}
return true;
} else {
var4.playback.a326(var4._p, this.calcVolumeX_idk(var4), this.calcPanX_idk(var4));
return false;
}
} else {
var4.reset_idk();
var4.unlink();
if (var4.noteOffNote_idk > 0 && this.noteOffStates_idk[var4.channel][var4.noteOffNote_idk] == var4) {
this.noteOffStates_idk[var4.channel][var4.noteOffNote_idk] = null;
}
return true;
}
}
private void handleProgramChange(final int channel, final int program) {
if (program != this.chCurrentProgram[channel]) {
this.chCurrentProgram[channel] = program;
for (int i = 0; i < 128; ++i) {
this.noteOffStates_idk[channel][i] = null;
}
}
}
private int calcPanX_idk(final MidiPlayerNoteState_idk note) {
final int midiPan = this.chPan[note.channel];
return midiPan >= 8192
? -(32 + (128 - note.pan_idk) * (-midiPan + 16384) >> 6) + 16384
: 32 + note.pan_idk * midiPan >> 6;
}
private void a423() {
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 (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 || ticks == 0) {
this.handleMidiMetaEvent(true);
this.midiReader.unload();
return;
}
this.midiReader.resetPlayback(var4);
}
break;
}
if ((event & 128) != 0) {
this.handleMidiEvent(event);
}
this.midiReader.advanceTrackTicks(track);
this.midiReader.setTrackPlaybackPosToCursor(track);
}
track = this.midiReader.trackWithSoonestNextTick();
ticks = this.midiReader.trackNextTick[track];
var4 = this.midiReader.getPlayTime(ticks);
}
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 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) {
note.playback.setPitchXNegAbs_idk();
var5 = -var5 + var4 + var4 - 1;
}
} else {
var5 = (int) ((long) this.chGeneral1[note.channel] * (long) var4 >> 6);
}
note.playback.h150(var5);
}
private int calcVolumeX_idk(final MidiPlayerNoteState_idk note) {
if (this.chVolumeAgainForSomeReason_idk[note.channel] == 0) {
return 0;
}
final KeyParams_idk keyParams = note.keyParams_idk;
int x = this.chVolume[note.channel] * this.chExpression[note.channel] + 4096 >> 13;
x = x * x + 16384 >> 15;
x = note.volume_idk * x + 16384 >> 15;
x = 128 + this.volume * x >> 8;
x = this.chVolumeAgainForSomeReason_idk[note.channel] * x + 128 >> 8;
if (keyParams._h > 0) {
x = (int) (0.5D + (double) x * Math.pow(0.5D, (double) note._h * 1.953125E-5D * (double) keyParams._h));
}
int var5;
int var6;
int var7;
int var8;
if (keyParams._n != null) {
var5 = note._F;
var6 = keyParams._n[1 + note._B];
if (note._B < keyParams._n.length - 2) {
var7 = keyParams._n[note._B] << 8 & '\uff00';
var8 = (255 & keyParams._n[2 + note._B]) << 8;
var6 += (-var6 + keyParams._n[note._B + 3]) * (-var7 + var5) / (-var7 + var8);
}
x = var6 * x + 32 >> 6;
}
if (note.notePlaying_idfk > 0 && keyParams._e != null) {
var5 = note.notePlaying_idfk;
var6 = keyParams._e[1 + note._v];
if (keyParams._e.length - 2 > note._v) {
var7 = (255 & keyParams._e[note._v]) << 8;
var8 = keyParams._e[2 + note._v] << 8 & '\uff00';
var6 += (keyParams._e[note._v + 3] - var6) * (-var7 + var5) / (-var7 + var8);
}
x = 32 + x * var6 >> 6;
}
return x;
}
public synchronized void initialize() {
this.chDefaultBank_idk[9] = 128;
this.chBank[9] = 128;
this.handleProgramChange(9, 128);
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public synchronized boolean h154() {
return this.midiReader.isLoaded();
}
}

View File

@ -0,0 +1,147 @@
package funorb.audio;
import funorb.data.NodeList;
import org.jetbrains.annotations.NotNull;
import java.util.Iterator;
import java.util.Objects;
public final class MidiPlayerNoteSet_idk extends AudioSource_idk {
public final NodeList<MidiPlayerNoteState_idk> notes = new NodeList<>();
public final AudioSourceSum_idk sum = new AudioSourceSum_idk();
private final MidiPlayer midiPlayer;
public MidiPlayerNoteSet_idk(final MidiPlayer midiPlayer) {
this.midiPlayer = midiPlayer;
}
@Override
public @NotNull Iterator<AudioSource_idk> iterator() {
return this.notes.stream().<AudioSource_idk>map(var1 -> var1.playback).filter(Objects::nonNull).iterator();
}
@Override
public int a784() {
return 0;
}
@Override
public void processAndDiscard(final int len) {
this.sum.processAndDiscard(len);
for (final MidiPlayerNoteState_idk note : this.notes) {
if (!this.midiPlayer.a258(note)) {
int var2 = len;
do {
if (note._p >= var2) {
this.a222(note, var2);
note._p -= var2;
break;
}
this.a222(note, note._p);
var2 -= note._p;
} while (!this.midiPlayer.a543(0, null, note, var2));
}
}
}
@Override
public void processAndWrite(final int[] dest, final int offset, final int len) {
this.sum.processAndWrite(dest, offset, len);
for (final MidiPlayerNoteState_idk note : this.notes) {
if (!this.midiPlayer.a258(note)) {
int var4 = offset;
int var5 = len;
do {
if (note._p >= var5) {
this.a829(dest, var4, note, var5, var4 + var5);
note._p -= var5;
break;
}
this.a829(dest, var4, note, note._p, var4 + var5);
var5 -= note._p;
var4 += note._p;
} while (!this.midiPlayer.a543(var4, dest, note, var5));
}
}
}
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());
} 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);
}
if (var2.instrument.noteTuning_idk[var2.note] < 0) {
assert var2.playback != null;
var2.playback.f150();
}
var3 = var2._j / var4;
}
}
assert var2.playback != null;
var2.playback.processAndDiscard(var3);
}
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;
while (true) {
final int var8 = (-var3._j + 1048575 + var7) / var7;
if (var8 > var4) {
var3._j += var7 * var4;
break;
}
var3.playback.processAndWrite(var1, var2, var8);
var3._j += var8 * var7 - 1048576;
var2 += var8;
var4 -= var8;
int var9 = SampledAudioChannel.SAMPLES_PER_SECOND / 100;
final int var10 = 262144 / 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());
} 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());
}
if (var3.instrument.noteTuning_idk[var3.note] < 0) {
assert var3.playback != null;
var3.playback.f150();
}
var11.g150(var9);
var11.processAndWrite(var1, var2, var6 - var2);
if (var11.volDeltaNonZero()) {
this.sum.addFirst(var11);
}
}
}
var3.playback.processAndWrite(var1, var2, var4);
}
}

View File

@ -0,0 +1,35 @@
package funorb.audio;
import funorb.data.NodeList;
public final class MidiPlayerNoteState_idk extends NodeList.Node {
/** seems to be -1 for active and 0 for inactive... ??? */
public int notePlaying_idfk;
public int _pitch_fac_2;
public int _v;
public int _F;
public int note;
public AudioSampleData_idk sampleData;
public KeyParams_idk keyParams_idk;
public AudioSamplePlayback_idk playback;
public MidiInstrument instrument;
public int _j;
public int _pitch_fac_1;
public int _C;
public int pan_idk;
public int channel;
public int pitch_idk;
public int _h;
public int noteOffNote_idk;
public int volume_idk;
public int _p;
public int _B;
public int vibratoPhase_idk;
public void reset_idk() {
this.instrument = null;
this.playback = null;
this.sampleData = null;
this.keyParams_idk = null;
}
}

View File

@ -1,845 +0,0 @@
package funorb.audio;
import funorb.cache.ResourceLoader;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
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 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 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];
private final int[] _J = new int[16];
private final int[] _A = new int[16];
private final int[] _T = new int[16];
private final rc_ _l = new rc_(this);
public final int[] _u = new int[16];
private int volume = 256;
private final MixerTrackConfig_idk[][] _K = new MixerTrackConfig_idk[16][128];
private int _M = 1000000;
private final int[] _s = new int[16];
private int trackWithSoonestEvent;
private long _O;
private int nextEventTicks;
private long currentPlayTime;
private boolean _v;
private SongData _z;
public MidiPlayer_idk() {
this._Q = new HashMap<>();
this.a679();
this.a430(true);
}
@SuppressWarnings("CopyConstructorMissesField")
public MidiPlayer_idk(final MidiPlayer_idk var1) {
this._Q = var1._Q;
this.a679();
this.a430(true);
}
private static br_ a675cf(final ResourceLoader var0, final int var1) {
final byte[] var2 = var0.getSingletonResource(var1);
return var2 == null ? null : new br_(var2);
}
public synchronized void e150() {
this.b430(true);
}
private void b789(final int var1, final int var3) {
this._T[var1] = var3;
}
@Override
public @NotNull Iterator<MixerInterface_idk> iterator() {
return Collections.<MixerInterface_idk>singletonList(this._l).iterator();
}
private void a326(final int var2, final int var3) {
this._E[var3] = var2;
this._u[var3] = (int) (0.5D + 2097152.0D * Math.pow(2.0D, 5.4931640625E-4D * (double) var2));
}
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;
int var6;
if (var4._o > 0 && (var4._f > 0 || this._p[var1._y] > 0)) {
var6 = var4._f << 2;
final int var7 = var4._j << 1;
if (var7 > var1._C) {
var6 = var1._C * var6 / var7;
}
var6 += this._p[var1._y] >> 7;
final double var8 = Math.sin((double) (var1._i & 511) * 0.01227184630308513D);
var3 += (int) ((double) var6 * var8);
}
var6 = (int) ((double) (256 * var1._M._j) * Math.pow(2.0D, 3.255208333333333E-4D * (double) var3) / (double) SampledAudioChannel.SAMPLES_PER_SECOND + 0.5D);
return Math.max(var6, 1);
}
public synchronized void f150() {
for (final br_ var2 : this._Q.values()) {
var2.e150();
}
}
private void a093(final int var1) {
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;
}
}
}
private void a172(final int var3, final int var4) {
final MixerTrackConfig_idk var5 = this._N[var3][var4];
if (var5 != null) {
this._N[var3][var4] = null;
if ((2 & this._F[var3]) == 0) {
var5._E = 0;
} else if (this._l._n.stream().anyMatch(var6 -> var5._y == var6._y && var6._E < 0 && var6 != var5)) {
var5._E = 0;
}
}
}
public synchronized void c430() {
this._M = 1000000;
}
public synchronized void a679() {
for (int var4 = 0; var4 < 16; ++var4) {
this._A[var4] = 256;
}
}
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.notesUsedPerProgram.entrySet()) {
final int var9 = var8.getKey();
br_ var10 = this._Q.get(var9);
if (var10 == null) {
var10 = a675cf(loader, var9);
if (var10 == null) {
var6 = false;
continue;
}
this._Q.put(var9, var10);
}
if (!var10.a972(soundLoader, var8.getValue())) {
var6 = false;
}
}
if (var6) {
track.resetNotesUsedPerProgram();
}
}
@Override
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.currentPlayTime - var3 >= 0L) {
this._O = var3;
break;
}
final int var5 = (int) ((-1L - this._O + this.currentPlayTime + (long) var2) / (long) var2);
this._O += (long) var5 * (long) var2;
this._l.generateAudio2_idk(var5);
len -= var5;
this.a423();
} while (this.midiReader.isLoaded());
}
this._l.generateAudio2_idk(len);
}
@SuppressWarnings("SameParameterValue")
public synchronized void setVolume(final int volume) {
this.volume = volume;
}
private synchronized void b430(final boolean var2) {
this.midiReader.unload();
this._z = null;
this.a430(var2);
}
private void b366(final int var1) {
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);
if (var3._K.e801()) {
this._l._o.addFirst(var3._K);
}
var3.d487();
}
if (var3._E < 0) {
this._N[var3._y][var3._H] = null;
}
var3.unlink();
}
}
}
private void a540(final int var2) {
if ((2 & this._F[var2]) != 0) {
for (final MixerTrackConfig_idk var3 : this._l._n) {
if (var3._y == var2 && this._N[var2][var3._H] == null && var3._E < 0) {
var3._E = 0;
}
}
}
}
public synchronized void a077(final SongData var1, final boolean var3) {
this.a918(var3, var1, true);
}
private void a556(int var2) {
if (var2 >= 0) {
this._y[var2] = 12800;
this._G[var2] = 8192;
this._s[var2] = 16383;
this._T[var2] = 8192;
this._p[var2] = 0;
this._J[var2] = 8192;
this.a540(var2);
this.d093(var2);
this._F[var2] = 0;
this._q[var2] = 32767;
this._r[var2] = 256;
this._t[var2] = 0;
this.a326(8192, var2);
} else {
for (var2 = 0; var2 < 16; ++var2) {
this.a556(var2);
}
}
}
private void a430(final boolean var2) {
if (var2) {
this.b366(-1);
} else {
this.a093(-1);
}
this.a556(-1);
int var3;
for (var3 = 0; var3 < 16; ++var3) {
this._I[var3] = this._m[var3];
}
for (var3 = 0; var3 < 16; ++var3) {
this._P[var3] = this._m[var3] & -128;
}
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean a258(final MixerTrackConfig_idk var2) {
if (var2._K == null) {
if (var2._E >= 0) {
var2.unlink();
if (var2._z > 0 && var2 == this._K[var2._y][var2._z]) {
this._K[var2._y][var2._z] = null;
}
}
return true;
} else {
return false;
}
}
private void a366(final int var1) {
switch (var1 & 240) {
case 128: {
this.a172(15 & var1, (32672 & var1) >> 8);
break;
}
case 144: {
final int var5a = var1 & 15;
final int var6a = var1 >> 8 & 127;
final int var7a = 127 & var1 >> 16;
if (var7a > 0) {
this.a842(var6a, var5a, var7a);
} else {
this.a172(var5a, var6a);
}
break;
}
case 160:
case 208:
break;
case 176: {
final int var5a = 15 & var1;
final int var6a = 127 & var1 >> 8;
final int var7a = 127 & var1 >> 16;
if (var6a == 0) {
this._P[var5a] = (var7a << 14) + (-2080769 & this._P[var5a]);
}
if (var6a == 32) {
this._P[var5a] = (var7a << 7) + (-16257 & this._P[var5a]);
}
if (var6a == 1) {
this._p[var5a] = (-16257 & this._p[var5a]) + (var7a << 7);
}
if (var6a == 33) {
this._p[var5a] = var7a + (this._p[var5a] & -128);
}
if (var6a == 5) {
this._J[var5a] = (-16257 & this._J[var5a]) + (var7a << 7);
}
if (var6a == 37) {
this._J[var5a] = var7a + (this._J[var5a] & -128);
}
if (var6a == 7) {
this._y[var5a] = (var7a << 7) + (-16257 & this._y[var5a]);
}
if (var6a == 39) {
this._y[var5a] = (-128 & this._y[var5a]) + var7a;
}
if (var6a == 10) {
this._G[var5a] = (var7a << 7) + (this._G[var5a] & -16257);
}
if (var6a == 42) {
this._G[var5a] = (this._G[var5a] & -128) + var7a;
}
if (var6a == 11) {
this._s[var5a] = (var7a << 7) + (-16257 & this._s[var5a]);
}
if (var6a == 43) {
this._s[var5a] = var7a + (this._s[var5a] & -128);
}
if (var6a == 64) {
if (var7a >= 64) {
this._F[var5a] = this._F[var5a] | 1;
} else {
this._F[var5a] = this._F[var5a] & -2;
}
}
if (var6a == 65) {
if (var7a >= 64) {
this._F[var5a] = this._F[var5a] | 2;
} else {
this.a540(var5a);
this._F[var5a] = this._F[var5a] & -3;
}
}
if (var6a == 99) {
this._q[var5a] = (var7a << 7) + (127 & this._q[var5a]);
}
if (var6a == 98) {
this._q[var5a] = var7a + (16256 & this._q[var5a]);
}
if (var6a == 101) {
this._q[var5a] = (this._q[var5a] & 127) + 16384 + (var7a << 7);
}
if (var6a == 100) {
this._q[var5a] = 16384 + (this._q[var5a] & 16256) + var7a;
}
if (var6a == 120) {
this.b366(var5a);
}
if (var6a == 121) {
this.a556(var5a);
}
if (var6a == 123) {
this.a093(var5a);
}
int var8;
if (var6a == 6) {
var8 = this._q[var5a];
if (var8 == 16384) {
this._r[var5a] = (this._r[var5a] & -16257) + (var7a << 7);
}
}
if (var6a == 38) {
var8 = this._q[var5a];
if (var8 == 16384) {
this._r[var5a] = var7a + (this._r[var5a] & -128);
}
}
if (var6a == 16) {
this._t[var5a] = (var7a << 7) + (this._t[var5a] & -16257);
}
if (var6a == 48) {
this._t[var5a] = (this._t[var5a] & -128) + var7a;
}
if (var6a == 81) {
if (var7a >= 64) {
this._F[var5a] = this._F[var5a] | 4;
} else {
this.d093(var5a);
this._F[var5a] = this._F[var5a] & -5;
}
}
if (var6a == 17) {
this.a326((var7a << 7) + (-16257 & this._E[var5a]), var5a);
}
if (var6a == 49) {
this.a326((this._E[var5a] & -128) + var7a, var5a);
}
break;
}
case 192: {
final int var5a = var1 & 15;
final int var6a = (32569 & var1) >> 8;
this.a599(var5a, this._P[var5a] + var6a);
break;
}
case 224: {
final int var5a = 15 & var1;
final int var6a = (127 & var1 >> 8) + (var1 >> 9 & 16256);
this.b789(var5a, var6a);
break;
}
default: {
if ((var1 & 255) == 255) {
this.a430(true);
}
break;
}
}
}
@Override
public synchronized int a784() {
return 0;
}
private synchronized void a918(final boolean var1, final SongData songData, final boolean var4) {
this.b430(var4);
this.midiReader.load(songData.midiData);
this._v = var1;
this._O = 0L;
final int numTracks = this.midiReader.numTracks();
for (int track = 0; track < numTracks; ++track) {
this.midiReader.setCursorToTrackPlaybackPos(track);
this.midiReader.advanceTrackTicks(track);
this.midiReader.setTrackPlaybackPosToCursor(track);
}
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 MixerTrackConfig_idk var3 : this._l._n) {
if (var3._y == var2) {
var3._j = 0;
}
}
}
}
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<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;
final int var6 = (var5._G * var5._r >> 12) + var5._J;
var5._J += -var5._H + var1 << 8;
var5._G = 4096;
var5._r = -var5._J + var6;
var5._H = var1;
return;
}
}
}
final br_ var10 = this._Q.get(this._I[var2]);
if (var10 != null) {
final kk_ var11 = var10._h[var1];
if (var11 != null) {
final MixerTrackConfig_idk var7 = new MixerTrackConfig_idk();
var7._y = var2;
var7._A = var10;
var7._M = var11;
var7._u = var10._j[var1];
var7._z = var10._r[var1];
var7._H = var1;
var7._k = var10._s[var1] * var3 * var3 * var10._q + 1024 >> 11;
var7._q = var10._t[var1] & 255;
var7._J = (var1 << 8) - (var10._k[var1] & 32767);
var7._B = 0;
var7._E = -1;
var7._F = 0;
var7._h = 0;
var7._v = 0;
if (this._t[var2] == 0) {
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);
}
if (var10._k[var1] < 0) {
assert var7._K != null;
var7._K.f150();
}
if (var7._z >= 0) {
final MixerTrackConfig_idk var9 = this._K[var2][var7._z];
if (var9 != null && var9._E < 0) {
this._N[var2][var9._H] = null;
var9._E = 0;
}
this._K[var2][var7._z] = var7;
}
this._l._n.addLast(var7);
this._N[var2][var1] = var7;
}
}
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
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;
if (var6 > 0) {
var6 -= (int) (Math.pow(2.0D, (double) this._J[var4._y] * 4.921259842519685E-4D) * 16.0D + 0.5D);
if (var6 < 0) {
var6 = 0;
}
var4._G = var6;
}
var4._K.d150(this.b237(var4));
final kc_ var7 = var4._u;
var4._i += var7._o;
++var4._C;
boolean var8 = false;
final double var9 = 5.086263020833333E-6D * (double) ((var4._H - 60 << 8) + (var4._G * var4._r >> 12));
if (var7._h > 0) {
if (var7._a > 0) {
var4._h += (int) (Math.pow(2.0D, var9 * (double) var7._a) * 128.0D + 0.5D);
} else {
var4._h += 128;
}
if (var7._h * var4._h >= 819200) {
var8 = true;
}
}
if (var7._n != null) {
if (var7._k <= 0) {
var4._F += 128;
} else {
var4._F += (int) (0.5D + Math.pow(2.0D, var9 * (double) var7._k) * 128.0D);
}
while (var4._B < var7._n.length - 2 && ('\uff00' & var7._n[2 + var4._B] << 8) < var4._F) {
var4._B += 2;
}
if (var7._n.length - 2 == var4._B && var7._n[1 + var4._B] == 0) {
var8 = true;
}
}
if (var4._E >= 0 && var7._e != null && (1 & this._F[var4._y]) == 0 && (var4._z < 0 || this._K[var4._y][var4._z] != var4)) {
if (var7._c <= 0) {
var4._E += 128;
} else {
var4._E += (int) (0.5D + 128.0D * Math.pow(2.0D, (double) var7._c * var9));
}
while (var4._v < var7._e.length - 2 && var4._E > (255 & var7._e[2 + var4._v]) << 8) {
var4._v += 2;
}
if (var7._e.length - 2 == var4._v) {
var8 = true;
}
}
if (var8) {
var4._K.g150(var4._p);
if (var2 == null) {
var4._K.generateAudio2_idk(var5);
} else {
var4._K.generateAudio1_idk(var2, var1, var5);
}
if (var4._K.e801()) {
this._l._o.addFirst(var4._K);
}
var4.d487();
if (var4._E >= 0) {
var4.unlink();
if (var4._z > 0 && this._K[var4._y][var4._z] == var4) {
this._K[var4._y][var4._z] = null;
}
}
return true;
} else {
var4._K.a326(var4._p, this.generateSample(var4), this.a237(var4));
return false;
}
} else {
var4.d487();
var4.unlink();
if (var4._z > 0 && this._K[var4._y][var4._z] == var4) {
this._K[var4._y][var4._z] = null;
}
return true;
}
}
private void a599(final int var1, final int var2) {
if (var2 != this._I[var1]) {
this._I[var1] = var2;
for (int i = 0; i < 128; ++i) {
this._K[var1][i] = null;
}
}
}
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 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 (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 || ticks == 0) {
this.a430(true);
this.midiReader.unload();
return;
}
this.midiReader.resetPlayback(var4);
}
break;
}
if ((event & 128) != 0) {
this.a366(event);
}
this.midiReader.advanceTrackTicks(track);
this.midiReader.setTrackPlaybackPosToCursor(track);
}
track = this.midiReader.trackWithSoonestNextTick();
ticks = this.midiReader.trackNextTick[track];
var4 = this.midiReader.getPlayTime(ticks);
}
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 MixerTrackConfig_idk var2, final boolean var3) {
int var4 = var2._M.data.length;
int var5;
if (var3 && var2._M._i) {
final int var6 = -var2._M._l + var4 + var4;
var5 = (int) ((long) this._t[var2._y] * (long) var6 >> 6);
var4 <<= 8;
if (var5 >= var4) {
var2._K.c487();
var5 = -var5 + var4 + var4 - 1;
}
} else {
var5 = (int) ((long) this._t[var2._y] * (long) var4 >> 6);
}
var2._K.h150(var5);
}
private int generateSample(final MixerTrackConfig_idk var1) {
if (this._A[var1._y] == 0) {
return 0;
}
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() {
this._m[9] = 128;
this._P[9] = 128;
this.a599(9, 128);
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public synchronized boolean h154() {
return this.midiReader.isLoaded();
}
}

View File

@ -1,30 +0,0 @@
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

@ -1,34 +0,0 @@
package funorb.audio;
import funorb.data.NodeList;
public final class MixerTrackConfig_idk extends NodeList.Node {
public int _E;
public int _G;
public int _v;
public int _F;
public int _H;
public kk_ _M;
public kc_ _u;
public al_ _K;
public br_ _A;
public int _j;
public int _r;
public int _C;
public int _q;
public int _y;
public int _J;
public int _h;
public int _z;
public int _k;
public int _p;
public int _B;
public int _i;
public void d487() {
this._A = null;
this._K = null;
this._M = null;
this._u = null;
}
}

View File

@ -2,10 +2,10 @@ package funorb.audio;
import funorb.io.Buffer;
public final class pn_ {
public final class OscillatorConfig_idk {
public int _d;
public int _i;
public int sampleType;
public int waveform;
private int count = 2;
private int[] values1 = new int[2];
private int[] values2 = new int[2];
@ -15,13 +15,13 @@ public final class pn_ {
private int _j;
private int pos;
public pn_() {
public OscillatorConfig_idk() {
this.values1[1] = 65535;
this.values2[1] = 65535;
}
public void initialize(final Buffer buffer) {
this.sampleType = buffer.readUByte();
this.waveform = buffer.readUByte();
this._d = buffer.readInt();
this._i = buffer.readInt();
this.read(buffer);
@ -45,14 +45,14 @@ public final class pn_ {
this._g = 0;
}
public int next(final int var1) {
public int next(final int volume) {
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) var1);
this._e = (int) (((double) this.values1[this.pos] / 65536.0D) * (double) volume);
if (this._e > this._g) {
this._b = ((this.values2[this.pos] << 15) - this._j) / (this._e - this._g);
}

View File

@ -5,7 +5,7 @@ import funorb.io.Buffer;
import java.util.Arrays;
import java.util.Random;
public final class pk_ {
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;
@ -38,42 +38,42 @@ public final class pk_ {
public int _s = 0;
public int _a = 500;
private fh_ _k;
private pn_ _o;
private OscillatorConfig_idk osc1;
private int _f = 0;
private pn_ _r;
private pn_ _g;
private pn_ _d;
private pn_ _m;
private OscillatorConfig_idk osc2;
private OscillatorConfig_idk osc3;
private OscillatorConfig_idk osc4;
private OscillatorConfig_idk osc5;
private int _b = 100;
private pn_ _n;
private pn_ _e;
private pn_ _l;
private pn_ _i;
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._m.reset();
this._i.reset();
this.osc5.reset();
this.osc9.reset();
int var5 = 0;
int var6 = 0;
int var7 = 0;
if (this._l != null) {
this._l.reset();
this._d.reset();
var5 = (int) ((double) (this._l._i - this._l._d) * 32.768D / var3);
var6 = (int) ((double) this._l._d * 32.768D / var3);
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._g != null) {
this._g.reset();
this._o.reset();
var8 = (int) ((double) (this._g._i - this._g._d) * 32.768D / var3);
var9 = (int) ((double) this._g._d * 32.768D / var3);
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) {
@ -81,27 +81,27 @@ public final class pk_ {
_c[i] = 0;
_q[i] = (int) ((double) this._h[i] * var3);
_p[i] = (this._y[i] << 14) / 100;
_t[i] = (int) ((double) (this._m._i - this._m._d) * 32.768D * Math.pow(1.0057929410678534D, this._x[i]) / var3);
_w[i] = (int) ((double) this._m._d * 32.768D / var3);
_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._m.next(var1);
int var13 = this._i.next(var1);
int var12 = this.osc5.next(var1);
int var13 = this.osc9.next(var1);
int var14;
int var15;
if (this._l != null) {
var14 = this._l.next(var1);
var15 = this._d.next(var1);
var12 += this.sample(this._l.sampleType, var7, var15) >> 1;
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._g != null) {
var14 = this._g.next(var1);
var15 = this._o.next(var1);
var13 = var13 * ((this.sample(this._g.sampleType, var10, var15) >> 1) + 0x8000) >> 15;
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;
}
@ -109,27 +109,27 @@ public final class pk_ {
if (this._y[var14] != 0) {
var15 = i + _q[var14];
if (var15 < var1) {
_u[var15] += this.sample(this._m.sampleType, _c[var14], var13 * _p[var14] >> 15);
_u[var15] += this.sample(this.osc5.waveform, _c[var14], var13 * _p[var14] >> 15);
_c[var14] += (var12 * _t[var14] >> 16) + _w[var14];
}
}
}
}
if (this._e != null) {
this._e.reset();
this._r.reset();
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._e.next(var1);
final int var16 = this._r.next(var1);
final int var15 = this.osc7.next(var1);
final int var16 = this.osc2.next(var1);
final int var12;
if (var19) {
var12 = this._e._d + ((this._e._i - this._e._d) * var15 >> 8);
var12 = this.osc7._d + ((this.osc7._i - this.osc7._d) * var15 >> 8);
} else {
var12 = this._e._d + ((this._e._i - this._e._d) * var16 >> 8);
var12 = this.osc7._d + ((this.osc7._i - this.osc7._d) * var16 >> 8);
}
var11 += 256;
@ -152,8 +152,8 @@ public final class pk_ {
}
if (this._k._d[0] > 0 || this._k._d[1] > 0) {
this._n.reset();
int var11 = this._n.next(var1 + 1);
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) {
@ -172,7 +172,7 @@ public final class pk_ {
}
_u[var14] = var16;
var11 = this._n.next(var1 + 1);
var11 = this.osc6.next(var1 + 1);
++var14;
}
@ -194,7 +194,7 @@ public final class pk_ {
}
_u[var14] = var16;
var11 = this._n.next(var1 + 1);
var11 = this.osc6.next(var1 + 1);
++var14;
}
@ -211,7 +211,7 @@ public final class pk_ {
}
_u[var14] = var16;
this._n.next(var1 + 1);
this.osc6.next(var1 + 1);
++var14;
}
break;
@ -237,35 +237,35 @@ public final class pk_ {
}
public void initialize(final Buffer buffer) {
this._m = new pn_();
this._m.initialize(buffer);
this._i = new pn_();
this._i.initialize(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._l = new pn_();
this._l.initialize(buffer);
this._d = new pn_();
this._d.initialize(buffer);
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._g = new pn_();
this._g.initialize(buffer);
this._o = new pn_();
this._o.initialize(buffer);
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._e = new pn_();
this._e.initialize(buffer);
this._r = new pn_();
this._r.initialize(buffer);
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) {
@ -284,26 +284,26 @@ public final class pk_ {
this._a = buffer.readUShort();
this._s = buffer.readUShort();
this._k = new fh_();
this._n = new pn_();
this._k.a086(buffer, this._n);
this.osc6 = new OscillatorConfig_idk();
this._k.a086(buffer, this.osc6);
}
private int sample(final int type, final int time, final int volume) {
if (type == SampleType.SQUARE) {
return ((time & 0x7fff) < 0x4000) ? volume : -volume;
} else if (type == SampleType.SINE) {
return (SINE[time & 0x7fff] * volume) >> 14;
} else if (type == SampleType.SAWTOOTH) {
return (((time & 0x7fff) * volume) >> 14) - volume;
} else if (type == SampleType.NOISE) {
return NOISE[(time / 2607) & 0x7fff] * volume;
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 SampleType {
private static final class Waveform {
public static final int SQUARE = 1;
public static final int SINE = 2;
public static final int SAWTOOTH = 3;

View File

@ -3,10 +3,10 @@ package funorb.audio;
import funorb.shatteredplans.client.Sounds;
public final class PlayingSound {
public final al_ _p;
public final AudioSamplePlayback_idk _p;
public int volume;
public PlayingSound(final al_ var1) {
public PlayingSound(final AudioSamplePlayback_idk var1) {
this._p = var1;
this.volume = var1.getVolume();
this._p.setVolume((128 + (this.volume * Sounds.soundVolume)) >> 8);

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 MixerInterface_idk[] _o = new MixerInterface_idk[8];
private final MixerInterface_idk[] _s = new MixerInterface_idk[8];
private final AudioSource_idk[] _o = new AudioSource_idk[8];
private final AudioSource_idk[] _s = new AudioSource_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 MixerInterface_idk source;
private AudioSource_idk source;
private int _r = 0;
private int _l = 0;
private boolean _n = true;
@ -46,10 +46,10 @@ public final class SampledAudioChannel implements Closeable {
return var6 & 255;
}
private static void b446(final MixerInterface_idk var0) {
var0.useGenerateAudio1_idk = false;
if (var0._k != null) {
var0._k._h = 0;
private static void b446(final AudioSource_idk var0) {
var0.enabled = false;
if (var0.sampleData != null) {
var0.sampleData._h = 0;
}
var0.forEach(SampledAudioChannel::b446);
}
@ -96,7 +96,7 @@ public final class SampledAudioChannel implements Closeable {
}
}
private void a704(final int[] data) {
private void fillAudioBuffer(final int[] data) {
Arrays.fill(data, 0, BYTES_PER_CHANNEL_PER_WRITE, 0);
this._a -= 256;
if (this.source != null && this._a <= 0) {
@ -106,7 +106,7 @@ public final class SampledAudioChannel implements Closeable {
int var4 = 0;
int var5 = 255;
MixerInterface_idk var10;
AudioSource_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;
MixerInterface_idk var11 = this._o[var7];
AudioSource_idk var11 = this._o[var7];
label100:
while (true) {
@ -132,13 +132,13 @@ public final class SampledAudioChannel implements Closeable {
break label100;
}
final kk_ var12 = var11._k;
final AudioSampleData_idk var12 = var11.sampleData;
if (var12 != null && var12._h > var8) {
var5 |= 1 << var7;
var10 = var11;
var11 = var11._h;
} else {
var11.useGenerateAudio1_idk = true;
var11.enabled = 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 MixerInterface_idk var18 = var11._h;
final AudioSource_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) {
MixerInterface_idk var16 = this._o[var6];
AudioSource_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.generateAudio1_idk(data, 0, 256);
this.source.processAndWrite(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.generateAudio2_idk(256);
this.source.processAndDiscard(256);
}
}
private void a607(final MixerInterface_idk var1, final int var2) {
private void a607(final AudioSource_idk var1, final int var2) {
final int i = var2 >> 5;
final MixerInterface_idk var4 = this._s[i];
final AudioSource_idk var4 = this._s[i];
if (var4 == null) {
this._o[i] = var1;
} else {
@ -277,7 +277,7 @@ public final class SampledAudioChannel implements Closeable {
}
while (var3 < var4) {
this.a704(this.data);
this.fillAudioBuffer(this.data);
this.performWrite();
var3 += 256;
}
@ -309,7 +309,7 @@ public final class SampledAudioChannel implements Closeable {
}
}
public synchronized void setSource(final MixerInterface_idk source) {
public synchronized void setSource(final AudioSource_idk source) {
this.source = source;
}

View File

@ -262,7 +262,7 @@ public final class SongData {
midi.writeByte(0xb0 + midiChannel); // control change
}
controller += input.data[posControlDeltas++] & 127;
controller = controller + input.data[posControlDeltas++] & 127;
midi.writeByte(controller);
final byte valueDelta;
if (controller == 0 || controller == 32) { // bank switch msb/lsb

View File

@ -2,20 +2,20 @@ package funorb.audio;
public final class SoundEffect {
public final int volume;
public final kk_ _f;
public final AudioSampleData_idk sample;
private SoundEffect(final kk_ var1, final int var2) {
this.volume = var2;
this._f = var1;
private SoundEffect(final AudioSampleData_idk sample, final int volume) {
this.volume = volume;
this.sample = sample;
}
@SuppressWarnings("SameParameterValue")
public static SoundEffect load1(final String item, final int var1) {
return new SoundEffect(SoundLoader.globalLoader.load1(item), var1);
public static SoundEffect load1(final String item, final int volume) {
return new SoundEffect(SoundLoader.globalLoader.load1(item), volume);
}
@SuppressWarnings("SameParameterValue")
public static SoundEffect load2(final String item, final int var1) {
return new SoundEffect(SoundLoader.globalLoader.load2(item), var1);
public static SoundEffect load2(final String item, final int volume) {
return new SoundEffect(SoundLoader.globalLoader.load2(item), volume);
}
}

View File

@ -8,7 +8,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, kk_> _d = new HashMap<>();
private final Map<Long, AudioSampleData_idk> _d = new HashMap<>();
private final ResourceLoader loader1;
private final ResourceLoader loader2;
@ -17,15 +17,15 @@ public final class SoundLoader {
this.loader2 = loader2;
}
private kk_ load1(final int groupId, final int itemId) {
private AudioSampleData_idk load1(final int groupId, final int itemId) {
final int var5 = (itemId ^ (((groupId << 4) & 0xfff3) | (groupId >>> 12))) | (groupId << 16);
final kk_ var8 = this._d.get((long) var5);
final AudioSampleData_idk var8 = this._d.get((long) var5);
if (var8 == null) {
final dq_ var9 = dq_.load(this.loader1, groupId, itemId);
if (var9 == null) {
return null;
} else {
final kk_ kk_ = var9.b720();
final AudioSampleData_idk kk_ = var9.b720();
this._d.put((long) var5, kk_);
return kk_;
}
@ -34,7 +34,7 @@ public final class SoundLoader {
}
}
public kk_ loadSingleton2(final int var3) {
public AudioSampleData_idk loadSingleton2(final int var3) {
if (this.loader2.groupCount() == 1) {
return this.load2(0, var3);
} else if (this.loader2.itemCount(var3) == 1) {
@ -44,7 +44,7 @@ public final class SoundLoader {
}
}
public kk_ loadSingleton1(final int var1) {
public AudioSampleData_idk loadSingleton1(final int var1) {
if (this.loader1.groupCount() == 1) {
return this.load1(0, var1);
} else if (this.loader1.itemCount(var1) == 1) {
@ -54,10 +54,10 @@ public final class SoundLoader {
}
}
private kk_ load2(final int var3, final int var2) {
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;
kk_ var8 = this._d.get(var6);
AudioSampleData_idk var8 = this._d.get(var6);
if (var8 == null) {
fd_ var9 = this._a.get(var6);
if (var9 == null) {
@ -77,7 +77,7 @@ public final class SoundLoader {
}
@SuppressWarnings("SameParameterValue")
public kk_ load2(final String item) {
public AudioSampleData_idk load2(final String item) {
final int groupId = this.loader2.lookupGroup("");
if (groupId < 0) {
return null;
@ -87,7 +87,7 @@ public final class SoundLoader {
}
}
public kk_ load1(final String item) {
public AudioSampleData_idk load1(final String item) {
final int groupId = this.loader1.lookupGroup("");
if (groupId >= 0) {
final int itemId = this.loader1.lookupItem(groupId, item);

File diff suppressed because it is too large Load Diff

View File

@ -4,17 +4,17 @@ import funorb.cache.ResourceLoader;
import funorb.io.Buffer;
public final class dq_ {
private final pk_[] _b = new pk_[10];
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 var3 = data.readUByte();
if (var3 != 0) {
final int peekByte = data.readUByte();
if (peekByte != 0) {
--data.pos;
this._b[i] = new pk_();
this._b[i].initialize(data);
this.oscillators[i] = new Oscillator_idk();
this.oscillators[i].initialize(data);
}
}
@ -31,8 +31,8 @@ public final class dq_ {
int var1 = 0;
for (int i = 0; i < 10; ++i) {
if (this._b[i] != null && var1 < this._b[i]._a + this._b[i]._s) {
var1 = this._b[i]._a + this._b[i]._s;
if (this.oscillators[i] != null && var1 < this.oscillators[i]._a + this.oscillators[i]._s) {
var1 = this.oscillators[i]._a + this.oscillators[i]._s;
}
}
@ -43,10 +43,10 @@ public final class dq_ {
final byte[] var3 = new byte[var2];
for (int i = 0; i < 10; ++i) {
if (this._b[i] != null) {
final int var5 = this._b[i]._a * SampledAudioChannel.SAMPLES_PER_SECOND / 1000;
final int var6 = this._b[i]._s * SampledAudioChannel.SAMPLES_PER_SECOND / 1000;
final int[] var7 = this._b[i].a111(var5, this._b[i]._a);
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);
@ -62,8 +62,12 @@ public final class dq_ {
return var3;
}
public kk_ b720() {
public AudioSampleData_idk b720() {
final byte[] var1 = this.a928();
return new kk_(var1, SampledAudioChannel.SAMPLES_PER_SECOND * this._c / 1000, SampledAudioChannel.SAMPLES_PER_SECOND * this._a / 1000);
return new AudioSampleData_idk(
var1,
SampledAudioChannel.SAMPLES_PER_SECOND * this._c / 1000,
SampledAudioChannel.SAMPLES_PER_SECOND * this._a / 1000
);
}
}

View File

@ -264,7 +264,7 @@ public final class fd_ {
return var2;
}
public kk_ a582() {
public AudioSampleData_idk a582() {
if (this._N == null) {
this._M = 0;
this._n = new float[_r];
@ -299,7 +299,7 @@ public final class fd_ {
this._n = null;
final byte[] var7 = this._N;
this._N = null;
return new kk_(this._B, var7, this._H, this._G, this._I);
return new AudioSampleData_idk(this._B, var7, this._H, this._G, this._I);
}
private float[] e875(final int var1) {

View File

@ -17,7 +17,7 @@ public final class fh_ {
return var1 * 3.1415927F / 11025.0F;
}
public void a086(final Buffer var1, final pn_ var2) {
public void a086(final Buffer var1, final OscillatorConfig_idk var2) {
final int var3 = var1.readUByte();
this._d[0] = var3 >> 4;
this._d[1] = var3 & 15;

View File

@ -6,95 +6,93 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
public final class h_ extends MixerInterface_idk {
public final MidiPlayer_idk _r;
public final MidiPlayer_idk _u;
private int[] _D;
private SongData _E;
public final class h_ extends AudioSource_idk {
public final MidiPlayer midiPlayer1;
public final MidiPlayer midiPlayer2;
private int[] midiBuffer2;
private SongData song1;
private int _l;
private int _n = 0x100000;
private SongData _z;
private int[] _p;
private int crossfade = 0x100000;
private SongData song2;
private int[] midiBuffer1;
private int volume = 256;
private boolean _C;
public h_() {
final MidiPlayer_idk var1 = new MidiPlayer_idk();
this._u = var1;
this._r = new MidiPlayer_idk(var1);
final MidiPlayer midiPlayer = new MidiPlayer();
this.midiPlayer2 = midiPlayer;
this.midiPlayer1 = new MidiPlayer(midiPlayer);
}
public boolean a419(final SongData var1) {
return var1 == this._z || var1 == this._E;
return var1 == this.song2 || var1 == this.song1;
}
@Override
public void generateAudio1_idk(final int[] dest, final int offset, final int len) {
public void processAndWrite(final int[] dest, final int offset, final int len) {
if (this.volume <= 0) {
this.generateAudio2_idk(len);
this.processAndDiscard(len);
} else {
if (this._C) {
if (this._l > 0 && !this._u.h154()) {
if (this._l > 0 && !this.midiPlayer2.h154()) {
this._C = false;
this._l = -this._l;
this._z = null;
} else if (this._l < 0 && !this._r.h154()) {
this._E = null;
this.song2 = null;
} else if (this._l < 0 && !this.midiPlayer1.h154()) {
this.song1 = null;
this._C = false;
this._l = -this._l;
}
}
final int var4 = (this._n >> 12) * this.volume / 256;
final int var5 = this.volume - var4;
final int midiAmp2 = (this.crossfade >> 12) * this.volume / 256;
final int midiAmp1 = this.volume - midiAmp2;
if (this._l != 0) {
this._n += this._l * len;
if (this._n >= 1048576) {
this._n = 1048576;
this.crossfade += this._l * len;
if (this.crossfade >= 0x100000) {
this.crossfade = 0x100000;
if (!this._C) {
this._l = 0;
if (this._E != null) {
this._r.e150();
if (this.song1 != null) {
this.midiPlayer1.e150();
}
this._E = null;
this.song1 = null;
}
} else if (this._n <= 0) {
this._n = 0;
} else if (this.crossfade <= 0) {
this.crossfade = 0;
if (!this._C) {
this._l = 0;
if (this._z != null) {
this._u.e150();
if (this.song2 != null) {
this.midiPlayer2.e150();
}
this._z = null;
this.song2 = null;
}
}
}
final int var6 = len << 1;
final int var7;
int var8;
if (this._z != null || this._E != null) {
if (var4 == 256) {
this._u.generateAudio1_idk(dest, offset, len);
} else if (var5 == 256) {
this._r.generateAudio1_idk(dest, offset, len);
final int lenSamples = len << 1;
if (this.song2 != null || this.song1 != null) {
if (midiAmp2 == 256) {
this.midiPlayer2.processAndWrite(dest, offset, len);
} else if (midiAmp1 == 256) {
this.midiPlayer1.processAndWrite(dest, offset, len);
} else {
if (this._D != null && this._D.length >= var6) {
Arrays.fill(this._D, 0, var6, 0);
Arrays.fill(this._p, 0, var6, 0);
if (this.midiBuffer2 != null && this.midiBuffer2.length >= lenSamples) {
Arrays.fill(this.midiBuffer2, 0, lenSamples, 0);
Arrays.fill(this.midiBuffer1, 0, lenSamples, 0);
} else {
this._p = new int[var6];
this._D = new int[var6];
this.midiBuffer1 = new int[lenSamples];
this.midiBuffer2 = new int[lenSamples];
}
this._u.generateAudio1_idk(this._D, 0, len);
this._r.generateAudio1_idk(this._p, 0, len);
var7 = offset << 1;
this.midiPlayer2.processAndWrite(this.midiBuffer2, 0, len);
this.midiPlayer1.processAndWrite(this.midiBuffer1, 0, len);
final int offsetSamples = offset << 1;
for (var8 = 0; var6 > var8; ++var8) {
dest[var7 + var8] += this._p[var8] * var5 + this._D[var8] * var4 >> 8;
for (int i = 0; i < lenSamples; ++i) {
dest[offsetSamples + i] += this.midiBuffer1[i] * midiAmp1 + this.midiBuffer2[i] * midiAmp2 >> 8;
}
}
}
@ -103,57 +101,57 @@ public final class h_ extends MixerInterface_idk {
}
@Override
public synchronized void generateAudio2_idk(final int len) {
if (this._n > 0 && this._z != null) {
this._u.generateAudio2_idk(len);
public synchronized void processAndDiscard(final int len) {
if (this.crossfade > 0 && this.song2 != null) {
this.midiPlayer2.processAndDiscard(len);
}
if (this._n < 1048576 && this._E != null) {
this._r.generateAudio2_idk(len);
if (this.crossfade < 0x100000 && this.song1 != null) {
this.midiPlayer1.processAndDiscard(len);
}
if (this._C) {
if (this._l > 0 && !this._u.h154()) {
if (this._l > 0 && !this.midiPlayer2.h154()) {
this._C = false;
this._z = null;
this.song2 = null;
this._l = -this._l;
} else if (this._l < 0 && !this._r.h154()) {
} else if (this._l < 0 && !this.midiPlayer1.h154()) {
this._C = false;
this._l = -this._l;
this._E = null;
this.song1 = null;
}
}
if (this._l != 0) {
this._n += this._l * len;
if (this._n >= 1048576) {
this._n = 1048576;
this.crossfade += this._l * len;
if (this.crossfade >= 0x100000) {
this.crossfade = 0x100000;
if (!this._C) {
this._l = 0;
if (this._E != null) {
this._r.e150();
if (this.song1 != null) {
this.midiPlayer1.e150();
}
this._E = null;
this.song1 = null;
}
} else if (this._n <= 0) {
this._n = 0;
} else if (this.crossfade <= 0) {
this.crossfade = 0;
if (!this._C) {
this._l = 0;
if (this._z != null) {
this._u.e150();
if (this.song2 != null) {
this.midiPlayer2.e150();
}
this._z = null;
this.song2 = null;
}
}
}
}
private void a633(final MidiPlayer_idk var3) {
var3.a679();
var3.c430();
private void a633(final MidiPlayer midiPlayer) {
midiPlayer.a679();
midiPlayer.c430();
}
public synchronized void setVolume(final int volume) {
@ -166,73 +164,73 @@ public final class h_ extends MixerInterface_idk {
}
@Override
public @NotNull Iterator<MixerInterface_idk> iterator() {
public @NotNull Iterator<AudioSource_idk> iterator() {
return Collections.emptyIterator();
}
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) {
this._u.e150();
if (this.song2 != null) {
this.midiPlayer2.e150();
}
this._z = track;
this.song2 = track;
if (track != null) {
this._u.a077(track, false);
this.a633(this._u);
this.midiPlayer2.a077(track, false);
this.a633(this.midiPlayer2);
}
} else {
if (this._E != null) {
this._r.e150();
if (this.song1 != null) {
this.midiPlayer1.e150();
}
this._E = track;
this.song1 = track;
if (track != null) {
this._r.a077(track, false);
this.a633(this._r);
this.midiPlayer1.a077(track, false);
this.a633(this.midiPlayer1);
}
}
} else {
this._C = var4;
if (this._z == track) {
if (this.song2 == track) {
this._l = var5;
this.a633(this._u);
} else if (track == this._E) {
this.a633(this.midiPlayer2);
} else if (track == this.song1) {
this._l = -var5;
this.a633(this._r);
this.a633(this.midiPlayer1);
} else {
final boolean var7;
if (this._z == null) {
if (this.song2 == null) {
var7 = true;
} else if (this._E == null) {
} else if (this.song1 == null) {
var7 = false;
} else {
var7 = this._n < 524288;
var7 = this.crossfade < 524288;
}
if (var7) {
if (this._z != null) {
this._u.e150();
if (this.song2 != null) {
this.midiPlayer2.e150();
}
this._z = track;
this.song2 = track;
if (track != null) {
this._u.a077(track, !var4);
this.a633(this._u);
this.midiPlayer2.a077(track, !var4);
this.a633(this.midiPlayer2);
}
this._l = var5;
} else {
if (this._E != null) {
this._r.e150();
if (this.song1 != null) {
this.midiPlayer1.e150();
}
this._E = track;
this.song1 = track;
if (track != null) {
this._r.a077(track, !var4);
this.a633(this._r);
this.midiPlayer1.a077(track, !var4);
this.a633(this.midiPlayer1);
}
this._l = -var5;

View File

@ -1,22 +0,0 @@
package funorb.audio;
public final class kk_ {
public final int _k;
public final int _l;
public final int _j;
public final byte[] data;
public final boolean _i;
public int _h;
public kk_(final byte[] data, final int var3, final int var4) {
this(SampledAudioChannel.SAMPLES_PER_SECOND, data, var3, var4, false);
}
public kk_(final int var1, final byte[] data, final int var3, final int var4, final boolean var5) {
this._j = var1;
this.data = data;
this._l = var3;
this._k = var4;
this._i = var5;
}
}

View File

@ -3,7 +3,78 @@ package funorb.audio;
import funorb.util.BitMath;
public final class kn_ {
private static final float[] _j = new float[]{1.0649863E-7F, 1.1341951E-7F, 1.2079015E-7F, 1.2863978E-7F, 1.369995E-7F, 1.459025E-7F, 1.5538409E-7F, 1.6548181E-7F, 1.7623574E-7F, 1.8768856E-7F, 1.998856E-7F, 2.128753E-7F, 2.2670913E-7F, 2.4144197E-7F, 2.5713223E-7F, 2.7384212E-7F, 2.9163792E-7F, 3.1059022E-7F, 3.307741E-7F, 3.5226967E-7F, 3.7516213E-7F, 3.995423E-7F, 4.255068E-7F, 4.5315863E-7F, 4.8260745E-7F, 5.1397E-7F, 5.4737063E-7F, 5.829419E-7F, 6.208247E-7F, 6.611694E-7F, 7.041359E-7F, 7.4989464E-7F, 7.98627E-7F, 8.505263E-7F, 9.057983E-7F, 9.646621E-7F, 1.0273513E-6F, 1.0941144E-6F, 1.1652161E-6F, 1.2409384E-6F, 1.3215816E-6F, 1.4074654E-6F, 1.4989305E-6F, 1.5963394E-6F, 1.7000785E-6F, 1.8105592E-6F, 1.9282195E-6F, 2.053526E-6F, 2.1869757E-6F, 2.3290977E-6F, 2.4804558E-6F, 2.6416496E-6F, 2.813319E-6F, 2.9961443E-6F, 3.1908505E-6F, 3.39821E-6F, 3.619045E-6F, 3.8542307E-6F, 4.1047006E-6F, 4.371447E-6F, 4.6555283E-6F, 4.958071E-6F, 5.280274E-6F, 5.623416E-6F, 5.988857E-6F, 6.3780467E-6F, 6.7925284E-6F, 7.2339453E-6F, 7.704048E-6F, 8.2047E-6F, 8.737888E-6F, 9.305725E-6F, 9.910464E-6F, 1.0554501E-5F, 1.1240392E-5F, 1.1970856E-5F, 1.2748789E-5F, 1.3577278E-5F, 1.4459606E-5F, 1.5399271E-5F, 1.6400005E-5F, 1.7465769E-5F, 1.8600793E-5F, 1.9809577E-5F, 2.1096914E-5F, 2.2467912E-5F, 2.3928002E-5F, 2.5482977E-5F, 2.7139005E-5F, 2.890265E-5F, 3.078091E-5F, 3.2781227E-5F, 3.4911533E-5F, 3.718028E-5F, 3.9596467E-5F, 4.2169668E-5F, 4.491009E-5F, 4.7828602E-5F, 5.0936775E-5F, 5.424693E-5F, 5.7772202E-5F, 6.152657E-5F, 6.552491E-5F, 6.9783084E-5F, 7.4317984E-5F, 7.914758E-5F, 8.429104E-5F, 8.976875E-5F, 9.560242E-5F, 1.0181521E-4F, 1.0843174E-4F, 1.1547824E-4F, 1.2298267E-4F, 1.3097477E-4F, 1.3948625E-4F, 1.4855085E-4F, 1.5820454E-4F, 1.6848555E-4F, 1.7943469E-4F, 1.9109536E-4F, 2.0351382E-4F, 2.167393E-4F, 2.3082423E-4F, 2.4582449E-4F, 2.6179955E-4F, 2.7881275E-4F, 2.9693157E-4F, 3.1622787E-4F, 3.3677815E-4F, 3.5866388E-4F, 3.8197188E-4F, 4.0679457E-4F, 4.3323037E-4F, 4.613841E-4F, 4.913675E-4F, 5.2329927E-4F, 5.573062E-4F, 5.935231E-4F, 6.320936E-4F, 6.731706E-4F, 7.16917E-4F, 7.635063E-4F, 8.1312325E-4F, 8.6596457E-4F, 9.2223985E-4F, 9.821722E-4F, 0.0010459992F, 0.0011139743F, 0.0011863665F, 0.0012634633F, 0.0013455702F, 0.0014330129F, 0.0015261382F, 0.0016253153F, 0.0017309374F, 0.0018434235F, 0.0019632196F, 0.0020908006F, 0.0022266726F, 0.0023713743F, 0.0025254795F, 0.0026895993F, 0.0028643848F, 0.0030505287F, 0.003248769F, 0.0034598925F, 0.0036847359F, 0.0039241905F, 0.0041792067F, 0.004450795F, 0.004740033F, 0.005048067F, 0.0053761187F, 0.005725489F, 0.0060975635F, 0.0064938175F, 0.0069158226F, 0.0073652514F, 0.007843887F, 0.008353627F, 0.008896492F, 0.009474637F, 0.010090352F, 0.01074608F, 0.011444421F, 0.012188144F, 0.012980198F, 0.013823725F, 0.014722068F, 0.015678791F, 0.016697686F, 0.017782796F, 0.018938422F, 0.020169148F, 0.021479854F, 0.022875736F, 0.02436233F, 0.025945531F, 0.027631618F, 0.029427277F, 0.031339627F, 0.03337625F, 0.035545226F, 0.037855156F, 0.0403152F, 0.042935107F, 0.045725275F, 0.048696756F, 0.05186135F, 0.05523159F, 0.05882085F, 0.062643364F, 0.06671428F, 0.07104975F, 0.075666964F, 0.08058423F, 0.08582105F, 0.09139818F, 0.097337745F, 0.1036633F, 0.11039993F, 0.11757434F, 0.12521498F, 0.13335215F, 0.14201812F, 0.15124726F, 0.16107617F, 0.1715438F, 0.18269168F, 0.19456401F, 0.20720787F, 0.22067343F, 0.23501402F, 0.25028655F, 0.26655158F, 0.28387362F, 0.3023213F, 0.32196787F, 0.34289113F, 0.36517414F, 0.3889052F, 0.41417846F, 0.44109413F, 0.4697589F, 0.50028646F, 0.53279793F, 0.5674221F, 0.6042964F, 0.64356697F, 0.6853896F, 0.72993004F, 0.777365F, 0.8278826F, 0.88168305F, 0.9389798F, 1.0F};
private static final float[] EXP_LUT_16_1024 = new float[]{
1.0649863E-7F, 1.1341951E-7F, 1.2079015E-7F, 1.2863978E-7F,
1.369995E-7F, 1.459025E-7F, 1.5538409E-7F, 1.6548181E-7F,
1.7623574E-7F, 1.8768856E-7F, 1.998856E-7F, 2.128753E-7F,
2.2670913E-7F, 2.4144197E-7F, 2.5713223E-7F, 2.7384212E-7F,
2.9163792E-7F, 3.1059022E-7F, 3.307741E-7F, 3.5226967E-7F,
3.7516213E-7F, 3.995423E-7F, 4.255068E-7F, 4.5315863E-7F,
4.8260745E-7F, 5.1397E-7F, 5.4737063E-7F, 5.829419E-7F,
6.208247E-7F, 6.611694E-7F, 7.041359E-7F, 7.4989464E-7F,
7.98627E-7F, 8.505263E-7F, 9.057983E-7F, 9.646621E-7F,
1.0273513E-6F, 1.0941144E-6F, 1.1652161E-6F, 1.2409384E-6F,
1.3215816E-6F, 1.4074654E-6F, 1.4989305E-6F, 1.5963394E-6F,
1.7000785E-6F, 1.8105592E-6F, 1.9282195E-6F, 2.053526E-6F,
2.1869757E-6F, 2.3290977E-6F, 2.4804558E-6F, 2.6416496E-6F,
2.813319E-6F, 2.9961443E-6F, 3.1908505E-6F, 3.39821E-6F,
3.619045E-6F, 3.8542307E-6F, 4.1047006E-6F, 4.371447E-6F,
4.6555283E-6F, 4.958071E-6F, 5.280274E-6F, 5.623416E-6F,
5.988857E-6F, 6.3780467E-6F, 6.7925284E-6F, 7.2339453E-6F,
7.704048E-6F, 8.2047E-6F, 8.737888E-6F, 9.305725E-6F,
9.910464E-6F, 1.0554501E-5F, 1.1240392E-5F, 1.1970856E-5F,
1.2748789E-5F, 1.3577278E-5F, 1.4459606E-5F, 1.5399271E-5F,
1.6400005E-5F, 1.7465769E-5F, 1.8600793E-5F, 1.9809577E-5F,
2.1096914E-5F, 2.2467912E-5F, 2.3928002E-5F, 2.5482977E-5F,
2.7139005E-5F, 2.890265E-5F, 3.078091E-5F, 3.2781227E-5F,
3.4911533E-5F, 3.718028E-5F, 3.9596467E-5F, 4.2169668E-5F,
4.491009E-5F, 4.7828602E-5F, 5.0936775E-5F, 5.424693E-5F,
5.7772202E-5F, 6.152657E-5F, 6.552491E-5F, 6.9783084E-5F,
7.4317984E-5F, 7.914758E-5F, 8.429104E-5F, 8.976875E-5F,
9.560242E-5F, 1.0181521E-4F, 1.0843174E-4F, 1.1547824E-4F,
1.2298267E-4F, 1.3097477E-4F, 1.3948625E-4F, 1.4855085E-4F,
1.5820454E-4F, 1.6848555E-4F, 1.7943469E-4F, 1.9109536E-4F,
2.0351382E-4F, 2.167393E-4F, 2.3082423E-4F, 2.4582449E-4F,
2.6179955E-4F, 2.7881275E-4F, 2.9693157E-4F, 3.1622787E-4F,
3.3677815E-4F, 3.5866388E-4F, 3.8197188E-4F, 4.0679457E-4F,
4.3323037E-4F, 4.613841E-4F, 4.913675E-4F, 5.2329927E-4F,
5.573062E-4F, 5.935231E-4F, 6.320936E-4F, 6.731706E-4F,
7.16917E-4F, 7.635063E-4F, 8.1312325E-4F, 8.6596457E-4F,
9.2223985E-4F, 9.821722E-4F, 0.0010459992F, 0.0011139743F,
0.0011863665F, 0.0012634633F, 0.0013455702F, 0.0014330129F,
0.0015261382F, 0.0016253153F, 0.0017309374F, 0.0018434235F,
0.0019632196F, 0.0020908006F, 0.0022266726F, 0.0023713743F,
0.0025254795F, 0.0026895993F, 0.0028643848F, 0.0030505287F,
0.003248769F, 0.0034598925F, 0.0036847359F, 0.0039241905F,
0.0041792067F, 0.004450795F, 0.004740033F, 0.005048067F,
0.0053761187F, 0.005725489F, 0.0060975635F, 0.0064938175F,
0.0069158226F, 0.0073652514F, 0.007843887F, 0.008353627F,
0.008896492F, 0.009474637F, 0.010090352F, 0.01074608F,
0.011444421F, 0.012188144F, 0.012980198F, 0.013823725F,
0.014722068F, 0.015678791F, 0.016697686F, 0.017782796F,
0.018938422F, 0.020169148F, 0.021479854F, 0.022875736F,
0.02436233F, 0.025945531F, 0.027631618F, 0.029427277F,
0.031339627F, 0.03337625F, 0.035545226F, 0.037855156F,
0.0403152F, 0.042935107F, 0.045725275F, 0.048696756F,
0.05186135F, 0.05523159F, 0.05882085F, 0.062643364F,
0.06671428F, 0.07104975F, 0.075666964F, 0.08058423F,
0.08582105F, 0.09139818F, 0.097337745F, 0.1036633F,
0.11039993F, 0.11757434F, 0.12521498F, 0.13335215F,
0.14201812F, 0.15124726F, 0.16107617F, 0.1715438F,
0.18269168F, 0.19456401F, 0.20720787F, 0.22067343F,
0.23501402F, 0.25028655F, 0.26655158F, 0.28387362F,
0.3023213F, 0.32196787F, 0.34289113F, 0.36517414F,
0.3889052F, 0.41417846F, 0.44109413F, 0.4697589F,
0.50028646F, 0.53279793F, 0.5674221F, 0.6042964F,
0.64356697F, 0.6853896F, 0.72993004F, 0.777365F,
0.8278826F, 0.88168305F, 0.9389798F, 1.0F};
private static final int[] _a = new int[]{256, 128, 86, 64};
private static boolean[] _g;
private static int[] _i;
@ -204,7 +275,7 @@ public final class kn_ {
int var12 = 0;
final int var13 = var7 < 0 ? var10 - 1 : var10 + 1;
var9 -= (var10 < 0 ? -var10 : var10) * var8;
var5[var1] *= _j[var2];
var5[var1] *= EXP_LUT_16_1024[var2];
if (var3 > var6) {
var3 = var6;
}
@ -218,7 +289,7 @@ public final class kn_ {
var11 += var10;
}
var5[var14] *= _j[var11];
var5[var14] *= EXP_LUT_16_1024[var11];
}
}
@ -276,7 +347,7 @@ public final class kn_ {
}
}
final float var16 = _j[var7];
final float var16 = EXP_LUT_16_1024[var7];
for (var9 = var6; var9 < var2; ++var9) {
var1[var9] *= var16;

View File

@ -1,147 +0,0 @@
package funorb.audio;
import funorb.data.NodeList;
import org.jetbrains.annotations.NotNull;
import java.util.Iterator;
import java.util.Objects;
public final class rc_ extends MixerInterface_idk {
public final NodeList<MixerTrackConfig_idk> _n = new NodeList<>();
public final vk_ _o = new vk_();
private final MidiPlayer_idk _m;
public rc_(final MidiPlayer_idk var1) {
this._m = var1;
}
@Override
public @NotNull Iterator<MixerInterface_idk> iterator() {
return this._n.stream().<MixerInterface_idk>map(var1 -> var1._K).filter(Objects::nonNull).iterator();
}
@Override
public int a784() {
return 0;
}
@Override
public void generateAudio2_idk(final int len) {
this._o.generateAudio2_idk(len);
for (final MixerTrackConfig_idk var3 : this._n) {
if (!this._m.a258(var3)) {
int var2 = len;
do {
if (var3._p >= var2) {
this.a222(var3, var2);
var3._p -= var2;
break;
}
this.a222(var3, var3._p);
var2 -= var3._p;
} while (!this._m.a543(0, null, var3, var2));
}
}
}
@Override
public void generateAudio1_idk(final int[] dest, final int offset, final int len) {
this._o.generateAudio1_idk(dest, offset, len);
for (final MixerTrackConfig_idk var6 : this._n) {
if (!this._m.a258(var6)) {
int var4 = offset;
int var5 = len;
do {
if (var6._p >= var5) {
this.a829(dest, var4, var6, var5, var4 + var5);
var6._p -= var5;
break;
}
this.a829(dest, var4, var6, var6._p, var4 + var5);
var5 -= var6._p;
var4 += var6._p;
} while (!this._m.a543(var4, dest, var6, var5));
}
}
}
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;
var2._j = 1048575 & var2._j + var3 * var4;
if (var5 <= var3) {
if (this._m._t[var2._y] == 0) {
var2._K = al_.a771(var2._M, var2._K.f784(), var2._K.getVolume(), var2._K.l784());
} else {
var2._K = al_.a771(var2._M, var2._K.f784(), 0, var2._K.l784());
this._m.a559(var2, var2._A._k[var2._H] < 0);
}
if (var2._A._k[var2._H] < 0) {
assert var2._K != null;
var2._K.f150();
}
var3 = var2._j / var4;
}
}
assert var2._K != null;
var2._K.generateAudio2_idk(var3);
}
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;
while (true) {
final int var8 = (-var3._j + 1048575 + var7) / var7;
if (var8 > var4) {
var3._j += var7 * var4;
break;
}
var3._K.generateAudio1_idk(var1, var2, var8);
var3._j += var8 * var7 - 1048576;
var2 += var8;
var4 -= var8;
int var9 = SampledAudioChannel.SAMPLES_PER_SECOND / 100;
final int var10 = 262144 / var7;
if (var10 < var9) {
var9 = var10;
}
final al_ var11 = var3._K;
if (this._m._t[var3._y] == 0) {
var3._K = al_.a771(var3._M, var11.f784(), var11.getVolume(), var11.l784());
} else {
var3._K = al_.a771(var3._M, var11.f784(), 0, var11.l784());
this._m.a559(var3, var3._A._k[var3._H] < 0);
var3._K.a093(var9, var11.getVolume());
}
if (var3._A._k[var3._H] < 0) {
assert var3._K != null;
var3._K.f150();
}
var11.g150(var9);
var11.generateAudio1_idk(var1, var2, var6 - var2);
if (var11.e801()) {
this._o.addFirst(var11);
}
}
}
var3._K.generateAudio1_idk(var1, var2, var4);
}
}

View File

@ -1,38 +0,0 @@
package funorb.audio;
import funorb.data.NodeList;
import org.jetbrains.annotations.NotNull;
import java.util.Iterator;
public final class vk_ extends MixerInterface_idk {
private final NodeList<MixerInterface_idk> _l = new NodeList<>();
@Override
public @NotNull Iterator<MixerInterface_idk> iterator() {
return this._l.iterator();
}
@Override
public int a784() {
return 0;
}
@Override
public synchronized void generateAudio2_idk(final int len) {
for (final MixerInterface_idk var2 : this._l) {
var2.generateAudio2_idk(len);
}
}
public synchronized void addFirst(final al_ var1) {
this._l.addFirst(var1);
}
@Override
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

@ -5,7 +5,7 @@ import funorb.audio.AudioThread;
import funorb.audio.SongData;
import funorb.audio.SampledAudioChannel;
import funorb.audio.h_;
import funorb.audio.vk_;
import funorb.audio.AudioSourceSum_idk;
import funorb.awt.FullScreenCanvas;
import funorb.awt.KeyState;
import funorb.awt.MouseState;
@ -4263,15 +4263,15 @@ public final class ShatteredPlansClient extends JagexApplet {
super.initialize();
final h_ musicTn = new h_();
musicTn._u.initialize();
musicTn._r.initialize();
musicTn._u.setVolume(Sounds.MAX_VOLUME);
musicTn._r.setVolume(Sounds.MAX_VOLUME);
musicTn.midiPlayer2.initialize();
musicTn.midiPlayer1.initialize();
musicTn.midiPlayer2.setVolume(Sounds.MAX_VOLUME);
musicTn.midiPlayer1.setVolume(Sounds.MAX_VOLUME);
Sounds.musicChannel = createAudioChannel(0, SampledAudioChannel.SAMPLES_PER_SECOND);
Sounds.soundsChannel = createAudioChannel(1, 1102);
Sounds.soundsTn = new vk_();
Sounds.soundsTn = new AudioSourceSum_idk();
Sounds.soundsChannel.setSource(Sounds.soundsTn);
Sounds.musicTn = musicTn;
Sounds.musicTn.setVolume(Sounds.musicVolume);

View File

@ -5,10 +5,10 @@ import funorb.audio.PlayingSound;
import funorb.audio.SampledAudioChannel;
import funorb.audio.SoundEffect;
import funorb.audio.SoundLoader;
import funorb.audio.al_;
import funorb.audio.AudioSamplePlayback_idk;
import funorb.audio.h_;
import funorb.audio.kk_;
import funorb.audio.vk_;
import funorb.audio.AudioSampleData_idk;
import funorb.audio.AudioSourceSum_idk;
import funorb.cache.ResourceLoader;
import java.util.ArrayList;
@ -34,7 +34,7 @@ public final class Sounds {
public static int musicVolume = 256;
public static final List<PlayingSound> playingSounds = new ArrayList<>();
public static vk_ soundsTn;
public static AudioSourceSum_idk soundsTn;
public static h_ musicTn;
static SampledAudioChannel soundsChannel;
static SampledAudioChannel musicChannel;
@ -59,24 +59,24 @@ public final class Sounds {
MUSIC_LOSE = SongData.load(loader1, "shattered_plans_lose");
ShatteredPlansClient.currentTrack = MUSIC_IN_GAME_2;
musicTn._u.a350(SoundLoader.globalLoader, loader2, MUSIC_INTRO);
musicTn._u.a350(SoundLoader.globalLoader, loader2, MUSIC_IN_GAME_1);
musicTn._u.a350(SoundLoader.globalLoader, loader2, MUSIC_IN_GAME_2);
musicTn._u.f150();
musicTn.midiPlayer2.a350(SoundLoader.globalLoader, loader2, MUSIC_INTRO);
musicTn.midiPlayer2.a350(SoundLoader.globalLoader, loader2, MUSIC_IN_GAME_1);
musicTn.midiPlayer2.a350(SoundLoader.globalLoader, loader2, MUSIC_IN_GAME_2);
musicTn.midiPlayer2.f150();
SoundLoader.globalLoader = null;
}
public static void play(final SoundEffect effect) {
play(effect._f, effect.volume);
play(effect.sample, effect.volume);
}
public static PlayingSound play(final SoundEffect effect, final int volume) {
return play(effect._f, effect.volume * volume / 96);
return play(effect.sample, effect.volume * volume / 96);
}
private static PlayingSound play(final kk_ var1, final int volume) {
final al_ var01 = al_.a638(var1, volume);
private static PlayingSound play(final AudioSampleData_idk var1, final int volume) {
final AudioSamplePlayback_idk var01 = AudioSamplePlayback_idk.a638(var1, volume);
assert var01 != null;
final PlayingSound sound = new PlayingSound(var01);
playingSounds.add(sound);