Diegetic music or source music is music in a drama (e.g., film, opera, musical or video game) that is part of the fictional setting and so is knowingly performed and heard by the characters.  The term refers to diegesis, a style of storytelling. In 1987 Claudia Gorbman was influential in establishing the terms "diegetic/non-diegetic" (derived from narrative theory) for use in academic film music and soundtrack studies, and from there its usage spread to other disciplines.

Film
The opposite of source music is incidental music or underscoring, which is music heard by the viewer (or player), intended to comment on or highlight the action, but is not to be understood as part of the "reality" of the fictional setting.

Source music was sometimes used as scores from the earliest days of Hollywood talkies, in some cases—e.g., The Public Enemy (1931)—using it to the exclusion of any underscoring; or in Touch of Evil (1958), where there is proportionately more source compared to underscore.

In Britain from 1940 onwards there was a trend for including specially composed piano concertos (dubbed 'Denham Concertos' by Steve Race after the film studios) into films as part of the plot. An early example was Jack Beaver's 'Portrait of Isla' from the score for the 1940 Edgar Wallace film The Case of the Frightened Lady. Here the piano is actually played by lead actor Marius Goring (an accomplished pianist) as Lord Lebanon. A year later Richard Addinsell's much more famous Warsaw Concerto appeared in the film Dangerous Moonlight, in which a piano virtuoso plays a concerts and recalls composing the concerto while the Germans bomb London.

Songs are commonly used in various film sequences to serve different purposes. They can be used to link scenes in the story where a character progresses through various stages toward a final goal. If it is synchronized with the action, as in the "Good Morning" dance sequence from Singin' in the Rain, it is said to be Mickey Mousing.

Source and background music 
If the characters in the film can (or could) hear the music the audience hears, then that music is called diegetic. It is also called source music by professionals in the industry. It is said to be within the narrative sphere of the film. For instance, if a character in the film is playing a piano, or turns on a CD player, the resulting sound is diegetic. The cantina band sequence in the original Star Wars is an example of diegetic music in film, with the band playing instruments and swaying to the beat, as patrons are heard reacting to the second piece the band plays. In road movies where the characters are traveling by car, we often hear the music that the characters are depicted as listening to on the car stereo.

By contrast, the background music that cannot be heard by the characters in the movie is termed non-diegetic or extradiegetic. An example of this is in Rocky, where Bill Conti's "Gonna Fly Now" plays non-diegetically as Rocky makes his way through his training regimen finishing on the top steps of the Philadelphia Museum of Art with his hands raised in the air.

Variations 
A combination of these concepts in film sound and music is known in the industry as source scoring—a blending of diegetic source music, such as a character singing or playing an instrument, with non-diegetic dramatic scoring.

There are other varying dimensions of diegesis in film sound, for example, metadiegetic sound, which are sounds imagined by a character within the film, such as memories, hallucinatory sounds, and distorted perspectives.

Another notable condition of diegesis is cross-over diegesis, which is explored in the book Primeval Cinema - An Audiovisual Philosophy by Danny Hahn, in which he describes it as "blending/transforming a sound or piece of music from one spectrum of diegesis to another – from diegetic to non-diegetic space". The sci-film 2BR02B: To Be or Naught to Be is an example of cross-over diegetic music in film, with Schubert's Ave Maria playing over separate shot sequences as non-diegetic music, but then later showing it to come from a gramophone in a hospital waiting room. The music also becomes diegetic with the assistance of audio engineering techniques, having its reverberation undergo change to match the room's characteristics and indicate a spatial location from the surround speakers. Even though Ave Maria reappears extensively as diegetic music, its inclusion was treated as non-diegetic by the film-makers, the song being a bespoke recording by soprano Imogen Coward to match the film's tone, and the film being edited to her recording. The recording itself was timed to include a layer of narrative commentary for audiences familiar with the German lyrics.

This distinction may also be made explicit for comic effect, a form of breaking the fourth wall. For example, the first appearance of Kermit the Frog in The Muppets is accompanied by what initially appears to be a stock "heavenly choir" sound effect, which is then revealed to be coming from an actual church choir singing on a passing bus.

Opera 
Examples of diegetic music in opera go right back to its beginnings - for instance the central wedding serenade in Monteverdi's L'Orfeo. Stories about musicians are common in opera, and almost all operas include some level of internal performance. Wagner used the singing contest as a plot mechanism in Tannhäuser and Die Meistersinger, and Bizet's Carmen makes full use of the street music and street activity of Seville.  Ariadne auf Naxos by Richard Strauss is an example of opera within an opera. Benjamin Britten's Peter Grimes contains a wide variety of diegetic music.

Musical theatre 
In musical theatre, as in film, the term "diegesis" refers to the context of a musical number in a work's theatrical narrative. In typical operas or operettas, musical numbers are non-diegetic; characters are not singing in a manner that they would do in a naturalistic setting; in a sense, they are not "aware" that they are in a musical. In contrast, when a song occurs literally in the plot, the number is considered diegetic. Diegetic numbers are often present in backstage musicals such as Cabaret and Follies.

For example, in The Sound of Music, the song "Edelweiss" is diegetic, since the character (Captain von Trapp) is performing the piece in front of other fictional characters at a gathering. In "Do-Re-Mi" the character Maria is using the song to teach the children how to sing, so this song is also diegetic. In contrast, the song "How Do You Solve A Problem Like Maria?" is non-diegetic, since the musical material is external to the narrative, it being a conversation that would in a naturalistic setting take place as simple speech.

In both the 1936 and the 1951 film versions of Show Boat, as well as in the original stage version, the song "Bill" is diegetic. The character Julie LaVerne sings it during a rehearsal in a nightclub. A solo piano (played onscreen) accompanies her, and the film's offscreen orchestra (presumably not heard by the characters) sneaks in for the second verse of the song. Julie's other song in the film, "Can't Help Lovin' Dat Man", is also diegetic. In the 1936 film, it is supposed to be an old folk song known only to blacks; in the 1951 film, it is merely a song that Julie knows; however, she and the captain's daughter Magnolia are fully aware that Julie is singing. When Julie, Queenie, and the black chorus sing the second chorus of the song in the 1936 version, they are presumably unaware of any orchestral accompaniment, but in the 1951 film, when Magnolia sings and dances this same chorus, she does so to the accompaniment of two deckhands on the boat playing a banjo and a harmonica. Two other songs in the 1936 Show Boat are also diegetic: "Goodbye, My Lady Love" (sung by the comic dancers Ellie and Frank), and "After the Ball", sung by Magnolia. Both are interpolated into the film, and both are performed in the same nightclub in which Julie sings "Bill".

The musical The Phantom of the Opera offers an interesting example of ambiguity in distinguishing between diegetic and non-diegetic music. At the end of Act 1, Christine and Raoul sing "All I Ask of You", and the Phantom, having eavesdropped on them, reprises the song shortly after. Narratively, there is no reason for the characters to be singing, and so these numbers would appear to be non-diegetic. However, in Act 2, within the opera "Don Juan Triumphant", which the Phantom composed, not only are Christine and Raoul's words repeated, but they are sung to the same tune they used, suggesting that the eavesdropping Phantom heard them to be singing, rather than speaking, their conversation. To define "All I Ask of You" as either diegetic or non-diegetic is therefore not straightforward.

Television
In the television series Buffy the Vampire Slayer, the episode entitled "Once More, with Feeling" toys with the distinction between diegetic and non-diegetic musical numbers. In this episode, the Buffy characters find themselves compelled to burst into song in the style of a musical. The audience is led to assume that this is a "musical episode", in which the characters are unaware that they are singing. It becomes clear that the characters are all too aware of their musical interludes, and that determining the supernatural causes of the singing is the focus of the episode's story. On the same show, the episode entitled "The Body" was presented without any non-diegetic music at all, in order to convey the reality of the theme of death within the family that it portrays.

See also
Diegesis
Incidental music
Background music
Ambient music
Furniture music
Film score

References

Film sound production
Theatrical sound production