コード例 #1
0
ファイル: microphone.py プロジェクト: JosephGlavan/psychopy
    class _Recorder(object):
        """Class for internal object to make an audio recording using pyo.

        Never needed by end-users; only used internally in __init__:
            self.recorder = _Recorder(None) # instantiate, global
        Then in record(), do:
            self.recorder.run(filename, sec)
        This sets recording parameters, starts recording.
        To stop a recording that is in progress, do
            self.stop()
        This class never handles blocking; AudioCapture has to do that.

        Motivation: Doing pyo Record from within a function worked most of the time,
        but failed catastrophically ~1% of time with a bus error. Seemed to be due to
        a namespace scoping issue, which using globals seemed to fix; see pyo mailing
        list, 7 April 2012. This draws heavily on Olivier Belanger's solution.
        """
        def __init__(self):
            self.running = False
        def run(self, filename, sec, sampletype=0, buffering=16, chnl=0, chnls=2):
            self.running = True
            inputter = Input(chnl=chnl, mul=1)  # chnl from pyo.pa_get_input_devices()
            self.recorder = Record(inputter, filename, chnls=chnls, fileformat=0,
                                sampletype=sampletype, buffering=buffering)
            Clean_objects(sec, self.recorder).start()  # handles recording offset
            threading.Timer(sec, self._stop).start()  # set running flag False
        def stop(self):
            self.recorder.stop()
            self._stop()
        def _stop(self):
            self.running = False
コード例 #2
0
 def run(self, filename, sec, sampletype=0, buffering=16, chnl=0, chnls=2):
     self.running = True
     inputter = Input(chnl=chnl, mul=1)  # chnl from pyo.pa_get_input_devices()
     self.recorder = Record(inputter, filename, chnls=chnls, fileformat=0,
                         sampletype=sampletype, buffering=buffering)
     Clean_objects(sec, self.recorder).start()  # handles recording offset
     threading.Timer(sec, self._stop).start()  # set running flag False
コード例 #3
0
    class _Recorder(object):
        """Class for internal object to make an audio recording using pyo.

        Never needed by end-users; only used internally in __init__:
            self.recorder = _Recorder(None) # instantiate, global
        Then in record(), do:
            self.recorder.run(filename, sec)
        This sets recording parameters, starts recording.
        To stop a recording that is in progress, do
            self.stop()
        This class never handles blocking; AudioCapture has to do that.

        Motivation: Doing pyo Record from within a function worked most of the time,
        but failed catastrophically ~1% of time with a bus error. Seemed to be due to
        a namespace scoping issue, which using globals seemed to fix; see pyo mailing
        list, 7 April 2012. This draws heavily on Olivier Belanger's solution.
        """
        def __init__(self):
            self.running = False
        def run(self, filename, sec, sampletype=0, buffering=16, chnl=0, chnls=2):
            self.running = True
            inputter = Input(chnl=chnl, mul=1)  # chnl from pyo.pa_get_input_devices()
            self.recorder = Record(inputter, filename, chnls=chnls, fileformat=0,
                                sampletype=sampletype, buffering=buffering)
            Clean_objects(sec, self.recorder).start()  # handles recording offset
            threading.Timer(sec, self._stop).start()  # set running flag False
        def stop(self):
            self.recorder.stop()
            self._stop()
        def _stop(self):
            self.running = False
コード例 #4
0
 def __init__(self, file, sec=0, sampletype=0):
     self.running = False
     if file:
         inputter = Input(chnl=0, mul=1)
         self.recorder = Record(inputter,
                                file,
                                chnls=2,
                                fileformat=0,
                                sampletype=sampletype,
                                buffering=4)
         self.clean = Clean_objects(sec, self.recorder)
コード例 #5
0
ファイル: microphone.py プロジェクト: JosephGlavan/psychopy
 def run(self, filename, sec, sampletype=0, buffering=16, chnl=0, chnls=2):
     self.running = True
     inputter = Input(chnl=chnl, mul=1)  # chnl from pyo.pa_get_input_devices()
     self.recorder = Record(inputter, filename, chnls=chnls, fileformat=0,
                         sampletype=sampletype, buffering=buffering)
     Clean_objects(sec, self.recorder).start()  # handles recording offset
     threading.Timer(sec, self._stop).start()  # set running flag False
コード例 #6
0
ファイル: sine_player.py プロジェクト: pl728/lofi-algorithm
    def record_midi_wav(mid_):
        # write mid_ to file
        with open("test.mid", "wb") as bin_file:
            mid_.writeFile(bin_file)

        s = Server().boot().start()

        # create app synth
        midi_reader = Notein()
        amp = MidiAdsr(midi_reader['velocity'])
        pit = MToF(midi_reader['pitch'])
        osc = SineLoop(freq=pit, feedback=0, mul=amp).mix(1)
        rev = STRev(osc, revtime=1, cutoff=4000, bal=0.2).out()

        # create recorder
        rec = Record(rev, buffering=2, filename='beat.wav', quality=0.4)
        clean = Clean_objects(12, rec)
        clean.start()

        midi_reader = MidiFile('test.mid')

        # makeshift infinite loop
        for message in midi_reader.play():
            s.addMidiEvent(*message.bytes())

        s.stop()
コード例 #7
0
ファイル: microphone.py プロジェクト: RainyJupiter/psychopy
 def __init__(self, file, sec=0, sampletype=0):
     self.running = False
     if file:
         inputter = Input(chnl=0, mul=1)
         self.recorder = Record(inputter,
                        file,
                        chnls=2,
                        fileformat=0,
                        sampletype=sampletype,
                        buffering=4)
         self.clean = Clean_objects(sec, self.recorder)