Pixar’s new film Coco, about a little boy named Miguel who dreams of becoming a musician, has already broken records as the highest-grossing movie in Mexico’s history and won over critics with a 97 percent rating on Rotten Tomatoes. The animated feature even brought a brigade of abuelitos from Tehuantepec, Oaxaca to the theater for the first time.

Coco’s allure rests in a blend of top-notch animation and a primarily Latino voice cast – all part of Pixar’s effort to make its first Mexico-set film as nuanced as possible. But a heap of the magic also lays in the Mexican music that courses through Miguel’s fictional town of Santa Cecilia and leads the pint-sized protagonist to emulate his hero Ernesto de la Cruz, a singer drawn in the spirit of Pedro Infante. Miguel chases after his musical aspirations and winds up in the mystical Land of the Dead, where he has to weave his way through family history – to the tune of Mexico’s most distinctive traditional and contemporary rhythms.

Getting the music just right was a six-year feat that coalesced the efforts of composer Michael Giacchino, composer and songwriter Germaine Franco, co-director/screenwriter Adrian Molina and music consultant Camilo Lara, the DJ and producer behind Mexican Institute of Sound. Frozen’s power couple Kristen Anderson-Lopez and Robert Lopez also contributed a song to the project. The endeavor required identifying music to ground the story in Mexican traditions, composing a score to reflect the themes and emotions of the film, and creating original songs that propel the soundtrack into the present day.

Federico Ramos, Michael Giacchino, Germaine Franco, Camilo Lara and Adrian Molina at Pixar Animation Studios in Emeryville, Calif. Photo by Marc Flores. Courtesy of Pixar

“We didn’t want music to be incidental – we wanted it to be crucial to the story,” Molina explained at a Pixar presentation with Franco, Lara and Giacchino back in August.

The source music, which refers to the background sounds in the film, had to strike a particularly realistic chord to bring Santa Cecilia to life. Scenes in which Miguel runs through market squares or family parties needed a natural soundscape made up of the right street musicians, the right voices, the right buzz from traffic. Lara, who lives in Mexico City, took on the Herculean task of exploring Mexican regions – Oaxaca, Michoacán, Veracruz, Yucatán, Sinaloa, Guanajuato – to find the exact swatches of sound that would color the film with authenticity.

In Mexico City’s glossy Estudio 13, Mexican street legends shuffled in and out of rooms, heaving trumpets, folkloric harps, bajos and massive guitarróns across the halls.

“In pueblos and cities, there is music and noise all the time,” Lara told Remezcla. “So, there’s music playing basically throughout the entire film because that’s what Mexican towns are like. If it’s not the radio playing, it’s someone’s voice selling something. There’s always something musical happening.”

Throughout the process, Lara also uncovered some of Mexico’s most impressive examples of street and traditional music. In Oaxaca’s San Andrés Huayapam municipality, Lara linked up with the famed Banda Tierra Mojada, a 15-piece group that has pioneered its own style of brassy, bursting Oaxacan-meets-Sinaloense banda. The multi-generational Mono Blanco, made up of more than 20 musicians from families who have played together since 1977, stood out as the leaders of son jarocho, a folk style from Veracruz. And in Mexico City, Lara connected with the storied Marimba Nandayapa Ensemble, a 61-year-old group that has championed Mexican marimba all over the world.

To record the references for source music and original songs, Franco met Lara in Mexico for a session that included more than 50 musicians. In Mexico City’s glossy Estudio 13, Mexican street legends shuffled in and out of rooms, heaving trumpets, folkloric harps, bajos and massive guitarróns across the halls. Because many Mexican street musicians learn to play their instruments by ear, Franco brought along sheet music and several demos she’d recorded. Some musicians would quickly memorize the songs by listening to the demos; those who knew how to read music would teach their band mates in a matter of minutes.

“I tried to make them feel like they should approach the music the way they would play it, not how I thought it should go. That was so important because it put them at ease and suddenly, the session became a real cultural exchange,” Franco said. “I wanted them to feel like they were the ones teaching us, because they have stylistic elements and traditions that have been carried on in Mexican music for hundreds, if not thousands, of years.”

“I feel like I somehow carried the traditions of my ancestors and shared them with the world.”

Franco also worked with Giacchino to realize the vision for the score, which the team recorded last August with an 83-piece orchestra. Giacchino, the composer behind Up, saw an opportunity to heighten the emotion in Coco. For Miguel’s character arc, he wanted to convey the 12-year-old’s love and passion for music. For the film’s theme of family history, he wanted to express a sense of mystery, longing, and reverence. Franco helped him identify renowned session musicians of Latino backgrounds, including violinist Rocio Marron, accordion player Enrique Martinez, guitarist Federico Ramos, trombone player Francisco Torres, percussionists Luis Conte and Alex Acuña and more.

Coco often has the spirit of a musical since it relies on original songs to move the plot forward. “Un Poco Loco,” for example, develops the relationship between Miguel and Héctor, a shifty skeleton in the Land of the Dead. Franco and Molina wrote “Un Poco Loco” as a classic son jarocho, nodding to the folk style’s tradition of storytelling. Anthony Gonzalez, the voice actor for Miguel, and Gael García Bernal, the voice of Héctor, belt out the tune in alternating verses.

The Lopezes penned “Remember Me” with Franco’s help as De la Cruz’s signature song. It appears in the film styled as a banda anthem sung by voice actor Benjamin Bratt, but a gentler duet featuring R&B star Miguel and singer-songwriter Natalia Lafourcade shines during the end credits. Lara, meanwhile, lent his electronic expertise for the glitchy “Jálale,” which powers a party in the film. Lara even makes a cameo in the scene as a skeleton DJ, clad in Lara’s signature bowler hat and “Give Cumbia A Chance” T-shirt.

Franco grew up on the border of Juarez and El Paso and has studied Mexican music for years – she’s incorporated Mexican music into films, such as The Book of Life, Margarita, and Breaking Pan With Sol. Coco gave her a chance to dive deep and share a wealth of Mexican musical genres with the world, letting her go far beyond mariachi or ranchera standards. The process, she said, even led her to some new discoveries, such as the indigenous voice tradition of Canto Cardenche. But most importantly, Coco allowed her to give back to Mexico while honoring her roots. When the film premiered in Mexico, Franco says people told her how the story had lifted their spirits at a time when the country has been affected by natural disasters, including a 7.1-magnitude earthquake that killed more than 300 people.

“I feel like I somehow carried the traditions of my ancestors and shared them with the world,” she said.

Perhaps Coco’s biggest achievement is that it comes across culturally aware and, as director Lee Unkrich put it in a recent interview with the New York Times, manages not to “lapse into cliché or stereotype.” Much of this is owed to the time spent unearthing traditions and weaving them into the film to show a side of Mexico that is often obscured from mainstream America.

“This film shows a beautiful Mexico, a magical Mexico – not the corruption or violence that we get in Hollywood. It moved me to think you can make a love letter that depicts the country in such a vibrant, respectful way,” Lara said. Coco is exactly that, a majestic love letter to Mexico and its people.

Coco is currently playing in theaters across the United States in both English and Spanish.