Because Spielberg envisioned a grand musical dialogue between alien and human at the end, he needed a musical motif before filming began. Spielberg informally began collaborating with Williams in 1975, even before post-production on Jaws was finished. Spielberg gave Williams a script draft, and Williams began composing music for the film in late 1975. Spielberg often altered or created scenes to fit Williams' music, which is opposite to the way 99 percent of film music is scored.
Warner Bros. executives did NOT want to hire John Williams for Close Encounters, as they knew he was already working on Star Wars. Williams met with them and convinced them that he was far enough along on Star Wars to devote his full attention to Close Encounters. Very early on in the process, Spielberg and Williams decided that the film had two parts: An early, creepy, scary part about alien abduction, and a second, thrilling, adventure-like part in which the heroes evade the military and meet the aliens.
It was Williams who suggested licensing Leigh Harline and Ned Washington's 1940 "When You Wish Upon A Star" (from Pinocchio). Spielberg agreed. After the film became a hit, Spielberg would claim credit for this idea, asserting that it was his favorite childhood song and that he spent millions to get it in the movie.
Williams wanted a short musical riff to use as the "contact music" between alien and human. Williams wanted a seven- or eight-note riff. But Spielberg wanted a five-note riff, like in Jaws. (DAH-dum. dah-DUM-dum. Dum-dum dum-dum-dum-dum dum-dum...) Spielberg also argued that "hello" has just five letters, and that seven or more notes might sound like an unfinished melody rather than a riff. ("When You Wish Upon A Star" has just seven notes to establish the melody.) The two argued, but Spielberg won. Between 250 and 300 riffs were tried, but Spielberg liked none of them. In frustration, Spielberg just chose one -- and it is this riff which is now famous.
Again, Williams wrote the score in the Romantic style. Much of the first half of the score uses aleatoric passages -- in which music seems to occur by chance, stumbling over itself, with little in the way of themes or motifs. It also uses tone clusters. (For example, three white keys next to one another on the piano are a tone cluster.) For the second half of the film, melody and theme taking over.
The recurring "chase music" in the film is based on themes found in the work of Bernard Herrman, the mid-century composer known for his work with Alfred Hitchcock. Much of the second half of the film finds strong similarities with Elmer Bernstein's soundtrack for the 1956 film The Ten Commandments.
Short "riff motifs" are important throughout the score. The Devil's Tower theme is just two notes, constantly rising, underscored by soft strings and voices. The "vision theme" is a three-note motif (heard at 3:55 on the accompanying video) that occurs whenever people meet aliens or have visions about them. The "danger theme" is a four-note motif (heard at 4:16 on the accompanying video) that echoes the traditional medieval music for the Mass for the dead found in the "Dies Irae".
The score was recorded by the Warner Bros. Orchestra at the Warner Bros. scoring studio in Burbank, California.