After being assigned to score a film with a far-flung backdrop, most composers would do a little research to try to add the appropriate atmosphere.

Ludwig Göransson, the Swedish-born composer who was charged with scoring Marvel’s “Black Panther” movie and has worked with director Ryan Coogler on all of his films, didn’t just visit a university library or look at YouTube videos: He spent a month in Africa.

The result was life-changing, he tells Variety: “I came back with a totally different idea of music, a different knowledge. The music that I discovered was so unique and special. [The challenge was] how do I use that as the foundation of the entire score, but with an orchestra and modern production techniques — infuse it in a way that it doesn’t lose its African authenticity?”

Coogler says his composer (who also scored “Fruitvale Station” and “Creed”) returned from his sojourn with “amazing” material. “We were really interested in getting African sounds that had never been in a film like this,” he notes.

Nearly all of the unusual sounds in the “Black Panther” score were recorded in the West African nation of Senegal, where Göransson spent two and a half weeks accompanying singer-guitarist Baaba Maal on tour. Maal introduced Göransson to other Senegalese musicians, and many performed on the soundtrack.

The music that pairs with T’Challa (Chadwick Boseman), monarch of the film’s fictional African kingdom Wakanda, is led by six “talking drums,” which Göransson explains as “a small drum you put on your shoulder, one that does what no other percussion instrument does — it breathes.” The drummer squeezes, then loosens it to change the pitch.

Maal sings (in the Fula language) about the death of T’Challa’s father; he collaborated with Göransson on the song, heard when Wakanda is first revealed in the film. For the theme associated with usurper Killmonger (Michael B. Jordan), the composer used another West African instrument, the Fula flute: “It sounded sad but also aggressive, energetic and impulsive,” he says, and with the flutist speaking and even screaming into the flute, “it really resonated with the character.”

Göransson further found specific sounds for certain scenes. A sabar drummer performed “challenge rhythms” for T’Challa’s competitors. The kora, an African harp, and the vuvuzela, an African horn often used by fans at sporting events, provided additional color.

Having recorded hours of music in Senegal, the composer flew to South Africa, where he spent a week studying at the International Library of African Music in Grahamstown. There he sought out recordings from across the continent and played dozens of instruments.

At the same time, says Coogler, the score had to work as a superhero movie: “The music had to be anthemic, in the cinematic language that we recognize for these event movies. Ludwig is so well versed in orchestral composition, he could find a way to merge the two, and know when to go with one or the other.”

After months of writing, Göransson recorded more than two hours of music with a 92-piece London orchestra and a 40-voice choir in October and December, augmenting the African recordings and even using the orchestra to echo the multiple layers of rhythms in some of the complex drumming he first heard in Senegal. The choir sang in Xhosa, a South African language.

Massamba Diop (fore-ground) and Göransson record talking drums.

Serena McKinney

Göransson’s job wasn’t over when he finished recording. Grammy-winning rapper Kendrick Lamar was signed to add a contemporary sound to the score (as well as to curate an album of music from and inspired by the movie). Coogler says Lamar was an easy choice. “For me, it wasn’t about Kendrick’s name,” he explains. “It’s about his art.”

Coogler says that Göransson worked with Lamar and producer Sounwave “to weave in and out of his score the beautiful music that Kendrick was able to do for us.” Lamar and SZA sing the end-title song “All the Stars,” which has already hit the hip-hop charts.

The hip-hop tie-in was all in a day’s work for Göransson, who, in his other life, is producer and co-songwriter for Donald Glover’s band Childish Gambino and, like Lamar, performed on the recent Grammy Awards show. Nominated for three Grammys, including record of the year and album of the year, Göransson didn’t win, but he didn’t have time to mope about it. As soon as the ceremony ended, he was on a plane to L.A. for the premiere of “Black Panther.” Now that the movie is done, he’s back working on Childish Gambino’s next album.

Says Coogler: “Ludwig really set the table for the emotion that we were trying to get across, whether it was excitement or reflection or sadness.”