Better way to switch between sounds quickly

As a developer, it is currently quite difficult to make dynamic sounds. Because the sounds involved may be measured in milliseconds, or have a total duration that is not in multiples of the client’s framerate, lua does not have the fidelity to jump to the necessary position in time to make clean transitions between sounds.

Below is a screenshot of a program used to configure sound effects for model trains called the LokProgrammer. The LokProgrammer uses a system of States and Transitions to make clean and dynamic sound effects. States are the boxes, and Transitions are the lines. Transitions can have criteria, which are shown in brackets.

This is a simple script for a horn sound. The script waits in the Mute state until the Function is set to true. Once the Function is set to true, the Init sound is played, then it repeats the Loop sound until the Function is set to false, where it plays the Exit sound and returns to the idle Mute state.

At the other extreme, this is the script used to simulate a turbo-equipped diesel engine at various RPM:

The LokProgrammer uses individual .wav files for the sounds in each State, but on ROBLOX using separate sounds is undesirable because of data and monetary costs and the relatively low refresh rate of the lua environment.

A possible solution to this problem would be “seek points” which can be set via an object method of some sort. These seek points would, when the specified TimePosition is reached, instantly change the TimePosition to a value specified when the method was called. A max number of times the seek point seeks before removing itself, and a way to revoke seek points will be especially useful.

Thank you for your consideration.

11 Likes