diff --git a/arcade/sound.py b/arcade/sound.py index 457a1aff03..5a6ddbfc70 100644 --- a/arcade/sound.py +++ b/arcade/sound.py @@ -24,6 +24,8 @@ def __init__(self, file_name: str, streaming: bool = False): self.file_name: str = "" self.wav_file:Union[soloud.WavStream, soloud.Wav] + self.voice_handle = None # needed for volume control + if not _audiolib: return @@ -52,11 +54,11 @@ def play(self, volume=1.0, pan=0.0): if not _audiolib: return - _audiolib.play(self.wav_file, - aVolume=volume, - aPan=pan, - aPaused=0, - aBus=0) + self.voice_handle = _audiolib.play(self.wav_file, + aVolume=volume, + aPan=pan, + aPaused=0, + aBus=0) def stop(self): """ @@ -75,27 +77,27 @@ def get_length(self): # --- These functions should work, but instead just return zero or otherwise # don't appear functional. - # def get_volume(self): - # """ Get the current volume """ - # if not _audiolib: - # return 0 - # return _audiolib.get_volume(self.wav_file.objhandle) - # - # def set_volume(self, volume): - # """ Set the current volume. Doesn't seem to work. """ - # if not _audiolib: - # return - # self.wav_file.set_volume(volume) - # - # def set_left_right_volume(self, left_volume, right_volume): - # """ Set absolute left/right volume """ - # if not _audiolib: - # return - # _audiolib.set_pan_absolute(self.wav_file.objhandle, left_volume, right_volume) - # - # def get_stream_position(self): - # """ This always returns zero for some unknown reason. """ - # return _audiolib.get_stream_position(self.wav_file.objhandle) + def get_volume(self): + """ Get the current volume """ + if not _audiolib: + return 0 + return _audiolib.get_volume(self.voice_handle) + + def set_volume(self, volume): + """ Set the current volume. """ + if not _audiolib: + return + _audiolib.set_volume(self.voice_handle, volume) + + def set_left_right_volume(self, left_volume, right_volume): + """ Set absolute left/right volume """ + if not _audiolib: + return + _audiolib.set_pan_absolute(self.voice_handle, left_volume, right_volume) + + def get_stream_position(self): + """ This always returns zero for some unknown reason. """ + return _audiolib.get_stream_position(self.voice_handle) def load_sound(file_name: str): diff --git a/setup.py b/setup.py index 600f6de124..9e6bffc4c7 100644 --- a/setup.py +++ b/setup.py @@ -72,7 +72,6 @@ def execfile(filepath, globals=None, locals=None): "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development :: Libraries :: Python Modules", ], - package_data={'arcade': ['resources/gui_themes/Fantasy/Buttons/*', 'resources/gui_themes/Fantasy/DialogueBox/*', 'resources/gui_themes/Fantasy/Menu/*',