Skip to content

Commit 5853492

Browse files
authored
Add files via upload
Initial release
0 parents  commit 5853492

File tree

8 files changed

+836
-0
lines changed

8 files changed

+836
-0
lines changed

LICENSE

Lines changed: 661 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/sbin/sh
2+
3+
#################
4+
# Initialization
5+
#################
6+
7+
umask 022
8+
9+
# echo before loading util_functions
10+
ui_print() { echo "$1"; }
11+
12+
require_new_magisk() {
13+
ui_print "*******************************"
14+
ui_print " Please install Magisk v20.4+! "
15+
ui_print "*******************************"
16+
exit 1
17+
}
18+
19+
#########################
20+
# Load util_functions.sh
21+
#########################
22+
23+
OUTFD=$2
24+
ZIPFILE=$3
25+
26+
mount /data 2>/dev/null
27+
28+
[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
29+
. /data/adb/magisk/util_functions.sh
30+
[ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk
31+
32+
install_module
33+
exit 0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#MAGISK

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
## A Magisk module resampling for cheapies
2+
3+
This module has been developed for casual users to overide re-sampling parameters of AudioFlinger (the system-wide mixer) in my other modules (["Audio misc. settings"](https://github.com/Magisk-Modules-Alt-Repo/audio-misc-settings) and ["Hifi Maximizer"](https://github.com/yzyhk904/hifi-maximizer-mod)) to significantly improve audio quality of DAC's under $30 (probably) and LDAC bluetooth devices especially when replaying 44.1kHz tracks up-sampled over or equal to 96kHz & 24bits by AudioFlinger, but also the quality of internal speakers and 3.5 mm jack receiving 48kHz & 24bits audio data (except 48kHz & 16bits) up-sampled by AudioFlinger. If you are an audiophile expert, please use "extras/change-resampling-quality.sh" in ["USB SampleRate Changer"](https://github.com/yzyhk904/usb-samplerate-changer) which can change the parameters on the fly flexibly.
4+
5+
And its effect is accomplished almost without pre-echo, ringing (post-echo) and aliasing noise by very long filter length re-sampling near ideally cutting a frequency zone from just above 20kHz (ultrasonic noise) generated by high frequency dithering and deteriorating audible sound by intermodulation significantly amplified by large amplification non-linearity of DAC's under about $30 and LDAC BT devices. Furthermore this can be considered to be a kind of decimation filtering from 44.1 kHz & 16 bits samples to 40 kHz & 24 or 32 bits ones except the ultrasonic noise by hight frequency dithering. So it has little effect when using AAC and SBC codecs which transmit audio data by 44.1 kHz & 16bits.
6+
7+
However, as the noise has a merit adding mellowness in the case of none cheap DAC's having very small non-linear amplification distortion, please use this module only when using DAC's under $30 (probably) and LDAC bluetooth devices.
8+
9+
Finally, this module is designed to override re-sampling parameters set by my other modules, but can be used by itself only. You can install this module and enjoy its effect whether you are using one of them or not.
10+
11+
Notes:
12+
* This module doesn't have the effect for HIRES. tracks (greater than 44.1 kHz sample rate) which not having large pre-echo and ringing, and high frequency dithering noise.
13+
* DAC's deteriorate the quality more or less by their internal over-sampling filtering when receiving low sample rate data.
14+
* Don't forget disabling "A2DP hardware offload" on Snapdragon devices (if you can), because it forces double re-sampling (44.1 kHz to 48 kHz, and 48 kHz to 96 kHz) and it is so much worse that the latter re-sampling guts the former one at all.
15+
16+
<br/>
17+
18+
- Appendix A. Examples of Re-sampling Parameters :
19+
20+
21+
| Stop band attenuation (dB) | Half filter length | Cut-off (%) | Stop band (%) | Memo |
22+
| ---: | ---: | ---: | ---: | ---- |
23+
| AOSP parameters: | - | - | - | - |
24+
| 90 | 32 | 100 | | Default Quality|
25+
| 80 | 16 | 100 | | LOW Quality |
26+
| 84 | 16 | 100 | | MED Quality |
27+
| 98 | 32 | 100 | | HIGH Quality |
28+
| Parameters of Audio misc. settings: | - | - | - | - |
29+
| 159 | 480 | 92 | | Old devices of A11 and earlier |
30+
| 165 | 360 | | 104 | Low performance devices of A12 and later with audio ones having small non-linear amp. distortion |
31+
| 179 | 408 | | 99 | General purpose on A12 and later for audio devices having small non-linear amp. distortion |
32+
| Parameters of this module: | - | - | - | - |
33+
| 179 | 520 | 94 | | for DAC's under $30 and LDAC BT devices both having large non-linear amp. distortion |
34+
| External examples: | - | - | - | - |
35+
| 100 | 29 | (91) | 109 | AK4493 (Sharp roll-off N-fold over-sampling) |
36+
| 150 | 42 | (91) | 109 | AK4191EQ (Sharp roll-off N-fold over-sampling) |
37+
| 120 | 35 | (97) | 110 | ESS 9038PRO (Fast roll-off N-fold over-sampling) |
38+
| 50 ~ 118 | 34 | 96 | (398) | ESS 9039PRO (Fast roll-off N-fold over-sampling) |
39+
| 110 | 40 | (96) | 109 | CX43131 (Fast roll-off N-fold over-sampling) |
40+
| 98 | 130 | 98.5 | | MacOS Leopard (guess) |
41+
| 159 | 240 | | 99 | iZotope, No-Alias (guess) |
42+
| 100 | 64 | | 99 | SoX HQ linear phase (guess) |
43+
| 170 | 520 | | 99 | SoX VHQ linear phase (guess) |
44+
45+
46+
- Appendix B. Characteristics of Re-sampling Parameters :
47+
48+
49+
| Category | Background opaqueness (aliasing noise) | Pre-echo and ringing | Mellowness (intermodulation) | Memo |
50+
| ---: | ---: | ---: | ---: | ---- |
51+
| DAC | light | heavy | heavy | AK4491EQ Sharp roll-off |
52+
| DAC | medium | medium | light | ESS9039PRO Fast roll-off |
53+
| Mastering tool | slight | slight | light | iZotope, No Alias (guess) |
54+
| Audio misc. settings | almost none | almost none | light | for general purpose |
55+
| Audio misc. settings | very slight | very slight | medium | for low performance devices |
56+
| Audio misc. settings | slight | almost none | almost none | for old devices |
57+
| This module | almost none | almost none | very slight | for DAC's under $30 and LDAC BT devices |
58+
59+
<br/>
60+
<br/>
61+
62+
## DISCLAIMER
63+
64+
* I am not responsible for any damage that may occur to your device, so it is your own choice to attempt this module.
65+
66+
##

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## Change logs
2+
3+
# v1.0.0
4+
* Initial Release
5+
6+
##

customize.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/system/bin/sh
2+
3+
rm -f "$MODPATH/LICENSE" "$MODPATH/README.md" "$MODPATH/changelog.md"

module.prop

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
id=resampling-for-cheapies
2+
name=Resampling for cheapies
3+
version=v1.0.0
4+
versionCode=1000
5+
author=zyhk
6+
description=Setting re-sampling parameters of AudioFlinger (the system-wide mixer) to improve audio quality of DAC's under $30 and LDAC BT devices especially.

service.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/system/bin/sh
2+
3+
function reloadAudioserver()
4+
{
5+
# wait for system boot completion and audiosever boot up
6+
local i
7+
for i in `seq 1 5` ; do
8+
if [ "`getprop sys.boot_completed`" = "1" -a -n "`getprop init.svc.audioserver`" ]; then
9+
break
10+
fi
11+
sleep 1.3
12+
done
13+
14+
if [ -n "`getprop init.svc.audioserver`" ]; then
15+
16+
setprop ctl.restart audioserver
17+
sleep 0.2
18+
if [ "`getprop init.svc.audioserver`" != "running" ]; then
19+
# workaround for Android 12 old devices hanging up the audioserver after "setprop ctl.restart audioserver" is executed
20+
local pid="`getprop init.svc_debug_pid.audioserver`"
21+
if [ -n "$pid" ]; then
22+
kill -HUP $pid 1>"/dev/null" 2>&1
23+
fi
24+
for i in `seq 1 10` ; do
25+
sleep 0.2
26+
if [ "`getprop init.svc.audioserver`" = "running" ]; then
27+
break
28+
elif [ $i -eq 10 ]; then
29+
echo "audioserver reload failed!" 1>&2
30+
return 1
31+
fi
32+
done
33+
fi
34+
return 0
35+
36+
else
37+
echo "audioserver is not found!" 1>&2
38+
return 1
39+
fi
40+
}
41+
42+
function setResamplingParameters()
43+
{
44+
# Workaround for recent Pixel Firmwares (not to reboot when resetprop'ing)
45+
resetprop --delete ro.audio.resampler.psd.enable_at_samplerate
46+
resetprop --delete ro.audio.resampler.psd.stopband
47+
resetprop --delete ro.audio.resampler.psd.halflength
48+
resetprop --delete ro.audio.resampler.psd.cutoff_percent
49+
resetprop --delete ro.audio.resampler.psd.tbwcheat
50+
# End of workaround
51+
52+
resetprop ro.audio.resampler.psd.enable_at_samplerate 44100
53+
resetprop ro.audio.resampler.psd.stopband 179
54+
resetprop ro.audio.resampler.psd.halflength 520
55+
resetprop ro.audio.resampler.psd.cutoff_percent 94
56+
57+
reloadAudioserver
58+
}
59+
60+
setResamplingParameters 1>"/dev/null" 2>&1

0 commit comments

Comments
 (0)