Mark DiVecchio's O-Gauge Train Layouts

1992 Layout Page

2006 Layout Page

2009 Layout Page

P&LE Postcards by Howard Fogg 

Plasticville Buildings

Portable Layout Page

Train Clubs

Bing Track

Remote Train Control Program

YouTube Channel

OOK Radio Support

Technical Videos

ADPCM and Playing Clips from ".mth" Sound Files

This Page last updated on .

This page describes and has links to my program, ADPCM to play sound clips from the .mth sound file.

I am releasing this program and documentation under the  GNU GENERAL PUBLIC LICENSE Version 3 and GNU Free Documentation License Version 1.3. These licenses permit anyone to use the program and the documentation to produce follow on programs as long as those programs remain covered by the GNU licenses.  

The Free Software Foundation web page talks about what "free software" means.

For more information, look on the Open Source Initiative web site which includes a description of what  Open Source means and their certification of the GPL version 3

Here is the copyright notice for those two licenses:


Remote Train Control Program for Windows
© Copyright 2015 by Mark DiVecchio

Remote Train Control is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Remote Train Control is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Remote Train Control.  If not, see <>.


This is part of the Remote Train Control Manual.
© Copyright 2015 by Mark DiVecchi

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. You should have received a copy of the GNU Free Documentation License along with Remote Train Control. If not, see <>.

Sound File Format

The ".mth" sound file contains engine information and sounds. I looked at the sounds only.

My path on this task started with this post by a poster named "Sporadic" on Model Train Forum. He had studied the sound file format and understood the structure of two pieces of the sound file:
    1. The index (or directory)
    2. Sounds

He found the index started at offset 0x0100 and went through 0x10E0. Here is a quote from his original posting:

After banging my head on it for a few days off and on, I managed to figure out the audio directory structure. Starting at 0x0100 there is a series of 16 byte records running up through 0x10E0. I don't have all the fields nailed down yet, but audio sample location and length seems to be spot on. Everything is referenced by frames (16bit) and sample offset count. I've tried this with a few PS2 and PS3 files and they all seem to map correctly. The following is an example of the first 3 records for a PS2 sd70ace file I pulled (R092PF3SD70ACe_ALL100107aF2X.MTH) that should explain it a little better. There's more data further in the header section I haven't worked on yet, but I'm now able to pull all discrete audio from the file. I'm a ways off from modifying or porting soundsets, but it definitely seems doable.

Frames are 16bit (65,536 byte frame size).
Audio is referenced as Frame number + offset in sample count.
Audio samples are 4bit ADPCM (i.e. 512 bytes = 1024 samples).
All calculated offsets for audio records are in reference to the beginning of the audio data which is at 0x8000 in the .mth file.

//1st audio record
0x0100: 01 // Frame (Start)
0x0101: 00 00 // Offset sample count into frame for start of audio data (16bit big endian)
0x0103: FF FF FF // majority of records defined this way. when not, references a frame + offset as above. unknown, maybe loop data
0x0106: FF FF FF // majority of records defined this way. when not, references a frame + offset as above. unknown, maybe loop data
0x0109: 00 00 00 // majority of records defined this way. when not, pattern is apperent but haven't analyzed it yet.
0x010C: 01 // Frame (End)
0x010D: CE 79 // Offset sample count into frame for end of audio data (16bit big endian)
0x010F: 0B // not known yet. seems to be a bitmask or referenced in nibbles. probably sample rate and other flags.
//result: start @ 0; end @ 52875; 52875 samples

//2nd audio record
0x0110: 01
0x0111: CE 7A
0x0113: FF FF FF
0x0116: FF FF FF
0x0119: 00 00 00
0x011C: 02 // second frame, so add 65,536 to offset
0x011D: F4 6B
0x011F: 0B
//result: start @ 52876; end @ 128107; 75231 samples

//3rd audio record
0x0120: 02
0x0121: F4 6C
0x0123: FF FF FF
0x0126: FF FF FF
0x0129: 00 00 00
0x012C: 03 // 3rd frame, so start at 65,536*2 this time (frame_size*(n-1))
0x012D: D5 03
0x012F: 0B
//result: start @ 128108; end @ 185603; 57495 samples

Found some more tidbits last week when exploring newer PS3 files. Found some audio that wasn't ADPCM! Took some digging and bit fiddling, but ended up 24bit PCM in big endian. So it seems that page and offset references are by nibble count, not necessarily sample rate. Not sure why the 4bit references yet, but it seems to hold true. I threw together a little C# app and am able to extract all the raw audio data into separate files as well as play the 24bit PCM within the app. Once I get the ADPCM decoding and playing within the app I'll post something for people to play with. Been looking for checksum data, but haven't located it yet. Nothing in the upper header anyways. Still more stuff to parse between the directory structure and audio data.

I tried to contact him but could not. So I took what he found as a basis and created this program to play clips from the sound file. First the program looks at the index and creates a table showing each clip and the playback information about each clip. You can then select a clip and play it. The program will play both 4 bit ADPCM and 24 bit signed PCM clips.

4 bit ADPCM is "Adaptive Differential Pulse-Code Modulation". You can Google that! Its an industry standard method of encoding sound developed in the 1970's at Bell Labs. Originally used on telephone systems with a sample rate of 8,000 Hz. It was adopted by the Interactive Multimedia Association in the early 1990's (called IMA/DVI ADPCM). It's a compressed format and I used a decompresser written by David Overton. Since it uses only 4 bits to represent each sample, it is a lossy encoding. It is NOT VOX ADPCM. This is imporant when you create clips to insert into the sound file.

24 bit signed PCM
uses 24 bits to represent each Sample. It is not a compressed format and uses 24 bits to represent each sample. It's Big-Endian! (Google that!) This is important when you create clips to insert into the sound file. Thus the sound file size is six times larger than 4 bit ADPCM. The result is a much higher quality sound.

In the table, except for the Length which is decimal, the other fields are in hexidecimal. As Sporadic mentioned on Model Train Forums, we don't know exactly what all of the fields mean. I followed his interpretation from the orginal postings (with a small change - you can look at the code - its in the ZIP file.). Here is my description of the fields:

        Index - the index consists of 255-16 byte entries.
        Start - the offset into the sound file of the start of this clip.
        End - the offset into the sound file of the end of this clip.
        Length - the length in decimal of this clip
        Data - not sure what this byte is for. I believe it should represent the Sample Rate and Format (ADPCM or PCM) of the clip. My program uses this byte (if you have "[X] Automatic Settings" checked) to make a guess at the file Level, Sample Rate and Format. It does not always get it right. Here what I think I know:

                    bit 7 (high order bit)  0 = IMA/DVI ADPCM clip
                                                    1 = 24 bit signed PCM clip (PS3 sound files only)
                    bit 6 - possibly, with bits 7 & 3, sets the sample rate and format per the table below.
                    bit 5-4 - appears to connect the clip with the volume control that controls it:
                                    00 - Engine sound clip
                                    01 - Accent sound clip
                                    10 - Horn/Whistle sound clip
                                    11 - Bell sound clip
                    bit 3 - possibly, with bits 7 & 6, sets the sample rate and format per the table below.
                    bit 2 - unknown
                    bits 1-0 - unknown, either "00" or "11", but mostly "11".

        Here are some suggested values for the Data byte. You can start with one of these values and then experiment:



Engine Accent Horn/Whistle Bell

5512 Hz 4F 5B * *

11025 Hz 0B 1B 1F 2F 2B 3F 3B

22050 Hz * * 27 23 37 *33



Engine Accent Horn/Whistle Bell

5512 Hz 4B 5B 5F * *

11025 Hz 0B 1B 1F 2B 3B

22050 Hz 03 07 13 17 23 *27 37 *33

24 bit big-endian signed PCM


Engine Accent Horn/Whistle Bell

5512 Hz 8B 9B 9F AB BF

11025 Hz 83 87 93 A7 A3 B7

22050 Hz * * * *

* no examples of this combination seen

An examination of this table seems to show that bits 7, 6, and 3 set the clip format and sample rate as shown here:

Bit 7 6 3

0 0 0 22050 Hz ADPCM

0 0 1 11025 Hz ADPCM

0 1 0 not seen

0 1 1 5512 Hz ADPCM

1 0 0 11025 Hz PCM

1 0 1 5512 Hz PCM

1 1 0 not seen

1 1 1 not seen

When ADPCM program has "[X] Automatic Settings" checked, it uses this table to take its best guess at the settings for clip format and sample rate.

Some sounds can repeat. For example the bell, or the diesel engine rev sound. The repeatable segments of a clip may only be a portion of a clip or may be the entire clip:

Start Rep - the offset into the sound file of the start of a repeatable segment of a clip.
End Rep - the offiset into the sound file of the end of a repeatable segment of a clip.
SM Init-     For IMA/DVI ADPCM clips this is "State machine initialization" - for the programers out there : the ADPCM decompressor is written as a state machine. The state machine requires two pieces of data at startup - the initial state and previous sound value. When you start a clip from the beginning, both of these values are usually zero. A repeating segment, which may start in the middle of a clip, needs to know these two pieces of data to produce the correct sound. You can look at the code if you are really interested. For 24 bit signed PCM clips, I don't know what this field in the index used for because it does sometimes contain a non-zero value.       

The sound file from the beginning of the file (0x00) to the start of the index (0x100) and from the end of the index (0x10FF) to the first sound clip (0x8000) probably contains engine performance information. The softkeys are stored at 0x1900-0x191F. The [Edit Softkeys] button lets you turn these softkeys on  and off.

ADPCM v 1.3.5 sound file player ZIP file is here

--- A reminder to always work with a copy of your sound file. ADPCM makes changes/edits to the sound file immediately without confirmation. ---

(As of version 1.0.11, the ADPCM program has been ported to Embarcadero C++ Builder v10.1 Berlin. Thanks to Kevin Rice for showing that this was possible.)


Make a folder, maybe called ADPCM. Unzip the contents of the zip file into that folder.

Start the program by double clicking on "ADPCM.exe". In Windows Explorer, it may appeat as "ADPCM      Application".

Press [Browse] to choose a sound file. ADPCM can play back most of the clips for both PS2 and PS3 engines. You can select either ".mth" files or ".ima" files or ".raw" files. ".ima" files are 4 bit IMA/DVI ADPCM audio data. The ".raw" files are for 24 bit signed PCM audio data. The clip's data format can either be 4 bit IMA ADPCM (PS2 and PS3 engines) or 24 bit signed PCM (PS3 engines).

Press [Analyze] and the program will list each clip in an index. This is ".mth" files only. ".ima" and ".raw" files can only played directly with the [Play entire file] button.

You can play the entire file by clicking on [Play Entire File]. If the file is a ".mth" file, the program will play each clip in the index (you must press [Analyze] first) or if it is either ADPCM or 24 bit signed PCM, it will play the entire file using the Data Format and Sample Rate.

Click on the start address of the clip you want to play.

Choose the file Level, the Sample Rate and the Data Format.

Press [Play Clip] --- the program converts the sound to 16 bit PCM and sends it to the default sound card. It's Mono.

When you play the horn/whistle sound, at clip 152, ADPCM will always play one of the four ending clips, at 153-156. I did this to make the horn/whistle sound right when played. Watch the Messages window and you can see which ending that ADPCM randomly selected. In the engine, clip 153 is the simple normal end of a horn/whistle. Clips 154-156 are more fanciful endings. When you replace the horn/whistle clip, you should always replace all 5 at the same time.

If the clip has a repeatable section, you can press the [Play Repeating Segment] button. The program will play that segment once.

You can press STOP to try to stop playback but the code queues up 20 blocks in advance. It may take 10-20 seconds to acutally stop playing a long clip.

Volume control is a real Windows volume control. Values go from 0 to 15.

"[X] Automatic Setting" lets the program make its best guess at the file Level, the Sample Rate and the Data Format of the clip. If you can figure out how I can improve the guesses, let me know. You should normally run with this box checked. The program has actually gotten pretty good at this guess. You can always override the program by picking Level/Format/Rate explicitly using the radio buttons. I'm going to make it default to checked with v 1.3.5 of the program.

If you press the [Long Play] button, which is enabled if a "Repeating Segment" is present, ADPCM will play the clip while repeating the segment the number of times shown in the "Rep" field. This technique is used, for example, for the bell sound. Setting "Rep" to a higher number will cause the bell to ding additional times.

If you click on the title of the left column of the grid, "Offset/Index", the value in that column will change from the hex offset into the sound file to a numeric counting of sounds. The numeric value of each sound corresponds to the number sent in the "n" command to the TIU by the RTC program.

The sound Filename, file Level, the Sample Rate, the Data Format, Automatic Setting status, and Volume are saved in the Registry for the next time you run the program.

GetDevCaps button shows the result of the call to this function. Useful only if you work with the source code.

Hint - If you click on "ADPCM Info" from a popup menu and then click on the [Hide] button, that annoying copyright window on startup won't appear any more.

Getting Sound Files

You can get (almost) all of the sound files from MTH's web pages.

For example:

click on "Support"
click on icon that says "ProtoSound"

This will let you download either the sound file which is named "*.mth" or it will let you download a ZIP file which contains the sound file.

Just open the "*.mth" sound file with the ADPCM program (press [Browse] or drag & drop).

v 1.1.0 Exporting Sounds to MP3 Files

As of version 1.1.0, I added the ability to export each sound to an mp3 file.  Click on [Export mp3] after you have analyzed a sound file. The program will go through all of the sounds in the index and create individual sound files in the same folder as the ".mth" file. Each sound file is named with the ".mth" filename followed by the index number of clip, 1-255, and the extension mp3.

This requires the "lame" mp3 encoder. You can get version 3.99.5 for Windows here. Its a zip file. The program "lame.exe" and the DLL "lame_enc.dll" must be placed into the same folder as holds the ADPCM.exe file. You can use the complementary copies of lame v3.99.5 in the ADPCM zip file.

Two export options are available:
MP3 format does not support 5512 Hz sample rate which is common in the sound files. Lame upsamples them to 8000 Hz when creating the mp3 file. Other sample rates are used unchanged.

v 1.1.2 Editing the sound file

Version 1.1.2 of ADPCM ADPCM will allow you to replace a clip in a sound file with a clip from another sound file.

  1. Start with a sound file downloaded from the engine's web page as I describe in "Getting Sound Files" above. Make a copy of it and work with the copy.
  2. Run ADPCM and [Browse] or Drag & Drop the sound file into the Filename entry box.
  3. Press the [Analyze] button. Note the value for "End of Sounds" which displays in the "Messages" box. More about this later.
  4. Scroll down the index table to the clip that you want to change. Click on that row in the index.
  5. Then right click on the row and select "Edit Clip" or just press the [Edit Clip] button.
  6. Click on "Replace clip with a clip from another sound file" but it will probably already be selected.
  7. Press [Browse] or Drag & Drop the sound file that you will be taking the clip from.
  8. Type the Clip Number of the clip in that sound file.
  9. Press [Do It].
  10. When the clip transfer is complete, the sound file index will update and you can look at and test the result of the clip change.
  11. You can go back to step 4 and change another clip OR
  12. The sound file can be transfered to the engine using the DCS Loader.

1. If you replace a short clip with a longer clip (look at the Length field of the clips), the sound file will grow. ADPCM will alert you if the clip that you are adding causes the sound file to grow larger than the engine's EEPROM. You should always double check the calculation. If you replace a clip with a shorter clip, the unused space is available for other clips.

2. With a few exceptions, clips seem to be randomly located in the index depending on the engine. ADPCM will not let you put a clip into a previously empty clip number. The engine would not know what to do with it. ADPCM will let you put a clip with a repeating segment into a clip location that did not have a repeating segment. The engine probabaly won't know what to do with the repeating segment information.

3. Here are a few of what seem to be fixed clip # locations (indexes 177-186 are probably the best place to put replacement clips):

            41        Single Toot
            42        Single Toot or sometimes SXS (Xing sound)
            43        SFS (forward sound)
            44        SRS (reverse sound)

            152    Engine horn/whistle
            153    Ending #1 for the horn/whistle
            154    Ending #2 for the horn/whistle
            155    Ending #3 for the horn/whistle
            156    Ending #4 for the horn/whistle
                        ----- you should always change all 5 of these horn/whistle clips at the same time
            157    Bell

            177-186   Engine Sounds clips which correspond to S01-S10 on the softkeys.

4. Do not put a 24 bit PCM clip into a PS2 sound file. As far as I know, PS2 engines cannot play 24 bit PCM sound clips. PS3 engines can play both types of sound clips.

5. I've tried this with a few engines and it seems to work. If any changed clips don't play correctly, you can always just reload the original sound file back into the engine. That said, I am not responsible for anything that happens to your engines as a result of using ADPCM. I use version 5.0 of the DCS Loader.

I'd appreciate hearing any insights you have about other clips and how they are used.

v 1.1.5 Replacing a clip with clip from another file

Version 1.1.5 of ADPCM allows you to replace a clip in the sound file with any other sound. 

1. Allows you to insert any sound from a disk file into the sound file.

    ADPCM will let you insert any 4 bit IMA-ADPCM or 24 bit big-endian signed PCM sound clip into the sound file. You must be careful about the the new size of the sound file so you don't exceed the EEPROM size. The program will try to warn you if you exceed the EEPROM size but the program can only guess at the size and it may be wrong.

    The best candidates for replacement are the Engine Sounds S01 to S10. Most engines play many of these sounds from the softkeys. They correspond to index locations 177 to 186. They do not repeat.

    You must convert the sound you want to insert into a 4 bit IMA-ADPCM or a 24 bit signed big-endian PCM file. I used Audacity and sox for this.

        1. Once your clip (maybe from an mp3 file or recorded from your microphone) is in Audacity, make sure the sample rate is set to 5512 Hz, 11025Hz or 22050 Hz.
            If its not, resample it. The sound level setting will affect how the sound plays in the engine. I can't give you any guidance about this. You will have to experiment.
            Remember that the sample rates are samples per second of sound. One second of 11025 Hz sound using 24 bit signed PCM is 33,075 bytes. The sound file will fill up FAST.
            At 4 bit ADPCM at 11025 Hz, it's only 5,512 bytes (but at lower audio quality).

        2. In Audacity, select File->Export Audio
        3. Set "Save as type" to "Other Uncompressed files"
        4. Set "Header" to "RAW (headerless)"
        5. Set "Encoding" to either "VOX ADPCM" or "Signed 24 bit PCM" (remember that one file will be six times larger than the other). 24 bit PCM is only supported in PS3 sound files
        6. Set "File name" to something that is meaningful, like "Bells_x4_4bADPCM_11025Hz.vox" for  a VOX-ADPCM clip or "Bells_x4_24bPCM_11025Hz.raw" for a 24 bit
            signed little endian PCM clip. Note: Audacity only generates little-endian *.raw files. See step 8.

        7. For 4 bit ADPCM clips, convert the ".vox" file into a ".ima" (or IMA-ADPCM) file. I use sox to do the conversion. Command line:

                "C:\Program Files (x86)\sox-14-4-2\sox" "farm sounds 11025 4b.vox" -e ima-adpcm  -c 1 "farm sounds 11025 4b.ima"

            The program zip file contains a batch file named vox_to_ima.bat which may help you with this conversion.

Here is a hint from Sam via the OGR forum :

So happy to have found this thread - and really appreciate the work done to decipher the MTH sound files and assemble a program to manipulate the sounds inside.

I have a PS2 steamer pulling my Polar Express around our Christmas village.  Not only were the sounds not really appropriate for the Polar Express, but the command environment made it so the conductor announcement car was not functional.  This is no longer an issue!

Following the directions above, I was able to use ADPCM, Audacity, and sox to successfully replace all of the engine sounds this afternoon.  The only caveat, I was never able to export from Audacity to vox format for sox conversion.  Instead, when exporting from Audacity, I set "Save as type" to "(external program)".  The command was specified as

"C:\Program Files (x86)\sox-14-4-2\sox.exe" -t wav - -e ima-adpcm -c 1 "%f"

allowing Audacity to pipe its wav output directly into sox, skipping the intermediate vox step.

Thanks again!

        8. For 24 bit signed PCM clips, convert the .raw file from little-endian to big-endian. Audacity only outputs raw files as little-endian. Sound files require 24 bit signed PCM clips to be big-endian. Maybe the sound editing program that you use can output directly as big-endian so you would not need to do this. I use sox to do the conversion. Command line:

                "C:\Program Files (x86)\sox-14-4-2\sox" -t .s24 -c 1 -r 11025 -B "farm sounds 11025 24b.raw"  "farm sounds BE 11025 24b.raw"

            The program zip file contains a batch script name le_to_be.bat to help you with this conversion.

        9. Back in ADPCM, browse to the file to edited, press [Analyze]
        10. Select the clip to be replaced.
        11. Right click for the popup menu and select "Edit Clip" or just push the [Edit Clip] button.
        12. Set "Operation" to "Replace clip with a clip read from a file"
        13. [Browse] or Drag & Drop the new sound clip into the Filename field.
        14. Choose a good value for the "Data Byte" (see the table above for some starting point suggestions)

            This is more difficult because I don't have a sure-fire algorithm that will always work for this choice. The initial value is the data byte from the original clip in the sound file. The value of this data byte sets the Format, Sample Rate, and Category of the sound in the engine. Get it wrong and funny sounds will come out of the speaker.

            My best suggestion is to create the replacement clip in the exact same format as the clip to be replaced and use the value of the data byte from the original clip.

            This is not required. I have replaced clips with clips using a different data byte.

            You can also search through the original sound file, looking at other clips, until you find one that matches your new clip, then use the data byte value from that clip.

        15. Press [DoIt] and the new clip replaces the original clip in the sound file.

        16. If the clip has a repeat segment, look at the next section titled "Editing an index entry".

2. ADPCM adjusts the length of the sound file to be correct whenever it is edited. This will insure that only the minimum of data needs to be downloaded to the engine by the DCS Loader.

3. On the index menu, added a menu item ("Dump this clip to disk") to dump a clip from the sound to a disk file. Its a straight extract and dump. The output file will either be a ".ima" file for 4bit IMA-ADPCM clips or a "*_be.raw" file for 24 bit signed big-endian PCM.

4. On the index menu, added a menu item to set the file length to the highest clip end address in the index. Useful because when you upload a file from an engine, its length is set to 1MB, 2MB or 4MB. To save time when it's downloaded to an engine, we don't have to download the padding at the end of the file.

v 1.2.0 Editing an index entry

Version 1.2.0 of ADPCM allows you to edit an index entry. You can change any of the fields in the index. This feature does not do very much validation or checking of what you type in. If you make a mistake, some awful sounds will come out of the speaker. Always work on a copy of the sound file.

        1. Load and Analyze the sound file you are working on
        2. Select the clip index to be edited.
        3. Press the [Edit Index] button.
        4. Edit the values as you wish and press the [Ok] button or press [Cancel].

The sound file is updated, analyzed and displayed for you.

You can use this feature to add a repeating segment to a clip. You should only add a repeating segment to a clip that has replaced a clip that already had a repeating segment. The engine probably would not know what to do with a repeating segment of a clip that replaced a clip without one.

You have to calculate the Start Repeat Address and End Repeat Address of your clip. Figure these values based on the sample rate (in Hz)  times the number of bytes per sample (0.5 for ADPCM and 6 for PCM). If the clip is an ADPCM clip, you must also enter a State Machine Initialization value. The ADPCM program will help you with this. First enter the Start Repeat and End Repeat Address values. Then when you play the clip with a repeating segment, the program will print out the SMInit value. That is, it's the state machine value just before the Start Repeating sample is played. Look in the Messages window for this:

      PlaySegment: State Machine Init 0x32015D (0x01D70F)

This lists the SMInit value for this Start Repeating Address value in (). You can then insert this SMInit value into the index.

v 1.3.0 Adding totally new sounds

With version 1.3.0 of ADPCM comes the ability to add new sounds to the sound file and hook them up to certain softkeys. I was able to add a Xing Signal Horn/Whistle sound to an engine that did not come with such a sound. You can have the remote display the softkey label also.

Two new options on the [Edit Clip] window : "(o) Add a clip from another sound file into an empty index location" and "(o) Add a clip read from a file into an empty index location" let you put a new sound into an empty or unused index location. Use the first new option to copy a clip from another sound file and use the second new option to copy an IMA 4 bit ADPCM clip or a 24 bit big-endian PCM clip (also known as raw audio data) into your sound file.

How is this new feature useful?  The remote has a few Softkeys that aren't used much. For example:

    SXS    Xing Signal                    Older engines do not have this sound                       Sound Index 42
    CDO    Coors Door Open        Only one engine uses this sound                               Sound Index 121
    CDC    Coors Door Close        Only one engine uses this sound                               Sound index 122
    SAH    Alternate Horn              Used by the newest engines with quillable whistle      Sound index 243

I know where in the sound file that these softkeys are encoded. If the right bits are set, the remote will display the softkey name.

I started with the sound file for the 20-3163 P&LE 2-8-0 H9 Consolodation (PS2). The whistle on this engine is not to my liking. I took the whistle and bell from  the 20-3372 NYC Mohawk 4-8-2 (PS2) and copied them into the H9's sound file. The sounds on both of these engines are 4 bit ADPCM.

Index Description of sound in the H9 Clip copied from the Mohawk Description of sound in the Mohawk Clip Size in Bytes
41 empty 41 1x toot 4418
42 1x toot 255 Xing Signal 52158
43 2x toot 43 (2x toot) 2x toot 7429
44 3x toot 44 3x toot 7555
121 Coors Door Open * -
122 Coors Door Close * -
152 Whistle 152 Whistle 4933
153 Whistle Ending 1 153 Whistle Ending 1 5218
154 Whistle Ending 2 154 Whistle Ending 2 16484
155 Whistle Ending 3 155 Whistle Ending 3 6466
156 Whistle Ending 4 156 Whistle Ending 4 11669
157 Bell 157 Bell 11616
243 empty 41 1x toot 4418

* I copied test sounds into these 2 locations just to test the progam. I haven't yet decided what "real" sounds I want in these 2 spots in my H9. You can choose whatever sounds you want in these locations. You don't have to have slamming doors or gurgling beer - when you press the CDO/CDC softkeys on the remote, the engine will just play the sound.

To enable the softkey labels on the remote, I added three check boxes on the [Edit Clip] window:

            [  ] Set SXS Softkey (n42)
            [  ] Set SAH Softkey (n243)
            [  ] Set CDO/CDC Softkeys (n121/n122)

If you check the boxes you need, ADPCM will set the bits in the sound file that will cause the remote to display those softkeys. You must delete the engine from the remote and then add it back for the new softkeys to appear. Note: this is not working with the SAH softkey. I don't know why yet.

I've modified  RTC also to show buttons so you will be able to play these sounds as follows:

            SXS                No modification needed, this was already supported on the Operations window.
            SAH               If the engine supports SAH, a new button [Alternate Sound] will appear under the horn/whistle button on the RTC Operations window - this will be available with version 3.22.0 of RTC.
            CDO/CDC     No modifications needed, this was already supported on the Sound window.

You can use any empty index location for new sounds (as long as you don't exceed the size of the EEPROM in the engine). But you will have to use the RTC program to access that sounds as there is no way to get to them via the remote. This is a perfect use for the Hot Buttons window in RTC. You can have RTC send any 'nXXX' command at the press of a button.

So just edit up your sound file and load it into an engine for some new sounds. Be sure to delete the engine from the remote and add it back for the changed softkeys labels to take effect.

v 1.3.1 Editing Softkeys

Version 1.3.1 adds the ability to edit the softkey settings. That is, the bits in the sound file that tell the remote which softkeys to display. Most useful if you plug a light into a prevously unused jack on the PS2/3 board in the engine. You can set the bit and the remote will present you with a softkey. Also useful when there are errors in the sound file (there are a few!). For example, one engine I have does not have marker lights but the LMK softkey appears on the remote. With this editing function, you can can remove that softkey.

To use this, select a sound file on the main window, press [Analyze] and press [Edit Softkeys]. The program will show you the current status of which bits are set. You can select or deselect softkeys. Press [DoIt] or [Cancel] when complete. Then download the sound file to the engine, delete the engine from the remote and add it back for the change to take effect.

The remote seems to have used odd terminalogy for the connectors on the board. They talk about "on Ditch", "on Interior" and "on Mars" to mean three connectors on the board. Then when they say "Mars Light on Ditch" they mean the Mars light plugged into the Ditch connector. You can see each light listed like that on the table on pg 121 of the 5th edition DCS Operators Manual.

v 1.3.2 Cleanup and minor enhancements

1. Added a few more softkeys that can be turned on or off on the "Edit Softkey" window.

2. Added the ability to delete a clip from the sound file. The released memory becomes available to be used by added or replaced clips.

3. When you press the [Analyze] button, the progam will display the available time remaining in the sound file for added/replaced clips. The calculation is based on the setting of the Format and Sample Rate radio buttons. If you want the time remaining for a different Format or Sample Rate, press the radio buttons as wanted, right click to get the main ADPCM popup menu and select "Available Time Remaining".

4. Added selections to the index ADPCM popup menu to clear an index location and to copy an index location to another index location.

v 1.3.4 Replacing a sound with silence

1. Added the sample rate into the automatically generated filename when "Dump Clip to Disk" menu item is selected.

2. Changed the "Dump Clip to Disk" menu item to have a submenu that lets you dump the entire clip as it originally did or to just dump the repeating segment. NOTE that dumping the repeating segment of a 4bit ADPCM clip may not be useful because the State Machine Initialization has not been taken into account.

3. When you export to mp3 & 16 bit raw formats, the 16 bit little-endian PCM raw data is saved in a file named <sound file>_<clip number>_16bit_little_endian_PCM_<sample rate>.raw. This file can be easily imported into Audacity:

    Select Import -- Raw Data
    Pick the .raw file created by [Export mp3]
    Select Encoding: Signed 16 bit PCM
    Select Byte order: Little-endian
    Select Channels: 1
    Select Sample rate: 5512/11025/22050 as necessary
    Press [Import]

4. I found that the "Exporting one clip to mp3" function was used more than "Export All Clips to mp3". The [Export mp3] button on the main window now does the first function. You can access the second function from the index popup menu.

5. If you hold down the shift key when you click on [Export mp3], ADPCM will use the long play method which will export the clip including the number of repeats in the "Rep" field. In the case of the horn/whistle, the export will contain one of the four different horn/whistle endings.

6. Added the option to the Edit Clip window to replace a sound with silence. The program does not just delete the sound but replaces it with 0.01 seconds of silence. If there was a repeating segment, the silent clip will also contain one. I can't be certain that this scheme will always work - send feedback. This was suggested by a member of the OGR Forum. The freed up space in the sound file becomes available for new or replacement sounds.

7. More minor bug fixes.

V1.3.5 Misc Cleanup

1. Made "[X] Automatic Settings" default to checked. The program has actually gotten pretty good at this guess. You can always override the program by picking Level/Format/Rate explicitly using the radio buttons.

2. Fixed an incorrect error message when using [Edit Index] to change the data byte from 24 bit PCM to 4 bit ADPCM setting in PS3 sound files that were less than 2MB in size.

3. The Hex Editor code that I used in the [Edit Index] window, written by Jacek Szumigaj <> was not working quite right. I tried to repair it and now it functions a little better.

--- A reminder to always work with a copy of your sound file. ADPCM makes changes/edits to the sound file immediately without confirmation. ---

Exporting ADPCM clips into Audacity for Editing

If you want to edit a 4 bit IMA-ADPCM clip from a sound file using Audacity here is one way to do it:

1. Using ADPCM, click on the sound index you want to use, right click for the popup menu and select "Dump this clip to disk" -> "Dump Entire Clip to Disk". This will create a "*.ima" file on disk. The name of the file will be the sound file name followed by the clip number. This file is in IMA-ADPCM format.

2. Audacity cannot import this directly. I use sox to convert it to a VOX-ADPCM file with this command line:

        "C:\Program Files (x86)\sox-14-4-2\sox" infile.ima -e oki-adpcm  -c 1 outfile.vox

    The program zip file has a batch file named ima_to_vox.bat which may help you with this conversion.

3. Then import this file into Audacity as VOX-ADPCM. In Audacity:

        Select Import->Raw Data
        Pick the ".vox" file created by the above sox command
        Select Encoding: VOX-ADPCM
        Select Byte order: Big-Endian
        Select Channels: 1
        Select Sample rate: 5512/11025/22050 as necessary
        Press [Import]

4.  You can edit the sound as necessary and then export it and prepare it for use by ADPCM. Follow the instructions above in the section "Replacing a clip with clip from another file"

You can also access these videos on my YouTube Channel.

ADPCM Video 1 - Example of a PS2 sound file

Video recorded 29 Aug 2016

Image loading....

P&LE U28B Sound File (PS2)

ADPCM Video 2 - Example of a PS3 sound file

Video recorded 29 Aug 2016

Image loading....

P&LE GP-7 Sound File (PS3)

I used Embarcadero C++ Builder v10.1 Berlin to compile the program.

I used Audacity and WavePad to try different decodes on the ".mth" file.

I used hex editor HxD in understanding the format of the sound file and in editing the sound file.

I used SOX understand and convert audio files from one format to another.

I use Lame to convert clips to mp3 format.

This site prepared and maintained by Mark DiVecchio

email :

 Mark's Home Page

The DiVecchio genealogy home page
The Frazzini genealogy home page

This site will be under construction for a while.