The Interpretation of Dreams by Sigmund Freud Chapter 3 Page 25

case, the external stimulus undergoes a new rendering, which leads him to connect it with a repressed desire seeking its realization, and robs him of its reality, and is treated as if it were a part of the psychical matter. Thus, some one dreamt that he had written a comedy which embodied a definite motif; it was being performed; the first act was over amid enthusiastic applause; there was great clapping.

At this moment the dreamer must have succeeded in prolonging his sleep despite the disturbance, for when he woke he no longer heard the noise; he concluded rightly that some one must have been beating a carpet or bed. The dreams which come with a loud noise just before waking have all attempted to cover the stimulus to waking by some other explanation, and thus to prolong the sleep for a little while.