(Photo: Elijah Henderson/Unsplash)

Ever feel embarrassed to be at a concert, and suddenly realize that your mind has been wandering? This can lead to self-scolding: You paid good money for that ticket, and you didn't even pay attention!

Well, give yourself a break. Chances are you began to mentally drift during a sad song, or the anguished slow movement of a symphony. According to newly published research, that's a perfectly natural occurrence—and it helps explain why we find melancholy music surprisingly enjoyable.

"When listening to sad (as opposed to) happy music, people withdraw their attention inwards, and engage in spontaneous, self-referential cognitive processes," reports a research team led by Liila Taruffi of the Free University of Berlin. "Our study suggests that the multifaceted emotional experience underlying sad music, often described by listeners as melancholic yet pleasant, shapes mind-wandering in a unique way."

In the journal Scientific Reports, the researchers describe three experiments—two in which participants described their mental state immediately after listening to a piece of music, and a third in which their brains were scanned as they listened.

In the first, the 216 participants recruited online listened to "music previously shown to evoke emotions of sadness and happiness, while keeping their eyes closed." Sad pieces included Song for Bob by Nick Cave and Warren Ellis; happy ones included the finale of a Haydn string quartet.

Immediately following each piece, they were asked "Where was your attention just before the music stopped?" They answered on a scale of one ("completely on the music") to seven ("completely on something else").

The second experiment was similarly structured, except the happy and sad musical excerpts were of approximately the same tempo. (The researchers point out that slow music doesn't have to be sad; some is simply peaceful and contemplative, such as pieces used in the background for yoga practice.)

The researchers report that "music evoking sad, low-arousal emotions increased the strength of mind-wandering," while that evoking happy, high-arousal emotions did the opposite. With happy tunes, "listeners are more focused on the music itself, and exhibit reduced mind-wandering levels."

The final experiment, which featured 24 people who underwent brain scans, found sad music produced a more robust response in the default mode network—"a set of brain regions typically active during rest periods." This reflects the fact participants tuned out the world and went inward.

"An additional interesting result was the form of mental experiences during music," the researchers add. They report music generated far more images than words, "pointing to a strong link between visual mental imagery and music processing."

Who needs music videos when we're creating our own?

These results may have practical implications. The link between music and mind-wandering "could be harnessed to improve creativity," Taruffi and her colleagues note. Indeed, a 2012 study found mind wandering can stimulate innovative thinking.

So if you find yourself creatively stuck, cue up Samuel Barber's Adagio for Strings and let your mind roam.