Exemplo n.º 1
0
 def close(self):
     if self._stream is not None:
         try:
             if not pa.is_stream_stopped(self._stream):
                 pa.stop_stream(self._stream)
         finally:
             pa.close(self._stream)
             self._stream = None
Exemplo n.º 2
0
    def stop_stream(self):
        """ Stop the stream. Once the stream is stopped,
        one may not call write or read. However, one may
        call start_stream to resume the stream. """

        if not self._is_running:
            return

        pa.stop_stream(self._stream)
        self._is_running = False
Exemplo n.º 3
0
    def stop_stream(self):

        """ Stop the stream. Once the stream is stopped,
        one may not call write or read. However, one may
        call start_stream to resume the stream. """

        if not self._is_running:
            return

        pa.stop_stream(self._stream)
        self._is_running = False
Exemplo n.º 4
0
    def stop_stream(self):
        """
        Stop the stream. Once the stream is stopped, one may not call
        write or read.  Call :py:func:`start_stream` to resume the
        stream.
        """

        if not self._is_running:
            return

        pa.stop_stream(self._stream)
        self._is_running = False
Exemplo n.º 5
0
    def stop_stream(self):
        """
        Stop the stream. Once the stream is stopped, one may not call
        write or read.  Call :py:func:`start_stream` to resume the
        stream.
        """

        if not self._is_running:
            return

        pa.stop_stream(self._stream)
        self._is_running = False
Exemplo n.º 6
0
stream_output = _portaudio.open(format = FORMAT,
                                channels = CHANNELS,
                                rate = RATE,
                                output = True,
                                frames_per_buffer = chunk)

print "* starting stream"
_portaudio.start_stream(stream_input)
_portaudio.start_stream(stream_output)

print "* recording"

for i in range(0, 44100 / chunk * RECORD_SECONDS):
    data = _portaudio.read_stream(stream_input, chunk)
    _portaudio.write_stream(stream_output, data, chunk)
    
print "* stopping stream"
_portaudio.stop_stream(stream_input)
_portaudio.stop_stream(stream_output)

print "* closing stream"
_portaudio.close(stream_input)
_portaudio.close(stream_output)

# match initialize() with terminate() calls
_portaudio.terminate()



Exemplo n.º 7
0
print "* initializing"
_portaudio.initialize()

print "* opening"
stream = _portaudio.open(format = FORMAT, 
                         channels = CHANNELS, 
                         rate = RATE, 
                         input = True,
                         output = True,
                         frames_per_buffer = chunk)

print "* starting stream"
_portaudio.start_stream(stream)

print "* recording"

for i in range(0, 44100 / chunk * RECORD_SECONDS):
    data = _portaudio.read_stream(stream, chunk)
    _portaudio.write_stream(stream, data, chunk)
    
print "* stopping stream"
_portaudio.stop_stream(stream)

print "* closing stream"
_portaudio.close(stream)

# match all initialize() with terminate() calls
_portaudio.terminate()