def test_local_app_in_out(): # connect Node.output to Node.input # so copy inaudio buffer to out audio buffer app = pg.mkQApp() dev = PyAudio() dev.configure(nb_channel=2, sample_rate=44100., input_device_index=0, output_device_index=0, format='int16', chunksize=1024) dev.output.configure(protocol='tcp', interface='127.0.0.1', transfermode='plaindata') dev.input.connect(dev.output) dev.initialize() dev.start() def terminate(): dev.stop() dev.close() app.quit() # start for a while timer = QtCore.QTimer(singleShot=True, interval=3000) timer.timeout.connect(terminate) timer.start() app.exec_()
def test_local_app_in_out(): # connect Node.output to Node.input # so copy inaudio buffer to out audio buffer app = pg.mkQApp() dev = PyAudio() dev.configure(nb_channel=2, sample_rate=44100., input_device_index=0, output_device_index=0, format='int16', chunksize=1024) dev.output.configure(protocol='tcp', interface='127.0.0.1', transfertmode='plaindata') dev.input.connect(dev.output) dev.initialize() dev.start() def terminate(): dev.stop() dev.close() app.quit() # start for a while timer = QtCore.QTimer(singleShot=True, interval=3000) timer.timeout.connect(terminate) timer.start() app.exec_()
""" Simple demonstration of streaming data from a PyAudio device to a QOscilloscope viewer. Both device and viewer nodes are created locally without a manager. """ from pyacq.devices.audio_pyaudio import PyAudio from pyacq.viewers import QTriggeredOscilloscope import pyqtgraph as pg # Start Qt application app = pg.mkQApp() # Create PyAudio device node dev = PyAudio() # Print a list of available input devices (but ultimately we will just use the # default device). default_input = dev.default_input_device() print("\nAvaliable devices:") for device in dev.list_device_specs(): index = device['index'] star = "*" if index == default_input else " " print(" %s %d: %s" % (star, index, device['name'])) # Configure PyAudio device with a single (default) input channel. dev.configure(nb_channel=1, sample_rate=44100., input_device_index=default_input, format='int16',
viewer. Both device and viewer nodes are created locally without a manager. """ from pyacq.devices.audio_pyaudio import PyAudio from pyacq.viewers import QOscilloscope import pyqtgraph as pg # Start Qt application app = pg.mkQApp() # Create PyAudio device node dev = PyAudio() # Print a list of available input devices (but ultimately we will just use the # default device). default_input = dev.default_input_device() print("\nAvaliable devices:") for device in dev.list_device_specs(): index = device['index'] star = "*" if index == default_input else " " print(" %s %d: %s" % (star, index, device['name'])) # Configure PyAudio device with a single (default) input channel. dev.configure(nb_channel=1, sampling_rate=44100., input_device_index=default_input, format='int16', chunksize=1024) dev.output.configure(protocol='tcp', interface='127.0.0.1', transfertmode='plaindata') dev.initialize()