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 __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 = Audio.MicrophonePassthroughStream(engine, self) self.passthroughStream.setVolume(passthroughVolume) else: Log.debug('Microphone: not creating passthrough stream') self.passthroughStream = None
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, 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, 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 = Audio.MicrophonePassthroughStream( engine, self) self.passthroughStream.setVolume(passthroughVolume) else: Log.debug('Microphone: not creating passthrough stream') self.passthroughStream = None
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 Audio.Music.setEndEvent(MusicFinished) #Audio.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 Audio.Music.setEndEvent(MusicFinished) #Audio.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." )