Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

The staff in the operating room burst into applause as Dan Fabbio tooted out a melody on his saxophone.

It may not have been his best performance but the notes were, to make a deliberate pun, music to the ears of Dr. Webster Pilcher, the neurosurgeon who had just been peeling away layers of Fabbio’s brain.

“He played it really flawlessly. It was beautiful,” said Elizabeth Marvin, a professor of music theory at the University of Rochester.

Fabbio’s ability to play the tune showed that Pilcher had removed the last sliver of a benign brain tumor safely.

It’s not the first time a patient has stayed awake during brain surgery to help the surgical team make sure that critical areas are not being damaged. But, Pilcher and colleagues reported this month, it’s the first time surgery to remove a brain tumor has been used to help map the precise location of musical ability in the brain.

“I’ve had patients sing country music. I’ve had patients reading. We’ve had patients creating poetry on the operating table. But this was probably the most dramatic,” Pilcher told NBC News.

Mapping musical ability in the brain

The case, detailed in the journal Current Biology, was a triumph for the multidisciplinary team at the University of Rochester, where music theorist Marvin works with neurosurgeons like Pilcher and a team of cognitive neuroscientists.

“How are you going to be assured that you are going to walk out of the hospital the same person as you came in as?”

They not only got the tumor safely out of Fabbio’s brain, preserving his musical abilities, but showed a way to use functional magnetic resonance imaging or fMRI to map the precise location of such musical ability in the brain.

“We were able to advance our scientific understanding of how music is represented in the brain,” Mahon said.

Musical ability resides in a part of the brain called the right posterior superior temporal gyrus. Language abilities are on the left side of the brain in most people. “Music and language, they are exactly across the brain from each other,” Mahon said. “They are almost mirror reversed.”

For Fabbio, a high school and middle school music teacher and band coach in New Hartford, New York, it started when he had a hallucination and seizure.

“All of a sudden with pretty much no warning at all, I started to hear things and see things that I knew were not there,” he said in an interview.

“It was kind of like a dream, like when you wake up from a dream and you have a hard time remembering.”

Tests showed he had a brain tumor, and indicated it was close to, if not pressing against, the center of the brain known to be important for musical processing.

Fabbio was only 25, and frightened. But it turned out to be a low-grade glioma — one that had to come out, but not likely to be life-threatening any time soon.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

He seemed like a perfect candidate for the team at Rochester. Fabbio said he was confused by the careful approach. As a research volunteer, there were forms to fill out and repeated explanations of what it would all mean to be part of a study.

“To me, my only question was basically do I have a better chance of being OK afterwards?” Fabbio said.

Pilcher said the program is designed to not only advance scientific knowledge, but to help the volunteer and to help future, patients, also.

“To me, it’s then like well, yeah. Let’s do it,” Fabbio said.

Brain surgery is scary enough at the best of times, but Fabbio faced losing the focus of his life: music.

“To me, my only question was basically do I have a better chance of being OK afterwards?”

Pilcher said brain surgeons want precise maps so that they help patients without hurting them.

“How are you going to be assured that you are going to walk out of the hospital the same person as you came in as?” he asked.

“I could map motor function and sensory function and some elements of language function, but there’s so much more that makes each human being an individual.”

This was his chance.

Watch: Maria Menounos Say Her Brain Tumor Was a 'Gift'

Mahon said brain scans such as fMRI are only somewhat accurate. “You never entirely know if the region that lights up in fMRIs is absolutely needed and critical for a task,” he said.

“How music is represented in the brain may be different from how language is represented in the brain,” added Frank Garcea, who worked on the research team.

Being able to test the regions in real time was a great opportunity.

They got the tumor. Could he still play?

So Fabbio signed up for weeks of brain scans and also worked with Marvin to come up with a simple tune he could play without too much effort on his saxophone while on his side in the operating room.

They worked on tests for pitch processing, melody processing and other skills. “There were aspects of music processing that were particularly relevant for Dan,” Garcea added.

Then it was time to go in. A piece of Fabbio’s skull was removed and Pilcher’s team went after the tumor, referring again and again to the map they'd built of Fabbio's brain.

“We removed the vast majority of the tumor,” Pilcher said.

“We gently removed the last vestige of tumor and then we had him play his saxophone to confirm for us that he was still musical. And he was.”

Pictured in this photograph, from left to right, are neuroscientist Brad Mahon, Dan Fabbio, the patient, and neurosurgeon Web Pilcher. The three stand against a display showing footage of Fabbio's surgery as well as maps of his brain created by the scientists to identify both the location of the tumor and music function. Mark Michaud / University of Rochester

Fabbio doesn’t remember the applause, but the university captured it on video.

He was back at work six weeks later and a year later he says he feels no impairment.

But right after surgery, his musical ability was affected. He got a taste of what it would have felt like had the tumor been bigger, had it extended into the musical areas, or had the team been unable to fine-tune the surgery.

“Nothing sounded correct, musically. Music didn’t sound correct. It didn’t sound right, for about a month. Having it taken away for a month was awful. It was awful,” Pilcher said.

The team got a National Institutes of Health grant for the work, which Pilcher said can and will benefit other patients needing brain surgery.

“This is a shining example of how research funding from NIH can tangibly benefit not only the understanding of brain science, but the outcomes for patients,” he said.

“Without this funding this kind of work could not be done. Period. It would be impossible.”