Skip to content

Commit cef993f

Browse files
authored
Add files via upload
* Changed the default target sampling rate from 44.1 kHz to 48 kHz because YTM recently changed its streaming format from AAC (141; 44.1 kHz & 256 kbps stereo) to Opus (774; 48 kHz & 256 kbps vbr stereo), Am@zon music had already changed its SD format from AAC (44.1 kHz & 256 kbps stereo) to Opus (48 kHz & 192 kbps vbr stereo) and YT had adopted Opus (251; 48 kHz & 160 kbps vbr stereo); Though this change affects very little for 44.1 kHz tracks (of which cut-off changes 20 kHz to 19 kHz) * Note that Opus encoders enforce low-pass filtering (cut-off: 20 kHz), but their decoders output ultra sonic noise by noise-shaping dithering when 16 bit depth outputting
1 parent 7bc17ce commit cef993f

File tree

4 files changed

+42
-18
lines changed

4 files changed

+42
-18
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
## A Magisk module resampling for cheapies
22

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)) so as to significantly improve audio quality of LDAC Bluetooth earphones and DAC's under $30 (probably) especially when replaying 44.1 kHz tracks up-sampled over or equal to 96 kHz & 24 or 32 bits by AudioFlinger, but also the quality of internal speakers and a 3.5 mm jack receiving 48 kHz & 24 or 32 bits audio data (except 48 kHz & 16 bits) 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.
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)) so as to significantly improve audio quality of LDAC Bluetooth earphones and DAC's under $30 (probably) especially when replaying 48 kHz tracks up-sampled over or equal to 96 kHz & 24 or 32 bits by AudioFlinger, but also the quality of internal speakers and a 3.5 mm jack receiving 48 kHz & 24 or 32 bits audio data (except 48 kHz & 16 bits) re-sampled (i.e., low-pass filtered) 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.
44

5-
By the way, although most people might wonder how this module improve the audio quality of such devices, it is accomplished by very long filter length re-sampling near ideally (almost without pre-echo, ringing (post-echo) and aliasing noise) cutting off a frequency zone from just above 20 kHz filled with ultrasonic noise generated by high frequency dithering and deteriorating audible sound by intermodulation significantly amplified by large amplification non-linearity of LDAC Bluetooth earphones and DAC's under $30. 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 & 16 bits.
5+
By the way, although most people might wonder how this module improve the audio quality of such devices, it is accomplished by very long filter length re-sampling near ideally (almost without pre-echo, ringing (post-echo) and aliasing noise) cutting off a frequency zone from just above 20 kHz filled with ultrasonic noise (although most people believe part of natural sound) generated by high frequency dithering (also called delta-sigma modulation, noise-shaping, super bit-mapping, etc.) at recording time and even 16 bits noise-shaping rounding output time (e.g., Opus decoders), and deteriorating audible sound like smoke by intermodulation significantly amplified by large amplification non-linearity of LDAC Bluetooth earphones and DAC's under $30. Furthermore this can be considered to be a kind of decimation filtering from 48 kHz & 16 bits samples (having dynamic range larger than usual 16 bits limit with ultrasonic noise) 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 & 16 bits.
66

77
However, as the noise has a merit adding mellowness into audible sound in the case of none cheap DAC's having very small amplification non-linearity, please use this module only when using LDAC Bluetooth earphones (any devices, as far as I know) and DAC's under $30 (typically using DAC chip CX31993, ALC5686, KT0210, etc.).
88

99
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 together or not.
1010

1111

1212
Notes:
13-
* If you feel your LDAC earphones or "cheapie" DAC wouldn't become to sound good at all, try editting "service.sh" script in the installed place or its ZIP archive so as to replace "94" in it with one of "93" down to "87" for appropriately cutting off ultrasonic noise causing intermodulation.
14-
* 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, except ultrasonic noise added on purpose for mellowness. Anyhow, if you want to improve the quality of only Hires. tracks on "cheapie" devices, edit "service.sh" script in the installed place or its ZIP archive as described in the script.
13+
* If you feel your LDAC earphones or "cheapie" DAC wouldn't become to sound good at all, try editting "service.sh" script in the installed place or its ZIP archive so as to replace "85" in it with "86" or "87" for appropriately cutting off ultrasonic noise causing intermodulation.
14+
* This module doesn't have the effect for Hires. tracks (greater than 48 kHz sample rate) which not having large pre-echo and ringing, and high frequency dithering noise, except ultrasonic noise added on purpose for mellowness. Anyhow, if you want to improve the quality of only Hires. tracks on "cheapie" devices, edit "service.sh" script in the installed place or its ZIP archive as described in the script.
1515
* LDAC earphones and DAC's deteriorate the quality more or less by their internal over-sampling filtering when receiving low sample rate data.
16-
* 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.
16+
* Don't forget disabling "A2DP hardware offload" on Snapdragon devices (if you can), because it forces double re-sampling (48 kHz to 48 kHz (i.e., a low-pass filter), and 48 kHz to 96 kHz) and it is so much worse that the latter re-sampling guts the former one at all.
1717

1818
<br/>
1919
<br/>
@@ -33,19 +33,21 @@ Notes:
3333
| 165 | 360 | | 104 | Low performance devices of A12 and later with audio ones having small amp. non-linearity |
3434
| 179 | 408 | | 99 | General purpose on A12 and later for audio devices having small amp. non-linearity |
3535
| Parameters of this module: | - | - | - | - |
36-
| 179 | 520 | 94, 93, ... , 87 | | for LDAC BT earphones and DAC's under $30 both having large amp. non-linearity |
36+
| 179 | 520 | 95,94,93 | | AAC or Flac 44.1kHz; for LDAC BT earphones and DAC's under $30 both having large amp. non-linearity |
37+
| 194 | 520 | 87,86,85 | | Opus 48kHz; for LDAC BT earphones and DAC's under $30 both having large amp. non-linearity |
38+
| 194 | 520 | 44,43 | | Hires. 96kHz; for LDAC BT earphones and DAC's under $30 both having large amp. non-linearity |
3739
| External examples: | - | - | - | - |
3840
| 100 | 29 | (91) | 109 | AK4493 (Sharp roll-off N-fold over-sampling) |
3941
| 150 | 42 | (91) | 109 | AK4191EQ (Sharp roll-off N-fold over-sampling) |
4042
| 120 | 35 | (97) | 110 | ES9038PRO (Fast roll-off N-fold over-sampling) |
4143
| vary 50 ~ 118 | 34 | 96 | (398) | ES9039PRO (Fast roll-off N-fold over-sampling) |
42-
| 110 | 40 | (96) | 109 | CX43131 (Fast roll-off N-fold over-sampling) |
44+
| 110 | 40 | (96) | 109 | CS43131 (Fast roll-off N-fold over-sampling) |
4345
| 98 | 130 | 98.5 | | MacOS Leopard (guess) |
4446
| 159 | 240 | | 99 | iZotope, No-Alias (guess) |
4547
| 100 | 64 | | 99 | SoX HQ linear phase (guess) |
4648
| 170 | 520 | | 99 | SoX VHQ linear phase (guess) |
4749

48-
* % in "Cut-off" and "Stop band" (starting from) fields means the proportion to the Nyquist frefuency.
50+
* % in "Cut-off" and "Stop band" (starting from) fields means the proportion to the Nyquist frequency.
4951
<br/>
5052

5153
- Appendix B. Characteristics of Re-sampling Parameters :

changelog.md

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

3+
# v2.0.0
4+
* Changed the default target sampling rate from 44.1 kHz to 48 kHz because YTM recently changed its streaming format from AAC (141; 44.1 kHz & 256 kbps stereo) to Opus (774; 48 kHz & 256 kbps vbr stereo), Am@zon music had already changed its SD format from AAC (44.1 kHz & 256 kbps stereo) to Opus (48 kHz & 192 kbps vbr stereo) and YT had adopted Opus (251; 48 kHz & 160 kbps vbr stereo); Though this change affects very little for 44.1 kHz tracks (of which cut-off changes 20 kHz to 19 kHz)
5+
* Note that Opus encoders enforce low-pass filtering (cut-off: 20 kHz), but their decoders output ultra sonic noise by noise-shaping dithering when 16 bit depth outputting
6+
7+
# v1.0.3
8+
* Changed the cut-off frequency from 94% to 93% for casual people to be appealed by its transparent
9+
310
# v1.0.2
411
* Added a note for adjusting the cut-off for your devices
512

module.prop

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
id=resampling-for-cheapies
22
name=Resampling for cheapies
3-
version=v1.0.2
4-
versionCode=1002
3+
version=v2.0.0
4+
versionCode=2000
55
author=zyhk
6-
description=For avoiding muddy distortion specific to LDAC Bluetooth earphones and DAC's under $30 (probably), this sets special re-sampling at the system-wide mixer.
6+
description=For avoiding smoky distortion specific to LDAC Bluetooth earphones and DAC's under $30 (probably), this sets special re-sampling at the system-wide mixer.

service.sh

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/system/bin/sh
22

3+
# Changed the default target sampling rate from 44.1 kHz to 48 kHz because YTM recently changed its streaming format
4+
# from AAC (141; 44.1 kHz & 256 kbps stereo) to Opus (774; 48 kHz & 256 kbps vbr stereo), Am@zon music had already changed its SD format from
5+
# AAC (44.1 kHz & 256 kbps stereo) to Opus (48 kHz & 192 kbps vbr stereo) and YT had adopted Opus(251; 48 kHz & 160 kbps vbr stereo)
6+
37
function reloadAudioserver()
48
{
59
# wait for system boot completion and audiosever boot up
@@ -49,17 +53,28 @@ function setResamplingParameters()
4953
resetprop --delete ro.audio.resampler.psd.tbwcheat
5054
# End of workaround
5155

52-
resetprop ro.audio.resampler.psd.stopband 179
53-
resetprop ro.audio.resampler.psd.halflength 520
5456
resetprop ro.audio.resampler.psd.enable_at_samplerate 44100
57+
resetprop ro.audio.resampler.psd.stopband 194
58+
resetprop ro.audio.resampler.psd.halflength 520
5559

56-
# If you feel your LDAC earphones or "cheapie" DAC wouldn't become to sound good at all,
57-
# try replacing "94" (below) with one of "93" down to "87" for appropriately cutting off ultrasonic noise causing intermodulation
58-
resetprop ro.audio.resampler.psd.cutoff_percent 94
60+
# If you feel your LDAC earphones or "cheapie" DAC wouldn't become to sound well or loses mellowness at all,
61+
# try replacing "85" (below) with "86" or "87" for appropriately cutting off ultrasonic noise causing intermodulation
62+
#
63+
resetprop ro.audio.resampler.psd.cutoff_percent 85
5964

60-
# Uncomment the following lines if you intend to replay only 96 kHz & 24 bits Hires. tracks
65+
# Uncomment the following resetprop lines if you intend to replay only 44.1 kHz & 16 and 24 bit tracks;
66+
# If you feel your LDAC earphones or "cheapie" DAC wouldn't become to sound well or loses mellowness at all,
67+
# try replacing "93" (below) with "94" or "95" for appropriately cutting off ultrasonic noise causing intermodulation
68+
#
69+
#resetprop ro.audio.resampler.psd.stopband 179
70+
#resetprop ro.audio.resampler.psd.cutoff_percent 93
71+
72+
# Uncomment the following resetprop lines if you intend to replay only 96 kHz & 24 bit Hires. tracks.
73+
# If you feel your LDAC earphones or "cheapie" DAC wouldn't become to sound well,
74+
# try replacing "43" (below) with "44" for appropriately cutting off ultrasonic noise causing intermodulation
75+
#
6176
#resetprop ro.audio.resampler.psd.enable_at_samplerate 96000
62-
#resetprop ro.audio.resampler.psd.cutoff_percent 44
77+
#resetprop ro.audio.resampler.psd.cutoff_percent 43
6378

6479
reloadAudioserver
6580
}

0 commit comments

Comments
 (0)