engines.sound module

Provides access to the Sound and StreamSound interfaces.

class engines.sound.Attenuation[source]

Bases: float, enum.Enum

Attenuation values wrapper enumerator.

_member_type_

alias of float

_generate_next_value_(name, start, count, last_values)
GUNFIRE = <Attenuation.GUNFIRE: 0.27000001072883606>
IDLE = <Attenuation.IDLE: 2.0>
MAXIMUM = <Attenuation.MAXIMUM: 3.9800000190734863>
NONE = <Attenuation.NONE: 0.0>
NORMAL = <Attenuation.NORMAL: 0.800000011920929>
RICOCHET = <Attenuation.RICOCHET: 1.5>
STATIC = <Attenuation.STATIC: 1.25>
_member_map_ = OrderedDict([('NONE', <Attenuation.NONE: 0.0>), ('NORMAL', <Attenuation.NORMAL: 0.800000011920929>), ('IDLE', <Attenuation.IDLE: 2.0>), ('STATIC', <Attenuation.STATIC: 1.25>), ('RICOCHET', <Attenuation.RICOCHET: 1.5>), ('GUNFIRE', <Attenuation.GUNFIRE: 0.27000001072883606>), ('MAXIMUM', <Attenuation.MAXIMUM: 3.9800000190734863>)])
_member_names_ = ['NONE', 'NORMAL', 'IDLE', 'STATIC', 'RICOCHET', 'GUNFIRE', 'MAXIMUM']
_value2member_map_ = {0.0: <Attenuation.NONE: 0.0>, 0.800000011920929: <Attenuation.NORMAL: 0.800000011920929>, 2.0: <Attenuation.IDLE: 2.0>, 1.25: <Attenuation.STATIC: 1.25>, 1.5: <Attenuation.RICOCHET: 1.5>, 0.27000001072883606: <Attenuation.GUNFIRE: 0.27000001072883606>, 3.9800000190734863: <Attenuation.MAXIMUM: 3.9800000190734863>}
class engines.sound.Channel

Bases: Boost.Python.enum

AUTO = _engines._sound.Channel.AUTO
BODY = _engines._sound.Channel.BODY
ITEM = _engines._sound.Channel.ITEM
REPLACE = _engines._sound.Channel.REPLACE
STATIC = _engines._sound.Channel.STATIC
STREAM = _engines._sound.Channel.STREAM
USER_BASE = _engines._sound.Channel.USER_BASE
VOICE = _engines._sound.Channel.VOICE
VOICE_BASE = _engines._sound.Channel.VOICE_BASE
WEAPON = _engines._sound.Channel.WEAPON
names = {'REPLACE': _engines._sound.Channel.REPLACE, 'AUTO': _engines._sound.Channel.AUTO, 'WEAPON': _engines._sound.Channel.WEAPON, 'VOICE': _engines._sound.Channel.VOICE, 'ITEM': _engines._sound.Channel.ITEM, 'BODY': _engines._sound.Channel.BODY, 'STREAM': _engines._sound.Channel.STREAM, 'STATIC': _engines._sound.Channel.STATIC, 'VOICE_BASE': _engines._sound.Channel.VOICE_BASE, 'USER_BASE': _engines._sound.Channel.USER_BASE}
values = {-1: _engines._sound.Channel.REPLACE, 0: _engines._sound.Channel.AUTO, 1: _engines._sound.Channel.WEAPON, 2: _engines._sound.Channel.VOICE, 3: _engines._sound.Channel.ITEM, 4: _engines._sound.Channel.BODY, 5: _engines._sound.Channel.STREAM, 6: _engines._sound.Channel.STATIC, 7: _engines._sound.Channel.VOICE_BASE, 135: _engines._sound.Channel.USER_BASE}
class engines.sound.Pitch

Bases: Boost.Python.enum

HIGH = _engines._sound.Pitch.HIGH
LOW = _engines._sound.Pitch.LOW
NORMAL = _engines._sound.Pitch.NORMAL
names = {'NORMAL': _engines._sound.Pitch.NORMAL, 'LOW': _engines._sound.Pitch.LOW, 'HIGH': _engines._sound.Pitch.HIGH}
values = {100: _engines._sound.Pitch.NORMAL, 95: _engines._sound.Pitch.LOW, 120: _engines._sound.Pitch.HIGH}
class engines.sound.Sound(sample, index=0, volume=1.0, attenuation=<Attenuation.NONE: 0.0>, channel=_engines._sound.Channel.AUTO, flags=_engines._sound.SoundFlags.NO_FLAGS, pitch=_engines._sound.Pitch.NORMAL, origin=Vector(0.0, 0.0, 0.0), direction=Vector(0.0, 0.0, 0.0), origins=(), update_positions=True, sound_time=0.0, speaker_entity=-1, download=False)[source]

Bases: engines.sound._BaseSound

Class used to interact with precached sounds.

Note

On some engines (e.g. CS:GO) server is unable to precache the sound, thus the sound won’t be played. StreamSound is recommended in that case. However, sounds located in sound/music/ directory are always streamed on those engines, and this class will be able to play them.

_play(recipients)[source]

Play the sound (internal).

_stop(index, channel)[source]

Stop a sound from being played (internal).

precache()[source]

Precache the sample.

is_precached

Return whether or not the sample is precached.

Return type:bool
class engines.sound.SoundFlags

Bases: Boost.Python.enum

CHANGE_PITCH = _engines._sound.SoundFlags.CHANGE_PITCH
CHANGE_VOL = _engines._sound.SoundFlags.CHANGE_VOL
DELAY = _engines._sound.SoundFlags.DELAY
IGNORE_NAME = _engines._sound.SoundFlags.IGNORE_NAME
IGNORE_PHONEMES = _engines._sound.SoundFlags.IGNORE_PHONEMES
NO_FLAGS = _engines._sound.SoundFlags.NO_FLAGS
SHOULD_PAUSE = _engines._sound.SoundFlags.SHOULD_PAUSE
SPAWNING = _engines._sound.SoundFlags.SPAWNING
SPEAKER = _engines._sound.SoundFlags.SPEAKER
STOP = _engines._sound.SoundFlags.STOP
STOP_LOOPING = _engines._sound.SoundFlags.STOP_LOOPING
names = {'NO_FLAGS': _engines._sound.SoundFlags.NO_FLAGS, 'CHANGE_VOL': _engines._sound.SoundFlags.CHANGE_VOL, 'CHANGE_PITCH': _engines._sound.SoundFlags.CHANGE_PITCH, 'STOP': _engines._sound.SoundFlags.STOP, 'SPAWNING': _engines._sound.SoundFlags.SPAWNING, 'DELAY': _engines._sound.SoundFlags.DELAY, 'STOP_LOOPING': _engines._sound.SoundFlags.STOP_LOOPING, 'SPEAKER': _engines._sound.SoundFlags.SPEAKER, 'SHOULD_PAUSE': _engines._sound.SoundFlags.SHOULD_PAUSE, 'IGNORE_PHONEMES': _engines._sound.SoundFlags.IGNORE_PHONEMES, 'IGNORE_NAME': _engines._sound.SoundFlags.IGNORE_NAME}
values = {0: _engines._sound.SoundFlags.NO_FLAGS, 1: _engines._sound.SoundFlags.CHANGE_VOL, 2: _engines._sound.SoundFlags.CHANGE_PITCH, 4: _engines._sound.SoundFlags.STOP, 8: _engines._sound.SoundFlags.SPAWNING, 16: _engines._sound.SoundFlags.DELAY, 32: _engines._sound.SoundFlags.STOP_LOOPING, 64: _engines._sound.SoundFlags.SPEAKER, 128: _engines._sound.SoundFlags.SHOULD_PAUSE, 256: _engines._sound.SoundFlags.IGNORE_PHONEMES, 512: _engines._sound.SoundFlags.IGNORE_NAME}
class engines.sound.StreamSound(sample, index=0, volume=1.0, attenuation=<Attenuation.NONE: 0.0>, channel=_engines._sound.Channel.AUTO, flags=_engines._sound.SoundFlags.NO_FLAGS, pitch=_engines._sound.Pitch.NORMAL, origin=Vector(0.0, 0.0, 0.0), direction=Vector(0.0, 0.0, 0.0), origins=(), update_positions=True, sound_time=0.0, speaker_entity=-1, download=False)[source]

Bases: engines.sound._BaseSound

Class used to interact with streamed sounds.

Note

This class is a recommended choice on some engines (e.g. CS:GO), however, it’s unable to play *.wav-files.

Note

On some engines (e.g. CS:GO) files that are located in sound/music/ directory are already streamed, so simple Sound class can be used instead.

_play(recipients)[source]

Play the sound (internal).

_stop(index, channel)[source]

Stop a sound from being played (internal).

precache()[source]

Precache the sample.

_stream_sample

Return the streamed sample path of the Sound instance.

is_precached

Return whether or not the sample is precached.

Return type:bool