示例#1
0
def listAudioDevices(devNum=None):
    pa.initialize()
    if not devNum:
        for x in range(pa.get_device_count()):
            dev = pa.get_device_info(x)
            print x, dev.name

    else:
        dev = pa.get_device_info(devNum)
        print "device number", devNum, "(", dev.name, ")"
        for y in ["name","structVersion","hostApi","maxInputChannels","maxOutputChannels","defaultLowInputLatency","defaultHighInputLatency","defaultLowOutputLatency","defaultHighOutputLatency"]:
            print "\t", y, ":", dev.__getattribute__(y)
示例#2
0
    def get_device_info_by_index(device_index: int) -> DeviceInfo:
        default_index = Devices.get_real_index(device_index)
        device_info = pa.get_device_info(device_index)

        try:
            device_name = device_info.name.decode('utf-8')
        except UnicodeDecodeError:
            device_name = device_info.name.decode('cp1252')
        default = default_index == device_index

        return DeviceInfo(default, default_index, device_name,
                          device_info.maxInputChannels,
                          device_info.defaultSampleRate)
示例#3
0
文件: pyaudio.py 项目: chai41104/NLP
    def get_device_info_by_index(self, device_index):
        """
        Return the Device parameters for device specified in
        `device_index` as a dictionary. The keys of the dictionary
        mirror the data fields of PortAudio's ``PaDeviceInfo``
        structure.

        :param device_index: The device index
        :raises IOError: Invalid `device_index`.
        :rtype: dict
        """

        return self._make_device_info_dictionary(
            device_index, pa.get_device_info(device_index))
示例#4
0
    def get_device_info_by_index(self, device_index):
        """
        Return the Device parameters for device specified in
        `device_index` as a dictionary. The keys of the dictionary
        mirror the data fields of PortAudio's ``PaDeviceInfo``
        structure.

        :param `device_index`: The device index.
        :raises IOError: Invalid `device_index`.
        :rtype: dict
        """

        return self._make_device_info_dictionary(
            device_index,
            pa.get_device_info(device_index)
            )
示例#5
0
print "\nHost APIs:\n=========="

for i in range(max_apis):
    apiinfo = p.get_host_api_info(i)
    print "Number              : ", i
    print "Name                : ", apiinfo.name
    print "Type                : ", apiinfo.type
    print "Devices             : ", apiinfo.deviceCount
    print "defaultInputDevice  : ", apiinfo.defaultInputDevice
    print "defaultOutputDevice : ", apiinfo.defaultOutputDevice
    print "--------------------------"

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()