I think sound is as good as I can get it.
This commit is contained in:
@@ -48,8 +48,8 @@ def initialize_gui(gameTitle):
|
||||
if not pygame.mixer.get_init():
|
||||
pygame.mixer.pre_init(44100, -16, 2, 4096, allowedchanges=0)
|
||||
pygame.mixer.init()
|
||||
pygame.mixer.set_num_channels(64)
|
||||
pygame.mixer.set_reserved(16) # Reserve channels 0-15 for priority sounds (cutscenes, obj_play)
|
||||
pygame.mixer.set_num_channels(48)
|
||||
pygame.mixer.set_reserved(1) # Reserve channel 0 for cutscenes only
|
||||
|
||||
# Enable key repeat for volume controls
|
||||
pygame.key.set_repeat(500, 100)
|
||||
|
12
sound.py
12
sound.py
@@ -93,8 +93,8 @@ class Sound:
|
||||
if not pygame.mixer.get_init():
|
||||
pygame.mixer.pre_init(44100, -16, 2, 4096, allowedchanges=0)
|
||||
pygame.mixer.init()
|
||||
pygame.mixer.set_num_channels(64)
|
||||
pygame.mixer.set_reserved(16) # Reserve channels 0-15 for priority sounds (cutscenes, obj_play)
|
||||
pygame.mixer.set_num_channels(48)
|
||||
pygame.mixer.set_reserved(1) # Reserve channel 0 for cutscenes only
|
||||
|
||||
self.load_sounds()
|
||||
|
||||
@@ -537,7 +537,9 @@ def obj_update(channel, playerPos, objPos):
|
||||
def obj_stop(channel):
|
||||
"""Stop a sound channel."""
|
||||
if channel:
|
||||
try: channel.stop()
|
||||
try:
|
||||
channel.stop()
|
||||
pygame.event.pump() # Force pygame to update channel state immediately
|
||||
except: pass
|
||||
return None
|
||||
|
||||
@@ -578,8 +580,8 @@ def play_priority_sound(sound_or_name, volume=1.0, loop=False, playerPos=None, o
|
||||
return None
|
||||
|
||||
# Extremely concise lambda definitions for legacy functions
|
||||
obj_play = lambda sounds, soundName, playerPos, objPos, loop=True: play_priority_sound(
|
||||
soundName, 1.0, loop, playerPos, objPos, None, sounds)
|
||||
obj_play = lambda sounds, soundName, playerPos, objPos, loop=True: play_sound(
|
||||
soundName, 1.0, loop, playerPos, objPos, None, False, False, False, False, sounds)
|
||||
|
||||
play_ambiance = lambda sounds, soundNames, probability, randomLocation=False: play_sound(
|
||||
random.choice(soundNames) if random.randint(1, 100) <= probability and not any(
|
||||
|
4
utils.py
4
utils.py
@@ -151,8 +151,8 @@ class Game:
|
||||
# Set up audio system
|
||||
pygame.mixer.pre_init(44100, -16, 2, 1024, allowedchanges=0)
|
||||
pygame.mixer.init()
|
||||
pygame.mixer.set_num_channels(64)
|
||||
pygame.mixer.set_reserved(16) # Reserve channels 0-15 for priority sounds (cutscenes, obj_play)
|
||||
pygame.mixer.set_num_channels(48)
|
||||
pygame.mixer.set_reserved(1) # Reserve channel 0 for cutscenes only
|
||||
|
||||
# Enable key repeat for volume controls
|
||||
pygame.key.set_repeat(500, 100)
|
||||
|
Reference in New Issue
Block a user