# use integers to control volume which avoids float rounding error issues
MAX = 100
MIN = 0
+ volume = 50
volume_step = 5
- def __init__(self, volume=1.0, channel_id=0, debug=False):
+
+ def __init__(self, volume=50, channel_id=0, debug=False):
""" Constructor.
volume: an SDL/PyGame floating-point with range 0.00 to 1.00. It is stored internally as an
integer with range 0 to 100 to avoid rounding errors when stepping the volume.
self.channel == None indicates this is the Music channel.
"""
- self.volume = int(volume*100)
self.channel_id = 0
self.debug = debug
self.paused = False
self.channel_id = channel_id
self.channel = pygame.mixer.Channel(self.channel_id)
+ self.set_volume(int(volume))
+
def set_volume(self, new_level):
""" Ensure the new level is within legal range and alter the mixer level """
if new_level >= Channel.MIN and new_level <= Channel.MAX: