Bluetooth codecs


Free Download Mp4Gain
picture

Bluetooth codecs

Bluetooth

Today, music playback over the Bluetooth protocol is gaining immense popularity.

Bluetooth

This function is not only integrated into all modern audio systems. This algorithm is based on the operation of portable speakers and most models of wireless headphones. At the same time, the sound quality in practice can vary greatly, and here is why. The secret lies in the use of one or the other codec (not to be confused with profiles) when transmitting the source sound to the playback device. What codecs are there and what properties are they endowed with, let’s find out.

BLUETOOTH CODES

SBC (SubBand Codec) is a codec that is present in all devices without exception and provides basic sound quality, at the level of compressed files of an average bit rate.
AAC (Advanced Audio Codec) is an encoding algorithm based on a complex mathematical model. In terms of sound quality, it beats the SBC, but falls short of the next. It is used massively in Apple technology, which is why today it is the most preferred option for transmitting audio over Bluetooth.
AptX is an algorithm developed by Qualcomm with a sound quality similar to that of a CD. The source signal is compressed in a 4: 1 ratio with a 352 kbps bit rate and a 16 bit / 44.1 kHz bit rate. The AptX LL (low latency) variant with reduced playback delays stands out.
AptX HD is a further development of the AptX algorithm with the ability to transmit a signal with 24-bit / 48 kHz parameters. At the same time, the bit rate increases to 576 kbps. By ear, the differences to plain AptX are palpable, and the higher the class of technique, the more obvious the advantage of AptX HD.
AptX Adaptive is a new version (introduced in 2018) of the AptX codec, the key feature of which is the ability to compress audio with variable bit rate (dynamic quality setting). This is necessary in an environment where there are many “competing” wireless signals. In this case, it is possible to increase the compression of the original data to preserve the stability of the connection and, in the presence of “free air”, the sound quality will be maximum.
LDAC is a Sony creation and one of the highest quality codecs. The bit rate reaches 990 kbps at 24 bit / 96 kHz. By ear, this results in clear and dynamic music reproduction, free of digital artifacts. With the release of Android 8.0 Oreo, the LDAC codec has become part of this operating system as Open Source, but its presence on a particular device depends on the manufacturer of the gadget.
HWA (Hi-Res Wireless Audio) is a competitor of LDAC proposed by Huawei. The technology is based on the LHDC codec, developed by the Chinese Savitech, with a bit rate of up to 900 kbps and a maximum stream parameter of 24 bit / 96 kHz. In terms of sound quality, HWA is similar to LDAC, but so far the latter has a larger number of supported devices.
UAT (Ultra Audio Transmission) is the latest development from Hiby with a maximum bit rate of 1.2 Mbps and transmission parameters of up to 24-bit / 192 kHz. Due to the increase in the volume of data transmitted, UAT requires Bluetooth version 4.2 or higher. In order for the technology to work, any compatible Android smartphone with the Hiby Music app installed and a suitable receiver can be used, for example a compact Hiby W5 Bluetooth receiver.
BT-UHD (Bluetooth Ultra High-Definition Audio) is the next-generation protocol designed for maximum fidelity in high-resolution audio recordings. The maximum bit rate is 2.3 Mbit / s. Implemented for the first time on the Huawei Kirin A1 microprocessor using Bluetooth 5.1.
LC3 is the latest audio codec in the Bluetooth LE Audio specification, theoretically capable of delivering better sound quality than standard SBC at half the bit rate. As stated by the developers of the Bluetooth SIG (Special Interest Group) consortium, devices with LC3 will receive increased operating time (by reducing power consumption) and the ability to transmit the signal to multiple receiving devices at the same time (Broadcast Audio). Support for enhanced sync (multi-stream audio) is also noted. According to experts, the LC3 codec will be more relevant in wireless headphones, where one of the most important indicators is the battery life.


Free Download Mp4Gain
picture


Mp4Gain Main Window
picture


Mp4Gain Features
picture


Free Download Mp4Gain
picture

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

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

Bluetooth

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.

Bluetooth

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.

Bluetooth problems Part 4

Bluetooth problems Part 4

Bluetooth

AptX is a popular marketing codec

Bluetooth

Often times, in a new market, it is not the one who came up with the best solution that becomes the leader, but the one who came up with their solution first. This was the Apt-X codec, which was developed by Professor Stephen Smith of Britain’s Queen’s University in the 1980s for fast transmission of high-quality sound to various laptops and generally for fast recording. high-quality audio. Subsequently, the rights to the then Apt-X were bought by CSR, which made the codec wireless in 2009 and renamed it AptX. Well, in 2015, Qualcomm bought this company, which now owns the rights to AptX and voluntarily sells it to everyone.

The main idea behind AptX is to offer audio CDs with almost original quality. In fact, we see a 4: 1 compression, that is, the bitrate was up to 352 kbps at 16 bits and 44.1 kHz. Therefore, we are not talking about “almost” here: the maximum lossless compression does not exceed 2: 1, so data is still lost when transmitting sound using AptX. But how strong? We will talk about this below.

Since AptX is a purely mathematical codec that always covers the entire audio range up to 22 kHz; it seems like it should be better compared to the SBC, which often turns off the high frequencies. In fact, sadly, this is not the case. The basic principle of this codec is quantization, that is, the allocation of a certain number of bits for each subband: for example, 8 bits are used to transmit sound from 0 to 5500 Hz, from 5500 to 11000 Hz – 4 bits, 11000 to 16500 Hz and 16500 to 22000 Hz are 2 bits.

Bluetooth problems Part 2

Bluetooth problems Part 2

Bluetooth

As a result, SBC starts to sound even worse in the context of more “advanced” codecs.

Bluetooth

However, there is an interesting point: it can sound even better than AptX HD with a bit rate of 576 kbps. How is that? It’s simple: as I wrote earlier, this codec can be scaled within a very wide range, and its theoretical maximum is just over 1.5 Mbit / s, that is, it can even pass CD Audio without compression! Of course, in fact, in our noisy 2.4 GHz band, that speed is only possible in dreams, and not all headphones support it. However, the vast majority of solutions on the market are capable of working with SBC at a bit rate of 400 to 600 Kbps.

As a result, this is enough for psychoacoustics to stop cutting off frequencies, and in theory SBC starts to introduce even less distortion into the sound than Qualcomm’s newer codecs (yes, AptX belongs to them). But here everything was spoiled by the drivers: neither in Windows, nor macOS, nor iOS, you can in any way change the standard bitrate of 328 kbps upwards. The so-called SBC HD with a higher bit rate is available only for Android with LineageOS custom firmware. So, as I said initially, SBC wasn’t “killed” by a bad implementation – it was killed by bad drivers, and this codec itself is very good.

In 2020, we still cannot hear stereo sound through Bluetooth when we use the headset microphone

I think many users have found that when answering a call with wireless headphones, the sound quality drops significantly. What happens is that the headphones go into headphone mode (HFP, Hands-Free Profile). In this mode, they can transmit sound from the microphone of the headphones to the smartphone, but the sound of the smartphone is output only in mono. Of course, this is enough for a conversation – you don’t need stereo for clear speech understanding. But in 2020, we are often used to talking and listening to music or playing at the same time, and in this case, obviously, flat mono sound with low quality spoils everything.

Therefore, if you want to listen to music in stereo and chat at the same time, you will have to use an external microphone (for example, a smartphone). In this case, the standard profile A2DP (Advanced Audio Distribution Profile) will be used with at least SBC (or other “full” codec). But, of course, you will not have freedom of movement. This limitation was logical in the early 2000s, when Bluetooth sound was in its infancy – headphones were used only for communication, and the weak processors in the headphones were simply not enough to simultaneously work with stereo sound and a microphone.

But in the modern world, where headphones support complex mathematical codecs, such as AAC or LDAC, with noise cancellation and other chips, it was quite possible to expand the A2DP profile to the ability to receive and transmit sound in stereo.

Bluetooth issues

Bluetooth issues

Bluetooth

How 3.5mm Jack Rejection Caused A Complete Disaster With Wireless Sound

Bluetooth

In 2016, Apple shocked the world once again with the release of the iPhone 7 without our usual 3.5mm audio jack. The company then explained its move to the fact that it interfered with the creation of normal water protection. Whether it is true or not, you can argue for a long time, but with that step, Apple pushed the development of wireless headphones, actively participating in this, launching various AirPods.

As a result, at the moment, the absence of a 3.5mm jack on a smartphone no longer seems to be unusual, as does the dominance of various wireless headphones of all shapes and sizes on the market. You can buy both models for a conditional thousand rubles, such as Xiaomi AirDots, with minimal features and mediocre workmanship, and the flagship Sony WH-1000XM4 at the price of some of the best smartphones, which have excellent noise control and many configurations.

However, with the transition to Bluetooth sound, a new problem has arisen: When connecting wireless headphones to any device, the only thing you can know for sure is what the sound will be. But its quality and latency can be questionable, and to fix this you’ll have to dive into the hell of Bluetooth codecs, which I’ve been boiling over on my own for a couple of years. So you are welcome.

SBC is a good standard codec that drivers have drowned out

Of course, when creating any data transmission standard, in our case sound, you need to make it a basic and accessible implementation for everyone – this is how the SBC Bluetooth codec, or SubBand Codec, appeared. It has minimal hardware requirements and even simple button phones can work with it. It has a basic psychoacoustic model and extensive customization options. It’s free and open source and available to everyone for over 15 years. All of this should have made the rest of the codecs just unnecessary, if not for one thing.

In 99% of devices, this codec has a 328 kbps bit rate. Just for comparison: Standard 16-bit 44.1 kHz CD audio has a 4 times higher bit rate, slightly over 1.4 Mbps. As a result, even when listening to music from streaming services, the rate bit rate is no longer enough and psychoacoustics can start to turn off the upper frequency ranges, above 16-18 kHz, so that the lower ones, which everyone hears, get more space at the “narrow” bit rate. As a result, when listening to multiple compositions with a wide stage (for example, with female voices), the sound quality can drop significantly, which is why the SBC codec is traditionally considered unsuitable for transferring high-quality music.

Adding fuel to the fire is the fact that many headphone manufacturers simply do not configure DSP (Digital Signal Processing) for this codec. Headphones have a processor of the same name, which is responsible for preparing the sound before its direct output, and it can be made to do many useful things, for example, it is the DSP processor that is responsible for noise cancellation. You can also fix codec glitches by working with an equalizer. And if for several AACs or AptX the makers of the headphones still go off and “tweak” the sound, then even Sony doesn’t do anything with SBCs in their WH-1000XM line of overhead audiophile solutions, let alone simpler headphones.