yashsingh1/xdaforums huggingface dataset:
[Nexus 5 Android Development] scorpeeon:
I see. What's the practical point of displaying the RMS value though? I mean when sound is too loud and distortion happens, the LED turns red anyway right (so you can lower the mic gain)? And I also read that changing the mic gain temporarily kills the sound, so I it's not a good idea to frequently adjust the mic gain based on the current RMS values right? So it's mostly just additional information, but not very important to make the recording better right?

Wow, I didn't know about this App Factory, looks really cool :) Yeah I imagine it can be really useful to make apps for special purposes really fast, even without programming knowledge.

(I develop for phones anyway in Java and C++ but I can see how it can come in handy in many situations)
[Nexus 5 Android Development] chdloc:
Yes, displaying the RMS along with the LED is redundant, but necessarily so as you don't know whether you are at the safe end of the yellow range or very close (1 dB, say) to red, where you should be at the ready to make gain adjustments. Most recording equipment shows a colored VU meter along with a scale. aMGC tries to do a similar thing. But since you are using the Tasker version, feel free to make any adjustments that make sense to you.

The sound does not get "killed" when you change the gain. You may hear a soft (and short) click, though. So yes, ideally, you don't want to change the gain often.
[Nexus 5 Android Development] scorpeeon:
Yesterday I could test it on a concert, some quick thoughts:

-the mod didn't start (and even caused some error messages in the camera app) when the phone is not unlocked (for instance when double tapping power button on standby). I think it might be some security measure that might prevent su permissions when the phone is not unlocked.

-I think it might be a good idea to remember the last set mic gain when starting a new recording. I constantly had to tap the down button (to go down to at least -30 dB) after every record start not to be in the red zone.

While in the red zone (at the start of recordings), the sound was pretty much just as bad as before (this makes me think it's not just the noise filter that causes this bad sound but more so the too sensitive mic gain setting), when in the yellow zone, the sound was great, with no audible distortions.

It also makes me think about a more advanced approach: if we know what is the correct mic gain setting for the current environment (yellow light) couldn't we automate it to adapt to that automatically? So if it would detect too sensitive gain settings (red led) it would go down automatically to yellow? Well you said changing gain frequently is not a good idea, so it could work like this:

-it would auto-adjust gain only at the beginning of every recording

-and there could be a button to auto-adjust the mic gain based on the current environment

Well I understand this auto-adjust might not be that easy to implement, in loud environments it would have to iteratively lower the mic gain and check if it's out of (or still in) the red zone. But still it looks doable for me. What do you think?
[Nexus 5 Android Development] chdloc:
Good and valid observations!

The power button double-tap to camera launch is a new feature, right? I have to admit that I have not updated my phone in months as I have too many mods along with my own kernel running to the point where system updates become a major hassle. Your assumption regarding permission issues may be correct. What error message(s) do you see?

I was thinking about this early on in the development phase. I abandoned that idea after realizing that acoustic environments are not predictable. Consider this thought experiment: your -30 dB gain from yesterday at the concert may cause the gain to be too low to record the first word uttered by your baby today. I also gave up on the idea of having presets as I wanted the UI to be as non-intrusive as possible. You can turn down the gain much more quickly by long-tapping the down arrow. Each short tap lowers the gain by 6 dB while each long-tap lowers it by 12 dB.

This is correct.

In principle this is a very good idea that I have also toyed around with in the past. It is everything but trivial to implement automatic gain control (AGC) correctly and robustly for arbitrary audio signals. I started the process by using the AGC mechanisms that are offered by Qualcomm as well as webRTC. They both failed miserably in dealing with signals other than speech (for which they are designed for).

I don't think I will be investing more time in adding major changes to this mod for the Nexus 5 as most people have moved on. I myself will be getting one of the new Nexus phones later this year. I may revisit the idea of implementing a more automated gain control paradigm if that phone proves to be poor in the camcorder audio department.
[Nexus 5 Android Development] scorpeeon:
Yeah I think it's a pretty new feature, I think it came around in one of the first 6.0.1 updates. It should be identical to just starting to camera from the lock screen by swiping from the camera icon there. Well, the behavior was really random. At first, the recording started there was just no LED or overlay whatsoever. The second time I tried the LED eventually appeared but there still was no overlay. Sometimes after that when I tried to start the camera it said maybe that it couldn't connect to the camera, and there might have been an app crash too along with that. Also sometimes after the recording, the LED and overlay just stuck there even after exiting the camera app with no way of hiding it - except for reboot. So it looked like it can really mess things up.

That's a good point, but one could argue that for frequent usage, remembering the last setting would be more optimal.

In the "recording the first words of your baby" scenario, the situation could have been prevented if after leaving the concert you would have made a recording where you set the gain back to the normal values. (even if you didn't have to make a recording, you would make one just for the sake of changing the gain - it's not optimal but it could work)

Whereas as it is now, if you're at a loud concert, there's pretty much nothing you can do to prevent the distorted sound at the beginning of every recording until you lower the gain.

Also, lowering the gain by 30 dB can take a quite long time as of now. Because if you tap the lowering button too fast, it just won't register, so you can't just tap it 5 times within a second (or 3 long times), because only a few taps will register, you have to wait a few seconds between every tap to register, so it usually took at least 10 seconds to lower the gain to the needed value. Well, this is something that could definitely use some improvements, I'm not sure if it's a Tasker issue or something that could be improved upon. If it would register every tap, then any gain could be achieved within a few seconds, it would be much less of a problem.

Well, you could also argue that being in a loud concert is a much more uncommon situation, so there's rarely a need for remembering the low gain settings and the default should work in most situation - and it's probably true...

Yeah I imagine it's a pretty hard thing to implement correctly. That's why I mostly think about only a basic approach just to prevent the horrible distortions in loud environments. Might try to see if it's something that I could achieve without putting too much effort in it.

Yeah I also plan to get one of this year's Nexuses if they don't screw it up :)
[Nexus 5 Android Development] chdloc:
There is a small 'x' in the lower right-hand corner of the UI with which you can dismiss it, if necessary.

See, no simple answer. To keep it the way I've implemented it, the unpredictable (acoustic environment) is kept predictable (gain always starts at the same level).

The efficiency (speed) constraints here are Tasker and the shell scripts that actually change the gains. I don't think you will save much time by trying to implement some form of AGC in Tasker as you will need to observe the sound field for a second or two as soon as the recording is started to make sure that you are not in a quiet environment where, for instance, someone just slammed the door. The solution to this problem needs to be implemented inside libaudioflinger.

If you are not bothered by the additional screen real estate required you may want to implement an extra on-screen button that reduces the gain by, say, 30 dB. A nice little Tasker and shell script project...;)
[Nexus 5 Android Development] Rubaka:
Hi do you know ROMs or kernels where this fix already included?
[Nexus 5 Android Development] chdloc:
I'm not aware of any ROM that has this (ROM-level) camcorder mod built in.
[Nexus 5 Android Development] gr-e:
I've installed CM13 yesterday and it doesn't have noise suppression.

However, after I switched to ElementalX kernel that "bubbly" sound is back again. Using "audio_platform_info.xml" fix does help with camcorder sound, but when I use a recorder app the problem is still there.

Is it possible to add another string to this .xml file to fix main microphone audio too?
[Nexus 5 Android Development] chdloc:
Are you sure? I'm neither using custom ROMs nor custom kernels, but it is my understanding that the kernel only supports "dumb" plumbing from user-space (audio HAL) to the hardware in form of an ioctl interface. It should be the ROM controlling all available signal processing, including noise suppression -- by way of closed-source calibration data -- and not the kernel. The audio_platform_info.xml file offers to overwrite the defaults defined in the audio HAL.

It may be possible to do what you are asking for with trial-and-error. You might be better off using a sound recorder app that allows you to switch to the CAMCORDER audio device and, hence, take advantage of the disabled noise suppression already achieved. I use Easy Voice Recorder Pro which also comes in a free version. I'm using Pro to allow for stereo recording.
[Nexus 5 Android Development] gr-e:
Absolutely. I decided to switch back to stock CM13 kernel. Everything worked as intended and I was happy, but they screwed up the audio in yesterday's nightly build, so now CM is affected by this issue too :(

------------------

This will fix sound in both camera and recorder apps. Not sure if it will work with other ROMs though.

<?xml version="1.0" encoding="ISO-8859-1"?>
<audio_platform_info>
<acdb_ids>
<device name="SND_DEVICE_IN_CAMCORDER_MIC" acdb_id="89"/>
<device name="SND_DEVICE_IN_HANDSET_MIC" acdb_id="89"/>
<device name="SND_DEVICE_IN_HANDSET_DMIC_STEREO" acdb_id="89"/>
</acdb_ids>
<backend_names>
</backend_names>
<config_params>
</config_params>
</audio_platform_info>
[Nexus 5 Android Development] CGA231:
Everytime I install it it "disables" audio. I can't record videos and play music anymore and sometimes it boot loops. Any help?
[Nexus 5 Android Development] chdloc:
You are likely flashing it on an unsupported ROM. This mod will only work on stock and AOSP based ROMs, but not on CM and derivatives.

What ROM are you running and which zip did you flash?
[Nexus 5 Android Development] CGA231:
Stock Marshmallow MOB30D. I Flashed the Marshmallow zip
[Nexus 5 Android Development] chdloc:
You are running an older build (April's security patch level) and I have not received any reports of this mod breaking. What version of the mod did you flash (simple or advanced), and which recovery did you use?

Is anybody else experiencing issues with this mod?
[Nexus 5 Android Development] CGA231:
I tried both simple and advanced and they both failed with the exception of the simple build. I installed this some time ago and it worked flawlessly. But I was experiencing bad audio when I used snapchat so I tried changing the settings by flashing again. I used TWRP
[Nexus 5 Android Development] chdloc:
As I haven't seen any reports like yours in many months I would not yet blame the mod just yet. Would it be possible for you to start from a completely stock system partition?

By the way, this mod will not help with Snapchat, unless you can change the recording device in the Snapchat settings to CAMCORDER. We can try some other things for dealing with poor audio when using Snapchat.
[Nexus 5 Android Development] CGA231:
That won't wipe any data I have right? I'll try
[Nexus 5 Android Development] chdloc:
That is correct if you use fastboot to only install the system partition. To avoid other issues you probably should install the same patch level that you've been running (MOB30D?).
[Nexus 5 Android Development] CGA231:
So I flashed a nee system partition. Everything is back to normal. No more mod. Would it be advisable that I try to flash it again?
[Nexus 5 Android Development] chdloc:
Why not? You can easily revert to the stock files from within the mod's Aroma installer if you are running into issues. (You would be the first in 10 months to report a problem.) Make sure, though, that you are flashing Nexus5_6.0.1_MBB29K_v1.0_audiofix_aroma.zip from this post.

Keep in mind that the mod in its current form will not improve audio quality for Snapchat, unless Snapchat can be forced to use the camcorder audio device in its app settings.
[Nexus 5 Android Development] CGA231:
Alright. Thanks for your help!
[Nexus 5 Android Development] andgtr08:
Someone tested this mod in any N5 Nougat ROM?
[Nexus 5 Android Development] chdloc:
Given the changes that AOSP has undergone from Marshmallow to Nougat I would be very surprised if the mod worked on Nougat. Since Google dropped Nexus 5 support, likely will I. There would be too many ROMs floating around that may put their own spin on the relevant AOSP code, which would turn this into a support nightmare. In addition, I will be moving on to one of the new Nexus devices. For hammerhead going forward, your best bet will likely be this approach.
[Nexus 5 Android Development] onesolo:
Sorry for the trouble, but can you make a zip of this?
[Nexus 5 Android Development] chdloc:
Flashable zip of "simple" camcorder audio fix for Nougat

Here is a flashable zip of the "simple" -- no noise suppression and no aMGC -- camcorder audio fix that should work on Nougat ROMs (or any other ROM for that matter). Note that this is not an Aroma installer, so it will not give you the option to install add-ons, such as stereo recording/playback.
[Nexus 5 Android Development] RoadToNever:
Is it possible to do line-in recording? I tried a trrs splitter like this one but there's no signal coming in Easy voice recorder.
[Nexus 5 Android Development] chdloc:
Did you try what I suggested here?
[Nexus 5 Android Development] [Gorgasm]:
I know that I'm a little off-topic, but what is your opinion about the new Pixel devices ? Considering that they are built by HTC, perhaps there is a chance that the microphones have a better quality than in the past... Hope to see an improvement, for the moment I still use your mod with great success !
[Nexus 5 Android Development] chdloc:
It does seem that the Pixel's microphone(s) are of higher quality than the ones used in the Nexus 5. I did watch the videos shared by the guy on Reddit before they got taken down. While a couple of them are still available, the one where he is walking down the steps showing off the Pixel's image stabilization indicated that there is still audible noise suppression going on, but to a much lesser extend than on the Nexus 5. While this video shows that scene with a recording made by the Nexus 6p beside it, it is not clear whether the audio was recorded by the Pixel. Also, it is not clear whether the distortion audible in that video was created by the phone itself of by some post-processing procedure.

I've pre-ordered the Pixel XL. I'll let you guys know what I think about the audio once I get it.
[Nexus 5 Android Development] Joy Bangla:
[MENTION=2760454]chdloc[/MENTION] any plans on advanced nougat mod so we can get stereo playback on our Nexus 5??
[Nexus 5 Android Development] chdloc:
I have no plans to develop the advanced mod for Nougat.

If all you want is stereo playback, I can certainly make that available for you. Post your current mixer_paths.xml file and I'll create a simple flashable zip.
[Nexus 5 Android Development] jacomail95:
This advanced stereo playback, is it different by the ones you have already created, with and without the biQuads lines?

Inviato dal mio Nexus 5 con Tapatalk 2
[Nexus 5 Android Development] chdloc:
It is time to say goodbye

Folks, I have enjoyed my Nexus 5, even with all the flaws it has. But time has come for me to move on.

I've been using my new Pixel XL for the last week and it is a significant upgrade in every single way. In particular, the microphone recordings sound much better out-of-the-box, so I will not have to mess with that anymore. Still, I've already enabled stereo recording and dual-loudspeaker playback, which is of only limited use due to the extreme level differences between the speakers. I'm also currently working on porting my biQuads mod over to the Pixel.

Having said that, I'll still be around to answer questions and to continue to make the "easy-to-maintain" parts of the camcorder mod (simple mod, stereo recording, and stereo playback) available. I'll be updating this post over the next couple of weeks with flashable zips.
[Nexus 5 Android Development] Tarcis:
Is there a way to move the live level adjust amgc? The new camera app adds a button to take screen shot right on top of the level adjusting buttons and meter.

Thanks!
[Nexus 5 Android Development] chdloc:
Try the attached app update. The UI should now be on the lower left-hand side of the screen. Note that you may have to re-grant Accessibility status after the update.
[Nexus 5 Android Development] Tarcis:
Beautiful!!! Congratulations on this great project.

Why don´t you "sell" this apk in play store? That way we can donate easily.

Thanks!

PS: No need to re-grant acessibility permissions.
[Nexus 5 Android Development] chdloc:
Thanks. I'm not in this for the money.

If you'd like, give a donation to your favorite charity instead.
[Nexus 5 Android Development] [Gorgasm]:
Thank you for your work on the Nexus 5 and make it better, your mod is the reason why I didn't change my Nexus 5 for another phone (and the Nexus 5 is one the best Android device ever, despite some weaknesses).

So, have you ever tried to record in a loud environment with your Pixel XL ? I'm curious to hear it, it seems that in terms of image quality, the Pixel and Pixel XL are the best photophone on the market, but there is no word about their audio capacities (recording and playback).

For the moment, both Pixel are not available in my country, which is very very disappointing :(
[Nexus 5 Android Development] chdloc:
Here are my thoughts on the Pixel audio:

While I have not taken my Pixel to a concert, I made a few recordings in pretty loud environments. The audio quality is very acceptable. I think there are a few YouTube videos showcasing the performance. (After some mixer modifications, stereo recording works fine, too.)

While there does seem to be some mild noise suppression going on, I do not feel that I have to step in.

The single bottom-firing loudspeaker is significantly louder and clearer than the one on the Nexus 5. (After some mixer modifications, stereo playback works fine, too.)

The headphone output is of sufficient quality for the majority of users. (After some mixer modifications, my biQuads filtering paradigm works on this phone, too.)
[Nexus 5 Android Development] [Gorgasm]:
Thanks for your reply ! I will definitively buy a Pixel, even if I still hesitate with the LG V20 which seems to have incredible audio capabilities too, the Pixel is, for me, more homogeneous, and it's Google :)
[Nexus 5 Android Development] gr-e:
upd. This fix is for CAF builds. For AOSP use the older one.

Fix for the first CM14.1 CAF nightly build. Disables noise suppression for both camcorder and audio recorder. Replace /system/etc/audio_platform_info.xml contents with this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Copyright (c) 2014, The Linux Foundation. All rights reserved. -->
<!-- -->
<!-- Redistribution and use in source and binary forms, with or without -->
<!-- modification, are permitted provided that the following conditions are -->
<!-- met: -->
<!-- * Redistributions of source code must retain the above copyright -->
<!-- notice, this list of conditions and the following disclaimer. -->
<!-- * Redistributions in binary form must reproduce the above -->
<!-- copyright notice, this list of conditions and the following -->
<!-- disclaimer in the documentation and/or other materials provided -->
<!-- with the distribution. -->
<!-- * Neither the name of The Linux Foundation nor the names of its -->
<!-- contributors may be used to endorse or promote products derived -->
<!-- from this software without specific prior written permission. -->
<!-- -->
<!-- THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -->
<!-- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -->
<!-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -->
<!-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -->
<!-- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -->
<!-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -->
<!-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -->
<!-- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -->
<!-- OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -->
<!-- IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -->
<audio_platform_info>
<acdb_ids>
<!-- Output devices -->
<device name="SND_DEVICE_OUT_HANDSET" acdb_id="7" />
<device name="SND_DEVICE_OUT_SPEAKER" acdb_id="15" />
<device name="SND_DEVICE_OUT_HEADPHONES" acdb_id="10" />
<device name="SND_DEVICE_OUT_VOICE_HANDSET" acdb_id="7" />
<device name="SND_DEVICE_OUT_VOICE_SPEAKER" acdb_id="15" />
<device name="SND_DEVICE_OUT_VOICE_HEADPHONES" acdb_id="10" />
<device name="SND_DEVICE_OUT_SPEAKER_AND_HDMI" acdb_id="15" />

<!-- Input devices -->
<device name="SND_DEVICE_IN_HANDSET_MIC" acdb_id="4" />
<device name="SND_DEVICE_IN_SPEAKER_MIC" acdb_id="4" />
<device name="SND_DEVICE_IN_HANDSET_DMIC" acdb_id="4" />
<device name="SND_DEVICE_IN_VOICE_DMIC" acdb_id="89" />
<device name="SND_DEVICE_IN_CAMCORDER_MIC" acdb_id="89" />
<device name="SND_DEVICE_IN_HANDSET_STEREO_DMIC" acdb_id="89" />
<device name="SND_DEVICE_IN_VOICE_REC_MIC" acdb_id="89" />
<device name="SND_DEVICE_IN_VOICE_REC_DMIC_STEREO" acdb_id="89" />
</acdb_ids>

<backend_names>
<!-- empty -->
</backend_names>

<pcm_ids>
<!-- empty -->
</pcm_ids>

<device_names>
<!-- empty -->
</device_names>
</audio_platform_info>
[Nexus 5 Android Development] [Gorgasm]:
Hi !

I will probably buy a new device soon (I don't know which one for the moment, both Pixel are not available in my country yet :( ), but I will keep my Nexus 5 for testing. I would like to use the simple fix (not the advanced one, no aMGC) and reduce permanently the gain of microphones. As far I konw, the top microphone (the auxiliary) is used for the left channel, and the bottom microphone (the main) is used for the right channel. By using the aMGC, I needed to reduce the gain by 54 dB (or 60 dB, it depends).

So, which values (or lines) I have to edit (or add) in mixer_paths.xml to reduce permanently the gain of both microphones (in stereo, obviously) ?

Thanks !