def __init__(self, width, height): self.mWidth = width self.mHeight = height self.mBackground = Background(width, height) self.mBall = Ball(width, height) self.mBars = [] self.mBars.append(Bar(width, height)) self.mBars[0].evolve() self.mScore = 0 self.mGameStart = False self.mEZGame = False self.mEZText = Text("EZ MODE", self.mWidth / 2, 40) self.mGameStartTextTop = Text("Press 'W' to flap", self.mWidth / 2, self.mHeight / 3) self.mGameStartTextBot = Text("Press 'E' for EZ Mode", self.mWidth / 2, self.mHeight / 3 + 35) self.mScoreText = Text(str(self.mScore), self.mWidth / 10 - 20, self.mHeight / 10 - 20) self.mGameOverTextTop = Text("GAME OVER NERD", self.mWidth / 2, self.mHeight / 3) self.mGameOverTextBot = Text("Press 'A' to play again", self.mWidth / 2, self.mHeight / 3 + 35) self.mGameOver = False self.mFlapSound = Sound("sounds/flap.wav") self.mPipeSound = Sound("sounds/pipe_sound.wav") self.mHitSound = Sound("sounds/hit.wav") self.mThemeSong = Sound("sounds/theme_song.wav") self.mThemePlaying = False self.mThemeSong.setVolume(.5) self.mWings = 0 return
def __init__(self): # 初始化 pygame pygame.init() # 初始化時間,遊戲幀數為每秒60幀 self.mainClock = pygame.time.Clock() self.mainClock.tick(60) self.tick = 0 # 初始化「繪圖」、「聲音」、「主角」 self.renderer = Renderer() self.character = Character() self.sound = Sound() self.bgm = Sound() '''遊戲參數初始化設定''' self.pause = False # 可控制遊戲暫停 self.quit = False # 可退出當前遊戲 self.pause_button = 0 # 遊戲暫停選單按鍵 self.game_over_button = 0 # 遊戲死亡選單按鍵 '''遊戲參數初始化設定結束''' '''遊戲精靈群組初始化''' self.allsprite = pygame.sprite.Group() # 精靈群組的總群組 self.bulletsprite = pygame.sprite.Group() # 子彈群組 self.bricksprite = pygame.sprite.Group() # 子彈邊界群組 self.bosssprite = pygame.sprite.Group() # 魔王群組 self.score_sprite = pygame.sprite.Group() self.shoes_sprite = pygame.sprite.Group() self.heart_sprite = pygame.sprite.Group() self.bonus_lst = [ self.score_sprite, self.shoes_sprite, self.heart_sprite ] # 突發class清單 self.direction = 0 self.num = 0 self.speed_adjust = 0 self.map_changex = 0 self.map_changey = 0 self.speed_up = False self.speed_up_time = 0 # 魔王加群組 self.boss = Boss() # boss = Boss(const.screen_width // 2 + self.map_changex, const.screen_height // 2 + self.map_changey) self.bosssprite.add(self.boss) '''遊戲精靈群組初始化結束''' self.volume_dct = { "v_0": pygame.image.load("images/volume/volume.png"), "v_1": pygame.image.load("images/volume/volume5.png"), "v_2": pygame.image.load("images/volume/volume4.png"), "v_3": pygame.image.load("images/volume/volume3.png"), "v_4": pygame.image.load("images/volume/volume2.png"), "v_5": pygame.image.load("images/volume/volume1.png"), "v_6": pygame.image.load("images/volume/volume0.png") } self.screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
def make_processing(self): """ Process all the raw data""" if not self.root_dir.exists(): # require dataset folder raise SoundDataset.DatasetFolderStructureError( f'No folder called \'{self.dataset_name}\' found in the ' f'dataset ' f'folder{SoundDataset.DATA_FOLDER}') if not self.raw_dir.exists(): # require raw data folder raise SoundDataset.DatasetFolderStructureError( f'To process data, raw data have to be located in \'data' f'/{self.dataset_name}/raw/\' ') self.processed_dir.mkdir(exist_ok=True) labels = [f.stem for f in self.raw_dir.glob('*/') if f.is_dir()] for label in labels: Path(self.processed_dir / label).mkdir(exist_ok=True) # Cutting Process for file in list(self.raw_dir.rglob('*.wav')): sound = Sound( file, process=False, sampling_rate=self.sampling_rate, ) sound.to_samples( output_folder=self.processed_dir / file.parent.stem, suffix='clean', ) # Other processing for file in list(self.processed_dir.rglob('*clean.wav')): sound = Sound( file, process=True, sampling_rate=None, ) np.save( Path(file.parent / f'{file.stem[:-5]}1D.npy'), sound.y, ) np.save( Path(file.parent / f'{file.stem[:-5]}2D.npy'), sound.spectrogram, ) np.save( Path(file.parent / f'{file.stem[:-5]}mfcc.npy'), sound.mfcc, )
def __init__( self, grid_size=3, humans=0, bots=2, testing=False, difficulty=1, ): self.width = 800 self.height = 600 self.determine_grid_size(grid_size) self.create_screen() self.audio = Sound() self.out_of_bounds_length = 50 self.x_boundary = (self.width // 2) - self.out_of_bounds_length self.y_boundary = (self.height // 2) - self.out_of_bounds_length self.grid = self.create_grid() self.humans = humans self.bots = bots self.difficulty = difficulty self.players = [] self.particles = [] self.game_on = True self.testing = testing self.create_assets()
def main(): """ Robot will use two corners on one side of the wall in the arena. It will try to put all 4 tokens into slots. This gives us 9 points. """ option = 2 robot = Robot() reset_log(robot) robot.sound = Sound(robot, USING_SOUND) robot.sound.play('R2D2') robot.position = Tracker(robot.zone) set_pins(robot) slots_x = 2.91 if robot.zone in [0, 3] else 5.09 target_theta = pi / 2 if robot.zone in [0, 3] else 1.5 * pi if robot.zone in [0, 1]: dy = 0.9 slot_y_0 = 2.65 else: dy = -0.9 slot_y_0 = 5.65 while 1: try: if option == 1: put_down(robot) grab(robot) token_to_slot(robot, robot.zone) for i in range(4): zone = robot.zone if i < 2 else 3 - robot.zone has_token = get_token_from_corner(robot, zone) if has_token: token_to_slot(robot, zone) elif option == 2: put_down(robot) grab(robot) for i in range(4): zone = robot.zone if i < 2 else 3 - robot.zone if i == 0: move_to_point(robot, slots_x, slot_y_0 + 0.9, target_theta) token_to_slot_2(robot) elif i == 1: move_to_point(robot, 2, 2) get_token_from_corner(robot, zone) move_to_point(robot, slots_x, slot_y_0, target_theta) token_to_slot_2(robot) else: move_to_point(robot, 2, 2) get_token_from_corner(robot, zone) slot_y = slot_y_0 + dy * i move_to_point(robot, slots_x, slot_y, target_theta) token_to_slot_2(robot) except: print_exc() restart(robot)
def __init__(self): pygame.display.set_caption("Visualizer") self.window = pygame.display.set_mode(size=(WIDTH, HEIGHT)) self.window.fill([0, 0, 0]) self.running = True self.top_pixels, self.bot_pixels = [], [] # Top pixel self.top_color = Color(rgb=WHITE) self.top_pixel = Pixel(CENTER[0], CENTER[1], RADIUS, self.top_color, facing='RIGHT', win=self.window) # Bottom pixel self.bot_color = Color(rgb=BLUE) self.bot_pixel = Pixel(CENTER[0], CENTER[1], RADIUS, self.bot_color, facing='LEFT', win=self.window) self.sound = Sound()
def __init__(self): self.scores = HighScore() self.ai_settings = Settings() self.screen = pygame.display.set_mode((self.ai_settings.screen_width, self.ai_settings.screen_height)) pygame.display.set_caption("Alien Invasion") self.sounds = Sound() self.play_button = Button(self.screen, pygame.image.load('images/play_btn.png'), 850, 400) self.high_score_button = Button(self.screen, pygame.image.load('images/high_score_btn.png'), 850, 600) self.menu_bg = Button(self.screen, pygame.image.load('images/menu.png'), self.ai_settings.screen_width / 2, self.ai_settings.screen_height / 2) self.stats = GameStats(self.ai_settings, self.scores) self.sb = Scoreboard(self.ai_settings, self.screen, self.sounds, self.stats) self.ship = Ship(self.ai_settings, self.screen, self.sounds) self.bullets = Group() self.alien_bullets = Group() self.aliens = Group() self.ufo = UFO(self.ai_settings, self.screen, self.sounds) self.barriers = Group() self.smokes = Group() self.inactive = 240 gf.create_fleet(self.ai_settings, self.screen, self.sounds, self.aliens) gf.create_barriers(self.ai_settings, self.screen, self.barriers) # timers used for animation and event checking self.alien_timer = Timer(self.ai_settings.alien_frame_factor) self.smoke_timer = Timer(self.ai_settings.smoke_timer) self.ship_timer = Timer(self.ai_settings.ship_timer) self.ufo_timer = Timer(self.ai_settings.alien_frame_factor * 5) self.bullet_delay = 0 self.stats.game_active = True
def parse_file(self, config, section): """Loads all the sounds in this folder. Assumes all the sounds are ogg files, and thus have a .ogg extension.""" file_path = os.path.join(self.get_path(), config.get(section, 'file')) volume = self.get_config_option(config, 'getfloat', section, 'volume', 1.) setattr(self, section, Sound(file_path, volume))
def __init__(self, width, height): super().__init__(width, height) self.width = width self.height = height arcade.set_background_color(arcade.color.BLACK) self.on_menu = True # self.on_menu = False self.menu_selecting = 0 self.max_menu = 2 self.selector_sprite = arcade.Sprite('images/selector.png') self.selector_sprite.set_position(200, 255) self.menu_screen = arcade.Sprite('images/menu.png') self.menu_screen.set_position(width/2, height/2) self.menu_keys = [] self.instruction_screen = arcade.Sprite('images/instruction.jpg') self.instruction_screen.set_position(width/2, height/2) self.on_instruction = False self.menu_prop = arcade.Sprite('images/planet3-6.png') self.menu_prop_x = 650 self.menu_prop_y = 150 self.menu_prop_direction = 'up' self.menu_prop.set_position(self.menu_prop_x, self.menu_prop_y) self.gameover_screen = arcade.Sprite('images/gameover.jpg') self.gameover_screen.set_position(width/2, height/2) self.gameover = False self.gameover_selecting = 0 self.gameover_keys = [] self.max_gameover_menu = 2 self.sound = Sound() self.pause = False
def __init__(self): pygame.init() self.click = False self.renderer = Renderer() # self.game = Game() self.sound = Sound() self.main_menu()
def __init__(self): os.environ['SDL_VIDEO_CENTERED'] = '1' pygame.mixer.pre_init(44100, -16, 2, 4096) pygame.init() if FULL_SCREEN == True: if os.name == "nt": self.screen = pygame.display.set_mode( SCREEN_SIZE, FULLSCREEN | HWSURFACE | DOUBLEBUF, COLOR_DEPTH) else: self.screen = pygame.display.set_mode(SCREEN_SIZE, FULLSCREEN, COLOR_DEPTH) else: self.screen = pygame.display.set_mode(SCREEN_SIZE, 0, COLOR_DEPTH) pygame.display.set_caption(GAME_NAME) self.clock = pygame.time.Clock() self.timer = time.time() - 5 self.game_started = False self.menu = Menu(self) self.sound = Sound() self.sprites = pygame.sprite.OrderedUpdates() self.font = pygame.font.Font( os.path.join('data', 'misc', 'coopbl.ttf'), 28) self.initialize_game()
def main(): com = Communication() sound = Sound() try: executor = concurrent.futures.ThreadPoolExecutor(max_workers=2) # start MIDI as a concurrent executor sound.quit_midi = False midi_sender = executor.submit(send_midi, sound) # init serial communication # ser = com.init_serial() com.init_serial() # start serial as a concurrent executor quit_recv = False serial_receiver = executor.submit(recv_serial, com, sound) # start video stream video_stream(com , sound) # this block is for stoping process with terminating receive after video_stream()finished while True: try: key = input() time.sleep(1) # wait for checking input if(key == KEY_RECEIVER_STOP): print("accepted f command for stopping \n") break # if anything from standard input, write back to AVR. key += "\n" com.ser.write(str.encode(key)) except: print(traceback.format_exc()) print("\nstop receiver and midi sender thread\n") exit(1) except concurrent.futures.CancelledError: print(traceback.format_exc()) print("executor is cancelled\n") except: print(traceback.format_exc()) finally: print("main is waiting for stopping threas") # do not wait the queue empty as AVR is working asynchronouly # serial_q.join() com.quit_recv = True sound.quit_midi = True # wait until executor(receiver) finishes while not serial_receiver.done(): time.sleep(1) while not midi_sender.done(): time.sleep(1) print("main finished") exit(0)
async def get_sounds(): print(f'get_sounds: entered') sounds = [] for file in os.listdir("BotFiles\Audio"): print(f'get_sounds: file == {file}') path = f'BotFiles\Audio\{file}' mp3_file = mp3.Mp3AudioFile(path) if mp3_file.tag != None: name = mp3_file.tag.title if mp3_file.tag.artist != None: user_names = mp3_file.tag.artist.replace(' ', '').split(',') else: user_names = [] if mp3_file.tag.album != None: emoji_names = mp3_file.tag.album.replace(' ', '').split(',') else: emoji_names = [] if mp3_file.tag.album_artist != None: creator_user_name = mp3_file.tag.album_artist else: creator_user_name = '' sounds.append( Sound(path, name, user_names, emoji_names, creator_user_name)) else: print(f'get_sounds: bad/missing tag data') return sounds
def play_sound_on_frame(self, frames, layer, armature, sound_name, sound_object=None, play_type='play', use_3d=True, lowpass=True, obstructed_lowpass=True, alert_entities=True, volume=1.0): """ Play a sound tied to an animation frame """ ### New sound instance sound = Sound() ### Choose random sound if isinstance(sound_name, list): sound.name = sound_name[random.randrange(0,len(sound_name))] else: sound.name = sound_name ### sound.play_on_frame = True sound.frames = frames sound.layer = layer sound.armature = armature sound.object = sound_object sound.play_type = play_type sound.use_3d = use_3d sound.lowpass = lowpass sound.obstructed_lowpass = obstructed_lowpass sound.alert_entities = alert_entities ### Check for duplicates passed = True for sound_obj in self.sounds: if sound_obj.play_on_frame: if (sound_obj.armature == armature) and (sound_obj.layer == layer): passed = False if passed: self.sounds.append(sound)
def run_game(): pygame.init() pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=521) ai_settings = Settings() pygame.mixer.music.load("sound\\BGM.mp3") screen = pygame.display.set_mode( (ai_settings.screen_width, ai_settings.screen_height)) pygame.display.set_caption("Alien Invasion") icon = pygame.image.load("images\\icons\\alien.ico").convert_alpha() pygame.display.set_icon(icon) play_button = Button(ai_settings, screen, "Play") stats = GameStats(ai_settings) score = ScoreBorad(ai_settings, screen, stats) sound = Sound(pygame.mixer) ship = Ship(screen, ai_settings) bullets = Group() aliens = Group() gf.create_fleet(ai_settings, screen, aliens, ship) while True: if stats.game_active and pygame.mixer.music.get_busy() == False: pygame.mixer.music.play() gf.check_events(ai_settings, screen, aliens, ship, bullets, play_button, stats, score, sound) gf.update_screen(ai_settings, screen, ship, bullets, aliens, play_button, stats, score) if stats.game_active: ship.update() gf.update_bullets(bullets, ai_settings, screen, aliens, ship, stats, score, sound) gf.update_aliens(ai_settings, stats, screen, aliens, ship, bullets, score, sound)
def pressed(self, instance: Button, touch: MouseMotionEvent = None): if touch is not None: if not instance.collide_point(touch.x, touch.y): return if touch.button == 'right': from os.path import basename, split, splitext, exists from os import remove import ffmpeg btn_id = self.get_id(instance) path: str = fileopenbox( msg='Choose audio', title='OneBoard file chooser', default=self.config.getLastPath() + '\\*.mp3', filetypes=[[ '*.mp3', '*.flac', '*.wav', '*.m4a', '*.aac', "Audio files" ]]) if path is not None: self.config.setLastPath(split(path)[0]) file_name = basename( splitext(path)[0]) # only the name of the file new_file_name = file_name + '.wav' # name with extension Body.setup_button(instance, file_name, new_file_name) self.config.setButton(btn_id, file_name, new_file_name) old_path = 'audio/' + self.config.getButtonFile( btn_id) # old local file directory if old_path: # remove old file if exists(old_path): remove(old_path) ffmpeg.input(path).output( 'audio/' + new_file_name).run() # convert and copy the file return if instance.file != '': Sound().play(instance.file)
def __init__(self, name): self.name = name self.curr_cursor_idx = SCREENS[name]["default_cursor_idx"] self.cursor_positions = SCREENS[name]["cursor_positions"] self.num_cursor_positions = len(self.cursor_positions) self.bg = SCREENS[name]["path"] self.audio = Sound()
def run(self): self.__loadConfigs() self.player = pyaudio.PyAudio() # hacky solution, but in this way the console will only print the error once for ii in range(self.player.get_device_count()): self.player.get_device_info_by_index(ii) self.__dailTone = Sound(self.player, './music/kiestoon.wav') self.__dailTone.repeat = True self.rotator = Rotator( self.config.get('DialerRedGpio', self.DAILER_STEP_PIN_DEFAULT), self.config.get('DialerYellowGpio', self.DAILER_ISON_PIN_DEFAULT) ) self.rotator.when_dailed = self.dailed self.hook = gpiozero.Button(self.config.get('HookGpio', self.HOOK_PIN_DEFAULT)) self.hook.when_released = self.offHook self.hook.when_pressed = self.onHook print('t65 started') if not self.hook.is_pressed: # start offHook when it's already of the hook self.offHook() self.__mainLoop()
def __init__(self, file1=None, file2=None): pygame.mixer.pre_init(44100, -16, 2, 2048) pygame.init() self.fps = pygame.time.Clock() flag = DOUBLEBUF self.board = pygame.display.set_mode(screenRect, flag) pygame.display.set_caption('[ --- Pong --- ]') self.state = 1 # 1 - run, 0 - exit self.track = Tracking(file1, file2) self.sound = Sound() self.p1 = Paddle(self.board, (200, 100, 100), screenRect) self.p1.setInitialPostition(0, screenHeight / 2) self.p2 = Paddle(self.board, (100, 200, 100), screenRect) self.p2.setInitialPostition(screenWidth - self.p2.get()['width'], screenHeight / 2) self.ball = Ball(self.board, (50, 50, 250), screenRect, self.sound) self.ball.setInitialPostition(screenWidth / 2, screenHeight / 2) self.arena = Arena(self.board, screenRect) self.referee = Referee(self.ball, self.p1, self.p2, screenRect, self.sound) self.t = Thread(target=self.track.run) #self.track.run() self.t.start() self.p1_pos = 0 self.p2_pos = 0 self.loop()
def run_game(): # 初始化游戏并创建一个屏幕对象 pygame.init() ai_settings = Settings() screen = pygame.display.set_mode( (ai_settings.screen_height, ai_settings.screen_width)) pygame.display.set_caption('Alien Invasion') sound = Sound(pygame) bg = Background(ai_settings, screen) play_button = Button(ai_settings, screen, 'PLAY') stats = GameStats(ai_settings) ship = Ship(ai_settings, screen) bullets = Group() aliens = Group() sb = Scoreboard(ai_settings, screen, stats) gf.create_fleet(ai_settings, screen, ship, aliens) while True: gf.check_events(ai_settings, screen, ship, aliens, bullets, stats, play_button, sb, sound) if stats.game_active: ship.update() gf.update_bullets(ai_settings, screen, ship, aliens, bullets, stats, sb, sound) gf.update_aliens(ai_settings, screen, ship, aliens, bullets, stats, sb, sound) gf.update_screen(ai_settings, screen, ship, bullets, aliens, stats, play_button, sb, bg)
def run_game(): pygame.init() pygame.mixer.init() ai_settings = Settings() screen = pygame.display.set_mode( (ai_settings.screen_width, ai_settings.screen_height)) sound = Sound(pygame.mixer) ship = Ship(screen, ai_settings) bullets = Group() aliens = Group() stats = GameStats(ai_settings) sb = Scoreboard(ai_settings, screen, stats) background = Background(screen, 'background.jpg', [0, 0]) pygame.display.set_caption("Alient invasion") play_button = Button(ai_settings, screen, "Play") gf.create_fleet(ai_settings, screen, ship, aliens) while True: gf.check_events(ai_settings, screen, stats, play_button, ship, sb, aliens, bullets, sound) if stats.game_active: ship.update() gf.update_bullets(ai_settings, screen, stats, sb, ship, aliens, bullets, sound) gf.update_aliens(ai_settings, stats, screen, sb, ship, aliens, bullets, sound) gf.update_screen(ai_settings, screen, stats, sb, ship, aliens, bullets, play_button, background)
def __init__(self, outfile): super(Board, self).__init__() self.filename = outfile self.coord = { 'center' :((config.BOARD_DIM+1)//2, (config.BOARD_DIM+1)//2), 'arrow_up' :(0, (config.BOARD_DIM+1)//2), 'arrow_down' :(config.BOARD_DIM+1, (config.BOARD_DIM+1)//2), 'arrow_left' :((config.BOARD_DIM+1)//2, 0), 'arrow_right' :((config.BOARD_DIM+1)//2, (config.BOARD_DIM+1)), 'corner_top_left' :(1, 1), 'corner_top_right' :(1, config.BOARD_DIM), 'corner_bottom_left' :(config.BOARD_DIM, 1), 'corner_bottom_right':(config.BOARD_DIM, config.BOARD_DIM), 'previous_move':(), 'current_move':(), 'last_correct':(), } if os.path.isfile(self.filename): print('warning: file "%s" exists and will be erased' % self.filename) os.remove(self.filename) self.reset_vars() if config.ARDUINO_USED: self.arduino = Arduino() self.sound = Sound() self.time = Time() self.grid = QtWidgets.QGridLayout() self.draw_board() self.draw_arrows() self.set_ui_elements()
def start_game(self): self.level.reset() level_map = self.level.get_level() self.game_over = False self.stats = GameStats(settings=self.settings) self.sb = Scoreboard(settings=self.settings, screen=self.screen, stats=self.stats) self.sound = Sound() self.maze = Maze(settings=self.settings, screen=self.screen) self.maze.get_maze() self.grid_pts = Grid_Pnts_Group(settings=self.settings, screen=self.screen, txt_file=level_map["mazename"]) self.foods = FoodGroup(settings=self.settings, screen=self.screen, food_file=level_map["foodname"]) self.pacman = Pacman(game=self, settings=self.settings, screen=self.screen, grid_pts=self.grid_pts, foods=self.foods, sb=self.sb) self.ghosts = Ghost_Group(game=self, settings=self.settings, screen=self.screen, grid_pts=self.grid_pts) self.pellets_eaten = 0 self.settings.pacman_lives = self.settings.starting_lives self.fruit = None self.pause.force(True)
def make_sound(self, directory, steps=0): if steps == 0: return path = directory + '/' n = self.length walk_range = self.get_range() def x(value): return (value - walk_range[0][0]) / (walk_range[0][1] - walk_range[0][0]) def y(value): return (value - walk_range[1][0]) / (walk_range[1][1] - walk_range[1][0]) def frequency(value, frequency_min=self.config.frequency_min, frequency_max=self.config.frequency_max): return frequency_min * ((frequency_max / frequency_min)**y(value)) duration = 1 / self.config.frame_rate sound = Sound(sampling_frequency=self.config.sampling_frequency, note_duration=duration) for i in range(steps + 1): index = math.ceil(i * (n / steps)) if i < steps else -1 point = self.walk[index] note = [frequency(point[1]), x(point[0])] sound.make_sound(note[0], note[1]) progress_bar(i, steps) sound.export_sound(path + "walk.wav") print('\n')
def main(): game_set = Settings() pygame.init() pygame.mixer.init() screen = pygame.display.set_mode( (game_set.screen_width, game_set.screen_height)) pygame.display.set_caption("Conway's Game of Life") gf.set_icon() sound = Sound(game_set) clock = pygame.time.Clock() button_start = Button(screen, "start", 80, 10, 160, 30) button_stop = Button(screen, "stop", 320, 10, 160, 30) button_clear = Button(screen, "clear", 560, 10, 160, 30) cells = Group() gf.create_cell(game_set, screen, cells) while True: clock.tick(game_set.fps) gf.check_event(game_set, cells, button_start, button_stop, button_clear, sound) if game_set.game_status == 'started': gf.step(game_set, cells, sound) gf.render(game_set, screen, cells, button_start, button_stop, button_clear)
def process(filename): fs, snd = wavfile.read(filename) try: sndobj = Sound(fs, snd) except DepthException as e: print(e) print("Skipping...") return print("==== Information about {} ====".format(filename)) print("Samples: {}".format(sndobj.samples)) print("Channels: {}".format(sndobj.channels)) print("Duration: {}".format(sndobj.duration)) print("Depth: {}-bit".format(sndobj.depth)) print("============================" + "=" * len(filename)) signals_to_save = np.array([], dtype=np.int64).reshape(sndobj.samples, 0) for c in range(sndobj.channels): print("Parsing channel {}".format(c)) cleaned_signal = parse(snd.T[c], sndobj) signals_to_save = np.column_stack([signals_to_save, cleaned_signal]) if DEBUG: print(signals_to_save) output_filename = gen_output_filename(filename) print("Saving to {}".format(output_filename)) wavfile.write(output_filename, rate=sndobj.fs, data=signals_to_save)
def __init__(self, nr_of_people, preferences): self.index = 0 self.nr_of_people = nr_of_people self.playlist = [] self.preferences = preferences for p in preferences: self.playlist.append(Sound(p))
def __init__(self, host, port, media_path): self.media = Sound() self.loop = asyncio.get_event_loop() self.server = Server(host, port, self.background_tasks, self.shutdown_tasks) self.dir = media_path self.server.on_post('media', 'play', self.handle_play) self.server.on_post('media', 'stop', self.handle_stop) self.server.on_get('media', self.handle_get_media)
def __init__(self, ipc): self.ipc = ipc self.Log = Logger("SoundHandler") self.sound = Sound() #add callback to ipc handler self.ipc.add_message_callback(self.on_message) self.ipc.start()
def initGameObjects(self): self.prevGameState = self.gameState self.inp = Input() self.gameBoard = GameBoard(self) self.shipMan = ShipManager(self.screen, GameBoard.BOTTOM) self.hitMan = HitManager(self.screen) self.opponent = Opponent(self.screen, OpponentType.AI) self.helpergui = Helpergui(self) self.sound = Sound(self.screen)