Procedural Engine Sound

From TrainzOnline
Revision as of 16:18, 10 January 2017 by Windwalkr (Talk | contribs)

Jump to: navigation, search

Procedural Engine Sound synthesis is achieved through use of the Graph Editor. The Graph Editor is a pre-release feature of Trainz. It has been discussed publicly in the TrainzDev forums and is summarised on this page, however users should understand that no release schedule has been provided for this feature. All discussions and details are speculative in nature and may not accurately reflect the final form of this feature.

This feature is only usable within the Graph Editor for now, however as development continues it will obviously be possible to use the result from within the game environment as well.

Contents

Simple Synthesiser Tutorial

To create a sound synthesiser graph, select an existing Engine Sound asset and open it in the Graph Editor. The following steps allow you to create an extremely trivial synthesiser:

  • Create a new "Sample" node near the top left of the graph panel.
  • Edit the "WAV File" property on the "Sample" node to "idle 1.wav" (it is assumed that your Engine Sound asset already contains this file).
  • Create a new "Constant" node near the top right of the graph panel.
  • Edit the "Constant" property of the "Constant" node to "1.0".
  • Add a "Sampler" node in the center of the graph panel.
  • Connect the "Sample" node output to the left input of the "Sampler" node. This determines the input waveform for the sampler.
  • Connect the "Constant" node output to the right input of the "Sampler" node. This determines the playback rate for the sampler.
  • Add an "Output" node at the bottom of the graph panel.
  • Connect the leftmost "Sampler" node output to the "Output" node input.

At this point, you should begin to hear the idle sound playing. You can adjust the "constant" value to vary the playback rate of the sample. You should adjust your system volume (outside Trainz) to a comfortable level since you're going to be hearing a lot of repeating (and sometimes uncomfortable) sounds while editing the graph. You can also temporarily disconnect the sound output by clicking on the input connector of the "Output" node for some peace and quiet while making changes. Any changes you make to the graph will take effect immediately.

Since there are no true external inputs in the editing environment, you can simulate any inputs (such as throttle notch, or train velocity) by creating "Constant" nodes and adjusting their values on demand.

Media:Simple Procedural Engine Sound sample

Sound Synthesis Nodes

A number of Node Types have been created for working with sound data and processing logic states. These are for testing purposes and by no means reflect the final functionality of the Procedural Engine Sound system.

Output Node

The Output Node offers a single input. It reads sound waveform data from the input and plays it through the computer's sound output device. Only one output node should be present in each Procedural Engine Sound graph; if multiple outputs are desired then these should be mixed by the graph logic and fed into the single output node.


Sample Node

The Sample Node offers a single output. It reads sound waveform data from a specified file on disk. A "WAV File" property is available to indicate the name of the wav file to read from disk.


Sampler Node

The Sampler Node offers two inputs (the sample and a playback rate) and two outputs (the waveform and a wrap trigger). Playback rate can be varied in realtime between 0.0 and 10.0. The wrap trigger output is normally zero, but spikes high whenever the input wraps. This can be used to stop playback at the end of the parent sound sample, for example.


Math Node

The Math Node offers two inputs and one output, and performs a simple mathematical operation (*, /, +, -) on the inputs. An "Output Scale" property can also be used to further scale the result.


Constant Node

The Constant Node offers a single output, which remains at a constant value. The "constant" property can be modified in the editor in order to adjust the output value.


Threshold Node

The threshold node is obsolete; it offers no real advantages over the Map Node.


Toggle Node

The toggle node allows for a flip-flop logic operation. It offers two inputs ("set" and "reset") and one output. At any given time the node is either "high" or "low". When the "set" input is pulled high, the toggle switches into the "high" state. When the "reset" input is pulled high, the toggle switches into the "low" state.

Additional "Auto Trigger" and "Auto Reset" values exist which cause the toggle to swap into the specified state after a specified number of seconds in the opposite state; a zero duration here disables the timed effect.

Under normal operation, the output value is determined based on the high/low state and the "Low Value" / "High Value" properties. An "Output Spike Only" property causes the output to instead spike the intended value but immediate return to zero.


Map Node

The map node allows a custom mapping to be created. The mapping is edited by double clicking on the Node, clicking the "Edit" button, then drawing on the map. The horizontal axis corresponds with the input value. The vertical axis defines the corresponding output value. The map node also offers properties defining the range of the input values; values outside this range are clamped.


Meter Node

The meter node displays the current value of its input. This is used for diagnostic purposes within the Graph Editor; it has no runtime effect.

Personal tools