Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deinit the playback class in case another song is played afterwards. #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions adafruit_rtttl.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The MIT License (MIT)
#
# Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
# Copyright (c) 2017, 2018 Scott Shawcroft for Adafruit Industries
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -130,7 +130,7 @@ def _play_to_pin(tune, base_tone, min_freq, duration, octave, tempo):
else:
base_tone.frequency = int(16000 * (PIANO[piano_note] / min_freq))
base_tone.play(loop=True)
print(piano_note, note_duration)

time.sleep(4 / note_duration * 60 / tempo)
if pwm:
base_tone.duty_cycle = 0
Expand Down Expand Up @@ -162,8 +162,6 @@ def play(pin, rtttl, octave=None, duration=None, tempo=None):
if not tempo:
tempo = 63

print("tempo", tempo, "octave", octave, "duration", duration)

base_tone = None
min_freq = 440
if AUDIOIO_AVAILABLE:
Expand All @@ -179,3 +177,5 @@ def play(pin, rtttl, octave=None, duration=None, tempo=None):
base_tone = pulseio.PWMOut(pin, duty_cycle=0, variable_frequency=True)

_play_to_pin(tune, base_tone, min_freq, duration, octave, tempo)

base_tone.deinit()