i have successfully utilized pyaudio to read and record microphone data. I would like to do the same for the soundcard output. (i.e. playing a wavfile and open a stream with pyaudio and read frame by frame the soundcard output).
For reading mic i opened a pyaudio stream like the following
stream = pyaud.open(
format = pyaudio.paInt16,
channels = 1,
rate = 22050,
input_device_index = 0,
input = True)
when i change the input_device_index to 1 i get the following error
IOError: [Errno Invalid number of channels] -9998
Below is the system_info for the macbook soundcard
Default Devices:
================
Default Input Device : 0
defaultSampleRate: 44100.0
defaultLowOutputLatency: 0.01
defaultLowInputLatency: 0.00199546485261
maxInputChannels: 2
structVersion: 2
hostApi: 0 (Core Audio)
index: 0
defaultHighOutputLatency: 0.1
maxOutputChannels: 0
name: Built-in Microph
defaultHighInputLatency: 0.0121541950113
--------------------------------
Default Output Device: 1
defaultSampleRate: 44100.0
defaultLowOutputLatency: 0.00655328798186
defaultLowInputLatency: 0.01
maxInputChannels: 0
structVersion: 2
hostApi: 0 (Core Audio)
index: 1
defaultHighOutputLatency: 0.0167120181406
maxOutputChannels: 2
name: Built-in Output
defaultHighInputLatency: 0.1
--------------------------------
Some soundcards have 'Capture' channels, which is the output of the soundcard. They may or may not work correctly (there seems to have been pressure from the music industry to eliminate those ports).
The following is for Linux... Eg. on my system, I only have a standard, on-board ALC887 audio port. In /proc/asound/card0, I find a port pcm2c, which has the following info:
card: 0
device: 2
subdevice: 0
stream: CAPTURE
id: ALC887-VD Alt Analog
name: ALC887-VD Alt Analog
subname: subdevice #0
class: 0
subclass: 0
subdevices_count: 1
subdevices_avail: 1
These capture devices should show up in your audio mixer.