Jazz musicians are skilled improvisers. And now we know that they craft their spontaneous melodies the same way you craft a sentence.

Researchers scanned the brains of 11 professional musicians doing what’s called “trading fours”: two soloists take turns playing short riffs of about four bars. During each 10 minute session, a subject in a cramped functional MRI machine with a small keyboard traded fours with a second musician outside the scanner.

The research demonstrates that the brain appears to treat creating music as a form of communication. After all, trading fours is a musical conversation, where each player makes and modifies melodies in response to the other. And the research also hints that syntax applies to more than language. The same brain regions help us keep all our communication swinging smoothly.