This tutorial will show you how to add volumes to sound effects in your client.
Firstly, you will need to declare this variable:
Code:
public static int volumeType;
If you are using Bluurr's "SoundPlayer" class, declare it in that class, if not, declare it in the SignLink class.
Next, in your client class, you will see something similar to this:
Non-Refactored:
Code:
if (anInt1008 == 174) {
int i4 = aClass30_Sub2_Sub2_1083.method410();
int l11 = aClass30_Sub2_Sub2_1083.method408();
int k17 = aClass30_Sub2_Sub2_1083.method410();
if (aBoolean848 && !aBoolean960 && anInt1062 < 50) {
anIntArray1207[anInt1062] = i4;
anIntArray1241[anInt1062] = l11;
anIntArray1250[anInt1062] = k17 + Class16.anIntArray326[i4];
anInt1062++;
}
packetType = -1;
return true;
}
Refactored:
Code:
if (pktType == 174) {
int i4 = inStream.readUnsignedWord();
int l11 = inStream.readUnsignedByte();
int k17 = inStream.readUnsignedWord();
if (aBoolean848 && !lowMem && anInt1062 < 50) {
anIntArray1207[anInt1062] = i4;
anIntArray1241[anInt1062] = l11;
anIntArray1250[anInt1062] = k17 + Sounds.anIntArray326[i4];
anInt1062++;
}
pktType = -1;
return true;
}
Within that if-statement, if you are using the SoundPlayer class, add:
Code:
SoundPlayer.volumeType = l11;
If you are using the SignLink class, add:
Code:
SoundPlayer.volumeType = l11;
Next, in your SoundPlayer/SignLink class, you will see either:
SoundPlayer:
Code:
soundeffect.open(stream);
SignLink:
Code:
auline.open(format);
Below that line in the class that you are using, you will need to add:
If you are using the SoundPlayer class:
Code:
if (soundeffect.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
double[] volumes = {
0.0, 0.25, 0.5, 0.75, 1.0
};
float dB = (float)(Math.log(volumes[volumeType]) / Math.log(10.0) * 20.0);
FloatControl pan = (FloatControl) soundeffect.getControl(FloatControl.Type.MASTER_GAIN);
pan.setValue(dB);
}
If you are using the SignLink class:
Code:
if (auline.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
double[] volumes = {
0.0, 0.25, 0.5, 0.75, 1.0
};
float dB = (float)(Math.log(volumes[volumeType]) / Math.log(10.0) * 20.0);
FloatControl pan = (FloatControl) auline.getControl(FloatControl.Type.MASTER_GAIN);
pan.setValue(dB);
}
You should now have fully working sound volumes.
To use them, use either 1, 2, 3, or 4 for the volume (1 being the lowest, 4 being the highest). If you want no volume at all, use 0.
An example:
Code:
player.getActionSender().sendSound(SOUNDID, 4, 0);