In 1963, jazz pianist Herbie Hancock was playing a show with Miles Davis when, during Davis’ solo, he played the wrong chord.

Shamed, he froze for about a minute. “Miles paused for a second and then he played some notes that made my chord right,” Hancock recalled. “(He) was able to make something that was wrong into something that was right with the power of the choice of notes that he made and the feeling that he had.

“What I realize now is that Miles didn’t hear it as a mistake. He heard it as something that happened, an event. That was just part of the reality of what was happening at that moment and he dealt with it. He felt it was his responsibility to find something that fit.”

That classic slice of jazz history became one of the guiding lights for Joe Gardner, the 45-year-old Black protagonist of Pixar’s “Soul.” The Disney subsidiary’s 23rd feature film, and first with a Black lead, was co-directed by the studio’s chief creative officer Pete Docter and playwright Kemp Powers.

Hancock’s memory of Davis was “a perfect metaphor for the story we’re trying to tell,” Powers said by phone last week. “Which is this idea that life itself is about taking whatever we have thrown at us and turning it into something beautiful.”

“That just seemed so profound and dead-on to what we were trying to say in the film,” Docter said in a separate phone interview. “It felt like jazz was a key component for the thematics of the film.”

It also mirrors the evolution of the film’s production.

When “Soul” begins streaming Dec. 25 on Disney+, audiences will follow Joe (voiced by Jamie Foxx), who dies just after receiving potentially life-changing news. After teaming with a rebellious unborn soul (voiced by Tina Fey), the two conspire to return his soul to his body.

An early iteration of the story was largely set in the metaphysical realm and featured Fey’s character as the lead. A teaser trailer released in 2019 drew concern over an animation trope of Black leads being magically transformed into non-human characters for the bulk of a film.

“The very first incarnation of the story spent almost no time on Earth,” Docter told Insider in October, adding that the human character wasn’t conceived as a Black man.

In fact, Joe’s race wasn’t decided until after the decision to integrate jazz into the story. “Jazz, both in African American culture and within the film itself, was so crucial,” Docter told The Times about shaping the ultimate narrative. “There was something about (making the character) a jazz musician that felt (altruistic) because you don’t go into jazz to get rich and famous, you do it because you have a passion for it. Then we realized that if this guy is going to be a jazz musician, he should be Black. It felt wrong to do anything other than that because it’s such a great American art form and contribution from African American culture.”

To ensure an accurate portrayal, Docter, whose previous Pixar credits include directing “Inside Out,” “Up” and “ Monsters, Inc.,” assembled teams of consultants to weigh in on story details and tapped Powers initially as a co-writer. (In a fluke of timing, Powers’ first two features will be released next month, as Amazon plans a Christmas theatrical run for “One Night in Miami,” an already acclaimed Regina King-directed drama that Powers adapted from his own stage play.)

“They showed me a very early reel of the film, and Joe Gardner didn’t have a lot of depth yet,” Powers said. “I just saw endless potential. I was like, ‘Well, how old is this guy?’ And they told me 45 years old. At the time, I was 45. The character is supposed to be from New York City, I’m from Brooklyn. And I’ve always been a jazz enthusiast as well. So it felt like this was the character that I was meant to write.”

“Kemp is not a guy to just fill the air; when he says something you know it’s important and well-considered,” Docter said. “We would involve him in the art and design process and in animation — he just had contributions throughout and was a real cornerstone to making this film authentic. So we said, ‘OK, we’ve got to bump him up to co-director.’”

To consider a broad range of perspectives, the filmmaking team turned to cultural consultants both in-house and externally. “Our first line of attack was to have our own culture trust within Pixar,” said Docter, who took over his executive role in 2018. “We had anywhere between eight and 10 African American employees who would see what we had and would comment. And even then it was tricky because everybody wants to be polite. So in the room, there were smiles and nods, but later we’d hear back that somebody didn’t like (something). We really had to work hard to make sure people felt like they could speak up with no fear of reprisal.

“We had a couple of folks on the story crew that put together a whole presentation about the shameful negative stereotypes that have existed throughout history and things to avoid,” he added. “They were like, ‘Don’t just soft pedal this. Don’t just make him a white character with Black skin, you’ve got to embrace the things that are distinctive (about Black culture) and do it in a loving way.’ That was a huge help to us.”

The directors also gathered a team of cultural and music consultants including Hancock, Daveed Diggs, Questlove, bandleader Jon Batiste, cinematographer Bradford Young and former director of the Smithsonian Institution’s National Museum of African Art, Johnnetta Cole. “We pretty much ran every single thing we did by Dr. Cole, from the character designs to the sets to the film in their incomplete form,” Powers said. “In many ways, she is like the mother of this film.”

“She was really pivotal to understanding how far to take things and how to nail it,” Docter said. “If you look at any of our films, we try to stylize. We made a lot of mistakes and errors and pushed things as far as we could and then recognized where things maybe could have been seen as offensive. Things like ear size and nose size, which are standard for us, but because of the history, it was a really difficult tightrope.”

Going forward, every Pixar film will include a culture trust, including the upcoming “Luca,” which takes place in Italy and will be helmed by Italian director Enrico Casarosa.

“If we really want to reflect people and the world accurately, we need to spend more time looking at it and really learning. That’s not easy because it’s extra work and takes extra time, but I think it’s important, especially given the amazing platform that we have and the effect these films have on young kids,” Docter said