
Modification of the Bluetooth stack to improve the sound in headphones without AAC, aptX and LDAC codecs

Some wireless headphone users notice poor sound quality and a lack of high frequencies when using the Bluetooth SBC standard codec, which is supported by all audio devices. A common recommendation for improving sound is to buy devices and headphones that support aptX and LDAC codecs. These codecs require license fees, so the devices that support them are more expensive.

It turns out that the poor quality of the SBC is due to artificial limitations of the Bluetooth stacks and the headphone configuration, and this limitation can be avoided on any existing device by software changes on the smartphone or computer.
SBC codec
The SBC codec has many different parameters that are negotiated during the connection establishment phase. Among them:
Number and type of channels: Joint Stereo, Stereo, Dual Channel, Mono;
Number of frequency bands: 4 or 8;
Number of blocks in a pack: 4, 8, 12, 16;
Quantization Bit Allocation Algorithm: Loudness, SNR;
The maximum and minimum value of the group of bits used for quantization (group of bits): usually 2 to 53.
The decoder MUST support any combination of these parameters. The encoder may not do everything.
Existing Bluetooth stacks generally match the following profile: Stereo set, 8 bands, 16 blocks, Loudness, bitpool 2..53. This profile encodes 44.1 kHz audio at 328 kbps.
The bitpool parameter directly affects the bit rate within a profile: the higher it is, the higher the bit rate and therefore the quality.
However, the bitpool parameter is not tied to a specific profile; Other parameters also significantly affect the bit rate: the type of channels, the number of frequency bands, the number of blocks. You can increase the bitrate indirectly by agreeing on non-standard profiles without changing the bit group.
SBC bit rate calculation formula
For example, dual channel mode encodes channels separately using the full bit set for each channel. By forcing the device to use Dual Channel instead of Joint Stereo, we get almost double the bitrate with the same maximum bitpool value: 617 kbps.
In my opinion, the use of a non-profiled bitpool value in the negotiation stage is a flaw in the A2DP standard, which led to an artificial limitation of the SBC quality. It would be more prudent to agree on the bitrate rather than the bit group.
These fixed Bitpool and Bitrate values originate from the table of recommended values for high quality audio. But the recommendation is no reason to limit yourself to these values.
SBC Bluetooth Profile Table
The A2DP v1.2 specification, which was active from 2007 to 2015, requires all decoding devices to function properly with bit rates up to 512 kbps:
The SNK decoder shall support all possible values of the bit combination that do not exceed the maximum bit rate. This profile limits the maximum bit rate available to 320 kb / s for mono and 512 kb / s for two-channel modes.
In the new version of the specification, there is no bit rate limitation. Modern headphones released after 2015 that support EDR are supposed to be able to support bit rates up to ≈730 kbps.
For whatever reason, the Bluetooth stacks I have tested for Linux (PulseAudio), Android, Blackberry, and macOS have artificial limits on the maximum value of the 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, most devices work fine on a modified Bluetooth stack with a 551 kbps bit rate, without any dropouts or crackles. But that bitrate would never be constant under normal circumstances, in normal Bluetooth stacks.
Modify the Bluetooth stack
Any Bluetooth stack that is compatible with the A2DP standard supports dual channel mode, but it cannot be activated from the interface.
Let’s add a switch to the interface! I made patches for Android 8.1 and Android 9 that add full dual channel support to the stack, add mode to the mode switch menu in developer tools, and treat dual channel SBCs as if they were an additional codec like aptX, AAC or LDAC (Android calls it HD Audio) by adding a check mark to the Bluetooth device settings.











