Ambient Sounds for Coding: What Works

Borrowed Evidence

No published experiment has measured the effect of background sound on programming. The literature that gets cited in these articles tested reading comprehension, serial recall of word lists, creative idea generation and sustained attention — never writing, reading or debugging code. So every recommendation, including the ones below, involves a step where a result from one task is carried across to another, and the quality of the advice depends entirely on whether that step is sound.

That step is worth examining rather than hiding, because there is one study that speaks to it directly, and what it says is not what the usual framing assumes.

Code and Prose in the Scanner

A controlled experiment put twenty-nine participants in a functional magnetic resonance imaging scanner while they performed three tasks: understanding a code snippet, reviewing a GitHub pull request, and reviewing English prose with editing markups. The headline result is that the neural representations of programming languages and natural languages are distinct. Which task someone was doing could be classified from brain activity alone at 79 per cent balanced accuracy, and the same set of brain regions that distinguished code from prose did so with a near-perfect correlation.

If code were simply read the way prose is read, borrowing the reading literature wholesale would be straightforward. It is not that simple. But the study's third finding complicates it again in a useful direction: task distinctions were modulated by expertise, and greater skill predicted a less differentiated representation. More skilled participants treated code and prose more similarly at the level of neural activation.

Taken together that is a specific and limited licence. Reading results transfer better for experienced programmers than for beginners, because experience is what makes code look more like language to the brain. It is an unusual conclusion — the transfer is strongest exactly where the task is most automatic — and it is the honest basis for the rest of this page.

The Experiments Behind the Advice

Here are the findings being borrowed, with the task each one used and what the transfer rests on in each case.

A six-row table. Columns are the coding activity and the nearest tested task, the sound tested, the direction of effect, and what the transfer rests on. Reading code or reviewing a diff maps to reading comprehension from Vasilev and colleagues 2018, where noise, speech or music produced a small reliable cost; transfer rests on reading text. Holding a call stack in mind maps to serial recall from Salamé and Baddeley 1982, where unattended speech disrupted performance; transfer is weaker. Sketching an approach maps to creative idea generation from Mehta and colleagues 2012, where moderate ambient noise improved performance; transfer is weaker. Sustained attention in an inattentive group maps to Söderlund and colleagues 2007, where white noise improved performance; transfer is weaker. The same experiment's control group worsened under white noise; transfer is weaker. A final row reads: any coding activity, no experiment found, not measured. A note states that rows are separate experiments on separate tasks, so arrow sizes are not comparable. Coding activity, and the nearest tested task Sound tested Direction Transfer rests on Reading code, reviewing a diff Reading comprehension · Vasilev et al. 2018 Noise, speech or music Small cost, reliable Reading text Holding a call stack in mind Serial recall · Salamé & Baddeley 1982 Unattended speech Disrupted Weaker Sketching an approach Creative idea generation · Mehta et al. 2012 Moderate ambient noise Improved Weaker Sustained attention, inattentive group Attention task · Söderlund et al. 2007 White noise Improved Weaker Sustained attention, everyone else Same experiment · Söderlund et al. 2007 White noise Worsened Weaker Any coding activity No experiment found — Not measured — Rows are separate experiments on separate tasks, so the arrows show direction only; sizes are not comparable.
The experiments the advice is borrowed from. None of them used programmers, so the last column records what each inference rests on, by a fixed rule: reading text where the tested task was itself reading written language, weaker otherwise. Rows come from separate experiments on separate tasks, so the arrows give direction only and their sizes are not comparable.

The pattern in that table is worth stating plainly: the only finding whose tested task is itself reading written language is the one that says sound costs you. A meta-analysis of sixty-five reading experiments found background noise, speech and music all carry a small but reliable penalty, with intelligible speech and lyrical music the most disruptive. The results that favour sound come from creative idea generation and from an attention task in a group with attention deficits, both of which are further from code reading than prose review is.

So the defensible summary is uncomfortable for an article about which sounds to code to: for the activity programmers spend most of their time on, which is reading and understanding existing code, the nearest evidence says silence beats sound. Everything below is about the situation where silence is not what you actually have.

The Case That Survives

What survives is masking, and the argument for it is comparative rather than absolute. If your alternative to a steady sound is a quiet room, the reading evidence says take the quiet room. If your alternative is a colleague's phone call, a meta-analysis of the same literature identifies intelligible speech as the worst condition tested, and a steady sound that covers it is trading a large cost for a small one.

That has a consequence for sound choice which is more useful than any genre recommendation. The property you want is the absence of information. Anything with words is out, because speech is the specific thing the literature singles out. Anything with a recognisable repeating pattern is out for the same reason in weaker form: a pattern is something to follow. That rules out lyrics, podcasts, café recordings with audible conversation, and — if you are being consistent — the music most programmers actually listen to.

Choosing Among the Layers

Between white, pink and brown noise the choice follows from what you are covering rather than from the task. Those three differ only in spectral slope: white is flat, pink falls at about three decibels per octave, brown at about six. Flat means energy everywhere, including the frequency range where speech sits, which makes white the most effective at covering a conversation. Brown puts almost all of its energy low, which covers a fan or traffic rumble at a lower overall level but does little about voices. Pink sits between them and is the least fatiguing of the three to sit under for a full day, because the high-frequency content that makes white noise feel sharp is partly rolled off.

A mostly brown mix with a thin white layer on top is a reasonable default for an environment with both a mechanical drone and occasional voices, and the mixer on this site can run all five of its generated layers at once. Two independent layers at equal gain would sum to about three decibels above either alone, and the mixer divides the sum by the square root of the number of active layers to cancel exactly that, so a second layer changes the shape of the sound rather than its level — if nothing above a few hundred hertz is bothering you, it is not buying you anything.

Interruptions, Which Sound Does Not Reach

The thing programmers most often invoke to justify a sound setup is the cost of being interrupted, and the measured version of that cost is not what the summaries say. A laboratory experiment interrupted forty-eight people every two minutes during an email task. They finished faster than the uninterrupted baseline — 20.31 minutes against 22.77 — with no difference in quality. What rose significantly, after only twenty minutes, was stress, frustration, mental workload, time pressure and effort.

Two things follow for a coding setup. The cost of interruption is real but it is paid in strain rather than in elapsed time, which means it accumulates across a day rather than showing up in a single task. And the interruptions in that experiment were telephone calls and instant messages, which no acoustic measure touches. Masking addresses sound you do not need to respond to. It has no effect on the notification, the tap on the shoulder, or the message that requires an answer, and those are the interruptions that cost you.

The widely quoted figure of twenty-three minutes to recover from an interruption does not appear in that paper, and this article will not repeat it.

Session Length and Breaks

The ninety-minute figure that circulates in programming advice is not established by any source usually cited for it. What the break literature supports is narrow: a meta-analysis of twenty-two samples covering about 2,300 people found short breaks reliably improved vigour and reduced fatigue, with effect sizes near 0.35, while the pooled effect on performance was 0.16 and not statistically significant. Performance benefits appeared only for less cognitively demanding tasks, and longer breaks helped more than shorter ones. The authors concluded that recovering from highly depleting work may need more than ten minutes.

Coding is in the demanding category where the pooled performance effect was absent, so the honest reading is that breaks are worth taking for how they leave you feeling and lasting, and that five minutes is at the short end of what has shown any effect. Rotating between different sounds every ninety minutes is sometimes advised to prevent habituation to a masking sound; no source establishes that, and habituation is the mechanism by which masking works rather than a failure of it.

The Practical Residue

Use sound when the room gives you something worse, not as a default. Prefer the layer that matches the intrusion rather than the task. Keep it at the lowest level that stops the intrusion pulling at you, and remember that volume controls on a browser page set a gain multiplier rather than a decibel level, so the number tells you nothing about what reaches your ear. Turn off the audio notifications in your editor, because those are interruptions rather than noise and they are the category that actually costs you. And if you are new to a codebase or a language, weight the reading evidence more heavily than an experienced colleague would: the imaging study suggests that is precisely when code is least like prose, and when added sound has the most to interfere with.

References

Frequently Asked Questions

What is the best ambient sound for programming?

No experiment has tested background sound on programmers, so there is no measured answer. What the nearest evidence supports is narrower: for reading and understanding code, which is where most programming time goes, the reading literature says silence outperforms sound. Choose a sound when the alternative is someone else's conversation, and pick the one whose frequency range matches the intrusion.

Is music or ambient sound better while coding?

The reading meta-analysis found intelligible speech and lyrical music were the most disruptive conditions tested, which rules out anything with words. Beyond that, the property that matters is the absence of information to follow, so a steady noise is a safer choice than music with structure. This cuts against what most programmers actually do, which is worth being honest about.

Does it matter whether someone is new to the language?

The imaging evidence suggests it does. Code and prose produce distinct neural representations, but greater expertise predicts a less differentiated one, meaning skilled programmers process the two more similarly. Reading results therefore transfer best to experienced developers, and someone learning a new codebase is in the condition where code is least like prose and added sound has the most to interfere with.

How should editor notifications be handled?

Switch the audio ones off and keep visual indicators. Notification sounds are interruptions rather than background noise, and the interruption experiment found that the measured cost of interruptions is higher stress, frustration and effort rather than lost time. No masking sound addresses a notification, because the point of a notification is that you respond to it.

Should sounds be rotated to prevent habituation?

No source establishes that rotating sounds helps, and habituation is not a failure here: ceasing to notice a steady background is the mechanism by which masking works. On session length, the break research supports longer breaks over shorter ones and found no significant pooled performance benefit for demanding tasks, which is the category coding falls into.

WhiteNoise.top

WhiteNoise.top builds free browser-based noise generators, mixers and breathing timers. Our articles explain the acoustics behind those tools and cite published research where it exists.