Skip to content

Commit 102b7dd

Browse files
committed
Deinit the playback class in case another song is played afterwards.
Fixes #6
1 parent 89b09db commit 102b7dd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

adafruit_rtttl.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The MIT License (MIT)
22
#
3-
# Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
3+
# Copyright (c) 2017, 2018 Scott Shawcroft for Adafruit Industries
44
#
55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal
@@ -130,7 +130,7 @@ def _play_to_pin(tune, base_tone, min_freq, duration, octave, tempo):
130130
else:
131131
base_tone.frequency = int(16000 * (PIANO[piano_note] / min_freq))
132132
base_tone.play(loop=True)
133-
print(piano_note, note_duration)
133+
134134
time.sleep(4 / note_duration * 60 / tempo)
135135
if pwm:
136136
base_tone.duty_cycle = 0
@@ -162,8 +162,6 @@ def play(pin, rtttl, octave=None, duration=None, tempo=None):
162162
if not tempo:
163163
tempo = 63
164164

165-
print("tempo", tempo, "octave", octave, "duration", duration)
166-
167165
base_tone = None
168166
min_freq = 440
169167
if AUDIOIO_AVAILABLE:
@@ -179,3 +177,5 @@ def play(pin, rtttl, octave=None, duration=None, tempo=None):
179177
base_tone = pulseio.PWMOut(pin, duty_cycle=0, variable_frequency=True)
180178

181179
_play_to_pin(tune, base_tone, min_freq, duration, octave, tempo)
180+
181+
base_tone.deinit()

0 commit comments

Comments
 (0)