Definesound

From EDukeWiki
Jump to navigation Jump to search

definesound <value> <filename> <pitch_lower> <pitch_upper> <priority> <type> <distance> [volume]

The definesound command defines a sound and assigns various properties to it. The maximum number of sounds that can be defined is 16384 for EDuke32, and 450 for Duke v1.5.

Sound defines over 1000 won't work with the MUSICANDSOUNDFX sprite, because above this value this will trigger an echo effect, so bear this in mind if you're working on a mod with many custom sound files.

  • <value>: This can be either the sound's number or the name that has been defined for that number.
  • <filename>: The name of the sound file. Sound files are assumed to be in the same directory as the program unless a folder path is specified. Assume that the user's OS is case sensitive, and directory delimiters are forward slashes (/) rather than backslashes (\).
  • <pitch_lower> and <pitch_upper>: These are a random pitch variation range. Values may be positive or negative. For example, if you want you sound to have a chance of both moderate increase and decrease in pitch, you would use values such as -512 512.
  • <priority>: A value of 0 to 255 indicates the priority the sound has over other sounds that are playing simultaneously. The higher the value, the greater its priority. This is due to the limit on the number of sounds that can play at once. Take a look at the original USER.CON to see what kinds of sounds get what kinds of priority. For example, most Duke remarks are maxed out at 255.
  • <type>: This flag is a bitfield which indicates what type of sound you are defining.
Bit #0 (1) - SF_LOOP: The sound repeats if continually played.
Bit #1 (2) - SF_MSFX: The sound is an ambient effect. Disabling ambience in the menu will mute this sound.
Bit #0 + Bit #1 (3): The sound will loop until instructed to stop.
Bit #2 (4) - SF_TALK: The sound is a player voice. Disabling "Duke Talk" in the menu will mute this sound. These sounds are affected by the "Speech" volume slider in the menu.
Bit #3 (8) - SF_ADULT: The sound contains offensive content. Disabling "Adult Mode" or enabling the parental lock in the menu will mute this sound.
Bit #4 (16) - SF_GLOBAL: The sound will always be heard from anywhere in the level. When applied to MUSICANDSFX sprites, the sound will play randomly. (See globalsound.) (sndist = 0)
Bit #5 (32) - SF_ONEINST_INTERNAL: Internal flag, reserved for sounds where only one instance should be played at the same time, e.g. looping ambient sounds.
Bit #6 (64) - SF_SPEECH: The sound is NPC speech, and will be affected by the "Speech" volume slider in the menu.
Bit #7 (128) - SF_DTAG: The sound is used in Duke-Tag.
Bit #4 + #7 (144): Applies vanilla Duke3D explosion sound behavior. Note that the sound is treated as neither global, nor as a duketag sound. The sound will be pitched down when in water, and it is always audible with at most the specified distance offset.
  • <distance>: Negative values increase the distance at which the sound is heard; positive ones reduce it. Can range from -32768 to 32767. Note that this value does not affect the sound's volume, but rather it modifies the distance registered between it and any listening players. As such, this has no effect on global sounds or sounds made by the player.
  • [volume]: Optional parameter, specifies the volume at which the sound should played. 255 is the default volume, 0 is silence, 510 is double volume. This parameter is not part of the original Duke3D 1.3 spec, and was added to eduke32 in October 2023.