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.
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
- Floyd, B., Santander, T. & Weimer, W. (2017). Decoding the Representation of Code in the Brain: An fMRI Study of Code Review and Expertise. Proceedings of the 39th International Conference on Software Engineering, 175-186 (twenty-nine participants across code comprehension, code review and prose review; neural representations of programming and natural languages are distinct, classified at 79% balanced accuracy; greater expertise predicts a less differentiated representation, r = -0.44, p = 0.016)
- Siegmund, J., Kästner, C., Apel, S., Parnin, C., Bethmann, A., Leich, T., Saake, G. & Brechmann, A. (2014). Understanding understanding source code with functional magnetic resonance imaging. Proceedings of the 36th International Conference on Software Engineering, 378-389 (seventeen participants comprehending short code snippets against locating syntax errors; a distinct activation pattern of five brain regions related to working memory, attention and language processing)
- Vasilev, M. R., Kirkby, J. A. & Angele, B. (2018). Auditory Distraction During Reading: A Bayesian Meta-Analysis of a Continuing Controversy. Perspectives on Psychological Science 13(5), 567-597 (sixty-five studies; background noise, speech and music all carry a small but reliable cost, with intelligible speech and lyrical music the most distracting)
- Salamé, P. & Baddeley, A. (1982). Disruption of short-term memory by unattended speech: Implications for the structure of working memory. Journal of Verbal Learning and Verbal Behavior 21(2), 150-164
- Mehta, R., Zhu, R. & Cheema, A. (2012). Is Noise Always Bad? Exploring the Effects of Ambient Noise on Creative Cognition. Journal of Consumer Research 39(4), 784-799 (a moderate level of ambient noise improved creative idea generation; a loud level did not)
- Söderlund, G., Sikström, S. & Smart, A. (2007). Listen to the noise: noise is beneficial for cognitive performance in ADHD. Journal of Child Psychology and Psychiatry 48(8), 840-847 (white noise improved performance in the ADHD group and deteriorated it in controls)
- Mark, G., Gudith, D. & Klocke, U. (2008). The cost of interrupted work: more speed and stress. Proceedings of the SIGCHI Conference on Human Factors in Computing Systems, 107-110 (forty-eight people interrupted every two minutes; interrupted conditions finished faster, 20.31 minutes against a 22.77-minute baseline, with no quality difference and significantly higher stress, frustration, workload, time pressure and effort after twenty minutes)
- Albulescu, P., Macsinga, I., Rusu, A., Sulea, C., Bodnaru, A. & Tulbure, B. T. (2022). "Give me a break!" A systematic review and meta-analysis on the efficacy of micro-breaks for increasing well-being and performance. PLOS ONE 17(8), e0272460 (twenty-two samples, about 2,300 participants; vigour d = 0.36, fatigue d = 0.35, performance d = 0.16 and not significant, with benefits confined to less cognitively demanding tasks)
- Colored noise: spectral slopes of white, pink and brown noise — IEEE Technology Navigator
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.