[01/10] [DEV] [FIXED] Low Speakerphone Mic Gain & High Background Noise ONE CLICK FIX

Search This thread

memin1857

Senior Member
Jun 2, 2010
907
202
Istanbul
[01/10] [DEV] [FIXED] Low Speakerphone Mic Gain & High Background Noise ONE CLICK FIX


01/10 Update: New Tytung R12.4 Kernel is attached at the bottom. initrd.gz is removed so you can use it with your magldr + cm7/miui/aosp rom. THIS IS ALL THAT IS NEEDED FOR MIC GAIN AND VOICE ECHO FIX.

---------older stuff ------------

Flash THIS FILE from CWM Recovery. (For MAGLDR AOSP, CM7 and MIUI ROMS. NOT for SENSE ROMS) This contains the tytung r12beta1 kernel.
More information: http://xdaforums.com/showpost.php?p=17207745&postcount=268

For sense roms check post 308:
http://xdaforums.com/showpost.php?p=17537327&postcount=308
Check the libaudio.so & acdb file information below. Also you may need to copy default.acdb as htcleo.acdb because current version of sense kernel may bootloop without it.

For MIUI if there is miui_default.acdb exists in/etc/firmware, you should overwrite it with the default.acdb version below.

VOICE ECHO:If the "remote" party have echo reduce "your in-call" volume with the side vol keys on your hd2.
More info: http://xdaforums.com/showpost.php?p=17233906&postcount=279

Please check this post, try the acdb file there and give feedback here please whether it fixes echo or not:
http://xdaforums.com/showpost.php?p=17997557&postcount=330


ALWAYS MAKE A FULL BACKUP FROM CWM, JUST IN CASE!
Thanks to mdebeljuh and jdivic for fixing the kernel code and tytung for releasing a new version of his kernel with the new code and all the others I forgot to mention.


HD2 MIC CONTROL APP:This app can easily adjust mic gain in realtime inside a call and also set it permanently. Get it FROM MARKET.Thanks to windroidHD



For CLK, try this: http://xdaforums.com/showpost.php?p=17230125&postcount=278



IF YOU DON'T HAVE ENOUGH GAIN EVEN WITH 400 GAIN CHECK THE TWO FILES BELOW. YOU SHOULD HAVE ENOUGH VOICE VOLUME AT THE REMOTE SIDE WITH 400 GAIN!

-----ANYTHING BELOW IS FOR THE CURIOUS OR FOR DEVELOPMENT-----


libaudio.so
This fix is libaudio.so dependent! It is known not to work with "older" drizztje libaudio.so. Working one is THIS. I think this is the iamgpc version. You may get bizzare force closes or slowdowns with "older" drizztje libaudio. The included iamgpc version has robot voice fix and volume level fix, so it works well. New compatible libaudio is included with tytung r12.3 kernel, see above.

default.acdb
This fix includes 122,442 bytes (119,57K) default.acdb. Other sizes may or may not work well, THIS one works. It is from the aosp 2.3.4 nexushd2 rom. It seems 2.3.5 has different acdb file.
It is possible that the 122,442 bytes default.acdb file may be causing voice echo. Try the one below, if there is enough feedback I will update the update zip files.
Alternative ACDB file:
Please check this post, try the acdb file there and give feedback here please whether it fixes echo or not:
http://xdaforums.com/showpost.php?p=17997557&postcount=330


KERNEL DEVELOPERS:
- Here is the "latest" diff file: diff_mic_gain.txt
- Please make sure your kernel code ignores htcleo.acdb. The diff does not have the code to ignore htcleo.acdb. Chefs, you can also just rename/delete htcleo.acdb
- You MUST include the above iamgpc libaudio.so and default.acdb along with 10mic_level script in your kernel zip update file.

HOW IT WORKS:
The new kernel code adjusts mic gain levels from /proc/mic_level
Use a Terminal Emulator or Gscript with the below commands to set gain in REALTIME (even while inside a call)
You can also use the HD2 MIC CONTROL app in Market for easier adjusting.

To set normal mode (handset) gain:
echo '0 350' > /proc/mic_level

To set speakerphone mode gain:
echo '1 600' > /proc/mic_level

More than 600 gives background noise, less than 200 is too quiet.

If you want to set the levels permanently, edit the mic_level init script in /etc/init.d

LeTama's previous method of fixing the high background noise (caused by extreme mic gain) was modifying the acdb file with values from winmo. It worked well for the normal speaking but made speakerphone unusuable and overall audio playback low. Modifying acdb file is difficult, the above fix uses the default.acdb file and modify the values in realtime while inside a call.

While the post states FIXED, there is always room for tweaking or implementing better solutions. Currently the problem is fixed but can also be considered "under development"



----------Anything below is OLD STUFF----------


28/08 EDIT: THE PROBLEM IS FIXED! Thanks to respected developers mdebeljuh and jdivic we are now able to set mic gain level for normal mode and speakerphone mode seperately.
THAT MEANS you will have crystal clear voice with no high background noise while doing normal talking AND you will have working speakerphone mode AND you will have properly high audio playback volume ALL AT THE SAME TIME.
I have tested the test kernel mdebeljuh sent me and I confirm it is working. There will be more testing with values, different roms and file versions.

THIS THREAD IS "NOT" SIMPLY JUST ABOUT HIGH BACKGROUND NOISE PROBLEM. It's already been fixed with LeTama's htcleo.acdb file (but it has side effects, check post 8) This thread is about MIC GAIN LEVELS BEING THE SAME between normal and speakerphone mode. (So you either have high background noise OR not usable speakerphone mode)

--------

Hello everyone,
THIS IS THE LAST "MAJOR" PROBLEM WITH THE HD2 ANDROID PROJECT. It is present in every rom available today.
Since this is almost a year of development, here is the description and history of the problem:

Description of the problem:
With LeTama's 113910 bytes htcleo.acdb file that is included in many roms: Everybody are getting complaints that people can't hear them properly when they are on speakerphone mode, I found out that if you enable speakerphone the mic does not get more sensitive. Normally android has to change mic gain when speakerphone is enabled. Mic gain levels are the same when normal talking, and in speakerphone mode. (I am talking about what volume the remote party hears your voice.

With no htcleo.acdb file or with android's default.acdb file or htcleo.acdb file that is not LeTama's. (same as the default default.acdb): This time the complaints are that the remote party hears too much background noice and can't understand the hd2 caller properly. This is because the mic gain is set to speakerphone levels even when in normal mode.

If you remove LeTama's htcleo.adcb in /etc/firmware (which forces android to use default.acdb instead) the mic becomes too sensitive in both normal and speakerphone mode.
WITH LeTama's htcleo.acdb present mic gain is normal in both normal and speakerphone mode.
WITHOUT LeTama's htcleo.acdb present mic gain high in both normal and speakerphone mode.
That means mic gain is either always in speakerphone mode or always in normal mode depending on acdb file used.
But actually mic gain has to be low in normal mode and high in speakerphone mode. This has to be fixed because you either can't use speakerphone or you get too much backgorund noise and people complain.
I tried with a samsung native android phone and with winmo hd2 and mic gain gets higher (mic gets more sensitive) when speakerphone is enabled. This is not about the speaker on your phone. It is about the microphone in your phone and its gain adjustment by android.

Some ROM chefs include LeTama's htcleo.acdb, some of them don't include any htcleo.acdb file, and some of them just make another copy of default default.acdb file as htcleo.acdb. All files are in /etc/firmware Android's original default.acdb file is 129346 bytes. I don't know if any other different size versions are available.

Here is how I test: I call another phone which I hold to my ear with my hd2. I mute mic of the phone in my ear and put hd2 on the table. I talk or have some audio in the background such as tv or I hit my fingernails on the table or something. I turn speakerphone on the hd2 on and off and see if what I hear on the other phone on my ear get higher or not. OR you can call someone and ask them of course

History:
Normally Android uses default.acdb for audio/mic gain levels. htcleo.acdb is made by LeTama and newer kernels first look for htcleo.acdb and if it is not found fallback to default.acdb. This was made because mic gain is unacceptably high and prevents proper conversation with hd2 android. So many modern hd2 android roms use htcleo.acdb But I don't think every hd2 android rom chef knows about this. File sizes should always be checked. There is also a htcleo.acdb file made by iamgpc (125868 bytes) but it is always in high mic gain mode so you can't talk properly with it. I do not know why he created it.

LeTama says: (Author of the htcleo.acdb file that enables proper understandable conversation, but not properly functioning speakerphone)
The way I did htcleo.acdb was quite complex:
- I patched kernel audio driver to:
1) kill acdb switches in audio driver to avoid interference while extracting values
2) expose a sysfs variable to userland with acdb values.

- I wrote a userspace tool that:
1) Parse a template android acdb to get android acdb channels/bitrates.
2) loops on all acdb entries and get associated winmo values with sysfs kernel variable.
2) reconstruct htcleo.acdb by merging channels/bitrates/values.

With all these, I boot android from haret on SD, get winmo values and generates the acdb with the tools.

As you can see, it's a bit tricky, I can provide you patches and source code, but it's a bit rough and patch is against an old kernel, not sure it will go smoothly.

If you want only to patch htcleo.acdb with android values for some channels, I'd suggest writing a specific tool for that, it's far more easier. The android acdb file structure is quite straightforward if you don't have to interpret audio values and just want to copy entries.

But first, you'll need to identify which entry is used when going speaker mode, you probably need to add few traces in kernel audio driver.
.............
Frankly, I don't know if this can be fixed from htcleo.acdb by adjusting the values, or does kernel need modification, it would require traces to see if the kernel is using same acdb entries or separated ones. If it's separated, you could get speaker mode entries from android and patch them into htcleo.acdb. If it's not, kernel modification is probably required.
.............
I have thought also about not enabling speakerphone once leading to missing data. It could be, however Cotulla told me that the acdb in winmo is initialized completely by spl, so values should be there. But who knows... Anyway, if you need advices on how to patch the acdb, let me know. I'll dig in my archive for the acdb rebuild userspace tool source, it could give you a good base to build a patch tool.

OP Note: LeTama doesn't have time for this matter, but he is willing to share what he did before.

iamgpc says:
MIC gain is not controlled by libaudio.so It is the part of kernel

-----------------
What needs to be done:
First we should find out if the kernel or the acdb file is the culprit. Does the LeTama's current acdb file have different gain values for normal and speakerphone, or are they the same? Does the kernel look for two different values for normal and speakerphone, or erraneously look for a single value?
What I think: Since the original default.acdb file comes with android and also does have equal levels with speakerphone and normal mode then I think current kernels must be wrongfully looking at the normal mode value for speakerphone?
Then fixing the kernel or acdb file whichever is needed.
I believe that finding where the speakerphone mic gain entry is in the acdb file and modifying the kernel code to make it look for this correct value for speakerphone mode, and using LeTama's htcleo.acdb file is the key. Better way would be disabling htcleo.acdb file in kernel and making kernel lower the value it reads from the default.acdb file when in normal mode. This way no rom chef knowledge would be required. (I am sure many chefs will forget/don't know the htcleo.acdb and use default.acdb file)
Note: I do not know if android has AGC (auto gain control) thing in kernel. It is possible that it is interfering with actual mic gain settings.
Unfortunately acdb file also affects audio playback volume, so while fixing background noise with LeTama's acdb file, you may be unhappy with the audio output volume, though it can be fixed with dsp manager or volume+ apps.
Note: LeTama's shared his tools on post 3.

The problem is fixed by mdebeljuh and jdivic. Check the opening sentences of this post.
 

Attachments

  • kernel_tytung_r12.4_noinitrd_magldr.zip
    3.2 MB · Views: 3,220
Last edited:

Hannes_HD2

Senior Member
Apr 5, 2010
164
38
For as long as I am using Android on my HD2, I suffer from high mic gain in normale mode (not speakerphone). This is really annoying, so I'd definitely love to see that last glitch to be fixed!
 

letama

Senior Member
Feb 13, 2008
1,689
2,324
Hi there!

Here are the files, I included the kernel patch and the resulting q6audio.c. The patch has other crap in it, the only modification required is in q6audio.c. It was against a very old kernel, I'm not sure you can use it "as-is".

You also have the user space tool source and my script to compile it.

To dump values, you have to flash a working WinMo 6.5 to have winmo values in memory and launch android with Haret .

To use it, compile the kernel with the modification. It will somehow kill your audio as it won't set acdb to be able to dump acdb in memory untouched. The userspace tools expect to find a pure android default.acdb in the directory where it's launched, it will query kernel values, and remap it to a proper htcleo.acdb in /sdcard/acdb_out.acdb.

Good luck!

LeTama
 

Attachments

  • acdb_gen_kit.zip
    18 KB · Views: 1,528

codiak

Senior Member
Feb 27, 2009
782
140
+1 for this issue.
With or without htcleo file its way too loud.
Would love to have that fixed.
 

memin1857

Senior Member
Jun 2, 2010
907
202
Istanbul
Guys, if you have the high mic gain problem that means your rom doesn't include "LeTama's" htcleo.acdb file. (113910 bytes, check the file size, your rom chef might have just copied original default.acdb as htcleo.acdb)
Just download the attachment below and extract it. Copy the htcleo.acdb file you just extracted to /etc/firmware with rootexplorer or similar file manager and reboot.
Your calls will be OK by then and people won't complain. But speakerphone mode will also be low gain from now on. But since most of the time you are calling in normal mode, it is better to have htcleo.acdb in /etc/firmware
 

Attachments

  • htcleo.zip
    5 KB · Views: 1,873
Last edited:

codiak

Senior Member
Feb 27, 2009
782
140
What about /system/etc/firmware? I saw this path in other threads about this problem?
I have that file in /etc/firmware and /system/etc/firmware but still mic is too loud.

Edit:
OK, overwrote your file with the existing one. Mic seems better now, thanks!
But for me, its still about 25% to loud :(

I am a bit curios... is this file in somehow involved in bluetooth playback or music output at all?
Trough all the testing I made the last days I am unsure if at least the bluetooth playback is a little bit worse now?
I would be glad if that were not confirmed :)

Thanks soooo much dude yeah.. love it. kool. i love ya =)
 
Last edited by a moderator:

memin1857

Senior Member
Jun 2, 2010
907
202
Istanbul
I think /etc/firmware and /system/etc/firmware are the same.
I am not sure about bluetooth or audio playback. acdb may possibly affect it but can you try reverting back to see and give feedback?
We really need to make this thread attract attention.
 
  • Like
Reactions: shendan

codiak

Senior Member
Feb 27, 2009
782
140
Its really hard to tell if you have to reboot your phone and have no real comparison.
I would need a second hd2 ;)
But more imported to me is that the mic is still about 25% too loud :(
Is there a way to tweak the file a bit more?
I have no programming knowledge.
 
Last edited:

Rick_1995

Inactive Recognized Developer
Sep 3, 2009
1,118
3,017
Santa Clara
What about /system/etc/firmware? I saw this path in other threads about this problem?
I have that file in /etc/firmware and /system/etc/firmware but still mic is too loud.

Edit:
OK, overwrote your file with the existing one. Mic seems better now, thanks!
But for me, its still about 25% to loud :(

I am a bit curios... is this file in somehow involved in bluetooth playback or music output at all?
Trough all the testing I made the last days I am unsure if at least the bluetooth playback is a little bit worse now?
I would be glad if that were not confirmed :)

on Android boot, /system partition is mounted and merged with "/" (root) which already contains the initramfs (the ramdisk provided with your kernel).

so just replacing the file in /system/etc/firmware and rebooting should remove and overwrite any clones thereof.
 
  • Like
Reactions: codiak

Ambious

Senior Member
May 11, 2008
1,828
478
Haifa
Not a dev, but out of pure interest - is this the reason that voice commands seem to be so shaky? The wave form when using voice search looks like static half of the time, and it just doesn't hear anything the other half.
This happens on all Gingerbread Sense builds.
 

jan-willem3

Inactive Recognized Developer
Mar 13, 2010
1,499
810
┌┐(●_●)┌┐
Why is this thread pinned it is completely rediclious.

I can make a thread to

[DEV] Fixing camera bugs

[DEV] Fixing PPP data on clk

[DEV] Fixing I2C code

etc...

This are bugs that are annoying for you and you try to track attention of the developers. Let the developers fix whatever they want what they find annoying. They are not here to fix your problem.
 
  • Like
Reactions: KrisHilbun

gt2009

Senior Member
Mar 29, 2010
119
79
Why is this thread pinned it is completely rediclious.

I can make a thread to

[DEV] Fixing camera bugs

[DEV] Fixing PPP data on clk

[DEV] Fixing I2C code

etc...

This are bugs that are annoying for you and you try to track attention of the developers. Let the developers fix whatever they want what they find annoying. They are not here to fix your problem.
WOW, you just prove that you’re not a developer that belongs to XDA. XDA is about helping others and not being selfish. I do hope you will change your attitude.
 
  • Like
Reactions: rashidkn

memin1857

Senior Member
Jun 2, 2010
907
202
Istanbul
It is pinned (stickied) because this is last "major" problem left that happens on every rom. All other problems can be considered minor. Please stay on topic and don't discuss about things unrelated to the problem mentioned in first of this thread. This is not only my problem, every hd2 user has it. This is the best way to get a developers attention, it is the "developers" forum.
I asked noellenchris to make this sticky for some time to see if it will get attention from a developer. I thank him here for that since I believe he shares my belief that this thread is important for the hd2 android project. Sticky making is a decision of a forum moderator.

I edited the opening post to be more detailed and specific btw.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 44
    [01/10] [DEV] [FIXED] Low Speakerphone Mic Gain & High Background Noise ONE CLICK FIX


    01/10 Update: New Tytung R12.4 Kernel is attached at the bottom. initrd.gz is removed so you can use it with your magldr + cm7/miui/aosp rom. THIS IS ALL THAT IS NEEDED FOR MIC GAIN AND VOICE ECHO FIX.

    ---------older stuff ------------

    Flash THIS FILE from CWM Recovery. (For MAGLDR AOSP, CM7 and MIUI ROMS. NOT for SENSE ROMS) This contains the tytung r12beta1 kernel.
    More information: http://xdaforums.com/showpost.php?p=17207745&postcount=268

    For sense roms check post 308:
    http://xdaforums.com/showpost.php?p=17537327&postcount=308
    Check the libaudio.so & acdb file information below. Also you may need to copy default.acdb as htcleo.acdb because current version of sense kernel may bootloop without it.

    For MIUI if there is miui_default.acdb exists in/etc/firmware, you should overwrite it with the default.acdb version below.

    VOICE ECHO:If the "remote" party have echo reduce "your in-call" volume with the side vol keys on your hd2.
    More info: http://xdaforums.com/showpost.php?p=17233906&postcount=279

    Please check this post, try the acdb file there and give feedback here please whether it fixes echo or not:
    http://xdaforums.com/showpost.php?p=17997557&postcount=330


    ALWAYS MAKE A FULL BACKUP FROM CWM, JUST IN CASE!
    Thanks to mdebeljuh and jdivic for fixing the kernel code and tytung for releasing a new version of his kernel with the new code and all the others I forgot to mention.


    HD2 MIC CONTROL APP:This app can easily adjust mic gain in realtime inside a call and also set it permanently. Get it FROM MARKET.Thanks to windroidHD



    For CLK, try this: http://xdaforums.com/showpost.php?p=17230125&postcount=278



    IF YOU DON'T HAVE ENOUGH GAIN EVEN WITH 400 GAIN CHECK THE TWO FILES BELOW. YOU SHOULD HAVE ENOUGH VOICE VOLUME AT THE REMOTE SIDE WITH 400 GAIN!

    -----ANYTHING BELOW IS FOR THE CURIOUS OR FOR DEVELOPMENT-----


    libaudio.so
    This fix is libaudio.so dependent! It is known not to work with "older" drizztje libaudio.so. Working one is THIS. I think this is the iamgpc version. You may get bizzare force closes or slowdowns with "older" drizztje libaudio. The included iamgpc version has robot voice fix and volume level fix, so it works well. New compatible libaudio is included with tytung r12.3 kernel, see above.

    default.acdb
    This fix includes 122,442 bytes (119,57K) default.acdb. Other sizes may or may not work well, THIS one works. It is from the aosp 2.3.4 nexushd2 rom. It seems 2.3.5 has different acdb file.
    It is possible that the 122,442 bytes default.acdb file may be causing voice echo. Try the one below, if there is enough feedback I will update the update zip files.
    Alternative ACDB file:
    Please check this post, try the acdb file there and give feedback here please whether it fixes echo or not:
    http://xdaforums.com/showpost.php?p=17997557&postcount=330


    KERNEL DEVELOPERS:
    - Here is the "latest" diff file: diff_mic_gain.txt
    - Please make sure your kernel code ignores htcleo.acdb. The diff does not have the code to ignore htcleo.acdb. Chefs, you can also just rename/delete htcleo.acdb
    - You MUST include the above iamgpc libaudio.so and default.acdb along with 10mic_level script in your kernel zip update file.

    HOW IT WORKS:
    The new kernel code adjusts mic gain levels from /proc/mic_level
    Use a Terminal Emulator or Gscript with the below commands to set gain in REALTIME (even while inside a call)
    You can also use the HD2 MIC CONTROL app in Market for easier adjusting.

    To set normal mode (handset) gain:
    echo '0 350' > /proc/mic_level

    To set speakerphone mode gain:
    echo '1 600' > /proc/mic_level

    More than 600 gives background noise, less than 200 is too quiet.

    If you want to set the levels permanently, edit the mic_level init script in /etc/init.d

    LeTama's previous method of fixing the high background noise (caused by extreme mic gain) was modifying the acdb file with values from winmo. It worked well for the normal speaking but made speakerphone unusuable and overall audio playback low. Modifying acdb file is difficult, the above fix uses the default.acdb file and modify the values in realtime while inside a call.

    While the post states FIXED, there is always room for tweaking or implementing better solutions. Currently the problem is fixed but can also be considered "under development"



    ----------Anything below is OLD STUFF----------


    28/08 EDIT: THE PROBLEM IS FIXED! Thanks to respected developers mdebeljuh and jdivic we are now able to set mic gain level for normal mode and speakerphone mode seperately.
    THAT MEANS you will have crystal clear voice with no high background noise while doing normal talking AND you will have working speakerphone mode AND you will have properly high audio playback volume ALL AT THE SAME TIME.
    I have tested the test kernel mdebeljuh sent me and I confirm it is working. There will be more testing with values, different roms and file versions.

    THIS THREAD IS "NOT" SIMPLY JUST ABOUT HIGH BACKGROUND NOISE PROBLEM. It's already been fixed with LeTama's htcleo.acdb file (but it has side effects, check post 8) This thread is about MIC GAIN LEVELS BEING THE SAME between normal and speakerphone mode. (So you either have high background noise OR not usable speakerphone mode)

    --------

    Hello everyone,
    THIS IS THE LAST "MAJOR" PROBLEM WITH THE HD2 ANDROID PROJECT. It is present in every rom available today.
    Since this is almost a year of development, here is the description and history of the problem:

    Description of the problem:
    With LeTama's 113910 bytes htcleo.acdb file that is included in many roms: Everybody are getting complaints that people can't hear them properly when they are on speakerphone mode, I found out that if you enable speakerphone the mic does not get more sensitive. Normally android has to change mic gain when speakerphone is enabled. Mic gain levels are the same when normal talking, and in speakerphone mode. (I am talking about what volume the remote party hears your voice.

    With no htcleo.acdb file or with android's default.acdb file or htcleo.acdb file that is not LeTama's. (same as the default default.acdb): This time the complaints are that the remote party hears too much background noice and can't understand the hd2 caller properly. This is because the mic gain is set to speakerphone levels even when in normal mode.

    If you remove LeTama's htcleo.adcb in /etc/firmware (which forces android to use default.acdb instead) the mic becomes too sensitive in both normal and speakerphone mode.
    WITH LeTama's htcleo.acdb present mic gain is normal in both normal and speakerphone mode.
    WITHOUT LeTama's htcleo.acdb present mic gain high in both normal and speakerphone mode.
    That means mic gain is either always in speakerphone mode or always in normal mode depending on acdb file used.
    But actually mic gain has to be low in normal mode and high in speakerphone mode. This has to be fixed because you either can't use speakerphone or you get too much backgorund noise and people complain.
    I tried with a samsung native android phone and with winmo hd2 and mic gain gets higher (mic gets more sensitive) when speakerphone is enabled. This is not about the speaker on your phone. It is about the microphone in your phone and its gain adjustment by android.

    Some ROM chefs include LeTama's htcleo.acdb, some of them don't include any htcleo.acdb file, and some of them just make another copy of default default.acdb file as htcleo.acdb. All files are in /etc/firmware Android's original default.acdb file is 129346 bytes. I don't know if any other different size versions are available.

    Here is how I test: I call another phone which I hold to my ear with my hd2. I mute mic of the phone in my ear and put hd2 on the table. I talk or have some audio in the background such as tv or I hit my fingernails on the table or something. I turn speakerphone on the hd2 on and off and see if what I hear on the other phone on my ear get higher or not. OR you can call someone and ask them of course

    History:
    Normally Android uses default.acdb for audio/mic gain levels. htcleo.acdb is made by LeTama and newer kernels first look for htcleo.acdb and if it is not found fallback to default.acdb. This was made because mic gain is unacceptably high and prevents proper conversation with hd2 android. So many modern hd2 android roms use htcleo.acdb But I don't think every hd2 android rom chef knows about this. File sizes should always be checked. There is also a htcleo.acdb file made by iamgpc (125868 bytes) but it is always in high mic gain mode so you can't talk properly with it. I do not know why he created it.

    LeTama says: (Author of the htcleo.acdb file that enables proper understandable conversation, but not properly functioning speakerphone)
    The way I did htcleo.acdb was quite complex:
    - I patched kernel audio driver to:
    1) kill acdb switches in audio driver to avoid interference while extracting values
    2) expose a sysfs variable to userland with acdb values.

    - I wrote a userspace tool that:
    1) Parse a template android acdb to get android acdb channels/bitrates.
    2) loops on all acdb entries and get associated winmo values with sysfs kernel variable.
    2) reconstruct htcleo.acdb by merging channels/bitrates/values.

    With all these, I boot android from haret on SD, get winmo values and generates the acdb with the tools.

    As you can see, it's a bit tricky, I can provide you patches and source code, but it's a bit rough and patch is against an old kernel, not sure it will go smoothly.

    If you want only to patch htcleo.acdb with android values for some channels, I'd suggest writing a specific tool for that, it's far more easier. The android acdb file structure is quite straightforward if you don't have to interpret audio values and just want to copy entries.

    But first, you'll need to identify which entry is used when going speaker mode, you probably need to add few traces in kernel audio driver.
    .............
    Frankly, I don't know if this can be fixed from htcleo.acdb by adjusting the values, or does kernel need modification, it would require traces to see if the kernel is using same acdb entries or separated ones. If it's separated, you could get speaker mode entries from android and patch them into htcleo.acdb. If it's not, kernel modification is probably required.
    .............
    I have thought also about not enabling speakerphone once leading to missing data. It could be, however Cotulla told me that the acdb in winmo is initialized completely by spl, so values should be there. But who knows... Anyway, if you need advices on how to patch the acdb, let me know. I'll dig in my archive for the acdb rebuild userspace tool source, it could give you a good base to build a patch tool.

    OP Note: LeTama doesn't have time for this matter, but he is willing to share what he did before.

    iamgpc says:
    MIC gain is not controlled by libaudio.so It is the part of kernel

    -----------------
    What needs to be done:
    First we should find out if the kernel or the acdb file is the culprit. Does the LeTama's current acdb file have different gain values for normal and speakerphone, or are they the same? Does the kernel look for two different values for normal and speakerphone, or erraneously look for a single value?
    What I think: Since the original default.acdb file comes with android and also does have equal levels with speakerphone and normal mode then I think current kernels must be wrongfully looking at the normal mode value for speakerphone?
    Then fixing the kernel or acdb file whichever is needed.
    I believe that finding where the speakerphone mic gain entry is in the acdb file and modifying the kernel code to make it look for this correct value for speakerphone mode, and using LeTama's htcleo.acdb file is the key. Better way would be disabling htcleo.acdb file in kernel and making kernel lower the value it reads from the default.acdb file when in normal mode. This way no rom chef knowledge would be required. (I am sure many chefs will forget/don't know the htcleo.acdb and use default.acdb file)
    Note: I do not know if android has AGC (auto gain control) thing in kernel. It is possible that it is interfering with actual mic gain settings.
    Unfortunately acdb file also affects audio playback volume, so while fixing background noise with LeTama's acdb file, you may be unhappy with the audio output volume, though it can be fixed with dsp manager or volume+ apps.
    Note: LeTama's shared his tools on post 3.

    The problem is fixed by mdebeljuh and jdivic. Check the opening sentences of this post.
    13
    FIX -setting mic level/gain

    Here are test and debug kernel. Only difference is that debug kernel has a lot dmesg output. Unfortunately the solution is dependent on libaudio so test it and report back. I have also included my libaudio so you can try it if it is not working. If you can't make it work please install debug kernel and send us dmesg output with description of what where you trying to do.
    For now this solution is not working with drizztje libaudio.
    UPDATE: just to make something clear, libaudio is not made by me but it is from tytung build which I am using.
    12
    tytung_r12_beta1

    Since mdebeljuh used rafpigna kernel's .config file to compile r11 test kernel and some people got problems, I decide to compile a test kernel using my .config file.
    Kernel r12 beta1 has all features of kernel r11 plus "Mic Gain" fix.

    P.S. Thanks to mdebeljuh and jdivic's "Mic Gain" fix and memin1857's summary in the 1st post.

    Downloads: (for NexusHD2-Gingerbread in default)

    If you're using other ROMs, it's better to use initrd.gz from your ROMs for best compatibility.
    • For MAGLDR users, please delete initrd.gz from kernel_tytung_r12_beta1_update.zip before flashing it.
    • For cLK users, please download and uncompress cLK_kernel_installer.zip to a temp folder, e.g. cLK_kernel_installer, and put zImage, your ROM's initrd.gz, and system folder to cLK_kernel_installer folder.
      Then run cLK_kernel_installer.bat to install new kernel and the related stuff.
      Code:
      adb remount
      adb shell rm /system/lib/modules/*
      adb push system /system/
      adb shell chown 0:2000 /system/bin/wpa_supplicant
      adb shell chmod 755 /system/bin/wpa_supplicant
      adb shell chown 0:2000 /system/etc/init.d/*
      adb shell chmod 750 /system/etc/init.d/*
      adb shell sync
      adb reboot bootloader
      
      fastboot -c "" -b 0x11800000 flash:raw boot zImage initrd.gz
      echo Press any key to reboot.
      echo Press any key to reboot.
      pause
      fastboot reboot

    Update:
    My r12b1 kernel ignores htcleo.acdb and only uses default.acdb no matter htcleo.acdb exists in /system/etc/firmware folder or not.
    And I use 10mic_level '0 200' and '1 600' in my releases.

    8/31 Update:
    Re-uploaded r12b1 kernel and change 10mic_level to '0 350' and '1 600'.
    11
    Hi there!

    Here are the files, I included the kernel patch and the resulting q6audio.c. The patch has other crap in it, the only modification required is in q6audio.c. It was against a very old kernel, I'm not sure you can use it "as-is".

    You also have the user space tool source and my script to compile it.

    To dump values, you have to flash a working WinMo 6.5 to have winmo values in memory and launch android with Haret .

    To use it, compile the kernel with the modification. It will somehow kill your audio as it won't set acdb to be able to dump acdb in memory untouched. The userspace tools expect to find a pure android default.acdb in the directory where it's launched, it will query kernel values, and remap it to a proper htcleo.acdb in /sdcard/acdb_out.acdb.

    Good luck!

    LeTama
    11
    Can someone do a simple Android app that has two sliders (or simple buttons) which adjust mic gains in realtime?

    It should just give these commands in the background with each slider step (or button press):

    For handset mic gain:
    echo '0 xxx' > /proc/mic_level
    where xxx is between 200-400

    For speakerphone mic gain:
    echo '1 xxx' > /proc/mic_level
    where xxx is between 500-700

    The app should state that it is only for HD2 with a supported kernel.
    A "make permanent" button should save to 10mic_level in /etc/init.d

    You may share the apk here or over the Market. I will link to it in the first post.

    Note: Yeah Gscript works well too, but it is not a ready to use solution for everyone.

    People with less experience but curious may try: http://appinventor.googlelabs.com


    :) here you go... HD2 Mic Control in android market. I will put the code in git for others to tweak, will update this post once done. I put the app in market to make it easy to push updates.

    All functionality is self explanatory. If you drag the seekbars mic levels will be changed immediately, if you click "Save Permanently" then mic levels will be saved to a script /etc/init.d/10mic_level. If you don't save then I guess mic levels will be lost on reboot.

    If you don't have correct kernel then you will see a error message and will not be able to make any changes.

    for future readers of this post: Market will have the latest version. No need to search for latest version. If you don't have market access then get it from http://code.google.com/p/hd2micctrl/downloads/list.

    img.php