Researchers — and parents — have long known that babies learn to speak by mimicking the words they hear. But a new study shows that babies also might try to imitate the singing they hear in songs.

As part of the study, scientists captured audio of a 15-month-old boy making sounds similar to the beginning of the song “Happy Birthday,” hours after he heard the song played on a toy. An analysis of the sounds showed the boy hitting the first six notes of “Happy Birthday” almost spot-on, in G major.

“We know that throughout the first year of life babies become sophisticated music listeners — they learn a lot about the patterns of pitches and rhythms in music,” said Lucia Benetti, a doctoral student at The Ohio State University School of Music and lead author of the study, which was recently published in the Journal of Research in Music Education. “And infants become better at doing this spontaneously. But we don’t know much about how exactly this happens.”

The study is among the first to measure an infant’s attempt to recreate music by following him for an entire day.

“And what we learned is that in this one case at least, the baby is trying to sing along to songs he’s hearing,” Benetti said.

For the study, Benetti recorded one infant, a 15-month-old boy named James, through one 16-hour period. James wore a small, light recording device throughout the day, which captured every sound he heard and made. Benetti and her adviser, Eugenia Costa-Giomi, a professor of music education at Ohio State, then analyzed that audio data using software designed to measure language — things like the number of adult words the baby heard and tried to say. Benetti also listened to the recording and transcribed the music he heard and the music he made, searching for patterns or places where the child seemed to mimic what he heard happening around him.

That technology has primarily been used in previous research studies to collect data that shows how babies develop language, not to understand how they might begin to learn about music.

James’ parents also logged his primary activities that day — things like napping and meals.

In the morning, James spent about 10 minutes with a toy that played the melody of “Happy Birthday.” Later that evening, the device recorded James making about 10 sounds, lasting about four seconds, that resembled the beginning of “Happy Birthday.”

The researchers shared the recordings with people who didn’t know James and didn’t know what the researchers were studying. Those listeners reported that James was trying to sing “Happy Birthday.”

Shortly after James ate lunch, his mom sang the song “Rain Rain” to him twice. (You know how it goes — “Rain, rain, go away, come again some other day.”) Six hours later, James was playing with his father and started singing a version of “Rain Rain.” (The research notes that he sang it for seven seconds in the key of A-flat major.)

James’ dad immediately picked up on what his son was trying to do, and sang the song back to him. James repeated it.

(James’ dad also made up funny lyrics — “Scrambled eggs, scrambled eggs, makes big muscles in my legs.” James didn’t repeat those.)

The study shows that it’s possible for babies to learn melodies from the music they hear around them, Benetti said. She said future work could examine a larger group of babies, with more data, to see whether James’ response was typical.

“We could try to do it systematically to really start to understand how this learning occurs,” she said. “From this study, we at least know that it happens.”

The takeaway for parents? It can’t hurt to sing to your kids.

“The social aspect of music is important — if a baby sees their mother singing, they know she’s engaging with that song, that she’s enjoying it, and they know it must be important,” Benetti said.

“I think that social context is important. It’s engaging and it’s socially relevant, and for them, that’s enough.”