Bluetooth audio very bad. - MTCD Android Head Units Q&A

Hello! I have this HeadUnit. I order it for listening music from phone via bluetooth. But sound via bluetooth very bad. I hear scratch, I can compare this with listening music 96kb/sec quality. But when I listen music via Radio or Google Play Music installed on my HU all ok.
I'm using lastest KD MCU (2.06) and Android
I try record it. but in life its really sounds as hell
Video

Privet,
I got my first head unit a week ago. Its an mtcd like yours. If you look around in the mtcd forum you will find out that there is no fix for this. At first i had bad bad Bluetooth quality. I wanted to send it back. Now i installed malaysk rom and i have good music quality. Dunno how he fix it but he will get a donation from me for this. But i need more testing, happend once that the quality was **** again for one drive, maybe other things interfering with bt.
Good luck

I am sure the quality is sh*t because of the low bitpool size, which is 32 ( modern devices have 52 and above ).
Is there a way to increase the size ?
Or is there a workaround because the bluetooth sound quality is really bad.

poddel said:
I am sure the quality is sh*t because of the low bitpool size, which is 32 ( modern devices have 52 and above ).
Is there a way to increase the size ?
Or is there a workaround because the bluetooth sound quality is really bad.
Click to expand...
Click to collapse
I Google it and found some thing

This method don't work. I change libs, but nothing changed.

One more idea, I need check audio_policy.conf file and change params.
a2dp {
outputs {
a2dp {
sampling_rates 48000|96000
channel_masks AUDIO_CHANNEL_OUT_STEREO
formats AUDIO_FORMAT_PCM_16_BIT
devices AUDIO_DEVICE_OUT_ALL_A2DP
}
}
}
maybe i try it today

What did you change?
I habe already tried changing The sampling Rates but there was no difference at all

RazGame said:
One more idea, I need check audio_policy.conf file and change params.
a2dp {
outputs {
a2dp {
sampling_rates 48000|96000
channel_masks AUDIO_CHANNEL_OUT_STEREO
formats AUDIO_FORMAT_PCM_16_BIT
devices AUDIO_DEVICE_OUT_ALL_A2DP
}
}
}
maybe i try it today
Click to expand...
Click to collapse
Since the Bluetooth is a separate chip controlled by the MCU, why do you think Android can do anything about it at all?
It's a separate chip with it's own firmware and connections to microphone and speakers. Android apps just send commands telling it to play or stop, dial or hangup, etc.
The only car unit where I think the Bluetooth is controlled by Android directly is the new Joying units.

Related

Stock KitKat N900T + Jaybird BlueBuds = Endless sadness. Help?

Hi, guys.
As the title states, the sound quality on my Jaybird BlueBuds is terrible on stock ROMs. They sound *perfect* on CM11, but I would rather run with a stock build for increased stability.
I've tried these two things to alleviate this, both to no avail
* Increasing the A2DP bitrate in audio.conf to 48000 Hz from 44100 Hz,
* Swapping audio.a2dp.default.so and bluetooth.default.so with copies from CM11 and the Nexus 5 stock image (either causes Bluetooth to crash or audio to not play)
I also tried finding clues within the Samsung KK source for the N9005, but it seems like they either (a) moved it from its default location, or (b) selectively took it out from the public source tree. So there's that.
I don't know what to do. I don't want to use CM11, and I don't want to sell a fantastic pair of earphones over this. I also can't downgrade to 4.3 because I am using the new bootloader. Anyone have any ideas?
Thanks!

Audio output sampling and bit rate??

Does anyone know the audio output in this device, I am using power amp media player and need to know if our device supports higher sampling and bit rate, if so how to enable it.
It supports up to 192 kHz - but - it forces the USB-C audio path to 96 kHz no matter what. Don't let the numbers fool you, if you're an audiophile you're going to be disappointed, everything sounds like mud.
The only app that the operating system is not stepping on is USB Audio Player Pro - it bypasses the operating system and provides a bit perfect path from the audio file to the USB output.
If you have an external DAC/amp and good headphones you're going to find bit-perfect 44.1 kHz sounds far better than any up-sampling.
Far better.
(I have no affiliation with USB Audio Player Pro or the company or people behind it. I just like music to sound like it's supposed to, within the technology limits given during production.)
Hi, I am planning to get an external DAC for my Honor View 10 but I read contradictory posts in several forums. With the stock EMUI, does USB audio really work?

Improve Bluetooth audio quality on headphones without aptX or LDAC

The test is over. I'm no longer accepting libraries to patch.
SBC XQ Feature is available in LineageOS 15.1 build created on or after the 31st of March 2019, or a 16.0 build created on or after the 13th of May 2019.
Many note low sound quality and lack of high frequencies when using the standard SBC Bluetooth codec, which is supported by all headphones and other Bluetooth devices. A common recommendation to get better sound quality is to buy devices and headphones with aptX or LDAC codecs supported. These codecs require licensing fees, so devices with them are more expensive.
It turns out that the low quality of SBC is caused by artificial limitations of all current Bluetooth stacks and headphones' configuration, and this limitation can be circumvented on any existing devices.
Everyone interested in Bluetooth audio, please take part in high-bitrate SBC compatibility testing on various headphones, receivers, stereo systems, or automotive head units.
If the vast majority of devices work with high bitrates, I will make a patch for Android and send it to AOSP and third-party ROMs, and high quality Bluetooth audio will be available to everyone on any headphones and smartphones, regardless of codecs with licensing fees.
Short technical information about SBC codec
SBC has lots of different parameters that are negotiated during the connection setup phase:
Audio channel type and number: Joint Stereo, Stereo, Dual Channel, Mono;
Number of frequency bands: 4 or 8;
Number of audio blocks in one packet: 4, 8, 12, 16;
Quantization bit allocation algorithm: Loudness, SNR;
Maximum and minimum bit pool used in quantization process: usually 2-53.
The decoder is required to support any combination of these parameters. Encoder may implement only a part of them.
Existing Bluetooth stacks usually negotiate the following profile: Joint Stereo, 8 bands, 16 blocks, Loudness, bitpool 2..53. This profile encodes 44.1 kHz audio with a bitrate of 328 kbps.
Bitpool parameter directly affects the bitrate within the same profile: the higher it is, the higher the bitrate, and hence the quality.
However, the bitpool parameter is not bound to a specific profile. The bitrate is also significantly affected by other parameters: audio channel type, number of frequency bands, number of audio blocks. You can increase the bitrate indirectly by negotiating non-standard profiles, without changing the bitpool.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
For example, Dual Channel encodes channels separately, using the entire bitpool for each channel. Forcing the device to use Dual Channel instead of Joint Stereo will get us almost doubled bitrate at the same maximum bitpool, 617 kbps.
To me it feels that bitpool should be an internal variable. It is an A2DP specification design fault that bitpool value is not bound to other codec parameters and only defined as a global value.
These fixed Bitpool and Bitrate values originate from recommended values for high-quality audio. But the recommendation is not an excuse to limit the profile to these values.
A2DP specification v1.2, which was active from 2007 to 2015, requires all decoders to work correctly with bitrates up to 512 kbps:
The decoder of the SNK shall support all possible bitpool values ​​that do not result in the excess of the maximum bit rate. This profile limits the available maximum bit rate to 320kb/s for mono, and 512kb/s for two-channel modes.
Click to expand...
Click to collapse
In the new version of the specification there is no bitrate limitation. It is assumed that modern headphones released after 2015 with EDR can support bitrates up to 730 kbps.
For some reason, all currently tested Bluetooth stacks (Linux (PulseAudio), Android, Blackberry and macOS) have artificial restrictions of maximum bitpool parameter, which directly affects the maximum bitrate. But this is not the biggest problem, almost all headphones also limit the maximum bitpool value to 53.
As I've already seen in my tests, most devices work fine on a modified Bluetooth stack with a bitrate of 507 kbps, without interrupts and crackling. But such a bitrate will never be negotiated under normal conditions, with stock Bluetooth stacks.
How to test on a PC
High bitrate SBC headphone compatibility test is the easiest to perform on the PC with a Bluetooth adapter. I've prepared Ubuntu image with a modified Bluetooth stack, which can be run as in a virtual machine (by connecting Bluetooth adapter as a USB device inside the virtual machine, it also works with the adapters built into the laptops) or by booting from the USB flash drive. This image uses the following profile: Dual Channel, 8 bands, 16 blocks, Loudness, bitpool 2..41, 44.1 kHz, which provides 485 kbps bitrate.
See the attachment in the end of this post.
Running in a VM
Download Virtualbox and Virtualbox Extension Pack: https://www.virtualbox.org/wiki/Downloads;
Install Virtualbox, start it;
Install Extension Pack using File → Preferences → Extensions;
Create new virtual machine: Linux, Ubuntu (64-bit), 1024 RAM. Do not create a HDD.
Navigate to virtual machine settings, in Storage choose Controller: IDE, Empty, press CD icon → Choose virtual optical disk file;
Select downloaded bluetooth-dualchannel-test-ubuntu-18.04.1-desktop-amd64.iso;
Save and close settings window, start virtual machine;
Right-click USB cable icon in the bottom right, select your Bluetooth adapter;
Running on a PC
The image supports BIOS/CSM and UEFI booting.
Burn the image to a USB flash drive using Etcher: https://etcher.io/. This operation will delete all existing files on a USB drive.
Turn off the PC;
Insert USB flash drive, turn on the PC and press boot order button (usually Esc or F12);
Select your USB flash drive.
Performing the test
(optional but recommended) Double click on "Btsnoop Dump" script on the desktop. It will start Bluetooth data capture for later analysis. Do not close terminal window.
Switch the headphones to pairing mode;
Click to the arrow in top right corner, select Bluetooth icon → Bluetooth Settings;
Choose your headphones, wait until pairing is complete and close the window;
Set Ubuntu volume to about 2/3. Also decrease volume using headset buttons as it could be very loud after pairing.
Open "music" folder, play "testrecord1.flac";
(optional but recommended) Close player, close terminal window. This will stop data capture.
(optional but recommended) Open Firefox browser, upload data dump (btsnoop_hci.btsnoop on the desktop) to https://btcodecs.valdikss.org.ru/
You can listen to other music in the music folder, or upload your own;
Post in this topic your headphone model and test results.
There should be no cracklings, audio interruption or other sound distortion in the headphones. If you hear a good high-quality sound, that means your headphones support audio with a bit rate of 485 kbps.
If you upload data to the server, please carefully follow the algorithm above. Especially, if you power off the headphones or disconnect after pairing, it's important to connect to the headphones manually from the bluetooth settings, do not allow auto connection!
How to test on Android device
In order to test from Android smartphone or tablet you need to use modified Bluetooth stack, which requires root privilege.
For regular users
Use PC method if possible.
Create backup before overwriting bluetooth library. Some patched libraries are attached to this post.
Unrestricted/unlimited versions negotiate Dual Channel mode and disable bitrate restriction (617-660 kbit/s will be used). Versions with 482 or 486 prefix negotiate 474-485 kbit/s.
For ROM developers (Android 5-7)
Patchset which increases maximum Bitpool value and adds Bluetooth Dual Channel option is available using the following link:
LineageOS 14.1 (Android 7.1.2)
The following information is outdated and is kept only for historical reasons:
Code:
[b]These modifications are designed only for test and should not be applied to the main ROM repository![/b]
[b]If you're a ROM developer, please provide flashable modified bluetooth library if possible![/b]
These modifications should be applied to stock Android bluetooth stacks Bluedroid (Android 5) and Fluoride (Android 6-7). Qualcomm-modified stack is not supported.
[b]1. Replace Joint Stereo with Dual Channel in standard SBC configuration[/b]
[url="https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/master/btif/co/bta_av_co.c#99"][i]android/platform/external/bluetooth/bluedroid/btif/co/bta_av_co.c:99[/i][/url]
[code]const tA2D_SBC_CIE btif_av_sbc_default_config =
{
BTIF_AV_SBC_DEFAULT_SAMP_FREQ, /* samp_freq */
A2D_SBC_IE_CH_MD_JOINT, /* ch_mode */
A2D_SBC_IE_BLOCKS_16, /* block_len */
A2D_SBC_IE_SUBBAND_8, /* num_subbands */
A2D_SBC_IE_ALLOC_MD_L, /* alloc_mthd */
BTA_AV_CO_SBC_MAX_BITPOOL, /* max_bitpool */
A2D_SBC_IE_MIN_BITPOOL /* min_bitpool */
};
Replace A2D_SBC_IE_CH_MD_JOINT with A2D_SBC_IE_CH_MD_DUAL.
2. Increase Dual Channel priority
android/platform/external/bluetooth/bluedroid/btif/co/bta_av_co.c:411
Code:
if (src_cap.ch_mode & A2D_SBC_IE_CH_MD_JOINT)
pref_cap.ch_mode = A2D_SBC_IE_CH_MD_JOINT;
else if (src_cap.ch_mode & A2D_SBC_IE_CH_MD_STEREO)
pref_cap.ch_mode = A2D_SBC_IE_CH_MD_STEREO;
else if (src_cap.ch_mode & A2D_SBC_IE_CH_MD_DUAL)
pref_cap.ch_mode = A2D_SBC_IE_CH_MD_DUAL;
else if (src_cap.ch_mode & A2D_SBC_IE_CH_MD_MONO)
pref_cap.ch_mode = A2D_SBC_IE_CH_MD_MONO;
Move if with A2D_SBC_IE_CH_MD_DUAL to the top.
3. Disable or increase bitrate restriction
Android bluetooth stack has not only bitpool limit, but also bitrate limit, 328 kbit/s. If the headphones support, for example, bitpool 53 for 48 kHz, Android will decrease the bitpool down to fit into 328 kbit/s limit. This will happen AFTER codec negotiation, on the encoding stage, do not take into account bitpool value in Bluetooth SetCapabilities packet.
android/platform/external/bluetooth/bluedroid/btif/src/btif_media_task.c:172
Code:
#define DEFAULT_SBC_BITRATE 328
Replace with 512.
4. (for experiments only) Disable MTU limit.
This is required for bitrates higher than ~580 kbit/s.
btif/src/btif_media_task.c:174
Code:
/* 2DH5 payload size of 679 bytes - (4 bytes L2CAP Header + 12 bytes AVDTP Header) */
#define MAX_2MBPS_AVDTP_MTU 663
[/code]
For ROM developers (Android 8-9)
Patchset which increases maximum Bitpool value and adds Bluetooth Dual Channel option is available using the following links:
LineageOS 15.1 (Android 8.1)
LineageOS 16.0 (Android 9)
AOSP Master (what will eventually become Android 9.1/10)
If you're a ROM developer, please provide flashable modified bluetooth library if possible!
The following information is outdated and is kept only for historical reasons:
1. Add Dual Channel support into A2DP SBC Source
/platform/system/bt/stack/a2dp/a2dp_sbc.cc:55
Code:
/* SBC SRC codec capabilities */
static const tA2DP_SBC_CIE a2dp_sbc_caps = {
A2DP_SBC_IE_SAMP_FREQ_44, /* samp_freq */
(A2DP_SBC_IE_CH_MD_MONO | A2DP_SBC_IE_CH_MD_JOINT), /* ch_mode */
(A2DP_SBC_IE_BLOCKS_16 | A2DP_SBC_IE_BLOCKS_12 | A2DP_SBC_IE_BLOCKS_8 |
A2DP_SBC_IE_BLOCKS_4), /* block_len */
A2DP_SBC_IE_SUBBAND_8, /* num_subbands */
A2DP_SBC_IE_ALLOC_MD_L, /* alloc_method */
A2DP_SBC_IE_MIN_BITPOOL, /* min_bitpool */
A2DP_SBC_MAX_BITPOOL, /* max_bitpool */
BTAV_A2DP_CODEC_BITS_PER_SAMPLE_16 /* bits_per_sample */
};
add A2DP_SBC_IE_CH_MD_DUAL in ch_mode.
2. Replace Joint Stereo with Dual Channel in default config
/platform/system/bt/stack/a2dp/a2dp_sbc.cc:82
Code:
/* Default SBC codec configuration */
const tA2DP_SBC_CIE a2dp_sbc_default_config = {
A2DP_SBC_IE_SAMP_FREQ_44, /* samp_freq */
A2DP_SBC_IE_CH_MD_JOINT, /* ch_mode */
A2DP_SBC_IE_BLOCKS_16, /* block_len */
A2DP_SBC_IE_SUBBAND_8, /* num_subbands */
A2DP_SBC_IE_ALLOC_MD_L, /* alloc_method */
A2DP_SBC_IE_MIN_BITPOOL, /* min_bitpool */
A2DP_SBC_MAX_BITPOOL, /* max_bitpool */
BTAV_A2DP_CODEC_BITS_PER_SAMPLE_16 /* bits_per_sample */
};
Replace A2DP_SBC_IE_CH_MD_JOINT with A2DP_SBC_IE_CH_MD_DUAL.
3. Increase Dual Channel priority
/platform/system/bt/stack/a2dp/a2dp_sbc.cc:1155
Code:
static bool select_best_channel_mode(uint8_t ch_mode, tA2DP_SBC_CIE* p_result,
btav_a2dp_codec_config_t* p_codec_config) {
if (ch_mode & A2DP_SBC_IE_CH_MD_JOINT) {
p_result->ch_mode = A2DP_SBC_IE_CH_MD_JOINT;
p_codec_config->channel_mode = BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO;
return true;
}
if (ch_mode & A2DP_SBC_IE_CH_MD_STEREO) {
p_result->ch_mode = A2DP_SBC_IE_CH_MD_STEREO;
p_codec_config->channel_mode = BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO;
return true;
}
if (ch_mode & A2DP_SBC_IE_CH_MD_DUAL) {
p_result->ch_mode = A2DP_SBC_IE_CH_MD_DUAL;
p_codec_config->channel_mode = BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO;
return true;
}
if (ch_mode & A2DP_SBC_IE_CH_MD_MONO) {
p_result->ch_mode = A2DP_SBC_IE_CH_MD_MONO;
p_codec_config->channel_mode = BTAV_A2DP_CODEC_CHANNEL_MODE_MONO;
return true;
}
return false;
}
Move if with A2DP_SBC_IE_CH_MD_DUAL to the top.
4. Increase bitrate limit
/platform/system/bt/stack/a2dp/a2dp_sbc_encoder.cc:42
Code:
#define A2DP_SBC_DEFAULT_BITRATE 328
Replace with 512.
5. (for experiments only) Disable MTU limit
This is required for bitrates higher than ~580 kbit/s.
/platform/system/bt/stack/a2dp/a2dp_sbc_encoder.cc:47
Code:
#define MAX_2MBPS_AVDTP_MTU 663
[/code]
For advanced users and ROM developers (Android 5-7 binary patch)
Please refer to this post in Russian (use Google Translate): https://4pda.ru/forum/index.php?s=&showtopic=914135&view=findpost&p=76169677
How to capture Bluetooth data dump on Android
Turn off Bluetooth;
In Developer Settings, enable the "Enable Bluetooth HCI snoop log" switch;
Turn on Bluetooth, connect to your headset using Bluetooth menu (this is important! Do not allow auto connection!);
Play short audio sample;
Open developer settings, disable the "Enable Bluetooth HCI snoop log" switch;
There should be /storage/emulated/0/btsnoop_hci.log or /data/misc/bluetooth/logs/btsnoop_hci.log created. If it's missing, open /etc/bluetooth/bt_stack.conf with a text editor and see the path in BtSnoopFileName option.
Upload btsnoop_hci.log to https://btcodecs.valdikss.org.ru/;
Post in this topic your headphone model and test results.
There should be no cracklings, audio interruption or other sound distortion in the headphones. If you hear a good high-quality sound with the patched library, that means your headphones support audio with a bit rate of 512 kbps.
If you upload data to the server, please carefully follow the algorithm above. Especially, if you power off the headphones or disconnect after pairing, it's important to connect to the headphones manually from the bluetooth settings, do not allow auto connection!
Some of the files attached below have no MTU limit patched. Unlocked/unrestricted versions most probably will introduce cracklings.
Tested devices
Devices which support at least 512 kbit/s SBC
1MORE iBFree
JBL Everest 310
JBL Everest 700
JBL T110BT
JBL E55BT
JBL T460BT
JBL Endurance SPRINT (Claim to not support Dual Channel, but work if forced. Does not conform to A2DP specification.)
Skullcandy HESH 3
SoundPEATS Q30
Sony WH-H900N
Sony WI-C400
Sony MDR-1ABT
Sony MDR-ZX770BT
Sony MDR-ZX770BN
Sony MDR-XB650BT
Sony MDR-XB950B1
Sony SBH50
SVEN AP-B570MV
Syllable G600
Bluedio A/Air (Claim to not support Dual Channel, but work if forced. Does not conform to A2DP specification.)
Bluedio T4s (Bitpool max 39. Claim to not support Dual Channel, but work if forced, 462 kbit/s. Does not conform to A2DP specification.)
Bluedio T5 (Claim to not support Dual Channel, but work if forced. Does not conform to A2DP specification.)
Bluedio T6 (Claim to not support Dual Channel, but work if forced. Does not conform to A2DP specification. Adopt Max 97220 chipset.)
Marshall Major II Bluetooth
Overdrive RealForce D1
DEXP BT-210
DEXP BT-220
DEXP BT-250
DEXP BT-260
DEXP BT-280
Edifier W288BT
Edifier W830BT
Nomi BT 211
LeEco Le Sports BT
Xiaomi MI Portable Bluetooth Speaker
Xiaomi Square Box Bluetooth Speaker 2
Sennheiser HD 4.40BT
AKG K845BT
Beyerdynamic Amiron Wireless
Bowers & Wilkins PX
Bowers & Wilkins Zeppelin Wireless
House of Marley Liberate XLBT
Harman Kardon Onyx Studio 4
Harman Kardon Aura Studio 2
QCY QY8
Panasonic RP-BT10
Jaybird X3
Logitech BT Adapter
TP-Link HA100
Xiaomi Mi Bluetooth Audio Receiver
Overfly Portable Bluetooth Receiver
KZ Wireless Bluetooth Module
Excelvan B7
Hagibis X2
Pioneer SE-E7BT
Automotive DAC Lusya bluetooth 4.0 with AK4490, NE5532
Noname automotive head unit (CSR8645 chip)
Sony DSX-A400BT automotive head unit
Devices which support SBC higher than 512 kbit/s
JBL Everest 310 (617-660 kbps)
JBL T110BT (576 kbps)
JBL Endurance SPRINT (573 kbps)
SoundPEATS Q30
DEXP BT-210 (617 kbps)
DEXP BT-220 (617 kbps)
DEXP BT-260 (617 kbps)
DEXP BT-280 (617 kbps)
Sony WI-C400 (576 kbps)
Sony MDR-ZX770BT (617-660 kbps)
Sony MDR-ZX770BN
Marshall Major II Bluetooth (617-660 kbps)
Overdrive RealForce D1 (730 kbps, dual channel, 4 subbands)
Jaybird X3
QCY QY8 (617 kbps)
Edifier W288BT (617 kbps)
Panasonic RP-BT10 (596 kbps)
LeEco Le Sports BT (617 kbps)
Nomi BT 211 (617 kbps)
Xiaomi Mi Bluetooth Audio Receiver (576 kbps)
Overfly Portable Bluetooth Receiver (617 kbps)
Automotive DAC Lusya bluetooth 4.0 with AK4490, NE5532 (576 kbps)
Devices which don't work with higher bitrates or Dual Channel
Harper HB-202 (cracklings; Beken BK3256 chip)
Sony Ericsson MW600 (high frequency distortion, cracklings; device from 2009)
Sony SBH52 (too slow to handle packet rate)
BlitzWolf BW-F2 (no sound)
Overfly mini Bluetooth receiver (no sound)
Why this is important: SBC 328k and 485k vs aptX
Contrary to popular belief of aptX sound quality, in some cases it can produce worse audio quality than SBC with a standard 328k bitrate.
SBC dynamically allocates quantization bits for frequency bands, acting on a "bottom-to-top" basis. If the whole bitrate was used for the lower and middle frequencies, the upper frequencies are "cut off" (silenced).
aptX quantizes frequency bands with the same number of bits constantly, which makes it a constant bitrate codec: 352 kbps for 44.1 kHz, 384 kbps for 48 kHz. It can't "transfer bits" to frequencies that are mostly needed in them. Unlike SBC, aptX will not "cut" frequencies, but will add quantization noise to them, reducing the dynamic range of audio, and sometimes introducing crackles. SBC, on the contrary, "eats the details" - discards the quietest areas.
On average, compared to SBC 328k, aptX makes less distortion in music with a wide frequency range, but on music with a narrow frequency range and a wide dynamic range SBC 328k sometimes wins.
Let us consider a special case, a piano recording. Here's a spectrogram:
The most energy lies in the 0-4 kHz frequencies, and lasts up to 10 kHz.
The spectrogram of the file aptX file looks like this:
Here is SBC 328k:
It can be seen that the SBC 328k periodically completely cut off the range above 16 kHz, and used all available bitrates for ranges below this value. However, aptX introduced more distortions into the frequency spectrum audible by the human ear, which can be seen on the subtracted original spectrogram from the aptX spectrogram (the brighter, the more distortion):
While the SBC 328k has introduced less distortion the signal in the range from 0 to 10 kHz, and the rest has been сut:
Bitrate 485k for SBC was enough to save the entire frequency range, without cutting off the bands.
SBC 485k on this audio sample is much better than aptX in the range of 0-15 kHz, and with a smaller but still noticeable difference - at 15-22 kHz (the darker, the less distortion):
Switching to a high-bitrate SBC, you will get a sound superior to aptX most of the time, on any headphones.
Bro. The concepts sound amazing.
I have Le Max 2 (Oreo). I have attached Bluetooth .so files.
If you patch I will try on Sony Bluetooth system and share with my friends patched files to see how much it works.
Thanks.
rohit3192 said:
Bro. The concepts sound amazing.
I have Le Max 2 (Oreo). I have attached Bluetooth .so files.
If you patch I will try on Sony Bluetooth system and share with my friends patched files to see how much it works.
Thanks.
Click to expand...
Click to collapse
For some reason I can't download your file, always get 404 not found. Another person with LeEco LeMax 2 (x820) contacted me and I made a patch, but only for 32-bit library. Since your archive is >2 MB, I suppose it contains 32 and 64 bit libraries. Please write your exact OS version and build number.
Would you mind to try? Backup your files first, replace 32-bit library with the file from the archive and rename 64-bit library, so it won't be used, and follow the instructions in the second post to capture the dump and upload it to btcodecs.
OK .
I try. Allow me some time.
Yes both libs were in one file. Now sending you separate libs.
rohit3192 said:
OK .
I try. Allow me some time.
Yes both libs were in one file. Now sending you separate libs.
Click to expand...
Click to collapse
Try these.
I have replaced file in /system/lib with permission.
And renamed /lib64 file as instructed.
Bluetooth switch doing nothing.
After renaming lib64 to original name the Bluetooth switch works and connects.
Build no attached.
rohit3192 said:
I have replaced file in /system/lib with permission.
And renamed /lib64 file as instructed.
Bluetooth switch doing nothing.
After renaming lib64 to original name the Bluetooth switch works and connects.
Build no attached.
Click to expand...
Click to collapse
Please try the latest archive. It includes patched 64 bit libraries.
The new patched 64bit file worked.
Tried 486 one only.
Here is Bluetooth log. (Upload was too slow at given link so sending GD link)
Post edited: thanks @ValdikSS a lot.
rohit3192 said:
Here is Bluetooth log. (Upload was too slow at given link so sending GD link)
Click to expand...
Click to collapse
Yes, it worked, the bitrate is 485 kbit/s. Did you hear any cracklings or interruptions?
The audio you played is of low quality. That's probably an MP3 ~160-192 kbit/s?
There is no crackling. Yes mp3 was of low quality that I tested.
Yet sound seems improved. I will need more time to get proper impression. I will post later here.
Also I have spread the word in few telegram channels.
Thanks
@op here you have my lib from Huawei P9 Android 7.0
Can you check and modded to test. I be test on my LG HBS910 with aptx
https://mega.nz/#!G3gR3RrC!yNysYtkk1DhlBk-ec87bIP56aupCwKvfiWM1k32Qy7k
chudy_85 said:
@op here you have my lib from Huawei P9 Android 7.0
Can you check and modded to test. I be test on my LG HBS910 with aptx
Click to expand...
Click to collapse
Patched version has been added to the second post.
This sound enhancement is only for SBC codec, it won't do anything with aptX. You should disable aptX to test patched version.
Hello
I have 1more ibfree sport headphone that supports AAC HD codec only with apple devices as company has mentioned in their site. (https://india.1more.com/collections...ore-ibfree-sport-bluetooth-earphones-with-mic)
As in your post you have mentioned 1more ibfree, that support aptx codec .
My headphone is newer version of ibfree series.
So the problem is in developer setting I can't change to AAC from SBC codec.
It stays to SBC only so I think I can get help from here from you.
So here the link to those .so files
https://mega.nz/#F!tj5AlahL!yCrNHYB-ft-zaJl2uc7kig
Phone - Le Max2 Lineage Oreo 8.1
AdityaDharewa said:
Hello
So the problem is in developer setting I can't change to AAC from SBC codec.
It stays to SBC only so I think I can get help from here from you.
Phone - Le Max2 Lineage Oreo 8.1
Click to expand...
Click to collapse
Please capture a dump and upload it to https://btcodecs.valdikss.org.ru, you'll see all codec information which the device supports.
And by the way, patched libraries for Le Max2 Oreo are already in the second post, give them a try.
ValdikSS said:
For regular users
Send me your bluetooth stack libraries: /system/lib/hw/bluetooth.default.so and /system/lib64/hw/bluetooth.default.so (if it exists).
Click to expand...
Click to collapse
Hmmm those files don't exist on my device (Pixel 2 XL, Pie 9.0 stock OS)
LeifAlbor said:
Hmmm those files don't exist on my device (Pixel 2 XL, Pie 9.0 stock OS)
Click to expand...
Click to collapse
/system/lib/libbluetooth.so and /system/lib64/libbluetooth.so for Android 9.
ValdikSS said:
/system/lib/libbluetooth.so and /system/lib64/libbluetooth.so for Android 9.
Click to expand...
Click to collapse
Done

Can You Screen Mirror/Cast With Dolby Digital Output (5.1)?

It has been a bit frustrating trying to find an answer to something that I would think would be a common question (or not common since people with real surround systems are rare). Anyway, is it possible to output 5.1 surround sound (Dolby Digital Plus, DTS, etc) to an external device like a TV? If you can't mirror cast/screen cast that, is their a way to get that kind of audio output from some kind of usb-c to hdmi cord/adapter?
If the answer is no to both, and that it's impossible to do at all, why would such a seemingly basic thing never come to be supported?
The only possible way to retain full resolution is using the C port and keep the signal in the digital realm (minimum output should be 24/96 khz) to a quality reciever.
Normally Dolby, DTS, HDCD, etc is then decoded by the reciever and brought into the analog realm.
BT LDAC is the best bluetooth option available for this device, but this will degrade the image.
It lacks the bandwidth to fully support 24 bit/48 khz and higher resolutions.
A degraded image will be especially noticeable with a stereo image or more channels on a room sound system. They lower the resolution, the more of sound stage you lose. Mp3 have about none, CDs better, HDCDs much better, 24 bit and higher, best.
blackhawk said:
The only possible way to retain full resolution is using the C port and keep the signal in the digital realm (minimum output should be 24/96 khz) to a quality reciever.
Normally Dolby, DTS, HDCD, etc is then decoded by the reciever and brought into the analog realm.
BT LDAC is the best bluetooth option available for this device, but this will degrade the image.
It lacks the bandwidth to fully support 24 bit/48 khz and higher resolutions.
A degraded image will be especially noticeable with a stereo image or more channels on a room sound system. They lower the resolution, the more of sound stage you lose. Mp3 have about none, CDs better, HDCDs much better, 24 bit and higher, best.
Click to expand...
Click to collapse
Alright, so, I bought one of these https://www.amazon.com/dp/B07G2GJFF3/ref=cm_sw_r_cp_apa_fabc_KNVWFbWRMZRWP?_encoding=UTF8&psc=1 hooked it up to my TCL 75Q825 TV, and I was able to get a 4K 30fps connection. My TV has an HDMI ARC channel I use to bitstream audio to my Integra DHC-80.3 reciever so that I get Dolby Digital Plus and DTS output from my Smart TV app's shows and movies, but the Note 20 Ultra will only play 2.1 channels.
So if I directly connected the hdmi adapter to the reciever, and fed the video and audio through there to the TV, would I get the 5.1 channel sound? Or am I misunderstanding what you said and basically you can't really do it?
I'm actually going to be returning the hdmi adapter because I found out that there are better adapters that will allow me to have 4K 60fps from my ultra, but honestly, if I can't get HDR out of it and surround sound, I probably will forget the whole thing.
I'm not for sure what the 20 is outputting in the digital realm. It would need to preserve the digital DTS encryption for it to work. Same for Dolby 5.1
I doubt it will glean these though.
However as long as it outputs 24bit/48khz in the digital realm it will preserve the HDCD encoding subtext (my only interest at this point).
Sorry I never had use for this. The C port digital is how the get the highest possible resolution throughput from it.
The hardware/firmware/software must support formats like Dolby 5.1 or DTS.
Does Sammy even support Dolby 5.1 let alone DTS on this?
Sammy been pretty backward in this respect so I doubt it.
Best I can tell it doesn't.
https://www.samsung.com/us/support/answer/ANS00080318/
blackhawk said:
The only possible way to retain full resolution is using the C port and keep the signal in the digital realm (minimum output should be 24/96 khz) to a quality reciever.
Normally Dolby, DTS, HDCD, etc is then decoded by the reciever and brought into the analog realm.
BT LDAC is the best bluetooth option available for this device, but this will degrade the image.
It lacks the bandwidth to fully support 24 bit/48 khz and higher resolutions.
A degraded image will be especially noticeable with a stereo image or more channels on a room sound system. They lower the resolution, the more of sound stage you lose. Mp3 have about none, CDs better, HDCDs much better, 24 bit and higher, best.
Click to expand...
Click to collapse
blackhawk said:
I'm not for sure what the 20 is outputting in the digital realm. It would need to preserve the digital DTS encryption for it to work. Same for Dolby 5.1
I doubt it will glean these though.
However as long as it outputs 24bit/48khz in the digital realm it will preserve the HDCD encoding subtext (my only interest at this point).
Sorry I never had use for this. The C port digital is how the get the highest possible resolution throughput from it.
The hardware/firmware/software must support formats like Dolby 5.1 or DTS.
Does Sammy even support Dolby 5.1 let alone DTS on this?
Sammy been pretty backward in this respect so I doubt it.
Best I can tell it doesn't.
https://www.samsung.com/us/support/answer/ANS00080318/
Click to expand...
Click to collapse
Alright so this is what confused me about the audio capabilities https://www.samsung.com/us/smartphones/galaxy-note20-5g/specs/ just use find in page and put "Dolby" and you should find the sentence that throws me off. Makes it sound like it can at least decode those formats? From my perspective the whole thing just seems odd, I mean to give a piece of hardware those kind of capabilities, and then not be able to output that to something that could really make use of it, makes those capabilities a bit pointless. But to be fair, I do have a usb-c to aux adapter that allows 32 bit audio to pass from the phone to some high end equipment and I rather like it, just wish there was a way to bitstream that audio so as to have a solid surround sound playback.
dece870717 said:
Alright so this is what confused me about the audio capabilities https://www.samsung.com/us/smartphones/galaxy-note20-5g/specs/ just use find in page and put "Dolby" and you should find the sentence that throws me off. Makes it sound like it can at least decode those formats? From my perspective the whole thing just seems odd, I mean to give a piece of hardware those kind of capabilities, and then not be able to output that to something that could really make use of it, makes those capabilities a bit pointless. But to be fair, I do have a usb-c to aux adapter that allows 32 bit audio to pass from the phone to some high end equipment and I rather like it, just wish there was a way to bitstream that audio so as to have a solid surround sound playback.
Click to expand...
Click to collapse
If you go into the reciever in the digital realm and get a Dolby or DTS indicator light up you got your answer.
Don't think you'll see this but it be cool if you did
By the way for HDCDs you don't need a decoder; a reciever with high resolution DAC(s) will glean 90+% of the subtext and yield around a 22 bit image.
You must stay in the digital realm going in though to preserve that encoding.
Many CDs are HDCDs but not marked as such.
Example: B52's Time Capsule album is an HDCD.
blackhawk said:
If you go into the reciever in the digital realm and get a Dolby or DTS indicator light up you got your answer.
Don't think you'll see this but it be cool if you did
By the way for HDCDs you don't need a decoder; a reciever with high resolution DAC(s) will glean 90+% of the subtext and yield around a 22 bit image.
You must stay in the digital realm going in though to preserve that encoding.
Many CDs are HDCDs but not marked as such.
Example: B52's Time Capsule album is an HDCD.
Click to expand...
Click to collapse
Ok so I tried plugging in the hdmi from the adapter directly into the receiver, when I look at the audio information display from the receiver on that input, it shows as 2ch PCM audio as what's being received, tried different apps on my phone that I thought maybe support Dolby Digital Plus (Vudu, Anywhere Movies, and tried MX Player Pro with a couple movie trailers that contain and able to select Dolby Digital audio) but to no avail. And as I thought about it, I forgot something basic that I should have immediately remembered, I won't be able to get actual Dolby Digital Plus or DTS audio coming through to the receiver unless the phone and/or app allowed/had an option of bitstreaming audio. I was hoping though, that at the very least, the phone could send out 5.1 PCM audio. So either the phone just hasn't been given that ability or I need a certain adapter that would allow it.
It would be really awesome if they made the screen mirroring and/or USB-C outputs of a phone more customizable, like being able to adjust video resolution output, color format, bit depth, and of course audio options with bitstreaming and/or speaker channel options.
Make sure the phone's UHQ Upscaler is enabled/active after hook it up.
blackhawk said:
Make sure the phone's UHQ Upscaler is enabled/active after hook it up.
Click to expand...
Click to collapse
I'll try that when I get home, assuming that option becomes selectable, from what I read that option is for use with headphones, I guess I'll find out if that USB-C connection with the adapter allows it to be enabled. I assume it might, I'm sure my USB-C to aux cord would allow its enablement as that connection would be for headphones as well.
I guess this frustration is what I get for being part of that very tiny minority of audio/video "weirdos", lol. What I see as basic options that should be available considering the hardware capabilities of a device, most phone engineers will never think about.
At one point I had a Denon flagship 7.1 reciever driving all identical THX bookshelf speakers with two 400 watt subwoofers on the mains in a stereo configuration.
Excuse me while I kiss the sky
So... now I have this silly Note 10+
And yes Sammy's engineers have dropped the ball with sound so many times their faces are imprinted on the tarmac. Feel the wuv.
blackhawk said:
Make sure the phone's UHQ Upscaler is enabled/active after hook it up.
Click to expand...
Click to collapse
Was able to and enabled the UHQ Upscaler, checked my receivers audio display info, and what it did was change the sampling rate from 44kHz (or I think it was 48kHz) to 192kHz. It's possible that it also raised the audio bit depth, but my receiver didn't display that info.
Yeah best thing that could be done would be Samsung adding a bitstreaming capability, if it had that, a speaker channel option would be less of an issue, since bitstreaming would carry the speaker channel information built into the audio codec that is bitstreamed.
I would think something like that could be implemented through software alone, as whatever source is sending the audio doesn't need to decode it or anything, it just has to be sent untouched.
dece870717 said:
Alright so this is what confused me about the audio capabilities https://www.samsung.com/us/smartphones/galaxy-note20-5g/specs/ just use find in page and put "Dolby" and you should find the sentence that throws me off. Makes it sound like it can at least decode those formats? From my perspective the whole thing just seems odd, I mean to give a piece of hardware those kind of capabilities, and then not be able to output that to something that could really make use of it, makes those capabilities a bit pointless. But to be fair, I do have a usb-c to aux adapter that allows 32 bit audio to pass from the phone to some high end equipment and I rather like it, just wish there was a way to bitstream that audio so as to have a solid surround sound playback.
Click to expand...
Click to collapse
dece870717 said:
Was able to and enabled the UHQ Upscaler, checked my receivers audio display info, and what it did was change the sampling rate from 44kHz (or I think it was 48kHz) to 192kHz. It's possible that it also raised the audio bit depth, but my receiver didn't display that info.
Yeah best thing that could be done would be Samsung adding a bitstreaming capability, if it had that, a speaker channel option would be less of an issue, since bitstreaming would carry the speaker channel information built into the audio codec that is bitstreamed.
I would think something like that could be implemented through software alone, as whatever source is sending the audio doesn't need to decode it or anything, it just has to be sent untouched.
Click to expand...
Click to collapse
Excellent. It may support up to 32 bit certainly 24 bit.
Never looked into that as my music database is .wav and HDCD files. As long as I have 24 bit throughput they're good to go.
I know I wasn't able to rip DTS audio files to hard drive but since I only had one album at the time I dropped the issue.
The only reason I know as much as I do about HDCDs is Tony Harding at Denon* was kind and generous enough in 2004 to fully explain the technology and how to save/decode them. I have over 200 gb of .wav files on my 10+, my whole CD collection in my hand.
That's pretty cool.
Some of the high end audio sites would be good places to find answers. There are definitely people there that know.
*Denon gives near unconditional product support including hardware and firmware. They are on the bleeding edge of high end home audio.
Dollar for dollar they give you the most bang for the buck.
Their flagship receivers rival those costing thousands more including standalone audiophile products.
There devices always exceed their written specs and they support them for life.
Denon has even have issued hardware/firmware upgrades for their flagship recievers which is unheard of at this price point. They've been a industry innovator for over a century.
Rub up against them and you'll be pleasantly surprised.

[MOD] [GUIDE] [ROOT] Enable HI-RES (24bits and over 48kHz sampling) on Xiaomi Redmi Note 9's family

Hello, I'm going to present to you a method to enable hi-res on the DAC of the Xiaomi Redmi Note 9' family.
The procedure will allow to you to use the full potential of the WCD9385 DAC present (at least) in the Snapdragon 720G.
Indeed, this chip can go up to 32 bits @ 192Khz for PCM stream and can decode natively DSD. Moreover, this chip have a THD+N (Total Harmonics Distortion + Noise) at a level of -108dB, but all audio tests of Xiaomi's phones mesures a THD+N about ~ -96dB, which is the noise floor of 16bits, logic cause by default, this chip is configured to only output in 16 bits mode.
I have setup, tested and experimenting myself on my own phone (Redmi Note 9 Pro - Global Version - MIUI 12.0.2.0 QJZMIXM) this method.
Due to some ROM similarity with other smartphone models in Xiaomi, it will probably works with other smartphones than the Note 9's family, but i will probably need some adjustments if your phone use a different DAC or scheme of audio configuration files.
Before anything :
I'm not responsible of any damage, malfunction or brick that you can do by applying the method. In general, if you don't know what are you doing, just don't do it !
Click to expand...
Click to collapse
Pre-requests :
1) Install ADB, Fastboot and Google ADB Drivers (if you are on Windows)
2) You need to unlock bootloader with Mi-Flash-Unlock (THIS WILL WIPE ALL YOUR PERSONAL DATA, MAKE A SAVE BEFORE STARTING ANYTHING !)
3) Install TWRP for Redmi Xiaomi Note 9
4) You need to root your smartphone with Magisk and install the boot image in fastboot mode that it will give to you.
5) Install ABD_ROOT and ENABLE_ENG Magisk's modules (it will give you the possibility to get root access in ADB) and turn them on for the next device reboot in Magisk App
6) Install MakeSysRW in TWRP (without it we can't remount /vendor partition in Read-Write, and can't touch system's files)
7) Strongly recommanded but not necessary : install Sample Rate Checker from Google Play (with this tool, you can check if the DAC has correctly been set in "HI-RES" mode)
Click to expand...
Click to collapse
Get your phone tuned for Hi-RES :
1) One all of those pre-requests are effectives, you need to get a terminal with adb working (smartphone connected to your PC and debug mode activated) and type :
adb shell mount -o remount,rw /vendor
If you get no errors, you just mounted the partition /vendor on your phone in Read-Write mode, this will allow you to get to the next step, otherwise, i strongly recommand to you to check if you have correctly done all the pre-requests i have described.
2) The next step will save the current audio configuration of your phone (in case you want to return to it for some reasons), still in a terminal window, type :
Code:
adb pull /vendor/etc/audio/audio_policy_configuration.xml ./saved_audio_policy_configuration.xml
adb pull /vendor/etc/audio_io_policy.conf ./saved_audio_io_policy.conf
This will download from your smartphone to your computer the current audio configuration files and save them under "saved_audio_policy_configuration.xml" and "saved_audio_io_policy.conf" in your current directory.
3) Now we will upload configurations files that i've tuned myself, in first case for my personal use.
What changes I've made from the OEM configuration ?
PRIMARY_OUTPUT was in 16 bits @ 48kHz => changed to 24bits @ 192 Khz
RAW_OUTPUT was in 16 bits @ 48 Khz => changed to 24 bits @ 192 Khz
DEEP_BUFFER was in 24bits @ 48 Khz => changed to 24bits @ 192 Khz
Wired Headset, Wired Headphones and Line comes from 16 bits @ 48 Khz, have all been tuned to 24 bits @ 192 Khz
Moreover, i have not touched the integrated speakers because they will not profit to go into 24 bits mode or with an higher sampling rate, and you will get more energy saving by let them as they currently are.
Click to expand...
Click to collapse
If you check the configuration, you will see at points that I tuned this : samplingRates="48000, 96000,192000"
EDIT 22-04-2021 - Few hours after the first release :
I have done this to let Android choose by it's own the sampling rate, because i have seen some sort of clipping on LINE output with OGG (vorbis) files (I assume it will be the same with destructive formats, such as MP3, but it's at least with OGG files) at max volume with very loud musics, i thinks if you set strict resampling at 96 or 192Khz, due to fast algorithms in Android Audio, it will generate some sort of distortion and, if your music is loud enough (and you are at the max volume), it will go over 0dB and clip. So I've maintained sampling rate at 48Khz, and it seems to be well, but if you have some clipping, please tell me in your reply, i will investigate further.
The clipping was effectively done by a resampling mismatches with two configurations files :
audio_policy_configuration.xml (the one that I modified originally)
audio_io_policy.conf
Sampling rates mismatches in audio_io_policy.conf because I left them to the OEM configuration, now it's fixed.​
Click to expand...
Click to collapse
You can get my configuration file in the files attached to this post, unzip the files in the current directory where ADB running, then send them to your device :
Code:
adb push ./audio_policy_configuration.xml /vendor/etc/audio/audio_policy_configuration.xml
adb push ./audio_io_policy.conf /vendor/etc/audio_io_policy.conf
This command will overwrite your current configuration files, once again, please be sure to have saved OEM configuration file on your PC !
4) Reboot your phone, and enjoy ! Now you can check with Sample Rate Checker the configuration, you will see something like this (it can be slithly different depending on what is plugged to your phone when you're start the app, in my case i have plugged my phone to an amplifier, so LINE_ANALOG has appears):
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
As you can see, AudioManager is in 192Khz mode, BUILTIN_EARPIECE correspond to the front top speaker usesed for private communications, and BUILTINT_SPEAKER is the bottom speaker, both of them have remain untouched.
The most interesting is LINE_ANALOG, corresponding to the phone plugged to a LINE output (a high impedance receiver, such as an amplifier), you can see the different Sample Rates supported, up to 192Khz, and Encodings is ENCODING_PCM_FLOAT corresponding to 24 bits (you can compare it with BUILTIN_EARPIECE and BUILTIN_SPEAKER that they are in 16bits mode).
EDIT : i can't attach the file to my post, anyway i sent it to mediafire and there is the download link
Download the Audio Configuration files tuned for HI-RES
If you have any comments, any remarks or want help, do not hesitate to ask.
22/04/2021 - Few hours after the first post :
I have discovered that the mysterious clipping isn't present when i plug/unplug the phone for few seconds, before appearing.
After some research, try and retries, I've found the problem : the file audio_io_policy.conf
In this file is listed all outputs present in the audio_policy_configuration.xml, but i found that all outputs have a fixed 48 kHz sample rate, which don't match with the concatenated ones in the tuned file.
Concretely, internally the sample rates don't matches, and streams (over)sampled above 48 KHz are some sort of clipped.
So I have concatenated samples also in audio_io_policy.conf, and now it works well with all types of musics.
The first post will be edited with modifications that you need to do with the file audio_io_policy.conf
06/13/2021 :
Xiaomi released an update (MIUI V12.0.1.0 - R****M) which introduce Android 11.
My mod is still perfectly working with this update and Android 11 without any modifications !
So, you can still follow this tutorial to enhance your device audio quality
_xenoxis_ said:
... (deleted)
EDIT : i can't attach the file to my post, anyway i sent it to mediafire and there is the download link
Download the Audio Configuration files tuned for HI-RES
If you have any comments, any remarks or want help, do not hesitate to ask.
Click to expand...
Click to collapse
Your audio_policy_configuration.xml has '<globalConfiguration speaker_drc_enabled="true"/>', and this means DRC (Dynamic Range Control) has been enabled on your all audio outputs. This is the reason the THD+N of your device is larger than that of usual hifi devices. Try replace the true with false in your configuration.xml file.
If you like, see maximizing the audio quality of bluetooth.
zyhk said:
Your audio_policy_configuration.xml has '<globalConfiguration speaker_drc_enabled="true"/>', and this means DRC (Dynamic Range Control) has been enabled on your all audio outputs. This is the reason the THD+N of your device is larger than that of usual hifi devices. Try replace the true with false in your configuration.xml file.
If you like, see maximizing the audio quality of bluetooth.
Click to expand...
Click to collapse
Thanks for your reply, i tried on my device but i don't know if I can hear a difference between before and now or if is it a placebo effect.
Android's audio configuration are poorly documented, what does exactly DRC ?
Thanks again for this tips, it will be added in the mod
The sample rate of AudioManager always 192kHZ, not fit the song dynamically.
Even we ignored energy saving(96kHZ, 48kHZ, etc), but how to handle 44.1kHZ case?
SRC still exist in this case right?
RlTd said:
The sample rate of AudioManager always 192kHZ, not fit the song dynamically.
Even we ignored energy saving(96kHZ, 48kHZ, etc), but how to handle 44.1kHZ case?
SRC still exist in this case right?
Click to expand...
Click to collapse
Yes it doesn't fit the song dynamically (at least them which are lossy formatted songs), but this is the android default behaviour, and instead of putting anything in 48kHz (which can be bad for all musics sampled over 48kHz), with my mod it resampling everything at 192Khz, which can avoid frequencies repliement (cf Shannon-Nyquist's theorem) and can be benefit for the DAC's internal logic and post-treatments.
Anyway, some music players on Android define the "passthrough" flag on lossless formats which tell to Android to not upsample.
In 24bits float, upsampling is very precise, and there's be no distortions audible (if there distorsion, it will happen only close to the noise floor, which is inaudible anyway), so you can consider your 44.1Khz to be EXACTLY the same if they are upsampling to 192Khz.
If it was 16bits, I will not tell you the same, in 16bits, the noise floor is at 96Khz, and there's much more conversions errors in Integer than floats, and much more in 16bits than 24 bits, so in this case, it can be destructive.
_xenoxis_ said:
Yes it doesn't fit the song dynamically (at least them which are lossy formatted songs), but this is the android default behaviour, and instead of putting anything in 48kHz (which can be bad for all musics sampled over 48kHz), with my mod it resampling everything at 192Khz, which can avoid frequencies repliement (cf Shannon-Nyquist's theorem) and can be benefit for the DAC's internal logic and post-treatments.
Anyway, some music players on Android define the "passthrough" flag on lossless formats which tell to Android to not upsample.
In 24bits float, upsampling is very precise, and there's be no distortions audible (if there distorsion, it will happen only close to the noise floor, which is inaudible anyway), so you can consider your 44.1Khz to be EXACTLY the same if they are upsampling to 192Khz.
If it was 16bits, I will not tell you the same, in 16bits, the noise floor is at 96Khz, and there's much more conversions errors in Integer than floats, and much more in 16bits than 24 bits, so in this case, it can be destructive.
Click to expand...
Click to collapse
Thanks!
Actually I am using Apple Music beta version which supporting lossless(even hi-res) resource. What can I do to "passthrough" upsample of Android? I saw a module called AINUR NARSIL in Magisk, is that work?
Two most common lossless formats in Apple Music are 16bit_44.1kHZ and 24bit_96kHZ. As you said, 16bit may cause serious problems? BTW, what's the difference between AUDIO_FORMAT_PCM_24_BIT_PACKED and AUDIO_FORMAT_PCM_24_BIT?
If 192kHZ works fine, how about 384?
RlTd said:
Thanks!
Actually I am using Apple Music beta version which supporting hi-res resource. What can I do to "passthrough" upsample of Android? I saw a module called AINUR NARSIL in Magisk, is that work?
Click to expand...
Click to collapse
You can't force to use the passthrough flag, it only depend on the music player implementation, how it use the Android's Audio layer. Apple Music can decode hi-res resources, but it not guaranteed that it use the passthrough flag behind. Anyway with my mod, even it doesn't use the passthrought flag, it will be upscaled to 192Khz which is sufficient for every hi-res listening.
Remember that the passthrough flag only tell to the Android Audio layer to not resampling the audio, which can be bad with music with a low sampling rate (as 44.1Khz or even 48Khz), cause there's no margin for audio processing in the DAC or high frequencies already in the audio source file.
I don't know about if the AINUR NARSIL mod can force the passthrough, the better is to test it yourself i would say
RlTd said:
Two most common lossless formats in Apple Music are 16bit_44.1kHZ and 24bit_96kHZ. As you said, 16bit may cause serious problems? BTW, what's the difference between AUDIO_FORMAT_PCM_24_BIT_PACKED and AUDIO_FORMAT_PCM_24_BIT?
Click to expand...
Click to collapse
Yes 16 bits may cause interpolations errors only if the destination rate isn't a multiple of the original rate and only if Android make the upsampling by maintaining the output level if the destination sampling rate is a multiple of the original one. This is a bit technical, and I don't know what Android decide and do, but in the worst case, yes, 16 bits integer sound makes more interpolation errors cause 16 bits is less precise than 24 bits float and makes more rounding errors.
For your last question, AUDIO_FORMAT_PCM_24BIT doesn't exist.
According to https://android.googlesource.com/platform/hardware/interfaces/+/master/audio/common/4.0/types.hal :
Code:
/* Subformats */
PCM_SUB_16_BIT = 0x1, // PCM signed 16 bits
PCM_SUB_8_BIT = 0x2, // PCM unsigned 8 bits
PCM_SUB_32_BIT = 0x3, // PCM signed .31 fixed point
PCM_SUB_8_24_BIT = 0x4, // PCM signed 8.23 fixed point
PCM_SUB_FLOAT = 0x5, // PCM single-precision float pt
PCM_SUB_24_BIT_PACKED = 0x6, // PCM signed .23 fix pt (3 bytes)
So there's just two different version of representing 24bits data.
You should take a look here, you'll probably learn some tips on how Android handle audio data
_xenoxis_ said:
You can't force to use the passthrough flag, it only depend on the music player implementation, how it use the Android's Audio layer. Apple Music can decode hi-res resources, but it not guaranteed that it use the passthrough flag behind. Anyway with my mod, even it doesn't use the passthrought flag, it will be upscaled to 192Khz which is sufficient for every hi-res listening.
Remember that the passthrough flag only tell to the Android Audio layer to not resampling the audio, which can be bad with music with a low sampling rate (as 44.1Khz or even 48Khz), cause there's no margin for audio processing in the DAC or high frequencies already in the audio source file.
I don't know about if the AINUR NARSIL mod can force the passthrough, the better is to test it yourself i would say
Yes 16 bits may cause interpolations errors only if the destination rate isn't a multiple of the original rate and only if Android make the upsampling by maintaining the output level if the destination sampling rate is a multiple of the original one. This is a bit technical, and I don't know what Android decide and do, but in the worst case, yes, 16 bits integer sound makes more interpolation errors cause 16 bits is less precise than 24 bits float and makes more rounding errors.
For your last question, AUDIO_FORMAT_PCM_24BIT doesn't exist.
According to https://android.googlesource.com/platform/hardware/interfaces/+/master/audio/common/4.0/types.hal :
Code:
/* Subformats */
PCM_SUB_16_BIT = 0x1, // PCM signed 16 bits
PCM_SUB_8_BIT = 0x2, // PCM unsigned 8 bits
PCM_SUB_32_BIT = 0x3, // PCM signed .31 fixed point
PCM_SUB_8_24_BIT = 0x4, // PCM signed 8.23 fixed point
PCM_SUB_FLOAT = 0x5, // PCM single-precision float pt
PCM_SUB_24_BIT_PACKED = 0x6, // PCM signed .23 fix pt (3 bytes)
So there's just two different version of representing 24bits data.
Click to expand...
Click to collapse
Much to learn.
One more question: your Sample Rate Checker showed that "LINE_ANALOG Encodings" is AUDIO_FORMAT_PCM_FLOAT. I got same result with my earphone. Our related setting should be AUDIO_FORMAT_PCM_24_BIT_PACKED. Thus i am confusing about that. Do you know why?
Here is my log and its screenshots. Some FLOAT words also appeared in it. Looks like Qualcomm handle audio by FLOAT format. I don't know if they have similar reason.
RlTd said:
One more question: your Sample Rate Checker showed that "LINE_ANALOG Encodings" is AUDIO_FORMAT_PCM_FLOAT. I got same result with my earphone. Our related setting should be AUDIO_FORMAT_PCM_24_BIT_PACKED. Thus i am confusing about that. Do you know why?
Here is my log and its screenshots. Some FLOAT words also appeared in it. Looks like Qualcomm handle audio by FLOAT format. I don't know if they have similar reason.
Click to expand...
Click to collapse
AUDIO_FORMAT_PCM_24_BIT_PACKED is the sub-format which is the float format in Android (as showed in my last reply), it contain only factional part and no integer part.
AUDIO_FORMAT_PCM_FLOAT is just a short alias which refer to it.
So, AUDIO_FORMAT_PCM_24_BIT_PACKED is strictly equal to AUDIO_FORMAT_PCM_FLOAT.
Apparently on your device, is it already setup to handle hifi audio in the record processing as well as the output, everything is in 24bits (float) @ 384KHz, which is very nice !
Which device is it ?
_xenoxis_ said:
AUDIO_FORMAT_PCM_24_BIT_PACKED is the sub-format which is the float format in Android (as showed in my last reply), it contain only factional part and no integer part.
AUDIO_FORMAT_PCM_FLOAT is just a short alias which refer to it.
So, AUDIO_FORMAT_PCM_24_BIT_PACKED is strictly equal to AUDIO_FORMAT_PCM_FLOAT.
Apparently on your device, is it already setup to handle hifi audio in the record processing as well as the output, everything is in 24bits (float) @ 384KHz, which is very nice !
Which device is it ?
Click to expand...
Click to collapse
Xiaomi mix2s with snapdragon 845.
Its integrated audio codec DSP is WCD9341, which has better dynamic range than WCD9385(snapdragon 888).
WCD9341 | Qualcomm
www.qualcomm.com
I carry it everyday as a "hi-fi" player.
RlTd said:
Xiaomi mix2s with snapdragon 845.
Its integrated audio codec DSP is WCD9341, which has better dynamic range than WCD9385(snapdragon 888).
WCD9341 | Qualcomm
www.qualcomm.com
I carry it everyday as a "hi-fi" player.
Click to expand...
Click to collapse
I can see the THD+N (Total Harmonics Distortions + Noise) is at -109dB for the WCD9341 and at -108 for the WWCD9385, which is exactly the same (you can't hear the difference, i dare anyone to tell me otherwise).
Don't refer to the "Playback Dynamic Range", which don't represent what is it outputted (you have to add the noise and the harmonics distortions).
You're very right to use it as a everyday hifi player ! I'm very surprise that Xiaomi has think to set the DAC in a hi-res mode by default. I'm wondering why they haven't do the same for their new devices .
_xenoxis_ said:
You're very right to use it as a everyday hifi player ! I'm very surprise that Xiaomi has think to set the DAC in a hi-res mode by default. I'm wondering why they haven't do the same for their new devices .
Click to expand...
Click to collapse
Actually I also changed configs as your mod and turn more items else to 24bit/384kHZ to ensure hi-res works. However, i don't know which features are essential for me.
RlTd said:
Actually I also changed configs as your mod and turn more items else to 24bit/384kHZ to ensure hi-res works. However, i don't know which features are essential for me.
View attachment 5361457
View attachment 5361459
View attachment 5361461
View attachment 5361463
Click to expand...
Click to collapse
"hifi_playback" is just an unused output which isn't routed to anything, so don't mind about it.
About your sampling rate change to 384kHz, this will not gonna set it to 384Khz cause you don't change the file "audio_io_policy.conf" where is the i/o configuration (currently, your configuration can cause some volume saturation as it done the first time I tried my mod on my device).
You need to set 384KHz as well in this file.
Moreover, is it useless to set the USB output over to 192Khz, I don't know a device in USB which can handle 384KHz audio on a USB connection.
However, I don't think there's a reel benefit to set the DAC to 384KHz, I mean the maximum sampling rate in PCM hi-res file is 192Khz (still rare actually) and I never seen anything beyond this value. Typically a hi-res file is in [email protected]
So what i'm trying to say, is that a change from [email protected] to [email protected] is beneficial, for many reasons (16-->24 bits, integer mode to float, increasing sampling rate), but passing from 192KHz to 384KHz is, in my opinion, completely useless.
Moreover, a value that high can increase the risk of causing some jitter (which normally can't happen even at 384Khz, but theoretically the risk increase).
And finally, you'll consume more power for nothing.
_xenoxis_ said:
"hifi_playback" is just an unused output which isn't routed to anything, so don't mind about it.
About your sampling rate change to 384kHz, this will not gonna set it to 384Khz cause you don't change the file "audio_io_policy.conf" where is the i/o configuration (currently, your configuration can cause some volume saturation as it done the first time I tried my mod on my device).
You need to set 384KHz as well in this file.
Moreover, is it useless to set the USB output over to 192Khz, I don't know a device in USB which can handle 384KHz audio on a USB connection.
However, I don't think there's a reel benefit to set the DAC to 384KHz, I mean the maximum sampling rate in PCM hi-res file is 192Khz (still rare actually) and I never seen anything beyond this value. Typically a hi-res file is in [email protected]
So what i'm trying to say, is that a change from [email protected] to [email protected] is beneficial, for many reasons (16-->24 bits, integer mode to float, increasing sampling rate), but passing from 192KHz to 384KHz is, in my opinion, completely useless.
Moreover, a value that high can increase the risk of causing some jitter (which normally can't happen even at 384Khz, but theoretically the risk increase).
And finally, you'll consume more power for nothing.
Click to expand...
Click to collapse
My system is MIUI11. A file called "audio_output_policy.conf" in same place which has the same content as a part of your audio_io_policy.conf. I've edited it and other file called "audio_policy.xml" in case.
Jitter looks getting higher in log but I don't know if I can hear it apparently.
Even I removed all energy-cost-optimizing-strategy on my music app to enhance stability of performance with 384kHZ. The battery cost is still acceptable.
Indeed, it makes me feel little bit weird when adopting 384kHz. All I do this is considering SRC from 44.1kHZ. Higher sampling may cause more reasonable curve in analog signal. However, it depends on algorithm and may cause other problems like harmonic wave and jitter. So it's an experiment and a trade-off. I will go back to 192kHZ if got nothing on 44.1kHZ files after comparing.
_xenoxis_ said:
"hifi_playback" is just an unused output which isn't routed to anything, so don't mind about it.
About your sampling rate change to 384kHz, this will not gonna set it to 384Khz cause you don't change the file "audio_io_policy.conf" where is the i/o configuration (currently, your configuration can cause some volume saturation as it done the first time I tried my mod on my device).
You need to set 384KHz as well in this file.
Moreover, is it useless to set the USB output over to 192Khz, I don't know a device in USB which can handle 384KHz audio on a USB connection.
Click to expand...
Click to collapse
I'm making a USB Sample Rate Changer script like bluetooth LDAC and usb-samplerate-unlocker (up to 386kHz and even 768kHz). If you like, see my github USB Sample Rate Changer and usb-samplerate-unlocker.
Update 08/07/2021 :
Hello guys, i have made a magisk module with this mod, it's currently on submission stage and it will be, normally, fully available in the magisk module repository (the "market").
With this magisk module, the mod will be systemless and will no require tricks to hard-modifying files on the device !
I'll keep you informed about this !
Great work.
I need to do the same in my K20 pro (Raphaelin), for the apple music lossless to use the inbuilt hifi dac

Categories

Resources