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


Python Recorder.stop方法代碼示例

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


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

示例1: MyApp

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import stop [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

示例2: __init__

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

#.........這裏部分代碼省略.........
		'rev sweep',
		'fast sweep',
		'fast rev sweep',
		'pulse',
		'rev pulse',
		'fast pulse',
		'fast rev pulse',
		'fade in',
		'fade out',
		'fast fade in',
		'fast fade out',
		'rainbow!',
	]

	def __init__(self):
		pygame.init()
		self.size=1024,480
		self.screen=pygame.display.set_mode(self.size)
		self.bg=0,0,0
		self.fg=255,255,255
		self.audio_color=0,0,255

		self.first_click=0
		self.last_click=0
		self.clicks=0
		self.last_tick=0

		self.effects={}
		self.function=1
		self.shift=False
		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()
開發者ID:gdkar,項目名稱:beat-off,代碼行數:70,代碼來源:beat.py

示例3: Gui

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import stop [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

示例4: ArgumentParser

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import stop [as 別名]
    parser = ArgumentParser(description="""\
Copy n seconds from source video to destination.""",
                           )
    parser.add_argument('-s', '--seconds', dest='seconds', type=int, default=5)
    parser.add_argument(nargs=1, dest='in_file', type=str)
    parser.add_argument(nargs=1, dest='out_file', type=str)
    args = parser.parse_args()
    
    args.in_file = path(args.in_file[0])
    args.out_file = path(args.out_file[0])
    if args.in_file.abspath() == args.out_file.abspath():
        raise ValueError, 'Input path and output path must be different.'
    
    return args


if __name__ == '__main__':
    from safe_cv import cv

    args = parse_args()
    cap_config = CVCaptureConfig(args.in_file, type_='file')
    r = Recorder(cap_config, args.out_file)

    print 'start recording'
    r.record()

    sleep(args.seconds)

    print 'stop recording'
    r.stop()
開發者ID:cfobel,項目名稱:opencv_helpers,代碼行數:32,代碼來源:recorder_test.py

示例5: DreamCatcher

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import stop [as 別名]
class DreamCatcher(object):
    def __init__(self):
        config = read_config()
        self._path = os.path.abspath(
            config.get('directories', 'sessions'))
        self._recorder = None
        self._display_index = 0 # Text to show in root menu
        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 update_root_menuitem(self):
        if self._recorder == None:
            return 

        def pow():
            return "Sig. Pow.\n{0:.2f}".format(
                self._recorder.signal_power)

        def level():
            return "Sleep Lvl.\n{0:.2f}".format(
                self._recorder.sleep_level)

        def hb():
            return "Est. Hb.\n{0:.2f}".format(
                self._recorder.hb)

        def breath():
            return "Est. Breath.\n{0:.2f}".format(
                self._recorder.breath)

        def be_clever():
            config = read_config()
            min = config.getfloat('recorder', 'power_min')
            pow = self._recorder.signal_power
            if pow < min:
                return "Thinking:\nNot in bed."
            else:
                level = self._recorder.sleep_level
                if level > 0:
                    return "Thinking:\nAwake."
                elif level > -0.5:
                    return "Thinking:\nLight sleep."
                else:
                    return "Thinking:\nSleeping."

        func = [pow, level, hb, breath, be_clever][self._display_index]
        self._root_item.header = func()
        self._display_index += 1
        if self._display_index > 4 :
            self._display_index = 0
        
 
    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[:]
#.........這裏部分代碼省略.........
開發者ID:SirHegel77,項目名稱:DreamCatcher,代碼行數:103,代碼來源:dreamcatcher.py

示例6: parse_args

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import stop [as 別名]
if __name__ == '__main__':
    args = parse_args()

    if args.fourcc is None:
        for c in preferred_codecs:
            if CodecTest.test_codec(c):
                args.fourcc = c
                break
        if args.fourcc is None:
            print 'Default codecs not supported on this system.'
            print_codec_list()
            raise SystemExit
    elif not CodecTest.test_codec(args.fourcc):
        print 'Unsupported codec: %s\n' % args.fourcc
        raise SystemExit

    cam_cap = CameraCapture()
    info = cam_cap.get_record_framerate_info(args.fourcc)
    target_fps = min(args.fps, int(0.95 * info.mean_framerate))

    r = Recorder(args.out_file, cam_cap, fps=target_fps, codec=args.fourcc, auto_init=True)
    r.record()
    sleep(args.seconds)

    log = r.stop()

    log.print_summary()
    log.save(args.out_file.parent.joinpath('%s.dat' % args.out_file.namebase))
    print 'DONE'
    del cam_cap
開發者ID:cfobel,項目名稱:opencv_helpers,代碼行數:32,代碼來源:test_recorder.py

示例7: _recordaction

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import stop [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

示例8: DreamCatcher

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import stop [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.stop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。