def __init__(self, engine, controlnum, samprate=44100): Task.__init__(self) self.engine = engine self.controlnum = controlnum devnum = self.engine.input.controls.micDevice[controlnum] if devnum == -1: devnum = None self.devname = pa.get_default_input_device_info()['name'] else: self.devname = pa.get_device_info_by_index(devnum)['name'] self.mic = pa.open(samprate, 1, pyaudio.paFloat32, input=True, input_device_index=devnum, start=False) self.analyzer = pypitch.Analyzer(samprate) self.mic_started = False self.lastPeak = 0 self.detectTaps = True self.tapStatus = False self.tapThreshold = -self.engine.input.controls.micTapSensitivity[controlnum] self.passthroughQueue = [] passthroughVolume = self.engine.input.controls.micPassthroughVolume[controlnum] if passthroughVolume > 0.0: log.debug('Microphone: creating passthrough stream at %d%% volume' % round(passthroughVolume * 100)) self.passthroughStream = MicrophonePassthroughStream(engine, self) self.passthroughStream.setVolume(passthroughVolume) else: log.debug('Microphone: not creating passthrough stream') self.passthroughStream = None
def __init__(self, engine, mic): Task.__init__(self) self.engine = engine self.channel = None self.mic = mic self.playing = False self.volume = 1.0
def test_exit(self): # add tasks task0 = Task() task1 = Task() self.task_engine.addTask(task0) self.task_engine.addTask(task1) # remove all tasks self.task_engine.exit() self.assertFalse(self.task_engine.checkTask(task0)) self.assertFalse(self.task_engine.checkTask(task1))
def test_checkTask(self): # no task no_task = "no task" self.assertFalse(self.task_engine.checkTask(no_task)) # no task # one task task = Task() self.task_engine.tasks.append({'task': task}) self.assertTrue(self.task_engine.checkTask(task)) # one task
def __init__(self, engine, geometry = None, screens = 1): Task.__init__(self) self.layers = [] self.incoming = [] self.outgoing = [] self.visibility = {} self.transitionTime = 512.0 self.engine = engine if geometry: self.geometry = list(geometry) else: self.geometry = list(glGetIntegerv(GL_VIEWPORT)) w = self.geometry[2] - self.geometry[0] h = self.geometry[3] - self.geometry[1] self.aspectRatio = float(w) / float(h) self.geometryNormalized = [0,0,0,0] self.setNormalizedGeometry() self.geometryAll = None self.initGeometryAll() self.geometryAllHalf = None self.initGeometryAllHalf()
def __init__(self): self.logClassInits = Config.get("game", "log_class_inits") if self.logClassInits == 1: log.debug("Input class init (Input.py)...") Task.__init__(self) self.mouse = pygame.mouse self.mouseListeners = [] self.keyListeners = [] self.systemListeners = [] self.priorityKeyListeners = [] self.controls = Controls() self.activeGameControls = [] self.p2Nav = self.controls.p2Nav self.type1 = self.controls.type[0] self.keyCheckerMode = Config.get("game", "key_checker_mode") self.disableKeyRepeat() self.gameGuitars = 0 self.gameDrums = 0 self.gameMics = 0 self.gameBots = 0 # Initialize joysticks pygame.joystick.init() self.joystickNames = {} self.joystickAxes = {} self.joystickHats = {} self.joysticks = [ pygame.joystick.Joystick(id) for id in range(pygame.joystick.get_count()) ] for j in self.joysticks: j.init() self.joystickNames[j.get_id()] = j.get_name() self.joystickAxes[j.get_id()] = [0] * j.get_numaxes() self.joystickHats[j.get_id()] = [(0, 0)] * j.get_numhats() log.debug("%d joysticks found." % len(self.joysticks)) # Enable music events Music.setEndEvent(MusicFinished) #Music.setEndEvent() #MFH - no event required? # Custom key names self.getSystemKeyName = pygame.key.name pygame.key.name = self.getKeyName self.midi = [] if haveMidi: pygame.midi.init() for i in range(pygame.midi.get_count()): interface, name, is_input, is_output, is_opened = pygame.midi.get_device_info( i) log.debug("Found MIDI device: %s on %s" % (name, interface)) if not is_input: log.debug("MIDI device is not an input device.") continue try: self.midi.append(pygame.midi.Input(i)) log.debug("Device opened as device number %d." % len(self.midi)) except pygame.midi.MidiException: log.error("Error opening device for input.") if len(self.midi) == 0: log.debug("No MIDI input ports found.") else: log.notice( "MIDI input support is not available; install at least pygame 1.9 to get it." )
def __init__(self): self.logClassInits = Config.get("game", "log_class_inits") if self.logClassInits == 1: log.debug("Input class init (Input.py)...") Task.__init__(self) self.mouse = pygame.mouse self.mouseListeners = [] self.keyListeners = [] self.systemListeners = [] self.priorityKeyListeners = [] self.controls = Controls() self.activeGameControls = [] self.p2Nav = self.controls.p2Nav self.type1 = self.controls.type[0] self.keyCheckerMode = Config.get("game","key_checker_mode") self.disableKeyRepeat() self.gameGuitars = 0 self.gameDrums = 0 self.gameMics = 0 self.gameBots = 0 # Initialize joysticks pygame.joystick.init() self.joystickNames = {} self.joystickAxes = {} self.joystickHats = {} self.joysticks = [pygame.joystick.Joystick(id) for id in range(pygame.joystick.get_count())] for j in self.joysticks: j.init() self.joystickNames[j.get_id()] = j.get_name() self.joystickAxes[j.get_id()] = [0] * j.get_numaxes() self.joystickHats[j.get_id()] = [(0, 0)] * j.get_numhats() log.debug("%d joysticks found." % len(self.joysticks)) # Enable music events Music.setEndEvent(MusicFinished) #Music.setEndEvent() #MFH - no event required? # Custom key names self.getSystemKeyName = pygame.key.name pygame.key.name = self.getKeyName self.midi = [] if haveMidi: pygame.midi.init() for i in range(pygame.midi.get_count()): interface, name, is_input, is_output, is_opened = pygame.midi.get_device_info(i) log.debug("Found MIDI device: %s on %s" % (name, interface)) if not is_input: log.debug("MIDI device is not an input device.") continue try: self.midi.append(pygame.midi.Input(i)) log.debug("Device opened as device number %d." % len(self.midi)) except pygame.midi.MidiException: log.error("Error opening device for input.") if len(self.midi) == 0: log.debug("No MIDI input ports found.") else: log.info("MIDI input support is not available; install at least pygame 1.9 to get it.")
def test_resumeTask(self): task = Task() self.task_engine.addTask(task) self.task_engine.pauseTask(task) # paused self.task_engine.resumeTask(task) # resumed self.assertFalse(self.task_engine.tasks[0]['paused']) # resumed
def test_pauseTask(self): task = Task() self.task_engine.addTask(task) self.task_engine.pauseTask(task) self.assertTrue(self.task_engine.tasks[0]['paused']) # paused
def run(self, ticks): Task().run(ticks) # needed to cover Task.run self.running = True self.ticking = ticks