The Basics

The Basics of LokProgrammer

So, you've decided to step into the world of LokProgrammer and want to start making your own templates? Well you have come to the right place.

Important tidbits before you start: LokSound V5s have a maximum memory of 128 MBits. You can track the space as you add sound files with the blue bar directly under the decoder type in the top left side of the window, if it turns RED You have too many sounds, consider removing sounds. If a sound has a lot of silence in it, remove it and make them separate sounds, the decoder can imitate the silences between using states and transitions on the flowchart.

NOTE: Decoders can take up to a half hour to write, if you want shorter write times, consider removing selectable horn and bell packs, and choose a horn or bell from the Template 1.9 pack, or, open the sound slot and delete every horn or bell besides the one you want, and remove the "SV9=x" condition from the incoming transition doing this can also free up space to add more of your own sounds. (This will eventually be a walkthrough on this website) Don't want to use door sounds, alarm bells, or other little one off functions? You can delete them out of the project, it wont effect anything.

CAUTION!: Sound Slots can neither be read from a decoder, or written singularly to a decoder, you can only WRITE THE ENTIRE PROJECT FILE, NO READ BACK. This means if you want to add, just one template/sound slot to a decoder, you MUST HAVE A PROJECT FILE FIRST!. ESU has many available, ScaleTrains has them on the product page under the "support" tab.

Lets start with some definitions first and foremost

Next step we can take, is double click on Sound Slot 4 (1-3 are kinda "Special" and are made specifically for Prime mover 1, 2 and the Horn, I will get into that at a later time.)

Sound Slot 4 should now be open, and you should be in the empty tab, and see nothing but Mute. (Mute doesn't mean Mute, it basically means Off)

Look over to the left, you should see the following:

This is the properties tab, Starting from top to bottom.

State: A State holds information and sound, it can control lighting and motor functions as well.

Transition: This holds information on the prerequisites that are required to move throughout the "Flowgraph", it can also set global and local conditions (we will get into that later)

Container: This is a box, that can hold states, transitions and comments, used to make your project look cleaner. 

Steam Chuff Container: This is strictly used for the steam sounds on a steam project

Comment: This is a super handy little thing, you can use it to add a comment to the sound slot, or add it inside containers, use it like a sticky note, or a readme so you can keep track of what everything does. It no way effects the operation of the decoder.

Lets begin making our first sound slot! (Also, if you would like things to snap to a grid, select Edit-Align To Grid, Very useful for keeping everything organized)

With "State" selected, you should now see this on the left panel

Lets take a pause here to go over everything here Note: If you don't see this whole screen above, don't worry, use the scrollbar.

Okay, so now you have a rundown of the different State Properties. For this demonstration download this ZIP, unless you already have some sounds in mind. (These are ESUs Civil Defense Siren sounds) Also note, This process is similar to how you also add and set up custom horns.

So, first thing you want to do is extract the sound files from that ZIP to somewhere handy, like your desktop. There are multiple ways to add these sounds to your project, you can click and drag them to the lower right pane, or at the top left of the window where it says "Sound" between "Programmer" and "Tools" press that, and select "Add Sound Files" and browse to it.

NOTE: Ideally sound files must be of .WAV format, Mono, 16 bit and around 31.250 kHz. If not, LokProgrammer will automatically convert, but you may loose audio quality

It should look something like this, all the states should turn a pale yellow color

Next step, is a very important one, adding "Transitions" These are the most crucial part of any sound slot. They contain very important information, telling the decoder what step to make next. Think of the state saying "Alright I'm done now what?" and the transition tells it where to go, or gives it multiple options to go depending on certain prerequisites. You can only activate one state at a time, multiple states cannot be activated, but you can activate another sound slot.

Click on "Transition", and draw a line from "mute" to "up" . Direction matters! Its telling the decoder which way to go after the transition.
You should now have a new little line between Mute and up, with the arrow pointing towards up. it should say 1: [true] above the line near mute, by default, it just means that regardless if the function is active or not, it will transition to up, you dont want this, because it will just play the sound slot with no control, if you click the "transition" line, or still have it selected, it will be blue, and pop this box up on the left

From top to bottom
1. Mode: There are 3 select able modes, normal means when the condition is met to transition to the next state, it will play the sound on the last state all the way through then transition, as long as the conditions are still set. Immediate means that as soon as the condition is met, it will immediately stop the sound, and move to the next state, the last one, which you wont see here, instead it goes in a container, is "exit" and that tells the decoder to completely stop the sound slot once the state meets the condition specified by the transition.

2. Order: This tells the decoder which transition is the most important in order, this is particularly important if there are multiple outgoing transitions, you typically have the most restrictive transition numbered lowest, and the lest restrictive last. This also is very important when you get the error that says "Last transition must be unconditioned" 

3. Conditions: These are requisites that must be met before the transition can take place. There are MANY to choose from. For more info visit Transitions Glossary

4.  Actions: This will set a action in the sound slot, depending on what you set in the Modifty action box. For more info visit Transitions Glossary

For now, it will be kept simple

Next step is to link "Up" to "loop"

Follow the last steps outlined, except adding a condition. If you add a condition, once the sound plays through, and for whatever reason Function is no longer on, it will get stuck in up, it will also throw the warning "Last Condition must be Unconditioned" when you hit Validate. More on validate later.

And now draw a transition between "Loop" and "Down" and "Down" to Mute. Should now look like this:

Now we will test the sound slot, go ahead and do this.
1. Press Validate

2. Press Simulator

3. A bar should pop up on the bottom, press "Function" (warning: its loud, turn your sound down) and play with it a bit. You can watch the flow graph move about. You should notice a couple issues off the bat.

Here are the issues you will run into.

So, Lets fix that

CONGRATS! YOU NOW HAVE A USABLE SOUND SLOT THAT CAN BE SAVED AS A TEMPLATE! 

And this is how very simple horn sounds are made.

We aren't done yet, lets get a little more involved in the project. Notice when its looping and you turn the function off, it doesn't stop? Instead it plays through, THEN stops? Lets work on the response time some.

Go ahead and select Simulator again, and play with it, notice that now, the loop will instantly stop, and go to "Down" when you turn the function off.


Play with it some, you'll notice one thing, when you turn the function off, while it is "ramping up" it has to go through the loop state before it winds back down.

Lets fix that

Don't worry! This is an easy fix, remember when I said "order" is important when dealing with transitions? It can make or break a template, well you've found where they come into play, Remember this, the least restrictive always need to be the highest numbered. Basically your telling the decoder "Play "Up" and then continue to loop, unless I turn the function off" What you want to tell it is "Play "up" then if the function is off, go to "Down" if not, continue to "Loop" Just think of the decoder needing to have specific instructions on what to do, or its gonna get confused and not know what to do. Lets fix this.

There you go, there's a simple sound slot to start with, When I have time, we will go over timers, users, shares and other variables that can add functionality to the sound slot!

If you found this handy, if something is wrong, you have a suggestion, or something needs clarification, let me know as well! 

Consider donating if you found this helpful so I can keep the site online!