[Brought to you by a collaboration of Ainur and ARISE]
Description of the issue:
The issue with all Oreo ROMs for mi max 2 right now, is that there is very apparent audio distortion at max volume.
The reason for that is this:
The phone uses a stereo setup with the earpiece acting as the left channel and the bottom loudspeaker acting as the right channel.
Of course those two speakers are not of the same quality or meant to play the same frequencies.
Reading a bit around the official miui forum you will find that the earpiece speaker is meant as a treble speaker playing mid to high frequencies and the bottom loudspeaker as a woofer playing low to mid frequencies or even high ones since it can.
Using an aosp Oreo ROM though loses that optimization and treats the two unequal speakers as equal with the result of having the earpiece rattle heavily when it must play a frequency under 550hz.
Using an equalizer such as the one included in Dolby Atmos Axon 7, to reduce every frequency Lower than 500hz worked to remove the rattle from the earpiece but also removed the bass from the bottom loudspeaker, which isn't the ideal solution.
The final solution was to implement a high filter pass (suggested by UltraM8/Sovetnikov from Ainur), which was elaborated upon and implemented by Joe0Bloggs from ARISE.
Description of included impulses:
If your left channel is the earpiece and the right channel is the bottom speaker, (which is true for mi max 2) you need one of the following impulses:
1) Hi-Low Speakerphone HiL:
Which simply applies a high filter pass of 500hz to the left channel
2) Hi-Low Speakerphone 4-Way HiL:
Which applies a high filter pass of 500hz to the left channel but also redirects those left channel frequencies that are cut-off and merges them with the right channel.
So in the scenario that the left and right channel have a difference you will he able to hear it instead of it being just cut-off
If your right channel is the earpiece and the left channel is the loudspeaker, (which may be true for other phones with a similar issue) you need one of the following impulses:
1)Hi-Low Speakerphone HiR:
Simply cuts off any frequency under 500hz with a high filter pass on the right channel.
2)Hi-Low Speakerphone 4-Way HiR:
Cuts off any frequency under 500hz from the right channel with a high filters pass but also redirects and merges it with the left channel.
To test which is your left and right channel, you can use anyone of the myriad left-right channel test videos in YouTube:
Left Right Channel Test
All the impulses are wav files and they are zipped in ImpulsesOxygen.zip, so you simply unzip them and import the wav file of your choosing in the JamesDSP Convolver.
Those impulses can also be used with ROMs of other phones that either come with dual-speaker setup or use a mod to create two channel audio.
You will need to flash the following modules through Magisk (They can all be found in the Downloads section of Magisk Manager):
1) Ainur Sauron
2) Ainur JamesDSP (you can also use viper4a fx, but it has some bug when switching impulses)
3) Audio Modification Library
4) Audio Compatibility Patch
After flashing the requirements:
1) Reboot so all Magisk Modules are installed
2) Copy the impulse of your choosing (wav file) at 'Internal Storage/JamesDSP/Convolver' (I suggest you use the 4-Way HiL wav found in the zip for mi max 2)
3) Open JamesDSP
4) Enable the Master Switch on top of that window to activate JamesDSP
5) Enable the Convolver option near the bottom of that window
6) Select as Impulse your chosen wav file (4-way HiL for example)
(Or from the zip attachment in this post)
MD5sums of the attachments:
4-Way HiL: 96207e83552fc99a40e6012ff5646bbe
4-Way HiR: c0d88c31352d50ba350755f97a924266
Contact: For any clarifications feel free to contact @Joe0Bloggs on Telegram.