A musical chameleon and flamboyant showman who never stopped evolving, Prince was one of the music world’s most enigmatic superstars. He celebrated unabashed hedonism, sang of broken hearts and spiritual longing and had a mysterious personal identity that defied easy definition.

In such hit songs as “1999,” “Little Red Corvette,” “I Would Die 4 U,” “When Doves Cry” and “Purple Rain,” Prince produced a musical legacy and a provocative stage presence that set him apart from most other entertainers of the 1980s and ’90s.

He won seven Grammy Awards and an Academy Award, and was named in 2004 to the Rock and Roll Hall of Fame. He remained a creative force in recent years and had performed earlier this month but canceled an April 7 appearance in Atlanta because of what a representative called the flu.

His death April 21 at his home in the Minneapolis suburb of Chanhassen, Minn., was a devastating shock to the entertainment world and beyond. He was 57.

His publicist, Yvette Noel-Schure, confirmed his death, but the cause was not immediately known.

Prince was a songwriter, musician, producer, choreographer and performer, seemingly in equal measure. He crossed musical genres, from classic rhythm-and-blues to hard rock, funk and jazz, seeking a vision of originality with each incarnation. His primary canvas was, in effect, the studio, where he produced his music with a meticulous eye toward pop perfection.

“Few artists have influenced the sound and trajectory of popular music more distinctly, or touched quite so many people with their talent,” President Obama said in a statement. “As one of the most gifted and prolific musicians of our time, Prince did it all. Funk. R&B. Rock and roll. He was a virtuoso instrumentalist, a brilliant bandleader, and an electrifying performer.”

Onstage, he projected both an urgent masculinity and an androgynous vulnerability, as falsetto squeals yielded to deep baritone growls. He stood only 5-foot-2, but few had a more commanding presence. He wore leather and lace, sometimes at the same time. He strutted the stage in a long coat like a Regency dandy, only to throw it open and reveal scanty briefs underneath.

In the early years, his theatrical concerts featured cars, backup singers and dancers, elaborate lighting and sometimes raunchy, frankly sensual dramatizations. He linked sexual obsession with a sense of spiritual yearning, drawing comparisons with one of his early musical models, Marvin Gaye. As he played his guitar with a frenzied intensity, a geyser of liquid would spew forth from the guitar’s neck.

“Do you want to take a bath with me?” he said, as he tore off his shirt in concerts in the mid-1980s. He then stepped into a bathtub under a spotlight and let the audience’s imagination roam.

Prince’s music was full of bounce and drive, with memorable musical and verbal hooks. “Tonight we’re gonna party like it’s 1999,” he sang in his 1982 hit “1999,” coining a phrase that would survive long past its expiration date into the new millennium.

In 2007, Prince gave what was widely regarded as one of the greatest Super Bowl halftime performances ever, singing “Purple Rain” and other songs in a downpour in Miami. As a songwriter, he penned songs recorded by Chaka Khan (“I Feel for You”), the Bangles (“Manic Monday”) and Sinead O’Connor (“Nothing Compares 2 U”), among other performers.

In 1988, Village Voice critic Robert Christgau declared that Prince’s varied talents made him “the greatest rock-and-roll ­musician of the era — as singer-guitarist-hooksmith-beatmaster, he has no peer.”

When “Little Red Corvette” became a major hit in 1982, it was one of the first songs by a black artist to be in regular rotation on MTV. It was one of the grand party songs of its era, celebrating youthful libido. His crowd-pleasing 1984 song “Let’s Go Crazy” began with a call to prayer — “Dearly beloved, we are gathered here today to get through this thing called life” — before becoming a hard-driving dance tune.

His 1984 album “Purple Rain” sold more than 13 million copies in the United States and won two Grammy Awards. He also won an Academy Award for best ­original song score for the semi­autobiographical film of the same name — in which Prince was the central character.

Six of Prince’s songs rank in Rolling Stone magazine’s list of the top 500 songs in rock history, including “When Doves Cry” from the album and film “Purple Rain.” The soulful “When Doves Cry” was simultaneously No. 1 on the pop, dance, and soul charts in 1984.

The musically innovative tune had no bass line. Instead, Prince’s keening voice and an insistent rhythm track contributed to the mood of emotional desolation:

How can you just leave me standing?

Alone in a world that’s so cold? (So cold)

Maybe I’m just too demanding

Maybe I’m just like my father too bold

Beyond the erotic indulgences of some songs, Prince also created music of surprising subtlety and depth, showing that rock music could evolve from its adolescent impulses to a more wistful sense of maturity. He challenged Michael Jackson for pop supremacy and acknowledged the influence of such masters as Gaye, James Brown and Jimi Hendrix.

Drummer Ahmir Thompson of the group the Roots, known as Questlove, wrote in Rolling Stone magazine that “Purple Rain” was “a crowning achievement, not only in Prince’s career but for black life — or how blacks were perceived — in the Eighties. It’s the equivalent of Michael Jordan’s 1997 championship games: He was absolutely just in the zone, every shot was going in.”

But the depth, sweep and dynamism of Prince’s music also evoked comparisons with such disparate artists as John Lennon, Mick Jagger, Bob Dylan, Bruce Springsteen and Madonna. The kaleidoscopic quality of his talent — torn between stardom and artistry — was sometimes vexing. One of his managers told him, “You can’t be both Elvis Presley and Miles Davis.”

From an early age, Prince cultivated a certain sexual and racial ambiguity. He confronted — but did not answer — the questions with his 1981 song “Controversy”: “Am I black or white? / Am I straight or gay? / . . . Was I what you wanted me to be?”

In “I Would Die 4 U,” from 1984, Prince wrote: “I’m not a woman / I’m not a man / I am something that you’ll never understand.”

He deepened the mystery when he officially dropped the name Prince in 1993 and asked to be identified by a visual symbol that could not be pronounced. For seven years, until he reclaimed his crown — and given name — as Prince, he was called “The Artist Formerly Known as Prince” or just “The Artist.”

His goal, he said, was to create a fresh artistic start.

“ ‘Prince is crazy’ — I knew what people were saying,” he told Newsweek in 2004. “When I became a symbol, all the writers were cracking funnies, but I was the one laughing. I knew I’d be here today, feeling each new album is my first.”

He sometimes performed with the word “slave” written on his face, as he fought his record label, Warner Bros., for control of his work. “If you don’t own your masters,” he said, “your master owns you.”

When he broke free of the label in 1996, he released an album fraught with symbolic meaning: “Emancipation.”

Prince Rogers Nelson was born in Minneapolis on June 7, 1958. His father, John Nelson, was a pianist in the jazz group Prince Rogers Trio, which would give the future superstar his name. His mother, the former Mattie Shaw, was a singer in the group.

When the couple divorced, Prince grew estranged from his father. They later reconciled, and John Nelson co-wrote songs with his son, including “Computer Blue” on the album “Purple Rain” and “Scandalous,” from the “Batman” soundtrack (1989).

Early in his career, Prince sometimes said he was the product of an interracial marriage, but in fact both of his parents were African American. He attended a largely black high school in Minneapolis.

Prince began playing piano at age 7 and soon became proficient on other instruments, including guitar, saxophone and drums. When he was 10, he saw James Brown in concert and was transfixed. He determined that he would try to emulate the soul star’s captivating style. He formed his first group in junior high school, began writing music and made a demo tape that attracted interest from Warner Bros. He wrote, produced and performed all the music on his debut album, “For You,” in 1978.

He found success with his second album, “Prince” (1979). The song “I Wanna Be Your Lover” reached No. 1 on Billboard’s R&B chart. With his third album, “Dirty Mind,” he sang explicitly about homosexuality and incest “with a gleeful lasciviousness,” critic Stephen Holden wrote in the New York Times.

“Obviously,” Holden observed, “Prince is not for everyone’s taste. But in today’s conformist pop-funk atmosphere, he stands out as a powerful, if eccentric, original voice.”

More than 30 other albums would follow. In addition to his music, Prince directed and performed in three other films, “Under the Cherry Moon” (1986), “Sign O’ the Times” (1987) and “Graffiti Bridge” (1990).

After leaving Warner Bros. in 1996, Prince started his own record label and a nightclub in Las Vegas. He continued to live near his home town of Minneapolis, where he recorded his music at a 65,000-square-foot studio.

As a reflection of his musical eclecticism, his desk contained photos of jazz giants Charlie Parker and Miles Davis.

In 1996, he married Mayte Garcia, a dancer. The marriage was annulled two years later. They had a son who died in infancy.

His second marriage, to Manuela Testolini, ended in divorce. A complete list of survivors was not available.

Throughout much of the 1990s, Prince kept a low profile as he preferred to be identified by the visual symbol. He re-emerged in his 40s as something of a changed and chastened man, still musically energetic but seeking a kind of spiritual sustenance.

After years in which he gave the impression of being a hedonist, Prince said he had a spiritual rebirth. He stopped swearing, adopted a vegan diet and in 2001 became a Jehovah’s Witness. He also stopped performing some of his more sexually explicit songs, which to some observers was like novelist William Faulkner forsaking Mississippi as a theme.

“There’s certain songs I don’t play anymore, just like there’s certain words I don’t say anymore,” he said in 2004. “It’s not me anymore. Don’t follow me way back there. There’s no more envelope to push. I pushed it off the table. It’s on the floor. Let’s move forward now.”

In recent years, the ­once-sheltered personality of Prince became more outgoing, as he consented to interviews and went on concert tour. He received his most recent Grammy in 2007 for best male R&B vocal performance for the song “Future Baby Mama.”

In a late burst of energy, Prince released four albums in the past two years, and last month announced that he was writing an autobiography titled “The Beautiful Ones,” a reference to a track on the album “Purple Rain.”

“Sometimes I stand in awe of what I do myself,” Prince told the New York Times in 1996. “I feel like a regular person, but I listen to this and wonder, where did it come from? I believe definitely in the higher power that gave me this talent. If you could go in the studio alone and come out with that, you’d do it every day, wouldn’t you?”