srctools.sndscript
Enumerations
Several options have a number of predefined names.
- class srctools.sndscript.Pitch
-
The constants permitted for sound pitches.
- PITCH_NORM = 100.0
- PITCH_LOW = 95.0
- PITCH_HIGH = 120.0
- class srctools.sndscript.Channel
Bases:
EnumDifferent categories of sounds.
- DEFAULT = 'CHAN_AUTO'
- GUNFIRE = 'CHAN_WEAPON'
- VOICE = 'CHAN_VOICE'
- TF2_ANNOUNCER = 'CHAN_VOICE2'
- ITEMS = 'CHAN_ITEM'
- BODY = 'CHAN_BODY'
- STREAMING = 'CHAN_STREAM'
- CON_CMD = 'CHAN_REPLACE'
- BACKGROUND = 'CHAN_STATIC'
- PLAYER_VOICE = 'CHAN_VOICE_BASE'
- class srctools.sndscript.Level
Bases:
EnumSoundlevel constants - attenuation.
- SNDLVL_NONE = 'SNDLVL_NONE'
- SNDLVL_20dB = 'SNDLVL_20dB'
- SNDLVL_25dB = 'SNDLVL_25dB'
- SNDLVL_30dB = 'SNDLVL_30dB'
- SNDLVL_35dB = 'SNDLVL_35dB'
- SNDLVL_40dB = 'SNDLVL_40dB'
- SNDLVL_45dB = 'SNDLVL_45dB'
- SNDLVL_50dB = 'SNDLVL_50dB'
- SNDLVL_55dB = 'SNDLVL_55dB'
- SNDLVL_IDLE = 'SNDLVL_IDLE'
- SNDLVL_65dB = 'SNDLVL_65dB'
- SNDLVL_STATIC = 'SNDLVL_STATIC'
- SNDLVL_70dB = 'SNDLVL_70dB'
- SNDLVL_NORM = 'SNDLVL_NORM'
- SNDLVL_80dB = 'SNDLVL_80dB'
- SNDLVL_TALKING = 'SNDLVL_TALKING'
- SNDLVL_85dB = 'SNDLVL_85dB'
- SNDLVL_90dB = 'SNDLVL_90dB'
- SNDLVL_95dB = 'SNDLVL_95dB'
- SNDLVL_100dB = 'SNDLVL_100dB'
- SNDLVL_105dB = 'SNDLVL_105dB'
- SNDLVL_110dB = 'SNDLVL_110dB'
- SNDLVL_120dB = 'SNDLVL_120dB'
- SNDLVL_125dB = 'SNDLVL_125dB'
- SNDLVL_130dB = 'SNDLVL_130dB'
- SNDLVL_GUNFIRE = 'SNDLVL_GUNFIRE'
- SNDLVL_140dB = 'SNDLVL_140dB'
- SNDLVL_145dB = 'SNDLVL_145dB'
- SNDLVL_150dB = 'SNDLVL_150dB'
- SNDLVL_180dB = 'SNDLVL_180dB'
- class srctools.sndscript.VOLUME
- srctools.sndscript.VOL_NORM
Volumes have only one value available, which produces a full volume (
1.0).
Sound
- class srctools.sndscript.Sound(
- name: str,
- sounds: list[str],
- volume: tuple[float | VOLUME, float | VOLUME] | float | VOLUME = (srctools.sndscript.VOL_NORM, srctools.sndscript.VOL_NORM),
- channel: int | Channel = Channel.DEFAULT,
- level: tuple[float | Level, float | Level] | float | Level = (Level.SNDLVL_NORM, Level.SNDLVL_NORM),
- pitch: tuple[float | Pitch, float | Pitch] | float | Pitch = (Pitch.PITCH_NORM, Pitch.PITCH_NORM),
- stack_start: Keyvalues | None = None,
- stack_update: Keyvalues | None = None,
- stack_stop: Keyvalues | None = None,
- force_v2: bool = False,
Represents a single soundscript.
Sound Characters
- srctools.sndscript.SND_CHARS
String with some operator characters. Deprecated, use
SoundCharsinstead.
- class srctools.sndscript.SoundChars
Bases:
FlagFlags to represent sound characters which can be added to the start of sound filenames.
Despite comments in the SDK, more than 2 are permitted simultaneously. To re-assemble into a set of characters, call
str.- none = 0x0
A filename with no characters included.
- stream = 0x1
- user_vox = 0x2
Marks player voice chat data, shouldn’t ever be used.
- sentence = 0x4
Dialog from the NPC sentence system.
- dry_mix = 0x8
DSP FX is bypassed for this sound.
- doppler = 0x10
Doppler encoded stereo wav: left wav (incoming) and right wav (outgoing).
- directional = 0x20
Stereo wav has direction cone: mix left wav (front facing) with right wav (rear facing) based on sound facing direction
- dist_variant = 0x40
Distance variant encoded stereo wav (left is close, right is far)
- omni = 0x80
Non-directional - sound appears to play from everywhere, but still has distance volume falloff.
- spatial_stereo = 0x100
Spatialised stereo wav
- dir_stereo = 0x200
Directional stereo wav (like doppler)
- fast_pitch = 0x400
Forces low quality, non-interpolated pitch shift
- subtitled = 0x800
Indicates subtitles were forced on.
- hrtf_force = 0x1000
CSGO+ only. Enables HRTF for all players including the owner.
- hrtf = 0x2000
CSGO+ only. Enables HRTF for non-owners.
- hrtf_blend = 0x4000
CSGO+ only. Enables HRTF for non-owner players, fading to stereo instead if close.
- radio = 0x8000
CSGO+ only. Used for ‘radio’ sounds tha are played without spatialisation.
- music = 0x10000
CSGO+ only. Used for main menu music.
- classmethod from_fname(filename: str) tuple[SoundChars, str]
Parse sound characters out of a filename, then return both.
Utilities
- srctools.sndscript.split_float( ) tuple[float | EnumType, float | EnumType]
Handle values which can be a low, high pair of numbers or enum constants.
A single number can be provided, producing the same value for low and high.
- Parameters:
value – The value to read.
enum – This is either an Enum with values to match text constants, or a converter function returning enums or raising ValueError, KeyError or IndexError.
default – If either value or the whole string is unparsable, this default is used.