Example #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
Example #2
0
 def __init__(self, engine, mic):
     Task.__init__(self)
     self.engine = engine
     self.channel = None
     self.mic = mic
     self.playing = False
     self.volume = 1.0
Example #3
0
 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()
Example #4
0
 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()
Example #5
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
Example #6
0
    def merge(self):
        for source in self.sources:
            if not source.fields_map:
                self.alarm('存在映射为空的源:{},请检查!'.format(str(source)))
                return

        task = Task()
        task.add_sources(self.sources)
        task.merge()

        info = '\n{}:\n'.format(datetime.datetime.utcnow())
        for x in task.stats:
            info += '数据源:{}, 标签:{}, 抽取数目:{}, 去重丢弃:{}\n'.format(
                x[0], x[1], x[2], x[3])
        orig_text = self.textEdit_2.toPlainText()
        self.textEdit_2.setText(orig_text + info)

        self.table_info, self.tag_info = task.merge_completed()
Example #7
0
    parser.add_argument(
        "--path",
        "-f",
        required=True,
        help="The path the the file that contains a command per line")
    parser.add_argument("--process",
                        "-p",
                        required=True,
                        help="The number of parallel process",
                        type=int)
    parser.add_argument("--timeout",
                        "-t",
                        help="The maximum execution time (in sec)",
                        type=int,
                        default=None)
    parser.add_argument("--gpu",
                        help="The processes are using a CPU",
                        action='store_true',
                        default=False)

    args = parser.parse_args()
    tasks = []
    with open(args.path, 'r', encoding="utf8") as fd:
        content = fd.read()
        for line in content.split("\n"):
            if len(line.strip()) == 0:
                continue
            tasks.append(Task(line))
    runner = TaskRunner(tasks, args)
    runner.execute()
Example #8
0
    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.")
Example #9
0
    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."
            )