當前位置: 首頁>>代碼示例>>Python>>正文


Python Recorder.start方法代碼示例

本文整理匯總了Python中recorder.Recorder.start方法的典型用法代碼示例。如果您正苦於以下問題:Python Recorder.start方法的具體用法?Python Recorder.start怎麽用?Python Recorder.start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在recorder.Recorder的用法示例。


在下文中一共展示了Recorder.start方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import start [as 別名]
def main():
    parser = OptionParser()
    parser.add_option('-v', '--verbose',
                      dest='verbose', action='store_true', default=False,
                      help='verbose output')
    (options, args) = parser.parse_args()
    verbose = options.verbose
    if verbose:
        print 'verbose output mode.'

    if len(args) == 0:
        print 'no input files.'
        exit

    filename = args[0]
    if verbose:
        print 'filename: ' + filename
    p = Player(filename)

    r = Recorder()
    r.start()

    pl = plotter(p, r)
    th = Thread(target=pl)
    th.daemon = True
    th.start()

    p.run()
開發者ID:hirofumi0810,項目名稱:karaoke,代碼行數:30,代碼來源:karaoke.py

示例2: MyApp

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import start [as 別名]
class MyApp( wxApp ):
   def OnInit( self ):
      self.recorder=Recorder()
      self.res   = wxXmlResource( GUI_FILENAME )
      self.frame = self.res.LoadFrame( None, GUI_MAINFRAME_NAME )
      self.frame.Show()
        
      EVT_BUTTON(self.frame, XRCID("button_quit"), self.onClick)
      EVT_BUTTON(self.frame, XRCID("button_start"), self.onClick)
      EVT_BUTTON(self.frame, XRCID("button_stop"), self.onClick)

      in_src = XRCCTRL(self.frame, "choice_inputsource")
      for n in self.recorder.getDeviceNames():
         in_src.Append(n)
      in_src.SetSelection(0)
      
      self.frame.Bind(EVT_IDLE, self.onIdle)
      
      return 1

   def onIdle(self, evt):
      if self.recorder.status == RECORDING:
         self.recorder.process()
         XRCCTRL(self.frame, "main_frame_statusbar").SetStatusText("bytes written: " +str(self.recorder.bytesWritten()),0)
      evt.Skip()
        
   def onClick(self, evt):
      btn = evt.GetEventObject()
      name = evt.GetEventObject().GetName()
       
      if name == "button_start":
         self.startRecording()
         btn.Disable()
         XRCCTRL(self.frame, "button_stop").Enable()
          
      elif name == "button_stop":
         self.stopRecording()
         btn.Disable()
         XRCCTRL(self.frame, "button_start").Enable()

      else:
         self.quitApplication()
         
   def quitApplication(self):
      self.frame.Close(true)
       
   def startRecording(self):
      self.recorder.setDevice(XRCCTRL(self.frame, "choice_inputsource").GetStringSelection())
      
      file = wxFileSelector("Select file to save mp3 audio to")
      self.recorder.start(open(file,"wb"))
       
   def stopRecording(self):
      self.recorder.stop()
開發者ID:petri,項目名稱:mp3recorder,代碼行數:56,代碼來源:app.py

示例3: main

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import start [as 別名]
def main():
    # start recording -> 5 sec default
    recorder = Recorder()
    frames = recorder.start(5)
    recorder.write_wav(frames, "input.wav")

    # load the hum and process
    hum = track_pitch("input.wav")
    timeseries(hum)
    process(hum)

    """
開發者ID:NISH1001,項目名稱:humT,代碼行數:14,代碼來源:main.py

示例4: __init__

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import start [as 別名]

#.........這裏部分代碼省略.........
		self.forever=False
		self.forever_patterns={}
		self.forever_fn={}
		self.last_stop=0
		self.recording=False
		self.recorded={}
		self.coarse_grain=1
		self.fine_grain=4
		self.saved_patterns={}
		self.rec_pat=None
		self.kb_map=[0,1,2]
		self.last_effect=collections.deque()

		self.r=Recorder()
		self.tb=TimeBase()
		self.tb.register_tickfn(self.tick)
		if len(sys.argv)>=2 and sys.argv[1]=='fake':
			b=[FakeSingleBespeckleDevice('/dev/ttyUSB0',115200)]
		else:
			b = []
			for i in range(10):
				try:
					b.append(SingleBespeckleDevice('/dev/ttyUSB%d' % i, 3000000))
					if len(b) >= 4:
						break
				except:
					pass

		self.oa=OutputAdapter(b,self.tb)
		self.oa.add_reset()

		self.seq=Sequencer(self.tb,self.oa)

		self.oa.start()
		self.r.start()
		self.tb.start()
		self.seq.start()

		while True:
			quit=False
			for event in pygame.event.get():
				if event.type==pygame.QUIT: quit=True
				if event.type==pygame.KEYDOWN:
					if event.key==self.KEY_TAP:
						self.tap()
					elif event.key==self.KEY_PHASE:
						self.phase()
					elif event.key==pygame.K_UP:
						self.tempo_adjust(1.)
					elif event.key==pygame.K_DOWN:
						self.tempo_adjust(-1.)
					elif event.key in self.KEYBOARD:
						self.effect(self.KEYBOARD[event.key])
					elif event.key==pygame.K_TAB:
						self.start_recording()
					elif event.key in self.PATTERN_KEYS:
						k=self.PATTERN_KEYS[event.key]
						if self.rec_pat is not None:
							self.save_pattern(k)
						else:
							p=self.pattern_map(k)
							if self.forever:
								if k in self.forever_patterns:
									self.remove_pattern(self.forever_patterns[k])
									self.forever_patterns.pop(k)
								elif p is not None:
開發者ID:gdkar,項目名稱:beat-off,代碼行數:70,代碼來源:beat.py

示例5: PypoFile

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import start [as 別名]
    pfile = PypoFile(media_q)
    pfile.daemon = True
    pfile.start()

    pf = PypoFetch(pypoFetch_q, pypoPush_q, media_q, telnet_lock)
    pf.daemon = True
    pf.start()

    pp = PypoPush(pypoPush_q, telnet_lock)
    pp.daemon = True
    pp.start()

    recorder = Recorder(recorder_q)
    recorder.daemon = True
    recorder.start()

    stat = ListenerStat()
    stat.daemon = True
    stat.start()

    # all join() are commented out because we want to exit entire pypo
    # if pypofetch is exiting
    # pmh.join()
    # recorder.join()
    # pp.join()
    pf.join()

    logger.info("pypo fetch exit")
    sys.exit()
開發者ID:Cougar,項目名稱:Airtime,代碼行數:31,代碼來源:pypocli.py

示例6: Gui

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import start [as 別名]
class Gui(QtGui.QWidget):

    # =========================================================================
    def __init__(self, parent=None):

        super(Gui, self).__init__(parent)

        self.videoComboBox = QtGui.QComboBox(self)
        self.videoComboBox.currentIndexChanged.connect(self.videoIndexChanged)

        self.audioComboBox = QtGui.QComboBox(self)
        self.audioComboBox.currentIndexChanged.connect(self.audioIndexChanged)

        self.recordPushButton = QtGui.QPushButton(self)
        self.recordPushButton.setCheckable(True)
        self.recordPushButton.clicked.connect(self.recordClicked)

        separator = QtGui.QFrame(self)
        separator.setFrameStyle(QtGui.QFrame.HLine|QtGui.QFrame.Sunken)

        layout = QtGui.QVBoxLayout(self)
        layout.addWidget(self.videoComboBox)
        layout.addWidget(self.audioComboBox)
        layout.addWidget(separator)
        layout.addWidget(self.recordPushButton)

        self.setLayout(layout)
        self.resetToDefault()

    # =========================================================================
    def resetToDefault(self):

        self.video = Video()
        self.audio = Audio()

        self.populateVideoComboBox()
        self.populateAudioComboBox()

        self.recordPushButton.setIcon(QtGui.QIcon(os.path.join(scriptDir, 'rec_btn_off.svg')))
        self.recordPushButton.setChecked(False)
        self.recordPushButton.setEnabled(False)

    # =========================================================================
    def populateVideoComboBox(self):

        self.videoComboBox.clear()
        self.videoComboBox.addItem('Select video screen...')

        for screen in self.video.screens:
            comboBoxItem = 'Screen {i}, size {s}'.format(
                    i=self.videoComboBox.count(), s=screen.size)

            self.videoComboBox.addItem(comboBoxItem)

    # =========================================================================
    def populateAudioComboBox(self):

        self.audioComboBox.clear()
        self.audioComboBox.addItem('Select audio device...')

        for device in self.audio.devices:
            comboBoxItem = '{d}'.format(d=device.description)
            self.audioComboBox.addItem(comboBoxItem)

    # =========================================================================
    def videoIndexChanged(self, index):

        if index:
            self.video.screenSet(index - 1)

        self.checkEnableRecord()

    # =========================================================================
    def audioIndexChanged(self, index):

        if index:
            self.audio.deviceSet(index - 1)

        self.checkEnableRecord()

    # =========================================================================
    def recordClicked(self):

        if self.recordPushButton.isChecked():
            self.videoComboBox.setEnabled(False)
            self.audioComboBox.setEnabled(False)
            self.recordPushButton.setIcon(QtGui.QIcon(os.path.join(scriptDir, 'rec_btn_on.svg')))

            self.startRecorder()
        else:
            self.videoComboBox.setEnabled(True)
            self.audioComboBox.setEnabled(True)
            self.recordPushButton.setIcon(QtGui.QIcon(os.path.join(scriptDir, 'rec_btn_off.svg')))

            self.stopRecorder()

    # =========================================================================
    def checkEnableRecord(self):

        if self.videoComboBox.currentIndex() and \
#.........這裏部分代碼省略.........
開發者ID:ImageEngine,項目名稱:xcorder,代碼行數:103,代碼來源:gui.py

示例7: Timelapse

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import start [as 別名]
class Timelapse(NSObject):
    """ Creates a timelapse video """

    def applicationDidFinishLaunching_(self, notification):
        self.check_dependencies()

        # Initialize recording
        self.recording = start_recording

        # Set correct output paths
        self.recorder_output_basedir = os.path.join(
            dir_base, dir_pictures, dir_app)
        self.encoder_output_basedir = os.path.join(dir_base, dir_movies)

        self.image_dir = self.create_dir(self.recorder_output_basedir)

        # Create a reference to the statusbar (menubar)
        self.statusbar = NSStatusBar.systemStatusBar()

        # Create item in statusbar
        self.statusitem = self.statusbar.statusItemWithLength_(
            NSVariableStatusItemLength)
        self.statusitem.setHighlightMode_(1)  # Highlight upon clicking

        # Create a simple menu and bind it to the status item
        self.menu = self.createMenu()
        self.statusitem.setMenu_(self.menu)

        # Load icons and show them in the statusbar
        self.loadIcons()
        self.setStatus()

    def loadIcons(self):
        self.icon_recording = NSImage.alloc().initWithContentsOfFile_(
            os.path.join("timelapse", dir_resources, image_recording))
        self.icon_idle = NSImage.alloc().initWithContentsOfFile_(
            os.path.join("timelapse", dir_resources, image_idle))

    def setStatus(self):
        """ Sets the image and menu text according to recording status """
        if self.recording:
            self.statusitem.setImage_(self.icon_recording)
            self.recordButton.setTitle_(text_recorder_running)
            self.statusitem.setToolTip_(tooltip_running)
        else:
            self.statusitem.setImage_(self.icon_idle)
            self.recordButton.setTitle_(text_recorder_idle)
            self.statusitem.setToolTip_(tooltip_idle)

    def createMenu(self):
        """ Status bar menu """
        menu = NSMenu.alloc().init()
        # Bind record event
        self.recordButton = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
            text_recorder_idle, 'startStopRecording:', '')
        menu.addItem_(self.recordButton)
        # Quit event
        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
            'Quit', 'terminate:', '')
        menu.addItem_(menuitem)
        return menu

    def startStopRecording_(self, notification):
        if self.recording:
            self.recorder.join()
            # Create timelapse after recording?
            if encode:
                self.encoder = Encoder(
                    self.image_dir, self.encoder_output_basedir)
                self.encoder.start()
        else:
            self.recorder = Recorder(self.image_dir, screenshot_interval)
            self.recorder.start()
        self.recording = not self.recording
        self.setStatus()

    @objc.python_method
    def create_dir(self, base_dir):
        """ Creates a specified directory and the path to it if necessary """
        if create_session_subdir:
            # Create a new subdirectory
            output_dir = os.path.join(base_dir, self.get_sub_dir(base_dir))
        else:
            # Don't create a subdirectory. Use base directory for output
            output_dir = base_dir
        # Create path if it doesn't exist
        try:
            print(output_dir)
            os.makedirs(output_dir)
        except OSError as e:
            print("Error while creating directory:", e)
            exit()
        return output_dir

    @objc.python_method
    def get_sub_dir(self, base_dir):
        """ Returns the next nonexistend subdirectory to base_dir """
        subdir_base = os.path.join(base_dir, subdir_suffix)
        # Check if we can use subdir without any session id
        subdir = subdir_base
#.........這裏部分代碼省略.........
開發者ID:mre,項目名稱:timelapse,代碼行數:103,代碼來源:__main__.py

示例8: DreamCatcher

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import start [as 別名]

#.........這裏部分代碼省略.........
        return delete

    def plot_file(self, timestamp):
        """ Plot selected recording session. """
        def plot():
            logger.info("Plotting %s", timestamp)
            config = read_config()
            self.menu.message = "Plotting..."
            plotter.plot(
                config.get('directories', 'sessions'),
                config.get('directories', 'images'),
                timestamp)
            self.menu.current_item = self._root_item
        return plot

    def update_network_menu(self):
        del self._network_item.items[:]
        for device, ip in ifconfig().items():
            self._network_item.add_item(
                '\n'.join([device, ip])) 

    def update_file_menu(self):
        """ Update file menu sub-items when file menu is activated. """
        del self._file_item.items[:]
        datafiles = iglob(self._path + '/*.data')
        for path, name in (os.path.split(f) for f in datafiles):
            timestamp = name.split('.')[0]
            format = "%d.%m.%Y\n%H:%M"
            date = datetime.fromtimestamp(float(timestamp))
            item = self._file_item.add_item(date.strftime(format))
            item.add_item("Plot", self.plot_file(timestamp))
            item.add_item("Delete", self.delete_file(timestamp))

    def start_recording(self):
        """ Start recording data. """
        if self._recorder == None:
            logger.info("Starting recorder...")
            self._restarts = 0
            self._recorder = Recorder(self._path)
            self._recorder.start()
            self.menu.current_item = self._root_item
            self._toggle_item.header = "Stop\nRecording"
            self._root_item.header = "DreamCatcher\nRecording..."
            self.menu.lcd.backlight(self.menu.lcd.RED)

    def stop_recording(self):
        """ Stop recording data. """
        if self._recorder != None:
            logger.info("Stopping recorder...")
            self._recorder.stop()
            self._recorder = None
            self.menu.current_item = self._root_item
            self._toggle_item.header = "Start\nRecording"
            self._root_item.header = "DreamCatcher"
            self.menu.lcd.backlight(self.menu.lcd.BLUE)

    def record_marker(self):
        """ Record marker. """
        if self._recorder != None:
            self.menu.lcd.backlight(self.menu.lcd.GREEN)
            self._recorder.record_marker()
            sleep(1.0)
            self.menu.lcd.backlight(self.menu.lcd.RED)

    def verify_recorder(self):
        """ Verify worker is running """
開發者ID:SirHegel77,項目名稱:DreamCatcher,代碼行數:70,代碼來源:dreamcatcher.py

示例9: _recordaction

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import start [as 別名]
 def _recordaction(self, action, filename):
     print "Press key sequence for %s, then press <enter>" % action
     recorder = Recorder()
     recorder.start(filename, self._inputdevice)
     sys.stdin.readline();
     recorder.stop()
開發者ID:marclitchfield,項目名稱:grinder,代碼行數:8,代碼來源:configurator.py

示例10: record

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import start [as 別名]
def record(*args):
    """
    records a kitten walking on the keyboard and outputs it into specified file
    """
    recorder = Recorder(options.output)
    print recorder.start()
開發者ID:wschurman,項目名稱:kittenmash,代碼行數:8,代碼來源:kittenmash.py

示例11: DreamCatcher

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import start [as 別名]
class DreamCatcher(object):
    def __init__(self):
        config = read_config()
        self._path = os.path.abspath(
            config.get('directories', 'sessions'))
        self._recorder = None
        self._fan = Fan()
        self.create_menu()

    def create_menu(self):
        """ Create LCD menu. """
        m = LcdMenu()
        self._menu = m

        self._root_item = m.add_item("DreamCatcher", 
            self.record_marker)

        self._toggle_item = self._root_item.add_item(
            "Start\nRecording", self.toggle_recording)

        self._file_item = m.add_item(
            "File", activated=self.update_file_menu)

        self._network_item = m.add_item(
            "Network", activated=self.update_network_menu)

        m.add_item("Exit", self.stop)
        m.add_item("Shut down", self.shut_down)
 
    def delete_file(self, filename):
        """ Delete selected recording session. """
        def delete():
            logger.info("Deleting %s", filename)
        return delete

    def plot_file(self, timestamp):
        """ Plot selected recording session. """
        def plot():
            logger.info("Plotting %s", timestamp)
            config = read_config()
            self.menu.message = "Plotting..."
            plotter.plot(
                config.get('directories', 'sessions'),
                config.get('directories', 'images'),
                timestamp)
            self.menu.current_item = self._root_item
        return plot

    def update_network_menu(self):
        del self._network_item.items[:]
        for device, ip in ifconfig().items():
            self._network_item.add_item(
                '\n'.join([device, ip])) 

    def update_file_menu(self):
        """ Update file menu sub-items when file menu is activated. """
        del self._file_item.items[:]
        datafiles = iglob(self._path + '/*.data')
        for path, name in (os.path.split(f) for f in datafiles):
            timestamp = name.split('.')[0]
            format = "%d.%m.%Y\n%H:%M"
            date = datetime.fromtimestamp(float(timestamp))
            item = self._file_item.add_item(date.strftime(format))
            item.add_item("Plot", self.plot_file(timestamp))
            item.add_item("Delete", self.delete_file(timestamp))

    def start_recording(self):
        """ Start recording data. """
        if self._recorder == None:
            logger.info("Starting recorder...")
            self._restarts = 0
            self._recorder = Recorder(self._path)
            self._recorder.start()
            self.menu.current_item = self._root_item
            self._toggle_item.header = "Stop\nRecording"
            self._root_item.header = "DreamCatcher\nRecording..."
            self.menu.lcd.backlight(self.menu.lcd.RED)

    def stop_recording(self):
        """ Stop recording data. """
        if self._recorder != None:
            logger.info("Stopping recorder...")
            self._recorder.stop()
            self._recorder = None
            self.menu.current_item = self._root_item
            self._toggle_item.header = "Start\nRecording"
            self._root_item.header = "DreamCatcher"
            self.menu.lcd.backlight(self.menu.lcd.BLUE)

    def record_marker(self):
        """ Record marker. """
        if self._recorder != None:
            self.menu.lcd.backlight(self.menu.lcd.GREEN)
            self._recorder.record_marker()
            sleep(1.0)
            self.menu.lcd.backlight(self.menu.lcd.RED)

    def verify_recorder(self):
        """ Verify worker is running """
        if self._recorder != None:
#.........這裏部分代碼省略.........
開發者ID:Paulxia,項目名稱:DreamCatcher,代碼行數:103,代碼來源:dreamcatcher.py


注:本文中的recorder.Recorder.start方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。