Files
runelite/runescape-client/src/main/java/SoundEnvelope.java
2020-10-04 20:53:17 -04:00

96 lines
2.4 KiB
Java

import net.runelite.mapping.Implements;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
@ObfuscatedName("dw")
@Implements("SoundEnvelope")
public class SoundEnvelope {
@ObfuscatedName("z")
int segments;
@ObfuscatedName("k")
int[] durations;
@ObfuscatedName("s")
int[] phases;
@ObfuscatedName("t")
int start;
@ObfuscatedName("i")
int end;
@ObfuscatedName("o")
int form;
@ObfuscatedName("w")
int ticks;
@ObfuscatedName("g")
int phaseIndex;
@ObfuscatedName("m")
int step;
@ObfuscatedName("n")
int amplitude;
@ObfuscatedName("d")
int max;
SoundEnvelope() {
this.segments = 2; // L: 21
this.durations = new int[2]; // L: 22
this.phases = new int[2]; // L: 23
this.durations[0] = 0; // L: 24
this.durations[1] = 65535; // L: 25
this.phases[0] = 0; // L: 26
this.phases[1] = 65535; // L: 27
} // L: 28
@ObfuscatedName("z")
@ObfuscatedSignature(
descriptor = "(Lkf;)V"
)
final void decode(Buffer var1) {
this.form = var1.readUnsignedByte(); // L: 31
this.start = var1.readInt(); // L: 32
this.end = var1.readInt(); // L: 33
this.decodeSegments(var1); // L: 34
} // L: 35
@ObfuscatedName("k")
@ObfuscatedSignature(
descriptor = "(Lkf;)V"
)
final void decodeSegments(Buffer var1) {
this.segments = var1.readUnsignedByte(); // L: 38
this.durations = new int[this.segments]; // L: 39
this.phases = new int[this.segments]; // L: 40
for (int var2 = 0; var2 < this.segments; ++var2) { // L: 41
this.durations[var2] = var1.readUnsignedShort(); // L: 42
this.phases[var2] = var1.readUnsignedShort(); // L: 43
}
} // L: 45
@ObfuscatedName("s")
final void reset() {
this.ticks = 0; // L: 48
this.phaseIndex = 0; // L: 49
this.step = 0; // L: 50
this.amplitude = 0; // L: 51
this.max = 0; // L: 52
} // L: 53
@ObfuscatedName("t")
final int doStep(int var1) {
if (this.max >= this.ticks) { // L: 56
this.amplitude = this.phases[this.phaseIndex++] << 15; // L: 57
if (this.phaseIndex >= this.segments) { // L: 58
this.phaseIndex = this.segments - 1;
}
this.ticks = (int)((double)this.durations[this.phaseIndex] / 65536.0D * (double)var1); // L: 59
if (this.ticks > this.max) { // L: 60
this.step = ((this.phases[this.phaseIndex] << 15) - this.amplitude) / (this.ticks - this.max);
}
}
this.amplitude += this.step; // L: 62
++this.max; // L: 63
return this.amplitude - this.step >> 15; // L: 64
}
}