Sound
This commit is contained in:
1 parent
f1bf79bc6a
commit
3261a066c4
5 files changed
+518
-431
No files matched your search
@@ -6657,7 +6657,7 @@ public class Game extends GameShell {
|
||||
flag1 = true;
|
||||
}
|
||||
} else {
|
||||
Packet packet = SoundTrack.method241(anIntArray1241[i], anIntArray1207[i]);
|
||||
Packet packet = SoundTrack.generate(anIntArray1241[i], anIntArray1207[i]);
|
||||
if ((System.currentTimeMillis() + (long) (packet.position / 22)) > (aLong1172 + (long) (anInt1257 / 22))) {
|
||||
anInt1257 = packet.position;
|
||||
aLong1172 = System.currentTimeMillis();
|
||||
@@ -9071,7 +9071,7 @@ public class Game extends GameShell {
|
||||
if ((aPlayer_1126.anIntArray1500[0] >= (k3 - i14)) && (aPlayer_1126.anIntArray1500[0] <= (k3 + i14)) && (aPlayer_1126.anIntArray1501[0] >= (j6 - i14)) && (aPlayer_1126.anIntArray1501[0] <= (j6 + i14)) && aBoolean848 && !aBoolean960 && (anInt1062 < 50)) {
|
||||
anIntArray1207[anInt1062] = i9;
|
||||
anIntArray1241[anInt1062] = i16;
|
||||
anIntArray1250[anInt1062] = SoundTrack.anIntArray326[i9];
|
||||
anIntArray1250[anInt1062] = SoundTrack.delays[i9];
|
||||
anInt1062++;
|
||||
}
|
||||
}
|
||||
@@ -10066,7 +10066,7 @@ public class Game extends GameShell {
|
||||
if (aBoolean848 && !aBoolean960 && (anInt1062 < 50)) {
|
||||
anIntArray1207[anInt1062] = i4;
|
||||
anIntArray1241[anInt1062] = l11;
|
||||
anIntArray1250[anInt1062] = k17 + SoundTrack.anIntArray326[i4];
|
||||
anIntArray1250[anInt1062] = k17 + SoundTrack.delays[i4];
|
||||
anInt1062++;
|
||||
}
|
||||
anInt1008 = -1;
|
||||
|
||||
@@ -1,63 +1,65 @@
|
||||
// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3)
|
||||
|
||||
/**
|
||||
* A {@link SoundEnvelope} is essentially a curve and can be visualized similarly to <a href="https://docs.unity3d.com/Manual/EditingCurves.html">unity curves</a>.
|
||||
* Their main function is to provide shapes for sound related modifiers to take the form of.
|
||||
*
|
||||
* @see SoundTone
|
||||
*/
|
||||
public class SoundEnvelope {
|
||||
|
||||
public int anInt535;
|
||||
public int[] anIntArray536;
|
||||
public int[] anIntArray537;
|
||||
public int anInt538;
|
||||
public int anInt539;
|
||||
public int anInt540;
|
||||
public int anInt541;
|
||||
public int anInt542;
|
||||
public int anInt543;
|
||||
public int anInt544;
|
||||
public int anInt545;
|
||||
public int length;
|
||||
public int[] durations;
|
||||
public int[] peaks;
|
||||
public int start;
|
||||
public int end;
|
||||
public int form;
|
||||
public int threshold;
|
||||
public int position;
|
||||
public int delta;
|
||||
public int amplitude;
|
||||
public int ticks;
|
||||
|
||||
public SoundEnvelope() {
|
||||
}
|
||||
|
||||
public void method325(Packet packet) {
|
||||
anInt540 = packet.get1U();
|
||||
anInt538 = packet.get4();
|
||||
anInt539 = packet.get4();
|
||||
method326(packet);
|
||||
public void read(Packet packet) {
|
||||
form = packet.get1U();
|
||||
start = packet.get4();
|
||||
end = packet.get4();
|
||||
readShape(packet);
|
||||
}
|
||||
|
||||
public void method326(Packet packet) {
|
||||
anInt535 = packet.get1U();
|
||||
anIntArray536 = new int[anInt535];
|
||||
anIntArray537 = new int[anInt535];
|
||||
for (int i = 0; i < anInt535; i++) {
|
||||
anIntArray536[i] = packet.get2U();
|
||||
anIntArray537[i] = packet.get2U();
|
||||
public void readShape(Packet packet) {
|
||||
length = packet.get1U();
|
||||
durations = new int[length];
|
||||
peaks = new int[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
durations[i] = packet.get2U();
|
||||
peaks[i] = packet.get2U();
|
||||
}
|
||||
}
|
||||
|
||||
public void method327() {
|
||||
anInt541 = 0;
|
||||
anInt542 = 0;
|
||||
anInt543 = 0;
|
||||
anInt544 = 0;
|
||||
anInt545 = 0;
|
||||
public void reset() {
|
||||
threshold = 0;
|
||||
position = 0;
|
||||
delta = 0;
|
||||
amplitude = 0;
|
||||
ticks = 0;
|
||||
}
|
||||
|
||||
public int method328(int i) {
|
||||
if (anInt545 >= anInt541) {
|
||||
anInt544 = anIntArray537[anInt542++] << 15;
|
||||
if (anInt542 >= anInt535) {
|
||||
anInt542 = anInt535 - 1;
|
||||
public int evaluate(int delta) {
|
||||
if (ticks >= threshold) {
|
||||
amplitude = peaks[position++] << 15;
|
||||
if (position >= length) {
|
||||
position = length - 1;
|
||||
}
|
||||
anInt541 = (int) (((double) anIntArray536[anInt542] / 65536D) * (double) i);
|
||||
if (anInt541 > anInt545) {
|
||||
anInt543 = ((anIntArray537[anInt542] << 15) - anInt544) / (anInt541 - anInt545);
|
||||
threshold = (int) (((double) durations[position] / 65536D) * (double) delta);
|
||||
if (threshold > ticks) {
|
||||
this.delta = ((peaks[position] << 15) - amplitude) / (threshold - ticks);
|
||||
}
|
||||
}
|
||||
anInt544 += anInt543;
|
||||
anInt545++;
|
||||
return (anInt544 - anInt543) >> 15;
|
||||
amplitude += this.delta;
|
||||
ticks++;
|
||||
return (amplitude - this.delta) >> 15;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,104 +1,119 @@
|
||||
// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3)
|
||||
|
||||
/**
|
||||
* https://www.rune-server.ee/runescape-development/rs2-client/snippets/421977-sound-effects.html
|
||||
* https://ccrma.stanford.edu/~jos/filters/Direct_Form_I.html
|
||||
* https://en.wikipedia.org/wiki/Digital_biquad_filter
|
||||
*/
|
||||
public class SoundFilter {
|
||||
|
||||
public static final float[][] aFloatArrayArray669 = new float[2][8];
|
||||
public static final int[][] anIntArrayArray670 = new int[2][8];
|
||||
public static float aFloat671;
|
||||
public static int anInt672;
|
||||
public final int[] anIntArray665 = new int[2];
|
||||
public final int[][][] anIntArrayArrayArray666 = new int[2][2][4];
|
||||
public final int[][][] anIntArrayArrayArray667 = new int[2][2][4];
|
||||
public final int[] anIntArray668 = new int[2];
|
||||
public static final float[][] coefficient = new float[2][8];
|
||||
public static final int[][] coefficient16 = new int[2][8];
|
||||
public static float unity;
|
||||
public static int unity16;
|
||||
public final int[] pairs = new int[2];
|
||||
public final int[][][] frequencies = new int[2][2][4];
|
||||
public final int[][][] ranges = new int[2][2][4];
|
||||
public final int[] unities = new int[2];
|
||||
|
||||
public SoundFilter() {
|
||||
}
|
||||
|
||||
public float method541(int i, int j, float f) {
|
||||
float f1 = (float) anIntArrayArrayArray667[i][0][j] + (f * (float) (anIntArrayArrayArray667[i][1][j] - anIntArrayArrayArray667[i][0][j]));
|
||||
f1 *= 0.001525879F;
|
||||
return 1.0F - (float) Math.pow(10D, -f1 / 20F);
|
||||
public float gain(int direction, int pair, float delta) {
|
||||
float g = (float) ranges[direction][0][pair] + (delta * (float) (ranges[direction][1][pair] - ranges[direction][0][pair]));
|
||||
g *= 0.001525879F;
|
||||
return 1.0F - (float) Math.pow(10D, -g / 20F);
|
||||
}
|
||||
|
||||
public float method542(float f) {
|
||||
float f1 = 32.7032F * (float) Math.pow(2D, f);
|
||||
return (f1 * 3.141593F) / 11025F;
|
||||
public float normalize(float f) {
|
||||
return (32.7032F * (float) Math.pow(2D, f) * 3.141593F) / 11025F;
|
||||
}
|
||||
|
||||
public float method543(float f, int i, int j) {
|
||||
float f1 = (float) anIntArrayArrayArray666[j][0][i] + (f * (float) (anIntArrayArrayArray666[j][1][i] - anIntArrayArrayArray666[j][0][i]));
|
||||
public float phase(int direction, int pair, float delta) {
|
||||
float f1 = (float) frequencies[direction][0][pair] + (delta * (float) (frequencies[direction][1][pair] - frequencies[direction][0][pair]));
|
||||
f1 *= 0.0001220703F;
|
||||
return method542(f1);
|
||||
return normalize(f1);
|
||||
}
|
||||
|
||||
public int method544(int i, float f) {
|
||||
if (i == 0) {
|
||||
float f1 = (float) anIntArray668[0] + ((float) (anIntArray668[1] - anIntArray668[0]) * f);
|
||||
f1 *= 0.003051758F;
|
||||
aFloat671 = (float) Math.pow(0.10000000000000001D, f1 / 20F);
|
||||
anInt672 = (int) (aFloat671 * 65536F);
|
||||
public int evaluate(int direction, float delta) {
|
||||
if (direction == 0) {
|
||||
float u = (float) unities[0] + ((float) (unities[1] - unities[0]) * delta);
|
||||
u *= 0.003051758F;
|
||||
unity = (float) Math.pow(0.10000000000000001D, u / 20F);
|
||||
unity16 = (int) (unity * 65536F);
|
||||
}
|
||||
if (anIntArray665[i] == 0) {
|
||||
|
||||
if (pairs[direction] == 0) {
|
||||
return 0;
|
||||
}
|
||||
float f2 = method541(i, 0, f);
|
||||
aFloatArrayArray669[i][0] = -2F * f2 * (float) Math.cos(method543(f, 0, i));
|
||||
aFloatArrayArray669[i][1] = f2 * f2;
|
||||
for (int k = 1; k < anIntArray665[i]; k++) {
|
||||
float f3 = method541(i, k, f);
|
||||
float f4 = -2F * f3 * (float) Math.cos(method543(f, k, i));
|
||||
float f5 = f3 * f3;
|
||||
aFloatArrayArray669[i][(k * 2) + 1] = aFloatArrayArray669[i][(k * 2) - 1] * f5;
|
||||
aFloatArrayArray669[i][k * 2] = (aFloatArrayArray669[i][(k * 2) - 1] * f4) + (aFloatArrayArray669[i][(k * 2) - 2] * f5);
|
||||
for (int j1 = (k * 2) - 1; j1 >= 2; j1--) {
|
||||
aFloatArrayArray669[i][j1] += (aFloatArrayArray669[i][j1 - 1] * f4) + (aFloatArrayArray669[i][j1 - 2] * f5);
|
||||
|
||||
float u = gain(direction, 0, delta);
|
||||
|
||||
coefficient[direction][0] = -2F * u * (float) Math.cos(phase(direction, 0, delta));
|
||||
coefficient[direction][1] = u * u;
|
||||
|
||||
for (int pair = 1; pair < pairs[direction]; pair++) {
|
||||
float g = gain(direction, pair, delta);
|
||||
float a = -2F * g * (float) Math.cos(phase(direction, pair, delta));
|
||||
float b = g * g;
|
||||
|
||||
coefficient[direction][(pair * 2) + 1] = coefficient[direction][(pair * 2) - 1] * b;
|
||||
coefficient[direction][pair * 2] = (coefficient[direction][(pair * 2) - 1] * a) + (coefficient[direction][(pair * 2) - 2] * b);
|
||||
|
||||
for (int j = (pair * 2) - 1; j >= 2; j--) {
|
||||
coefficient[direction][j] += (coefficient[direction][j - 1] * a) + (coefficient[direction][j - 2] * b);
|
||||
}
|
||||
aFloatArrayArray669[i][1] += (aFloatArrayArray669[i][0] * f4) + f5;
|
||||
aFloatArrayArray669[i][0] += f4;
|
||||
|
||||
coefficient[direction][1] += (coefficient[direction][0] * a) + b;
|
||||
coefficient[direction][0] += a;
|
||||
}
|
||||
if (i == 0) {
|
||||
for (int l = 0; l < (anIntArray665[0] * 2); l++) {
|
||||
aFloatArrayArray669[0][l] *= aFloat671;
|
||||
|
||||
if (direction == 0) {
|
||||
for (int l = 0; l < (pairs[0] * 2); l++) {
|
||||
coefficient[0][l] *= unity;
|
||||
}
|
||||
}
|
||||
for (int i1 = 0; i1 < (anIntArray665[i] * 2); i1++) {
|
||||
anIntArrayArray670[i][i1] = (int) (aFloatArrayArray669[i][i1] * 65536F);
|
||||
|
||||
for (int pair = 0; pair < (pairs[direction] * 2); pair++) {
|
||||
coefficient16[direction][pair] = (int) (coefficient[direction][pair] * 65536F);
|
||||
}
|
||||
return anIntArray665[i] * 2;
|
||||
|
||||
return pairs[direction] * 2;
|
||||
}
|
||||
|
||||
public void method545(Packet packet, SoundEnvelope envelope) {
|
||||
int i = packet.get1U();
|
||||
anIntArray665[0] = i >> 4;
|
||||
anIntArray665[1] = i & 0xf;
|
||||
if (i != 0) {
|
||||
anIntArray668[0] = packet.get2U();
|
||||
anIntArray668[1] = packet.get2U();
|
||||
int j = packet.get1U();
|
||||
for (int k = 0; k < 2; k++) {
|
||||
for (int l = 0; l < anIntArray665[k]; l++) {
|
||||
anIntArrayArrayArray666[k][0][l] = packet.get2U();
|
||||
anIntArrayArrayArray667[k][0][l] = packet.get2U();
|
||||
public void read(Packet packet, SoundEnvelope envelope) {
|
||||
int count = packet.get1U();
|
||||
pairs[0] = count >> 4;
|
||||
pairs[1] = count & 0xf;
|
||||
|
||||
if (count != 0) {
|
||||
unities[0] = packet.get2U();
|
||||
unities[1] = packet.get2U();
|
||||
|
||||
int migration = packet.get1U();
|
||||
|
||||
for (int direction = 0; direction < 2; direction++) {
|
||||
for (int pair = 0; pair < pairs[direction]; pair++) {
|
||||
frequencies[direction][0][pair] = packet.get2U();
|
||||
ranges[direction][0][pair] = packet.get2U();
|
||||
}
|
||||
}
|
||||
for (int i1 = 0; i1 < 2; i1++) {
|
||||
for (int j1 = 0; j1 < anIntArray665[i1]; j1++) {
|
||||
if ((j & (1 << (i1 * 4) << j1)) != 0) {
|
||||
anIntArrayArrayArray666[i1][1][j1] = packet.get2U();
|
||||
anIntArrayArrayArray667[i1][1][j1] = packet.get2U();
|
||||
|
||||
for (int direction = 0; direction < 2; direction++) {
|
||||
for (int pair = 0; pair < pairs[direction]; pair++) {
|
||||
if ((migration & (1 << (direction * 4) << pair)) != 0) {
|
||||
frequencies[direction][1][pair] = packet.get2U();
|
||||
ranges[direction][1][pair] = packet.get2U();
|
||||
} else {
|
||||
anIntArrayArrayArray666[i1][1][j1] = anIntArrayArrayArray666[i1][0][j1];
|
||||
anIntArrayArrayArray667[i1][1][j1] = anIntArrayArrayArray667[i1][0][j1];
|
||||
frequencies[direction][1][pair] = frequencies[direction][0][pair];
|
||||
ranges[direction][1][pair] = ranges[direction][0][pair];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((j != 0) || (anIntArray668[1] != anIntArray668[0])) {
|
||||
envelope.method326(packet);
|
||||
|
||||
if ((migration != 0) || (unities[1] != unities[0])) {
|
||||
envelope.readShape(packet);
|
||||
}
|
||||
} else {
|
||||
anIntArray668[0] = anIntArray668[1] = 0;
|
||||
unities[0] = unities[1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+255
-209
@@ -4,278 +4,324 @@
|
||||
|
||||
public class SoundTone {
|
||||
|
||||
public static int[] anIntArray115;
|
||||
public static int[] anIntArray116;
|
||||
public static int[] anIntArray117;
|
||||
public static final int[] anIntArray118 = new int[5];
|
||||
public static final int[] anIntArray119 = new int[5];
|
||||
public static final int[] anIntArray120 = new int[5];
|
||||
public static final int[] anIntArray121 = new int[5];
|
||||
public static final int[] anIntArray122 = new int[5];
|
||||
public SoundEnvelope aEnvelope_98;
|
||||
public SoundEnvelope aEnvelope_99;
|
||||
public SoundEnvelope aEnvelope_100;
|
||||
public SoundEnvelope aEnvelope_101;
|
||||
public SoundEnvelope aEnvelope_102;
|
||||
public SoundEnvelope aEnvelope_103;
|
||||
public SoundEnvelope aEnvelope_104;
|
||||
public SoundEnvelope aEnvelope_105;
|
||||
public final int[] anIntArray106 = new int[5];
|
||||
public final int[] anIntArray107 = new int[5];
|
||||
public final int[] anIntArray108 = new int[5];
|
||||
public int anInt109;
|
||||
public int anInt110 = 100;
|
||||
public SoundFilter aSoundFilter_111;
|
||||
public SoundEnvelope aEnvelope_112;
|
||||
public int anInt113 = 500;
|
||||
public int anInt114;
|
||||
public static final int[] tmpPhases = new int[5];
|
||||
public static final int[] tmpDelays = new int[5];
|
||||
public static final int[] tmpVolumes = new int[5];
|
||||
public static final int[] tmpSemitones = new int[5];
|
||||
public static final int[] tmpStarts = new int[5];
|
||||
public static int[] buffer;
|
||||
public static int[] noise;
|
||||
public static int[] sin;
|
||||
|
||||
public static void init() {
|
||||
noise = new int[32768];
|
||||
for (int i = 0; i < 32768; i++) {
|
||||
if (Math.random() > 0.5D) {
|
||||
noise[i] = 1;
|
||||
} else {
|
||||
noise[i] = -1;
|
||||
}
|
||||
}
|
||||
sin = new int[32768];
|
||||
for (int j = 0; j < 32768; j++) {
|
||||
sin[j] = (int) (Math.sin((double) j / 5215.1903000000002D) * 16384D);
|
||||
}
|
||||
buffer = new int[22050 * 10]; // 10 second buffer
|
||||
}
|
||||
|
||||
public final int[] harmonicVolume = new int[5];
|
||||
public final int[] harmonicSemitone = new int[5];
|
||||
public final int[] harmonicDelay = new int[5];
|
||||
public SoundEnvelope frequencyBase;
|
||||
public SoundEnvelope amplitudeBase;
|
||||
public SoundEnvelope frequencyModRate;
|
||||
public SoundEnvelope frequencyModRange;
|
||||
public SoundEnvelope amplitudeModRate;
|
||||
public SoundEnvelope amplitudeModRange;
|
||||
public SoundEnvelope release;
|
||||
public SoundEnvelope attack;
|
||||
public int reverbDelay;
|
||||
public int reverbVolume = 100;
|
||||
public SoundFilter filter;
|
||||
public SoundEnvelope filterRange;
|
||||
public int length = 500;
|
||||
public int start;
|
||||
|
||||
public SoundTone() {
|
||||
}
|
||||
|
||||
public static void method166() {
|
||||
anIntArray116 = new int[32768];
|
||||
for (int i = 0; i < 32768; i++) {
|
||||
if (Math.random() > 0.5D) {
|
||||
anIntArray116[i] = 1;
|
||||
} else {
|
||||
anIntArray116[i] = -1;
|
||||
}
|
||||
public int[] generate(int sampleCount, int length) {
|
||||
for (int sample = 0; sample < sampleCount; sample++) {
|
||||
buffer[sample] = 0;
|
||||
}
|
||||
anIntArray117 = new int[32768];
|
||||
for (int j = 0; j < 32768; j++) {
|
||||
anIntArray117[j] = (int) (Math.sin((double) j / 5215.1903000000002D) * 16384D);
|
||||
}
|
||||
anIntArray115 = new int[0x35d54];
|
||||
}
|
||||
|
||||
public int[] method167(int i, int j) {
|
||||
for (int k = 0; k < i; k++) {
|
||||
anIntArray115[k] = 0;
|
||||
if (length < 10) {
|
||||
return buffer;
|
||||
}
|
||||
if (j < 10) {
|
||||
return anIntArray115;
|
||||
|
||||
double samplesPerStep = (double) sampleCount / ((double) length + 0.0D);
|
||||
|
||||
frequencyBase.reset();
|
||||
amplitudeBase.reset();
|
||||
|
||||
int frequencyStart = 0;
|
||||
int frequencyDuration = 0;
|
||||
int frequencyPhase = 0;
|
||||
|
||||
if (frequencyModRate != null) {
|
||||
frequencyModRate.reset();
|
||||
frequencyModRange.reset();
|
||||
frequencyStart = (int) (((double) (frequencyModRate.end - frequencyModRate.start) * 32.768) / samplesPerStep);
|
||||
frequencyDuration = (int) (((double) frequencyModRate.start * 32.768) / samplesPerStep);
|
||||
}
|
||||
double d = (double) i / ((double) j + 0.0D);
|
||||
aEnvelope_98.method327();
|
||||
aEnvelope_99.method327();
|
||||
int l = 0;
|
||||
int i1 = 0;
|
||||
int j1 = 0;
|
||||
if (aEnvelope_100 != null) {
|
||||
aEnvelope_100.method327();
|
||||
aEnvelope_101.method327();
|
||||
l = (int) (((double) (aEnvelope_100.anInt539 - aEnvelope_100.anInt538) * 32.768000000000001D) / d);
|
||||
i1 = (int) (((double) aEnvelope_100.anInt538 * 32.768000000000001D) / d);
|
||||
|
||||
int amplitudeStart = 0;
|
||||
int amplitudeDuration = 0;
|
||||
int amplitudePhase = 0;
|
||||
|
||||
if (amplitudeModRate != null) {
|
||||
amplitudeModRate.reset();
|
||||
amplitudeModRange.reset();
|
||||
amplitudeStart = (int) (((double) (amplitudeModRate.end - amplitudeModRate.start) * 32.768) / samplesPerStep);
|
||||
amplitudeDuration = (int) (((double) amplitudeModRate.start * 32.768) / samplesPerStep);
|
||||
}
|
||||
int k1 = 0;
|
||||
int l1 = 0;
|
||||
int i2 = 0;
|
||||
if (aEnvelope_102 != null) {
|
||||
aEnvelope_102.method327();
|
||||
aEnvelope_103.method327();
|
||||
k1 = (int) (((double) (aEnvelope_102.anInt539 - aEnvelope_102.anInt538) * 32.768000000000001D) / d);
|
||||
l1 = (int) (((double) aEnvelope_102.anInt538 * 32.768000000000001D) / d);
|
||||
}
|
||||
for (int j2 = 0; j2 < 5; j2++) {
|
||||
if (anIntArray106[j2] != 0) {
|
||||
anIntArray118[j2] = 0;
|
||||
anIntArray119[j2] = (int) ((double) anIntArray108[j2] * d);
|
||||
anIntArray120[j2] = (anIntArray106[j2] << 14) / 100;
|
||||
anIntArray121[j2] = (int) (((double) (aEnvelope_98.anInt539 - aEnvelope_98.anInt538) * 32.768000000000001D * Math.pow(1.0057929410678534D, anIntArray107[j2])) / d);
|
||||
anIntArray122[j2] = (int) (((double) aEnvelope_98.anInt538 * 32.768000000000001D) / d);
|
||||
|
||||
for (int harmonic = 0; harmonic < 5; harmonic++) {
|
||||
if (harmonicVolume[harmonic] != 0) {
|
||||
tmpPhases[harmonic] = 0;
|
||||
tmpDelays[harmonic] = (int) ((double) harmonicDelay[harmonic] * samplesPerStep);
|
||||
tmpVolumes[harmonic] = (harmonicVolume[harmonic] << 14) / 100;
|
||||
tmpSemitones[harmonic] = (int) (((double) (frequencyBase.end - frequencyBase.start) * 32.768 * Math.pow(1.0057929410678534D, harmonicSemitone[harmonic])) / samplesPerStep);
|
||||
tmpStarts[harmonic] = (int) (((double) frequencyBase.start * 32.768) / samplesPerStep);
|
||||
}
|
||||
}
|
||||
for (int k2 = 0; k2 < i; k2++) {
|
||||
int l2 = aEnvelope_98.method328(i);
|
||||
int j4 = aEnvelope_99.method328(i);
|
||||
if (aEnvelope_100 != null) {
|
||||
int j5 = aEnvelope_100.method328(i);
|
||||
int j6 = aEnvelope_101.method328(i);
|
||||
l2 += method168(j6, j1, aEnvelope_100.anInt540) >> 1;
|
||||
j1 += ((j5 * l) >> 16) + i1;
|
||||
|
||||
for (int sample = 0; sample < sampleCount; sample++) {
|
||||
int frequency = frequencyBase.evaluate(sampleCount);
|
||||
int amplitude = amplitudeBase.evaluate(sampleCount);
|
||||
|
||||
if (frequencyModRate != null) {
|
||||
int rate = frequencyModRate.evaluate(sampleCount);
|
||||
int range = frequencyModRange.evaluate(sampleCount);
|
||||
frequency += generate(frequencyModRate.form, frequencyPhase, range) >> 1;
|
||||
frequencyPhase += ((rate * frequencyStart) >> 16) + frequencyDuration;
|
||||
}
|
||||
if (aEnvelope_102 != null) {
|
||||
int k5 = aEnvelope_102.method328(i);
|
||||
int k6 = aEnvelope_103.method328(i);
|
||||
j4 = (j4 * ((method168(k6, i2, aEnvelope_102.anInt540) >> 1) + 32768)) >> 15;
|
||||
i2 += ((k5 * k1) >> 16) + l1;
|
||||
|
||||
if (amplitudeModRate != null) {
|
||||
int rate = amplitudeModRate.evaluate(sampleCount);
|
||||
int range = amplitudeModRange.evaluate(sampleCount);
|
||||
amplitude = (amplitude * ((generate(amplitudeModRate.form, amplitudePhase, range) >> 1) + 32768)) >> 15;
|
||||
amplitudePhase += ((rate * amplitudeStart) >> 16) + amplitudeDuration;
|
||||
}
|
||||
for (int l5 = 0; l5 < 5; l5++) {
|
||||
if (anIntArray106[l5] != 0) {
|
||||
int l6 = k2 + anIntArray119[l5];
|
||||
if (l6 < i) {
|
||||
anIntArray115[l6] += method168((j4 * anIntArray120[l5]) >> 15, anIntArray118[l5], aEnvelope_98.anInt540);
|
||||
anIntArray118[l5] += ((l2 * anIntArray121[l5]) >> 16) + anIntArray122[l5];
|
||||
|
||||
for (int harmonic = 0; harmonic < 5; harmonic++) {
|
||||
if (harmonicVolume[harmonic] != 0) {
|
||||
int position = sample + tmpDelays[harmonic];
|
||||
|
||||
if (position < sampleCount) {
|
||||
buffer[position] += generate(frequencyBase.form, tmpPhases[harmonic], (amplitude * tmpVolumes[harmonic]) >> 15);
|
||||
tmpPhases[harmonic] += ((frequency * tmpSemitones[harmonic]) >> 16) + tmpStarts[harmonic];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aEnvelope_104 != null) {
|
||||
aEnvelope_104.method327();
|
||||
aEnvelope_105.method327();
|
||||
int i3 = 0;
|
||||
boolean flag1 = true;
|
||||
for (int i7 = 0; i7 < i; i7++) {
|
||||
int k7 = aEnvelope_104.method328(i);
|
||||
int i8 = aEnvelope_105.method328(i);
|
||||
int k4;
|
||||
if (flag1) {
|
||||
k4 = aEnvelope_104.anInt538 + (((aEnvelope_104.anInt539 - aEnvelope_104.anInt538) * k7) >> 8);
|
||||
|
||||
if (release != null) {
|
||||
release.reset();
|
||||
attack.reset();
|
||||
|
||||
int counter = 0;
|
||||
boolean muted = true;
|
||||
|
||||
for (int sample = 0; sample < sampleCount; sample++) {
|
||||
int releaseValue = release.evaluate(sampleCount);
|
||||
int attackValue = attack.evaluate(sampleCount);
|
||||
int threshold;
|
||||
|
||||
if (muted) {
|
||||
threshold = release.start + (((release.end - release.start) * releaseValue) >> 8);
|
||||
} else {
|
||||
k4 = aEnvelope_104.anInt538 + (((aEnvelope_104.anInt539 - aEnvelope_104.anInt538) * i8) >> 8);
|
||||
threshold = release.start + (((release.end - release.start) * attackValue) >> 8);
|
||||
}
|
||||
if ((i3 += 256) >= k4) {
|
||||
i3 = 0;
|
||||
flag1 = !flag1;
|
||||
|
||||
if ((counter += 256) >= threshold) {
|
||||
counter = 0;
|
||||
muted = !muted;
|
||||
}
|
||||
if (flag1) {
|
||||
anIntArray115[i7] = 0;
|
||||
|
||||
if (muted) {
|
||||
buffer[sample] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((anInt109 > 0) && (anInt110 > 0)) {
|
||||
int j3 = (int) ((double) anInt109 * d);
|
||||
for (int l4 = j3; l4 < i; l4++) {
|
||||
anIntArray115[l4] += (anIntArray115[l4 - j3] * anInt110) / 100;
|
||||
|
||||
if ((reverbDelay > 0) && (reverbVolume > 0)) {
|
||||
int start = (int) ((double) reverbDelay * samplesPerStep);
|
||||
|
||||
for (int sample = start; sample < sampleCount; sample++) {
|
||||
buffer[sample] += (buffer[sample - start] * reverbVolume) / 100;
|
||||
}
|
||||
}
|
||||
if ((aSoundFilter_111.anIntArray665[0] > 0) || (aSoundFilter_111.anIntArray665[1] > 0)) {
|
||||
aEnvelope_112.method327();
|
||||
int k3 = aEnvelope_112.method328(i + 1);
|
||||
int i5 = aSoundFilter_111.method544(0, (float) k3 / 65536F);
|
||||
int i6 = aSoundFilter_111.method544(1, (float) k3 / 65536F);
|
||||
if (i >= (i5 + i6)) {
|
||||
int j7 = 0;
|
||||
int l7 = i6;
|
||||
if (l7 > (i - i5)) {
|
||||
l7 = i - i5;
|
||||
|
||||
if ((filter.pairs[0] > 0) || (filter.pairs[1] > 0)) {
|
||||
filterRange.reset();
|
||||
|
||||
int range = filterRange.evaluate(sampleCount + 1);
|
||||
int forward = filter.evaluate(0, (float) range / 65536F);
|
||||
int backward = filter.evaluate(1, (float) range / 65536F);
|
||||
|
||||
if (sampleCount >= (forward + backward)) {
|
||||
int index = 0;
|
||||
int interval = backward;
|
||||
|
||||
if (interval > (sampleCount - forward)) {
|
||||
interval = sampleCount - forward;
|
||||
}
|
||||
for (; j7 < l7; j7++) {
|
||||
int j8 = (int) (((long) anIntArray115[j7 + i5] * (long) SoundFilter.anInt672) >> 16);
|
||||
for (int k8 = 0; k8 < i5; k8++) {
|
||||
j8 += (int) (((long) anIntArray115[(j7 + i5) - 1 - k8] * (long) SoundFilter.anIntArrayArray670[0][k8]) >> 16);
|
||||
|
||||
for (; index < interval; index++) {
|
||||
int sample = (int) (((long) buffer[index + forward] * (long) SoundFilter.unity16) >> 16);
|
||||
|
||||
for (int offset = 0; offset < forward; offset++) {
|
||||
sample += (int) (((long) buffer[(index + forward) - 1 - offset] * (long) SoundFilter.coefficient16[0][offset]) >> 16);
|
||||
}
|
||||
for (int j9 = 0; j9 < j7; j9++) {
|
||||
j8 -= (int) (((long) anIntArray115[j7 - 1 - j9] * (long) SoundFilter.anIntArrayArray670[1][j9]) >> 16);
|
||||
|
||||
for (int offset = 0; offset < index; offset++) {
|
||||
sample -= (int) (((long) buffer[index - 1 - offset] * (long) SoundFilter.coefficient16[1][offset]) >> 16);
|
||||
}
|
||||
anIntArray115[j7] = j8;
|
||||
k3 = aEnvelope_112.method328(i + 1);
|
||||
|
||||
buffer[index] = sample;
|
||||
range = filterRange.evaluate(sampleCount + 1);
|
||||
}
|
||||
char c = '\200';
|
||||
l7 = c;
|
||||
|
||||
interval = 128;
|
||||
|
||||
do {
|
||||
if (l7 > (i - i5)) {
|
||||
l7 = i - i5;
|
||||
if (interval > (sampleCount - forward)) {
|
||||
interval = sampleCount - forward;
|
||||
}
|
||||
for (; j7 < l7; j7++) {
|
||||
int l8 = (int) (((long) anIntArray115[j7 + i5] * (long) SoundFilter.anInt672) >> 16);
|
||||
for (int k9 = 0; k9 < i5; k9++) {
|
||||
l8 += (int) (((long) anIntArray115[(j7 + i5) - 1 - k9] * (long) SoundFilter.anIntArrayArray670[0][k9]) >> 16);
|
||||
|
||||
for (; index < interval; index++) {
|
||||
int sample = (int) (((long) buffer[index + forward] * (long) SoundFilter.unity16) >> 16);
|
||||
|
||||
for (int offset = 0; offset < forward; offset++) {
|
||||
sample += (int) (((long) buffer[(index + forward) - 1 - offset] * (long) SoundFilter.coefficient16[0][offset]) >> 16);
|
||||
}
|
||||
for (int i10 = 0; i10 < i6; i10++) {
|
||||
l8 -= (int) (((long) anIntArray115[j7 - 1 - i10] * (long) SoundFilter.anIntArrayArray670[1][i10]) >> 16);
|
||||
|
||||
for (int offset = 0; offset < backward; offset++) {
|
||||
sample -= (int) (((long) buffer[index - 1 - offset] * (long) SoundFilter.coefficient16[1][offset]) >> 16);
|
||||
}
|
||||
anIntArray115[j7] = l8;
|
||||
k3 = aEnvelope_112.method328(i + 1);
|
||||
|
||||
buffer[index] = sample;
|
||||
range = filterRange.evaluate(sampleCount + 1);
|
||||
}
|
||||
if (j7 >= (i - i5)) {
|
||||
|
||||
if (index >= (sampleCount - forward)) {
|
||||
break;
|
||||
}
|
||||
i5 = aSoundFilter_111.method544(0, (float) k3 / 65536F);
|
||||
i6 = aSoundFilter_111.method544(1, (float) k3 / 65536F);
|
||||
l7 += c;
|
||||
|
||||
forward = filter.evaluate(0, (float) range / 65536F);
|
||||
backward = filter.evaluate(1, (float) range / 65536F);
|
||||
interval += 128;
|
||||
} while (true);
|
||||
for (; j7 < i; j7++) {
|
||||
int i9 = 0;
|
||||
for (int l9 = (j7 + i5) - i; l9 < i5; l9++) {
|
||||
i9 += (int) (((long) anIntArray115[(j7 + i5) - 1 - l9] * (long) SoundFilter.anIntArrayArray670[0][l9]) >> 16);
|
||||
|
||||
for (; index < sampleCount; index++) {
|
||||
int sample = 0;
|
||||
|
||||
for (int offset = (index + forward) - sampleCount; offset < forward; offset++) {
|
||||
sample += (int) (((long) buffer[(index + forward) - 1 - offset] * (long) SoundFilter.coefficient16[0][offset]) >> 16);
|
||||
}
|
||||
for (int j10 = 0; j10 < i6; j10++) {
|
||||
i9 -= (int) (((long) anIntArray115[j7 - 1 - j10] * (long) SoundFilter.anIntArrayArray670[1][j10]) >> 16);
|
||||
|
||||
for (int offset = 0; offset < backward; offset++) {
|
||||
sample -= (int) (((long) buffer[index - 1 - offset] * (long) SoundFilter.coefficient16[1][offset]) >> 16);
|
||||
}
|
||||
anIntArray115[j7] = i9;
|
||||
aEnvelope_112.method328(i + 1);
|
||||
|
||||
buffer[index] = sample;
|
||||
filterRange.evaluate(sampleCount + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i4 = 0; i4 < i; i4++) {
|
||||
if (anIntArray115[i4] < -32768) {
|
||||
anIntArray115[i4] = -32768;
|
||||
|
||||
for (int sample = 0; sample < sampleCount; sample++) {
|
||||
if (buffer[sample] < -32768) {
|
||||
buffer[sample] = -32768;
|
||||
}
|
||||
if (anIntArray115[i4] > 32767) {
|
||||
anIntArray115[i4] = 32767;
|
||||
if (buffer[sample] > 32767) {
|
||||
buffer[sample] = 32767;
|
||||
}
|
||||
}
|
||||
return anIntArray115;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public int method168(int i, int k, int l) {
|
||||
if (l == 1) {
|
||||
if ((k & 0x7fff) < 16384) {
|
||||
return i;
|
||||
public int generate(int form, int phase, int amplitude) {
|
||||
if (form == 1) {
|
||||
if ((phase & 0x7fff) < 16384) {
|
||||
return amplitude;
|
||||
} else {
|
||||
return -i;
|
||||
return -amplitude;
|
||||
}
|
||||
}
|
||||
if (l == 2) {
|
||||
return (anIntArray117[k & 0x7fff] * i) >> 14;
|
||||
}
|
||||
if (l == 3) {
|
||||
return (((k & 0x7fff) * i) >> 14) - i;
|
||||
}
|
||||
if (l == 4) {
|
||||
return anIntArray116[(k / 2607) & 0x7fff] * i;
|
||||
} else if (form == 2) {
|
||||
return (sin[phase & 0x7fff] * amplitude) >> 14;
|
||||
} else if (form == 3) {
|
||||
return (((phase & 0x7fff) * amplitude) >> 14) - amplitude;
|
||||
} else if (form == 4) {
|
||||
return noise[(phase / 2607) & 0x7fff] * amplitude;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void method169(Packet packet) {
|
||||
aEnvelope_98 = new SoundEnvelope();
|
||||
aEnvelope_98.method325(packet);
|
||||
aEnvelope_99 = new SoundEnvelope();
|
||||
aEnvelope_99.method325(packet);
|
||||
int i = packet.get1U();
|
||||
if (i != 0) {
|
||||
public void read(Packet packet) {
|
||||
frequencyBase = new SoundEnvelope();
|
||||
frequencyBase.read(packet);
|
||||
amplitudeBase = new SoundEnvelope();
|
||||
amplitudeBase.read(packet);
|
||||
|
||||
if (packet.get1U() != 0) {
|
||||
packet.position--;
|
||||
aEnvelope_100 = new SoundEnvelope();
|
||||
aEnvelope_100.method325(packet);
|
||||
aEnvelope_101 = new SoundEnvelope();
|
||||
aEnvelope_101.method325(packet);
|
||||
frequencyModRate = new SoundEnvelope();
|
||||
frequencyModRate.read(packet);
|
||||
frequencyModRange = new SoundEnvelope();
|
||||
frequencyModRange.read(packet);
|
||||
}
|
||||
i = packet.get1U();
|
||||
if (i != 0) {
|
||||
|
||||
if (packet.get1U() != 0) {
|
||||
packet.position--;
|
||||
aEnvelope_102 = new SoundEnvelope();
|
||||
aEnvelope_102.method325(packet);
|
||||
aEnvelope_103 = new SoundEnvelope();
|
||||
aEnvelope_103.method325(packet);
|
||||
amplitudeModRate = new SoundEnvelope();
|
||||
amplitudeModRate.read(packet);
|
||||
amplitudeModRange = new SoundEnvelope();
|
||||
amplitudeModRange.read(packet);
|
||||
}
|
||||
i = packet.get1U();
|
||||
if (i != 0) {
|
||||
|
||||
if (packet.get1U() != 0) {
|
||||
packet.position--;
|
||||
aEnvelope_104 = new SoundEnvelope();
|
||||
aEnvelope_104.method325(packet);
|
||||
aEnvelope_105 = new SoundEnvelope();
|
||||
aEnvelope_105.method325(packet);
|
||||
release = new SoundEnvelope();
|
||||
release.read(packet);
|
||||
attack = new SoundEnvelope();
|
||||
attack.read(packet);
|
||||
}
|
||||
for (int j = 0; j < 10; j++) {
|
||||
int k = packet.getSmartU();
|
||||
if (k == 0) {
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int volume = packet.getSmartU();
|
||||
|
||||
if (volume == 0) {
|
||||
break;
|
||||
}
|
||||
anIntArray106[j] = k;
|
||||
anIntArray107[j] = packet.getSmart();
|
||||
anIntArray108[j] = packet.getSmartU();
|
||||
|
||||
harmonicVolume[i] = volume;
|
||||
harmonicSemitone[i] = packet.getSmart();
|
||||
harmonicDelay[i] = packet.getSmartU();
|
||||
}
|
||||
anInt109 = packet.getSmartU();
|
||||
anInt110 = packet.getSmartU();
|
||||
anInt113 = packet.get2U();
|
||||
anInt114 = packet.get2U();
|
||||
aSoundFilter_111 = new SoundFilter();
|
||||
aEnvelope_112 = new SoundEnvelope();
|
||||
aSoundFilter_111.method545(packet, aEnvelope_112);
|
||||
|
||||
reverbDelay = packet.getSmartU();
|
||||
reverbVolume = packet.getSmartU();
|
||||
|
||||
length = packet.get2U();
|
||||
start = packet.get2U();
|
||||
|
||||
filter = new SoundFilter();
|
||||
filterRange = new SoundEnvelope();
|
||||
filter.read(packet, filterRange);
|
||||
}
|
||||
|
||||
}
|
||||
+129
-105
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user