Don Cheadle in Miles Ahead. Photo: Courtesy of Sony Pictures Classics

When, in 2006, Miles Davis was post­humously inducted into the Rock and Roll Hall of Fame, a family member announced that there was a biopic in the works starring Don Cheadle — which was, as it turned out, news to the actor. But the idea was inspired. As the cocaine-addicted Davis in Miles Ahead, Cheadle has the right wariness and sad, shocked-open eyes. He can seem at once self-contained and feral. His rhythms are his own.

Cheadle ended up co-writing (with Steven Baigelman) and directing Miles Ahead, too, and it’s half-marvelous. But it was hobbled from its inception. After years of jumping through hoops, Cheadle couldn’t get enough financing without a white co-star — who turned out to be Ewan McGregor, playing a journalist pushing a story on the musician’s five-year disappearance (circa 1979) from the music scene. It’s not as bad as it sounds, though. Rather than employing the usual, dopey, birth-to-death biopic scenario, Cheadle focuses on a single episode and leaves plenty of room for flashbacks. The emotional gist is that Davis has never recovered from the loss of his wife Frances Taylor (Emayatzy Corinealdi), who finally fled when — after cheating on and beating her — Davis pulled a gun and began hunting phantom intruders.

The movie’s actual scenario is a pure fantasia, complete with a McGuffin — an elusive session tape made during Davis’s fallow period that his record company wants and a nefarious manager (Michael Stuhlbarg) and his client, a young trumpeter (LaKeith Lee Stanfield), steal. There’s a lot of raging and gun-waving and even a car chase, and it might have all come together with a better, less abrupt payoff. Stanfield — who played a fiercely hurting teenager and wrote his own devastating rap in Short Term 12 — looks more and more like a major actor, and he doesn’t let the machinations of the story penetrate the character’s sphere of arrogance. Everything that’s great in Miles Ahead seems marginal to the main plot — when Cheadle lets himself go with the flow.

His style is jazziest when he travels into the past, as Miles’s memories drift in on a wave of blue notes and cigarette smoke and the younger Miles — aloof but not oblivious — surveys his listeners before fixing on Frances. As embodied by Corinealdi, she’s too much woman for Miles, not just ripely beautiful but bursting with a need to make her own art. Jealous whenever she travels (despite his own myriad sex partners), Miles makes Frances give up classical dance to devote herself to him. He bends his bandmates to his will, too, but gives them room to find their inner pulse. Miles Ahead probably doesn’t show enough of Davis’s rapport with Gil Evans and Herbie Hancock for the true fan, but it captures what you hear on many of Miles’s records — the sound of great artists alone together.

The writer George Grella Jr. described Davis as an “intensely, erotically intimate soloist: you overheard his thoughts, and he was ‘telling it like it is.’ ” That’s what Cheadle evokes when he’s onstage — and he is, at the very least, fingering the notes, having grown up playing sax. This is probably Cheadle’s most electrified performance since the one that made him a star, as the incorrigibly homicidal Mouse in Devil in a Blue Dress. Hobbled by illness, his Miles still seizes the space, using Davis’s high rasp to force people to lean in close. When he smokes cigarettes, he smokes hard. He burns too hot to settle into existing forms. He might have wished the movie broke out, too.

*This article appears in the March 21, 2016 issue of New York Magazine.