xxxstarmanxxx
Posts: 42
Joined: Fri Sep 16, 2011 3:35 pm
Contact: Website

Poor analog audio from 3.5mm Jack in raspbmc

Mon Jun 18, 2012 8:37 am

Just posting some findings using headphones via the onboard 3.5mm audio jack via Raspbmc.

It seems that distortion is present at any audio level in high frequencies using the following test files:

MP4 video with 192kbs AAC audio
MVK video with 384kbs Dolby Digital

I'm not sure if this is being caused by any of the following at present:

Bad screening with the audio jack/board being placed close to the monitor/screen.

5v power issue where the board is running at extreme minimum voltage input.

Codec issue which is causing peeks/clipping (however its present at all volumes).

Any audiofiles out there done any testing of analog audio quality in debian/arch finding the same???

I'm currently powering my Pi via a Motorola lapdock - and will be doing futher testing with 5v 1amp charger today to see if its a voltage thing and will feedback.

Any guidance/knowledge in the meantime would be most apreciated :)

=====================================================
Update : Just fed the board with 5volts @ 1 amp - same results - Its deffo not power related :(

Justin :)

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5171
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Poor analog audio from 3.5mm Jack in raspbmc

Mon Jun 18, 2012 9:14 am

It's by design for cost reasons. There is no audio codec. It is a 1-bit PWM signal with filtering.
The HDMI audio is obviously much better quality.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 11094
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Poor analog audio from 3.5mm Jack in raspbmc

Mon Jun 18, 2012 1:49 pm

That its an 1-bit PWM signal doesn't necessarily mean it gives poor audio quality, many high end CD players in the past used 1-bit converters because of their high quality.
The PWM signal of the RPI is probably not in the same league, but the quality of the RPI has been compared to FM-stereo, so not exactly HiFi, but good enough for most purposes.
Have you tested if the same issues occur when using HDMI audio?

xxxstarmanxxx
Posts: 42
Joined: Fri Sep 16, 2011 3:35 pm
Contact: Website

Re: Poor analog audio from 3.5mm Jack in raspbmc

Mon Jun 18, 2012 3:11 pm

mahjongg wrote:That its an 1-bit PWM signal doesn't necessarily mean it gives poor audio quality, many high end CD players in the past used 1-bit converters because of their high quality.
The PWM signal of the RPI is probably not in the same league, but the quality of the RPI has been compared to FM-stereo, so not exactly HiFi, but good enough for most purposes.
Have you tested if the same issues occur when using HDMI audio?
Hey Mahjongg - Yes this is an issue that only affects analog audio - HDMI is perfect - Gutted as its taken the shine off my Lapdock project.

I'd hoped to have a nice portable HD player although there is no point in it being portable with such poor analog output. I still can't decide if its actually 'clipping' rather than electrostatic coming through the board.

Either way analog audio really is pants on the board :(

Justin

slacker
Posts: 33
Joined: Wed Dec 07, 2011 9:12 pm

Re: Poor analog audio from 3.5mm Jack in raspbmc

Mon Jun 18, 2012 5:39 pm

I've done some quick tests on the analogue audio quality. I used audacity to generate a sine wave sweep from 20Hz to 20kHz and saved that as a .wav to play on the Pi. I then played one channel through my Hifi and ran the other channel to an oscilloscope. The signal looks and sounds clean up to about 800Hz, then the distortion start to creep in, by a couple of kHz you can see obvious steps on the edges of the waveform. From then up it looks more and more digital, basically less and less bits, at about 10kHz it's essentially a square wave. Presumably this is caused by a relatively low PWM frequency and the minimal filtering, according to the schematic it's just a single RC low pass filter.
If I get time I'll record the output and post it so people can see what I'm on about.

Having said all that I've used raspbmc quite a bit for youtube and on demand TV stuff and for low quality audio streaming it's perfectly acceptable.

I might experiment with adding some additional filtering, this might improve things a bit, but ultimately the top end is going to be limited by the PWM frequency.

gritz
Posts: 449
Joined: Sat Jan 28, 2012 2:33 am

Re: Poor analog audio from 3.5mm Jack in raspbmc

Mon Jun 18, 2012 8:23 pm

Hi slacker - if you do get around to generating some tones I'd be interested in downloading 'em to take a look (and a listen!)

I'm curious about the pwm rate and the resolution too (the size of the smallest possible step in the mark/space ratio), as well as any possible aliasing in the signal.

Jonathan

lb
Posts: 232
Joined: Sat Jan 28, 2012 8:07 pm

Re: Poor analog audio from 3.5mm Jack in raspbmc

Mon Jun 18, 2012 8:38 pm

In my experience the output quality depends on the impedance of the attached load, and high impedance seems to work better. That means it's not a good idea to attach a headphone directly, but active speakers sound OK.

I'd also like to know what the PWM frequency is (no scope here, or I would know already :)). Maybe it helps quality to increase the PWM frequency - this should shift the noise into ultrasonic range.
Last edited by lb on Mon Jun 18, 2012 8:43 pm, edited 1 time in total.

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: Poor analog audio from 3.5mm Jack in raspbmc

Mon Jun 18, 2012 8:43 pm

Does the PI perform resampling i.e. 44.1KHz -> 48KHz or vice versa I heard if it’s not done correctly high frequencies tend to suffer from nasty artefacts.
Try playback in with different sample rates and see how they sound.

Richard S.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5171
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Poor analog audio from 3.5mm Jack in raspbmc

Mon Jun 18, 2012 8:48 pm

The PWM frequency is:
(audio sample rate)*(1<<pwm_sample_bits)

with pwm_sample_bits=11

We are limited to 100MHz, so we can get to 11 bits @ 48kHz.

We did play with 6 bit samples, and an oversampling factor of 8 using a sigma delta algorithm, but it sounded worse.

aragats
Posts: 5
Joined: Thu Sep 20, 2012 11:21 pm
Location: Colorado

Re: Poor analog audio from 3.5mm Jack in raspbmc

Thu Sep 27, 2012 8:17 pm

Playing music with mplayer has no problem here, the sound is good (might not be perfect though), but with omxplayer it's really distorted and unacceptable. (I'm running Archlinux updated a few days ago)

Chendy
Posts: 4
Joined: Thu May 22, 2014 4:53 pm

Re: Poor analog audio from 3.5mm Jack in raspbmc

Thu May 22, 2014 5:18 pm

Is there any way to run the audio using 12 bit and thus 22 kHz PWM frequency? The top audio frequency would be 11 kHz, but I wondering if this will sound better as an overall compromise?

Cheers

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1792
Joined: Thu Jul 11, 2013 2:37 pm

Re: Poor analog audio from 3.5mm Jack in raspbmc

Thu May 22, 2014 9:37 pm

Wow, a 2-year necro.

In theory, yes you could halve Fs for an additional bit of resolution. However there's not really any point.

Because the PWM output is essentially a weak CMOS buffer driving into an RC filter, most of the distortion stems from the nonlinearities associated with the driver output voltage having a quadratic relationship with the output current.

Decreasing the number of bits of PWM resolution actually improves output linearity at the expense of noise floor. FM quality audio is still all that's realistically manageable due to the hardware, though.
Rockets are loud.
https://astro-pi.org

User avatar
cyrano
Posts: 713
Joined: Wed Dec 05, 2012 11:48 pm
Location: Belgium

Re: Poor analog audio from 3.5mm Jack in raspbmc

Fri May 23, 2014 8:26 pm

Those of us who have audiophile wishes, better look at the Wolfson 2in/2out audio card or a digital out (optical with a tiny add on board or coaxial over the video RCA output). Lemme see if I can find the threads about that stuff...

Here they are:
http://www.raspberrypi.org/forums/viewt ... 7&p=448406
http://www.raspberrypi.org/forums/viewt ... 5&p=550082

User avatar
DougieLawson
Posts: 34168
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Poor analog audio from 3.5mm Jack in raspbmc

Sat May 24, 2014 7:15 am

The output from the 3.5mm jack is at "line-out" levels. It's mostly OK with a reasonable amp.

The output from the Wolfson card is superb, anyone who wants good audio should use that (or use the HDMI audio out).
Note:The use of baseball bats for educational purposes is completely disallowed on this forum.

Any DMs sent on Twitter will be answered next month.

drgeoff
Posts: 8765
Joined: Wed Jan 25, 2012 6:39 pm

Re: Poor analog audio from 3.5mm Jack in raspbmc

Sat May 24, 2014 9:32 am

There are various USB sound cards/modules based on the TI PCM2704 which work well and are usually significantly cheaper than the Wolfson. But might not go higher than 48kHz. Have a search.

User avatar
GTR2Fan
Posts: 1601
Joined: Sun Feb 23, 2014 9:20 pm
Location: South East UK

Re: Poor analog audio from 3.5mm Jack in raspbmc

Sat May 24, 2014 10:17 am

Not as good as the Wolfson obviously, but roughly on a par with the old Soundblaster16 PC sound cards for 44.1/16 playback...

http://www.amazon.co.uk/USB2-0-External ... ters_img_y
Pi2B Mini-PC/Media Centre: ARM=1GHz (+3), Core=500MHz, v3d=500MHz, h264=333MHz, RAM=DDR2-1200 (+6/+4/+4+schmoo). Sandisk Ultra HC-I 32GB microSD card on '50=100' OCed slot (42MB/s read) running Raspbian/KODI16, Seagate 3.5" 1.5TB HDD mass storage.

Return to “Troubleshooting”