This commit is contained in:
thedaneeffect committed 2021-03-10 06:08:06 -05:00
1 parent f1bf79bc6a
commit 3261a066c4
5 files changed
+518 -431

No files matched your search

+129 -105
View File
@@ -1,149 +1,173 @@
// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
public class SoundTrack {
public static final SoundTrack[] A_TRACK_ARRAY_325 = new SoundTrack[5000];
public static final int[] anIntArray326 = new int[5000];
public static byte[] aByteArray327;
public static Packet aPacket_328;
public final SoundTone[] aToneArray329 = new SoundTone[10];
public int anInt330;
public int anInt331;
public static final SoundTrack[] tracks = new SoundTrack[5000];
public static final int[] delays = new int[5000];
public static byte[] buffer;
public static Packet packet;
public SoundTrack() {
}
public static void method240(Packet src) {
buffer = new byte[441000];
SoundTrack.packet = new Packet(buffer);
SoundTone.init();
public static void method240(Packet packet) {
aByteArray327 = new byte[0x6baa8];
aPacket_328 = new Packet(aByteArray327);
SoundTone.method166();
do {
int j = packet.get2U();
if (j == 65535) {
int id = src.get2U();
if (id == 65535) {
return;
}
A_TRACK_ARRAY_325[j] = new SoundTrack();
A_TRACK_ARRAY_325[j].method242(packet);
anIntArray326[j] = A_TRACK_ARRAY_325[j].method243();
tracks[id] = new SoundTrack();
tracks[id].read(src);
delays[id] = tracks[id].trim();
} while (true);
}
public static Packet method241(int i, int j) {
if (A_TRACK_ARRAY_325[j] != null) {
SoundTrack track = A_TRACK_ARRAY_325[j];
return track.method244(i);
public static Packet generate(int loopCount, int id) {
if (tracks[id] != null) {
SoundTrack track = tracks[id];
return track.getWaveform(loopCount);
} else {
return null;
}
}
public void method242(Packet packet) {
for (int i = 0; i < 10; i++) {
int j = packet.get1U();
if (j != 0) {
public final SoundTone[] tones = new SoundTone[10];
public int loopBegin;
public int loopEnd;
public SoundTrack() {
}
public void read(Packet packet) {
for (int tone = 0; tone < 10; tone++) {
if (packet.get1U() != 0) {
packet.position--;
aToneArray329[i] = new SoundTone();
aToneArray329[i].method169(packet);
tones[tone] = new SoundTone();
tones[tone].read(packet);
}
}
anInt330 = packet.get2U();
anInt331 = packet.get2U();
loopBegin = packet.get2U();
loopEnd = packet.get2U();
}
public int method243() {
int j = 0x98967f;
for (int k = 0; k < 10; k++) {
if ((aToneArray329[k] != null) && ((aToneArray329[k].anInt114 / 20) < j)) {
j = aToneArray329[k].anInt114 / 20;
public int trim() {
int start = 9999999;
for (int tone = 0; tone < 10; tone++) {
if ((tones[tone] != null) && ((tones[tone].start / 20) < start)) {
start = tones[tone].start / 20;
}
}
if ((anInt330 < anInt331) && ((anInt330 / 20) < j)) {
j = anInt330 / 20;
if ((loopBegin < loopEnd) && ((loopBegin / 20) < start)) {
start = loopBegin / 20;
}
if ((j == 0x98967f) || (j == 0)) {
if ((start == 9999999) || (start == 0)) {
return 0;
}
for (int l = 0; l < 10; l++) {
if (aToneArray329[l] != null) {
aToneArray329[l].anInt114 -= j * 20;
for (int tone = 0; tone < 10; tone++) {
if (tones[tone] != null) {
tones[tone].start -= start * 20;
}
}
if (anInt330 < anInt331) {
anInt330 -= j * 20;
anInt331 -= j * 20;
if (loopBegin < loopEnd) {
loopBegin -= start * 20;
loopEnd -= start * 20;
}
return j;
return start;
}
public Packet method244(int i) {
int k = method245(i);
aPacket_328.position = 0;
aPacket_328.put4(0x52494646);
aPacket_328.put4LE(36 + k);
aPacket_328.put4(0x57415645);
aPacket_328.put4(0x666d7420);
aPacket_328.put4LE(16);
aPacket_328.put2LE(1);
aPacket_328.put2LE(1);
aPacket_328.put4LE(22050);
aPacket_328.put4LE(22050);
aPacket_328.put2LE(1);
aPacket_328.put2LE(8);
aPacket_328.put4(0x64617461);
aPacket_328.put4LE(k);
aPacket_328.position += k;
return aPacket_328;
/**
* <a href="http://soundfile.sapp.org/doc/WaveFormat/">WaveFormat</a>
*
* @param loopCount the loop count.
* @return the {@link Packet} containing the waveform data.
*/
public Packet getWaveform(int loopCount) {
int length = generate(loopCount);
packet.position = 0;
packet.put4(0x52494646); // "RIFF" ChunkID
packet.put4LE(36 + length); // ChunkSize
packet.put4(0x57415645); // "WAVE" format
packet.put4(0x666d7420); // "fmt " chunk id
packet.put4LE(16); // chunk size
packet.put2LE(1); // audio format
packet.put2LE(1); // num channels
packet.put4LE(22050); // sample rate
packet.put4LE(22050); // byte rate
packet.put2LE(1); // block align
packet.put2LE(8); // bits per sample
packet.put4(0x64617461); // "data"
packet.put4LE(length);
packet.position += length;
return packet;
}
public int method245(int i) {
int j = 0;
for (int k = 0; k < 10; k++) {
if ((aToneArray329[k] != null) && ((aToneArray329[k].anInt113 + aToneArray329[k].anInt114) > j)) {
j = aToneArray329[k].anInt113 + aToneArray329[k].anInt114;
public int generate(int loopCount) {
int duration = 0;
for (int tone = 0; tone < 10; tone++) {
if ((tones[tone] != null) && ((tones[tone].length + tones[tone].start) > duration)) {
duration = tones[tone].length + tones[tone].start;
}
}
if (j == 0) {
if (duration == 0) {
return 0;
}
int l = (22050 * j) / 1000;
int i1 = (22050 * anInt330) / 1000;
int j1 = (22050 * anInt331) / 1000;
if ((i1 < 0) || (j1 < 0) || (j1 > l) || (i1 >= j1)) {
i = 0;
int sampleCount = (22050 * duration) / 1000;
int loopStart = (22050 * loopBegin) / 1000;
int loopStop = (22050 * loopEnd) / 1000;
if ((loopStart < 0) || (loopStop < 0) || (loopStop > sampleCount) || (loopStart >= loopStop)) {
loopCount = 0;
}
int k1 = l + ((j1 - i1) * (i - 1));
for (int l1 = 44; l1 < (k1 + 44); l1++) {
aByteArray327[l1] = -128;
int totalSampleCount = sampleCount + ((loopStop - loopStart) * (loopCount - 1));
for (int sample = 44; sample < (totalSampleCount + 44); sample++) {
buffer[sample] = -128;
}
for (int i2 = 0; i2 < 10; i2++) {
if (aToneArray329[i2] != null) {
int j2 = (aToneArray329[i2].anInt113 * 22050) / 1000;
int i3 = (aToneArray329[i2].anInt114 * 22050) / 1000;
int[] ai = aToneArray329[i2].method167(j2, aToneArray329[i2].anInt113);
for (int l3 = 0; l3 < j2; l3++) {
aByteArray327[l3 + i3 + 44] += (byte) (ai[l3] >> 8);
for (int tone = 0; tone < 10; tone++) {
if (tones[tone] == null) {
continue;
}
int toneSampleCount = (tones[tone].length * 22050) / 1000;
int start = (tones[tone].start * 22050) / 1000;
int[] samples = tones[tone].generate(toneSampleCount, tones[tone].length);
for (int sample = 0; sample < toneSampleCount; sample++) {
buffer[sample + start + 44] += (byte) (samples[sample] >> 8);
}
}
if (loopCount > 1) {
// All of these 44's are because we're avoiding the area where the WAV header will be written.
loopStart += 44;
loopStop += 44;
sampleCount += 44;
// Moves the end of the sound (after the loops) to the true end of the buffer.
int endOffset = (totalSampleCount += 44) - sampleCount;
for (int sample = sampleCount - 1; sample >= loopStop; sample--) {
buffer[sample + endOffset] = buffer[sample];
}
// Duplicates loop area.
for (int loop = 1; loop < loopCount; loop++) {
int offset = (loopStop - loopStart) * loop;
for (int sample = loopStart; sample < loopStop; sample++) {
buffer[sample + offset] = buffer[sample];
}
}
totalSampleCount -= 44;
}
if (i > 1) {
i1 += 44;
j1 += 44;
l += 44;
int k2 = (k1 += 44) - l;
for (int j3 = l - 1; j3 >= j1; j3--) {
aByteArray327[j3 + k2] = aByteArray327[j3];
}
for (int k3 = 1; k3 < i; k3++) {
int l2 = (j1 - i1) * k3;
for (int i4 = i1; i4 < j1; i4++) {
aByteArray327[i4 + l2] = aByteArray327[i4];
}
}
k1 -= 44;
}
return k1;
return totalSampleCount;
}
}