Skip to content

Instantly share code, notes, and snippets.

@cclauss
Last active December 14, 2015 10:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cclauss/5073235 to your computer and use it in GitHub Desktop.
Save cclauss/5073235 to your computer and use it in GitHub Desktop.
Play a blues melody on Pythonista on the iPad (iOS)
# Play a blues melody on Pythonista on the iPad (iOS)
import sound
import time
def playNotes(inNotes, inWithEmphisis=False):
for note in inNotes:
sound.play_effect('Piano_' + note)
if (inWithEmphisis):
time.sleep(0.25)
sound.play_effect('Piano_' + note)
time.sleep(0.25)
else:
time.sleep(0.5)
cnotes = ['C3', 'E3', 'G3', 'A3', 'C4', 'A3', 'G3', 'E3']
fnotes = ['F3', 'A3', 'C4', 'D4', 'F4', 'D4', 'C4', 'A3']
gnotes = ['G3', 'B3', 'D4', 'E4', 'F3', 'A3', 'C4', 'D4']
xnotes = ['C3', 'E3', 'F3', 'F3#', 'G3', 'A3#', 'G3', 'G3']
for i in range(2):
playNotes(cnotes)
cnotes[4] = 'A3#'
playNotes(cnotes)
playNotes(fnotes)
cnotes[4] = 'C4'
playNotes(cnotes)
playNotes(gnotes)
playNotes(cnotes, True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment