closed cpx PR for melody, when i first started it i though i need to edit frozen but can just do this
from adafruit_circuitplayground.express import cpx
import time
def play_melody(frequencies, durations, speed=10):
for idx, frequency in enumerate(frequencies):
if frequency != 0:
cpx.start_tone(frequency)
time.sleep(durations[idx]/speed)
cpx._sample.stop()
cpx.stop_tone()
notes = [293, 440, 440, 0, 330, 494, 349, 523, 523, 0, 330, 494,
293, 440, 440, 0, 330, 494, 349, 523, 523, 0, 330, 494,
293, 349, 587, 293, 349, 587,
659, 698, 659, 698, 659, 523, 440,
440, 293, 349, 392, 440, 440, 293, 349, 392, 330,
293, 349, 587, 293, 349, 587,
659, 698, 659, 698, 659, 523, 440,
440, 293, 349, 392, 440,
440, 293]
beats = [2, 2, 2, 1, 1, 4, 2, 2, 2, 1, 1, 4,
2, 2, 2, 1, 1, 4, 2, 2, 2, 1, 1, 4,
1, 1, 4, 1, 1, 4,
3, 1, 1, 1, 1, 1, 4, 2, 2, 1, 1, 6,
2, 2, 1, 1, 6,
1, 1, 4, 1, 1, 4,
3, 1, 1, 1, 1, 1, 4, 2, 2, 1, 1, 6,
2, 6]
while True:
play_melody(notes, beats)
time.sleep(2)
cpx PR #57i feel that is needed, but i removed melody from it. no way to control volume in tones without something changed