On the evening of January 26, 1936, Joseph Stalin and several other Soviet leaders went to the Bolshoi Theatre, in Moscow, to see a performance of Dmitri Shostakovich’s opera “Lady Macbeth of the Mtsensk District.” Shostakovich, only twenty-nine years old, was a rising star among Soviet composers, and his show was a hit; when Stalin came to see it, it was enjoying its eighty-fourth performance at the Bolshoi, after a successful première in Leningrad in 1934, and appearances in several European and American cities. A portrait of the desperate life of the Russian lower-middle class, the opera was sardonic, nervy, and violent, veering constantly between satire and vaudeville and naturalism.

The plot, based on a short story by the nineteenth-century Russian writer Nikolai Leskov, tells of a bored and frustrated housewife, Katerina Ismailova, who begins an affair with a clerk, Sergey, when her merchant husband leaves on a business trip. When her overbearing father-in-law discovers her transgression, she murders him; when her husband returns, she murders him, too. Controversially, Shostakovich portrayed Katerina’s murders and sexual liberation as justifiable responses to the awful environment of Tsarist Russia. The music is often more scandalous than the moral it points to: at one point, the orchestra whips itself into a mechanistic, pounding fury to accompany the lovemaking of Katerina and Sergey, before declining over a long trombone glissando, mimicking a post-coital comedown.

Though the opera had pleased audiences, it did not please Stalin. Somewhere during the third act, he and his comrades conspicuously departed the theatre. Two days later, Stalin’s displeasure was made manifest in an unsigned editorial in Pravda, titled “Muddle Instead of Music”—possibly the most chilling document of philistinism in music history. The author of the review begins by lambasting Shostakovich’s opera for its obscenity, both musical and dramatic (“The music croaks and hoots and snorts and pants in order to represent love scenes as naturally as possible”), and suggests that its success abroad came from the fact that “it titillates the depraved tastes of bourgeois audiences with its witching, clamorous, neurasthenic music.”

After detailing Shostakovich’s musical sins, the article proceeds to make political threats. “Left deviationism in opera grows out of the same source as left deviationism in painting, in poetry, in pedagogy, in science,” the critic writes, finally denouncing Shostakovich for “trifling with difficult matters.” If he continued to play this “dangerous game,” the critic concludes—in what can only be imagined as an icy whisper—“it might end very badly.” It was the beginning of a season of terror for Shostakovich, as well as for other artists and composers. His works were no longer performed, and he lived under the threat of arrest, and possibly murder, for nearly a year. Only after a wildly successful performance of his Fifth Symphony, in 1937, did he undergo a partial rehabilitation, eventually resuming his path toward becoming the U.S.S.R.’s favorite musician. Still, he never fully escaped the shadow of persecution, and suffered criticisms and official bans in the following decades.

Julian Barnes’s new novel, “The Noise of Time,” is about Shostakovich, and it begins with the composer enduring the humiliation and misery of his exclusion from musical life, in 1936. “All that he knew was that this was the worst time,” the first part opens. Barnes has Shostakovich repeat it twice more, at the beginnings of the novel’s two other sections, in response to fresh sources of persecution in 1948 and 1960, bringing to mind Edgar from “King Lear”: “The worst is not / So long as we can say, ‘This is the worst.’ ” The novel’s title comes from the nineteenth-century poet Alexander Blok, who used the phrase to describe history. The Soviet poet Osip Mandelstam chose it for the title of his memoir, published in 1923—Mandelstam, who would indeed suffer Stalin’s worst. For Barnes’s Shostakovich, “the noise of time” is counterposed to “that music which is inside ourselves—the music of our being—which is transformed by some into real music.” Real artists, Barnes has Shostakovich say, protect that private part of themselves against history, but if the music “is strong and true and pure enough to drown out the noise of time” it is “transformed into the whisper of history.” So we watch as Shostakovich struggles to live a life devoted to music, with history constantly intervening.

What Shostakovich’s music had to do with history has been one of the most fraught questions in the history of music. He lived through the most terrifying decades of the Soviet Union to become its most celebrated composer. Despite his transgression with “Lady Macbeth,” many of his compositions—such as the Seventh Symphony (“Leningrad”), performed in 1942 in the midst of the devastating siege and broadcast over loudspeakers into no man’s land—served the purposes of official propaganda (though the music itself was more multilayered than its use would suggest). The result of Shostakovich’s confrontation with the apparatus of Stalinism, and of his subsequent reassumption, was that his music has become impossible to interpret outside of historical circumstances. Debates over the actual meaning of his pieces have taken on the quality of titanic political arguments; they have even been dubbed the Shostakovich Wars.

In 1979, a book purporting to be Shostakovich’s memoir, entitled “Testimony,” appeared in the West, depicting a frustrated composer who despised Communism and hid veiled critiques of the Soviet regime in his music. Scholars such as Laurel Fay, Shostakovich’s biographer, eventually discredited the book as a forgery, but not before it had given license to somewhat crude allegorical readings of the music, showing how this or that musical cue clearly represented a parody or critique of some aspect of life under Stalin. The late Ian McDonald, in his book “The New Shostakovich,” became an exemplar of the form, writing about a passage in the Fifth Symphony in which, over a “thrumming rhythm, flute and horn now converse in a major-key transposition of the second subject: two dazed delegates agreeing that the rally had been splendid and the leader marvelous”; elsewhere, writing about the first movement of the Fourth Symphony, he claims that an ascending scale depicts the secret police “audibly climbing the stairs . . . and bursting through the door on a triumphant crescendo.” Shostakovich is known to have derided the Soviet form of this criticism. Speaking before the Union of Soviet Composers in 1933, he complained, “When a critic . . . writes that in such-and-such a symphony Soviet civil servants are represented by the oboe and the clarinet, and Red Army men by the brass section, you want to scream!”

Barnes, who acknowledges “Testimony” as one of his major sources, gives us a mournfully sarcastic, frustrated Shostakovich, at once mocking of his Soviet patrons and stymied by his inability to break with them fully. In a sort of third-person monologue of impressions, vignettes, and diaristic reflections, he comes off as neither heroic nor craven, though he exhibits both traits on occasion. A trip with the Soviet delegation to the United States is a “public success,” attended by huge audiences, during which he feels “nothing but self-disgust and self-contempt” for having to give canned speeches and warmly praise Stalin. He is given to dry aphorisms (“He lit another cigarette. Between art and love, between oppressors and oppressed, there were always cigarettes”), and he reflects with gallows humor on how Hitler’s invasion led to a period of unprecedented security for him (“A disaster to the rescue”). In one anecdote, his plane is diverted by bad weather from Frankfurt, forcing him to go to Stockholm. Swedish musicians enjoy the sudden visit, but then embarrass Shostakovich by asking him to name his favorite Swedish composer. “He was about to cite Svendsen when he remembered that Svendsen was Norwegian.” His humiliations and sense of injury are at once more tense and miserable than any we can imagine, but also, as Barnes handles them, similar to a kind of high-toned grumbling that one associates with artists forced to do things that they feel are beneath them.