Skip to content

Commit

Permalink
Merge 128cd89 into 4033c75
Browse files Browse the repository at this point in the history
  • Loading branch information
chpurdy committed Mar 11, 2020
2 parents 4033c75 + 128cd89 commit cf610d5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
54 changes: 28 additions & 26 deletions arcade/sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
"""
Expand All @@ -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):
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/*',
Expand Down

0 comments on commit cf610d5

Please sign in to comment.