Ejemplo n.º 1
0
def main():
    window = interface.interface
    
    while True:
        window.update_window(window) # Checa e atualiza eventos e entradas na interface

        # Se o botão Tocar música for pressionado:
        if (window.event == "play_button"):
            input_text = window.returnText(window)
            interpretToPlay(input_text, window.getDefaultVolumeSelect(window), window.getDefaultOctaveSelect(window), window.getDefaultBPMSelect(window))
            musicPlayer = audioplayer.AudioPlayer(os.getcwd() + "\\temp.mid") # inicializa o player
            musicPlayer.play()

        # Se o botão Parar música for pressionado:
        elif (window.event == "stop_button"):
            musicPlayer.stop()
            musicPlayer.close() # Finaliza o music player

        # Se o botão Carregar Arquivo for pressionado:
        elif (window.event == "file_selected"):
            window.writeFileToTextBox(window)

        # Se o botão Salvar MIDI for pressionado:
        elif (window.event == "file_saved"):
            filePathAndName = window.values['file_saved']
            input_text = window.returnText(window)
            interpretToSave(input_text, filePathAndName, window.getDefaultVolumeSelect(window), window.getDefaultOctaveSelect(window), window.getDefaultBPMSelect(window))

        # Fecha o programa se o usuário fechar a janela, precisa estar no loop do main!!
        elif (window.event == interface.sg.WIN_CLOSED):
            break        
Ejemplo n.º 2
0
    def __init__(self,
                 videoPath,
                 audioPath,
                 controller,
                 label,
                 loop=0,
                 size=(640, 360)):
        self.path = videoPath
        self.audioPath = audioPath
        self.controller = controller
        self.label = label
        self.loop = loop
        self.size = size

        self.isRunning = False
        self.isStarted = False

        self.startIcon = getIconImage("start")
        self.pauseIcon = getIconImage("pause")

        self.__configureController()

        self.frame_data = imageio.get_reader(videoPath)
        self.__setFirstFrame()

        self.audioPlayer = audioplayer.AudioPlayer(audioPath)
    def __init__(self):
        self.fileTrack = AudioTrack()
        self.synthesizedTrack = AudioTrack()

        self.notes = None

        self.channels = 1
        self.audioLength = 0
        self.sampleRate = 0

        self.player = audioplayer.AudioPlayer(self)

        self.instruments = {"Beep": instrument.Beep(), "Acoustic Guitar": instrument.AcousticGuitar(), "Electric Guitar": instrument.ElectricGuitar(), "Trumpet": instrument.Trumpet()}
        self.currentInstrument = None
Ejemplo n.º 4
0
def play():
	audio = audioplayer.AudioPlayer("../Google/music247/test.mp3")
	audio.volume = 20

	audio.play(block=True)
	status = audio.trackstatus()
	print(status[1])
	audio.play()
	audio.stop()
	while True:
		status = audio.trackstatus()
		print(status[1])
		audio.resume()
		time.sleep(1)
Ejemplo n.º 5
0
    def __init__(self, master, name, row, column, color):
        self.name = name
        self.color = color
        self.path = f"{test}/{name}"
        self.audioPlayer = audioplayer.AudioPlayer(self.path)
        fs, self.data = wavfile.read(self.path)

        self.isAnalyzing = False

        self.frame = tk.Frame(master, bg=blue)
        self.frame.grid(row=row, column=column, ipady=10)

        self.status = tk.Label
        self.result = tk.Label
        self.distance = tk.Label

        self.plotGraph()
        self.showDTW()
    def load_audio(self):
        if os.path.exists(self.sendpraat.AUDIOFILE_DIR):
            os.remove(self.sendpraat.AUDIOFILE_DIR)

        value = self.sld_speed.GetValue()

        midpoint = 5

        if value > midpoint:
            speed = 1 - (value - midpoint) * 0.05
        elif value < midpoint:
            speed = (midpoint - value) * 0.25 + 1
        elif value == midpoint:
            speed = 1
        self.sendpraat.extract_audio_file(speed)

        try:
            self.audio = audioplayer.AudioPlayer(self.sendpraat.AUDIOFILE_DIR)
        except:
            pass
Ejemplo n.º 7
0
    def reload(self, event=''):

        if self.quiz_no >= self.total_quiz_no:
            self.app.root.current = 'eq_finish'
            return ''

        self.show_popup('loading')
        self.quiz = self.generate_quiz()

        self.quiz_no += 1

        self.chances_left = 3
        self.chances_left_btn.source = 'icons/chances_left_3.png'
        self.next_btn.source = 'icons/back.png'
        self.next_btn.on_release = self.goto_menu
        self.gain_label.text = str(self.quiz['gain']) + ' db'
        self.band_label.text = str(self.quiz['band']) + ' band'
        self.quiz_label.text = str(self.quiz_no) + ' of ' + str(
            self.total_quiz_no)

        try:
            self.aud.unload()
        except:
            pass

        self.aud = audioplayer.AudioPlayer(self.quiz['song'])
        self.aud.equo(self.quiz['correct_option'],
                      self.quiz['gain'],
                      band=self.quiz['band'])

        self.ans_btn_1.text = str(self.quiz['all_options'][0])
        self.ans_btn_2.text = str(self.quiz['all_options'][1])
        self.ans_btn_3.text = str(self.quiz['all_options'][2])
        self.ans_btn_4.text = str(self.quiz['all_options'][3])

        pause_btn = self.app.root.ids['pause_btn']
        pause_btn.source = 'icons/resume.png'
Ejemplo n.º 8
0
	def beginplaying():
		self.audio = audioplayer.AudioPlayer("../Google/music247/test.mp3")
		self.audio.play()
Ejemplo n.º 9
0
    def __init__(self):
        # Input an existing wav filename
        #thunder = input("sounds\\thunder.wav")
        # load the file into pydub
        #sound_thunder = AudioSegment.from_wav("sounds/thunder.wav")
        # play the file
        #play(sound_thunder)
        # loads music and define music class a,b

        self.song1 = ("sounds/hintergrundmusik1.mp3")
        self.song2 = ("sounds/hintergrundmusik2.mp3")
        self.song3 = ("sounds/Background_Music_Castemia.mp3")
        self.song4 = ("sounds/Background_Music_Ragnarök_War.mp3")
        self.song5 = ("sounds/regen_gewitter.mp3")
        #audioplayer.AudioPlayer._do_setvolume(10, self.song5)
        self.a = audioplayer.AudioPlayer(self.song1)
        self.b = audioplayer.AudioPlayer(self.song2)
        self.c = audioplayer.AudioPlayer(self.song3)
        self.d = audioplayer.AudioPlayer(self.song4)
        self.e = audioplayer.AudioPlayer(self.song5)

        #-----------------------------------------------------
        # starts playing background music on the startpage
        self.d.play(0)
        self.d._do_setvolume(40)
        #self.c.play(0)
        #self.c._do_setvolume(90)
        #-----------------------------------------------------
        # starts the startscreen
        text_imagine = "          ||  ||\\\\      //||    //  \\\\      //#####   ||  ||\\\\     ||  ||######\n          ||  || \\\\    // ||   //    \\\\    //         ||  || \\\\    ||  ||\n          ||  ||  \\\\  //  ||  //######\\\\  //          ||  ||  \\\\   ||  ||######\n          ||  ||   \\\\//   ||  ||      ||  ||   ###||  ||  ||   \\\\  ||  ||\n          ||  ||          ||  ||      ||  ||      ||  ||  ||    \\\\ ||  ||\n          ||  ||          ||  ||      ||  ||######||  ||  ||     \\\\||  ||######"

        text_heroes = "                    ||      ||  ||######  ||#####||  ||######||  ||######  ######\n                    ||      ||  ||        ||     ||  ||      ||  ||        ||\n                    ||######||  ||######  ||#####||  ||      ||  ||######  ######\n                    ||      ||  ||        ||  \\\\     ||      ||  ||            ||\n                    ||      ||  ||        ||   \\\\    ||      ||  ||            ||\n                    ||      ||  ||######  ||    \\\\   ||######||  ||######  ######"

        for i in text_imagine:
            sys.stdout.write(Fore.YELLOW + i)
            sleep(0.01)
        print("")
        print("")
        print("")
        for i in text_heroes:
            sys.stdout.write(Style.BRIGHT + Fore.GREEN + i)

            sleep(0.01)
        print("")
        print("")
        print(Style.DIM +
              "This Game is produced by Jens Tucholski ([email protected])")
        print("")
        while True:
            print("")
            datei = Path("saved_game/game_saved.dir")
            startgame = input("Would you like to start the game? y/n: ")
            if startgame == "y":
                if datei.is_file():
                    while True:
                        q_load = input(
                            "You have a saved game, do you want to load it? y/n: "
                        )
                        if q_load == "y":
                            winsound.PlaySound(
                                "sounds\\thunder.wav",
                                winsound.SND_ASYNC | winsound.SND_ALIAS)
                            #play(sound_thunder)
                            self.load()
                            print("")
                            print(Fore.YELLOW + "Game loaded...")
                            print("")
                            return
                        elif q_load == "n":
                            winsound.PlaySound(
                                "sounds\\thunder.wav",
                                winsound.SND_ASYNC | winsound.SND_ALIAS)
                            #play(sound_thunder)
                            print("")
                            text.introduction()
                            break
                        else:
                            print("")
                            print("Wrong input, try again...")
                            print("")
                else:
                    winsound.PlaySound("sounds\\thunder.wav",
                                       winsound.SND_ASYNC | winsound.SND_ALIAS)
                    #play(sound_thunder)
                    print("")
                    # introduction--------------------------------------------------------------------------------------------------------
                    text.introduction()
                    break
                break
            elif startgame == "n":
                winsound.PlaySound("sounds\\thunder.wav",
                                   winsound.SND_ASYNC | winsound.SND_ALIAS)
                #play(sound_thunder)
                print("")
                print("The windows is now closing...")
                sleep(3)
                exit()
            else:
                print("")
                print("Wrong input, try again...")
        self.d._do_setvolume(20)
        self.e.play(0)
        self.e._do_setvolume(35)
        text1 = "Oh... hey, so you finally woke up.\nThat's great, I thought you were dying.\nYou're very lucky that I found you in the bay where I go fishing.\nMy name is Ben, by the way."
        for i in text1:
            sys.stdout.write(Fore.LIGHTYELLOW_EX + i)
            sleep(0.04)
        print("")
        #-------------------------------------------- Name -------------------
        while True:
            var1 = True
            print("")
            print(Fore.LIGHTYELLOW_EX +
                  "What is your name, can you remember? ",
                  end='')
            name = input()
            print("")
            for i in name:
                if i.isdigit() or i.isnumeric(
                ) or i == "!" or i == "§" or i == "$" or i == "%" or i == "&" or i == "/" or i == "(" or i == ")" or i == "=" or i == "?" or i == "+" or i == "*" or i == "~" or i == "#" or i == ":" or i == "." or i == ";" or i == "," or i == "<" or i == ">" or i == "|" or i == "^^" or i == "^" or i == "°" or i == "{" or i == "[" or i == "]" or i == "}":
                    print("")
                    print("A name should only consist of letters")
                    print("Try again...")
                    print("")
                    var1 = False
                    break
            if name == "":
                print("")
                print("A name should only consist of letters")
                print("Try again...")
                print("")
                var1 = False
                pass
            elif var1 == True:
                winsound.PlaySound("sounds\\thunder.wav",
                                   winsound.SND_ASYNC | winsound.SND_ALIAS)
                #play(sound_thunder)
                print("")
                print(Fore.LIGHTYELLOW_EX + "Allright, your name is", name)
                C().lear()
                break
        print("")
        text2 = "Ehm... sorry to ask you this, but you were talking really weird stuff when you were sleeping."
        for i in text2:
            sys.stdout.write(Fore.LIGHTYELLOW_EX + i)
            sleep(0.04)
        #--------------------------------------------- Gender ------------------
        print("")
        while True:
            print("")
            print(Fore.LIGHTYELLOW_EX +
                  "Do you know your gender? Are you female 'w' or male 'm': ",
                  end="")
            gender = input()
            print("")
            if gender == "w":
                winsound.PlaySound("sounds\\thunder.wav",
                                   winsound.SND_ASYNC | winsound.SND_ALIAS)
                #play(sound_thunder)
                print(Fore.LIGHTYELLOW_EX + "Thats right, you are female.")
                C().lear()
                break
            elif gender == "m":
                winsound.PlaySound("sounds\\thunder.wav",
                                   winsound.SND_ASYNC | winsound.SND_ALIAS)
                #play(sound_thunder)
                print(Fore.LIGHTYELLOW_EX + "Thats right, you are male.")
                C().lear()
                break
            else:
                print("")
                print("Wrong input, try again...")
                print("")
        #--------------------------------------------- Race -----------------
        print("")
        text2 = "I have one last question for you. Just to make sure you're really okay."
        for i in text2:
            sys.stdout.write(Fore.LIGHTYELLOW_EX + i)
            sleep(0.04)
        print("")
        while True:
            text3 = "Are you aware of which ancestors you descend from?"
            for i in text3:
                sys.stdout.write(Fore.LIGHTYELLOW_EX + i)
                sleep(0.04)
            print("")
            print("")
            print(Fore.BLUE + "(1) Human:")
            print("     - Humans are very tough creatures.")
            print(
                "       In the course of time, they have been able to adapt to any situation and thus have survived."
            )
            print(
                "       With their adaptability they have + 5% chance of blocking with the right equipment"
            )
            print("")
            print(Fore.YELLOW + "(2) Nefler:")
            print("     - Neflers are nimble cunning creatures.")
            print(
                "       Their advantage is that their skill more than makes up for their lack of strength."
            )
            print(
                "       Their agile nature, gives them an advantage and therefore have + 3% chance of 2nd attack."
            )
            print("")
            print(Fore.GREEN + "(3) Kro'L:")
            print("     - Kro'L are parasites.")
            print(
                "       They nest in other living beings, otherwise they have no chance of survival. In this way,"
            )
            print(
                "       they take control of their host and thus develop their enormous potential.  + 10% more life from all sources"
            )
            print("")
            print(Fore.LIGHTYELLOW_EX + "Enter 1, 2 or 3: ", end="")
            race = input()
            if race == "1":
                winsound.PlaySound("sounds\\thunder.wav",
                                   winsound.SND_ASYNC | winsound.SND_ALIAS)
                #play(sound_thunder)
                print("")
                print(Fore.LIGHTYELLOW_EX + "That's right too. Great!")
                race = "Human"
                C().lear()
                break
            elif race == "2":
                winsound.PlaySound("sounds\\thunder.wav",
                                   winsound.SND_ASYNC | winsound.SND_ALIAS)
                #play(sound_thunder)
                print("")
                print(Fore.LIGHTYELLOW_EX + "That's right too. Great!")
                print("")
                race = "Nefler"
                C().lear()
                break
            elif race == "3":
                winsound.PlaySound("sounds\\thunder.wav",
                                   winsound.SND_ASYNC | winsound.SND_ALIAS)
                #play(sound_thunder)
                print("")
                print(Fore.LIGHTYELLOW_EX + "That's right too. Great!")
                print("")
                race = "Kro'L"
                C().lear()
                break
            else:
                print("")
                print("Wrong input, try again...")
                print("")

        # Game Variables ##########################################################################################
        # Equipment Bonus:
#--------------------------------------------------
# 2x 1-Hand +3% 2nd Attack
        self.switch_bonus_on_2_1hand = False
        self.switch_bonus_off_2_1hand = False
        self.switch_2_1hand = False
        # 1x 2-Hand +7% total damage
        self.switch_bonus_on_1_2hand = False
        self.switch_bonus_off_1_2hand = False
        self.switch_1_2hand = False
        # Shield +5% bonus armor
        self.switch_bonus_on_shield = False
        self.switch_bonus_off_shield = False
        self.switch_shield = False
        # Leather + 5% bonus 2nd attack
        self.switch_bonus_on_Leather = False
        self.switch_bonus_off_Leather = False
        self.switch_Leather = False
        # Chain + 8% bonus total damage
        self.switch_bonus_on_Chain = False
        self.switch_bonus_off_Chain = False
        self.switch_Chain = False
        # Plate +3% armor and 2% blockchance
        self.switch_bonus_on_Plate = False
        self.switch_bonus_off_Plate = False
        self.switch_Plate = False
        # Ben Quest Variables -----------------------------
        self.ben_quest_1 = []
        # Ben Reward Variables -----------------------------
        self.ben_reward_1 = []

        # init Player --------------------------------------------------------------------------------
        self.Player1 = Player(name, gender, race)