コード例 #1
0
ファイル: musicexample.py プロジェクト: kurniawano/libdw
#Main function for the music player example program"""

#Initialize the finch    
finch = Finch()

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 ',
                'D D5 A4 G G5 A4 F5# A4 D D5 A4 G G5 A4 F5# A4 '
                'E D5 A4 G G5 A4 F5# A4 E D5 A4 G G5 A4 F5# A4 '
                'G D5 A4 G G5 A4 F5# A4 G D5 A4 G G5 A4 F5# A4 '
                'D D5 A4 G G5 A4 F5# A4 D D5 A4 G G5 A4 F5# A4 ',
                'E5 E  E   C E  G    G4   C5  G4   E   A BBb A  G  '
                'E5  G  A F G  E  C D B4  C5  G4   E   A BBb A  G  '
                'E5  G  A F G  E  C D B4 -  G5 Gb F D#  E G4# A C5 A4 C5 D '
                'G5 Gb F D#  E C6 C6 C6   '
                'G5 Gb F D#  E G4# A C5 A4 C5 D  Eb  D  C    '
                ' G5 Gb F D#  E G4# A C5 A4 C5 D G5 Gb F D#  E C6 C C  ']
timeList = [0.18,0.1,0.1]

song = 1
while song > 0 and song < 4:
    #get which song
    song = int(input("Enter 1 for the Michigan fight song, 2 for Sweet Child of Mine,"
                    "3 for the Mario theme song; any other number to exit."))

    if song >=1 and song <= 3:
        notes.sing(finch, songList[song -1],timeList[song-1])
    else:
        print('Exiting...')


コード例 #2
0
        ' G5 Gb F D#  E G4# A C5 A4 C5 D G5 Gb F D#  E C6 C C--',
        '------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------             -------------------------------------------------------------------------------------------------       ------------------------------------------------------       ------------------                 ---------------------- ------------------------------ -------------------------- ------------------ ------------------------- C10'
    ]

    song = 1
    while song > 0 and song < 6:
        #get which song
        song = int(
            input(
                "Enter 1 for the Michigan fight song, 2 for Sweet Child of Mine,"
                "3 for the Mario theme song, 4 for an alarm; any other number to exit."
            ))

        if song >= 1 and song <= 4:
            finch.led(0, 255, 255)
            notes.sing(finch, songList[song - 1], timeList[song - 1])
            finch.led(255, 255, 255)
        else:
            print('Exiting...')
else:
    print("alarm chosen")
    song = input(
        "type 1 for the normal alarm and type 2 for a harsh alarm (not recommended), and 3 for mario theme song"
    )
    snooze_time = input("type the snooze time (mins and without a label")
    song = int(song)
    snooze_time = int(snooze_time)
    songList = [
        'C  A  ', '-   -', 'E5  G  A F G  E  C D B4  C5  G4   E   A BBb A  G  '
        'E5  G  A F G  E  C D B4 -  G5 Gb F D#  E G4# A C5 A4 C5 D '
        'G5 Gb F D#  E C6 C6 C6   '
コード例 #3
0
ファイル: black_and_gold.py プロジェクト: plwinkler/finch
# Main function for the music player example program.

# Initialize the finch.
finch = Finch()

black_and_gold = (
    'C6       A5   G   F  GA           '
    'C6       A5   G  FBb           '
    'A  GF#   G   A   E   G --F       '
    'F  F#G   G  AbA   A  BbC6DCDCDCDCC--'  # Behold my awesome trill!
    'C   C       A5   G   F  GA           '
    'C6  CB5 C6 C  CB5 C6 D         --'
    'C5   F   F  GA   A  GF   F  DC  -'
    'C C# D F   D F   E   F C6CC C F ')

song = 1
while song == 1:
    # Get value telling us if we should play song or quit.
    song = int(
        input(
            'Enter 1 to play The College of Wooster fight song, "Black and Gold",'
            '\nor any other character to exit: '))

    if song == 1:
        notes.sing(finch, black_and_gold, 0.08)
    else:
        print('Exiting...')

finch.close()