mirror of
https://github.com/jtauber/applepy.git
synced 2025-02-05 05:33:31 +00:00
adjusted speaker sample length to allow for leading edge
This commit is contained in:
parent
fbd213e240
commit
a2fcbd5238
@ -261,7 +261,7 @@ class Display:
|
|||||||
|
|
||||||
class Speaker:
|
class Speaker:
|
||||||
|
|
||||||
CPU_CYCLES_PER_SAMPLE = 70
|
CPU_CYCLES_PER_SAMPLE = 60
|
||||||
CHECK_INTERVAL = 1000
|
CHECK_INTERVAL = 1000
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -273,7 +273,7 @@ class Speaker:
|
|||||||
if self.last_toggle is not None:
|
if self.last_toggle is not None:
|
||||||
l = (cycle - self.last_toggle) / Speaker.CPU_CYCLES_PER_SAMPLE
|
l = (cycle - self.last_toggle) / Speaker.CPU_CYCLES_PER_SAMPLE
|
||||||
self.buffer.extend([0, 0.8] if self.polarity else [0, -0.8])
|
self.buffer.extend([0, 0.8] if self.polarity else [0, -0.8])
|
||||||
self.buffer.extend(l * [0.5] if self.polarity else [-0.5])
|
self.buffer.extend((l - 2) * [0.5] if self.polarity else [-0.5])
|
||||||
self.polarity = not self.polarity
|
self.polarity = not self.polarity
|
||||||
self.last_toggle = cycle
|
self.last_toggle = cycle
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user