1- # ../engines/sound.py
1+ # ../engines/sound/base .py
22
3- """Provides access to the Sound interface."""
3+ """Provides access to the _BaseSound interface."""
44
55# =============================================================================
66# >> IMPORTS
77# =============================================================================
8- # Python Imports
9- # Enum
10- from enum import Enum
11-
128# Source.Python Imports
139# Core
1410from core import AutoUnload
1511# Engines
16- from engines import engines_logger
12+ from engines .sound import Attenuation
13+ from engines .sound import Channel
14+ from engines .sound import engine_sound
15+ from engines .sound import Pitch
16+ from engines .sound import SOUND_FROM_WORLD
17+ from engines .sound import SoundFlags
18+ from engines .sound import VOL_NORM
1719# Entities
1820from entities .constants import INVALID_ENTITY_INDEX
1921# Filters
2022from filters .recipients import RecipientFilter
2123# Mathlib
2224from mathlib import NULL_VECTOR
2325# Stringtables
24- from stringtables import string_tables
2526from stringtables .downloads import Downloadables
2627
2728
28- # =============================================================================
29- # >> FORWARD IMPORTS
30- # =============================================================================
31- # Source.Python Imports
32- # Engines
33- from _engines ._sound import Channel
34- from _engines ._sound import VOL_NORM
35- from _engines ._sound import ATTN_NONE
36- from _engines ._sound import ATTN_NORM
37- from _engines ._sound import ATTN_IDLE
38- from _engines ._sound import ATTN_STATIC
39- from _engines ._sound import ATTN_RICOCHET
40- from _engines ._sound import ATTN_GUNFIRE
41- from _engines ._sound import MAX_ATTENUATION
42- from _engines ._sound import SoundFlags
43- from _engines ._sound import Pitch
44- from _engines ._sound import SOUND_FROM_LOCAL_PLAYER
45- from _engines ._sound import SOUND_FROM_WORLD
46- from _engines ._sound import engine_sound
47-
48-
49- # =============================================================================
50- # >> ALL DECLARATION
51- # =============================================================================
52- __all__ = ('Attenuation' ,
53- 'Channel' ,
54- 'Pitch' ,
55- 'SOUND_FROM_LOCAL_PLAYER' ,
56- 'SOUND_FROM_WORLD' ,
57- 'Sound' ,
58- 'SoundFlags' ,
59- 'VOL_NORM' ,
60- 'engine_sound' ,
61- )
62-
63-
64- # =============================================================================
65- # >> GLOBAL VARIABLES
66- # =============================================================================
67- # Get the sp.engines.sound logger
68- engines_sound_logger = engines_logger .sound
69-
70-
71- # =============================================================================
72- # >> ENUMERATORS
73- # =============================================================================
74- class Attenuation (float , Enum ):
75- """Attenuation values wrapper enumerator."""
76-
77- NONE = ATTN_NONE
78- NORMAL = ATTN_NORM
79- IDLE = ATTN_IDLE
80- STATIC = ATTN_STATIC
81- RICOCHET = ATTN_RICOCHET
82- GUNFIRE = ATTN_GUNFIRE
83- MAXIMUM = MAX_ATTENUATION
84-
85-
8629# =============================================================================
8730# >> CLASSES
8831# =============================================================================
89- class Sound (AutoUnload ):
32+ class _BaseSound (AutoUnload ):
9033 """Class used to interact with a specific sound file."""
9134
9235 # Set the base _downloads attribute to know whether
@@ -138,11 +81,7 @@ def play(self, *recipients):
13881 self .precache ()
13982
14083 # Play the sound
141- engine_sound .emit_sound (
142- recipients , self .index , self .channel , self .sample ,
143- self .volume , self .attenuation , self .flags , self .pitch ,
144- self .origin , self .direction , self .origins ,
145- self .update_positions , self .sound_time , self .speaker_entity )
84+ self ._play (recipients )
14685
14786 def stop (self , index = None , channel = None ):
14887 """Stop a sound from being played."""
@@ -159,16 +98,24 @@ def stop(self, index=None, channel=None):
15998 channel = self .channel
16099
161100 # Stop the sound
162- engine_sound .stop_sound (index , channel , self .sample )
101+ self ._stop (index , channel )
102+
103+ def _play (self , recipients ):
104+ """Play the sound (internal)."""
105+ raise NotImplementedError
106+
107+ def _stop (self , index , channel ):
108+ """Stop a sound from being played (internal)."""
109+ raise NotImplementedError
163110
164111 def precache (self ):
165112 """Precache the sample."""
166- engine_sound . precache_sound ( self . sample )
113+ raise NotImplementedError
167114
168115 @property
169116 def is_precached (self ):
170117 """Return whether or not the sample is precached."""
171- return self . sample in string_tables . soundprecache
118+ raise NotImplementedError
172119
173120 @property
174121 def sample (self ):
0 commit comments