def play(self):
     snaps.play_note(self.__note)
     time.sleep(self.__duration)
# EG10-17 Play notes
import time
import snaps

for note in range(0, 13):
    snaps.play_note(note)
    time.sleep(.5)
# EG10-18 Twinkle Twinkle
import time
import snaps

snaps.play_note(0)
time.sleep(0.4)
snaps.play_note(0)
time.sleep(0.4)
snaps.play_note(7)
time.sleep(0.4)
snaps.play_note(7)
time.sleep(0.4)
snaps.play_note(9)
time.sleep(0.4)
snaps.play_note(9)
time.sleep(0.4)
snaps.play_note(7)
time.sleep(0.8)
snaps.play_note(5)
time.sleep(0.4)
snaps.play_note(5)
time.sleep(0.4)
snaps.play_note(4)
time.sleep(0.4)
snaps.play_note(4)
time.sleep(0.4)
snaps.play_note(2)
time.sleep(0.4)
snaps.play_note(2)
time.sleep(0.4)
snaps.play_note(0)
Exemple #4
0
# EG10-19 Twinkle Twinkle Tuples

import time
import snaps

tune = [(0, 0.4), (0, 0.4), (7, 0.4), (7, 0.4),
        (9, 0.4), (9, 0.4), (7, 0.8), (5, 0.4),
        (5, 0.4), (4, 0.4), (4, 0.4), (2, 0.4),
        (2, 0.4), (0, 0.8)]

for note in tune:
    snaps.play_note(note[0])
    time.sleep(note[1])