Category: Effects
Since engine version: 1.0 OC


Plays a sound. The specified sound file has to be available in the group Sound.ocg, in the active scenario file, or in any loaded object definition. The audibility of object local sounds will depend on the position of the object relative to the visible viewports.


bool Sound(string name, bool global, int volume, int player, int loop_count, int custom_falloff_distance, int pitch, proplist modifier);


Name of the sound effect (without .wav/.ogg extension). Wildcards as used by WildcardMatch are used.
[opt] Specifies wether the sound is played globally, i.e. independently of the object position always with the same loudness.
[opt] 0-100: volume for playback of the sound. A volume value of nil means playback at 100.
[opt] Player number of the player for which the sound is to be played. In network games, the sound will thus not be audible for the other players. If nil (or not specified), the sound will be played for all players.
[opt] Increases or decreases the number of sounds running in a continuous loop. Value +1 will play this sound indefinitely until it is stopped by calling this function again with value -1. Value 0 will play the sound once normally.
[opt] The further away the sound effect from the player, the more quiet it is played. By default, the sound will not be hearable anymore in a distance of 700 pixels. A custom distance can be specified here.
[opt] Pitch modification between -90 and 1000. Values larger than zero let the sound play the faster and at a higher pitch. The resulting speed multiplication factor is (pitch + 100) / 100.
[opt] Sound modifier for special effects such as reverb or echo. See Sound modifiers.


When a sound effect is already played in the same context (calling object or globally), it is not played again. Instead, only the volume and pitch parameters are updated. This feature can be used to adjust sound parameters live e.g. to tune the pitch of a motor sound based on its speed.


FindObject(Find_ID(WindGenerator))->Sound("Fanfare", false, 50);
Plays a 'Fanfare' sound next to the first found wind generator at half volume.
See also: SoundAt
See also: Music
See also: Sound modifiers
Sven2, 2002-08