Earle Hagen, the Emmy-winning composer who wrote the iconic themes for “The Andy Griffith Show,” “The Dick Van Dyke Show,” “I Spy” and many others, would have turned 100 years old on July 9.

He was one of the most influential composers in TV history, formally recognized for his landmark work when the Television Academy inducted him, posthumously, into its Hall of Fame in 2011. He was only the second musician to be so honored. (Leonard Bernstein was the first, for his contributions to “Omnibus” and “Young People’s Concerts.”)

Hagen pioneered the creation of original music for television in the 1950s, when most TV music was cheaply recorded mood music licensed from pre-existing libraries. By the 1960s, he was composing, arranging and conducting for as many as five shows a week — “The Danny Thomas Show,” “That Girl” and “The Mod Squad” among them — and set a high standard that other TV composers would aspire to in years to come.

“Earle was a huge influence on us, and really good with the tunes,” says composer Mike Post, whose own themes (“Hill Street Blues,” “The Rockford Files,” “Law & Order”) also achieved classic status in later years. “He would send them out humming — or whistling. He did every kind of show: action-adventure, drama … he practically invented music for sitcoms. And he was genuinely kind to younger composers.”

Hagen came to television from nearly 20 years of experience as a player during the big-band era and as an orchestrator and arranger for movies. In 1939, as a trombonist for Ray Noble’s big band, he wrote the hit “Harlem Nocturne,” whose moody, noirish tone would, 44 years later, make it the perfect theme for “Mickey Spillane’s Mike Hammer.” He spent seven years at 20th Century-Fox working with music director Alfred Newman on such musicals as “Call Me Madam,” “Gentlemen Prefer Blondes” and “There’s No Business Like Show Business.”

But when Fox, under pressure from the growing popularity of television, downsized its music staff in 1952, Hagen was laid off. He and a fellow Fox arranger, Herbert Spencer, formed the Spencer-Hagen Orchestra and began working in the very medium that cost them their film-studio jobs.

In 1960, Hagen struggled with what to write for the folksy character at the heart of the new “Andy Griffith Show.” “It finally occurred to me that [the theme] should be something simple, something you could whistle,” the composer later wrote in his entertaining autobiography, “Memoirs of a Famous Composer Nobody Ever Heard Of.” Hagen whistled it, and with the help of his 11-year-old son snapping his fingers, a classic of musical Americana was born.

“I had never whistled anything before, and I’ve never whistled anything since,” Hagen often quipped. The music inspired producer Sheldon Leonard to shoot his main-title sequence of Griffith and young Ron Howard going fishing together.

Hagen had a knack of finding just the right sound for each series. For “The Dick Van Dyke Show,” it was an upbeat, swinging sound with a little nod to Van Dyke’s penchant for physical comedy (remember the trip over the ottoman?). Says Van Dyke, “It promised laughter but was seasoned with an air of sophistication that set the right mood for what we were offering. He was a wonderful guy and one of the last real jazzmen.”

In 1963, “Griffith”/”Van Dyke” producer Sheldon Leonard, having a vague idea about shooting an hour-long dramatic series on location around the world, invited Hagen and his wife on a trip to scout locations: Tokyo, Hong Kong, Bangkok, Calcutta, Tel Aviv, Athens, Rome, Paris — 52 days in all. While Leonard was looking for places to shoot, Hagen was scouring the countryside for every kind of exotic music that might lend authenticity when he came to write the scores.

The show was “I Spy,” and while it broke new ground for its location filming and for its equal, above-the-title billing for a white actor and a black one (Robert Culp and Bill Cosby as globetrotting secret agents), it was also remarkable for its colorful, exciting musical scores, inspired by the real-life sounds of the various cultures on display in the show. Hagen’s music was Emmy-nominated for each of “I Spy’s” three seasons; he won for a third-season episode set in Greece.

When it came to “That Girl,” star Marlo Thomas decided she didn’t want her show to sound like the average sitcom. “I wanted it to be more melodic,” she says. “We were kind of a romantic comedy, so I wanted the music to have that feel. I loved it when I first heard it; it sounded like a movie theme. It could have been for Audrey Hepburn, with a kind of spirit and hope, and very feminine. I was thrilled with what he came up with.”

His other themes included a dynamic opening for teen cops in “The Mod Squad,” a jaunty march for “Gomer Pyle USMC,” a mariachi sound for Jose Jimenez in “The Bill Dana Show,” lighthearted Americana for “Mayberry RFD” and a wistful accordion-and-guitar combo for “The Guns of Will Sonnett.”

In 1983, Hagen got a surprising phone call about that song from his big-band days: Would he agree to the use of “Harlem Nocturne” for a new series starring Stacy Keach as New York private eye Mike Hammer? And would he be interested in scoring it? Hagen said yes, and a new generation was introduced to “Harlem Nocturne.”

“It has a nostalgic, film noir quality about it,” notes Keach, who befriended Hagen and even played “Harlem Nocturne” at the piano when the composer was honored at a TV Academy event in 2007. “Like Mike Hammer himself, It has a very New York feel about it. People used to tell me they watched the show just to listen to the music.”

After scoring an estimated 3,000 television episodes, Hagen retired from television scoring in 1986. But he didn’t leave the business; he turned his attention to teaching.

Hagen wrote the first how-to textbook in the field, “Scoring for Films,” in 1971. “Avengers: Endgame” composer Alan Silvestri remembers buying it in a hurry when, knowing absolutely nothing about dramatic composing or synchronizing music to picture, he got his first film job. Hagen’s technical know-how, set down in print, got him through.

Since the early 1970s, Hagen had been holding private classes in his Calabasas home for young composers interested in learning more about film scoring. Recalls Emmy-winning composer Bruce Babcock (“Murder, She Wrote”), who orchestrated for Hagen in the 1980s: “I was fortunate enough to take Earle’s course at a time when the only way to study the synchronization of music to film, and the psychology involved, was to attend Earle’s living-room workshop — if you were willing to provide the two dozen Titleist golf balls he required as tuition. What an education I received, and what opportunities.”

Hagen’s course became formalized when the performing-rights organization BMI launched an annual film-scoring workshop in 1986 with Hagen at the helm.

He died in May 2008, at the age of 88. In a 1997 Archive of American Television interview, Hagen said he’d like to be remembered “as a man who was a capable professional, who did good work, never sloughed a job, and who created some things that were interesting and perhaps memorable.” Talk about understatement. Tens of millions can hum his themes. As Marlo Thomas says, “More people remember the theme songs than even the names of the people who were in the shows!”

Adds Stacy Keach, “He was warm and kind and gracious and funny. He could work in so many different styles, just extraordinary versatility and variety. And he was a genius in his ability to musically capture the essence of what was on the screen. He was a giant.”