mirror of
https://github.com/jtauber/applepy.git
synced 2024-11-22 19:30:54 +00:00
moved speaker buffer playing into the Speaker class
This commit is contained in:
parent
96787a2667
commit
b9033a459a
11
applepy.py
11
applepy.py
@ -261,6 +261,12 @@ class Speaker:
|
|||||||
self.last_toggle = None
|
self.last_toggle = None
|
||||||
self.buffer = []
|
self.buffer = []
|
||||||
self.polarity = False
|
self.polarity = False
|
||||||
|
|
||||||
|
def play(self):
|
||||||
|
sample_array = numpy.array(self.buffer)
|
||||||
|
sound = pygame.sndarray.make_sound(sample_array)
|
||||||
|
sound.play()
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
|
||||||
class ROM:
|
class ROM:
|
||||||
@ -371,10 +377,7 @@ class Memory:
|
|||||||
|
|
||||||
def update(self, cycle):
|
def update(self, cycle):
|
||||||
if self.speaker.buffer and (cycle - self.speaker.last_toggle) > self.speaker.CHECK_INTERVAL:
|
if self.speaker.buffer and (cycle - self.speaker.last_toggle) > self.speaker.CHECK_INTERVAL:
|
||||||
sample_array = numpy.array(self.speaker.buffer)
|
self.speaker.play()
|
||||||
sound = pygame.sndarray.make_sound(sample_array)
|
|
||||||
sound.play()
|
|
||||||
self.speaker.reset()
|
|
||||||
|
|
||||||
|
|
||||||
class Disassemble:
|
class Disassemble:
|
||||||
|
Loading…
Reference in New Issue
Block a user