Search The Inn

Thursday, December 19, 2024

Digitrax Christmas & New Year Holidays 2024

Digitrax will be closed the week between Christmas and New Year's Day so we can enjoy time with our families and friends.  We wish everyone a Wonderful Holiday Season, a Merry Christmas and a Happy New Year!  We will close at 5:00PM CT on Tuesday December 24, 2024 and reopen on Thursday January 2, 2024.


If you have an idea for a blog post here, let me know. If I can comment on it, I will or I'll see if someone else can and post it  

Friday, December 6, 2024

LokSound 5 Change Horn On-The-Fly Via Function Key

As any DCC and Sound model railroader knows, you program your decoder by changing CVs (configuration variables) to have the sound you want to hear when you press a particular function. That's the way it has been since sound decoders became a thing. If you want to change a particular horn on an engine you have to either reprogram it (change the CV contents) on a programming track or do what is called Program On The Main (POM). On most club layouts POM is often frowned upon.

Enter the LokSound v5 sound decoder. It has the ability to change horns on the fly by repeatedly pressing a user assigned function key. Actually, you can change several different sounds this way but this discussion will demonstrate changing horns. We will use the S0523 sound file for this exercise.

Once you have the sound file loaded click on the decoder pane on the left and then click on the Sound Slot Settings sheet. In the right window you now have the SoundCV Configuration with the Sound Slot Configuration below. Notice that SoundCV 9 is labeled Horn. This is the CV we will be manipulating. See figure 1.

Figure 1 SoundCV Configuration

SoundCVs were added to allow the user to make changes to certain sounds and not have to rewrite the entire sound file to the decoder. You just Write Decoder Data from the menu. They also are accessible when programming in the Sound Pane when working with sound slots and that is the key to this exercise. If you've never programmed with the LokProgrammer the author highly recommends you complete this exercise first. It will show you how to create a sound slot which is what this exercise is going to accomplish.

Let's start by changing to the sound pane and then double click on sound slot 2 because it's empty. Under Sound Slot properties name this slot Horn Select (or whatever you want). Next click on State twice and arrange them as shown in Figure 2. Next add four Transitions and arrange them as also shown in figure 2. This is the basic layout. If you haven't completed the exercise mentioned above you won't understand how to or what you're doing here.

Figure 2 The basic layout

Conditions and Actions
These are what guides the logic. Click on the transition between Mute and State. In Conditions select Function and set it equal to true. In Actions select user1 and set it equal to 0. Now click on the upper transition between State and State(2). In Conditions select Function and set it equal to false. In Actions select timer1 and set it equal to 5. This is the start of the double click loop that will change the value in SoundCV 9.You Should now have figure 3.


Figure 3 First Conditions and Actions

Now for the lower transition. Select it and in Conditions select Function and set it equal to true. In Actions select User1 then "+" and set the value to 1. This is shown in figure 4.
Figure 4 Closing the Loop

These two states allow you to double click the selected function button repeatedly and the value of u1 will increment by one everytime. Now for the exit condition of the sound slot. Click on the bottom transition of State(2). In Conditions add 2 different ones. First, Select Function and set it equal to false then select Timer1 and set it equal to 0. In Actions select SoundCV9 and type in user1 for the value. This is probably a bug in LokProgrammer's software because you get no dropdown for any SoundCV selection but it will accept a typed in value. Results are shown in figure 5. Lastly, turn on looping in both states since exit conditions are not allowed in non-looping sound states.


Figure 5 The Exit Conditions

Finally go to the Decoder Pane, Function Mapping sheet and assign your Horn Select sound slot to an empty function key.
The author recommends you save this to your template files and then run it in the simulator. Double clicking the assigned function key will increase the user1 variable value for every click except for the first double click. This allows resetting the horn to the beginning value. When you stop clicking, the value is assigned to the SoundCV9 variable thereby changing the selected horn.

Recommendations
When you look at the horn packs for engines some of them contain a lot of horns.

Starting Point
Let's say we like horn #10 of a 16 horn pack. So you want it to start there when you increase the user1 value. Change the initial transition from user1 = 0 to user1 = 10. However, this will prevent being able to select any of the first 9 horns.

Safety Factor
In the lower transition to the left of state(2) it may be advisable to put a second condition of user1 < x where x is some number greater than 1. As is, double clicks will just continue to increase the value until the user stops clicking. If you go beyond the last horn in the pack, who knows? The x should be 1 less than the maximum value you want because u1+1 will increase the value on exit.

Rearrangement
You could rearrange the order of horns in the horn pack but that would be a ton of  work.

This is a simplified version of changing horns inspired from an exercise by Apoorva, the Indian Rail Modeler. He has a YouTube video on this here.

The author is sure you can come up with other things to make this better. Most of all have fun!



If you have an idea for a blog post here, let me know. If I can comment on it, I will or I'll see if someone else can and post it