It was as if a rock star were standing a few feet in front of Alex Palmer, not a balding, soft-spoken man in a cardigan and sensible shoes.

"I've never actually met a composer," said an excited Palmer, 15, motioning toward Aaron Jay Kernis, the musical celebrity in question. "I got to pick his brain."

For aspiring musicians at Palmer's South Philadelphia public school, the Girard Academic Music Program, it was a once-in-a-lifetime chance to learn from a legend.

Kernis, born in Philadelphia and raised in Olney and Bensalem, is a Pulitzer Prize winner whose works are performed around the world. He is the new composer-in-residence for Astral Artists, a Philadelphia nonprofit that assists emerging classical artists, and visited GAMP as part of the organization's outreach.

Next month, the 60 GAMP students who worked with Kernis will attend a performance of his Trio in Red, an energetic and whirling work in three movements.

Inside the GAMP auditorium on the day of Kernis' visit, spirits ran high as the students studied the piece.

As freshman Julia Bokunewicz put it: "When you listen to Bach and stuff, you never really get to know what he was thinking about when he wrote his music. But from now on, when we listen to this music, we'll know what was in his mind when he wrote it."

On stage, Kernis watched as Astral cellist Clancy Newman, pianist Michael Mizrahi, and clarinetist Igor Begelman warmed up. The day before, the trio had gone to GAMP to discuss the piece with a freshman-and-sophomore honors music class and a senior Advanced Placement music-theory class, a warm-up for the students' talk with Kernis.

For Kernis, accustomed to teaching at Yale University, the leap to working with inner-city high school students was large.

But, he said, "it's exciting having a different sort of educational experience. I'm really happy to see that this arts program has sprung up. It seems exceptional."

And, he said, it was rewarding to return to Philadelphia. Kernis attended Philadelphia public schools for a time, and graduated from Bensalem High School. He also attended the Governor's School for the Arts.

Kernis gave the students details of his musical past: taking voice lessons at 6, being a "total disaster" at clarinet and "more of a disaster" at flute, teaching himself at the piano, then, finally as a teenager, finding his niche as a composer.

"I would go into a room and shut myself in, and forget what was bothering me at school or home," Kernis said.

Colors often spring to mind when he's composing, he said.

For Trio in Red, whose score students pored over as he spoke, "red came through because, honestly, I would take walks when I was writing this piece, and I would see red. Literally, in the center of my vision, there was red."

The students nodded, familiar with the piece, at times mournful and angry.

Kernis explained synesthesia, when one sense joins with another. For him, music often equates with colors.

He motioned toward Mizrahi, the pianist, whose shirt was maroon.

"See your sweater? I have that color in my mind for C-sharp minor," Kernis said.

One student raised her hand shyly. "How does the music come to you?" she asked.

"Different ways - sitting at the piano and playing sometimes," Kernis said. "I can imagine sounds in my head, too - musical and nonmusical, like a trash truck or squeaking tires."

Sometimes he begins with a poem or another piece of text, exploring the rhythm of speech, he said.

The students wanted to know how Kernis had chosen the instruments for Trio in Red, and how he knows when he's finished with a piece.

He's always liked the combination of piano, cello, and clarinet, he said, and this work could easily be performed by the chamber group to which his wife, a pianist, belongs. And he knows when he's done "when I start getting calls from the commissioners saying, 'You're six months late! Where is that piece?' "

After the lesson, freshman Corrina Brabham, a singer and flutist, was breathless.

"I always wanted to meet someone famous," she said. "That piece was great - not, like, soft, but with some kind of tension."

Jack Carr, one of the founders of GAMP, a magnet school for fifth through 12th graders, sat in a back row during the lessons, pride on his face.

Trio in Red "is complex, deep, but they grasp it," said Carr, now vice principal. "Our students haven't had opportunities like this."

After a long chat with Kernis, Yung Bao, a senior pianist likely headed to Yale, the Juilliard School, or the New England Conservatory of Music, said he felt lucky.

"The piece was intense. You can see the colors, the rage, all the blood everywhere." Bao said. "This is fascinating to me. I can relate to him a lot."

Contact staff writer Kristen Graham at 215-854-5146 or kgraham@phillynews.com.