def update(): global a,a2,b0,c0,g0,im,im2,isec0,line0,line02,newMinute,\ nscroll,pim,pim2,nfa0,nfb0,bw,gfspan0, \ root_geom,t0,mousedf0,mousefqso0,nfreeze0,tol0,mode0,nmark0, \ fmid,fmid0,frange,frange0,dftolerance0,ff0 utc=time.gmtime(time.time()+0.1*Audio.gcom1.ndsec) isec=utc[5] if isec != isec0: #Do once per second isec0=isec t0=time.strftime('%H:%M:%S',utc) ltime.configure(text=t0) root_geom=root.geometry() g.rms=Audio.gcom1.rms if isec==0: nscroll=0 if isec==59: newMinute=1 if g.showspecjt==1: showspecjt() nspeed=nspeed0.get() #Waterfall update rate brightness=sc1.get() contrast=sc2.get() g0=sc3.get() newspec=Audio.gcom2.newspec #True if new data available if newspec or brightness != b0 or contrast != c0 or g.cmap != g.cmap0: Audio.spec(brightness,contrast,g0,nspeed,a,a2) #Call Fortran routine spec n=Audio.gcom2.nlines box=(0,0,NX,130-n) #Define region region=im.crop(box) #Get all but last line(s) region2=im2.crop(box) #Get all but last line(s) box=(125,0,624,120) try: if newspec==1: im.paste(region,(0,n)) #Move waterfall down im2.paste(region2,(0,n)) #Move waterfall down except: print "Images did not match, continuing anyway." for i in range(n): line0.putdata(a[NX*i:NX*(i+1)]) #One row of pixels to line0 im.paste(line0,(0,i)) #Paste in new top line(s) line02.putdata(a2[NX*i:NX*(i+1)])#One row of pixels to line0 im2.paste(line02,(0,i)) #Paste in new top line(s) nscroll=nscroll+n if newspec: if Audio.gcom2.monitoring: if newMinute: draw.line((0,0,749,0),fill=128) #Draw the minute separator draw2.line((0,0,749,0),fill=128) #Draw the minute separator # if nscroll == 13: # draw.text((5,2),t0[0:5],fill=253) #Insert time label # draw2.text((5,2),t0[0:5],fill=253) #Insert time label else: draw.line((0,0,749,0),fill=128) #Draw the minute separator draw2.line((0,0,749,0),fill=128) #Draw the minute separator t=g.ftnstr(Audio.gcom2.utcdata) # This test shouldn.t be needed, but ... try: draw.text((4,1),t[0:5],fill=253) #Insert time label draw2.text((4,1),t[0:5],fill=253) #Insert time label except: pass if newspec or brightness != b0 or contrast != c0 or g.cmap != g.cmap0: pim=ImageTk.PhotoImage(im) #Convert Image to PhotoImage graph1.delete(ALL) pim2=ImageTk.PhotoImage(im2) #Convert Image to PhotoImage graph2.delete(ALL) #For some reason, top two lines are invisible, so we move down 2 graph1.create_image(0,0+2,anchor='nw',image=pim) graph2.create_image(0,0+2,anchor='nw',image=pim2) g.ndecphase=2 newMinute=0 Audio.gcom2.newspec=0 b0=brightness #Save scale values c0=contrast g.cmap0=g.cmap if Audio.gcom2.nfreeze != nfreeze0: if not Audio.gcom2.nfreeze: draw_axis() if Audio.gcom2.nfreeze: df_mark() nfreeze0=int(Audio.gcom2.nfreeze) if (Audio.gcom2.fcenter + Audio.gcom2.fadd != ff0) or \ g.fspan != gfspan0: draw_axis() df_mark() ff0=float(Audio.gcom2.fcenter+Audio.gcom2.fadd) gfspan0=g.fspan msub=int(1000*(ff0-int(ff0))+0.5) try: Audio.gcom2.nfa=msub - 0.5*g.fspan except: Audio.gcom2.nfa=msub-30 try: Audio.gcom2.nfb=msub + 0.5*g.fspan except: Audio.gcom2.nfa=msub+30 nbpp=int((Audio.gcom2.nfb - Audio.gcom2.nfa)*32768/(95.2381*NX)) if nbpp<1: nbpp=1 bw=750.0*(95.2381/32768.0)*nbpp if (Audio.gcom2.mousedf != mousedf0 or Audio.gcom2.mousefqso != mousefqso0 or Audio.gcom2.dftolerance != dftolerance0 or Audio.gcom2.nfa != nfa0 or Audio.gcom2.nfb != nfb0): df_mark() # The following int() calls are to ensure that the values copied to # mousedf0 and mousefqso0 are static. mousedf0=int(Audio.gcom2.mousedf) mousefqso0=int(Audio.gcom2.mousefqso) dftolerance0=int(Audio.gcom2.dftolerance) nfa0=int(Audio.gcom2.nfa) nfb0=int(Audio.gcom2.nfb) if g.mode!=mode0: df_mark() ### was draw_axis() mode0=g.mode if nmark.get()!=nmark0: df_mark() nmark0=nmark.get() # if newspec: Audio.gcom2.ndiskdat=0 Audio.gcom2.nlines=0 Audio.gcom2.nflat=nflat.get() frange=nfr.get()*2000 if(fmid<>fmid0 or frange<>frange0): if fmid<1000*nfr.get(): fmid=1000*nfr.get() if fmid>5000-1000*nfr.get(): fmid=5000-1000*nfr.get() df_mark() fmid0=fmid frange0=frange Audio.gcom2.nfmid=int(fmid) Audio.gcom2.nfrange=int(frange) ltime.after(200,update) #Reset the timer
def update(): global a, b0, c0, g0, im, isec0, line0, newMinute, nscroll, nspeed00, pim, root_geom, t0, mousedf0, nfreeze0, tol0, mode0, nmark0, logm0 utc = time.gmtime(time.time() + 0.1 * Audio.gcom1.ndsec) isec = utc[5] if isec != isec0: # Do once per second isec0 = isec t0 = time.strftime("%H:%M:%S", utc) ltime.configure(text=t0) root_geom = root.geometry() g.rms = Audio.gcom1.rms if isec == 0: nscroll = 0 if isec == 59: newMinute = 1 if g.showspecjt == 1: showspecjt() nspeed = nspeed0.get() # Waterfall update rate if (nspeed < 6 and nspeed00 >= 6) or (nspeed >= 6 and nspeed00 < 6): draw_axis() nspeed00 = nspeed brightness = sc1.get() contrast = sc2.get() logm = logmap.get() g0 = sc3.get() if Audio.gcom2.monitoring or Audio.gcom2.ndiskdat: Audio.spec(brightness, contrast, logm, g0, nspeed, a) # Call Fortran routine spec newdat = Audio.gcom1.newdat # True if new data available else: newdat = 0 sm.updateProgress(newValue=Audio.gcom1.level) # S-meter bar if newdat or brightness != b0 or contrast != c0 or logm != logm0: if brightness == b0 and contrast == c0 and logm == logm0 and nspeed < 6: n = Audio.gcom2.nlines box = (0, 0, 750, 300 - n) # Define region region = im.crop(box) # Get all but last line(s) im.paste(region, (0, n)) # Move waterfall down for i in range(n): line0.putdata(a[750 * i : 750 * (i + 1)]) # One row of pixels to line0 im.paste(line0, (0, i)) # Paste in new top line nscroll = nscroll + n else: # A scale factor has changed im.putdata(a) # Compute whole new image b0 = brightness # Save scale values c0 = contrast logm0 = logm if newdat: if Audio.gcom2.monitoring: if minsep.get() and newMinute: draw.line((0, 0, 749, 0), fill=128) # Draw the minute separator if nscroll == 13: draw.text((5, 2), t0[0:5], fill=253) # Insert time label else: if minsep.get(): draw.line((0, 0, 749, 0), fill=128) # Draw the minute separator # Don't update waterfall while decoding pim = ImageTk.PhotoImage(im) # Convert Image to PhotoImage graph1.delete(ALL) # For some reason, top two lines are invisible, so we move down 2 graph1.create_image(0, 0 + 2, anchor="nw", image=pim) if nspeed > 5: color = "white" if g.cmap == "gray1": color = "black" t = time.strftime("%H:%M:%S", time.gmtime(Audio.gcom2.ntime + 0.1 * Audio.gcom1.ndsec)) graph1.create_text(5, 110, anchor=W, text=t, fill=color) t = g.filetime(g.ftnstr(Audio.gcom2.fnamea)) graph1.create_text(5, 260, anchor=W, text=t, fill=color) newMinute = 0 if (Audio.gcom2.mousedf != mousedf0 or Audio.gcom2.dftolerance != tol0) and g.mode[:4] == "JT65": df_mark() # The following int() calls are to ensure that the values copied to # mousedf0 and tol0 are static. mousedf0 = int(Audio.gcom2.mousedf) tol0 = int(Audio.gcom2.dftolerance) if Audio.gcom2.nfreeze != nfreeze0: if not Audio.gcom2.nfreeze: draw_axis() if Audio.gcom2.nfreeze: df_mark() nfreeze0 = int(Audio.gcom2.nfreeze) if g.mode != mode0: if g.mode[:4] == "JT65" and nspeed0.get() > 5: nspeed0.set(3) if g.mode == "FSK441" and nspeed0.get() < 6: nspeed0.set(6) if g.mode == "JT6M" and nspeed0.get() < 6: nspeed0.set(6) draw_axis() mode0 = g.mode if nmark.get() != nmark0: df_mark() nmark0 = nmark.get() if newdat: Audio.gcom2.ndiskdat = 0 Audio.gcom2.nlines = 0 Audio.gcom2.nflat = nflat.get() if g.focus == 2: root.focus_set() ltime.after(200, update) # Reset the timer
def __init__(self): Audio.playMusic('Game of Thrones 8-bit', 0) pygame.init() self.titreFond = pygame.font.SysFont('courier', 40) self.ligneFond = pygame.font.SysFont('courier', 28) self.creditFen0() sleep(6) self.creditFen1() sleep(6) self.creditFen2() sleep(6) self.creditFen3() sleep(6) self.creditFen4() sleep(6) self.creditFen5() sleep(6) self.creditFen6() sleep(6) self.creditFen7() sleep(6) self.creditFen8() sleep(6) self.creditFen9() while pygame.event.wait().type != pygame.locals.KEYDOWN: None pygame.display.quit() Audio.stopMusic()
def __init__(self, engine, infoFileName, songTrackName, guitarTrackName, rhythmTrackName, noteFileName, scriptFileName=None): self.engine = engine self.info = SongInfo(infoFileName) self.tracks = [Track() for t in range(len(difficulties))] self.difficulty = difficulties[AMAZING_DIFFICULTY] self._playing = False self.start = 0.0 self.noteFileName = noteFileName self.bpm = None self.period = 0 # load the tracks if songTrackName: self.music = Audio.Music(songTrackName) self.guitarTrack = None self.rhythmTrack = None try: if guitarTrackName: self.guitarTrack = Audio.StreamingSound( self.engine, self.engine.audio.getChannel(1), guitarTrackName) except Exception, e: Log.warn("Unable to load guitar track: %s" % e)
def __init__(self): Audio.playMusic('Game of Thrones 8-bit',0) pygame.init() self.titreFond = pygame.font.SysFont('courier',40) self.ligneFond = pygame.font.SysFont('courier',28) self.creditFen0() sleep(6) self.creditFen1() sleep(6) self.creditFen2() sleep(6) self.creditFen3() sleep(6) self.creditFen4() sleep(6) self.creditFen5() sleep(6) self.creditFen6() sleep(6) self.creditFen7() sleep(6) self.creditFen8() sleep(6) self.creditFen9() while pygame.event.wait().type != pygame.locals.KEYDOWN: None pygame.display.quit() Audio.stopMusic()
def SilenceToggled(self, MenuItem): OldState = Audio.GetSilenced() Audio.SetSilenced(not OldState) Methods = (Audio.AudioEvent.Unpause, Audio.AudioEvent.Pause) for Key in self.Notifications: Methods[not OldState](self.Notifications[Key].Noisemaker)
def auth(userID, img): if (userUD == 'Unknown'): Switch.open() Audio.negative() Notification.notif(img) else: Switch.close() Audio.positive(userID)
def mourir(self): self.vivant = False self.actif = False Audio.playSound('Goblin') __main__.perso.gagnerOR() #A remplacer par des potions __main__.perso.gagnerPv(int(self.dmg/10)) if __main__.perso.__class__.__name__ == 'Magicien' : __main__.perso.gagnerMana(int(self.dmg/10))
def lancerProjectile(type, pos, dir, degats, pene, sound): if len(__main__.motGraph.projectile) <= 3: __main__.motGraph.projectile.append(Projectile(type, pos, dir, degats, False)) __main__.motGraph.projectile[-1].start() Audio.playSound(sound) return True else: return False
def mourir(self): self.vivant = False self.actif = False Audio.playSound('Goblin') __main__.perso.gagnerOR() #A remplacer par des potions __main__.perso.gagnerPv(int(self.dmg / 10)) if __main__.perso.__class__.__name__ == 'Magicien': __main__.perso.gagnerMana(int(self.dmg / 10))
def lancerProjectile(type, pos, dir, degats, pene, sound): if len(__main__.motGraph.projectile) <= 3: __main__.motGraph.projectile.append( Projectile(type, pos, dir, degats, False)) __main__.motGraph.projectile[-1].start() Audio.playSound(sound) return True else: return False
def waitForTutorial(): is_playing = True while (is_playing) : time.sleep(0.01) is_playing = a.mixer.music.get_busy() if (g.checkBtnState('NXT')): g.setBtnState('NXT', False) a.stopAudio() return True return False
def chargerConfig(): global texturePack fichierConfig = open('Saves/Config.txt') config = fichierConfig.readlines() fichierConfig.close() Audio.volumeGlobal = int(config[0]) Audio.volumeMusic = int(config[1]) Audio.volumeSound = int(config[2]) Audio.setVolumeMusic() texturePack = config[3]
def fightInit(): global stageImage stageImage = Fight.loadStageBG(0,resolution) #load stageImage Audio.tavernMusic() #addsprites character1 = Character.spawnPlayer1('Ninja') allsprites.add(character1) return
def Begin(self): """Start the engine""" while self.App.IsOpened(): self.UpdateVars() Event.Input.clearStates() self.App.Clear(self._bgColour) Event.DispatchEvents(self.App) if self.World: self.World.update() self.World.render() self.App.Display() Audio.checkSounds() if self.World: self.World.endOfFrame()
def run(self): global son while not self._stopevent.isSet(): type,received = Client.receiveMsg() if type=="N": #print(received) Client.notify(received) else: print("-->%s" % received) if son: adire=received[:-14] Audio.parle(adire) time.sleep(0.01)
def on_message(self, mosclient, userdata, msg): messageparts = str(msg.payload).split("/") if len(messageparts) == 3 and messageparts[1] == "Sound": full_command = messageparts[2] self.app_log.info("Message received on mqtt: " + full_command) if messageparts[2] == "time": audio = Audio.Audio() audio.say_time("12") elif messageparts[2] == "morning+": audio = Audio.Audio() audio.say_good_greeting() elif messageparts[2] == "inspiration": audio = Audio.Audio() audio.say_inspiration()
def run(self, ticks): self.time += ticks / 50.0 if self.engine.cmdPlay == 1: #evilynux - improve cmdline support self.newLocalGame(players=Config.get("game", "players"), mode1p=Config.get("player0", "mode_1p"), mode2p=Config.get("player1", "mode_2p")) elif self.engine.cmdPlay == 2: self.quit() if self.menumusic: #MFH if not self.song.isPlaying(): #re-randomize if self.files: i = random.randint(0, len(self.files) - 1) filename = self.files[i] sound = os.path.join("themes", self.themename, "sounds", filename) self.menumusic = True #self.song = Audio.Sound(self.engine.resource.fileName(sound)) self.song = Audio.Music( self.engine.resource.fileName(sound)) self.song.setVolume( self.engine.config.get("audio", "songvol")) #self.song.play(-1) self.song.play(0) #no loop else: self.menumusic = False
def try_swap(): global cursor_pos margin = Globals.margin image_size = Globals.image_size x, y = pygame.mouse.get_pos() x = int(int(x - margin[0]) / image_size) y = int(int(y - margin[1]) / image_size) if not (x < 0 or x >= Gameboard.Gameboard_size or y < 0 or y >= Gameboard.Gameboard_size): if (Globals.selected_element == [x, y]): Globals.selected_element = (-1, -1) elif Globals.selected_element == (-1, -1): Globals.selected_element = [x, y] else: if coord_distance(Globals.selected_element, [x, y]) <= 1: Gameboard.swap_elements(Globals.selected_element, [x, y]) old_swap = ([x, y], Globals.selected_element) ## if we didn't get a match, undo this swap if not Gameboard.check_adjacency(3): Gameboard.swap_elements(old_swap[0], old_swap[1]) return Gameboard.check_drop() set_game_state(Globals.Game_State.animation) Globals.selected_element = (-1, -1) else: Audio.Cancel()
def RunGTKApp(): sys.excepthook = ExceptionDialogSpawner if '--silence' in sys.argv: Audio.SetSilenced(True) MainObj = GtkGUI.MainWindow() if '--tray' not in sys.argv: MainObj.show_all() TrayIcon = GtkGUI.TrayIconObject(MainObj) signal.signal(signal.SIGUSR1, MainObj.SilenceSignalHandler) signal.signal(signal.SIGUSR2, MainObj.DismissAllSignalHandler) signal.signal(signal.SIGTERM, lambda *Discarded: sys.exit(0)) signal.signal(signal.SIGINT, lambda *Discarded: sys.exit(0)) GtkGUI.GLib.timeout_add( 200, lambda *Discarded: MainObj.DB.CheckTriggers( MainObj.SpawnNotification) or True) GtkGUI.GLib.timeout_add( 10000, lambda *Discarded: MainObj.DB.CheckReload() or True) GtkGUI.Gtk.main()
def run(self): global son while not self._stopevent.isSet(): typ,received = Client.receiveMsg() if typ=="N": Client.notify(received) elif typ=="F": r=received.split(";") FileManager.convertFileReceive(r[0],r[1]) Client.notify("notif;Transfert;Fichier "+r[1]+" bien reçu;4") else: print("\n-->%s" % received) if son: adire=received[:-14] Audio.parle(adire) time.sleep(0.01)
def __init__(self): self.pywindow = pygame.display.set_mode((900, 600), 0, 32) #窗口大小 self.image = Image.Image() #导入图片 self.botany = Botany.Botany() #植物类 self.zombie = Zombie.Zombie() #僵尸类 self.collision = Collision.Collision() #碰撞类 self.audio = Audio.Audio() #音频类 self.Sunny_Collect = [] #回收的阳光坐标列表 self.Sunny_Collect_x = 0 self.Sunny_Collect_y = 0 self.Botany_Type = 0 #植物类型 self.Botany_Animation_Type = 0 #植物动画类型 self.Zombie_Animation_Type = 0 #僵尸动画类型 self.Stop_image = self.image.game_pause_nor #暂停初始图标 self.Zombie_image_list = 0 #僵尸图片列表索引 self.SunFlower_image_list = 16 #向日葵图片列表索引(从后往前索引只是想测试一下,并无大碍) self.Peashooter_image_list = 12 #豌豆列表索引 self.ZombieAttack_image_list = 0 #僵尸吃植物索引 self.FootballZombie_image_list = 0 #重装僵尸图片索引 self.FootballZombieAttack_image_list = 0 #重装僵尸吃植物图片索引 self.FootballZombieDie_image_list = 0 #重装僵尸死亡图片索引 self.evillaugh = pygame.mixer.Sound(self.audio.evillaugh) #僵尸暴走音效 self.Zombie_Go_ballistic_audio = 0 #暴走音效控制变量 self.scream = pygame.mixer.Sound(self.audio.scream) #僵尸胜利音效 self.buttonclick = pygame.mixer.Sound(self.audio.buttonclick) # 按钮音效 self.Zdie = pygame.mixer.Sound(self.audio.groan4) #僵尸死亡音效 self.ZWon = 0 #僵尸胜利后音效控制
def __init__(self, window, window_title, video_source=0, customer=None, database_ref=None): self.window = window self.window.title(window_title) self.video_source = video_source self.fr = fr.FacialRecognition() self.audioFile = None self.current_order = None self.gg = gg.adios() self.ac = Audio_clean.Audio() self.database_ref = database_ref self.id_list = [] # Customer Info self.customer_detected = customer self.customer_label_text = tkinter.StringVar() self.customer_label_text.set("customer") # Current Order Transcribe self.current_order_transcribe_text = tkinter.StringVar() self.current_order_transcribe_text.set("customer_current_order") # open video source (by default this will try to open the computer webcam) self.vid = MyVideoCapture(self.video_source) # Create a canvas that can fit the above video source size self.canvas = tkinter.Canvas(window, width=self.vid.width, height=self.vid.height) self.canvas.pack() # Button that lets the user record the order self.btn_text = tkinter.StringVar() self.btn_text.set("Start Order") self.btn_snapshot = tkinter.Button(window, textvariable=(self.btn_text), width=50, command=self.record) self.btn_snapshot.pack(anchor=tkinter.CENTER, expand=True) # Customer Label self.customer_label = tkinter.Label( window, textvariable=self.customer_label_text) self.customer_label.pack(anchor=tkinter.CENTER, expand=True) # Current Order Label self.customer_order_transcribe_label = tkinter.Label( window, textvariable=self.current_order_transcribe_text) self.customer_order_transcribe_label.pack(anchor=tkinter.CENTER, expand=True) # After it is called once, the update method will be automatically called every delay milliseconds self.delay = 15 self.update() self.window.mainloop()
def toAudiolist(config): if type(config) == configparser.ConfigParser: cfg = config else: cfg = configparser.ConfigParser() cfg.read(config) audiolist = Audio.AudioList() for section in cfg.sections(): sectionEntry = Audio.AudioSection(section) for option in cfg.options(section): sectionEntry.add(option, cfg[section][option]) audiolist.add(sectionEntry) return audiolist
def hello(): out_file = Audio.run_audio() return send_file( out_file, attachment_filename="testing.pptx", mimetype= "application/vnd.openxmlformats-officedocument.presentationml.presentation", as_attachment=True, cache_timeout=0)
def init_structure(self, name, file="", reinit=False): """Initialize structure.""" file = file or self[name].source.filename self[name] = Structure(Audio.Source(file, name), parent=self, reinit=reinit) save() return (self[name])
def tryBougerPerso(self, dx, dy, p): global perso if perso.dir == p: pos = [perso.pos[0]+dx, perso.pos[1]+dy] if (pos[0] == 6 and pos[1] == -1 and self.porte[0]) or (pos[0] == 13 and pos[1] == 3 and self.porte[1]) or (pos[0] == 6 and pos[1] == 7 and self.porte[2]) or (pos[0] == -1 and pos[1] == 3 and self.porte[3]): self.bougerPiece(self.piece, self.porte, -dx, -dy) elif perso.pos[0]+dx < 13 and perso.pos[1]+dy > -1 and perso.pos[1]+dy < 7 and perso.pos[0]+dx > -1:#si le perso peut avancer case = self.piece[perso.pos[0]+dx][perso.pos[1]+dy] mob = 0 for i in self.donjon[perso.Etage].grille[perso.Room[0]][perso.Room[1]].entites: if i.pos[0] == perso.pos[0]+dx and i.pos[1] == perso.pos[1]+dy: mob = 1 if case != 'rocher' and case != 'trou' and (not mob or case == 'coffre'): self.bougerPerso(dx, dy, 1) if self.piece[perso.pos[0]][perso.pos[1]] == 'coffre': #Récupère le contenu du coffre self.donjon[perso.Etage].grille[perso.Room[0]][perso.Room[1]].grille[perso.pos[1]][perso.pos[0]] = 0 self.piece[perso.pos[0]][perso.pos[1]] = 'case' self.fenetre.blit(block[perso.Etage]['case'], (px(perso.pos[0]), px(perso.pos[1]))) perso.gagnerOR(Coffre.gagnerOR(perso.Etage)) self.majOr(perso.OR) if perso.pos[0] == 6 and perso.pos[1] == 3 and perso.Room == [5,5] and perso.Etage != 0 and perso.dir == p: #Descend d'un étage si le personnage est sur un escalier self.bougerEtage() perso.Etage = perso.Etage-1 perso.Room = [self.donjon[perso.Etage].posBoss[1], self.donjon[perso.Etage].posBoss[0]] self.startMob() self.creerPiece() self.afficherPiece() Audio.stageMusic(perso.Etage) elif perso.pos[0] == 6 and perso.pos[1] == 3 and self.piece[6][3] == 'sortie' and perso.dir == p: #Monte d'un étage si le personnage est sur un escalier if perso.Etage != 4: self.bougerEtage() perso.Etage = perso.Etage+1 perso.Room = [5,5] self.startMob() self.creerPiece() self.afficherPiece() afficherCarte(self.donjon[perso.Etage]) Audio.stageMusic(perso.Etage) else: #Ferme la fenêtre si le personnage fini le jeu self.stop() perso.dir = p
def __init__(self, Title, Message, AudioFile=None, Loop=False, Callback=None, *CallbackArgs): Gtk.Window.__init__(self, title=Title) SetWindowIcon(self) self.Callback = Callback self.CallbackArgs = CallbackArgs self.set_default_size(400, 150) self.VBox = Gtk.Box.new(orientation=Gtk.Orientation.VERTICAL, spacing=8) self.add(self.VBox) self.MsgText = Gtk.Label.new(Message) self.MsgHBox = Gtk.Box.new(orientation=Gtk.Orientation.HORIZONTAL, spacing=0) self.Icon = Gtk.Image.new_from_icon_name('appointment-soon', Gtk.IconSize.DIALOG) self.MsgHBox.pack_start(self.Icon, False, True, 8) self.MsgHBox.pack_start(self.MsgText, False, True, 8) MsgHBoxAlign = Gtk.Alignment.new(0.0, 0.0, 0.0, 0.0) MsgHBoxAlign.add(self.MsgHBox) self.VBox.pack_start(MsgHBoxAlign, True, True, 8) self.ButtonHBox = Gtk.Box.new(orientation=Gtk.Orientation.HORIZONTAL, spacing=0) self.VBox.pack_start(self.ButtonHBox, True, True, 8) SnoozeAlign = Gtk.Alignment.new(0.0, 1.0, 0.0, 0.0) DismissAlign = Gtk.Alignment.new(1.0, 1.0, 0.0, 0.0) self.SnoozeButton = Gtk.Button.new_with_mnemonic("_Snooze") self.SnoozeButton.set_sensitive(False) #Snooze not yet implemented self.DismissButton = Gtk.Button.new_with_mnemonic("_Dismiss") self.DismissButton.connect('clicked', self.DismissClicked) SnoozeAlign.add(self.SnoozeButton) DismissAlign.add(self.DismissButton) self.ButtonHBox.pack_start(SnoozeAlign, True, True, 8) self.ButtonHBox.pack_start(DismissAlign, True, True, 8) self.connect('delete-event', self.DismissClicked) if AudioFile: self.Noisemaker = Audio.AudioEvent(AudioFile) self.Noisemaker.Play(Loop) else: self.Noisemaker = None
def wakeUp(self): print 'Waiting to be waked up' cacheAudio = Audio.startAccord(self) status, txt = BD.audio2txt(self, cacheAudio) if status: print "you have said:%s" % (txt) if txt in self.wakeUpIns: BD.txt2audio(self, '您好, 有什么可以帮助的吗') return 1 return -1
def main(): a.initializeAudio() print('Done initializing audio') initializeGPIO() print('Done initializing GPIO') g.globalState = 0 runTutorial() # Tutorial of device g.globalState = 1 runTask('Tasks.Task1') # Run first task #Infinite loop: only stop main program when RPi is shut down while True: # After finishing/aborting a task we end up here if g.checkBtnState('LVLUP'): handleIndicatorsLocally('LVLUP') if g.checkBtnState('LVLDOWN'): handleIndicatorsLocally('LVLDOWN')
def __init__(self): pygame.init() pygame.display.set_icon( pygame.transform.scale(functions.load_image(GAME_ICON), (32, 32))) pygame.display.set_caption('Python-Game') self.playerObj = Player.Player() self.audioObj = Audio.GameAudio() self.inputObj = Input() self._log = logging.getLogger(__name__) self._log.debug('Initialized Game')
def wikipedia_search(): try: engine.speak( "what to search in wikipedia master?please tell me again clearly master" ) search_string = Audio.get_audio() engine.speak("searching master") print(wikipedia.summary(search_string, sentences=2)) engine.speak(wikipedia.summary(search_string, sentences=2)) except: engine.speak("sorry master no results found!")
def __init__(self, mode, sample_list=None): self.cv = CvDriver() self.midi = MidiHandler(self._note_on_callback, self._note_off_callback, self._message_callback) self.audio = Audio(0, 2, 2, 48000) self.library = SampleLibrary(sample_list) self._mode = mode self._recording_note = None self._held_midi_notes = [] self.verbose = False
def write(self, audio_data): """Comm.write(processed_audio) takes an audio file from Audio.adapt() and writes to the serial port""" data = Audio.adapt(audio_data, 150) self.serialPort.close() for x in range(len(data)): self.serialPort.open() self.serialPort.write(data[x]) self.serialPort.close() printProgressBar(x, len(data), prefix='', suffix='', decimals=1, length=100, fill='█', printEnd="\r")
def init(): global globs os.system("mode 200,60") os.system("color 5E") globs.dungeon = Dungeon.genDungeon() globs.player = Player.Player() globs.audio = Audio.Audio() globs.event( "You have entered pony dungeon in the quest for the sword of awesomeness!" ) globs.event("Press h at anytime to view a help menu.") globs.event("Press q at anytime to quit the game.")
def poemLoader(poem): # Maps stanza number to stanza text [1...n] nums_to_stanzas = parsePoem(poem) # Analyze the tones of the poem and map the dominant tone to stanza number num_to_tone = analyzePoem(nums_to_stanzas) # Combine nums_to_stanza and num_to_tone to a list of tuples: [( string of stanza text, # string of dominant tone) ...] text_tone_list = [] for key, val in nums_to_stanzas.items(): text_tone_list.append((val, num_to_tone.get(key))) Audio.run(text_tone_list) # a = """Do not go gentle into that good night, # Old age should burn and rave at close of day; # Rage, rage against the dying of the light. # # Though wise men at their end know dark is right, # Because their words had forked no lightning they # Do not go gentle into that good night. # # Good men, the last wave by, crying how bright # Their frail deeds might have danced in a green bay, # Rage, rage against the dying of the light. # # Wild men who caught and sang the sun in flight, # And learn, too late, they grieved it on its way, # Do not go gentle into that good night. # # Grave men, near death, who see with blinding sight # Blind eyes could blaze like meteors and be gay, # Rage, rage against the dying of the light. # # And you, my father, there on the sad height, # Curse, bless, me now with your fierce tears, I pray. # Do not go gentle into that good night. # Rage, rage against the dying of the light.""" # poemLoader(a)
def main(music_folder: str, disable_menu: bool, enable_rfid: bool): music_folder = os.path.expanduser(music_folder) files = Files(music_folder) audio_files = [] queue = Queue() t = Menu.start_kbd_listener_thread(queue, music_folder) # main loop loop = True while loop: if audio_files: audio_files = Audio.play(audio_files) if not queue.empty(): key = queue.get() if key == "q": print("The End") t.join() loop = False else: print("{} was selected".format(key)) Audio.stop() audio_files = files.get_audio_files(key) audio_files = Audio.play(audio_files)
def loadFile(self, file_path=None, num_frames_total=None): if (file_path): self.setPath(file_path=file_path) if ('file_path' in self.a_info): self.reader = imageio.get_reader(self.a_info['file_path'], 'ffmpeg') self.meta_data = self.reader.get_meta_data() self.sampling_rate = self.meta_data['fps'] if (num_frames_total is not None): self.num_frames_total = num_frames_total else: self.num_frames_total = self.calcNumFramesTotal() try: self.audio = Audio(self.a_info['file_path']) self.audio.name = self.name #except RuntimeError: except Exception: print("Issue loading audio for {}".format( self.a_info['file_path'].encode('utf-8'))) self.audio = Audio(sampling_rate=16000) self.audio.x = np.zeros( int(np.ceil(self.audio.sampling_rate * self.getDuration())))
def runMusic(self): if self.menumusic and not self.song.isPlaying(): #re-randomize if self.files: i = random.randint(0,len(self.files)-1) filename = self.files[i] sound = os.path.join("themes",self.themename,"sounds",filename) self.menumusic = True self.engine.menuMusic = True self.song = Audio.Music(self.engine.resource.fileName(sound)) self.song.setVolume(self.engine.config.get("audio", "menu_volume")) self.song.play(0) else: self.menumusic = False self.engine.menuMusic = False
def run(self): global son global a while not self._stopevent.isSet(): data = raw_input(">") if data == "quit": a.stop() self.stop() elif data == "Tais toi!": son=False elif data == "Parle!": son=True elif data == "Fichier": Client.sendFile() elif data == "p": msg=Audio.ecoute() if msg != "": Client.sendMsg("T",str(msg)) elif len(data): Client.sendMsg("T",str(data)) else: continue time.sleep(0.01)
def mourir(self): Magasin.OR += self.OR Audio.stopMusic() Audio.playSound('Lose') __main__.motGraph.stop() Menu.openMenu()
def gagnerPv(self, valeur): Audio.playSound('Potion') if (self.pv + valeur) > self.pvMax : self.pv = self.pvMax else : self.pv += valeur __main__.motGraph.jauges[0].majJauge(self.pv, self.pvMax)
def run(self): pygame.draw.rect(self.fenetre, [0, 0, 0], [0, 0, 621, 32], 0) self.fenetre.blit(self.iPerso[perso.dir][0], (perso.pos[0]*32+32, perso.pos[1]*32+64)) self.jauges.append(Jauge(self.fenetre, [255, 0, 0], 1, " ", [206, 20], [0,0])) self.majOr(perso.OR) if perso.type == 'Magicien': self.jauges.append(Jauge(self.fenetre, [0, 0, 255], 2, " ", [206, 20], [240,0])) self.jauges[1].majJauge(perso.mana, perso.manaMax) self.jauges[0].majJauge(perso.pv, perso.pvMax) debug('MoteurGraphique.run()') Audio.stageMusic(perso.Etage) self.startMob() #Initialise les monstres self.afficherPiece() while(self.continuer): for event in pygame.event.get(): #On propose au joueur d'agir en appuyant sur une touche if event.type == KEYDOWN: if event.key == K_RIGHT: self.tryBougerPerso(1,0,1) elif event.key == K_LEFT: self.tryBougerPerso(-1,0,3) elif event.key == K_UP: self.tryBougerPerso(0,-1,0) elif event.key == K_DOWN: self.tryBougerPerso(0,1,2) elif event.key == K_F6 and debugMode: perso.mourir() elif event.key == K_F1 and debugMode: for i in self.donjon[perso.Etage].grille[perso.Room[0]][perso.Room[1]].entites: i.perdrePv(100000) elif event.key == K_F2 and debugMode: perso.perdrePv(5) elif event.key == K_F3 and debugMode: perso.gagnerPv(5) elif event.key == K_F7 and debugMode: if len(self.projectile) < 1: self.projectile.append(Projectile(1, [perso.pos[0]+posi(perso.dir, 0), perso.pos[1]+posi(perso.dir, 1)], perso.dir, 100, 10)) self.projectile[len(self.projectile)-1].start() elif event.key == K_LCTRL: pygame.event.set_blocked(pygame.KEYDOWN) self.attaquer() pygame.event.set_allowed(pygame.KEYDOWN) elif event.key == K_LALT: pygame.event.set_blocked(pygame.KEYDOWN) perso.special() self.wait(300) pygame.event.set_allowed(pygame.KEYDOWN) elif event.key == K_F10: self.mort(perso) elif event.type == QUIT: self.continuer = 0 for i in self.projectile: #Supprime les projectiles inactifs if not i.ok: self.projectile.remove(i) self.afficherPiece() #Affiche la pièce sleep(6) pygame.display.quit() #pygame.quit() print('moteur stop')
storing_c = 0 # Wash, Rinse, Repeat. while True: print("Collecting tweets!") # Retrieves the messages container. tweets = Twitter.get_tweets() # Create the llm file LLM.build_llm(tweets) # Send a message to the display to retrieve the LLM file. Update.update_display(Settings.filename) # Play audio when a 'storing' is discovered. if storing_c < tweets.storingen: # Play the audio file. Audio.storing() # Set the counter to the 'storing' level. storing_c = tweets.storingen # Wait for a set amount of time. time.sleep(Settings.tweet_loop) # Stops the HTTP server that is serving llm files. httpd.stop()
def setVolumeMusique(self, volume): Audio.volumeMusic = volume Audio.setVolumeMusic()
def run(self): Audio.playMusic('Rogue Legacy - Castle', -1) self.majPerso() self.mainloop() Sauvegarde.sauvegarder(__main__.savePath)
def run(self): self.root.mainloop() Audio.volumeGlobal = volume Audio.setVolumeMusic()
def bougerPiece(self, prPiece, prPorte, dx, dy): global perso prRoom = perso.Room prBoss = self.boss self.bougerPerso(-dx, -dy, 0) for i in self.donjon[perso.Etage].grille[perso.Room[0]][perso.Room[1]].entites: i.actif = False perso.Room = [perso.Room[0]-dy, perso.Room[1]-dx] self.creerPiece() if self.boss: #Si le personnage entre dans une salle de boss Audio.bossMusic(perso.Etage) elif prBoss: #Si le personnage sors d'une salle de boss Audio.stageMusic(perso.Etage) for i in range (289+dx*dx*192): t1 = pygame.time.get_ticks() self.fenetre.blit(block[perso.Etage]['sol'],(i*dx, 32+i*dy)) #affiche le fond self.fenetre.blit(block[perso.Etage]['sol'],((i-480)*dx, 32+(i-288)*dy)) for x in range(13):#On affiche les blocs des deux pièces for y in range(7): if prPiece[x][y] != 'case': self.fenetre.blit(block[perso.Etage][prPiece[x][y]],(px(x)+i*dx, py(y)+i*dy)) if self.piece[x][y] != 'case': self.fenetre.blit(block[perso.Etage][self.piece[x][y]],(px(x)+(-240*(1+dx)+240*(-1+dx)+i)*dx, py(y)+(-144*(1+dy)+144*(-1+dy)+i)*dy)) for j in self.donjon[perso.Etage].grille[prRoom[0]][prRoom[1]].entites: #On affiche les mobs de la pièce précédente if prBoss: self.fenetre.blit(iBoss[perso.Etage][j.dir][0], (px(j.pos[0])+i*dx, py(j.pos[1])+i*dy)) else: self.fenetre.blit(iEntite[j.type][j.num][j.dir], (px(j.pos[0])+i*dx, py(j.pos[1])+i*dy)) for j in self.donjon[perso.Etage].grille[perso.Room[0]][perso.Room[1]].entites: #On affiche les mobs de la pièce suivante if self.boss: self.fenetre.blit(iBoss[perso.Etage][j.dir][0], (px(j.pos[0])+(-240*(1+dx)+240*(-1+dx)+i)*dx, py(j.pos[1])+(-144*(1+dy)+144*(-1+dy)+i)*dy)) else: self.fenetre.blit(iEntite[j.type][j.num][j.dir], (px(j.pos[0])+(-240*(1+dx)+240*(-1+dx)+i)*dx, py(j.pos[1])+(-144*(1+dy)+144*(-1+dy)+i)*dy)) if prPorte[0]:#affiche les portes de la première pièce self.fenetre.blit(block[perso.Etage]['case'],(224+i*dx, 32+i*dy)) if prPorte[1]: self.fenetre.blit(block[perso.Etage]['case'],(448+i*dx, 160+i*dy)) if prPorte[2]: self.fenetre.blit(block[perso.Etage]['case'],(224+i*dx, 288+i*dy)) if prPorte[3]: self.fenetre.blit(block[perso.Etage]['case'],(0+i*dx, 160+i*dy)) if self.porte[0]:#affiche les portes de la deuxième pièce self.fenetre.blit(block[perso.Etage]['case'],(224+(i-480)*dx, 32+(i-288)*dy)) if self.porte[1]: self.fenetre.blit(block[perso.Etage]['case'],(448+(i-480)*dx, 160+(i-288)*dy)) if self.porte[2]: self.fenetre.blit(block[perso.Etage]['case'],(224+(i-480)*dx, 288+(i-288)*dy)) if self.porte[3]: self.fenetre.blit(block[perso.Etage]['case'],(0+(i-480)*dx, 160+(i-288)*dy)) self.fenetre.blit(self.iPerso[perso.dir][0], (px(perso.pos[0])+dx*i, py(perso.pos[1])+dy*i))#affiche le perso for j in self.projectile:#On affiche les projectiles self.fenetre.blit(j.type, (px(j.pos[0])+j.mPos[0]+dx*i, py(j.pos[1])+j.mPos[1]+dy*i)) pygame.draw.rect(self.fenetre, [0, 0, 0], [0, 0, 621, 32], 0) #On affiche le contour du donjon pygame.draw.rect(self.fenetre, [0, 0, 0], [480, 32, 304, 320], 0) pygame.draw.rect(self.fenetre, [140, 50, 0], [481, 33, 301, 181], 4) self.majOr(perso.OR) for i in self.jauges: #On affiche les jauges i.affJauge() pygame.display.flip() t2 = pygame.time.get_ticks() #Limite la vitesse de la boucle à 3 ms/tour while t2 < t1+3: t2 = pygame.time.get_ticks() self.projectile = [] self.affMap() perso.pos = [6+7*dx, 3+4*dy] self.startMob() self.bougerPerso(-dx, -dy, 0)
pal_blue() npal.set(3) if g.cmap == "Hot": pal_Hot() npal.set(4) if g.cmap == "AFMHot": pal_AFMHot() npal.set(5) # ---------------------------------------------- Display GUI and start mainloop draw_axis() Audio.gcom1.ndevin = g.ndevin.get() Audio.gcom1.ndevout = g.ndevout.get() ndevin = g.ndevin.get() ndevout = g.ndevout.get() Audio.audio_init(ndevin, ndevout) # Start the audio stream ltime.after(200, update) root.deiconify() g.showspecjt = 2 if g.Win32: root.iconbitmap("wsjt.ico") root.title(" SpecJT by K1JT") if __name__ == "__main__": Audio.gcom2.monitoring = 1 root.mainloop() # -------------------------------------------------- Save user params and quit f = open("WSJT.INI", mode="w") f.write("UpdateInterval " + str(nspeed0.get()) + "\n") f.write("Brightness " + str(b0) + "\n")
def setVolumeGlobal(self, volume): Audio.volumeGlobal = volume Audio.setVolumeMusic()
def perdrePv(self, valeur, perceArmure = False): Audio.playSound('Hurt') if perceArmure : self.pv -= valeur else : self.pv -= valeur - int(valeur*self.deff/100) if self.pv <= 0 : self.mourir() else : __main__.motGraph.jauges[0].majJauge(self.pv, self.pvMax)
def attaquer(self): cible = Fonctions.autour(self.dir, self.pos[0], self.pos[1], 12, 9) Audio.playSound('Sword') for i in __main__.motGraph.donjon[self.Etage].grille[self.Room[0]][self.Room[1]].entites: if i.pos == [cible[0], cible[1]] : i.perdrePv((random.random() <= self.critChc/100) * int(self.atk * (self.critDmg-100)/100) + self.atk)