HTML

musicexample.py

Nov 18th, 2016
144
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.69 KB | None | 0 0
  1. """
  2. Plays a list of songs. Input a number to choose.
  3. 1. Michigan fight song
  4. 2. Intro to Sweet Child of Mine
  5. 3. Mario Theme Song
  6.  
  7. Uses notes.py, an add-on library that simplifies buzzer song creation.
  8. Thanks to Justas Sadvecius for the library!
  9.  
  10. The Finch is a robot for computer science education. Its design is the result
  11. of a four year study at Carnegie Mellon's CREATE lab.
  12.  
  13. http://www.finchrobot.com
  14. """
  15.  
  16. from finch import Finch
  17. from time import sleep
  18. import notes
  19.  
  20. #Main function for the music player example program"""
  21.  
  22. #Initialize the finch    
  23. finch = Finch()
  24.  
  25. songList = ['E5  C D E C D E F  D E F D E F G  A  GE F C D E G E D C ',
  26.                 'D D5 A4 G G5 A4 F5# A4 D D5 A4 G G5 A4 F5# A4 '
  27.                 'E D5 A4 G G5 A4 F5# A4 E D5 A4 G G5 A4 F5# A4 '
  28.                 'G D5 A4 G G5 A4 F5# A4 G D5 A4 G G5 A4 F5# A4 '
  29.                 'D D5 A4 G G5 A4 F5# A4 D D5 A4 G G5 A4 F5# A4 ',
  30.                 'E5 E  E   C E  G    G4   C5  G4   E   A BBb A  G  '
  31.                 'E5  G  A F G  E  C D B4  C5  G4   E   A BBb A  G  '
  32.                 'E5  G  A F G  E  C D B4 -  G5 Gb F D#  E G4# A C5 A4 C5 D '
  33.                 'G5 Gb F D#  E C6 C6 C6   '
  34.                 'G5 Gb F D#  E G4# A C5 A4 C5 D  Eb  D  C    '
  35.                 ' G5 Gb F D#  E G4# A C5 A4 C5 D G5 Gb F D#  E C6 C C  ']
  36. timeList = [0.18,0.1,0.1]
  37.  
  38. song = 1
  39. while song > 0 and song < 4:
  40.     #get which song
  41.     song = int(input("Enter 1 for the Michigan fight song, 2 for Sweet Child of Mine,"
  42.                     "3 for the Mario theme song; any other number to exit."))
  43.  
  44.     if song >=1 and song <= 3:
  45.         notes.sing(finch, songList[song -1],timeList[song-1])
  46.     else:
  47.         print('Exiting...')
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment