At the start of “Begin Again,” Dan Mulligan (Mark Ruffalo) is, as they say in old movies, “in a bad way.” He’s a jaded record executive, a former indie-label entrepreneur with a broken marriage, a nonexistent relationship with his teenage daughter Violet (Hailee Steinfeld), and a drinking problem. His typical commute to the office—when he decides to show up—involves drinking swill from a flask and listening to swill on his car stereo, that is to say the latest demo CDs of derivative junk that arrived in the mail that week. Each of his Dan’s boozy thoughts is communicated through a thicket of smarm and world-weary cynicism, making this a definitively Ruffaloian part—one playing to the actor’s scruffy, sardonic strengths.

This lifestyle can’t last forever, and pretty soon Dan is unceremoniously fired from the label he helped launched, resulting in the inevitable funny-embarrassing workplace breakdown scene, in which he tries to take with him a cumbersomely giant abstract painting, not to mention his client list. He’s rebuffed on this last point and is told, “this isn’t ‘Jerry Maguire.’”

Except that it is, basically: A talent representative who has lost his way re-launches his career from the ground up by pooling all of his eggs into one long-shot basket. Dan’s Rod Tidwell, in this case, is Gretta (Kiera Knightley), an insecure but brilliant singer-songwriter whose single contribution to a open mic night at a local pub resonates with Dan on the very night his life has hit its nadir. Gretta, we’ll soon find, is dealing with plenty of consonant problems; she emigrated from her native U.K. to New York make music with her American boyfriend/songwriting partner Dave Kohl (Adam Levine, of Maroon 5), but as he rose to major-label stardom, he left her behind in more ways than one. When she performs that raw tune about loneliness for a listening audience of virtually one—Dan Mulligan—she’s reached the end of her rope too, and is set to book a flight back home the next day.

Something amazing happens when Dan watches Gretta play, the first of the film’s many instances of irrepressible pleasure for music lovers. We climb into Dan’s otherwise muddled head and see how he hears this solo acoustic song: a little drumming here, a little piano here, a well-placed string solo bridging a chorus to a verse. The instruments spring to life on their way around Gretta, performed by the invisible session players in Dan’s mental Rolodex.

Jimmy Swaggart famously said that “rock music is the new pornography.” If “Begin Again” is music porn, this scene is one of its coital highlights. And others follow, as this unlikely pair forges a business relationship predicated on an ingenious idea: They’ll make a demo tape by recording her songs in public places around New York City, from subway platforms to the tops of skyscrapers, integrating the ambient sound of a city symphony into their raw, immediate mix, all of it recorded using ProTools and a mobile studio, aka a refurbished truck. Later, Dan and Gretta will share guilty pleasures from their iPhones through the use of a headphone splitter, gallivanting around Times Square in their own sonic worlds.

It’s no surprise this film was written and directed by John Carney, the voice behind “Once,” the most poignant musical-bonding film of our time. He understands the importance of music to connect lives better than any director I can think of, and he’s effortlessly gifted at excavating emotional honesty through music. “Begin Again” overflows with the joy of constructing organized sound from nothing, using music to express love, secrets, solitude, defiance, revenge, regret and other therapeutic outpourings.

Gretta cycles through most of these emotions herself through song; as for Dan’s character arc, the similarities to Jon Favreau’s “Chef” are striking: a wayward soul, fired from his day job, renews his personal relationships by starting a business venture fueled by 21st century technologies. The overarching, gratingly implausible sunniness of “Chef” is present here too, though it’s less bothersome. The title, after all, gives away the movie’s inherent optimism in the face of real-world struggles, both romantic and economic. It’s as delectable a pop music fantasy as “Chef” is a foodie Valhalla: You want to live inside this movie, even if—especially if—its world probably doesn’t exist.

“Begin Again” opens today, July 2 at Cinemark Palace in Boca Raton, Carmike Parisian at CityPlace in West Palm Beach, AMC Aventura, and Regal South Beach.