5,605,373 Members 42,207 Now Online
XDA Developers Android and Mobile Development Forum

[MOD][TWEAK][03/05] Nexus S: Fidelity 2.0 - Ultimate Low latency audio playback

Tip us?
 
Windows X
Old
(Last edited by Windows X; 3rd May 2012 at 07:51 AM.) Reason: Version 2.0 released
#1  
Senior Member - OP
Thanks Meter 1243
Posts: 722
Join Date: Sep 2006
Default [MOD][TWEAK][03/05] Nexus S: Fidelity 2.0 - Ultimate Low latency audio playback

***WARNING!!! THIS MOD IS FOR PEOPLE WHO LOVE HAVING ULTIMATE AUDIO PLAYBACK SYSTEM ONLY (LOW LATENCY, LINEAR BIT-STREAM, AUDIO PERFORMANCE AT ITS BEST). IT'S NOT AIMED FOR LONG BATTERY LIFE OR FAST/SMOOTH PHONE AND MAY NOT WORK RIGHT ON YOUR PHONE. I'M NOT PROMISING ANYTHING ABOUT SOUND QUALITY IMPROVEMENTS AND DON'T WANT TO DEBATE ABOUT IT***



After spending months in github looking in Voodoo Sound code and gotta admit I have no idea how it could get any better. Finally, i found something interesting to improve sonic quality that can make us audiophiles smile for higher fidelity. Time to say goodbye to Android life with just Voodoo + cool music player alone.

Six months ago...after ICS firstly released, Google patched audiostream buffer in Nexus S' audio library increasing buffer size and latency after fixing latency delay in 4.0.2 and so on. For normal people's perspectives, it should be a good move as we get stable audio stream, more battery friendly and no more delay issue.

However, some purist computer audiophiles may not agree and have strong motto about 'low latency'. Some Windows players like JPLAY and XXHighEnd went far enough to feed single byte buffer feeding audio card. Not that lower is always better as I prefer minimum hardware buffer size over something extraordinary.

Back to the topic, so I messed around with Nexus S' audio library wondering why no one ever tried that before. As this is first attempt, I'll try to make things as extreme as possible according to what it's capable off.

As there're a lot of misconceptions about latency and jitter stuff so I'm not gonna explain how any those stuff will do about audio performance. Better let your ears decide it as it wouldn't hurt to try. Let's see what this brings to you now.



Features:

Features come in build packages below. Make sure to read all of them as you need to carefully pick out the best for your need. I added my own platform optimizations script in version 2.0 and improved audio library according to new platform performance. I also added Galaxy S (I9000) device support and will try to make more devices like Galaxy Tab and Galaxy Nexus in future. Also keep in mind that there's no best sounding build without sacrificing system's stability.



Builds:

platform: This is innovation of the year for all Android.....no for all Linux-based audio systems and technically work on any Android devices too. Specialized platform for lowest possible I/O latency and CPU utilization having audio thread optimized to its finest having real-time I/O with priority at highest level, Voodoo Sound and Color configuration for purist un-altered sound, kernel resource scheduling optimized to highend DAW level, CPU+I/O+kernel optimized for low latency, audio effects being disabled completely and plus_music patched audio library. It'll have to remove all existing scripts in init.d as most of them can screw this ones up. It'll give you best environment to run even more extreme patches in 2.0 at more battery-friendly setup.

plus_general: Designed for battery-friendly build at 10ms latency playback. You can use this on any ROM, kernels, tweaks you like. General build uses original ICS frame buffer size before modifications and trimmed down buffer size to be the same size as ICS frame for direct frame buffer transfer. I recommend getting plus_general if you don't want to get sloppy second like other builds.

plus_music: Also designed for battery-friendly like general but use even smaller frame buffer size to only 128 at 8 frames for 5ms latency playback at stock environment. It's designed for only music playback alone so you may get some playback problems aside from music playback. To make this stable, I increased number of frames in buffer pool from 4 to 8 according to ALSA's ideal specifications. It works fine on most governors but 100MHz or deep idle may cause some problems. This still works fine on most apps except you try having music played in background on intensive apps.

plus_google: This is alternative design for ideal 5ms latency playback based on plus_general design. Frame buffer size being reduce from original ICS frame buffer size (448) to 256 at 4 frames. The reason I picked ALSA's specifications for music is most ALSA drivers configured for low-latency use that but doesn't mean it's generally better than this ones. I personally prefer lower frames rather than lower frame size at same pool size.

extreme_direct: Designed for those who want to go extreme with lowest possible hw/sw buffer design having buffer pool exactly the same size as output buffer. It's plus_music having number of frames in buffer pool trimmed down from 8 to only 2. Yes.....2 for smallest possible frame buffer pool. You need to install optimized platform environment to keep this stable or run it on high performance setup.

extreme_linear: Designed for those who want to go extreme with smallest possible frame buffer size design. It has only 32 frame buffer size (1/32 of normal buffer size) and have 8 frames in buffer pool. I doubt you can run this at stable level without optimized platform. It has highest battery consumption of all but doesn't mean it works the best. Direct design provides fuller dynamics with more depth while this ones gives you richer ambient with smooth sound.

extreme_insane: Designed for those who want to go extreme with everything smallest possible. It has 32 frame buffer size (1/32 of normal buffer size) and only 2 frames in buffer pool making buffer pool 1/4 of other extreme patches. I said insane because it's beyond what this phone is capable of technically. Even in specialized platform on performance govenor may not music played till the end without single spike. You can only try making it stable with steve.garon's filesync off kernel after patching specialized platform. The reason I didn't include his kernel in because it causes occasional reboots and currupt data partition due to disabled filesync running insane task.



Downloads

nexus_s_fidelity_platform

nexus_s_fidelity_plus_general

nexus_s_fidelity_plus_music

nexus_s_fidelity_plus_google

nexus_s_fidelity_extreme_direct

nexus_s_fidelity_extreme_linear

nexus_s_fidelity_extreme_insane

nexus_s_fidelity_restore



Changelog

[03/05/12] Version 2.0
-Added audio thread priority optimizations to highest level
-Added audio I/O priority optimizations to highest real-time level
-Added CPU optimizations for low latency playback
-Added Galaxy S (I9000) device support
-Added kernel resource scheduling optimizations
-Added I/O optimizations for low latency playback
-Changed Voodoo Sound headphone gain to 0db (2db has too high hiss on low impedance phone)
-Fixed clear old scripts in init.d that didn't work last time
-Removed libaudioeffect_jni.so as it increase more load and latency
-Removed DSPManager as it can't be disabled and keep showing error during music playback
-Removed wildestpixel tweaks
-Tweaked audio library improvements
|-plus_music uses library from version 1.0 for Alsa's ideal specifications
|-plus_google added as alternative ideal 5ms design based on Google's Android code
|-extreme_direct now has 1/2 frame buffer size comparing to 1.1 version
|-extreme_linear now has 1/8 frames comparing to 1.1 version
|-extreme_insane added with everything smallest from other extreme patches
|-restore now also remove installed optimizations and restore libaudioeffect_jni.so

[28/04/12] Version 1.1
-Added plus_general for all-around use at 10ms latency playback
-Added plus_music for music focused use at 5ms latency playback
-Added extreme_direct and extreme_linear for non-compromise builds
-Added restore for people who want to use current AOSP build

[27/04/12] Version 1.0
-Initial release with kernel/tweaks for 8x1/8 frame buffer optimized for 5ms latency playback



If you experiences any playback problems, try changing minimum frequency or use suited governors, I/O, CPU settings in NSTools. I'm quite satisfied with battery-life in version 2.0 and never have issue after finalizing version 2.0.
The Following 19 Users Say Thank You to Windows X For This Useful Post: [ Click to Expand ]
 
DaXmax
Old
#2  
DaXmax's Avatar
Recognized Themer
Thanks Meter 10020
Posts: 10,692
Join Date: Sep 2008
Location: Singapore
Sound improvement? Do you have a git or something for us to explore?

Sent from my Nexus S using Tapatalk 2
 
Windows X
Old
(Last edited by Windows X; 27th April 2012 at 05:54 AM.)
#3  
Senior Member - OP
Thanks Meter 1243
Posts: 722
Join Date: Sep 2006
It should give cleaner sound and richer harmonics without oversampling and frequency locked loop as you get 4-8 times less latency jitter. I asked my sister to try it and she said it sounded more relaxed and easier to listen.

IMO, oversampling is bad as it caused aliasing and distortion of band. Frequency locked loop is more like trade-off as you'll get clearer sound at sacrifice of good transient response.
The Following 2 Users Say Thank You to Windows X For This Useful Post: [ Click to Expand ]
 
DaXmax
Old
#4  
DaXmax's Avatar
Recognized Themer
Thanks Meter 10020
Posts: 10,692
Join Date: Sep 2008
Location: Singapore
Quote:
Originally Posted by Windows X View Post
It should give cleaner sound and richer harmonics without oversampling and frequency locked loop as you get 4-8 times less latency jitter. I asked my sister to try it and she said it sounded more relaxed and easier to listen.

IMO, oversampling is bad as it caused aliasing and distortion of band. Frequency locked loop is more like trade-off as you'll get clearer sound at sacrifice of good transient response.
If i wanna compile, do you have sources to this?

Sent from my Nexus S using Tapatalk 2
 
Windows X
Old
#5  
Senior Member - OP
Thanks Meter 1243
Posts: 722
Join Date: Sep 2006
This should give you a clue

https://github.com/AOKP/device_samsu...246a1c785a6d3c

FYI: This is libaudio at its extremist. It's supposed to work alright with 100% performance mode without battery saving trick. Thanks to lazy/sio combination brought by wildestpixel that saved my day.
The Following User Says Thank You to Windows X For This Useful Post: [ Click to Expand ]
 
RcrdBrt
Old
#6  
RcrdBrt's Avatar
Senior Member
Thanks Meter 457
Posts: 477
Join Date: May 2011
Location: Italy

 
DONATE TO ME
Whoa!
Nice stuff! Waiting for source code or a patch to be released to take a look on it
Great work
 
Windows X
Old
(Last edited by Windows X; 27th April 2012 at 06:16 AM.)
#7  
Senior Member - OP
Thanks Meter 1243
Posts: 722
Join Date: Sep 2006
Quote:
Originally Posted by RcrdBrt View Post
Whoa!
Nice stuff! Waiting for source code or a patch to be released to take a look on it
Great work
Thank you. To be honest, this is my first coding in Linux and I didn't know it took me 8hrs to prepare env/source. All for changing few bytes of one file lol. Above post should give you some clues and I'm still in experimenting this one so let me test/check more to make sure its stable code for most ROMs/kernels. I may probably try few more on other phones like Galaxy S and Desire HD (does it have ICS source?)
 
DaXmax
Old
#8  
DaXmax's Avatar
Recognized Themer
Thanks Meter 10020
Posts: 10,692
Join Date: Sep 2008
Location: Singapore
Omg! My ears blewed lol. Played some Skrillex and Deadmau5 songs. It was absolutely awesome. It was better than voodoo. Oh my! :')

Glad voodoo is still here. :P

Sent from my Nexus S using Tapatalk 2
 
Windows X
Old
#9  
Senior Member - OP
Thanks Meter 1243
Posts: 722
Join Date: Sep 2006
Quote:
Originally Posted by DaXmax View Post
Omg! My ears blewed lol. Played some Skrillex and Deadmau5 songs. It was absolutely awesome. It was better than voodoo. Oh my! :')

Glad voodoo is still here. :P

Sent from my Nexus S using Tapatalk 2
Glad to hear that. lazy isn't the best governor for sound quality wise though. Some powerful governors give fuller and more coherent sound. Let me know if you find something more to do with.
The Following User Says Thank You to Windows X For This Useful Post: [ Click to Expand ]
 
bedalus
Old
#10  
bedalus's Avatar
Recognized Contributor
Thanks Meter 7772
Posts: 5,963
Join Date: Jun 2011
Location: Chester
There is no such thing as 'latency jitter', they are two separate things . Latency is the delay caused by digital sound processing as the CPU cycles take time. A buffer is used to keep this delay constant.

Sampling jitter is caused by inconsistent clocks either at the input A/D stage, or the output D/A stage. Since we can't do anything about either of these stages without modifying the hardware, there isn't much we can do to improve the sound quality, apart from use better headphones and get the EQ right.

A smaller buffer is not going to affect sound quality, it will just mean the sound hits your ears a few milliseconds earlier.
For various benchmarks, see my threads: >here<

The Following 2 Users Say Thank You to bedalus For This Useful Post: [ Click to Expand ]
Tags
audiophile, head-fi, libaudio, mod, nexus s
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes