It’s by chance that Ray appears mere months after the death of its hero, Ray Charles, but it offers a needed lift for many of us laid low by the passing of the rhythm-and-blues genius. Director Taylor Hackford has made a bristling, dynamic mélange of entertainment whipped up around the inspired music and gargantuan persona of its subject. And Jamie Foxx gives a wondrous impersonation; he gets Charles from the inside out.

The script strides purposefully through Charles’s career and personal life, using flashbacks to his traumatic childhood in rural Florida—which included the drowning of his kid brother and the blindness that enveloped him before he’d reached adolescence—to explain his adult behavior. His ferocious self-sufficiency, which deflects any attempt, however well intentioned, to assist a handicapped man, and his suspicion that someone’s always trying to cheat him derive from the struggles of his mother, Aretha (Sharon Warren), a single parent, to provide for her family and prepare a blind black son to move through a menacing and unjust world.

This pared-down psychologizing is remarkably effective. One scene, in which Aretha restrains her impulse to intervene while her boy, in tears of panic, stumbles around their shack, eventually threading his way through its familiar landscape, is a deeply affecting episode that links the childhood sections of Ray to classic triumph-of-the-spirit movies like The Miracle Worker, Sounder and My Left Foot. Pawel Edelman’s cinematography works its technicolor magic in these scenes, which have a storybook quality. Hackford takes us deep into the heart of 20th-century American mythology.

Though there are marvelous scenes throughout (especially when Ray is on the road or in the studio), the screenplay is most grounded in depicting Charles’s childhood. The treatment of his troubled marriage to Della Bea (Kerry Washington), of the jealousy of his longtime mistress, Margie Hendricks (Regina King)—one of the back-up vocalists in his band—and of his heroin addiction have a cobbled-together quality.

The movie is stuck between its impulse to be a folk fable about a pop-culture hero and its need to present the messy, complicated facts of his life. It doesn’t sanitize the facts, but it does arrange them in an inspirational pattern. For example, the movie’s Charles goes cold turkey and kicks his dope habit in one trial-by-fire hospitalization; his wife sticks by him and he learns to be a better father. The real Charles had a lifelong struggle with drugs, and his marriage finally dissolved. This phony side of the script culminates in a dream scene in which Ray communes with his mother—who explains that heroin was just another crutch—and his long-gone brother George, who forgives him for failing to save his life. It’s an up-to-the-minute pop-psych version of a longstanding Hollywood style.

But it’s tough to think of a pop bio that doesn’t melt into cliché in the second half, when the vertiginous early career successes give way to the inevitable heartbreak. And Ray is so vibrant and enjoyable that the script’s shortcomings don’t come close to wrecking it.

If the treatment of Charles’s life may not always be convincing, the treatment of his music is. We get to see how this prodigy draws on all the sounds that afford him pleasure—the country-western undercurrents of his upbringing; the smoky, forbidden seductions of ragtime and jazz, which he first hears as a child; the candied, overorchestrated, sentimental music of the mainstream—and alchemizes them into fresh popular styles.

The movie is superbly acted, not only by Foxx but also by the stunningly gifted actresses who play the three essential women in Charles’s life: soulful, heartfelt Sharon Warren, raucous, sashaying Regina King, and Kerry Washington. And there’s a large, vivid supporting cast that includes Curtis Armstrong and The West Wing’s Richard Schiff as the unexpectedly hip white executives who launched Charles’s recording career.

Ray is an endearing musical. It may not always dramatize its great subject brilliantly, but it keeps faith with him.