Skip to content

Commit cb6c5ea

Browse files
committed
Use new module constants in sampler example
1 parent dcce535 commit cb6c5ea

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

examples/sampler.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,28 +78,27 @@ def on_key_release(self, event):
7878
sample = self.samples[ch]
7979
# TODO: fade out (both recording and playback)?
8080
assert sample.action is not None
81-
# TODO: create a public API for that?
82-
if sample.action.type == rtmixer._lib.RECORD_RINGBUFFER:
81+
if sample.action.type == rtmixer.RECORD_RINGBUFFER:
8382
# TODO: check for errors/xruns? check for rinbuffer overflow?
8483
# Stop recording
8584
sample.action = self.stream.cancel(sample.action)
8685
# A CANCEL action is returned which is checked by poll_ringbuffer()
87-
elif sample.action.type == rtmixer._lib.PLAY_BUFFER:
86+
elif sample.action.type == rtmixer.PLAY_BUFFER:
8887
# TODO: check for errors/xruns?
8988
# Stop playback (if still running)
9089
if sample.action in self.stream.actions:
9190
sample.action = self.stream.cancel(sample.action)
9291
# TODO: do something with sample.action?
93-
elif sample.action.type == rtmixer._lib.CANCEL:
92+
elif sample.action.type == rtmixer.CANCEL:
9493
# We might end up here if on_key_press() exits early
9594
pass
9695
else:
9796
assert False, (event.char, sample.action)
9897

9998
def poll_ringbuffer(self, sample):
10099
assert sample.action is not None
101-
assert sample.action.type in (rtmixer._lib.RECORD_RINGBUFFER,
102-
rtmixer._lib.CANCEL)
100+
assert sample.action.type in (rtmixer.RECORD_RINGBUFFER,
101+
rtmixer.CANCEL)
103102
# TODO: check for errors? is everything still working OK?
104103
# TODO: check for xruns?
105104
chunk = sample.ringbuffer.read()

0 commit comments

Comments
 (0)