Thread: Sound Effect Volumes

Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1 Sound Effect Volumes 
    Banned

    Join Date
    Jun 2008
    Posts
    913
    Thanks given
    30
    Thanks received
    94
    Rep Power
    0
    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);
    Reply With Quote  
     

  2. #2  
    Officially Retired

    Huey's Avatar
    Join Date
    Jan 2008
    Age
    19
    Posts
    16,489
    Thanks given
    3,387
    Thanks received
    7,726
    Rep Power
    5000
    Nice prima thx

    Listen children don't become this guy.
    Quote Originally Posted by Owner Spikey View Post
    Why can I attack lower level npc's in a matter of a mouse hover but for a higher level npc the only choice to attack is by right clicking option attack?

    Reply With Quote  
     

  3. #3  
    Community Veteran

    Dust R I P's Avatar
    Join Date
    Jan 2008
    Posts
    2,556
    Thanks given
    183
    Thanks received
    198
    Rep Power
    561
    What do i change serverside?
    Reply With Quote  
     

  4. #4  
    Banned

    Join Date
    Jun 2008
    Posts
    913
    Thanks given
    30
    Thanks received
    94
    Rep Power
    0
    Quote Originally Posted by Dust R I P View Post
    What do i change serverside?
    Nothing, you just set the volume parameter to 4 if you want it at normal volume.
    Reply With Quote  
     

  5. #5  
    Community Veteran

    Dust R I P's Avatar
    Join Date
    Jan 2008
    Posts
    2,556
    Thanks given
    183
    Thanks received
    198
    Rep Power
    561
    Quote Originally Posted by Primadude View Post
    Nothing, you just set the volume parameter to 4 if you want it at normal volume.
    But i want to toggle it serverside...
    Reply With Quote  
     

  6. #6  
    Banned

    Join Date
    Jun 2008
    Posts
    913
    Thanks given
    30
    Thanks received
    94
    Rep Power
    0
    Quote Originally Posted by Dust R I P View Post
    But i want to toggle it serverside...
    Code:
    player.getActionSender().sendSound(SOUNDID, 4, 0);
    That IS server-side..
    4 is the volume, 0 is the delay.

    Reply With Quote  
     

  7. #7  
    Banned

    Join Date
    Jul 2008
    Posts
    3,532
    Thanks given
    188
    Thanks received
    696
    Rep Power
    0
    Not a very efficient way, i would prefer sounds to be a universal volume and you just set the volume for all sounds with the buttons.
    Reply With Quote  
     

  8. #8  
    Client God

    Join Date
    Aug 2009
    Posts
    3,130
    Thanks given
    3
    Thanks received
    614
    Rep Power
    896
    Sexyness may nor may not use
    Reply With Quote  
     

  9. #9  
    Banned

    Join Date
    Jun 2008
    Posts
    913
    Thanks given
    30
    Thanks received
    94
    Rep Power
    0
    Quote Originally Posted by badger41 View Post
    Not a very efficient way, i would prefer sounds to be a universal volume and you just set the volume for all sounds with the buttons.
    You can just set that via your server; it's what I do. Also, you'd need the volume parameter for other things, such as distance volumes (For example if you're within a distance of someone in combat with another player, it will play the sound with a volume depending on how close/far away you are from that player).
    Reply With Quote  
     

  10. #10  
    Endeavor

    Mikey`'s Avatar
    Join Date
    Dec 2007
    Posts
    4,421
    Thanks given
    693
    Thanks received
    1,425
    Rep Power
    1202
    It's very easy to set volumes server side and have them save.

    Nice work.
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •