Not too long ago, I was driving my son to school when a song called “Bang Bang” came on the radio. It was not a brief for gun control. “Bang bang into the room (I know ya want it)/ Bang bang all over you (I’ll let ya have it).” I was just about to express my disapproval when I realized I was actually leaning into the radio, longing helplessly for what came next.

I had been hooked, in other words, as cleanly as a halibut, and if I’m to believe John Seabrook’s invaluable chronicle “The Song Machine,” I was a goner from the first note, prey to a posse of ­in-studio geek-wizards who draw on the full gamut of technology to “create sounds that are more sonically engaging and powerful than even the most skilled instrumentalists can produce.”

The results, says Seabrook, are not “soulful ballads” but ­“industrial-strength products, made for malls, stadiums, airports, casinos, gyms and the Super Bowl half-time show . . . teen pop for adults.” Resistance is futile. Whether performed by Ellie Goulding, Tove Lo or your neighbor’s nanny, these songs “bristle with hooks, painstakingly crafted to tweak the brain’s delight in melody, rhythm, and repetition.”

Recall those days when composers and lyricists, wreathed in cigarette smoke, hammered out tunes in some unventilated Tin Pan Alley or Brill Building office. Now bid those days adieu. In today’s “track-and-hook” system, trackmakers lay down beats and instrumentation; hook writers add melodies; someone else may throw on some lyrics; someone else may add a bridge; someone else a rap interlude. By the time a song has crawled to the end of its assembly line, any number of largely anonymous craftsmen will be able to lay some small claim to it.

John Seabrook at Tech@Fest during the New Yorker Festival at One World Trade Center on Oct. 2, 2015 in New York. (Photo by Anna Webber//Getty Images for The New Yorker)

Hit records, to quote the now-retired mogul Clive Calder, “are made in the recording studio,” and elements that used to be considered essential — such as, say, session musicians and in-tune vocalists — are now so many tonsils. When the teenage Britney Spears was pitched to the head of artists and repertoire at Epic Records, he turned her down on the old-fashioned grounds that he was “looking for true talent and a hell of a voice.” It took a Swedish songwriter and former glam rocker named Max Martin (nee Martin Karl Sandberg) to see that Spears’s vacancy was a perverse asset: “She’s fifteen years old. I can make the record I really want to make, and use her qualities appropriately, without her telling me what to do.”

So he gave her a little ditty called “. . . Baby One More Time.” (The elided words are “Hit Me.”) For good or ill, he also made the careers of the Backstreet Boys and ’N Sync, and he pushed performers as disparate as Pink and Maroon 5 to the top of the charts.

By now a certain unwelcome truth demands to be acknowledged: We’re all just living in Martin’s jukebox. His Billboard track record surpasses that of the Beatles and Michael Jackson. Over the past decade alone, he and his songwriting partner, Dr. Luke, have scored more than 30 Top-10 hits between them. If you want to know what has happened to Kelly Clarkson “Since U Been Gone,” if you’re curious as to what makes Katy Perry “Roar,” if you can’t shake off Taylor Swift’s “Shake It Off,” if you’re wondering why The Weeknd “Can’t Feel My Face” — or if you just want to “Bang Bang” — you have entered Martin’s labyrinth.

It’s a maze that leads back, naturally enough, to Sweden, where Martin cut his teeth at the legendary Cheiron Studios. John Seabrook takes us there, and, indefatigable journalist that he is, he also takes us to South Korea, birthplace of that horrifyingly plasticine phenomenon K-pop. He reenacts the rise of Rihanna and the first season of “American Idol” and the power struggles between “Idol” champ Clarkson and lizardly record exec Clive Davis. He introduces us to such fascinating eccentrics as ­“hook-spitting savant” Ester Dean and felon­impresario Lou Pearlman, and he even sifts through the wreckage of Dr. Luke and his protégé Ke$ha.

If anything, “The Song Factory” becomes almost too encyclopedic for its own good. Seabrook has plenty of zeal and access, but he lacks an argument to integrate all these far-flung dispatches. On one page, he’s making dire noises about “the teening of America”; on another, he’s insisting that “the song (as the song goes) remains the same.”

Perhaps it all comes down to this: No amount of money or technology or Swedishness can plumb the mystery of what makes a great tune. At the age of 2, the same son who introduced me to “Bang Bang” was walking past a TV broadcast of “The Wizard of Oz” when a girl named Judy Garland started crooning “Over the Rainbow.” For the next couple of minutes, he stood utterly rapt, listening to a song that had never been tracked or hooked or Auto-Tuned or comped or subjected to dynamic range compression. And when it was over, all he had to say was, “More.”

Louis Bayard is a novelist and reviewer who sings with the Captones jazz group.

Inside the Hit Factory

By John Seabrook

Norton. 338 pp. $26.95