yashsingh1/xdaforums huggingface dataset:
[Nexus 5 Android Development] chdloc:
"Fluence" is Qualcomm's implementation (in firmware) of acoustic echo cancellation(AEC) and noise suppression (NS). This property has been present also in KitKat.

With respect to echo when dual-microphone processing is turned off I suggest you read the section "Thoughts on in-call voice quality" in the OP.

Disabling dual-microphone processing in build.prop essentially disables AEC and NS altogether, resulting in echo and noise being present in the signal you are sending to the folks on the other end of the call. There is a way to re-enable AEC and NS, but it involves a rather complicated setup with a custom kernel and Tasker scripts, see OP.
[Nexus 5 Android Development] and313:
Hm its funny i always disabled endfire but hadn't had any echo before i used it like that for a long time and nobody complained. So i guess that something changed in 5.0 or maybe the reason is that i am no longer on a custom kernel. I used elemental before. Who knows gonna send it back again

Fluence was always on
[Nexus 5 Android Development] Fuzzy13:
I've tried going through Aroma, manually adding the files one by one and loading the .gz file and i end up with a boot loop every time. Restoring the stock files through Aroma doesn't fix the bootloop so I have to reflash my ROM to get out of it.

What am I doing wrong?
[Nexus 5 Android Development] jssingh:
Easy VoiceRecorder

I use the Easy Voice Recorder Pro quite a bit for my stuff, and with the lollipop update, its quality has gone down a lot.

So the question is, which option in the mod should I flash to make it record better in Stereo. I listened to the demo audio that was attached, and it was impressive. I don't care as much about audio in video recording, but if that improves nonetheless, all the better.

Thanks for the help!
[Nexus 5 Android Development] donwhall70:
Worked great.. TY!!
[Nexus 5 Android Development] chdloc:
What ROM are you using? This mod will work only with stock for sure and maybe with other AOSP based ROMs. It will not work with CM or CM-based ROMs.

EDIT: You really do not need to reflash your ROM. All you need to do is to extract the files that are modified by this mod and flash them manually
[Nexus 5 Android Development] Fuzzy13:
Slim. It's not CM based. Judging by another post I saw someh were it appears that there is something missing in the mixer paths xml. Going to add the line that's missing and try it again.
[Nexus 5 Android Development] chdloc:
I'd say try all stereo options, i.e. with (6dB and 12dB) and without noise suppression, and keep the one that most closely matches your expectation of quality.

There is a tradeoff between the presence of white noise and non-linear distortion due to noise suppression in the recordings.

In Easy Voice Recorder Pro, make sure you select the "Camcorder" audio device and leave the pre-processing options (AEC and NS) at "Device Default", not "Off". Also, record at 48 kHz sampling rate.
[Nexus 5 Android Development] jssingh:
Thanks for the suggestions. After flashing the without - noise-suppression mod, easy voice recorder thinks the microphone is in use. I'm attaching the screen shots of the error as well as my settings for easy voice recorder.

P. S. I bought EVR from Amazon app store but the version is the same as google play.
[Nexus 5 Android Development] Fuzzy13:
Seems I've narrowed it down to the libaudioflinger.so file that's the one causing the boot loop. I managed to push all the other files with the updated mixer paths file with no problems. Soon as I push the libaudioflinger file though, no bueno. :(:confused:

edit: not sure what the libaudioflinger file does, but without it everything seems to be working and the audio and video recordings especially music has gotten much better. Well better in that the underwater garble is gone. The audio level is rather low but it sounds very natural.
[Nexus 5 Android Development] chdloc:
Just to throw out some ideas:

Does the same thing happen when you select "Main Microphone" as the recording device?

Do you happen to have Google Now enabled on all screens?

You may want to take a look at logcat and kernel messages to get an idea what may be going on.

look at the output of

adb shell cat /proc/asound/card0/pcm0c/sub0/status

before pressing "record" in the app. If it says anything but "closed" some other app is using the microphone.

The output contains a variable that is associated with the process that is using the recording device (owner_pid).

This should help you hunt down the offending app.
[Nexus 5 Android Development] adnan.selimagic:
Just to thank again [MENTION=2760454]chdloc[/MENTION] for everything that he's doing here and [MENTION=3163883]spacetaxi[/MENTION] for providing Aroma installer.

Thanks a lot ;)
[Nexus 5 Android Development] leeemans:
Thanks once again for this awesome stereo mod [MENTION=2760454]chdloc[/MENTION] and spacetaxi.

I flashed stereo, 6 dB noise suppression and everything seems to be working fine except when i open the equalizer in the play music app the sound gets really weird and bass was really high and couldn't able to stop it unless i turned off the equalizer or restart my phone.

thanks again and would be great if you could fix this.:good::good:
[Nexus 5 Android Development] scleone1987:
Using the aroma installer, I installed the mod before: Mono mode with -12dB suppression, all went good. I use code_blue kernel with stock LRX21O. Now, I tried to install the stereo mod, but I have no sound (even system sounds) and I'm not able to record videos (when I press the button, nothing happens). I have to revert to stock audio files to have sound back. In the meantime, between the mono and stereo mods, I installed UKM+Synapse to control the kernel. I noticed that in this app there's a section where I can adjust sound quality and loudness. Can be this the cause?
[Nexus 5 Android Development] chdloc:
I cannot reproduce the issue you are describing. Are you running stock without any other sound modifications?

If not, please go back to stock and try again.

If you are running all stock:

Starting from a fresh boot, please list all the steps required to reproduce your issue. Also, post the output of

logcat -v time | grep NOTE

while the problem is occurring.

Yes.

Try uninstalling UKM+Synapse and try again.
[Nexus 5 Android Development] leeemans:
Tried reflashing your audio fix and the problem is solved now.:good::good:
[Nexus 5 Android Development] scleone1987:
Tried but nothing. Same thing happens.
[Nexus 5 Android Development] chdloc:
It sounds like an incompatible audioflinger library. You could inspect the kernel messages and logcat for clues.

I would suggest you go back to the setup that was working for you, including the old mono mod with 12 dB of noise suppression.

Then, install the new stereo mod on top of that.
[Nexus 5 Android Development] leeemans:
In stereo mod, i here a small distortion noise on recorded video hearing with the headphones and especially on the left side. Is it because of the noise gain ? or but when i apply 12db noise suppression it is slightly reduced.

what is best settings to be used ??

i use 6db noise suppression, audio gain 103, right side.
[Nexus 5 Android Development] chdloc:
As I wrote in this post, I believe the noise is inherent to the top microphone (the one close to the headphone jack). There must be some "noisy" digital component close to the (analog) microphone trace which results its noise being picked up electrically. Interestingly, this noise is virtually non-existent when an audio-only stereo recording is made with e.g. Easy Voice Recorder Pro, which means that this component is not in use in the audio-only context.

Unless we identify and find a way to control the "noisy" component with the kernel, I don't think there will be a way to get rid of the noise in a (stereo) camcorder recording. If you find that noise too objectionable, you will have to go back to mono recordings.
[Nexus 5 Android Development] leeemans:
Thanks for the reply. BTW great work [MENTION=2760454]chdloc[/MENTION] :good::good:
[Nexus 5 Android Development] dtrano:
hey man i would like to test this fix, but i have a one plus one running CM11S on kitkat 4.4.4. How do i install the patch?
[Nexus 5 Android Development] chdloc:
The particular fix you quoted was built for CM on a Nexus 5. While there is a very small chance that the modified library, i.e. /system/lib/hw/audio.primary.msm8974.so, is compatible with the OPO, the other modified file, i.e. mixer_paths.xml, is almost certainly incompatible with your device.

Depending on your level of expertise you could try to merge your stock /system/etc/mixer_paths.xml with the modification required (see here) and copy the two files from here to your system partition after having made a backup of said files.
[Nexus 5 Android Development] marquimsp:
I'm running Cataclysm lollipop (at last a lollipop incarnation that I can live with) but this wonderful mod doesn't work (camera doesn't record videos, nothing happens when I press the button). Funny thing is : when I flash the aroma installer and choose "stock" everything goes back to normal.

If stock works, why doesn't the mod work? I mean, after I flash stock sound all files should be stock again, right? even if the original rom wasn't 100% stock... Then I'd be able to mod said stock files.

bummer...
[Nexus 5 Android Development] spacetaxi:
Strange... But that must be a problem on your side, as I'm a happy Cataclysm user myself - and the fix is working as expected.
[Nexus 5 Android Development] donwhall70:
Did you try running the installer again? I had this same issue except I was coming from using the one for the Lollipop beta. I had to revert back to the stock files and then run the new aroma installer again.
[Nexus 5 Android Development] marquimsp:
just did it, after reading your reply. No success.

I can't imagine what it is.

Thanks for the help, anyway!
[Nexus 5 Android Development] chdloc:
Which version of the mod did you install? Did you install any other audio mod, such as Viper?

With the camcorder mod installed, does audio stop working throughout the system or does it only impact the camcorder?

If audio works outside the camcorder context, the problem likely lies in your mixer_paths.xml file.

Please share the post-install mixer_paths.xml file

adb pull /system/etc/mixer_paths.xml .
[Nexus 5 Android Development] blior32017:
i have the same problem here :/
[Nexus 5 Android Development] marquimsp:
No, no other audio mods, I've just reinstalled to test and nothing works, PowerAMP playback is accelerated (you can see the song racing by but no sound comes out), whatsapp voice messages don't work... here's mixer paths:

https://www.dropbox.com/s/ew8p5r04ybcrh2s/mixer_paths.xml?dl=0

ps. : oh, version 2 (stereo /mono), aroma installer.

pps. : just noticed that mixer paths is blank... but that's what's going on.
[Nexus 5 Android Development] chdloc:
On the low-level noise produced by the top microphone (stereo mod only)

I have some experimental evidence as to where the low-level noise produced by the top microphone may be coming from.

Actually, I think it has at least two sources, both brought to you by non-optimal hardware design.

Source #1: PMIC

One of the PMIC's functions is to provide dynamic voltage scaling to the CPU so the system can dynamically adjust the clock speeds of the four ARM cores.

This DC-to-DC switching is known to be "noisy" and analog microphone traces laid close to the switching signals can pick those signals up. I ran an experiment where I made a stereo camcorder recording (6 dB noise suppression) with stock CPU settings (dynamic frequency scaling using ondemand governor) and one where all four ARM cores were locked at 1.19 GHz (performance governor), see attached files. You probably need to wear headphones with the level cranked all the way up to appreciate the difference.

The nature of the background noise changes with the audible "spikes" mostly gone.

You can try this experiment yourself by using, e.g., the app "Kernel Tuner".

Note that on stock kernels, Qualcomm's proprietary binary "mpdecision" controls voltage switching from userspace. Custom kernels often implement this feature differently, so your results may not match mine.

Source #2: High-speed camera data

The fact that stereo audio-only recordings sound a lot cleaner than the stereo camcorder recording leads me to believe that the communication between the CPU and the camera module is possibly to blame for the generation of noise as well (due to trace proximity or grounding issues).
[Nexus 5 Android Development] Jamith:
I know this fix is made for stock but I just wanna share my finds with another rom based in AOSPA, I'm using N5X 6.2 without any other audio modifications, any equalizer or similar. I let ADC6 with the valor recommended of 103.

I have used the Aroma installer v2, first with 6db noise suppression and made a video in a concert, second without noise suppression and made a video in another concert.

Stereo - simple: stereo, no noise suppression, bitrate 288 kbps

https://www.youtube.com/watch?v=YeD3fpVuTcE

Stereo - advanced (6 dB): stereo, 6 dB noise suppression, bitrate 288 kbps

https://www.youtube.com/watch?v=ObTRm5is38E

Any suggestion to improve my recordings?
[Nexus 5 Android Development] chdloc:
Yeah, your recordings contain badly clipped microphone signals.

My first suggestion would be to lower the gains, i.e. ADC1 and DEC6.

Note that there are no "recommended" values. I personally chose ADC1=15 and DEC6=103 as this setup closely matches stock in levels.

Keep in mind, though, that what you are hearing may be a result of the microphones themselves distorting badly. If this is the case,

then there is nothing that can be done with our hardware.

Next time you are recording a concert, try for instance ADC1=5 and DEC6=80 (reducing overall gain by approximately 40 dB),

and share your findings.

BTW, in these kind of recording scenarios, 6 dB of noise suppression makes very little difference.
[Nexus 5 Android Development] krneki10:
I just found out that Nexus 5 has utterly crappy auto gain control in comparison to some other flagships. It's basically impossible to record loud concerts or any other loud musical events since there will be only loud distorted buzz-noise instead of audio. Are there any workarounds yet to get normal audio out of camcorder? Does this mod help in this case?
[Nexus 5 Android Development] chdloc:
AGC seems to be disabled by default on the Nexus 5, possibly for a good reason.

I have never been a fan of AGC in general as the recorded audio more often than not suffers

from a pumping effect of the background noise. That's why I never bothered to look into this.

I will try to enable AGC and evaluate its performance.
[Nexus 5 Android Development] krneki10:
Thanks a lot in advance, I would really appreciate it. Disabled AGC may be better in most situations, but there are occasions where there's extremely loud sound which Nexus simply cannot handle. That's not a problem in a lot other flagships, I had Galaxy S3 before and it recorded a lot better sound on loud concerts. I had a chance to compare Nexus to iPhone 5 and 6 and they were far more superior in terms of audio quality (I can even send you comparison videos).

Perhaps someone know of camcorder app which already incorporates AGC? Or is that hardware/drivers dependent only?
[Nexus 5 Android Development] tuningsea:
I love you for this fix, nice bass, stereo works perfectly. U are awesome :o:o

https://www.youtube.com/watch?v=_Jl1kmq6MyI&index=1&list=UURF5H6TElze3lknC1614zgg
[Nexus 5 Android Development] AvivEliyahu:
No fix for aosp based ROMs?
[Nexus 5 Android Development] chdloc:
This fix is based on AOSP.

However, no guarantees can be given that the fix will work on any

ROM other than stock as ROM developers may have modified the audio subsystem.
[Nexus 5 Android Development] nomancoolboy:
I agree .. S3 has way better audio recording compared to nexus 5 ..
[Nexus 5 Android Development] dEris:
Has anyone tried this on Cataclysm (Lollipop)?

---------- Post added at 11:49 PM ---------- Previous post was at 11:46 PM ----------

What? Lol
[Nexus 5 Android Development] Badd_blood:
I'm using mono 6dB and now the loud sound is static noise rather than the weird alien techno sounds. Obviously I can't test it at a concert so I put it in front of a speaker at high volume.
[Nexus 5 Android Development] chdloc:
This result is to be expected. You would likely get the "weird alien techno sound" you are describing after applying an additional 15 dB of noise suppression to the static noise you get with the mod. The stock camcorder applies around 20 dB of noise suppression.

Please do me a favor:

Repeat your experiment after having changed both ADC1 gain and DEC6 gain

in /system/etc/mixer_paths.xml followed by a reboot.

In your mixer_paths.xml file look for the following entry

<path name="voice-rec-mic-mod">
<path name="handset-mic" />
<ctl name="ADC1 Volume" value="15" />
<ctl name="DEC6 Volume" value="103" />
</path>

change it to (with, e.g., Root Explorer)

<path name="voice-rec-mic-mod">
<path name="handset-mic" />
<ctl name="ADC1 Volume" value="[B]5[/B]" />
<ctl name="DEC6 Volume" value="[B]80[/B]" />
</path>

reboot your phone, and report back. Thanks!
[Nexus 5 Android Development] Badd_blood:
My values are already 13 and 84 actually. Should I be on stock or 6dB mod?
[Nexus 5 Android Development] chdloc:
You should be using the mod.

Lower the values further, I suggest to the ones I proposed before (5 and 80), maybe even lower (5 and 60?).
[Nexus 5 Android Development] Badd_blood:
Used 5 and 60, at first device wouldn't boot had to do a hard reset. Sounds pretty good, has that static sound a bit, but much better than the awful sound warping of stock.
[Nexus 5 Android Development] chdloc:
This is actually very good news!

There is a possibility that you can go even lower with the gains and get rid of that "static sound" altogether.

By the way, simply changing ADC1 and DEC6 levels should not prevent your device from booting. I'm suspecting

that you had some file permission issues.
[Nexus 5 Android Development] chdloc:
Here is a little teaser for everyone using their Nexus 5 to record very loud events:

I think I found a way (needs Tasker, though) of measuring the signal level at the microphone(s) and use the

result to drive the notification LED as a "VU meter". By simply looking at the color shown by the "VU meter"

and a "floating" on-screen level control drawn on top of the camcorder UI, one can lower the gain during

a live recording to (hopefully) prevent distorted sound. At least that's the theory...
[Nexus 5 Android Development] GMFalka:
Hello guys!

Today i installed a VOIP app called Plumble (mumble) and i set to "always active microphone". Let me tell you this: The voice quality was like five times better then on my Astro A50 (A very expensive PC headset)!

Can you guys shed some light on this? VOIP apps can use the phone microphone for its full potential (100% clear sound and everything), but the video recorder sound is worst then a WW2 field phone. Different codec?

Im just curious. :silly:
[Nexus 5 Android Development] krneki10:
I guess clicking on "thanks" button just isn't enough for all you work, so I really need to emphasize it how much I, including friends who own N5 as well, appreciate it. We're really crossing fingers that you manage to get it working ;).
[Nexus 5 Android Development] chdloc:
I have succeeded in implementing the idea that I described above, i.e. use the notification LED as a VU meter to aid in finding a more

appropriate gain (ADC and DEC) for a given acoustic environment. I'm calling it aMGC (assisted Manual Gain Control).

There is still a lot of work that needs to go into testing and tuning as well as making the UI more user-friendly, but here is a first glimpse as to what is possible.

I made a recording (stereo w/ 6dB of noise suppression) in my car with the radio at full blast playing some very bass-heavy (i.e. worst-case) music. The recording started out at nominal levels, i.e. ADC=15, DEC=103. It distorts badly.

About 20 seconds into the recording I started paying attention to the VU meter and played around with the gains. You will notice some overcompensation (too little gain) and more than necessary gain modifications, but the distortion is completely gone starting at around the 24 second mark. The good news is that even if the final recording has too little gain, it would be relatively easy to crank up the overall level again with a decent (offline) video editing app.
[Nexus 5 Android Development] Badd_blood:
Ok problem!! Microphone not working when using phone, I have to use speakerphone for the person to hear me. Good thing I backed up before.
[Nexus 5 Android Development] chdloc:
I'm guessing that the problem resulted from you manually changing the gains in mixer_paths.xml. The "vanilla" mod has absolutely no effect on cellular telephony.
[Nexus 5 Android Development] Badd_blood:
Yeah I flashed stock back from the flash zip and it's working.
[Nexus 5 Android Development] chdloc:
My point really was that you can go back to a version of the mod that delivers the quality that works for

you without breaking functionality of cellular calling.
[Nexus 5 Android Development] donwhall70:
Possible to get this working with this as well? Or at least via the aroma installer? I think one cancels out the other because of replacing the mixer_paths file.

http://xdaforums.com/google-nexus-5/themes-apps/mod-surround-sound-t2964809
[Nexus 5 Android Development] chdloc:
Yup, that works. Pretty cool actually. Thanks for the pointer.

The mod as posted, though does not give you true left-right separation, I made a couple of changes and now it does.

As provided in the referenced thread, the two channels are "intermixed", which makes it sound louder but less "spatial"

My mod does not touch this part of the mixer file at all, so the two audio mods can live together harmoniously.

Simply replace the existing device path "speaker" with:

<path name="speaker">
<ctl name="SLIM RX1 MUX" value="AIF1_PB" />
<ctl name="SLIM RX2 MUX" value="AIF1_PB" />
<ctl name="SLIM_0_RX Channels" value="Two" />
<ctl name="RX1 MIX1 INP1" value="RX1" />
<ctl name="RX7 MIX1 INP2" value="RX2" />
<ctl name="RX1 Digital Volume" value="90" />
<ctl name="RX7 Digital Volume" value="82" />
<ctl name="SPK DRV Volume" value="6" />
<ctl name="CLASS_H_DSM MUX" value="DSM_HPHL_RX1" />
<ctl name="DAC1 Switch" value="1" />
</path>

It still needs a little tweaking as the levels between the left and the right loudspeakers are slightly off (maybe simply the 88 vs 90 value).

I need to caution, though, that enabling the second speaker in speakerphone mode may mess with the phone's echo control.

This can possibly be fixed with some more mixer_paths.xml trickery.

Here is the modification necessary to mute the earpiece loudspeaker during cellular speakerphone calls:

<path name="voice-speaker">
<path name="speaker" />
<ctl name="SPK DRV Volume" value="8" />
<ctl name="RX7 Digital Volume" value="94" />
[COLOR="Red"]<ctl name="RX1 Digital Volume" value="0" />[/COLOR]
</path>
[Nexus 5 Android Development] donwhall70:
Thanks.. This is working great. I haven't used it during a call on speaker but everything else works so far :)
[Nexus 5 Android Development] chdloc:
Stereophonic playback

I've injected my self into the discussions around stereophonic playback on our Nexus 5.

To keep this thread clean, I posted my latest findings here. I'll try to keep that post up-to-date as necessary.
[Nexus 5 Android Development] winamp26:
hi guys

i merged surround mod into camcoder audio fix for stock 5.0 no echo.

if you dont like it, flash orginal camcoder audio fix. :)

download