A haunting melody can change your mood in just a few notes. New evidence suggests it is the distance between notes that determines how they make us feel—and that characteristic may have evolved from the way we use our voice.

Daniel Bowling, a cognitive neuroscientist at Duke University, analyzed the intervals, or distances between notes, in melodies from Western classical music and Indian ragas in a study published in March in PLoS ONE. He found that in both types of music, the size of the average interval is smaller in melodies associated with sadness and larger in melodies linked with happiness. Consider Beethoven's Moonlight Sonata. The melody in the first movement sways mournfully in a small grove of notes. In the second, happier movement, the melody takes off, lightly skipping through a much broader swath of the scale.

Bowling suggests that music mimics the natural patterns of our most primitive instrument—the voice. To test his theory, he collected speech samples from 20 English speakers and 20 Tamil Indian speakers and looked at whether the changes in frequency predicted the emotional content of their words. He found the same pattern as he did in written melodies: the sadder the speech, the more monotone the delivery. “Through the voice, we've come to associate different emotions with different tonal characteristics,” Bowling says.