Skip to content

Commit c6663d0

Browse files
authored
Add files via upload
Tuned tunables of I/O scheduler Added warning messages for unneeded magisk modules
1 parent ba52b36 commit c6663d0

File tree

6 files changed

+80
-52
lines changed

6 files changed

+80
-52
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## A Magisk module for maximizing the digital audio fidelity by reducing jitters on audio outputs (USB DACs, Bluetooth a2dp, DLNA, etc.)
22

3-
Very many music lovers abandon audio quality on smart phones and DAP's by believing its causes are delivered from analog components. However, actually most of all the causes are less than 50Hz jitter (i.e., the standard deviation of actual audio data rate with a low-pass filter; usually converted in time domain) on digital audio outputs that generates very short reverb or foggy sound like distortion on analog audio outputs. Although more than 50 Hz (less than 20msec interval) jitter can be easily reduced under the hearable level by PLL (Phase Locked Loop) in DAC's, the other (especially less than 10Hz or more than 100msec interval) modulates and distorts audio outputs by fluctuating the master clock in a DAC through the PLL. See ["Audio jitter silencer"](https://github.com/Magisk-Modules-Alt-Repo/audio-jitter-silencer) for more explanation.
3+
So many music lovers abandon audio quality on smart phones and DAP's by believing its causes are delivered from analog components. However, the most crucial cuase of it is actually less than 50Hz jitter (i.e., the standard deviation of actual audio data rate with a low-pass filter; usually converting into time-domain) on digital audio outputs that generates very short reverb or foggy sound like distortion on analog audio outputs. Although more than 50Hz (less than 20msec interval) jitter can be easily reduced under the hearable level by PLL (Phase Locked Loop) in DAC's, the other (especially less than 10Hz or more than 100msec interval) modulates and distorts audio outputs by fluctuating the master clock in a DAC through the PLL. For further explanation, see my another magisk module ["Audio jitter silencer"](https://github.com/Magisk-Modules-Alt-Repo/audio-jitter-silencer).
44

55
For maximizing the audio fidelity, this module reduces less than 50Hz (more than 20msec interval) jitters on digital audio outputs by optimizing kenel tunables (CPU & GPU governors, thermal control, CPU hotplug, I/O scheduler, Virtual memory), Selinux mode, WIFI parameters, etc. as follows,
66

@@ -17,15 +17,15 @@ For maximizing the audio fidelity, this module reduces less than 50Hz (more than
1717
<li>CPU hotplug<br>
1818
stop "MPDecision" server (if exists).</li>
1919
<li>Disable MediaTek EAS+ scheduler<br>
20-
`echo '1' > "/proc/cpufreq/cpufreq_sched_disable"`</li>
20+
```echo '1' > "/proc/cpufreq/cpufreq_sched_disable"```</li>
2121
<li>Doze<br>
2222
stop the Android doze server.</li>
2323
<li>Selinux mode<br>
2424
change the mode to "permissive".</li>
2525
<li>Adaptive battery saving features<br>
2626
disable wifi suspend optimizations, the adaptive battery management, the adaptive charging management and the adaptive connectivity management.</li>
2727
<li>Kill effect chains<br>
28-
force ignoring `/vendor/etc/audio_effects.xml` to disable equalizers, virtualizers, reverb's, visualizer, echo cancelers, automatic gain controls, etc. (very few vulnerable equalizers may crash by this killing, but please ignore it)</li>
28+
force ignoring ```/vendor/etc/audio_effects.xml``` to disable equalizers, virtualizers, reverb's, visualizer, echo cancelers, automatic gain controls, etc. (very few vulnerable equalizers may crash by this killing, but please ignore it)</li>
2929
<li>Disable the android built-in spatial audio feature (A13 or higher; especially Tensor devices)<br/>
3030
bypass an otiose audio pass.</li>
3131
<li>Disable aocd service<br/>
@@ -42,7 +42,7 @@ For maximizing the audio fidelity, this module reduces less than 50Hz (more than
4242
* For Convenience and Audio Quality:
4343
<ol type="1">
4444
<li> Disable DRC (Dynamic Range Control, i.e., a kind of compression)<br/>
45-
modify `/vendor/etc/*/audio_policy_configuration*.xml` to disable DRC if DRC has been enabled on a stock firmware.</li>
45+
modify ```/vendor/etc/*/audio_policy_configuration*.xml``` to disable DRC if DRC has been enabled on a stock firmware.</li>
4646
<li>Volume steps<br/>
4747
change the number of steps in media volume to 100 steps (0.4~0.7dB per step).</li>
4848
<li>Resampling quality<br/>
@@ -55,12 +55,12 @@ For maximizing the audio fidelity, this module reduces less than 50Hz (more than
5555
to reduce jitter on all audio outputs.</li>
5656
<li>Nullify volume listener libraries in "soundfx" folders for disabling slight compression (maybe a peak limiter only on Qcomm devices).</li>
5757
<li>Set 192kHz & 32bit mode for the USB audio output of Tensor devices exceptionally<br/>
58-
because Tensor devices lower the audio quality extremely for lower sample rates and bit depths. If your DAC cannot accept 32bit depth formats (e.g. Google's 3.5mm adapters and other very cheap ones), please edit "customize.sh" (in this Magisk module zip file) at line 95 and 96 to be `sRate="48000"` and `aFormat="AUDIO_FORMAT_PCM_24_BIT_PACKED"`.
58+
because Tensor devices lower audio quality extremely for lower sample rates and bit depths. If your DAC cannot accept 32bit depth formats (e.g. Google's 3.5mm adapters and other very cheap ones), please edit "customize.sh" (in this Magisk module zip file) at line 95 and 96 to be ```sRate="48000"``` and ```aFormat="AUDIO_FORMAT_PCM_24_BIT_PACKED"```.
5959
</li>
6060
</ol>
6161
<br/><br/>
6262

63-
* Don't forget to install ["Audio jitter silencer"](https://github.com/Magisk-Modules-Alt-Repo/audio-jitter-silencer) together and uninstall "Digital Wellbeing" app (for reducing very large jitters which this module cannot reduce as itself)! And uninstall ["Audio misc. settings"](https://github.com/Magisk-Modules-Alt-Repo/audio-misc-settings) and ["DRC remover"](https://github.com/Magisk-Modules-Alt-Repo/drc-remover) if they have already been installed, because all their functions are included in this module. Additionally if your device uses a Tensor SoC, uninstall ["USB SampleTate Unlocker"](https://github.com/Magisk-Modules-Alt-Repo/usb-samplerate-unlocker) for the same reason.
63+
* Don't forget to install ["Audio jitter silencer"](https://github.com/Magisk-Modules-Alt-Repo/audio-jitter-silencer) together and uninstall "Digital Wellbeing" app (for reducing very large jitters which this module cannot reduce as itself)! And uninstall ["Audio misc. settings"](https://github.com/Magisk-Modules-Alt-Repo/audio-misc-settings) and ["DRC remover"](https://github.com/Magisk-Modules-Alt-Repo/drc-remover) if they have already been installed, because all their functions are included in this module. Additionally if your device uses a Tensor SoC, uninstall ["USB Samplerate Unlocker"](https://github.com/Magisk-Modules-Alt-Repo/usb-samplerate-unlocker) for the same reason.
6464

6565
* Don't use Am@zon music using a much worse internal re-sampler which bypasses the mastering quality re-sampling in the OS mixer (audioFlinger). Other music streaming services don't use such an internal re-sampler, as far as I know.
6666

@@ -72,7 +72,7 @@ For maximizing the audio fidelity, this module reduces less than 50Hz (more than
7272

7373
* See also my companion script ["USB_SampleRate_Changer"](https://github.com/yzyhk904/USB_SampleRate_Changer) to change the sample rate of the USB (HAL) audio class driver and a 3.5mm jack on the fly like Bluetooth LDAC or Windows mixer to enjoy high resolution sound or to reduce resampling distortion (actually pre-echo, ringing and intermodulation) ultimately.
7474

75-
* Tips: If you use "AirMusic" to transmit audio data, I recommend setting around 4597 msec additional delay to reduce jitter distortion on the AirMusic panel to display target device(s).
75+
* Tips: If you use "AirMusic" to transmit audio data, I recommend setting around 4601 msec additional delay to reduce jitter distortion on the AirMusic panel to display target device(s).
7676

7777
* Note1: Please remember that this module will stop the thermal control (including CPU core controls, CPU hotplugs and thermal services), the "logd server" and the "camera server" (interfering jitter on audio outputs), disable SELinux enforcing mode and doze (battery saver while idling) on your device. If you like to enable these features, modify variables in "service.sh", respectively. Especially, note that the "Youtube" app became recetly to need the camera server for launching for some unexplained reason.
7878

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Change logs
22

3+
# v2.5.2
4+
* Tuned tunables of I/O scheduler
5+
* Added warning messages for unneeded magisk modules
6+
37
# v2.5.1
48
* Stopped Tensor device's AOC daemon for reducing significant jitter
59
* Optimized "extras/jitter-reducer.sh" for reducing I/O scheduling jitter on Tensor devices

customize-functions.sh

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,14 @@ function replaceSystemProps_kona()
250250

251251
function replaceSystemProps_SDM845()
252252
{
253-
# Do nothing even if "usb-samplerate-unlocker" exists
254-
:
253+
sed -i \
254+
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2750/' \
255+
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2750/' \
256+
"$MODPATH/system.prop"
257+
sed -i \
258+
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2750/' \
259+
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2750/' \
260+
"$MODPATH/system.prop-workaround"
255261
}
256262

257263
function replaceSystemProps_SDM()
@@ -274,26 +280,14 @@ function replaceSystemProps_MTK_Dimensity()
274280

275281
function replaceSystemProps_Tensor()
276282
{
277-
local freq="96000"
278-
if [ $# -gt 0 ]; then
279-
freq="$1"
280-
fi
281-
282-
if [ "$freq" -gt 96000 -o \
283-
-e "${MODPATH%/*/*}/modules/usb-samplerate-unlocker" -o -e "${MODPATH%/*/*}/modules_update/usb-samplerate-unlocker" ]; then
284-
sed -i \
285-
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2625/' \
286-
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2625/' \
287-
"$MODPATH/system.prop"
288-
sed -i \
289-
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2625/' \
290-
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2625/' \
291-
"$MODPATH/system.prop-workaround"
292-
293-
loosenedMessage
294-
295-
fi
296-
283+
sed -i \
284+
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2625/' \
285+
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2625/' \
286+
"$MODPATH/system.prop"
287+
sed -i \
288+
-e 's/vendor\.audio\.usb\.perio=.*$/vendor\.audio\.usb\.perio=2625/' \
289+
-e 's/vendor\.audio\.usb\.out\.period_us=.*$/vendor\.audio\.usb\.out\.period_us=2625/' \
290+
"$MODPATH/system.prop-workaround"
297291
}
298292

299293
function replaceSystemProps_Others()

customize.sh

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ if "$IS64BIT"; then
137137
replaceSystemProps_SDM845
138138
;;
139139
gs* )
140-
replaceSystemProps_Tensor 192000
140+
replaceSystemProps_Tensor
141141
;;
142142
"sdm660" | "bengal" | "holi" )
143143
replaceSystemProps_SDM
@@ -172,5 +172,29 @@ else
172172
rm -f "$MODPATH/system.prop-workaround"
173173
fi
174174

175+
# Warning unneeded magisk modules
176+
177+
if [ -e "${MODPATH%/*/*}/modules/audio-misc-settings" ]; then
178+
ui_print ""
179+
ui_print "****************************************************************"
180+
ui_print " Uninstall \"Audio misc. settings\" manually later; this module includes all its features"
181+
ui_print "****************************************************************"
182+
ui_print ""
183+
fi
184+
if [ -e "${MODPATH%/*/*}/modules/drc-remover" ]; then
185+
ui_print ""
186+
ui_print "****************************************************************"
187+
ui_print " Uninstall \"DRC remover\" manually later; this module includes all its features"
188+
ui_print "****************************************************************"
189+
ui_print ""
190+
fi
191+
if [ "$tensorFlag" -eq 1 -a -e "${MODPATH%/*/*}/modules/usb-samplerate-unlocker" ]; then
192+
ui_print ""
193+
ui_print "****************************************************************"
194+
ui_print " Uninstall \"USB Samplerate Unlocker\" manually later; this module includes all its features"
195+
ui_print "****************************************************************"
196+
ui_print ""
197+
fi
198+
175199
rm -f "$MODPATH/customize-functions.sh"
176200
rm -rf "$MODPATH/templates"

jitter-reducer-functions.shlib

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,41 +1208,41 @@ function getSchedulerValues()
12081208
"exp" )
12091209
case "`getSocModelName`" in
12101210
sdm8[5-9]* | sdm9* )
1211-
echo "88 0 36 512 0"
1211+
echo "89 0 36 516 0"
12121212
;;
12131213
gs* )
1214-
echo "88 0 36 516 0"
1214+
echo "89 0 36 516 0"
12151215
;;
12161216
sdm8* )
1217-
echo "88 0 34 510 0"
1217+
echo "89 0 34 516 0"
12181218
;;
12191219
sdm* | msm* | sd* | exynos* )
1220-
echo "88 0 34 510 0"
1220+
echo "89 0 34 516 0"
12211221
;;
12221222
mt68* )
12231223
echo "88 0 36 516 0"
12241224
;;
12251225
mt67[7-9]? )
1226-
echo "88 0 36 516 0"
1226+
echo "89 0 36 516 0"
12271227
;;
12281228
* )
1229-
echo "88 0 36 516 0"
1229+
echo "89 0 36 516 0"
12301230
;;
12311231
esac
12321232
;;
12331233
"boost" )
12341234
case "`getSocModelName`" in
12351235
sdm8[5-9]* | sdm9* )
1236-
echo "88 0 36 512 0"
1236+
echo "89 0 36 516 0"
12371237
;;
12381238
gs* )
1239-
echo "88 0 36 516 0"
1239+
echo "89 0 36 516 0"
12401240
;;
12411241
sdm8* )
1242-
echo "88 0 34 510 0"
1242+
echo "89 0 34 516 0"
12431243
;;
12441244
sdm* | msm* | sd* | exynos* )
1245-
echo "88 0 34 510 0"
1245+
echo "89 0 34 516 0"
12461246
;;
12471247
mt68* )
12481248
echo "88 0 36 516 0"
@@ -1251,7 +1251,7 @@ function getSchedulerValues()
12511251
echo "89 0 36 516 0"
12521252
;;
12531253
* )
1254-
echo "88 0 36 516 0"
1254+
echo "89 0 36 516 0"
12551255
;;
12561256
esac
12571257
;;
@@ -1387,45 +1387,51 @@ function getSchedulerNrRequests()
13871387
;;
13881388
"exp" )
13891389
case "`getSocModelName`" in
1390-
sdm8[5-9]* | sdm9* | gs* )
1390+
sdm8[5-9]* | sdm9* )
1391+
echo "86163"
1392+
;;
1393+
gs* )
13911394
echo "86153"
13921395
;;
13931396
sdm8* )
1394-
echo "86151"
1397+
echo "86163"
13951398
;;
13961399
sdm* | msm* | sd* | exynos* )
1397-
echo "86153"
1400+
echo "86163"
13981401
;;
13991402
mt68* )
14001403
echo "86153"
14011404
;;
14021405
mt67[7-9]? )
1403-
echo "86153"
1406+
echo "86163"
14041407
;;
14051408
* )
1406-
echo "86153"
1409+
echo "86163"
14071410
;;
14081411
esac
14091412
;;
14101413
"boost" )
14111414
case "`getSocModelName`" in
1412-
sdm8[5-9]* | sdm9* | gs* )
1415+
sdm8[5-9]* | sdm9* )
1416+
echo "86163"
1417+
;;
1418+
gs* )
14131419
echo "86153"
14141420
;;
14151421
sdm8* )
1416-
echo "86151"
1422+
echo "86163"
14171423
;;
14181424
sdm* | msm* | sd* | exynos* )
1419-
echo "86153"
1425+
echo "86163"
14201426
;;
14211427
mt68* )
14221428
echo "86153"
14231429
;;
14241430
mt67[7-9]? )
1425-
echo "86153"
1431+
echo "86163"
14261432
;;
14271433
* )
1428-
echo "86153"
1434+
echo "86163"
14291435
;;
14301436
esac
14311437
;;

service.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ DisableClearestTone="no"
2929
# sleep 30 secs needed for "settings" commans to become effective and another kernel tunables setting process completion in an orphan process
3030

3131
(((sleep 30; remountFile; optimizeOS $EnableThermalControl $EnableCameraService $EnableSelinuxEnforcing \
32-
$EnableDoze $EnableLogdService $EnableClearestTone) 0<&- &>"/dev/null" &) &)
32+
$EnableDoze $EnableLogdService $DisableClearestTone) 0<&- &>"/dev/null" &) &)

0 commit comments

Comments
 (0)