Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
* Added disabling Dolby control support for USB DAC's on HyperOS not to reboot
* Excluded "MotorolaSettingsProvider" on Motorala devices only for avoiding their bootloop
* Changed the USB period_us from 2250 usec to 2000 usec to optimize for 48 kHz Opus tracks (recent majority)
* Adjusted jitter optimizations and others for YTM's format change from AAC (141; 44.1 kHz & 256 kbps cbr stereo) to Opus (774; 48 kHz & 256 kbps vbr stereo)
  • Loading branch information
yzyhk904 authored Jul 28, 2024
1 parent 63b9751 commit 6558891
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 66 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ For maximizing the audio fidelity, this module reduces less than 50 Hz (longer t
| 150 | 42 | (91) | 109 | AK4191EQ (Sharp roll-off N-fold over-sampling) |
| 120 | 35 | (97) | 110 | ES9038PRO (Fast roll-off N-fold over-sampling) |
| vary 50 ~ 118 | 34 | 96 | (398) | ES9039PRO (Fast roll-off N-fold over-sampling) |
| 110 | 40 | (96) | 109 | CX43131 (Fast roll-off N-fold over-sampling) |
| 110 | 40 | (96) | 109 | CS43131 (Fast roll-off N-fold over-sampling) |
| 98 | 130 | 98.5 | | MacOS Leopard (guess) |
| 159 | 240 | | 99 | iZotope, No-Alias (guess) |
| 100 | 64 | | 99 | SoX HQ linear phase (guess) |
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Change logs

# v2.5.8
* Added disabling Dolby control support for USB DAC's on HyperOS not to reboot
* Excluded "MotorolaSettingsProvider" on Motorala devices only for avoiding their bootloop
* Changed the USB period_us from 2250 usec to 2000 usec to optimize for 48 kHz Opus tracks (recent majority)
* Adjusted jitter optimizations and others for YTM's format change from AAC (141; 44.1 kHz & 256 kbps cbr stereo) to Opus (774; 48 kHz & 256 kbps vbr stereo)

# v2.5.7
* Changed head ahead buffer sizes from 16960 kB to 17000 kB to reduce I/O jitter
* Adjusted NrRequests of I/O scheduling
Expand Down
45 changes: 22 additions & 23 deletions customize-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,9 @@ function replaceSystemProps_S4()
"$MODPATH/system.prop-workaround"
}

function replaceSystemProps_kona()
function replaceSystemProps_Kona()
{
if [ ! "`getprop ro.vendor.build.version.release_or_codename`" -ge "12" -a \
\( -e "${MODPATH%/*/*}/modules/usb-samplerate-unlocker" -o -e "${MODPATH%/*/*}/modules_update/usb-samplerate-unlocker" \) ]; then
if [ -e "${MODPATH%/*/*}/modules/usb-samplerate-unlocker" -o -e "${MODPATH%/*/*}/modules_update/usb-samplerate-unlocker" ]; then
sed -i \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2750/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2750/' \
Expand All @@ -251,12 +250,12 @@ function replaceSystemProps_kona()

else
sed -i \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2250/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2250/' \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2000/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2000/' \
"$MODPATH/system.prop"
sed -i \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2250/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2250/' \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2000/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2000/' \
"$MODPATH/system.prop-workaround"

fi
Expand All @@ -265,12 +264,12 @@ function replaceSystemProps_kona()
function replaceSystemProps_SDM845()
{
sed -i \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2250/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2250/' \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2000/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2000/' \
"$MODPATH/system.prop"
sed -i \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2250/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2250/' \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2000/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2000/' \
"$MODPATH/system.prop-workaround"
}

Expand All @@ -283,37 +282,37 @@ function replaceSystemProps_SDM()
function replaceSystemProps_MTK_Dimensity()
{
sed -i \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2250/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2250/' \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2000/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2000/' \
"$MODPATH/system.prop"
sed -i \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2250/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2250/' \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2000/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2000/' \
"$MODPATH/system.prop-workaround"
}

function replaceSystemProps_Tensor()
{
sed -i \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2250/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2250/' \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2000/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2000/' \
"$MODPATH/system.prop"
sed -i \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2250/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2250/' \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2000/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2000/' \
"$MODPATH/system.prop-workaround"
}

function replaceSystemProps_Others()
{
if [ -e "${MODPATH%/*/*}/modules/usb-samplerate-unlocker" -o -e "${MODPATH%/*/*}/modules_update/usb-samplerate-unlocker" ]; then
sed -i \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2250/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2250/' \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2000/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2000/' \
"$MODPATH/system.prop"
sed -i \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2250/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2250/' \
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2000/' \
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2000/' \
"$MODPATH/system.prop-workaround"

loosenedMessage
Expand Down
24 changes: 19 additions & 5 deletions customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if ! isMagiskMountCompatible; then
Aborted by no Magisk-mirrors:
try again either
a.) with official Magisk (mounting mirrors), or
b.) after installing "Compatible Magisk-mirroring" Magisk module
b.) after installing "Compatible Magisk-mirroring" Magisk module and rebooting
***'
fi

Expand Down Expand Up @@ -125,14 +125,27 @@ case "$configXML" in
;;
esac

# making patched ALSA utility libraries for "ro.audio.usb.period_us"
# Make patched ALSA utility libraries for "ro.audio.usb.period_us"
makeLibraries

# removing post-A13 (especially Tensor's) spatial audio flags in an audio configuration file for avoiding errors
# Remove post-A13 (especially Tensor's) spatial audio flags in an audio configuration file for avoiding errors
deSpatializeAudioPolicyConfig "/vendor/etc/bluetooth_audio_policy_configuration_7_0.xml"

# disabling pre-installed Moto Dolby faetures and Wellbeing for reducing very large jitter caused by them
disablePrivApps "
# Disabe pre-installed Moto Dolby faetures and Wellbeing for reducing very large jitter caused by them
# Excluded "MotorolaSettingsProvider" on Motorala devices for avoiding bootloop
if [ "`getprop ro.product.manufacturer`" = "Motorola" ]; then
disablePrivApps "
/system_ext/priv-app/MotoDolbyDax3
/system_ext/priv-app/daxService
/system_ext/priv-app/DaxUI
/system_ext/app/MotoSignatureApp
/product/priv-app/WellbeingPrebuilt
/product/priv-app/Wellbeing
/system_ext/priv-app/WellbeingPrebuilt
/system_ext/priv-app/Wellbeing
"
else
disablePrivApps "
/system_ext/priv-app/MotoDolbyDax3
/system_ext/priv-app/MotorolaSettingsProvider
/system_ext/priv-app/daxService
Expand All @@ -143,6 +156,7 @@ disablePrivApps "
/system_ext/priv-app/WellbeingPrebuilt
/system_ext/priv-app/Wellbeing
"
fi

if "$IS64BIT"; then
board="`getprop ro.board.platform`"
Expand Down
56 changes: 31 additions & 25 deletions jitter-reducer-functions.shlib
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,9 @@ function getSocModelName()
"holi" )
echo "sdm680"
;;
"pineapple" )
echo "sm8635"
;;
* )
if [ -r "/sys/devices/system/cpu/cpu7/core_ctl/enable" ]; then
echo "sdm855"
Expand Down Expand Up @@ -1211,7 +1214,7 @@ function getSchedulerValues()
case "$2" in
"light" )
case "`getSocModelName`" in
sdm8[5-9]* | sdm9* | gs* )
sm[6-8]* | sdm8[5-9]* | sdm9* | gs* )
echo "43 0 20 488 0"
;;
sdm8* )
Expand All @@ -1224,7 +1227,7 @@ function getSchedulerValues()
;;
"m-light" )
case "`getSocModelName`" in
sdm8[5-9]* | sdm9* | gs* )
sm[6-8]* | sdm8[5-9]* | sdm9* | gs* )
echo "71 0 28 496 0"
;;
sdm8* )
Expand All @@ -1246,32 +1249,35 @@ function getSchedulerValues()
;;
"boost" )
case "`getSocModelName`" in
sm[6-8]* )
echo "96 0 36 520 0"
;;
sdm8[5-9]* | sdm9* )
echo "95 0 36 516 0"
echo "99 0 36 516 0"
;;
gs* )
echo "96 0 36 516 0"
;;
sdm8* )
echo "94 0 36 516 0"
echo "99 0 36 516 0"
;;
sdm* | msm* | sd* | exynos* )
echo "97 0 36 515 0"
echo "102 0 38 517 0"
;;
mt68* )
echo "96 0 36 516 0"
echo "99 0 36 516 0"
;;
mt67[7-9]? )
echo "96 0 36 516 0"
echo "99 0 36 516 0"
;;
* )
echo "96 0 36 516 0"
echo "99 0 36 516 0"
;;
esac
;;
"medium" | *)
case "`getSocModelName`" in
sdm8[5-9]* | sdm9* )
sm[6-8]* | sdm8[5-9]* | sdm9* )
echo "92 0 36 516 0"
;;
gs* )
Expand Down Expand Up @@ -1309,8 +1315,8 @@ function getSchedulerValues()
;;
"boost" )
case "`getSocModelName`" in
sdm* | mt68* | gs* | sd* | exynos* )
echo "1 2 2 0 1 1 2 60 1541 0 1 1"
sm[6-8]* | sdm* | mt68* | gs* | sd* | exynos* )
echo "1 1 1 0 1 1 0 66 901 0 1 1"
;;
* )
echo "1 3 3 0 1 1 3 59 3000 0 3 3"
Expand All @@ -1319,7 +1325,7 @@ function getSchedulerValues()
;;
"medium" | * )
case "`getSocModelName`" in
sdm* | mt68* | gs* | sd* | exynos* )
sm[6-8]* | sdm* | mt68* | gs* | sd* | exynos* )
echo "1 3 3 0 1 1 3 51 3000 0 3 3"
;;
* )
Expand Down Expand Up @@ -1363,7 +1369,7 @@ function getSchedulerNrRequests()
case "$2" in
"light" )
case "`getSocModelName`" in
sdm8[5-9]* | sdm9* | gs* )
sm[6-8]* | sdm8[5-9]* | sdm9* | gs* )
echo "80645"
;;
sdm8* )
Expand All @@ -1379,7 +1385,7 @@ function getSchedulerNrRequests()
;;
"m-light" )
case "`getSocModelName`" in
sdm8[5-9]* | sdm9* | gs* )
sm[6-8]* | sdm8[5-9]* | sdm9* | gs* )
echo "86021"
;;
sdm8* )
Expand All @@ -1401,7 +1407,7 @@ function getSchedulerNrRequests()
;;
"boost" )
case "`getSocModelName`" in
sdm8[5-9]* | sdm9* )
sm[6-8]* | sdm8[5-9]* | sdm9* )
echo "86170"
;;
gs* )
Expand All @@ -1426,7 +1432,7 @@ function getSchedulerNrRequests()
;;
"medium" | * )
case "`getSocModelName`" in
sdm8[5-9]* | sdm9* | gs* )
sm[6-8]* | sdm8[5-9]* | sdm9* | gs* )
echo "86164"
;;
sdm8* )
Expand All @@ -1453,7 +1459,7 @@ function getSchedulerNrRequests()
case "$2" in
"light" )
case "`getSocModelName`" in
sdm* | msm* | sd* | exynos* | gs* )
sm[6-8]* | sdm* | msm* | sd* | exynos* | gs* )
echo "86021"
;;
* )
Expand All @@ -1463,7 +1469,7 @@ function getSchedulerNrRequests()
;;
"m-light" )
case "`getSocModelName`" in
sdm* | msm* | sd* | exynos* | gs* )
sm[6-8]* | sdm* | msm* | sd* | exynos* | gs* )
echo "86117"
;;
* )
Expand All @@ -1473,7 +1479,7 @@ function getSchedulerNrRequests()
;;
"boost" )
case "`getSocModelName`" in
sdm* | msm* | sd* | exynos* | gs* )
sm[6-8]* | sdm* | msm* | sd* | exynos* | gs* )
echo "86172"
;;
* )
Expand All @@ -1483,7 +1489,7 @@ function getSchedulerNrRequests()
;;
"medium" | * )
case "`getSocModelName`" in
sdm* | msm* | sd* | exynos* | gs* )
sm[6-8]* | sdm* | msm* | sd* | exynos* | gs* )
echo "86164"
;;
* )
Expand All @@ -1498,7 +1504,7 @@ function getSchedulerNrRequests()
case "$2" in
"light" )
case "`getSocModelName`" in
sdm* | msm* | sd* | exynos* | gs* )
sm[6-8]* | sdm* | msm* | sd* | exynos* | gs* )
echo "80645"
;;
* )
Expand All @@ -1508,7 +1514,7 @@ function getSchedulerNrRequests()
;;
"m-light" )
case "`getSocModelName`" in
sdm* | msm* | sd* | exynos* | gs* )
sm[6-8]* | sdm* | msm* | sd* | exynos* | gs* )
echo "86021"
;;
* )
Expand All @@ -1518,7 +1524,7 @@ function getSchedulerNrRequests()
;;
"boost" )
case "`getSocModelName`" in
sdm* | msm* | sd* | exynos* | gs* )
sm[6-8]* | sdm* | msm* | sd* | exynos* | gs* )
echo "86172"
;;
* )
Expand All @@ -1528,7 +1534,7 @@ function getSchedulerNrRequests()
;;
"medium" | * )
case "`getSocModelName`" in
sdm* | msm* | sd* | exynos* | gs* )
sm[6-8]* | sdm* | msm* | sd* | exynos* | gs* )
echo "86164"
;;
* )
Expand Down Expand Up @@ -1662,7 +1668,7 @@ function reduceIoJitter()
echo '0' >"/sys/block/$i/queue/nomerges"

case "`getSocModelName`" in
sdm8[5-9]* | sdm9* | sdm66* )
sm[6-8]* | sdm8[5-9]* | sdm9* | sdm66* )
echo '512' >"/sys/block/$i/queue/read_ahead_kb"
echo '128' >"/sys/block/$i/queue/nr_requests"
;;
Expand Down
4 changes: 2 additions & 2 deletions module.prop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id=hifi-maximizer-mod
name=Hifi Maximizer
version=v2.5.7
versionCode=2507
version=v2.5.8
versionCode=2508
author=zyhk
description=A module for maximizing the digital audio fidelity by reducing jitters on audio outputs (USB DACs, Bluetooth a2dp, DLNA, etc.)
6 changes: 4 additions & 2 deletions system.prop
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ ro.config.media_vol_steps=100
audio.safemedia.bypass=true
ro.audio.ignore_effects=true
ro.audio.spatializer_enabled=false
vendor.audio.usb.perio=2250
vendor.audio.usb.out.period_us=2250
ro.vendor.audio.dolby.dax.support=false
vendor.audio.dolby.control.support=false
vendor.audio.usb.perio=2000
vendor.audio.usb.out.period_us=2000
vendor.audio.usb.out.period_count=2
vendor.audio_hal.period_size=120
vendor.audio_hal.period_multiplier=1
Expand Down
Loading

0 comments on commit 6558891

Please sign in to comment.