Skip to main content

A poster on another forum posted some of the details that he discovered on the format of the sounds in the .mth file. I took what he did, extended it and put together a small program that can play clips from the .mth file. Its still very much a work in progress.

If you want to try it, you can get it here, along with simple instructions:

http://www.silogic.com/trains/ADPCM.html

includes a *.exe file, full source code for Borland C++ Builder v4. Like my RTC, Remote Train Control program, it's distributed free under the terms of the GNU Public license. I've run it on WinXP and Win7. Should run on Win10.

The audio formats in this file are industry standard formats. Most "low resolution" audio clips are ADPCM (Adaptive differential pulse-code modulation) at a sample rate of 5,512 Hz. "Medium resolution" clips are "24 bit signed PCM" at 11,025 Hz and "High Resolution clips are at 22,050 Hz. The sound files are simple binary files with no encoded or CRC.

Original Post

Replies sorted oldest to newest

I'm having a wonderful time playing with this program.  Thank you so much for creating it!  I've spent the past few hours trying to figure out how the PS2 files are organized, and have discovered in every file I have examined:

Index location 00000380 is a single, short whistle.

Index location 000003A0 is a double whistle.

Index location 000003B0 is a triple whistle.

Very cool.  Thanks again.  (BTW, I am running Windows 10 and have had no problems.)

-- 700E

I spent some time thinking about ways to change the sound file. The simplest way is to replace a clip in one sound file with a clip from another sound file. This does not require any sound format changes.

I added a routine in ADPCM that lets you do that. I have a beta version which I'd like to have some help testing.

You can read about it here:

http://www.silogic.com/trains/ADPCM.html#editing

Mark

Version 1.2.0 of my sound file editing program, ADPCM, is available on my web page: 

http://www.silogic.com/trains/ADPCM.html

This version lets you

1. play the clips in a sound file

2. copy a clip from one sound file to another

3. insert your own created clip into a sound file

4. edit the sound file clip index

With (3), you can insert any 4 bit IMA ADPCM clip into a PS2 or PS3 sound file and you can insert any 24 bit big endian signed PCM clip into a PS3 sound file. You can create those types of clips using freely available tools (I used Audacity and Sox - links to these on my web page).

Casey Jones2 posted:

So with say like using Audacity can we equalize the random sound clips? 

I'm not sure what you mean. If you have mp3, wav or many other types of sounds, you can read them into Audacity. You can adjust their sample rates to the 5512 Hz or11025 Hz rates supported by the engines (monophonic only). Then you can export them to raw data files. Then you need to use Sox to convert those files into clips, playable by the engines, that my program can stuff into the sound files.

Audacity can generate 4 bit VOX ADPCM clips - but you need Sox to convert those to 4 bit IMA ADPCM clips.

Audacity can generate 24 bit little endian signed PCM clips - but you need Sox to convert those to 24 bit big endian signed PCM clips.

It may be that the clips were originally created on Apple computers rather than Intel PCs. Commands for those conversions are on my web page.

Maybe you can find an sound editor program than can generate these needed formats directly.

gunrunnerjohn posted:

Any special things you need to install for SOX?  I see it's actually a command line program, and the reviews on SourceForge say something about not coming with the DLL's required.

I just installed it from *.exe file on their web page. I believe that the DLL missing are if you want to generate mp3 files. We are just using sox to manipulate 4bit and 24 bit raw data files.

gunrunnerjohn posted:

Am I missing something, or is it a plain command line application?

Yes, its a plain command line app. The .exe that you download, though, is an installation program. It puts the program and some required DLL's into your Program Files folder. Then its executed via command line from there.

On my computer (Win 7), the sox program is put into its folder and is executed with a command line like this:

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

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!

-Sam

Yet another version, V1.3.0, of ADPCM can be downloaded from my web page.

http://www.silogic.com/trains/ADPCM.html

This new version allows you to add sounds to empty index locations in the sound file. Those of you who have been around for a while know that the Xing Signal (SXS) was added late in the life of PS2. Many earlier engines don't have this sound.

My 20-3163-1 P&LE 2-8-0 H9 (from 2005) was one of these. Since I didn't like the whistle and bell sounds in this engine I  replaced those with sounds from a 20-3372-1 4-8-2 L-3a Mohawk (from 2009). The Mohawk had a Xing Signal so I fixed up ADPCM to be able to add a completely new sound into an empty index. The Xing Signal is in index location 42 so I added the Mohawk's Xing Signal sound into that location.

Since I discovered where the soft keys are stored in the sound file, I turned on the appropriate bit for the SXS soft key. I loaded this sound file into my H9, deleted the engine from the remote and added it back. The SXS soft key was there. All of the inserted Mohawk whistle and bell sounds were there and the SXS soft key played the Xing Signal.

With my RTC program, you can play any sound from 1-255 with the press of a button. You could insert sounds in any empty index location and play that sound. You would have to use the RTC program, though, as the remote does not have a way to command these new sounds to play.

metsno1fan posted:

Brilliant, thank you! I have been working on converting my MTH 4-6-0 George Washington to WDRR Walter E Disney, but was relying on Protocast for the Disneyworld Park announcements.. this will be perfect to add in the real sounds.

I'd suggest that you put the new sounds into indexes 177-186. The sounds in these locations play when you press the S01 to S10 soft keys.

My first cut at this is to take a best guess at the maximum sound file size based on the size of the sound file and if the file contains any 24 bit big endian PCM clips (which indicates PS3 4MB).

I could just let the sound file grow without bounds and have the user keep track.

I could guess but then put in an override selection to limit size to 1MB, 2MB and 4MB (are those the right limits?)  Barry's 3ed appendix B says PS3 boards have 16 MB of memory.

I'm open to other suggestions and I'll put the change into the next release.

Skipping PS-3, MTH PS-2 5V Sound files are all less than 1Meg.  For PS-2 3V most sf are 1Meg, later releases are above 1MEG but less than 2Meg.  These files only load into PS-2 3V boards with 2Meg memory.  The ones with "Sharpe" memory.  I am just noting, if folks start adding data to a file and it goes from 9K to 1.1 M it no longer will load into their board.  G

I am a novice here, so please pardon the basic questions.

Why are some of the values in the data column highlighted in red? Also, is there a way to know whether the clip should be played with the 24bit vs. 4bit setting, because it is trial and error for me right now. I can guess by the size of the data in the length field.

Thanks!

George

1. If the "Data" column is red, that means my program has determined that the clip is 24 bit big endian PCM otherwise its 4 bit ADPCM. When you press the [Play] button, the program will play it that way. Be sure to turn on "[X] Automatic Settings" to have the program play the clip after taking its best guess at the format. (I should make this the default as 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. The engines are pretty smart, they can play any sound 1-255 if commanded to do so. Unfortunately, the M*H remote only has the ability to command some of them - for example, SXS is sound 42, the horn/whistle is sound 152, SFS is sound 43, S01-S10 are sounds 177-186.

My computer program, Remote Train Control (on my web site), can command all 255 sounds.

SanDiegoMark posted:

1. If the "Data" column is red, that means my program has determined that the clip is 24 bit big endian PCM otherwise its 4 bit ADPCM. When you press the [Play] button, the program will play it that way. Be sure to turn on "[X] Automatic Settings" to have the program play the clip after taking its best guess at the format. (I should make this the default as 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. The engines are pretty smart, they can play any sound 1-255 if commanded to do so. Unfortunately, the M*H remote only has the ability to command some of them - for example, SXS is sound 42, the horn/whistle is sound 152, SFS is sound 43, S01-S10 are sounds 177-186.

My computer program, Remote Train Control (on my web site), can command all 255 sounds.

Mark,

Perfect! That is what I assumed. So here is the issue I have: I posted this in another thread, but your program is helping me troubleshoot this. My engine sound clips S02 through S09 play static when I select them on the DCS remote. I downloaded the engine sound file from MTH and loaded it in your program. Those clips are highlighted red with data values of 0x93 for each. However, they play static with the 24 bit setting and play correctly with the 4 bit setting. It seems the engine is seeing this the same way your program is. Is there anything I can do to fix this? Another oddity is that those sound clips appear to be the clips that play for Passenger/Freight Announcements (PFA). PFA plays correctly on the engine. Also, S01 and S10 work correctly on the engine and in your program.

Thanks again for the help!

George

SanDiegoMark posted:

George, post the M*H stock number. I'll download the sound file and look at it.

If we can determine that the "Data" byte is wrong, my program will let you change it. I'd worry that we might break PFA if we do that.

Mark

 

Mark,

The engine is 11-1044-1.

Here is the link to the sound file: http://mthtrains.com/sites/def...160108af4x-cnsmr.zip

If we break it and it doesn't work, we should be able to set it back.

Thanks, 

George

SanDiegoMark posted:

George, post the M*H stock number. I'll download the sound file and look at it.

If we can determine that the "Data" byte is wrong, my program will let you change it. I'd worry that we might break PFA if we do that.

Mark

 

I think the Data byte 0x93 is categorizing those clips as PFA. I think they should have been recorded as 24 bit. I could try exporting and converting them to 24 bit. There are clips at index locations 248 through 251 with the same Data byte. Those clips are station announcements that would be used in a passenger version of the engine and are recorded in 24 bit audio. I am just trying to use deductive reasoning here, but you are right that this could break PFA.

George

George,

(Always work with a copy of the sound file, then if we break it, you can download the original).

Observations: 1. clips at 248-251 have the 0x93 Data and they play correctly.

2. clips at 10-11 are also 24 bit (Data 0x8F) and they play correctly.

3. by looking at the starting address, the clip at 178 also appears at 80 but with a correct Data of 0x1B. Clip 80 is where I usually see the PFA announcements. If you look at clips 80-96, you again see the same clips as 248-251 but with the correct Data of 0x1B. "Same Clips" means the two index locations are referencing the same sound in the sound file.

So I think its an error in the sound file. You can click on each clip 178-183 and press [Edit Index], click in the Data edit field, then use the arrow keys to select the correct Data byte value of 0x1B. Download the new sound file into the engine and it should work for both PFA (from clips 80-96) and S01-S10 (from clips 177-186).

This pointed out an incorrect error message when the Data byte is edited. Just press [OK] on the message box. I'll repair the error in the next release.

Mark

SanDiegoMark posted:

George,

(Always work with a copy of the sound file, then if we break it, you can download the original).

Observations: 1. clips at 248-251 have the 0x93 Data and they play correctly.

2. clips at 10-11 are also 24 bit (Data 0x8F) and they play correctly.

3. by looking at the starting address, the clip at 178 also appears at 80 but with a correct Data of 0x1B. Clip 80 is where I usually see the PFA announcements. If you look at clips 80-96, you again see the same clips as 248-251 but with the correct Data of 0x1B. "Same Clips" means the two index locations are referencing the same sound in the sound file.

So I think its an error in the sound file. You can click on each clip 178-183 and press [Edit Index], click in the Data edit field, then use the arrow keys to select the correct Data byte value of 0x1B. Download the new sound file into the engine and it should work for both PFA (from clips 80-96) and S01-S10 (from clips 177-186).

This pointed out an incorrect error message when the Data byte is edited. Just press [OK] on the message box. I'll repair the error in the next release.

Mark

Mark,

Thank you! I made the changes to a copy of the file. Later today I will set up my TIU and test track to load the file onto my engine and test the changes out. I will report back.

Best,

George

I was able to load the updated file and it fixed the engine sounds problems. Thank you! I even replaced one of the engine sounds with a 24 bit station stop sound clip. Unfortunately, I replaced one that I need, so I will need to edit the file again to put that one back and change out another. 

In the process, I also reconfigured an old PC that I can use as a dedicated loader, unless I get my Windows 10 PC working well with a USB serial port adapter.

George

George S posted:

Mark,

Have you figured out if it is possible to add a quillable whistle (SPW) from a steam sound file that has the feature to a steam sound file that does not have the feature? Is this only a sound file modification, or would the chain file need to be modified too?

Thanks!

George

George, Glad you were able to use the program.  I think (really don't know for sure) that the quillable whistle requires code support in addition to the sound file. In sound files of engines with the SPW, I found that clip 3 must be that sound. Clip 3 is composed of 5-6 separate whistle sounds, whistle on, whistle getting louder, whistle slightly changing pitch, etc. The code probably strings these sounds end to end depending on how you twirl the thumbwheel.

For example, go here:  http://mthtrains.com/20-3280-1

Click on the "Support" tab.

Then you will see among other things a bunch of icons.   One says "protosound".

I'm using firefox.  If I left click that icon with firefox, I get a dialog pop up to save the .mth file to a local file.

However, you can also "right click" and follow the "save link as" option.  I believe this is what works under chrome also.

It's similar I believe for other engines but the protosound3 isn't one file -- it is (usually) a .zip file and contains both the .mth and .crec files.... if memory serves.

Working for you?

I've made a minor release of ADPCM with a few fixes and enhancements (V1.3.5):

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 <szumi@users.sourceforge.net> was not working quite right. I tried to repair it and now it functions a little better.

You can download V1.3.5 from the web page:

http://www.silogic.com/trains/ADPCM.html

Mark,

Thank you again for the awesome program. Maybe you can help me out. I'm running ADPCM on a Mac thru Virtual Box, I can get the MP3 clips I have thru Audacity into the 24 bit PCM file, but I can't find anything that works for me to get that file to the big-endian version. SoX crashes anytime I try to boot it up in my windows environment. Any other suggestions for getting big-endian files that I could insert into the .mth file?

Thanks!

Andrew

Last edited by metsno1fan

Which engine sound file did you download?

Try an older version of SOX to see if it will run. I see on this web page:

https://sourceforge.net/projects/sox/files/sox/

There are a dozen, at least, older versions. Sometimes the older versions work.

Here is the bug posting web page for SOX:
http://sox.sourceforge.net/Docs/Bugs

I don't know any other program to do the little endian to big endian
conversion. There might be others around but since SOX worked for
me, I didn't look further.

I believe an option there would be to port it to the GNU C++ compiler and use the Qt GUI library for the gui part.   In fact that was my original idea but instead I wrote a Java version.  But my Java version is no longer in sync with the one Mark produces, it's missing all the "edit" features principally.  I was thinking of just putting it into the public domain but got lazy & then someone else could take that on.

AmeenTrainGuy posted:
Severn posted:

I believe an option there would be to port it to the GNU C++ compiler and use the Qt GUI library for the gui part.   In fact that was my original idea but instead I wrote a Java version.  But my Java version is no longer in sync with the one Mark produces, it's missing all the "edit" features principally.  I was thinking of just putting it into the public domain but got lazy & then someone else could take that on.

This is a bit confusing but I see what you mean, but I don't exactly know how to do that. 

gunrunnerjohn posted:
AmeenTrainGuy posted:

Is there a way to get this to work on Linux?

Virtual Box with Windows running in the VM.

I am very sure my system had trouble running virtual box last time I tried. 

Does anyone have a Linux version even if it is slightly out of date? 

Best thing to do is contact SanDiegoMark. He wrote it. I doubt he ever created a Linux version. 

Here try this -- it's a zip file with my compiled java version less all the stuff he added for editing the sounds and things. there are some sound files in it but you can get more from MTH. 

Run the "jar" file with:

prompt> java -jar jadpcm.jar

You'll need to install Java.  I'm not sure the "open java" that's on many linux's will work.   If you can't get that to work, try the one from Oracle.

Attachments

No editing in the Java version.  Mark went too fast for me to keep up in his original.  I helped him move the original to Embarcadero from Borland so had some familiarity with the code.  First I had the idea of going to GNU-C++/Qt ... but somehow did this Java thing instead.  Then I got side tracked...  But intended to go back to it, or the GNU-C++ version at some point and align them.

 

AmeenTrainGuy posted:
Severn posted:

No editing in the Java version.  Mark went too fast for me to keep up in his original.  I helped him move the original to Embarcadero from Borland so had some familiarity with the code.  First I had the idea of going to GNU-C++/Qt ... but somehow did this Java thing instead.  Then I got side tracked...  But intended to go back to it, or the GNU-C++ version at some point and align them.

 

So are you going to update this later on so it has the edit?

Can you guys take this offline? I can't imagine there are many people who need to run this on Linux. This thread was for the tool that Mark built. He provides updates here. Anyone who wants to load one of these sound files onto an MTH engine has to use Windows on a PC or in a virtual machine.

George

Marks website is here where he releases updates and info:  http://www.silogic.com/trains/ADPCM.html

But there's also RTC (also there but different pages) -- which allows you to run mth trains through a DCS but less remote on a PC/Windows.

All software was written Embarcadero C++ ... only runs on PCs/Windows.

But I forgot about this -- Embarcadero supports multiple targets such linux, macos, hand helds using their RAD Studio product -- though it is > $1000 to get to that...

Could be done or some may qualify for an educational version.

https://www.embarcadero.com/products/rad-studio

The java version is an approach but someone has to maintain the code and keep it alive.  I just did it for fun, so may or may not have the interest.

If I add custom recorded sounds via the handheld remote to an engine, when I connect to a PC and copy the sound file from the engine, will the newly recorded custom sounds be in that file?

No. The Custom Sounds are in the TIU, not the engine.


DCS Book CoverThis and a whole lot more about DCS is all in MTH’s “The DCS Companion 3rd Edition!"

This book is available from many fine OGR advertisers and forum sponsors, or as an eBook or a printed book at MTH's web store!

DCS Book Cover

This and a whole lot more about DCS WiFi is all in MTH’s “The DCS WiFi Companion 1st Edition!"

This book is available from many fine OGR advertisers and forum sponsors, or as an eBook or a printed book at MTH's web store!

Get the free TMCC & Legacy Addendum here!

Unfortunately not. The program can only manipulate sound files for PS2 and PS3 engines. There is no way to download the sound files from a PS1 engine.

You could manually record the PS1 whistle and import it into the PS2 or PS3 sound file but you would lose some sound quality as you would be playing back a copy of a copy. The key would be to make sure that you are making the best possible audio recording of the PS1 whistle when recording the file from the original engine.

Last edited by H1000

Landon, Getting the sound out of the PS1 engine is not something that ADPCM does. H1000 describes one way to do it by recording the whistle. There is a PS3 version of the engine 30-1704-1. You could get the whistle from that sound file. But I checked and the whistle for that model is 24 bit signed PCM. PS2 engines don't support PCM. You would have to use an audio editing program (like Audacity) to convert each whistle clip into 4 bit ADPCM. You could then replace the whistle in your PS2 49er. I don't how the quality of the whistle sound would be affected and you might not be any better off when the task is complete.

Mark

 

fIpvRPB

This GIF literally shows how I feel about this thread.

GREAT GREAT GREAT Contribution.

Took me about 2 hours to read through your site and was able to add SXS (Or is it SSXXSSXSX LMAO Your "HOW TO" video was great and made me laugh a few times Mark) to my 5V PS2 UP SD70M.

Was a breeze to do minus the part where Audacity had the audacity (See what i did there?) to save the file in .raw format even after I would change it to .vox BUT exporting using "Other app" and sending the output directly to SOX.exe did the trick.

BTW, I used this on a Win10Pro machine, only issue was I had to force a certain screen resolution as when I would try and edit the .mth file with the new SXS .ima I created for 042, I was not able to see the whole screen, the bit rate setting stopped just below 5,512Hz. I was able to select the category by pressing the down key and praying but before I continued I decided to close the application and start it in compatibility mode with the following settings:

This is what I love about this hobby, really getting into these engines and making them sound and run as the hobbyist sees fit for their layout.

Keep up the fantastic work!

Thanks!!

Attachments

Images (2)
  • fIpvRPB
  • mceclip0

As far as I know, the PS1 line did not have any ability to download new sound files. There are no .mth files for PS1 engines that I have ever seen.

The file that you emailed me is a PS2 file and does play correctly in ADPCM.

I believe you would need to burn the sound files on chips compatible with PS1 boards and then chip swap. I'm not sure how feasible this would be. MTH used to offer replacement sound chips for PS1.

George

It would be fantastic if we could review the sound files without having to download them into the locomotives. 

I am no techie.  I have a MAC mini.  I'm 85.  Will I be able to download the sound files and search for some PS2 or PS3 files during my lifetime?

The way I used Zoom during the Pandemic was to follow a link set up by someone else and behold I was joining a meeting.

Wouldn't it be great to have a similar link that leads me to a listing of the sound files which can then be downloaded to my computer.

 

Lew Schneider

@Severn posted:

Marks website is here where he releases updates and info:  http://www.silogic.com/trains/ADPCM.html

But there's also RTC (also there but different pages) -- which allows you to run mth trains through a DCS but less remote on a PC/Windows.

All software was written Embarcadero C++ ... only runs on PCs/Windows.

But I forgot about this -- Embarcadero supports multiple targets such linux, macos, hand helds using their RAD Studio product -- though it is > $1000 to get to that...

Could be done or some may qualify for an educational version.

https://www.embarcadero.com/products/rad-studio

The java version is an approach but someone has to maintain the code and keep it alive.  I just did it for fun, so may or may not have the interest.

Am I correct in my understanding you ported the RTC to Java?

Anthony

Mark, a simple question.  I was tinkering with the ADPCM program 1.6.4, and I tried to edit the Softkeys, but it gets an error.  Oddly, the sound file is clearly there, but it complains about opening it. I clearly have loaded the sound file as I can play/modify sounds.

Can you tell me what I'm doing wrong?

Edit Softkeys: Unable to open sound file : E:\Downloads\Sound Files\p072pp3gs402_3_sp_070807afin.mth
Edit Engine Parameters: Sound file to be edited : E:\Downloads\Sound Files\p072pp3gs402_3_sp_070807afin.mth

Last edited by gunrunnerjohn
@rtb posted:

John, this may be a work-around, not a real fix.  And of course I defer to Mark.  But you may want to try opening up permissions on the .mth file and see if that eliminates the "unable to open file" message.

Actually, that didn't work, I tried that first thing.  However, I did figure out how to bypass the problem.

The secret is to take ownership of the files.  There are a couple of .REG files that do the trick.

You can get them at the website below.  The two files to grab are in the middle of the page.

Add_Take_Ownership_to_context_menu.reg
Remove_Take_Ownership_from_context_menu.reg

This is the website to grab the files:  Add Take Ownership to Context Menu in Windows 10

If you add the Take Ownership to the file right click menu, taking ownership of the file allows editing.  It's simple, right click on the .MTH file and click on the Take Ownership entry in the menu.  You do have to be an admin account to use these.

Attachments

Images (1)
  • blobid0

Working with gunnerjohn to investigate the problem, I found that the ADPCM program tried to use the Sound File requesting more access rights than the program really needed. I've changed that in the next version to be released. The program will now only request the minimum access rights that it needs to edit the file. If you hit up against this problem and gunnerjohn's fix is not effective, l can send you a beta copy of ADPCM with the code change.

Well Anthony, better late than never maybe?

The answer is I did do a port to java + javafx.  It's probably a little out of date now but I have it out on gitlab.  It could be resurrected I would guess without too much work.

If there's interest I could probably figure out how to make someone a project member, etc...

Last edited by Severn

Add Reply

Post
The DCS Forum is sponsored by

OGR Publishing, Inc., 1310 Eastside Centre Ct, Suite 6, Mountain Home, AR 72653
800-980-OGRR (6477)
www.ogaugerr.com

×
×
×
×
Link copied to your clipboard.
×
×