User Tools

Site Tools


gamedev:synthesizers

Start Page » Game Development with the Drag[en]gine » Dynamic sound with Synthesizers

Sound files provide support for playing back static, pre-recorded sound or music using speakers. Synthesizers provide support to produce dynamic sound at run-time using rules similar to animators. Synthesizers can be assigned to speakers similar to sounds and generate sound if required. Synthesizer Modules are responsible to provide sound production using the definition stored in the synthesizer resource. Once created a synthesizer instance is used to play back the synthesizer. This allows to reuse synthesizers with different configurations. In contrary to animators though a synthesizer instance can be assigned to multiple speakers. This allows to play back the same synthesizer through different speakers.

Synthesizers can output sound as mono or stereo with a user chosen sample rate and bit count. The default is mono, 44100 and 16-bit sampling. Synthesizers are set a number of samples they produce. Speakers play back this many samples of a synthesizer before stop playing back the synthesizer. Synthesizers can be set to looping in which case they produce sound forever. The sample count is still required for controllers to produce a meaningful result.

Controllers

Controllers define the interface between the sound artist and the coder. Any number of controllers can be defined for a synthesizer. The sound artist and coder only have to agree on the meaning and value range used by controllers. This provides an abstraction between sound artist and coders allowing for better work-flow. Controllers are defined by a bezier curve. The input of the curve is the play time along the synthesizer from 0 to the play time set by the artists for the synthesizer. The output is the value used to modify the sound generation of rules for a particular play position. This is different from animators where only a single value is used. This is required since animators produce one state in time but sound is a continuous production process. The synthesizer module has to know ahead of time how the controller value develops over time to properly produce sound. For this reason the controller is a curve the coder can adjust dynamically over time if required. The most typical usage pattern though is to set the controller to either a constant curve or a complex curve set up at the start of playback to obtain a desired sound pattern. Scripting modules typically provide some example implementations of to drive synthesizers easily.

Links

Links map a controller output value into an input value suitable for sources. This allows sound artists to use one controller to drive multiple sources by mapping the controller value to different input values in whatever way the source requires. Links contain a bezier curve like controllers do but the input is the controller output value and the output is fed directly to sources using the link. Most links are linear curves mapping (0,0) to (1,1).

Sources

Sources define the production rules for generating sound. Different sources exist to create complex sounds. Sounds have a mix mode, blend factor, volume and panning parameter. The mix mode can be addition or blend. The addition mode is the default and sums up the output of sources while blend mixes between the previous sound and the sound of this source using the blend factor, which can be driven by a link. Volume alters the volume of the source between a minimum and maximum volume using a link. Panning is used only if the synthesizer produces stereo sound and outputs the sound from left(-1) to right(1) from a minimum to maximum value using a link.

Sources do not have a play position. They are played back as samples are requested from them by the speaker playing a synthesizer instance. For this reason sources store a state of their playback which is updated as the source is generating samples.

The following sources can be used:

Sound

The sound source plays back a single sound file. The source plays back the sound file once and then produces silence unless looping is set. In this case the sound file repeats from the beginning. Sound sources have the additional parameters speed and play state. The speed parameter defines the playback speed of the sound file between a minimum and maximum speed driven by a link. The normal speed is 1 while larger values play the sound faster (2x speed would be a value of 2) and smaller values play the sound slower (1/2x speed would be 0.5). Negative values can be used to play the sound backwards. The play state parameter is used using a link to control if the sound is not playing (0), paused (1/2) or playing (1). The parameter is quantized so the link value is mapped to the closes state value. If switching to stopped state the internal play position is rewind to the beginning. Pause stops the playback without altering the play position. The sound file has to match the synthesizer parameters. If not the result is undefined (usually playing nothing).

Wave Generator

The wave generator source generates a waveform of specific type and frequency. Supported waveforms are sine, square, saw-tooth and triangle. Saw-tooth is right-falling. Supported parameter is frequency which defines the frequency from minimum to maximum using a link.

Chain

The chain source plays back sound files from a list of sound files in a chain. This source is best used for situations like train announcement systems where chains of individual sound files are played back to produces a full information sentence. Any number of sound files can be added to the chain source. Supported are the additional parameters select and play state. The select parameter uses a link to pick the next sound file to play from the list mapping 0 to the first sound, 1 to the last sound with all other sounds in between located in regular intervals. The parameter is quantized so the sound file located closest is picked. This parameter is typically used with a constant type input controller to select what sound file to play next in the chain. Since sound generation is done ahead of the current play position the select value has to be adjusted soon enough. The best time is shortly after the current sound file started playing. Once the current sound file finished the link is evaluated to pick the next sound file to play seamlessly. The play state parameters works similar to the sound source but supports not playing (0), paused (1/3), waiting (2/3) and playing (1). Stopped, paused and playing work the same as in the sound source. The waiting state continues playing the current sound but once finished pauses until the play state switches back to playing. This allows to introduce pauses into the playback without requiring silence sound files to simulate them. Depending in the sound scape required using special silence sound files can be still required.

Group

The group source generates sound using a list of sources. Supports the application modes all, select and solo. In the all mode all sources in the group generate sound mixed together. This allows to group output of similar sound scape type together to modify the results as a whole. The select mode uses a link to blend between the two closest sounds in the group. This can be considered blending through the list of sources in the group using a link from the first to the last source wrapping around. The solo mode is similar to the select mode but plays exactly only one source from the list, the one which is closest to the link value.

Synthesizer

The synthesizer source generates sound using another child synthesizer. Local controllers are forwarded to the child synthesizer potentially changing their order. This allows to reuse synthesizers.

Effects

Each source can be assigned one or more effects. They modify the output of a source.

You could leave a comment if you were logged in.
gamedev/synthesizers.txt · Last modified: 2024/03/14 16:34 by dragonlord