Improve Bluetooth audio quality on headphones without aptX or LDAC

Search This thread

ValdikSS

Senior Member
Nov 10, 2007
292
231
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.
bwvyq9.png


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.
v83ugt.png

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.
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
  1. Download Virtualbox and Virtualbox Extension Pack: https://www.virtualbox.org/wiki/Downloads;
  2. Install Virtualbox, start it;
  3. Install Extension Pack using File → Preferences → Extensions;
  4. Create new virtual machine: Linux, Ubuntu (64-bit), 1024 RAM. Do not create a HDD.
  5. Navigate to virtual machine settings, in Storage choose Controller: IDE, Empty, press CD icon → Choose virtual optical disk file;
  6. Select downloaded bluetooth-dualchannel-test-ubuntu-18.04.1-desktop-amd64.iso;
  7. Save and close settings window, start virtual machine;
  8. 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.
  1. Burn the image to a USB flash drive using Etcher: https://etcher.io/. This operation will delete all existing files on a USB drive.
  2. Turn off the PC;
  3. Insert USB flash drive, turn on the PC and press boot order button (usually Esc or F12);
  4. Select your USB flash drive.

Performing the test
  1. (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.
  2. Switch the headphones to pairing mode;
  3. Click to the arrow in top right corner, select Bluetooth icon → Bluetooth Settings;
  4. Choose your headphones, wait until pairing is complete and close the window;
  5. Set Ubuntu volume to about 2/3. Also decrease volume using headset buttons as it could be very loud after pairing.
  6. Open "music" folder, play "testrecord1.flac";
  7. (optional but recommended) Close player, close terminal window. This will stop data capture.
  8. (optional but recommended) Open Firefox browser, upload data dump (btsnoop_hci.btsnoop on the desktop) to https://btcodecs.valdikss.org.ru/
  9. You can listen to other music in the music folder, or upload your own;
  10. 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!
 

Attachments

  • bluetooth-dualchannel-test-ubuntu-18.04.1-desktop-amd64.iso.torrent
    5.4 KB · Views: 3,861
Last edited:

ValdikSS

Senior Member
Nov 10, 2007
292
231
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:
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
  1. Turn off Bluetooth;
  2. In Developer Settings, enable the "Enable Bluetooth HCI snoop log" switch;
  3. Turn on Bluetooth, connect to your headset using Bluetooth menu (this is important! Do not allow auto connection!);
  4. Play short audio sample;
  5. Open developer settings, disable the "Enable Bluetooth HCI snoop log" switch;
  6. 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.
  7. Upload btsnoop_hci.log to https://btcodecs.valdikss.org.ru/;
  8. 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.
 
Last edited:

ValdikSS

Senior Member
Nov 10, 2007
292
231
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)
 
Last edited:

ValdikSS

Senior Member
Nov 10, 2007
292
231
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.
 

Attachments

  • original_and_aptx.zip
    11.3 MB · Views: 1,650
  • sbc.zip
    11.2 MB · Views: 2,110
Last edited:

rohit3192

Senior Member
Jul 26, 2011
389
68
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.
 

Attachments

  • Backup.zip
    2.4 MB · Views: 346

ValdikSS

Senior Member
Nov 10, 2007
292
231
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.
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.
 

Attachments

  • leeco_lemax2_32bit_patched.zip
    3.4 MB · Views: 308
Last edited:
  • Like
Reactions: djackson02

rohit3192

Senior Member
Jul 26, 2011
389
68
OK .
I try. Allow me some time.
Yes both libs were in one file. Now sending you separate libs.
 

Attachments

  • lib.zip
    1.1 MB · Views: 304
  • lib64.zip
    1.3 MB · Views: 380

rohit3192

Senior Member
Jul 26, 2011
389
68
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.
 

Attachments

  • Screenshot_Settings_20180823-163228.png
    Screenshot_Settings_20180823-163228.png
    208.4 KB · Views: 3,284
  • Screenshot_Settings_20180823-163233.png
    Screenshot_Settings_20180823-163233.png
    213.7 KB · Views: 3,250

ValdikSS

Senior Member
Nov 10, 2007
292
231
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.
Please try the latest archive. It includes patched 64 bit libraries.
 

rohit3192

Senior Member
Jul 26, 2011
389
68
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.
 
Last edited:

rohit3192

Senior Member
Jul 26, 2011
389
68
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
 

ValdikSS

Senior Member
Nov 10, 2007
292
231
@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
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.
 

AdityaDharewa

Member
Apr 3, 2017
18
5
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
 

ValdikSS

Senior Member
Nov 10, 2007
292
231
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
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.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 37
    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.
    bwvyq9.png


    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.
    v83ugt.png

    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.
    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
    1. Download Virtualbox and Virtualbox Extension Pack: https://www.virtualbox.org/wiki/Downloads;
    2. Install Virtualbox, start it;
    3. Install Extension Pack using File → Preferences → Extensions;
    4. Create new virtual machine: Linux, Ubuntu (64-bit), 1024 RAM. Do not create a HDD.
    5. Navigate to virtual machine settings, in Storage choose Controller: IDE, Empty, press CD icon → Choose virtual optical disk file;
    6. Select downloaded bluetooth-dualchannel-test-ubuntu-18.04.1-desktop-amd64.iso;
    7. Save and close settings window, start virtual machine;
    8. 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.
    1. Burn the image to a USB flash drive using Etcher: https://etcher.io/. This operation will delete all existing files on a USB drive.
    2. Turn off the PC;
    3. Insert USB flash drive, turn on the PC and press boot order button (usually Esc or F12);
    4. Select your USB flash drive.

    Performing the test
    1. (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.
    2. Switch the headphones to pairing mode;
    3. Click to the arrow in top right corner, select Bluetooth icon → Bluetooth Settings;
    4. Choose your headphones, wait until pairing is complete and close the window;
    5. Set Ubuntu volume to about 2/3. Also decrease volume using headset buttons as it could be very loud after pairing.
    6. Open "music" folder, play "testrecord1.flac";
    7. (optional but recommended) Close player, close terminal window. This will stop data capture.
    8. (optional but recommended) Open Firefox browser, upload data dump (btsnoop_hci.btsnoop on the desktop) to https://btcodecs.valdikss.org.ru/
    9. You can listen to other music in the music folder, or upload your own;
    10. 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!
    21
    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:
    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
    1. Turn off Bluetooth;
    2. In Developer Settings, enable the "Enable Bluetooth HCI snoop log" switch;
    3. Turn on Bluetooth, connect to your headset using Bluetooth menu (this is important! Do not allow auto connection!);
    4. Play short audio sample;
    5. Open developer settings, disable the "Enable Bluetooth HCI snoop log" switch;
    6. 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.
    7. Upload btsnoop_hci.log to https://btcodecs.valdikss.org.ru/;
    8. 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.
    13
    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)
    13
    @SpiderSGS6, sorry, I'm no longer accepting libraries for patching. Please test on the PC.

    Current results show that most devices correctly work with SBC Dual Channel and high bitrates. The test can be considered complete. Thanks for all who participated.

    Bitrate/bitpool increasing and SBC Dual channel implementing patchset is available by the following links:

    I consider this patchset as stable, without obvious flaws or known problems. It has been tested on various devices and in different conditions. "HD Audio: SBC" tick in Bluetooth device menu is not enabled by default, to prevent possible compatibility issues.
    ROM builders could be asked to include this patchset in their builds, before LineageOS/AOSP code review is done. Alternatively, ROM builders may provide flashable zip file with Bluetooth stack and Settings.apk/Bluetooth.apk/framework built with this patchset.
    12
    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.