[FIX] Fixing bad sound during video recording / in dictaphone

Bonoboo

Senior Member
Dec 30, 2012
2,532
3,926
203
Fixing bad sound during video recording / in dictaphone for Redmi 3S / 3X / 4X
Also posted on 4pda and in bug-report on MIUI forums

UPD: heavily updated new v.8

Warning: in ZIP format this patch only for Redmi 3S/3X and 4X.
On Redmi 4A available manual install, see below. For Redmi 4 Pro solution here
Please, don't ask me to port on other models, ask someone on forum.
Because without device I can't test all.

Many-many people noticed awful sound quality in videos no matter what camera or ROM used (sample and another)
Was created two bug-reports on official MIUI forum (1, 2)
Also this problem affects at least Redmi 2, 3, 4A, 4Pro, Note 3 Pro.

Basing on this post with fix of similar issue on Nexus 5 created patch for Redmi 3S / 3X, that disabling noise cancellation in camera and apps (but not in-call).
Sound quality now much better: no crackling, no floating volume, just clean more louder sound.
So now this disturbing problem finally fixed.

Sample without and with fix here
Recorded via stock camera (mono, 96 Kbps), phone no moved, music volume not touched.
Someone can notice lack of bass, but I think it's just hardware microphone limitation (designed for voice, not ambient sound).
Nothing more to adjust here, sound just "by default" without effects.

Important information, please read:
  • how to install TWRP? Follow this or this thread
  • if phone won't boot apply TWRP > Advanced > Disable DM-verity or flash this zip
  • if this not helps, then files was edited incorrectly (I can't test all roms). Apply remove ZIP to cancel patch
  • patch applied for mono-recording in video (stock camera), and for stereo (awesome Snap Camera HDR)
  • also applied for dictaphone and other applications
  • noise cancellation during call still works, which good
  • patch compatible with MIUI firmware and custom rom's (LOS / CM / etc)
  • patch built-in (but with swapped stereo-channels) into LOS 14.1 by daniel.stuart14 and LOS 13 by FedosIS, don't install it
  • I don't know does your specific ROM include patch or not, check this yourself
  • patch directly edits files, not replacing them: it's more correct, because files not universal
  • you can flash latest version over previous
  • for custom rom's added auto-restore script: patch will persist even after updating rom
  • on MIUI you need flash patch after any update via any method
Version history:

8
- fixed swapped stereo channels: now upper mic - left, bottom - right (source)
- disabled noise cancellation for external / microphone headset (strange, but there was a problem)
- added support of Treble ROM's
- vastly improved editing files reliability to prevent mistakes
- at update previous changes not reverts, instead using clean backup file
- therefore patch can't be installed over ancient v.5 (I guess there's few users)
- backup files keeps up when updating the custom firmware, this is necessary for the possibility of canceling
- Magisk modules now can be installed through app
- updated remover ZIP
- updated manual installing guide

7
- now works on Android 8 Oreo and higher
- remover ZIP updated too

6
- fixed low mic volume on newest custom rom's
- during installing performed backup of current files
- therefore revert patch now not editing files in reverse way (hard to maintain) and just renames old
- manual installing a bit changed too

5
- fixed in-call mic volume for those who disabled in-call noise suppression via build.prop (version fits all, 1016/292)

4
- reduced volume from 102 to 96 to avoid distortion

3
- fixed high volume in-call that distorted your voice
- now volume changed only for required devices, not globally
- patch reverts all edits from old versions, implemented protection if patch applied twice
- where was possible edits fits XML-marking
- added comments into script

2
- increased mic volume, but globally
- was bug: in-call corespondent heard you worse due high volume
- now patch directly edits files, not replacing them
- added auto-restore script or custom rom's

1
- initial untested release
- was low mic volume
Installing / updating (v.8):
Just flash via TWRP ZIP that attached to post.
Also there's zip for reverting changes.

And here systemless version for Magisk.

Or manual installing (for 4A too):

If you made mistake or not set required rights / owner / SELinux-context (usually after coping file "outside") phone will not boot.
So better just flash ZIP (only for 3S / 3X / 4X) or be careful.


Note: on Oreo and higher (include Treble) files located into folder /system/vendor/etc

0. You need root.
1. Edit /system/etc/audio_platform_info.xml
2. Find lines contains this and delete them:
Code:
...SND_DEVICE_IN_HANDSET_MIC" acdb_id...
...SND_DEVICE_IN_HEADSET_MIC" acdb_id...
...SND_DEVICE_IN_HANDSET_STEREO_DMIC" acdb_id...
3. Under line <acdb_ids> add this:
Code:
<device name="SND_DEVICE_IN_HANDSET_MIC" acdb_id="1"/>
<device name="SND_DEVICE_IN_HANDSET_STEREO_DMIC" acdb_id="1"/
4. Edit file:
For Redmi 3S / 3X / 4X: /system/etc/mixer_paths_qrd_sku1.xml
For Redmi 4A: /system/etc/mixer_paths_qrd_sku2.xml (found by Ymys_ua)
At middle of file find these lines:
Code:
<path name="voice-call">
If after there is two lines with DEC1/DEC2 - remove them.
And replace it for this one line:
Code:
<path name="voice-call"><path name="adc1" /><ctl name="DEC1 Volume" value="84" /><ctl name="DEC2 Volume" value="84" />
5. Find this lines:
Code:
<path name="handset-mic">
<path name="adc1" />
If after there is two lines with DEC1/DEC2 - remove them.
And replace them for this one line:
Code:
<path name="handset-mic"><path name="adc1" /><ctl name="DEC1 Volume" value="96" /><ctl name="DEC2 Volume" value="96" />
6. Find this lines:
Code:
<path name="headset-mic">
<path name="adc2" />
If after there is two lines with DEC1/DEC2 - remove them.
And replace them for this one line:
Code:
<path name="headset-mic"><path name="adc2" /><ctl name="DEC1 Volume" value="99" /><ctl name="DEC2 Volume" value="99" />
7. Find this lines:
Code:
<path name="handset-stereo-dmic-ef">
<path name="adc2" />
If after there is two lines with DEC1/DEC2 - remove them.
And replace it for this one line:
Code:
<path name="handset-stereo-dmic-ef"><path name="adc3" /><ctl name="ADC1 Volume" value="6" /><ctl name="DEC2 MUX" value="ADC1" /><ctl name="MI2S_TX Channels" value="Two" /><ctl name="DEC1 Volume" value="96" /><ctl name="DEC2 Volume" value="96" />
8. Save file and reboot.
For those, who want port on other model:

Main requirement: /system/etc/audio_platform_info.xml must have this lines (or in /system/vendor for Oreo and higher):
Code:
<device name="SND_DEVICE_IN_HANDSET_MIC" acdb_id="1"/>
<device name="SND_DEVICE_IN_HEADSET_MIC" acdb_id="1"/>
<device name="SND_DEVICE_IN_HANDSET_STEREO_DMIC" acdb_id="1"/>
may not required: <device name="SND_DEVICE_IN_CAMCORDER_MIC" acdb_id="1"/>
Next you need adjust volumes, reefer to manual install guide. On other models "devices" names for volumes can be different.
To find which used in particular case use logcat (filter "device") and searching in file /system/etc/mixer_paths_*.xml to recreate "chain".
 

Attachments

Last edited:

s8m

Senior Member
Oct 9, 2010
310
112
63
Will you be able to create a systemless/Magisk version for those who do not want to modify system partition? Thank you!
 

Bonoboo

Senior Member
Dec 30, 2012
2,532
3,926
203
I'm facing issues during call.... The other person is not able to hear my voice in between for few seconds
Will this work?
No, this is only for sound quality in videos / apps.
Reason of your problem unknown, but this happens for some users (seems hardware).

It's usually fixes by disabling noise canceling during call.
You need root. Via filemanager edit file /system/build.prop
Find line ro.qc.sdk.audio.fluencetype=fluence
And change it to "none": ro.qc.sdk.audio.fluencetype=none
Save file, reboot and test.

Will you be able to create a systemless/Magisk version for those who do not want to modify system partition?
Here you are (attached), not tested, created by following guide
Please, let me know about result.

P.S. File deleted.
 
Last edited:

vivekkairi

Member
Feb 14, 2015
18
2
0
Hii
Can you make me a twrp flash able file regarding turning off noice cancelation..... Actually the biggest problem is I can't root device as of now.. Twrp is installed
 

s8m

Senior Member
Oct 9, 2010
310
112
63
Here you are (attached), not tested, created by following guide
Please, let me know about result.
Thank you so much but it doesn't work.. I get an error:
Code:
! Failed: Unable to extract zip file!
Updater process ended with ERROR: 1
I tried to repack the ZIP file too (with 7-Zip 'store' compression) but it didn't work either. Based on the Magisk documentation it seems to be missing some files perhaps like config.sh and module.prop:
https://github.com/topjohnwu/magisk-module-template
 

Bonoboo

Senior Member
Dec 30, 2012
2,532
3,926
203

Attachments

Last edited:
  • Like
Reactions: hasan291