For anyone who has seen “La La Land,” composer Justin Hurwitz is the one to blame if you can’t stop humming the tunes stuck in your head. “But that’s the goal,” he says with a laugh. “When we’re working on them, we throw out the ones that won’t get stuck enough.”

Lionsgate’s “La La Land,” set for release Dec. 9, tells the story of L.A. residents Mia (Emma Stone), an aspiring actress, and Sebastian (Ryan Gosling), a jazz pianist. After a couple of false starts, the two fall in love, but still struggle to live their dreams.

Hurwitz not only composed the score for the movie; he also wrote music for the six original songs.

The film marks Hurwitz’s third collaboration with writer-director Damien Chazelle, his college roommate, including the Oscar-winning “Whiplash.” The two met freshman year at Harvard, where they started a band called Chester French with classmates. Sophomore year, the two quit the band to work on movies full-time.

“When we were seniors, Chester French ended up sparking a bidding war among all the major labels,” recalls Hurwitz, who says he and Chazelle are still good friends with their former bandmates. “We were thinking, ‘Oh my God, we blew our chance!’”

Hurwitz and Chazelle began working on the “La La Land” script in 2010, long before “Whiplash.” From the start, Chazelle had some pivotal moments in mind — a musical number on an L.A. freeway, a romantic dance that defies gravity in the planetarium, a big fantasy sequence at the end. “I was composing at the same time he was working on the script,” says Hurwitz.

Chazelle could be exacting. “He’s very demanding,” says Hurwitz. “He says ‘no’ over and over again. I’d work on the piano at home and send him MP3s over email. He’d say, ‘No, no, no, no, no … maybe — I sort of like that.’ And there’s a point when he says, ‘Yes, that’s the one. I love it.’ And when he says that, there’s no question that’s the melody.”