Thread: Decoding sound effects 1, 2 & 3 - Figured out

Page 1 of 2 12 LastLast
Results 1 to 10 of 17
  1. #1 Decoding sound effects 1, 2 & 3 - Figured out 
    Registered Member
    Join Date
    Jul 2014
    Posts
    59
    Thanks given
    7
    Thanks received
    58
    Rep Power
    73
    This was figured out in reference to: https://github.com/nshusa/spitfire-155-client

    In the client, there is a class with methods to load from both cache indices 4 and 14 (Sound Effects and Instrument Samples), called SoundBank. For Sound Effects, there's a class called SoundEffects.java, which loads data from Index 4 through a buffer, then you can call the method in the SoundEffect class to mix the processed data into an audio file (It has a byte array (byte[]) return value). It comes out as raw data, but can be opened with a program called Audacity by choosing File > Import > Raw Data... and exported to a file type of choice.

    For the other part (Index 14), there's a processing method that reads an integer and then an integer array (int[]), but you can leave the int[] value as null when calling it. The basic int/number is the only thing that matters, to tell it which file ID to process. It does a little check and sends the process to another method where it eventually calls the Sfx1 class, loading the index file... and decoding it to an audio file. However, the final return value is not the byte array like in the SoundEffect class, and you'll have to find the byte array and write that to a new file. The byte array is found above the MusicNote class return value, it's not too far away. This comes out as raw data as well.

    Lastly, for decoding (Index 15), you'll have to make a new class loading the SoundBank class with Index 4 and 14, then loading the InstrumentDef class with a file from Index 15 as a byte array. Then you call a boolean method containing the SoundBank, byte array with data, and an int array (which can also be null). You'll also have to add printed messages to the console where needed in the 3 classes called SoundEffect, Sfx1 and InstrumentDef.

    Examples of what they should print are as follows - using Alex's FileStore:

    SoundEffect -
    Code:
    public static SoundEffect staticMethod44(Index js5index_0, int i_1, int i_2) {
            byte[] bytes_3 = js5index_0.getFile(i_1, i_2);
            System.out.println("Sound 1 (SampleID_NoteID): " + i_1 + "_");
            return bytes_3 == null ? null : new SoundEffect(new Buffer(bytes_3));
        }
    Sfx1 -
    Code:
    static Sfx1 staticMethod375(Index js5index_0, int i_1, int i_2) {
            if (!staticMethod374(js5index_0)) {
                js5index_0.fileExists(i_1, i_2);
                return null;
            } else {
                byte[] bytes_3 = js5index_0.getFile(i_1, i_2);
                System.out.print("Sound2 (SampleID_NoteID): " + i_1 + "_");
                return bytes_3 == null ? null : new Sfx1(bytes_3);
            }
        }
    InstrumentDef -
    Code:
        static boolean method490(SoundBank soundbank_1, byte[] bytes_2, int[] ints_3) throws IOException {
            boolean bool_5 = true;
            int i_6 = 0;
            MusicNote musicnote_7 = null;
    
            for (int i_8 = 0; i_8 < 128; i_8++)
                if (bytes_2 == null || bytes_2[i_8] != 0) {
                    int i_9 = intArray50[i_8];
                    if (i_9 != 0) {
                        if (i_9 != i_6) {
                            i_6 = i_9--;
                            if ((i_9 & 0x1) == 0) {
                                musicnote_7 = soundbank_1.method158(i_9 >> 2, ints_3);
                     	   	   System.out.print(i_8 + " "); 
                     	   	   }
                            else {
                                musicnote_7 = soundbank_1.method159(i_9 >> 2, ints_3);
                            	   System.out.print(i_8 + " ");
                            }
    I've also posted a modified version of the Spitfire client here using Alex's FileStore, it contains 3 additional classes to help you dump sounds the same way I did (Sound1Dumper, Sound2Dumper, Sound3Dumper): https://github.com/lequietriot/Modif...ire-155-Client

    Edit: Also when importing the raw data to Audacity, make sure the Sample Rate is 22050 Hz, otherwise it won't sound correct.
    Last edited by lequietriot; 01-08-2018 at 06:58 PM. Reason: Added a note about the sounds - they have a sample rate of 22050 Hz.
    Reply With Quote  
     

  2. Thankful users:


  3. #2  
    Registered Member

    Join Date
    Dec 2009
    Posts
    774
    Thanks given
    367
    Thanks received
    455
    Rep Power
    927
    Great work! I will use this for sure.
    Reply With Quote  
     

  4. #3  
    *breaks walking*

    Cody_'s Avatar
    Join Date
    Dec 2010
    Posts
    732
    Thanks given
    219
    Thanks received
    203
    Rep Power
    286
    Good job.
    Reply With Quote  
     

  5. #4  
    Community Veteran

    mige5's Avatar
    Join Date
    Aug 2008
    Posts
    5,528
    Thanks given
    573
    Thanks received
    1,410
    Rep Power
    2114
    Nice work
    Number of page #1 releases with most views & posts: (Updated: 2023)
    RS2 server section: 1
    RS2 client section: 2
    Reply With Quote  
     

  6. #5  
    Community Veteran

    Dust R I P's Avatar
    Join Date
    Jan 2008
    Posts
    2,599
    Thanks given
    197
    Thanks received
    221
    Rep Power
    586
    Wait.. Sound effects as in ingame sfx or Midi's with custom soundbank?
    Reply With Quote  
     

  7. #6  
    Registered Member
    Join Date
    Jul 2014
    Posts
    59
    Thanks given
    7
    Thanks received
    58
    Rep Power
    73
    Quote Originally Posted by Dust R I P View Post
    Wait.. Sound effects as in ingame sfx or Midi's with custom soundbank?
    In here, I figured out the way to decode the sound effects (Index 4) and the instrument samples (Index 14) from the soundbank, and figuring out which instruments are used with Index 15. This is decoded directly from the cache.
    Reply With Quote  
     

  8. #7  
    Community Veteran

    Dust R I P's Avatar
    Join Date
    Jan 2008
    Posts
    2,599
    Thanks given
    197
    Thanks received
    221
    Rep Power
    586
    Quote Originally Posted by lequietriot View Post
    In here, I figured out the way to decode the sound effects (Index 4) and the instrument samples (Index 14) from the soundbank, and figuring out which instruments are used with Index 15. This is decoded directly from the cache.
    But IIRC index 4 is for MUSIC like the Lumbridge theme etc. I'm talking about sound effects like whip or ice barrage
    Reply With Quote  
     

  9. #8  
    Registered Member
    Join Date
    Jul 2014
    Posts
    59
    Thanks given
    7
    Thanks received
    58
    Rep Power
    73
    Quote Originally Posted by Dust R I P View Post
    But IIRC index 4 is for MUSIC like the Lumbridge theme etc. I'm talking about sound effects like whip or ice barrage
    That's what I said, index 4 has sound effects. Index 6 has that music you're talking about, and Index 11 has the music fanfares both in MIDI. The sound effects like whip hitting and ice barrage are in Index 4 somewhere.
    Reply With Quote  
     

  10. #9  
    Community Veteran

    Dust R I P's Avatar
    Join Date
    Jan 2008
    Posts
    2,599
    Thanks given
    197
    Thanks received
    221
    Rep Power
    586
    Quote Originally Posted by lequietriot View Post
    That's what I said, index 4 has sound effects. Index 6 has that music you're talking about, and Index 11 has the music fanfares both in MIDI. The sound effects like whip hitting and ice barrage are in Index 4 somewhere.
    I tried ages to get the sound effects out and into a 317 client but till this day no luck
    Reply With Quote  
     

  11. #10  
    Registered Member
    Join Date
    Jul 2014
    Posts
    59
    Thanks given
    7
    Thanks received
    58
    Rep Power
    73
    In case anyone hasn't figured this out yet - All of the RS sounds have a Sample Rate of 22050 Hz (I believe). Forgot to mention this at first, but any other value other than 22050 Hz will make the sound come out incorrectly. By default, Audacity imports the raw data as 44100 Hz, which will make the sampled sound higher pitched and shorter, just change the value to 22050 and it'll sound correct.
    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

Similar Threads

  1. [508] Sound Effects...
    By Pro Gram Mer in forum Tutorials
    Replies: 48
    Last Post: 06-13-2009, 03:48 AM
  2. Set sound effect
    By Laxika in forum Configuration
    Replies: 14
    Last Post: 08-12-2008, 06:05 AM
  3. Replies: 5
    Last Post: 04-02-2008, 04:35 AM
  4. Sound Effects Needed
    By Palidino in forum RS2 Server
    Replies: 6
    Last Post: 10-17-2007, 04:39 AM
Tags for this Thread

View Tag Cloud

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