Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,785,052 Members 44,376 Now Online
XDA Developers Android and Mobile Development Forum

[MOD][ROOT] Camcorder Audio Quality "Fix" and Thoughts on In-Call Voice Quality

Tip us?
 
chdloc
Old
(Last edited by chdloc; 27th August 2014 at 02:54 PM.) Reason: Audio samples added
#1  
Member - OP
Thanks Meter 127
Posts: 83
Join Date: Jul 2010
Default [MOD][ROOT] Camcorder Audio Quality "Fix" and Thoughts on In-Call Voice Quality

I was asked to open a new thread with a workaround that deals with poor audio quality when using the Nexus 5 Camcorder, which I originally posted in this thread: http://forum.xda-developers.com/goog...rible-t2776502

So here it goes...

Background
==========

I have spent a lot of time trying to fix the in-call recording distortion issue (incoming audio) that seems to plague many devices with
Qualcomm chipsets that are trying to use call recording software that records from the line, like the excellent CallRecorder by @skvalex.
(Actually I found a way, which may not fit the broad population, but it works for me. PM me if you are interested). My time spent on this
endeavor gave me quite some insight into the audio subsystem

The Mod
=======

Up until now I have not really used the camcorder feature, but recently I have and lo and behold, the quality is god-awful.
So I played around with one of the system libraries, i.e. /system/lib/hw/audio.primary.msm8974.so and the audio mixer settings file, i.e.
/system/etc/mixer_paths.xml
The problem seems to be that the audio path chosen within the Qualcomm chipset by the camcorder is enabling a noise suppression algorithm
that is way too aggressive. The way I found around this problem is to find (by trial and error) a signal path that seems to bypass noise
suppression when the camcorder is used.

Give the attached library and settings file a try (either by modifying your system manually or by using the Aroma installer provided
by @spacetaxi, see third post) and report back whether it works for you.
If you go the manual route, unpack the archive, make a backup of the existing
library and settings file, copy the new ones in their respective place, and reboot. Make sure to not rename (or misspell)
the files before the reboot, otherwise you will get into a boot loop.
Also, make sure you give the files the correct permissions (644, i.e. rw-r--r--) after they have been copied to your phone.

In short, don't try this if you don't know what you are doing...
Of course, root is required to write to the system partition.

The attached library was built from 4.4.4 AOSP (branch: android-4.4.4_r1, build: KTU84P). It may or may not work with an older
version of stock KitKat. It will probably not work with any other version of Android, but I'd be happy to share the mod so it can be built for other ROMs, if the modified library seems to work for people (it does for me). For sure, this mod does not currently work with CM.


NOTE: People may have played with their mixer_paths.xml file to modify other audio-related issued. In that case you need to merge
your original mixer_paths.xml with the attached modified one.

REMEMBER: Always make a backup of your original system files first!

Changing the microphone gain
============================

Background:
The microphone path used by this mod is "voice-rec-mic-mod", which is derived from "voice-rec-mic" already present in the stock version of
/system/etc/mixer_paths.xml
The default microphone gain is set to 88 ("DEC6 Volume"). If one feels that microphone "sensitivity" is insufficient, this gain can be
increased significantly. According to ALSA mixer data, the maximum level can be set 124 (not sure about the actual gain difference in dB,
but it is very audible). Of course, there is a tradeoff between microphone gain and background noise, i.e. higher gain results in more audible
microphone/preamp ("white") self-noise. As a matter of fact it is this noise that the original library tries to fight with its poorly
implemented/configured noise suppression algorithm.


Static modification of microphone gain:
- method 1: The gain can easily be changed by editing line 360 ("DEC6 Volume") of the new mixer_paths.xml file directly via a file browser,
like Root Explorer. The values can range from 0 to 124. I have not tested yet whether the phone has to be rebooted after modifying the file,
but it may be good practice to do so
- method 2: run the Aroma installer from the third post


Dynamic modification of microphone gain using tinymix (use is currently limited):
Once the recording has started, the microphone gain can quite easily be modified with the help of the attached tinymix binary,
which can be built from the AOSP tree.
The syntax (after it has been uncompressed), copied to, e.g., /system/bin, and made executable is:
> tinymix "DEC6 Volume" X
where X=[0,124]. Again, there will be a tradeoff between microphone gain and noise amplification.
The big caveat is that the gain is reset to the one listed in the file /system/etc/mixer_paths.xml every time a new recording is started.
Shy of having the phone tethered to a PC during a shoot where the gain change can be initiated through adb, there may be a way for a dev
to come up with a "floating" gain setting (go here http://forum.xda-developers.com/show...4&postcount=84 if you would like to try a Tasker "scene" I cooked up for this), via a permanent notification, or bake it into a custom camcorder app.
Update: Actually, I think the problem of resetting gains can be solved with Tasker. One can imagine a profile that kicks in once the camera app is launched. That profile kicks off a shell script which continuously monitors the status of the sound card in /proc/asound/card0/pcm0c and reports status changes (i.e. triggered by starting/stopping a recording) back to Tasker. Tasker, in turn, can make the necessary changes. Convoluted, but it should work...


Thanks
======

Kudos go to @spacetaxi for providing the Aroma installer (third post).
Please direct all questions to him for questions around the installer and its use.
I'm more a "just the facts ma'am" kind of guy...



Update (08/05/2014):
Added a patch file so devs can integrate the fix into their custom ROMs, if desired


Update (08/08/2014):
Although this mod was originally developed for stock Android 4.4.4 (KTU84P), I have seen reports of it working (as is) on
recent versions of MIUI, OmniRom, PAC ROM, CarbonROM, PA ROM, SlimKat, and OctOS. In fact, this mod has a good
chance of working on all recent ROMs that closely follow AOSP as it really only changes a C library which sits underneath the Android stack.

A version for CM11 can be found here:
http://forum.xda-developers.com/show...0&postcount=30
Go here for @spacetaxi's Aroma installer of the fix for CM11:
http://forum.xda-developers.com/show...9&postcount=56


Update (08/08/2014) #2:
I added some thoughts on poor in-call voice quality here:
http://forum.xda-developers.com/show...9&postcount=40



Update (08/10/2014):
A version for L-Preview can be found here:
http://forum.xda-developers.com/show...0&postcount=47
Go here for @spacetaxi's Aroma installer of the fix for Android L developer preview (build LPV81C):
http://forum.xda-developers.com/show...8&postcount=57


Update (8/12/2014):
Some results and discussions with regard to gain settings can be found here:
http://forum.xda-developers.com/show...9&postcount=58


Update (8/27/2014):
Sound samples comparing the camcorder using the stock audio library vs my mod can be found here:
http://forum.xda-developers.com/show...&postcount=111
The setup was well-controlled while the recordings were being made, thereby allowing for a bias-less comparison.
Attached Files
File Type: gz camcorder_audio_fix.tar.gz - [Click for QR Code] (19.7 KB, 278 views)
File Type: gz tinymix.gz - [Click for QR Code] (3.6 KB, 105 views)
File Type: patch camcorder_audio_fix_hammerhead.patch - [Click for QR Code] (7.0 KB, 188 views)
The Following 39 Users Say Thank You to chdloc For This Useful Post: [ Click to Expand ]
 
m52 power!
Old
#2  
Senior Member
Thanks Meter 25
Posts: 200
Join Date: Mar 2008
So you say you found a signal path that bypasses noise suppression, but the modification is increasing the gain? Is their a specific gain value you are using that happens to bypass noise suppression?
The Following User Says Thank You to m52 power! For This Useful Post: [ Click to Expand ]
 
spacetaxi
Old
(Last edited by spacetaxi; 12th August 2014 at 12:37 PM.)
#3  
spacetaxi's Avatar
Senior Member
Thanks Meter 371
Posts: 173
Join Date: Nov 2010
Arrow Aroma installer package of chdloc's fix for Android 4.4.4 stock / AOSP-based roms

This is the aroma installer package of chdloc's fix for 4.4.4 stock / AOSP-based roms. For CM11 see post #56. For Android L Preview see post #57.
I will keep this post updated if there will be a new version of the installer package.

If you flash the attached zip, you'll get two options:
  1. Install Audio Fix: Install chdloc's Camcorder Audio Fix
  2. Install Stock KTU84P Audio: Install stock audio lib and config from build KTU84P
So if you are using Google's stock firmware build KTU84P, option 2 will revert both system files changed by option 1 (audio lib and config) to their stock version.

If you are using a different firmware build or if you've changed the config file (mixer_paths.xml) and want to be able to revert the files to their current state, please make a backup of the system partition by using the recovery (CWM / TWRP) prior to installing this zip. Then you can just restore the system partition if you don't like the changes.

By the way, you should make a backup of the system partition in any case! There's always a (small) risk that something goes wrong when flashing a zip. Anything you do, you are doing at your own risk.

Happy flashing!

Installer changes:
  • 2014-08-08 - build 3: Removed check for hammerhead device (ro.product.device) as it was causing unexpected problems (preventing installation in some cases).
The Following 23 Users Say Thank You to spacetaxi For This Useful Post: [ Click to Expand ]
 
chdloc
Old
#4  
Member - OP
Thanks Meter 127
Posts: 83
Join Date: Jul 2010
Quote:
Originally Posted by m52 power! View Post
So you say you found a signal path that bypasses noise suppression, but the modification is increasing the gain? Is their a specific gain value you are using that happens to bypass noise suppression?
My mod is not changing the externally controllable gain at all by default. It gives you, however, the option
to change the gain without affecting any other apps.
 
SOHKis
Old
#5  
SOHKis's Avatar
Senior Member
Thanks Meter 147
Posts: 565
Join Date: Apr 2008
Location: VA
initial testing seems to be working well, gonna do some more this evening & see how it goes. thanks for the share
 
SpaceGooner
Old
#6  
SpaceGooner's Avatar
Member
Thanks Meter 14
Posts: 73
Join Date: Jun 2009
Location: Bromley, Kent
Thumbs up Natural video sound again on my N5

After Google messed up the N5's camcorder audio in 4.4.3 and 4.4.4, I was getting by using Snap Camera with alternate mic enabled, but in all honesty the audio quality was still nowhere near as good as some of the phones I owned even 6 or 7 years ago,

Now I don't know exactly what this mod does, but my videos sound like they should again so big thanks to chdloc for the fix and spacetaxi for the aroma installer.
The Following 3 Users Say Thank You to SpaceGooner For This Useful Post: [ Click to Expand ]
 
RussianBear
Old
#7  
Recognized Contributor
Thanks Meter 275
Posts: 1,652
Join Date: Nov 2008
Quote:
Originally Posted by spacetaxi View Post
Here I'm posting the up-to-date aroma installer package for chdloc's fix. I think he will refer to it from the first post as soon as he is online again. Happy flashing!
Any chance you could post a stock revert, just in case, please?
 
rockknee
Old
(Last edited by rockknee; 5th August 2014 at 06:04 AM.)
#8  
rockknee's Avatar
Senior Member
Thanks Meter 106
Posts: 364
Join Date: Apr 2013
Location: Masku
Quote:
Originally Posted by RussianBear View Post
Any chance you could post a stock revert, just in case, please?
Check the aroma installer .zip. If I understood right it should be able to do the reverting. So just simply flash the file and you'll have an option to revert.
 
Maxamillion
Old
#9  
Senior Member
Thanks Meter 161
Posts: 839
Join Date: Feb 2011
Does this mod do anything to fix the in call audio problem?
Phone: Nexus 5
 
usaff22
Old
#10  
usaff22's Avatar
Senior Member
Thanks Meter 1,467
Posts: 3,445
Join Date: Nov 2011
Location: Unfortunately, Maps has stopped.
Could you possibly make a version for the L Preview? Thanks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes