Ejemplo n.º 1
0
    def terminate(self):
        """ Terminate PortAudio.

        :attention: Be sure to call this method for every
          instance of this object to release PortAudio resources.
        """

        for stream in self._streams:
            stream.close()

        self._streams = set()

        pa.terminate()
Ejemplo n.º 2
0
    def terminate(self):

        """ Terminate PortAudio.

        :attention: Be sure to call this method for every
          instance of this object to release PortAudio resources.
        """

        for stream in self._streams:
            stream.close()

        self._streams = set()

        pa.terminate()
Ejemplo n.º 3
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()



Ejemplo n.º 4
0
print "\nDevices:\n========"

for i in range(max_devs):
    devinfo = p.get_device_info(i)
    print "Number                   : ", i
    print "Name                     : ", devinfo.name
    print "hostApi Index            : ",  devinfo.hostApi
    print "maxInputChannels         : ", devinfo.maxInputChannels
    print "maxOutputChannels        : ", devinfo.maxOutputChannels
    print "defaultLowInputLatency   : ", devinfo.defaultLowInputLatency
    print "defaultLowOutputLatency  : ", devinfo.defaultLowOutputLatency
    print "defaultHighInputLatency  : ", devinfo.defaultHighInputLatency
    print "defaultHighOutputLatency : ", devinfo.defaultHighOutputLatency
    print "defaultSampleRate        : ", devinfo.defaultSampleRate
    print "--------------------------------"

print "\nDefault Devices:\n================"
try:
    print "Input  :", p.get_default_input_device()
except IOError, e:
    print "No Input devices."

try:
    print "Output :", p.get_default_output_device()
except IOError, e:
    print "No Output devices."

p.terminate()