HBO’s new ensemble drama “The Deuce” is, among other things, an unflinching show about the sex work industry in 1970s New York. But its most intimate exchange to date takes place in a moment of postcoital vulnerability between lovers. A bedside radio plays the white rocker Johnny Rivers’ cover of the Four Tops’ Motown hit “Baby I Need Your Loving” as Vincent Martino (James Franco), a thirtysomething bar proprietor, and his college-dropout bartender, Abby Parker (Margarita Levieva), lie in each other’s arms. “Do you like this music?” he asks, and her condescending laugh says it all. When he presses her about what she listens to, Abby turns the radio’s dial until she hears “Pale Blue Eyes” by the Velvet Underground. When she starts to tell a story about seeing the band at Max’s Kansas City, Vincent shushes her: “I’m listening.”

There’s a lot going on in this tranquil scene. Vincent, a gregarious Italian service-industry veteran from Brooklyn, seems to be using his fling with Abby to distract himself from his estranged family and obligations to the mafia. The gulf between his taste in music and hers reflects both age and class differences—she’s a young bourgeois bohemian, he’s a blue-collar Top 40 guy. Although they speak to two entirely different audiences, each song captures the exquisite pain of loneliness and longing. Vincent’s interest in what Abby calls “Lou’s tender side” may have something to do with lyrics that feel uncannily applicable to this new relationship: “The fact that you are married/Only proves you’re my best friend/But it’s truly, truly a sin.”

Music doesn’t play quite as obvious a role in this show as it did in one of co-creator David Simon’s previous HBO series, “Treme,” which was set in post-Katrina New Orleans, included several musician characters, and regularly featured live performances by local artists. But thoughtful syncs like the ones in the scene between Vincent and Abby reveal that it’s also a crucial part of “The Deuce.” In “Treme,” the vitality of the city’s music scene united a divided population and mitigated all the poverty and violence with moments of joy. The pop soundtrack of “The Deuce” does just as much work, establishing Times Square as a place where worlds collide while helping Simon demystify the mob, the sex industry, and 1970s New York in general.

Though very little of the music on the show is live, all of it is diegetic—part of the scene, not piped in after the fact to heighten viewer emotions. This choice goes a long way towards dispelling the aura of period nostalgia that has surrounded so many recent prestige-TV depictions of New York in the ’70s, from HBO’s terrible “Vinyl” to Netflix’s maximalist “The Get Down.” For better and worse, their splashy syncs glamorized the era’s violence and sleaze. In comparison, “The Deuce” feels more like a documentary.

When characters on the show choose their own music, it’s a window into who they are or who they want to be. As three pimps, Rodney (Method Man), C.C. (Gary Carr), and Larry (Gbenga Akinnagbe), get their shoes shined, a portable radio at their feet blasts James Brown’s “Get Up (I Feel Like Being a) Sex Machine”—a track that sums up their aspirations more than their reality. Abby listens to VU’s “Rock & Roll” after moving out of the NYU dorms and into the romantic squalor of a friend’s downtown apartment, as though to psych herself up for a precarious new life. By playing another Velvets song for Vincent and bragging about seeing them, she’s showing him the tougher image of herself that she’s just beginning to construct.