You press play, the song streams to your phone as a compressed file, your phone decodes it to plain audio samples, and then, if you are wearing wireless earbuds, it compresses the whole thing again in real time before sending it over the air. Most people never notice that second step. It is also the step that decides a surprising amount of what you hear.

That second step is the Bluetooth codec. There are a handful of them, each with a marketing name, a headline bitrate and a fan club. We read the specs, the vendor documents and the Android source to work out what those numbers actually mean.

If you want the basics of lossy compression first (masking, bitrate as a budget), our post on which codec differences you can actually hear covers them. Here we only care about the last few centimetres of the journey.

Why Bluetooth needs its own codec

Start with the raw numbers. CD-quality stereo audio is 44,100 samples per second, 16 bits each, two channels: 1,411 kbps. Classic Bluetooth with Enhanced Data Rate is nominally 3 Mbit/s, but once you allow for gaps between packets and acknowledgements, the practical maximum is about 2.1 Mbit/s.

So uncompressed audio would eat around two thirds of the best case link, on a 2.4 GHz band shared with Wi-Fi, through your pocket and your head, with retransmissions every time a packet gets lost. That does not leave much room for bad days. Compressing the stream to a few hundred kbps buys headroom, and headroom is what keeps the music from stuttering.

The rules for this live in the Advanced Audio Distribution Profile (A2DP). It makes one codec mandatory for every device, SBC, and lets devices negotiate optional ones on top. The phone and the headphones exchange the codecs they support, and the phone picks one. Everything else in this post is a story about that negotiation.

SBC: the codec everybody has to speak

SBC (low complexity subband codec) splits audio into 4 or 8 frequency bands and spends bits on each band according to a simple loudness rule. Its quality knob has a strange name: the bitpool. A bigger bitpool means more bits per block of audio, which means a higher bitrate.

Here is the worked math for the common "high quality" setting: 8 subbands, 16 blocks per frame, joint stereo, 44.1 kHz and bitpool 53.

audio bits per frame = 8 + 16 x 53 = 856 bits = 107 bytes header + scale info = 12 bytes frame size = 119 bytes samples per frame = 8 x 16 = 128 (per channel) frames per second = 44,100 / 128 = 344.5 bitrate = 119 x 8 x 344.5 = about 328 kbps 

That 328 kbps matches the A2DP high quality preset, and at 48 kHz with bitpool 51 you get 345 kbps. Android's own SBC encoder defines its default bitrate as 328, with a comment saying "High quality quality setting @ 44.1 khz", and drops to 229 kbps on links without EDR.

A Bauhaus style frame diagram on off-white paper. A long horizontal bar represents one SBC frame and is split into blocks: a small black block labelled "header + scale info, 12 bytes" and a large red block labelled "audio, 107 bytes". Above it a big dial labelled "bitpool" turns from 35 to 53 while "8 + 16 x 53 = 856 bits" works out the audio bytes, and the red block grows as it turns while a counter reads "229 kbps" then "328 kbps". Below, a row of 8 vertical blue bars labelled "8 subbands" and a grid of 16 columns labelled "16 blocks" multiply into "128 samples per frame". A yellow stopwatch shows "344.5 frames per second", and the final equation "119 bytes x 8 x 344.5 = 328 kbps" appears in black sans serif lettering.

One SBC frame, and where 328 kbps comes from

SBC's reputation is worse than its best case. At bitpool 53 it is respectable. The trouble is that the bitpool is negotiated, and a cautious phone or headset can settle much lower. Apple's accessory guidelines allow a bitpool range of 2 to 53 and say accessories "should support 53", which tells you the low end is real.

AAC: the iPhone's favourite

AAC is a full perceptual codec, the same family as the files in your music library. Apple's guidelines put it plainly: AAC-LC "provides higher audio quality than the SubBand Codec (SBC) for a given bit rate."

Apple even publishes its numbers. The AAC-LC codec information an iPhone advertises lists a bit rate of 264,630 bps with variable bitrate on, and the guidelines say devices "will vary AAC-LC bit rate depending on the content", with accessories expected to handle a minimum of 96 kbps. The current guidelines also add AAC-ELD, a low delay AAC variant, starting in iOS 27, defaulting to 256 kbps.

On Android, AAC goes through a different encoder. The AOSP AAC encoder uses the Fraunhofer FDK AAC library and takes the lower of two values: the bitrate the headphones advertise, and a peak derived from the link's packet size (MTU). Same codec name, different encoder, different budget. Keep that in mind; we will come back to it.

aptX: no psychoacoustics, on purpose

aptX works differently. Instead of a perceptual model, it splits audio into four subbands and codes each with ADPCM, predicting the next sample and storing only the error. That makes it simple and fast, at a fixed ratio of roughly 4:1: a 1.4 Mbit/s CD stream becomes 352 kbps at 44.1 kHz, or 384 kbps at 48 kHz.

Qualcomm's aptX Adaptive product brief gives the rest of the family:

  • aptX HD: 576 kbps at 48 kHz, 24-bit, fixed rate.
  • aptX Adaptive: variable, "typically 279kbps to 420kbps", with Qualcomm claiming aptX HD quality at 420 kbps and classic aptX quality at 279 kbps.

The fixed rates matter. A fixed-rate codec cannot back off when your phone is in a back pocket on a crowded train, so it either keeps up or drops out. Adaptive exists precisely to bend instead of break.

LDAC: 990 on the box, not always in your ears

Sony's LDAC is the one with the big number. Sony lists a maximum of 990 kbps and says that in "Best effort" mode the bitrate "automatically changes among 330kbps/660kbps/990kbps". Sony contributed the encoder to the Android Open Source Project, so any Android phone maker can include it (with a license from Sony for the software).

Two details are easy to miss, and both are in the libldac header:

Mode 44.1 / 88.2 kHz 48 / 96 kHz
HQ (high quality) 909 kbps 990 kbps
SQ (standard quality) 606 kbps 660 kbps
MQ (mobile use quality) 303 kbps 330 kbps

First, 990 only happens at 48 or 96 kHz. Music mastered at 44.1 kHz tops out at 909. Second, Android's LDAC encoder defaults to adaptive bitrate (ABR) unless the phone maker overrides it, and the initial mode for ABR is SQ. So out of the box, a lot of LDAC listening happens at around 606 or 660 kbps, and drops to MQ when the radio struggles. Still plenty, but not the number on the box.

A Bauhaus bitrate ladder on off-white paper with a strict grid. Vertical bars built from blocks, one block per 100 kbps, rise side by side from lowest to highest with sans serif labels underneath: "LC3 124 per channel" in yellow, "AAC 265 (iPhone)" in red, "aptX Adaptive 279 to 420" in blue, whose top pulses inside a dashed range box, "SBC 328" in black, "aptX 384", "aptX HD 576" in blue, and "LDAC" in red inside a dashed outline that marks 990. A dashed black line across the top is labelled "CD PCM 1411 kbps". On the right, four black radio arcs on a yellow disk, labelled "signal", turn grey one by one, and as they do the LDAC bar drops from 990 to 660 to 330, its top blocks breaking off and falling, while an "LDAC mode" panel switches from "HQ 990" to "SQ 660" to "MQ 330" before the signal recovers. A note beneath reads "990 only at 48 or 96 kHz".

Headline bitrates, and the one that moves when the signal gets weak

LC3 and LE Audio: doing more with less

LE Audio is the newer Bluetooth audio stack, built on the isochronous channels added in Bluetooth Core 5.2, and its mandatory codec is LC3. The Bluetooth SIG's technical overview of LC3 shows a listening test where LC3 at 160 kbps beat SBC at 345 kbps. The SIG's pitch is the trade: same quality as SBC at less than half the bitrate, or better quality at the same one, and the saved airtime can become battery life.

LC3 bitrates look small next to LDAC because they are counted per channel. The Basic Audio Profile defines named settings, for example:

setting rate frame bytes/frame bitrate 16_2 16 kHz 10 ms 40 32 kbps 48_2 48 kHz 10 ms 100 80 kbps 48_4 48 kHz 10 ms 120 96 kbps 48_6 48 kHz 10 ms 155 124 kbps 155 bytes x 8 bits / 0.010 s = 124,000 bit/s 

With a frame every 10 ms (LC3 also supports 7.5 ms), the arithmetic is refreshingly honest. Android has had built-in LE Audio support since Android 13, with LC3 as its default codec there.

Why the same earbuds sound different on Android and iPhone

Now the negotiation story pays off. The headphones advertise a menu, the phone picks from it, and the two platforms have different menus.

An iPhone speaks the codecs in Apple's guidelines: AAC-ELD, AAC-LC and SBC, preferred in that order. No aptX, no LDAC. Android's developer options list SBC, AAC, aptX, aptX HD and LDAC, and which of the optional ones a given phone actually ships is up to its maker.

So one pair of earbuds can easily end up on AAC with Apple's encoder on an iPhone, LDAC at an adaptive bitrate on one Android phone, and AAC with a different encoder and budget on another. Same drivers, same ear tips, three different signals. Suddenly "these sounded better on my friend's phone" stops being mysterious.

Lossy into lossy, and the latency bill

Here is the part most codec debates skip. Unless your source is lossless, Bluetooth is transcoding: decoding one lossy format and encoding the result into another. Spotube, for example, streams Opus at 256 kbps by default (see SettingsModels.kt). On Android our player hands decoded audio to the system as ordinary media playback, configured in AudioPlayer.android.kt, and the operating system re-encodes it into whatever codec the link negotiated. A music app does not normally pick the Bluetooth codec. The only Bluetooth-adjacent thing we do there is ask ExoPlayer to pause when audio gets rerouted from headphones to the speaker, which is a kindness to everyone on your bus.

Each lossy pass throws away what its own model thinks you will not miss, and the two models do not agree. Generation loss is the name for this: re-encoding lossy audio, especially with different settings, stacks artifacts. A higher Bluetooth bitrate mostly means the second pass damages the first one less.

A Bauhaus pipeline on off-white paper read left to right along a black rail, with each band drawn as thick as its bitrate. A red disc labelled "Opus 256 kbps" sends a thin red band into a black "decode" square, which lets out a wide yellow band labelled "PCM 1411 kbps". The band enters a blue triangle, "Bluetooth encode", and narrows into a thin red band labelled "SBC 328 kbps", which leaves as concentric black radio arcs toward a pair of geometric earbuds. Grey flakes break off at the Opus disc and at the triangle, labelled "loss 1" and "loss 2". Under the rail a timeline titled "where the delay comes from" grows block by block: a tiny black block "codec about 2 ms", then a long yellow block "buffers and radio", then a striped stretch ending at a red bracket labelled "50 to 80 ms (aptX Adaptive, Qualcomm)".

Two lossy passes, and where the delay really comes from

Latency follows a similar pattern of surprise. Qualcomm lists aptX codec latency at around 2 ms, yet total system latency for aptX Adaptive at "between approximately 50 and 80ms depending on implementation". The codec is rarely the slow part. Buffers that absorb radio hiccups are, and bigger buffers mean fewer dropouts and more delay. That is why low latency modes, such as aptX Low Latency (32 ms end to end, according to Wikipedia) and Apple's AAC-ELD, are their own products. For music the delay does not matter. For games and lip sync it very much does.

Check what your phone is actually using

On Android you can look at the link directly. The developer options documentation explains how to unlock it: tap Build number in About phone seven times until you see "You are now a developer!". Then, with your headphones connected and music playing, open Developer options and find:

  • Bluetooth Audio Codec: lists SBC, AAC, aptX, aptX HD and LDAC, and lets you choose among the ones both sides support.
  • Bluetooth Audio Sample Rate and Bits Per Sample: the PCM format fed to the encoder.
  • Bluetooth Audio LDAC Codec: quality, balanced, connection, or adaptive bitrate, which is the "best effort" mode Sony describes.

Two caveats. These menus differ a bit between phone makers. And forcing LDAC to 990 kbps in a busy place can trade a theoretical quality gain for real dropouts. On an iPhone there is no equivalent switch: you get what the negotiation picked.

The short version

Bluetooth recompresses your music because the radio cannot comfortably carry raw audio. SBC is the floor every device shares, AAC is Apple's choice and depends heavily on the encoder, aptX trades psychoacoustics for simplicity, LDAC offers the biggest budget but often runs below its headline number, and LC3 gets more out of fewer bits. The best codec is the one your two devices agree on and can sustain without dropping out.

References

Originally published on spotube.org.