USB & HID - Streaming Audio

Go To Last Post
20 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello all,

 

I'm looking to start a new project to remotely control my 2 meter radio. There are probably commercial kits out there, but where is the fun in that?

 

The PC software side I've got taken care of (streaming voice, channel up/down, ptt etc.), however I'm wondering how I could go about streaming audio to a AVR, via USB (preferably HID based) and then output that audio somehow. I assume I could use a DAC to get the sound out?

 

So, my question is, has anyone any tips on talking HID on USB, passing audio over and outputting somehow? The audio should be just a stream of bytes, it's how to reconstruct this for output I'm wondering about. Also, if anyone knows of any dev kits out there that would be handy to prototype this on would welcomed!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DirtyVolts wrote:
I assume I could use a DAC to get the sound out?
Yes

tiny817 has a DAC and an audio app note; the imminent tiny1617 has 3 DAC with one DAC to a pin.

Would be value-added to port V-USB to a tiny 1-series (tinyX, tiny817, tiny1617, etc); would be easier to attach a USB bridge some of which are USB HID.

Might be easier to use an XMEGA's DAC with its USB device controller.

 


Microchip Technology Inc

Microchip

AVR42777: Digital Sound Recorder using DAC with ATtiny817

http://www.microchip.com//wwwAppNotes/AppNotes.aspx?appnote=en592092

via

http://www.microchip.com/wwwproducts/en/attiny817

http://start.atmel.com/#examples/ATtiny817XplainedMini

http://www.microchip.com/DevelopmentTools/ProductDetails.aspx?PartNO=ATTINY817-XMINI

http://www.microchip.com/wwwproducts/en/attiny1617

http://www.avrfreaks.net/forum/attiny417-attiny814-attiny816-attiny817

https://github.com/obdev/v-usb

 

Edit : strikethru

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Wed. Apr 19, 2017 - 10:28 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DirtyVolts wrote:
I assume I could use a DAC to get the sound out?

Or PWM.

 

DirtyVolts wrote:
preferably HID based

Why not use an actual USB audio profile?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First thought was to suggest some ARM, like the popular stm32f103R8T6 with hardware support for USB and I2S audio out. But:

There are a gazillion different chips already designed for USB to audio output.

PCM2704 is one of them, and on sites like Ebay / Ali you can buy a shitload of usb dac's for the price of a postage stamp.

So there's no need for a uC for USB -> Audio and no need to write software. Just load a driver for the chip you plugged in USB.

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey gchapman, thanks so much for those links and references! Will digest those as soon as possible. Certainly a lot to get me going.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

DirtyVolts wrote:
I assume I could use a DAC to get the sound out?

Or PWM.

 

DirtyVolts wrote:
preferably HID based

Why not use an actual USB audio profile?

 

 

Interesting, hadn't thought of PWM - Interested to see how this would work out.

 

Also, and paulvdh mentioned this as well, the reason I wanted a HID based device was that I'll need other control options, such as frequency up, frequency down, push to talk etc that I assume wouldn't be available on a dedicated audio profile.

Last Edited: Thu. Apr 20, 2017 - 01:43 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lots of good options mentioned above.

 

If you want to use an AVR instead of an ARM or other USB/Audio chip, then an option might be:

 

FTDI USB chip, (serial port emulation, not HID, and therefore, IIRC, a faster data rate is possible); feeding an XmegaE5, (which has a 32 MHz speed, faster than the Mega's and Tiny's, and has a DAC).

 

One could then intermix occasional control commands mixed in with the audio data stream, going to the Xmega. 

(Change channel, adjust squelch Up/Down, change transmitter power setting, etc.).

 

One could also query the Xmega for current settings from the Radio, if it is possible for the uC to read such data from the radio, and report it back to the PC.

 

Sounds like a great project!

 

JC

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:

Lots of good options mentioned above.

 

If you want to use an AVR instead of an ARM or other USB/Audio chip, then an option might be:

 

FTDI USB chip, (serial port emulation, not HID, and therefore, IIRC, a faster data rate is possible); feeding an XmegaE5, (which has a 32 MHz speed, faster than the Mega's and Tiny's, and has a DAC).

 

One could then intermix occasional control commands mixed in with the audio data stream, going to the Xmega. 

(Change channel, adjust squelch Up/Down, change transmitter power setting, etc.).

 

One could also query the Xmega for current settings from the Radio, if it is possible for the uC to read such data from the radio, and report it back to the PC.

 

Sounds like a great project!

 

JC

 

 

Hey, good points. I had thought of going the emulated serial port way, however I've done a few projects using this approach and I fancied pushing myself a little and getting in to the guts of USB.

 

Whatever I do it will be open source, so ping me if you are interested and I'll make an effort to actually write up stuff as I go.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Paulvdh wrote:
First thought was to suggest some ARM, like the popular stm32f103R8T6 with hardware support for USB and I2S audio out.
... and most of the SAM G which have I2S, PDM for digital microphones, and USB.

Some of the AVR32 UC3 have an Audio Bitstream DAC (ABDAC) and have a USB Audio profile; might be able to combine USB audio and HID into USB composite.

 


http://www.atmel.com/products/microcontrollers/arm/sam-g.aspx

http://asf.atmel.com/docs/latest/applications.html (Category pull-down menu, Audio)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

HID for the controls, audio class for the audio stream? I believe it should be possible on the same device. The term to search for is "composite device".

Perhaps get the book "USB complete" by Jan Axelsson. Not excellent but "decent" - and there are few books on USB.. (Amusing coincidence - I'm actually browsing it while commuting to work this week..)

Dean Cameras USB framework for AVRs (LUFA) have a composite device example IIRC.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Thu. Apr 20, 2017 - 06:31 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Raspberry pi - problem solved. Can do text to speech as well.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Atmel/Microchip have an appnote on composite devices: http://www.atmel.com/images/doc7805.pdf

Re the RPi: Apart from "where's the fun in that?", +1.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Thu. Apr 20, 2017 - 06:34 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What bandwidth is the streamed audio anyway? For "fidelity" I doubt you are going to hack it with PWM (you sure won't be doing 2 (stereo) channels of 44.1kHz audio that way!) so I think it will require a DAC.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The audio bandwidth won't be too high - its for the 2m amateur band (144-148MHz) - about the same as a telephone so 8kHz sampling is ok.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
HID for the controls, audio class for the audio stream? I believe it should be possible on the same device. The term to search for is "composite device". Perhaps get the book "USB complete" by Jan Axelsson. Not excellent but "decent" - and there are few books on USB.. (Amusing coincidence - I'm actually browsing it while commuting to work this week..) Dean Cameras USB framework for AVRs (LUFA) have a composite device example IIRC.

 

Cheers, I had an old copy of USB complete, going way back. I think you are right and might order myself a new updated copy.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
Raspberry pi - problem solved. Can do text to speech as well.

 

Yup, many other ways this could be achieved. I really want to learn a new area and challenge myself, I've done many Pi projects and really want to get more hands on with the hardware.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

What bandwidth is the streamed audio anyway? For "fidelity" I doubt you are going to hack it with PWM (you sure won't be doing 2 (stereo) channels of 44.1kHz audio that way!) so I think it will require a DAC.

 

As Kartman points out in his comment, the audio isn't going to need to be crystal clear. I'd like something akin to ISDN style quality, so was budgeting for a 64kbps stream.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DirtyVolts wrote:
so was budgeting for a 64kbps stream.
Oh right in that case 8KB/s is easily do-able with PWM alone. Also should not be a problem to transport on a 12MHz USB link.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DirtyVolts wrote:
I'd like something akin to ISDN style quality, so was budgeting for a 64kbps stream.
The Opus software codec can meet that with music though will need an ARM Cortex-M (lots of 16-bit math)

There's a megaAVR and tinyAVR ADPCM app note that's up to 40kbps (8-bit, 8KHz signal, PWM output); XMEGA should reach to 64kbps.

 


Fish Logo and Xiph.org

Hydrogen audio 2011 multiformat listening test unofficial results page

64kbit/sec stereo multiformat listening test

by Greg Maxwell (greg@xiph.org)

https://people.xiph.org/~greg/opus/ha2011/

via

Opus Logo

Opus Codec

Comparison

http://www.opus-codec.org/comparison/

AVR336: ADPCM Decoder

http://ww1.microchip.com/downloads/en/AppNotes/doc2572.pdf

via http://www.microchip.com//wwwAppNotes/AppNotes.aspx?appnote=en591192

and http://www.microchip.com/wwwproducts/en/atmega328pb

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for all those links, I'll go over them and harvest as much info as I can.

 

I'm thinking that first steps should be to get a basic project together, much like the power switch example over at V-USB and build up from there.

 

I think a composite device would be a little to complex at this moment, I'm all up for learning however need to be aware of my limitations and learning curve.