Trains.com

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Digitrax SoundFX Programming Explained

11700 views
11 replies
1 rating 2 rating 3 rating 4 rating 5 rating
  • Member since
    September 2007
  • From: Victoria, BC
  • 54 posts
Digitrax SoundFX Programming Explained
Posted by Don 2816 on Thursday, February 14, 2008 1:10 AM

This is an overview about programming Digitrax SoundFX decoders.  After reviewing the existing sound project examples, one comes to realize the only limit to their functions, other than memory size, is our own imagination. It is possible to program any function key to perform an action, even depending on whether the loco is idle, moving forward, or in reverse.

I've taken an existing sound project sample file, from the yahoo support group
http://groups.yahoo.com/group/digitraxsound/, and modified it for use in my AC4400 which does the following:

Pressing F2 when the loco is idle and in forward, results in two toots.
Pressing F2 when the loco is idle and in reverse, results in 3 toots.
F2 Horn works normally when the loco is moving.
F7 is the grade crossing horn with ringing bell, the bell stops when F7 is pressed again.
F10, F11, F12 are used for cab chatter - voice instructions recorded from rail traffic heard thru a scanner.
The horn sound I used was obtained from the internet.

Part 1 - The Basics

Hardware Requirements:

A computer with a serial port.
A Serial to USB converter, if your pc doesn't have a serial port (Startech USB to RS-232 Serial DB9 adapter works, with the correct driver).
Digitrax PR2 Programmer.
Digitrax PS12 12v power supply, you may have a 12v 300ma one onhand for some other device which could be used.
A piece of track.
Digitrax decoder - I used an SDH104K1A+FN04K1 Combo installed in an HO Kato AC4400.

Software Requirements:

MS Windows, XP or Vista work well.
SoundLoader software downloaded for free from the Digitrax website along with any of the existing sample sound projects in the SoundDepot www.digitrax.com/sounddepot.php .  To create ones own sounds, download and install the free version of WAVEPAD from www.nch.com.au/wavepad/ .

No problems were encountered installing any of the software mentioned in this note.  The PR2 requires a serial port on the pc or a serial-to-usb adapter, one may have to do some debugging getting an adapter to work.  The 12v DC power supply plugs into the PR2 system which is connected to a standalone piece of track.  The PR2, www.digitrax.com/prd_compint_pr2.php , comes with a DB25 TO DB9 adapter.

The decoder uses a 32 ohm 28mm speaker, the only smaller speaker I've heard recommended is Projects Unlimited AST-1732MR-R available from www.mouser.com and is W 17mm L 17mm H 8mm .5 watt.

Part 2 - SoundLoader

The SoundLoader software, available for free from the Digitrax website, is used to create sound projects (SPJ) and download them into a decoder thru the PR2 Programmer.  This program can be used without the PR2 to examine existing sample spj files and play the individual .wav sound files contained in them.  SoundLoader is used to create a single "package" which contains the .wav sound files, SDF function code, a MAP file, and a TXT text description file.  A double mouse click on any of the displayed .wav files will play them, a right mouse click is used to change them.

The SoundLoader display shows the following type of information:

001 DIESEL_START_BELL  SD38_BEEP.wav        0.383 Secs 4224 Bytes 
002 DIESEL_START         AC4400_Start.wav     2.321 Secs 25590 Bytes
003 DIESEL_IDLE            4400_idle.wav           0.901 Secs 9936 Bytes 
004 IDL_RUN                 4400_idle_run1.wav    3.935 Secs 43392 Bytes

021 HORN1_START        1983_horn_start.wav   0.196 Secs 2170 Bytes
022 HORN1_RUN            1983_horn_sustainwav 0.746 Secs 8226 Bytes
023 HORN1_End            1983_horn_end.wav     0.358 Secs 3954 Bytes

You will see labels for HORN_START and HORN1_START, HORN1 is the default standard horn and the HORN files are for the alternate horn.  The alternate horn .wav files can be removed to make room for others you wish to use.

With the SoundLoader program one can export the MAP and TXT files from one of the samples to review or edit them and then reload them into the SPJ.  The Digitrax SoundDepot currently contains 23 sound projects which can be downloaded for free, examined or edited with SoundLoader, and installed in a decoder.  These projects are a good starting point and may completely meet your needs.  It's easy to change the sound files such as the horn or bell, just right mouse click the .wav file you want to change and assign your own file, then download the SPJ to the decoder.

When downloading the sound files to the decoder, it's easy to put more .wav files into the project than the decoder can hold. When this happens, the decoder will not respond to movement instructions or play any sounds.  The solution is to re-edit the sound project and remove some of the sound files and download it again.  SoundLoader does provide information about the size of the project but it is easy to miss the fact that the result is more than the amount of decoder memory.

The decoder I used has 524,288 bytes of memory which is just enough room for about 15 seconds of voice .wav files of cab chatter after the basic sounds and function instructions.

The yahoo Digitrax sound group was created as a place to share files.  Unfortunately, in the past 18 months only one horn sound has been submitted.  The owner of the group is concerned about copyright which effectively limits sound submissions to those we have recorded ourselves or obtained permission to use.  With the huge amount of sound files available on records, CDs, DVDs, and the internet, many of us will not be posting our sound files to that group collection but editing existing files for ourselves and sharing with friends and thru model railroad clubs.

The apparent lack of existing sound files should not discourage anyone from using these excellent decoders.  The WAVEPAD program can be used to edit any existing sound file for your own use.  It can also be used to copy sounds from any sound project.  When creating your own sound files it is important to keep them as short as possible to minimize memory usage.  Horn sounds are the most complex, they are made up of 3 pieces, part of the beginning, a second or less of the middle of the sound, and a short part of the ending.  The middle part is what is played continuously as you press F2.

It is important to save your new .wav file in the correct format, always choose 11025 samples/second, mono and 8 bits.

Anyone considering using SoundFX decoders should download the SoundLoader program and one of the sound projects from the SoundDepot and study it and browse the text description and export the MAP file.

Downloading my SPJ file to the decoder takes 2.5 minutes and one hears static from the speaker while this is happening.  After downloading, SoundLoader has a menu option, SoundTest, which can be used to simulate operating the locomotive. It has 28 function keys as well as direction control and speed.  The locomotive does not move on the track, only the sound function of the decoder is tested.  This is a very handy feature.
 
Most model railroaders will be happy using SoundLoader as described above.  The next part of this note is for those who want to modify any of their locomotive functions or add new features by customizing a Sound Definition File.

Part 3 - Creating a Sound Definition File (SDF)

For this it helps to have experience programming computers.  Previous use of a macro assembler is an advantage, any programming knowledge is second best, third best is an inquisitive nature to determine how this code works.  For all others, I recommend joining a model rail club (or use the internet) to find someone with the necessary experience to do the coding for you or provide advice.

There are two necessary files, snd_cmd.inc and snd_macs.inc, that can be obtained free from Digitrax or someone who has a copy.  These are called Include files and are required to assemble an SDF file.  Digitrax asks that we do not charge for any SDF or SPJ files we create but share them freely with others.  Charging a fee for downloading to a decoder is ok.  Only files that do not have possible copyright issues can be posted to the Digitrax site.

The software required to convert our macro assembler language code can be obtained for free from www.microchip.com by going to the MPLAB IDE page and downloading version 8.01.  Install it on your pc, when first started select the CONFIGURE/SET DEVICE menu option and choose the name of the computer processor chip that the decoder uses, PIC18F242.  This can be found in the first line of any existing SDF macro assembler language program.  Start by joining the yahoo SoundFX group and downloading a copy of the generic_diesel3e.asm file.  This is a complex example of what can be done with the decoder but provides a good basis to modify for one's own use or to learn from.

The macro assembler language looks like the following example of the code for a grade crossing horn with function key 7.  If you can understand this then you may be able to program decoders.

GRADE_CROSS_HORN
       LOAD_MODIFIER MTYPE_GAIN,IMMED_GAIN_MODIFY,SCV_WHISTLE_VOLUME,SCALE_F
F7_CROSSING_SEQ1
       PLAY  HNDL_HORN1_BEGIN,no_loop,loop_STD
       PLAY  HNDL_HORN1_CONT,no_loop,loop_INVERT 
       PLAY  HNDL_HORN1_END,no_loop,loop_STD
       DELAY_SOUND DELAY_THIS,(150/24),DELAY_GLOBAL
       PLAY  HNDL_HORN1_BEGIN,no_loop,loop_STD
       PLAY  HNDL_HORN1_CONT,no_loop,loop_INVERT 
       PLAY  HNDL_HORN1_END,no_loop,loop_STD
       DELAY_SOUND DELAY_THIS,(150/24),DELAY_GLOBAL
       PLAY  HNDL_HORN1_BEGIN,no_loop,loop_STD
       PLAY  HNDL_HORN1_END,no_loop,loop_STD
       DELAY_SOUND DELAY_THIS,(150/24),DELAY_GLOBAL
       PLAY  HNDL_HORN1_BEGIN,no_loop,loop_STD
       PLAY  HNDL_HORN1_CONT,no_loop,loop_INVERT 
       PLAY  HNDL_HORN1_END,no_loop,loop_STD
       END_SOUND

Create a new folder for your programming and put the Include files in there too.  Your programs can be edited with the MAPLAB Interactive Development Environment (IDE).  To compile the code, choose the menu option PROJECT/QUICK BUILD.  You will be notified of any errors in the assembly.  Assuming there are none, there will now be a .HEX file in your folder, this is the new SDF file.

To implement the SDF file, start SoundLoader and open an existing SPJ and use the menu option under File to import the HEX file.  When importing the .HEX file, a copy of it will be created by SoundLoader with the .sdf file type and loaded into the SPJ.

There are two other necessary files to complete an SPJ, the MAP file and description TXT.  SoundLoader can be used to obtain an example of a MAP file by loading any .spj file and choosing the menu File option and Export MAP file.  This will save a .map file in your folder which can be edited with any simple editor like Notepad. The MAP file looks as follows and is a necessary part for the linkage to the .wav files.

1 DYN_BEGIN
2 DYN_CONT
3 DYN_END
4 START_BELL
5 START
6 IDLE
7 IDL_RUN
8 RUN
9 RUN_IDL
10 TURNOFF
11 HORN_BEGIN
12 HORN_CONT
13 HORN_END
14 BELL
15 BRAKES
16 COUPLER
17 POPOFF
18 AIRCOMP
19 DRIER

After making and saving any changes, the updated file can be imported back into the sound project.

Under the menu option View/Project Description, you can export this file into your folder as a .txt file. The TXT file looks like the following and can also be edited with Notepad.  It is mostly documentation except for the list in (A) below which is used for descriptive popups for the function buttons in the SoundTest function.

project: AC4400 copy of Generic_Diesel_3e.spj
SDF:      Diesel Scheme

(A) Function Key Usage:
F0-  Lights      
F1- Bell  
F2-  Horn    
F3-  Auto Coupler 
F4-  Air disable 
F5-  Dynamic brake  
F6-  Reduce speed    
F7-  Crossing 
F8-  Mute  
F9-  Brake squeal 
F10-        
F11-      
F12-  

(B) SD38-2 Sound FX defined CV's:  [decoder CV8=8  Factory reset value in brackets]
CV58 Master Volume, 0-15, 0= max, (F8 used for Mute) [9]
CV122 Product TYpe, 12 = Digitrax SFX sound decoder  Read Only Value
CV123 Hardware Version, 17= SDH104K1 decoder  Read Only Value

CV132 Notch rate     [127]
CV135 Volume when Muted    [0]

User configurable SoundCV's:

CV140 PRIME mover vol   0-64 [60]
CV141 BELL volume     0-64 [25]
CV142 WHISTLE volume   0-64 [60]
CV143 Air volume (popoff, drier,comp) 0-64 [30]
CV145 Misc vols (cab chatter)  0-64 [40]  
CV146 BELL delay (24mS counts) 1-100 [7]
CV147 Drier rate, 1= about  2secs 1-64 [2]
CV148 Compressor Start rate         [30]
CV149  COMPRESSOR ON time  [20]
CV150 Horn Selector 0=std Horn

There are some good examples of SPJ and SDF files in the yahoo SoundFX group.


Digitrax has a new decoder, SFX0416, which I look forward to trying.  It has 2 megabytes of memory, 4 times as much as my current one, and uses an 8 ohm speaker instead of 32 ohm.  The decoder has no motor function and is intended to be used with an existing motor decoder.

I just started creating my own SDF files and it helps that I'm a computer programmer by profession who started macro assembler language programming a long time ago.

I expect that most model railroaders would be satisfied with any of the SoundDepot projects available and have a friend or LHS with a PR2 do the downloading to the decoder for them, for those that want additional features or different sounds, I hope this note removes some of the mystery about SoundFX and encourages you to try this excellent product.

Don

  • Member since
    December 2004
  • From: Bedford, MA, USA
  • 21,336 posts
Posted by MisterBeasley on Thursday, February 14, 2008 7:04 AM

Thanks a lot.  I've just ordered an SFX0416 for a trolley project.  Someone did post a trolley project at Digitrax, so I've got the files, and my LHS says I can use their PR-2.  (I'm wondering if that serial port requirement will be a problem, though.  He hasn't hooked up his PR-2 yet.)

 

Thumbs Up [tup]

It takes an iron man to play with a toy iron horse. 

  • Member since
    December 2005
  • From: East Granby, CT, USA
  • 505 posts
Posted by jim22 on Thursday, February 14, 2008 9:05 PM

Awesome Post!!!  And timely.  I just received my PR2 in the mail today.  I am also an embedded system programmer, and I won't be able to resist messing with the SDF file.

I installed my PR2 and it's software on an old Windows ME computer.  I seems to work fine, so Windows XP is not a strict requirement.

Jim 

  • Member since
    September 2007
  • From: Victoria, BC
  • 54 posts
Posted by Don 2816 on Thursday, February 14, 2008 9:51 PM

Dave,

Thanks for the compliment about my note.  I have good news for you, there is no longer any need to maintain secrecy about the two Include files.  The note I received a few days ago from AJ did not say anything about that and I have basically repeated everything he did mention in my note above. 

If I were to share those files with someone, I would forward AJ's entire note so they can read all his comments.  This would save AJ precious time I'd rather he spend with product development.

I'm not concerned with how many users of this forum get any use from my note, I believe that spreading this knowledge around will benefit the product.  For the few who decide to try programming these decoders, my note may help to advise them of what lies ahead and save them a few hours finding software, installing and using it.

Unfortunately I'm not interested in notching.

Don

  • Member since
    January 2002
  • From: Portland, OR
  • 3,119 posts
Posted by jfugate on Friday, February 15, 2008 10:49 AM

Once you guys figure this out, please keep me in the loop. I am a software guy, so new programming languages, etc don't scare me in the least.

I have some special uses I would like to make of the Soundbug, but I would need to know how to program sounds to throttle notches.

You can email me via this forum and we can take it from there. 

Joe Fugate Modeling the 1980s SP Siskiyou Line in southern Oregon

  • Member since
    December 2005
  • From: East Granby, CT, USA
  • 505 posts
Posted by jim22 on Friday, February 15, 2008 10:03 PM

If it helps, there are some files on the yahoo digitraxsound group which deal with notching.  Also, the factory installed SD38-2 project seems to me that it uses notching or something similar.

The RS32 project on the digitrax site, on the other hand, does not seem to have any notching capability.  The engine sounds in that one get louder when the throttle is advanced, but there is no change in frequency.  I have not heard an RS32 for myself, but I would suspect some increase in engine speed with the throttle setting, no? 

I'd like to get a copy of the macro definition include files and AJ's notes.  Is it still preferred that I request those directly from him?  I didn't figure I was quite up to speed enough to bug AJ yet.

Jim 

  • Member since
    December 2005
  • From: East Granby, CT, USA
  • 505 posts
Posted by jim22 on Saturday, February 16, 2008 5:05 PM

Well, we need to crawl before we run, or I do anyway.  My first challenge is to figure out why the factory default SD38-2 sound project supports CV11 (which can be set to 6 to turn the sound off 6 seconds after the engine speed is set to 0 or 0 to keep the sound on indefineatly) but the RS32 sound project from the Digitrax web site does not seem to.  Off into the depths of the sound files I go ... Captain [4:-)]

If I figure it out, I'll let y'all know. 

Jim 

  • Member since
    December 2005
  • From: East Granby, CT, USA
  • 505 posts
Posted by jim22 on Saturday, February 16, 2008 7:19 PM

Well, here's what I found out:

First of all, the soundbug DOES support CV11=0 for infinite sound timeout.  It does not seem to like being programmed in OPS mode with my PowerCab.  On the programming track, the PowerCab is quite happy to read and write CVs, even though the soundbug is not plugged into a decoder, and hence has no function or motor loads.  I set CV11=0, and now the engine sounds keep running while the speed is set to 0.  There is no way to force the shutdown sequence the way the timeout does that I've found yet.

Now, I loaded up the .SPJ file in JMRI LocoNet and viewed the embedded .SDF file.  I had some help from the commented .ASM file from a sample, and I found the following snippet in the SDF file as decoded by LocoNet:

        INITIATE_SOUND TRIG_SND_ACTV11,NOT_TRIG
          LOAD_MODIFIER MTYPE_GAIN,IMMED_GAIN_MODIFY,SCV_FREEFORM,SCALE_6
          PLAY 28,no_loop,loop_STD
          PLAY 33,no_loop,loop_STD
          PLAY 0,no_loop,loop_STD
          LOAD_MODIFIER MTYPE_WORK_IMMED,FMATH_AND+WORK_STATUS_BITS,WKSB_ANALOG_MASK+WKSB_DIRNOW_MASK+WKSB_ACEL_MASK+WKSB_SPDDELTA_MASK+WKSB_MATH_MASK,0
          BRANCH_TO 18; from base of 0

I believe the TRIG_SND_ACTV11,NOT_TRIG is an event which is activated when the decoder software determines the activity timer, as controlled by CV11, times out.  In this case, it plays a few sounds associated with engine shutdown, and the BRANCH_TO 18; from base of 0 mutes the sound.

Going back to the statement above where I said there is no manual shutdown method that I could find, I believe it would be possible to map an unused function key, or even one set for a grade crossing, like F10, to play the same sequence and make the same jump.  I have not tried to do this.  I suspect I would need to modify the .SDP file, save as an .ASM, assemble in the PIC microcontroller development environment, and maybe link into a hex file.  Time to declare victory and take a break! Cool [8D]

Jim 

 

 

  • Member since
    December 2005
  • From: East Granby, CT, USA
  • 505 posts
Posted by jim22 on Saturday, February 23, 2008 4:39 PM

I'm making progress....

I have downloaded and installed JMRI 2.0, which includes LocoTools.  LocoTools includes some LocoNet tools, including a tool which allows one to open a .SPJ sound project file, and fiddle with sound wave files like soundloader.  It also can display the contents of the embedded .SDF sound definition file.  This can be copied and pasted into an editor.

I have downloaded and installed MPLAB IDE 8.0, which allows assembler files like those available on the digitraxsound Yahoo group to be assembled into .HEX files which can be imported into a sound project file.  One needs the magic macro definition files to get the assembly to work.  I did manage to get an error free assembly and a .HEX file which appears to match the contents of the .SPJ file when viewed with a hex editor.

On the first try, I was not able to assemble the SDF file output of the LocoNet SPJ editor.  The raw output itself is lacking the header information where the processor is defined, cblock definitions, macro includes, etc. - basically everything before the "SKEME_START".  Beyond that, there may be some stuff missing at the bottom of the file.  I'll work more on it later.

Jim 

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Users Online

Search the Community

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
Model Railroader Newsletter See all
Sign up for our FREE e-newsletter and get model railroad news in your inbox!