USB Audio

Code junkies hangout here

Moderators: ChriThor, LXF moderators

USB Audio

Postby ianbell » Sat Apr 09, 2016 10:46 pm

I am trying to send and receive data to/from a USB audio device. The kernel has already attached a driver to it and it appears in the usb devices file system. The question is how to I communicate with it. I am using Python.

I have tried pyusb but that gains access via libusb which only allows root access. I need a user space access. I know it can be done because programs like Audacity and REW already to this. I have also tries the alsaaudio module but it is poorly documented and I am not sure of its support. There must be an easy way to do this - can I just open it like a file and read write to it and the kernel driver takes care of the rest - that would be ideal.

Cheers

Ian
ianbell
 
Posts: 8
Joined: Tue Feb 06, 2007 1:12 pm

Re: USB Audio

Postby Bazza » Mon Apr 11, 2016 11:28 am

I assume that you have tried pyaudio?
(This uses a derivative of PortAudio to work.)

https://people.csail.mit.edu/hubert/pyaudio/

Or do you want to access the Audio stick HW _directly_?

Plugging it in MIGHT give you either '/dev/dsp' or '/dev/dsp2'...

If either of those appear for the stick then you have access to simple MONO audio record and playback.
At 8 bit unsigned integer depth, mono, sampled at 8KHz this will generate noise, Ctrl-C to quit......

Code: Select all
 cat /dev/urandom > /dev/dsp[2]


......out of the stick's ear port...
73...

Bazza, G0LCU...

Team AMIGA...

The less that I speak, the smarter I sound.
User avatar
Bazza
LXF regular
 
Posts: 1565
Joined: Sat Mar 21, 2009 11:16 am
Location: Loughborough

Re: USB Audio

Postby ianbell » Mon Apr 11, 2016 10:58 pm

I just discovered pyaudio and it looks to be just what I need. I have managed to obtain the list devices and I think I can iterate through them to find the one I want.Unfortunately the docs major on using the default device but that is not what I need.

Thanks for the tip.

I do not have a /dev/dspx but I do have /dev/snd/by-id/ where my device is listed. I'll try your console code there.

Cheers

Ian
ianbell
 
Posts: 8
Joined: Tue Feb 06, 2007 1:12 pm


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest