How to begin with USB device design? (usb audio) - Page 1
Forum section: electronics / projects

author: palindrom
author_rank: Newbie
timestamp: April 16, 2017, 06:14:42 pm
content: Hi!In 2010 a friend of mine asked me if I could design headphone amp of decent quality for him. No worries, PCM2704 handled USB, TPA6120 handled power.7 years later I used the same PCM2704 design on next, ultra compact, bus powered headphone amp for other colleague. I thought there's demand for such devices and high res audio is gaining popularity, so it's time to go forward. Especially because I got 600headphones I'd love to drive properly.--All dedicated USB audio interfaces I came across have specs below 192kHz/24bits and that doesn't meet expectations of hi-res audio fans.The most reasonable interfaces out there are XMOS and C-media CM6610A+CM9822A, and I would feed stream to PCM1792a, which is very reasonable DAC.Those USB interfaces are overkill in my opinion. I could land helicopter on footprint of c-media chips if I had one. I just need system to see generic audio interface with defined set of bit depths and speeds. Basically a list of modes supported by DAC. I want to keep it as simple as possible, i.e. -->[controller+eeprom]-spdif->.My question is:where do I begin?How do I choose correct USB controller/micro and how do I set it up to get windows/mac/android see it as generic audio DAC with a list of supported modes and maybe defined manufacturer string?Can you think of articles / books I can read to begin with?Any help appreciated.

author: Gyro
author_rank: Super Contributor
timestamp: April 16, 2017, 06:30:14 pm
content: Hi palindrom, and welcomeQuoteI understand your aim, but I think you're in danger of straying away from real world limits. 192kHz is so far above Nyquist for an audio signal that it shouldn't be an issue, and if you think about 24bit resolution, the LSBs will be so far below system noise (assuming maximum drive of a few hundred mV headphone drive) that it will be impossible to distinguish.Edit: Your first port of call would probably best be USB isolation and decent supply filtering to drop noise levels as low as possible.

author: palindrom
author_rank: Newbie
timestamp: April 16, 2017, 07:03:51 pm
content: Wow, my post counter got reset--Well, it's 10 samples per cycle at the edge of spectrum, and yes, quite a few bits will sunk in noise. The problem with high res files is getting them to play without a hassle of conversion and problems it generates. 192/24 receiver will play anything you throw at it.--USB will be insulated and power power supply I designed in 2010 is linear regulator + EMC insulation for digital rails + leakage inductance and parasitic capacitance effects mitigation + CLC filter on each rail. I took it serious so having 70dB+ PSU noise rejection on amps and DAC will be well enough to take advantage of those few more bits and hertz.

author: Gyro
author_rank: Super Contributor
timestamp: April 16, 2017, 07:25:43 pm
content: QuoteDamn, sorry, I'd forgotten the PCM2704 is only 48kHz.

author: palindrom71
author_rank: Contributor
timestamp: April 16, 2017, 07:46:57 pm
content: Damn! It turn out I already had account on this forum!

author: DaJMasta
author_rank: Super Contributor
timestamp: April 16, 2017, 10:08:25 pm
content: Any reason for SPDIF between your micro and DAC? I believe the usual standard is I2S, and it's widely supported among micros - something like your standard ARM based micro will probably have a port capable of the data rates you're looking at and a USB controller. There are also a number of very high performance dual or more channel DACs that support I2S and the data rates you're looking at - they typically have better performance than equivalently priced ADCs, so it's entirely reasonable to get near -110dB THD+N on a chip that's only a few dollars. That said, I think a lot of high end audio people will be perfectly happy with 24b 96kHz, but often any chip that supports that will also support 192kHz. There's also a number of opamps that give you specifications for a 600 ohm load, while it's probably excessive for your design, I know the AD797 among others list performance with a 600 ohm load.While I understand wanting to make something as a project as much as anyone else... is there a compelling reason for doing it yourself in this case? There are MANY commercial options with very good performance that aren't super expensive. It's still valid to want to do it yourself, but I don't think the features or performance you're looking for are all that hard to find in commercial products.Since USB isolation is expensive and the data rate needed for two channels at 192KHz, 24 bits is getting close to the 12Mbps usually available from isolators, maybe you can use optical SPDIF for your isolation. Different decoding hardware, but it shouldn't be too hard to find something that would do it and you could avoid using a USB isolator. Another option would be to use a micro to convert unisolated USB to I2S, then isolate the I2S bus from your DAC and output system.

author: danmcb
author_rank: Regular Contributor
timestamp: April 16, 2017, 10:19:08 pm
content: well, FWIW, a discussion about whether 192kHz/24bits really matters or is audible is unlikely to ever be conclusive and only goes over some very well-covered ground, but the OP is quite correct that at least some hifi freaks will expect it.

author: palindrom71
author_rank: Contributor
timestamp: April 17, 2017, 09:56:14 pm
content: Thank you for replies!The USB to I2S converter got me thinking that I chose bad path initially. Having 2x spdif, line in and USB in, I went for spdif as internal format (and input for source switching). Yes, I2S will give me a lot more flexibility. I just foundSilicon Labs CP2114. It looks like it could do the business. Most systems should support it without drivers. I'll have to convert spdif and make second switch for analog input(s), but that shouldn't be problematic.192/24 is actually current hi-res standard, so if the project succeed I might go for crowdfunding for this. Without proper stickers on the box (>120dB SNR, 192/24) it would probably not take off.

author: Someone
author_rank: Super Contributor
timestamp: April 18, 2017, 12:38:40 am
content: Quote from: palindrom71 on April 17, 2017, 09:56:14 pmThat SiLabs part seems to be a 48kHz fixed sample rate:QuoteWhich is a really bad starting point for people who are obsessive enough about audio to want high sample rates, putting an asynchronous sample rate convertor in the middle is not going to appeal.And even worse the sloppy onboard clock is unable to fully exercise the full 16bit range:http://www.analog.com/media/en/training-seminars/tutorials/MT-007.pdfYou're a long way off being able to design high end audio, perhaps consider improving/modding off the shelf hardware to prove you can make it better first. Just a few minutes on google leads a long way:http://prosound.ixbt.com/interfaces/maudio-microdac24192.shtmlhttp://www.saviaudio.com/product.html

author: technix
author_rank: Super Contributor
timestamp: April 18, 2017, 01:00:29 am
content: Maybe you can try base your design on STM32F405RCT6. That is a 168MHz Cortex-M4F MCU with 192kHz I2S capability, and the USB 2.0 High Speed interface isn't easiest to use as it does not have the High Speed PHY. (Although the USB 2.0 Full Speed interface can still be used.)Couple that to an I2S codec and you should be good to go.

author: DaJMasta
author_rank: Super Contributor
timestamp: April 18, 2017, 03:46:09 am
content: There was someone looking to get easy SPDIF reading for basic data in a thread here a couple weeks back, and it turns out it's a pretty intensive thing to do with a micro. If you do end up going some sort of micro+i2s route, it may be worth getting a micro that can handle SPDIF too (and they tend to be the higher end 150+MHz ones) instead of looking for a different hardware solution... cause you'd probably have to add an expensive dedicated chip or a DSP that would cost more than just going with the more capable micro.It may be looking at any info you can find about the way your OS talks to default audio devices. I'm not familiar myself, but since there are devices that are very cheap and basic functionality seems to be very widespread, there could be an easy way to get a generic audio driver to ID your device so you didn't have to do any mucking around in driver software or getting a chip that advertises its own driver support.

author: theatrus
author_rank: Frequent Contributor
timestamp: April 18, 2017, 02:46:25 pm
content: The hard part with SPDIF is the clock recovery (and get the recovered clock jitter down). If you limited yourself to 96kHz the DIR9001 is a great drop in solution. The DIX9211 is overkill but at least could do the job.For USB, a micro controller solution with the appropriate USB audio class driver is probably the best bet. Perhaps tear down a few existing designs to see what they have on the digital side.

author: NiHaoMike
author_rank: Super Contributor
timestamp: April 18, 2017, 03:50:35 pm
content: The DIX9211 is actually quite easy to use, especially when there's already some initialization code for it.https://github.com/NiHaoMike/OpenDAC-HDRecently, some new USB audio chips have emerged for USB-C smartphones. Not sure where to actually get the bare chips, but they support 24 bit and 96kHz or 192kHz. And the audio quality is very impressive for something that fits in a USB-C plug.

author: palindrom71
author_rank: Contributor
timestamp: April 18, 2017, 06:43:46 pm
content: Quote from: Someone on April 18, 2017, 12:38:40 amWow, I was seriously tired yesterday. It's on the first page of the spec sheet.The good external clock is a must anyway so it's not a problem.DIR9001 and DIX were considered initially but 192kHz could be future selling point (+ playback of most files w/o resampling)Micro was something I wanted to avoidSA9226 looks very interesting. I'll take a look at that. It sells at 10USD per piece.Suddenly USB doesn't look that universal. I thought this would be straight forward input source, came out to be the most complicated.Thank you for answers, I'll see SA9226 and look how they tackle the problem in other commercial stuff.

author: Buriedcode
author_rank: Super Contributor
timestamp: April 19, 2017, 11:24:48 am
content: Most of the 'issues' people have had with USB DAC's is jitter due to the transport method. That and poor power supply filtering.Because your DAC's clock and your host (PC/MAC) clock will be slightly different, often USB-DAC's will run 'isochronous' adjusting their DAC's clock depending on host. Effectively using the host's USB timing and a PLL to generate the sample clock, but there are other methods - like dropping samples - or checking for buffer overrun/underrun. Although I am unsure of the support for it on Mac's, I'm pretty sure the USB audio class 2.0 fully supports 'Asynchronous' transfers on PC's. That is, the device reports back the status of its buffer to the host so it can adjust the number of samples sent per USB transfer to prevent buffer overrun/underrun. This means the clock in your DAC determines the sample clock, which can be as clean/accurate as you would like, no PLL jitter.I think only the latest USB-audio bridge devices are asynchronous, but Microchip has some app notes using the PIC32 for it. It has USB 2.0 HS, I2S port and a fairly reasonable fractional clock generator (for generating sample rates) and the software shouldn't be too difficult - using their USB framework, and configuring the USB audio class to be asynchronous. I did have a working example for a PIC24FJ128GB202 somewhere, but it was a while ago, and I didn't make any noise/jitter measurements as I simply don't have the equipment for it. It could have been dropping samples left right and centre.I think you're right about XMOS. I do see their devices everywhere in the USB audio world, but I thought that was mainly for SRC's and adding EQ/filters. In terms of USB audio, a device just has to get bytes from USB, buffer them, spit them out I2S and report back status - no DSP required.

author: NiHaoMike
author_rank: Super Contributor
timestamp: April 19, 2017, 03:42:05 pm
content: Maybe also look at HDMI? That's directly clocked by the source so there should be no complications with clock recovery.

author: tszaboo
author_rank: Super Contributor
timestamp: April 19, 2017, 04:02:35 pm
content: There are basically 3 options to get USB 24bit/192Khz without years of development:XMOS. Cmedia. There is an open source AVR32 project. That is it. USB audio class 2 is not supported well. All the big semiconductor players dont care about high resolution audio. I dont like any of these choices.