clock
[hoa] / hair_on_arm / Samples.py
1 from array import array
2
3 from pygame.mixer import Sound, get_init
4
5 class Samples(Sound):
6
7 def __init__(self):
8 self.set_amplitude()
9 Sound.__init__(self, self.build())
10
11 def set_amplitude(self):
12 self.amplitude = (1 << (self.get_sample_width() * 8 - 1)) - 1
13
14 def get_sample_width(self):
15 return abs(get_init()[1] / 8)
16
17 def build(self):
18 pass
19
20 def get_empty_array(self, length):
21 return array(self.get_array_typecode(), [0] * length)
22
23 def get_array_typecode(self):
24 return [None, "b", "h"][self.get_sample_width()]