yashsingh1/xdaforums huggingface dataset:
[Nexus 5 Android Development] DonAndress:
When I use the handset my voice is clear, no echo on the caller's side.

When I use loudspeaker, the caller can hear me like I was behind the glass door plus the caller can hear himself.

In both cases I can hear the caller loud and clear, no echo on my side.

As discussed, in the below section:

<path name="speaker">
<ctl name="SLIM RX1 MUX" value="AIF1_PB" />
<ctl name="SLIM_0_RX Channels" value="One" />
<ctl name="RX7 MIX1 INP1" value="RX1" />
[COLOR="Red"][B] <ctl name="RX7 Digital Volume" value="88" />
<ctl name="SPK DRV Volume" value="6" />[/B][/COLOR]
<ctl name="COMP0 Switch" value="1" />
</path>

I changed only two lines like below:

<ctl name="RX7 Digital Volume" [COLOR="Red"][B]value="85"[/B][/COLOR] />
<ctl name="SPK DRV Volume" [COLOR="Red"][B]value="5"[/B][/COLOR] />

Plus I added this line in the build.prop, like you suggested.

persist.audio.dualmic.config=endfire

No other changes made.

Everything else is as given in your file.

Of course reboot performed.

Tricky question.

I did not change anything else.

If this feature is not turned on by default in your files, then the answer is rather not.
[Nexus 5 Android Development] chdloc:
OK, my last educated guess would be that your phone for whatever reason uses the wrong microphone in the handsfree telephony use-case. In handsfree mode the microphone usually switches from the main microphone located at the bottom of the phone to the auxiliary one next to the headphone jack. This is done to maximize the distance between the loudspeaker and the microphone to minimize acoustic coupling, which in tern would easily lead to echo.

To find out run

logcat | grep select_devices

while making a call using speakerphone. Also, please attach your (entire) currently used mixer_paths.xml file
[Nexus 5 Android Development] chdloc:
OK, open your mixer_paths.xml file, look for

<path name="voice-speaker-dmic-ef">
<path name="dmic-endfire" />
</path>

replace with

<path name="voice-speaker-dmic-ef">
<!-- <path name="dmic-endfire" /> -->
<path name="voice-speaker-mic" />
</path>

and reboot. This change forces your phone to use the auxiliary microphone in speakerphone mode. Hopefully this change provides better echo control for you.

If this hack does not work for you there is, unfortunately, not much I can do without digging into the CM sources. It would appear that CM (the audio HAL) has changed since I looked at it several months ago.
[Nexus 5 Android Development] DonAndress:
Hmm that helped for my voice not being heard as from behind of the glass doors - it's clear now.

But still the caller can hear his voice...

Do you think you would be able to find some time for us? :)
[Nexus 5 Android Development] chdloc:
One more try, copy the following "voice-speaker-dmic-ef" over your existing one:

<path name="voice-speaker-dmic-ef">
<!-- <path name="dmic-endfire" /> -->
<path name="speaker-mic-aec" />
</path>

followed by a reboot (the "aec" presumably stands for acoustic echo cancellation)

If that does not solve the problem, there is nothing else I can suggest other than the below.

Unfortunately, I don't currently have time to spend quality time with the CM sources. I'm afraid I have to suggest you either go back to stock CM to see whether the echo problems go away (and live with poor camcorder audio) or switch to one of the AOSP-based ROMs which are fully supported by my mod.
[Nexus 5 Android Development] DonAndress:
Unfortunatelly that didn't help either.

The caller says he can hear me even worse them with <path name="voice-speaker-mic" />

There's the echo of my voice, hiss and distorion of my voice plus the echo of the caller's voice.

What is weird though is that with <path name="speaker-mic-aec" /> the caller can hear a little of his voice echo during the handset call (not loudspeaker).

No worries, mate. You've been helpful enough and thanks for your time :)

To be honest I'd prefer to stick with CM as it's superbly smooth and has some really useful goodies...

But maybe you could guide me through the lines a little, so maybe I can find some most suitable settings for CM (if possible).

For example, what do these lines stand for (which mic or speaker, top or bottom one) and what might be the difference between some of them:

<path name="handset-mic">
<path name="adc1" />
<ctl name="ADC1 Volume" value="16" />
<ctl name="DEC6 Volume" value="86" />
</path>

<path name="headset-mic">
<path name="adc2" />
<ctl name="ADC2 Volume" value="16" />
<ctl name="DEC5 Volume" value="90" />
</path>

<path name="handset">
<path name="voice-handset">

<path name="speaker-mic">
<path name="handset-mic">
<path name="voice-handset">
<path name="voice-handset-tmus">
<path name="voice-speaker">
<path name="voice-speaker-mic">
<path name="speaker-mic-aec">

<path name="headset-mic">
<path name="voice-headset-mic">

<path name="voice-rec-mic">
<path name="camcorder-mic">
<path name="voice-rec-mic-mod">

<path name="dmic-endfire">
<path name="dmic-broadside">

<path name="voice-dmic-ef">
<path name="voice-dmic-ef-tmus">
<path name="voice-speaker-dmic-ef">

<!-- TTY devices -->

And which line says that Android should use the "dual mic devices" part of mixer_paths file?
[Nexus 5 Android Development] chdloc:
I'd suggest you go back to the stock CM mixer_paths.xml, audio HAL (msm.primary.msm8974.so), and build.prop. Are you still getting echo? If you do you may be able to improve the situation by lowering microphone and/or loudspeaker gain.

Decoding mixer_paths is relatively straightforward. First you need to find out which device is being called for by Android. You can do that by looking at logcat and filtering for "select_device", as you did above. There will be a corresponding entry in mixer_paths. To find out which hardware device you eventually get to, you need to follow the "path name" tag upwards. For example, in one use-case (see your logcat example above) Android asks for the "voice-speaker" device. In your mixer_paths you get:

<path name="voice-speaker">
<path name="speaker" />
<ctl name="SPK DRV Volume" value="8" />
<ctl name="RX7 Digital Volume" value="94" />
</path>

Following the path ("speaker") gets you

<path name="speaker">
<ctl name="SLIM RX1 MUX" value="AIF1_PB" />
<ctl name="SLIM_0_RX Channels" value="One" />
<ctl name="RX7 MIX1 INP1" value="RX1" />
<ctl name="RX7 Digital Volume" value="85" />
<ctl name="SPK DRV Volume" value="5" />
<ctl name="COMP0 Switch" value="1" />
</path>

This is the final "stop" in this example. "speaker" refers to "RX7 MIX1 INP1" which is the signal path corresponding to the main loudspeaker (bottom of phone), the gain of which is controlled by "RX7 Digital Volume" (digital) and "SPK DRV Volume" (analog). The earpiece device is for example referred to by the "handset" device (RX1 signal path), the gain of which is controlled by "RX1 Digital Volume" (digital) and "EAR PA Gain" (analog).

On the recording side with a single microphone you will finally end up with one of the adcX (X=1,2,3) devices and the corresponding ADCX hardware device ("ADCX Volume" controls the analog gain and "DECY Volume" controls the digital gain). ADC1 is the main microphone (bottom of phone), ADC2 is the microphone that is built into a wired headset (not on phone), and ADC3 is the auxiliary microphone (top of phone)

Your logcat above shows that Android asks for the "voice-dmic-ef" device while you talk on the handset and "voice-speaker-dmic-ef" when you use the speakerphone mode.

In general sometimes it appears that different devices called by Android end up using the same exact hardware setup. Under the hood the hardware is set up quite differently by the audio HAL, however.
[Nexus 5 Android Development] sky0165:
I've some questions:

1- Why does use your own assisted gain control instead of the own built in AGC (Automatic Gain Control)? Was it disabled by default?

2- My device (Moto G 2014) faces the same problem as the N5. I could achieve better quality bumping the Audio Encoder to its maximum in the media_profiles. 320kbps 48hz 2 channels (stereo) has fixed most of the audio problem, but it's impossible to record a musician/concert without distortion. Digging in your post, i've seen you saying about increasing/decreasing sensitivity, but i fear if i decrease it, would make the concert sound with no distortion at all, but it will be barelly hearable in other circunstances. Is there any other option i could tweak? I fell motorola forgot to turn AGC on.

Thank you.
[Nexus 5 Android Development] LeBaldi:
[MENTION=2760454]chdloc[/MENTION] I always been use your mod... and I used under Cataclysm's Rom... but I moved to the Temasek CM13 CAF version... and when flash the mod... something break the camera... even I flash only the stereo mod... is there any way I can make a log or something to help about this to try solve the problem?

Thx!
[Nexus 5 Android Development] chdloc:
1. AGC, indeed, is disabled by default, at least on Nexus devices. I played around with both the Qualcomm-provided AGC as well as the Google-provided one (webRTC). They are both unusable in the context of camcorder recordings.

2. The problem is that, by default, microphone gain changes done in the mixer reset back to the default values whenever a new recording is started. That's why you would need something like Tasker to automatically apply the gain changes as necessary. I see two options for you:

have two mixer_paths.xml files handy, one for high-gain ("normal") and one for low-gain ("concert mode") scenarios, copy the appropriate version in place as necessary, and reboot. You could also design an Aroma installer with which you can edit the gain upon a reboot as needed. You could look at the one that comes with this mod as a starting point.

find a kernel for your device that offers built-in microphone gain control

CM derivatives in general and CAF build in particular make use of very different audio HALs than the AOSP-derived ROMs. For this reason and due to the "moving target" nature of CM, I'm maintaining my mod for AOSP-based ROMs only. Sorry.
[Nexus 5 Android Development] sky0165:
Thank you very much for your quick reply. Both AGCs were turned off by using #(comentary) in audio processing XML?
[Nexus 5 Android Development] chdloc:
Honestly, I don't remember exactly how I turned on the Qualcomm AGC. I believe I simply manipulated /vendor/etc/audio_effects.conf

For sure, enabling the Google (webRTC) AGC required source code modifications.

Note that the webRTC is optimized for speech signals only and it proved to be a poor match for "generic" audio signals. I believe that the Qualcomm AGC simply shipped completely unoptimized for the Nexus 5 as a proprietary vendor blob. I did hear anecdotal evidence that the Qualcomm AGC seems to be working decently for other phones.
[Nexus 5 Android Development] gaz41:
You could look at the one that comes with this mod as a starting point.

[*]find a kernel for your device that offers built-in microphone gain control

[/LIST]

[MENTION=2760454]chdloc[/MENTION]

Could you tell me a kernel for nexus 5 which allows to do this? Now I'm on elemental-x...

Inviato dal mio Nexus 5 utilizzando Tapatalk
[Nexus 5 Android Development] chdloc:
I don't know, but I believe Faux was the pioneer in providing kernel-level sound control. It appears, though, that development of his kernel has stopped with Lollipop. I'd look for a kernel that cherry-picked his kernel module. Google for "sound_control_3_gpl.c" and see which hammerhead-supported kernel comes up.
[Nexus 5 Android Development] DonAndress:
[MENTION=2760454]chdloc[/MENTION] do you think it's safe to apply these two files we discussed before (mixer_paths.xml and audio.primary.msm8974.so) from CM13 into CM12.1?

I have a confirmation that audio recording works well in one of the CM13 builds so maybe it's worth to try?

Or is it that not only these two files are responsible for audio in/out in the system?

TapaTalked from i9506
[Nexus 5 Android Development] chdloc:
I don't think it will work, but you can certainly give it a try...
[Nexus 5 Android Development] BelzIgoh:
Flashable aroma zip for MMB29K is working fine with the latest update MMB29S.

Thanks [MENTION=2760454]chdloc[/MENTION]
[Nexus 5 Android Development] amkirk94:
Is this compatible with CM13?
[Nexus 5 Android Development] netinetinet:
for me no

Odoslané z BV2000 pomocou Tapatalku
[Nexus 5 Android Development] DonAndress:
CM is not supported. Unfortunately it doesn't work properly even on CM12.1, not to mention 13.

TapaTalked from i9506
[Nexus 5 Android Development] amkirk94:
I can confirm that the latest build has worked for me so far on the latest CM nightly
[Nexus 5 Android Development] DonAndress:
What does work mean?

Because I couldn't get rid of the distorted sound in recordings effect.

TapaTalked from i9506
[Nexus 5 Android Development] amkirk94:
I don't get any of that. Are you using the Noise Cancelling mechanism?
[Nexus 5 Android Development] DonAndress:
Tried it on and off. No change. Seems like CM12.1 has it f** up a bit when it comes to recording sound. Everything else (calls, speaker etc) works fine.

TapaTalked from i9506
[Nexus 5 Android Development] chdloc:
Are you saying that the main mod works on CM13, even the "advanced" version?
[Nexus 5 Android Development] amkirk94:
I can't confirm the advanced fix, since I only use the simple fix, but yes. For me flashing Nexus5_6.0.1_MBB29K_v1.0_audiofix_aroma.zip on the latest nightly works just fine. No errors, no distortion so far.
[Nexus 5 Android Development] D.martijn:
Has anyone tried this mod with Catalysm 6.0.1, latast stable build?
[Nexus 5 Android Development] dakore:
Working just fine.
[Nexus 5 Android Development] D.martijn:
Even when you are on build MMB29S?
[Nexus 5 Android Development] Hinkelstein_1976:
Are there any problems with 6.0.1 MMB29Q?
[Nexus 5 Android Development] amkirk94:
No
[Nexus 5 Android Development] liusi522:
MMB29U can not use it.
[Nexus 5 Android Development] chdloc:
Build MMB29U is meant for fugu (Nexus Player). I'll update the mod once it is required for a new hammerhead build.
[Nexus 5 Android Development] liusi522:
Great.Thanks for your reply.
[Nexus 5 Android Development] Flyview:
I've been using this mod for well over a year now. Just realized my earspeaker isn't getting very loud, when I had previously found settings where they were pretty equal (94 earspeaker, 83 bottom). I just tried setting earspeaker to 100 and volume hasn't changed as far as I can tell. This is on Android 6.0.1 with latest MBB29K build.
[Nexus 5 Android Development] chdloc:
Do you happen to have any other audio mods installed?

Please post your current mixer_paths.xml file.

Also, do you have the advanced mod installed? If so, please run the following command as root in a shell while audio is playing through the loudspeakers

tinymix > /sdcard/mixer.txt

and attach the output (mixer.txt) as well.
[Nexus 5 Android Development] Flyview:
Here's the mixer_paths.xml. Nope, no other audio mods. Simple camcorder fix + stereo mod without advanced mod installed.

EDIT: Upload didn't work at first, renamed to mixer_paths.xml.txt.
[Nexus 5 Android Development] chdloc:
Your mixer_paths.xml file looks good to me. We need to make sure that no other process is changing the gains on you. Have you recently installed a new or updated custom kernel? In order for me to be able to help you further you will need to install tinymix. For that you can either "update" to the advanced mod or manually download the binary from here, copy to /system/bin, and change the permission to 744 (rwxr--r--). Then play audio through the loudspeakers and simultaneously issue the following command in a root shell

tinymix > /sdcard/tinymix.txt

and send me the resulting tinymix.txt file.
[Nexus 5 Android Development] Flyview:
Yes, I've installed the ElementalX 6.12 kernel, and SuperSU 2.67 beta. Here's the tinymix.txt. I set the levels to 94/83. Covering the big speaker shows that the top speaker is fairly quiet, whereas before with these settings they'd be pretty similar.
[Nexus 5 Android Development] chdloc:
ElementalX kernel has Faux sound control built-in, which appears to be taking over gain control. As proven in the tinymix output that you posted, the gains have been reset to default (the "RX1 Digital Volume" entry is 84, but should be 100 according to your previously posted mixer_paths.xml file).

As I require a couple of special features, I'm running my own kernel without Faux sound, so I'm not familiar with it. I see three options for you

go back to a kernel without Faux sound, not sure which ones other than stock. The only way to find out is to look at the respective kernel sources in the developer's github and see whether the following file exists: sound/soc/codecs/sound_control_3_gpl.c

find a way to disable Faux sound, for example by using Faux' own kernel control app ("Faux123 Kernel Enhancement Pro")

use Faux sound to control the gains, again by using an appropriate kernel control app

As far as I know, you can also control everything via the command-line as well. Post the output of

ls -al /sys/kernel/sound_control_3 && cat ls -al /sys/kernel/sound_control_3/*

and I may be able to help with command-line control.
[Nexus 5 Android Development] Flyview:
Interesting, I wonder if the Faux sound is also causing a mild stereo effect then or is that still because of your mod? Is it affecting the camcorder modifications as well? I just checked and it looks like FauxSound was recently added back to ElementalX. I could use an older version.

Here you go:

1|shell@hammerhead:/ $ su
l /sys/kernel/sound_control_3 && cat ls -al /sys/kernel/sound_control_3/* <
-rw-rw-rw- root root 4096 2016-03-05 16:17 gpl_cam_mic_gain
-rw-rw-rw- root root 4096 2016-03-05 16:17 gpl_headphone_gain
-rw-rw-rw- root root 4096 2016-03-05 16:17 gpl_headphone_pa_gain
-rw-rw-rw- root root 4096 2016-03-05 16:17 gpl_mic_gain
-r--r--r-- root root 4096 2016-03-05 16:17 gpl_sound_control_hw_revision
-rw-rw-rw- root root 4096 2016-03-05 16:17 gpl_sound_control_rec_locked
-r--r--r-- root root 4096 2016-03-05 16:17 gpl_sound_control_version
-rw-rw-rw- root root 4096 2016-03-05 16:17 gpl_speaker_gain
-r--r--r-- root root 4096 2016-03-05 16:17 sound_reg_read
--w--w--w- root root 4096 2016-03-05 16:17 sound_reg_sel
--w--w--w- root root 4096 2016-03-05 16:17 sound_reg_write
sush: cat: ls: No such file or directory
sush: cat: -al: No such file or directory
0
0 0
36 36
0
hw_revision: 2
0
version: 3.6
0 0
sush: cat: /sys/kernel/sound_control_3/sound_reg_read: Operation not permitted
sush: cat: /sys/kernel/sound_control_3/sound_reg_sel: Permission denied
sush: cat: /sys/kernel/sound_control_3/sound_reg_write: Permission denied
[Nexus 5 Android Development] chdloc:
Unfortunately, Faux sound does not support the notion of stereo speaker playback, so whatever stereo effect you are hearing comes from my mod. Due to Faux, both loudspeaker gains are set to 0 dB (84) by default. In fact, if you are changing the loudspeaker gain through Faux, you are only modifying the main loudspeaker ("RX7 Digital Volume").

I checked the kernel sources and it would definitely be possible to modify the Faux sound kernel driver to allow for both loudspeakers to be supported natively.

The microphone gain part of my mod is definitely also nullified by Faux, in particular if you are recording in stereo.

I'd be happy to assist [MENTION=4684315]flar2[/MENTION] to work this out, if desired.
[Nexus 5 Android Development] Flyview:
That'd be great, I'll link him to this discussion!
[Nexus 5 Android Development] crisis_trustee:
What about MOD for MMB29X?
[Nexus 5 Android Development] chdloc:
Is the latest Google update breaking the mod? Honestly, I haven't bothered to keep up with the security updates in recent months. A thumbs up/down report as to whether this mod still works with Google's April security update would be appreciated.

Edit: The just posted changelog suggests that the current mod should work just fine with the latest (April) security update.
[Nexus 5 Android Development] cdonald:
The mod works well for me with the latest security update. Thanks!
[Nexus 5 Android Development] Neutrality:
Nexus 5x

Hi all. Hi @chdloc and thank you for best mod ever)

https://drive.google.com/folderview?id=0B8kfnHfER5HIeFRfcEp3aFppekU&usp=sharing

I bought a Nexus 5x and did not find this mod for it. So I read the thread and found your message. Unfortunately I forgot that I installed @sshafranko mod :) A long story short, I made a combined mod with stereo sound and stereo recording with a camcorder. Just copy these files in the systems/etc folder, replacing the original, make sure that files permissions - rw- r-- r--.

View attachment media_profiles.xml

View attachment mixer_paths.xml

mirror https://drive.google.com/open?id=0B8kfnHfER5HIeFRfcEp3aFppekU

You will get surround mod and stereo sound recording) Thank you dudes, you are the best.

This mod only for Nexus 5x (6.0.1).

PS Sorry for my English :angel:
[Nexus 5 Android Development] kivin21:
Works good with the latest mob30d!
[Nexus 5 Android Development] amkirk94:
If I use a call recording app, the voice of the guy I'm speaking to is distorted (probably due to the increased gain that the earspeaker is at). Do we have any solutions to that? :confused:
[Nexus 5 Android Development] onesolo:
Does anyone know if this mod is already present on the Pure Nexus rom or do I need to flash it? Don't want to ask on their thread cause probably I don't get an answer
[Nexus 5 Android Development] chdloc:
Good question. As a matter of fact, this very issue is the root cause I started looking into Android audio in the first place.

The distortion of the far-end signal in the recording of a phone call from the line is produced somewhere inside the baseband DSP and has nothing to do with the level of the earpiece, unless you are referring to distortion that you can hear during a call.

There is no satisfying solution to this problem and only Qualcomm/LG/Google could fix it (spoiler: they won't). I did come up with a workaround that I described in the "Thoughts on in-call voice quality" section in the OP. However, I decided not to publish that mod as its complexity would turn into a support nightmare for me.

I don't think that this mod comes with any ROM by default.
[Nexus 5 Android Development] HeltonMax:
hello [MENTION=2760454]chdloc[/MENTION] Any method that mod work in conjunction with surround MOD since installed this Mod and overlapped the other MOD
[Nexus 5 Android Development] chdloc:
The Aroma installer that comes with this mod allows you to enable "surround" sound. No need to flash anything else.
[Nexus 5 Android Development] disiz:
Hello, I have LG G2 with KK and those 2 phones have some same hardware, is it possible to set "voice recognition" by default for every media recorded with the phone ? With this way we can record with 3rd apps with snapchat or else :)

I've changed this line in build prop, but it doesn't change anything...

persist.audio.handset_rx_type=DEFAULT by this one

persist.audio.handset_rx_type=VOICE RECOGNITION

Anyone have an idea to set voice recognition by default ?

And I even change this line but don't change a lot...

persist.audio.handset.mic.type=analog

Thanks a lot for your help.
[Nexus 5 Android Development] Neutrality:
Hi [MENTION=2760454]chdloc[/MENTION]

Can I use this to make a separate topic?