Hello,

My code is a userspace application using libusb for now, but this
seems the best place to ask.

I repurposed some USB audio class device code. At this point I've only
changed the descriptor to report as vendor class so nothing else grabs
the device. I can receive and play PCM audio from the device, but
there is popping and clicking. The program I am using is attached; it
is written in Python. The data is saved to RAM and then written to
disk.

The device does not implement the synchronization aspect of the USB
audio class and when it registers as a microphone a normal userland
can read it properly.

During testing I think I noticed behavior related to my issue - for
some reason there will be long runs of zero returned or no data
returned. Usually this happens when a single transfer is scheduled.
Many transfers in a row tend to report the data properly, but from the
audible results I get it seems that runs of zeros still seem to slip
in.

The problem seems more noticeable when using the Python libusb
bindings but it still exists when using libusb directly. Can anyone
suggest what to look into?

Thanks in advance,
     R0b0t1

---

#!/usr/bin/env python3
import usb, numpy as np
import array, wave

def main():
    ds = [d for d in
            usb.core.find(find_all=True, idVendor=0x0000, idProduct=0x0000)]
    d = ds[0]
    d.set_configuration(1)
    d.set_interface_altsetting(interface=1, alternate_setting=1)

    f = wave.open('out.wav', 'wb')
    f.setnchannels(2)
    f.setsampwidth(2)
    f.setframerate(48000)

    t = array.array('B', [])

    try:
        while True:
            t += d.read(0x81, 200 * 1)
    finally:
        print('Saved.')
        f.writeframes(t)
        f.close()

if __name__ == '__main__':
    main()
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to