__Plasma__
Posts: 29
Joined: Sat Mar 05, 2016 9:31 pm

Re: Analogue audio testing

Tue Apr 19, 2016 5:17 pm

jdb wrote:Use the version from sudo rpi-update 1e84c2891c1853a3628aed59c06de0315d13c4f1 until a fix is pushed.
Excellent that has done the trick and Audio now seems a million times better than it was before. I simply added a ferrite choke to the psu USB lead and changed the driver. Having other issues with the built in browser now but my audio works great.

This should become the default Audio driver for Raspian!

Kind Regards

Plasma

m-h
Posts: 18
Joined: Sun Jan 11, 2015 10:36 pm

Re: Analogue audio testing

Tue Apr 19, 2016 10:34 pm

Hi JDB,
Many thanks for the updates in the firmware.
Audio is improved so much I am now enjoying the standard analogue output over big speakers in my living room.
For my tests I use a picoreplayer 2.04 setup with manually updated start.elf and only the audio_pwm_mode=2 switch.
I've had no stability issues, nor experienced the distorted single channel, but also have not tested all versions as the picore implementation lacks rpi-update.t.m.k.
Some stutters were due to the squeezelight buffer under runs and my Wi-Fi utilization and overcome by increasing buffers.
The distortion in peaks when playing at volume levels between 85 and 100% are obvious audible. And of course easy avoided.
A limited volume setting would help to use this 85-100 range.
Please try and avoid the clipping or wrapping in the final version.
Perhaps in a version "audio_pwm_mode=3" ? you could reduce the noise amplitude in the shaping when nearing the upper and lower limits. I think it woud come down to dynamic range compression, but with the benefits of max analogue output without obvious digital distortion.
Please help me to determine the exact firmware version from start.elf files. Or methods to pull such updates from picore.

Regards Marcel

masa-aud
Posts: 144
Joined: Fri Feb 26, 2016 9:20 am

Re: Analogue audio testing

Wed Apr 20, 2016 12:09 am

Is it sure for signed binary to zero audio level not for unsigned binary in order to avoid zero shift ?

cjan
Posts: 749
Joined: Sun May 06, 2012 12:00 am

Re: Analogue audio testing

Wed Apr 20, 2016 2:52 am

update to #878, still right ear noise?

User avatar
WaLLy3K
Posts: 3
Joined: Wed Apr 20, 2016 4:20 am
Contact: Website

Re: Analogue audio testing

Wed Apr 20, 2016 4:37 am

cjan wrote:update to #878, still right ear noise?
If I understand correctly, there's no update referencing "pwm_sdm" in the most recent update.

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

Re: Analogue audio testing

Wed Apr 20, 2016 9:42 am

WaLLy3K wrote:If I understand correctly, there's no update referencing "pwm_sdm" in the most recent update.
Yes, the fix wasn't ready for the last update. I believe jdb had a fix for the right ear noise and had made some progress on the Kodi dropouts, but he's not submitted a final patch yet. I suspect it will be imminent.

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

Re: Analogue audio testing

Thu Apr 21, 2016 1:34 pm

I can replicate the Kodi issue. It only appears on release builds of the firmware which turns on SMP - debug builds operate on a single VPU core. It affects both menu sounds and the built-in audio player. Not much of a clue as to what's causing it, yet.

Similarly, the output was garbled only in release builds because the compiler helpfully optimised instruction ordering in the noise shaper - swapping an inline asm() and a line of C. I have a local fix for this.
Rockets are loud.
https://astro-pi.org

sylgar
Posts: 26
Joined: Wed Mar 23, 2016 10:39 pm
Contact: Website

Re: Analogue audio testing

Fri Apr 22, 2016 8:00 pm

Thank you for the new firmware (https://github.com/raspberrypi/firmware ... 056764621e)

Analogue sound is perfect, both my ears are happy this time.

Good work!

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

Re: Analogue audio testing

Fri Apr 22, 2016 10:17 pm

For posterity, this is what I ended up with:

Code: Select all

.function pwm_sdm_mod_ord2 ; (int16_t *source, uint32_t *dest, SDM_CONTEXT_T *ctx)
.align 32                  ; ICache line width
   stm       r6-r14,lr,(--sp)
   mov       r9,r0         ; r9 = in
   mov       r8,r2         ; r8 = ctx
   mov       r7,r1         ; r7 = dest
   ld        r2,(r8)       ; r2 = z1_L
   ld        r1,(r8+4)     ; r1 = z1_R
   ld        r5,(r8+8)     ; r5 = z2_L
   ld        r4,(r8+12)    ; r4 = z2_R
   ld        r6,(r8+16)    ; r6 = pwm_bits
   ld        r12,(r8+20)   ; r12 = pwm_offset
   ld        r10,(r8+24)   ; r10 = nsamples
   mov       r0,1
   rsub      r6,32         ; r6 = out_shift
   shl       r11,r0,r6
   sub       r11,1         ; r11 = quant_mask
   addcmpble r10,0,0,done
   ldsh      r3,(r9++)     ; r3 = (L)
   ldsh      r0,(r9++)     ; r0 = (R)
loop:
   ldsh      r13,(r9++)    ; r13 = (L+1)
   ldsh      r14,(r9++)    ; r14 = (R+1)
loop_nopreload:
   shl       r3,16         ; L <<= 16
   shl       r0,16         ; R <<= 16
   adds      r3,r3,r2      ; L = z1_L
   adds      r0,r0,r1      ; R = z1_R
   adds      r3,r3,r2      ; L = z1_L
   adds      r0,r0,r1      ; R = z1_R
   subs      r3,r5,r3      ; L -= z2_L
   subs      r0,r4,r0      ; R -= z2_R
   bic       r5,r3,r11     ; z2_L = L & quant_mask
   bic       r4,r0,r11     ; z2_R = R & quant_mask
   subs      r3,r5,r3      ; L -= z2_R
   subs      r0,r4,r0      ; R -= z2_R
   asr       r5,r6         ; z2_L >>= nbits
   asr       r4,r6         ; z2_R >>= nbits
   add       r5,r12        ; z2_L += offset
   add       r4,r12        ; z2_R += offset
   st        r5,(r7++)     ; z2_L -> (out)
   mov       r5,r2         ; z2_L = z1_L
   st        r4,(r7++)     ; z2_R -> (out)
   mov       r4,r1         ; z2_R = z1_R
   mov       r2,r3         ; z1_L = L
   mov       r1,r0         ; z1_L = R
   mov       r3,r13        ; L = L+1
   mov       r0,r14        ; R = R+1
   addcmpbgt r10,-1,1,loop
   addcmpbgt r10,0,0,loop_nopreload
done:
   st        r2,(r8)
   st        r1,(r8+4)
   st        r5,(r8+8)
   st        r4,(r8+12)
   ldm       r6-r14,pc,(sp++)
.endfn
Which, as far as I can tell from debug tool output, has no ALU stalls except for 1 cycle during predicted branches inside the inner loop, and has register load stalls only when SDRAM is busy.

I think I like this architecture. The last time I did DSP was with a 1GHz TMS320C6210 in university.
Rockets are loud.
https://astro-pi.org

User avatar
WaLLy3K
Posts: 3
Joined: Wed Apr 20, 2016 4:20 am
Contact: Website

Re: Analogue audio testing

Sat Apr 23, 2016 12:38 am

Annoyingly, the rpi-update left me with no ALSA audio over analogue. Omxplayer and compiling hello_audio both worked as expected, but I had the following output for these commands when running as root:

Code: Select all

vcgencmd version
Apr 22 2016 20:15:38
Copyright (c) 2012 Broadcom
version 75efdffdcd609254ec6b1bb39f3558ce765aeb02 (clean) (release)

aplay -l
aplay: device_list:268: no soundcards found...

lsmod
Module                  Size  Used by
bnep                   10340  2
hci_uart               17943  1
btbcm                   5929  1 hci_uart
bluetooth             326105  22 bnep,btbcm,hci_uart
brcmfmac              186535  0
brcmutil                5661  1 brcmfmac
cfg80211              427855  1 brcmfmac
rfkill                 16037  3 cfg80211,bluetooth
bcm2835_gpiomem         3040  0
bcm2835_wdt             3225  0
uio_pdrv_genirq         3164  0
uio                     8000  1 uio_pdrv_genirq
snd_bcm2835            25029  0
snd_pcm                75698  1 snd_bcm2835
snd_timer              19160  1 snd_pcm
snd                    51844  3 snd_bcm2835,snd_timer,snd_pcm
fuse                   83461  1
ipv6                  347530  28
Searching around, I tried a few things that didn't work, but eventually stumbled across "dtparam=audio=on", and added it to /boot/config.txt. It's done the trick!

With "audio_pwm_mode=2" enabled, the sound quality is supremely better with both low and high sound, as well as under heavy load. I hear the minutest crackle over my headphones depending on the song (Audio-Technica ATH-ADG1X), but that doesn't bother me as the Pi is connected to my speakers.
Last edited by WaLLy3K on Sun Apr 24, 2016 3:49 am, edited 1 time in total.

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

Re: Analogue audio testing

Sat Apr 23, 2016 11:35 am

I've updated firmware in rpi-update to still do some of the sdram calibration (but avoid disabling it during the calibration) when audio_pwm_mode=2.

This gets us a step closer to making audio_pwm_mode=2 a default option.

Would be useful if testers can update and confirm there are no regressions.

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

Re: Analogue audio testing

Sat Apr 23, 2016 2:17 pm

I can't see any degradation in quality with the latest firmware. Tested on pi 2 and b+.
Rockets are loud.
https://astro-pi.org

User avatar
WaLLy3K
Posts: 3
Joined: Wed Apr 20, 2016 4:20 am
Contact: Website

Re: Analogue audio testing

Sun Apr 24, 2016 3:45 am

dom wrote:Would be useful if testers can update and confirm there are no regressions.
No noticeable regressions or improvements that I can notice on my Pi 3, since the last update!

sylgar
Posts: 26
Joined: Wed Mar 23, 2016 10:39 pm
Contact: Website

Re: Analogue audio testing

Sun Apr 24, 2016 2:05 pm

Sound is clean on my RPi 2. OS is FreeBSD.

I have some barely noticeable static white noise on analogue output but I also have it when the board is powered off, so it is not related to the firmware.

However, when it is powered on, and if I turn raspberry volume to 0 (which really is a never-happen-edge case) and at the same time scp a huge file, the white noise get more noticeable, sound like more metallic. It may already be the case without audio_pwm_mode=2, surely I just didn't hear it because of all the other white noise which happened in that case.

I am gonna buy ferrite chockes to clip both ends of my USB cable. The Pi is on the same AC plug than TV, speakers, etc..., that doesn't help, should separate all this.

I would clearly make audio_pwm_mode=2 the default. Great work @dom!

tpfkanep
Posts: 16
Joined: Mon Feb 29, 2016 8:34 am

Re: Analogue audio testing

Mon Apr 25, 2016 6:13 pm

dom wrote:I've updated firmware in rpi-update to still do some of the sdram calibration (but avoid disabling it during the calibration) when audio_pwm_mode=2.

This gets us a step closer to making audio_pwm_mode=2 a default option.

Would be useful if testers can update and confirm there are no regressions.
Still having issues with playback of media on kodi with audio_pwm_mode=2, which is only resolved commenting it out.

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

Re: Analogue audio testing

Mon Apr 25, 2016 6:15 pm

I've identified what's causing the Kodi issue with both menu sounds and built-in player. A patch is in the pipeline.
Rockets are loud.
https://astro-pi.org

tpfkanep
Posts: 16
Joined: Mon Feb 29, 2016 8:34 am

Re: Analogue audio testing

Mon Apr 25, 2016 6:25 pm

Thanks

rosswesleyporter
Posts: 10
Joined: Tue Sep 22, 2015 3:53 am

Re: Analogue audio testing

Tue Apr 26, 2016 2:48 am

No noise, no pops -- sounds quite good to me. I just did a quick comparison to a Pi with a basic USB audio adapter. Happily, not much difference to my ears.

Tested with a Pi A+, audio_pwm_mode=2. I did some testing earlier in this thread. I didn't repeat all of that testing. But for me, the big difference is the removal of pops at high volume. Note that I am testing with headphones, not speakers.

Nice work folks.

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

Re: Analogue audio testing

Tue Apr 26, 2016 3:45 pm

Latest rpi-update firmware should contain a fix for Kodi stuttering issues.

Additionally, this may tangentially improve behaviour with Squeezelite in mmap'ed mode.
Rockets are loud.
https://astro-pi.org

User avatar
Taxicletter
Posts: 218
Joined: Sat Mar 05, 2016 4:25 pm
Location: Antwerp, Belgium
Contact: Website

Re: Analogue audio testing

Tue Apr 26, 2016 9:49 pm

Where can we see if the bug is fixed?
--::--::- 3 x Raspberry Pi 3 - Raspbian Lite 9 - RuneAudio - one broke (wifi) - not in use -::--::--

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

Re: Analogue audio testing

Wed Apr 27, 2016 10:06 am

Taxicletter wrote:Where can we see if the bug is fixed?
Before the fix in Kodi gui then gui sounds were delayed by a couple of seconds.
After the fix they are responsive.

tpfkanep
Posts: 16
Joined: Mon Feb 29, 2016 8:34 am

Re: Analogue audio testing

Wed Apr 27, 2016 10:34 am

jdb wrote:Latest rpi-update firmware should contain a fix for Kodi stuttering issues.
So far so good on both audio & video files on kodi. Deadbeef still working great - seems not to have been affected by this update.

Once again, many thanks to all involved for taking the time & effort to fix this.

mkkyah
Posts: 31
Joined: Fri Jan 25, 2013 2:32 pm

default Audio device disappeared after last rpi-update!

Thu Apr 28, 2016 11:53 am

It was working fine with Apr 6 firmware; after a rpi-update to Apr 22 I have no default analog output device listed.
This is happened on 2 Max2play devices. :cry:
I have also tried sudo rpi-update 1e84c2891c1853a3628aed59c06de0315d13c4f1 to have them back, but it didn't work.

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

Re: Analogue audio testing

Thu Apr 28, 2016 11:55 am

Is the line dtparam=audio=on present in /boot/config.txt?
Rockets are loud.
https://astro-pi.org

mkkyah
Posts: 31
Joined: Fri Jan 25, 2013 2:32 pm

Re: Analogue audio testing

Thu Apr 28, 2016 12:23 pm

jdb wrote:Is the line dtparam=audio=on present in /boot/config.txt?
Yes, adding that line to config.txt brought back the audio device. And sorry, I have seen the solution a few posts above!

I think the fix for "mmap'ed mode" in squeezelite is also working, I have set one of my players with "80:4:16:1" parameters and it's playing well so far.

Return to “Advanced users”