Ejemplo n.º 1
0
def linux_player():
    pygame.mixer.init()
    global soundstr
    while True:
        print("Which sound effect would you like to choose?", soundstr,
              "\nInput q to quit.")
        soundfile = input("Choose a sound file:")
        if soundfile == 'q':
            break
        soundfile = soundfile + '.json'
        try:
            with open(soundfile, 'r') as f:
                sounds = json.load(f)
                print("Press 'q' to quit")
                while True:
                    ch = getchar()
                    if ch == 'q':  # break when q is hit
                        print("Exiting")
                        break
                    elif ch in sounds:
                        print(sounds[ch])
                        filepath = os.path.join(pathbase, sounds[ch])
                        print(filepath)
                        sounda = pygame.mixer.Sound(file=filepath)
                        blinkblink(0.2)
                        sounda.play()
                    else:
                        print(ch)
                        continue
        except Exception as e:
            print(e)
Ejemplo n.º 2
0
def pianoplay_linux():
    pygame.mixer.init()
    with open("piano.json", 'r') as f:
        sounds = json.load(f)
        print("Press 'q' to quit")
        while True:
            ch = getchar()
            if ch == 'q':
                print("Exiting")
                break
            elif ch in sounds:
                print(sounds[ch])
                filepath = os.path.join(pathbase, sounds[ch])
                print(filepath)
                sounda = pygame.mixer.Sound(file=filepath)
                blinkblink(0.2)
                sounda.play()
            else:
                print(ch)
                continue
Ejemplo n.º 3
0
def win_player():
    pygame.mixer.init()
    getchar = _GetchWindows()
    global soundstr
    while True:
        print("Which sound effect would you like to choose?", soundstr,
              "\nInput q to quit.")
        soundfile = input("Choose a sound file:")
        if soundfile == 'q':
            break
        if soundfile == 'piano':
            pianomode()
        soundfile = soundfile + '.json'
        try:
            with open(soundfile, 'r') as f:
                sounds = json.load(f)
                print("Press 'q' to quit")
                while True:
                    if msvcrt.kbhit():
                        ch = ord(getchar())
                        ch = chr(ch)
                        print(ch)
                        if ch == 'q':  # break when q is hit
                            print("Exiting")
                            break
                        elif ch in sounds:
                            print(sounds[ch])
                            filepath = os.path.join(pathbase, sounds[ch])
                            print(filepath)
                            sounda = pygame.mixer.Sound(file=filepath)
                            blinkblink(0.2)
                            sounda.play()
                        else:
                            continue
        except Exception as e:
            print('No such music file!')
Ejemplo n.º 4
0
from randomflash import blinkblink
import time
while True:
    blinkblink(0.01)
    time.sleep(0.01)