WHERE IN the process of artistic creation does friendly poaching end and esthetic larceny begin? When one composer pays another the compliment of imitation, is this "flattery" or theft - or both? What's the difference between "influence" and plagiarism?

These are the questions that pianist-scholar-author Charles Rosen discussed in a lecture last Monday at Johns Hopkins University, often illustrating them at the keyboard as he went along.

He noted that the practice of "borrowing" musical ideas from pre-existing or contemporary sources didn't really begin in earnest until the 18th century. Not until then did composers attain the status of "old masters" for succeeding generations with occasional exceptions such as Josquin or Palestrinat. Before that, there was no such concept as a "classic." Music was composed for specific uses and occasions - church services, courtly or popular entertainments - and the demand for the new was unceasing. Composers achieved fame during their lifetimes, but rarely "immortality."

The growing taste for history and archeology, however, and the burgeoning skills and resources of historiographers, conferred a new importance on the arts of the past. Great composers - Haydn, for instance - became models to be emulated, and a search began for masterworks of earlier eras. Hence the 18th-century reverence for Handel, and the gradual rediscovery of J.S. Bach. In their turn Mozart, and especially Beethoven, were to become idols for the century that followed, hallowed almost as deities by the composers of the romantic period.

When music publishing on a mass scale began during the 18th century, in the absence of such protections as copyright, the crasser forms of musical plagiarism - outright pilferage and deceit - were rampant. Haydn was a favorite source. His reputations was so lofty that dozens of hacks took to publishing his quartets and symphonies under their own names, in hopes of boosting an obscure career swiftly and easily.

Rosen is almost superabundantly qualified as an arbiter of such matters. As much a virtuoso of the intellect as of the ivories, often called "the thinking man's pianist," as erudite as any living musician, he has played and recorded a repertoire ranging from Scarkatti and Bach to Webern, Stravinsky, Boulez and Elliott Carter.

His performances are not only technically impeccable, but models of analytic charity and insight. His book "The Classical Style: Haydn, Mozart, Beethoven," called by critic George Steiner "a masterpiece," won the National Book Award for Arts and Letters in 1971, and established him as a major musical savant of our times.

Rosen also discussed the less venal and obvious forms of expropriation. He pointed out that imitation was the time-honored mode of apprenticeship in the arts. Thus, Mozart started off by imitating Haydn, and Beethoven began by imitating the two of them. But far more intriguing to Rosen than mere adaptation of manners or procedures was what he termed "structural borrowing." He cited a rare case from Beethoven, whose String Quartet in A Major, Op. 18, No. 5, is modeled "bar by bar" on Mozart's celebrated late quartet, K. 464, in the same key. The correspondence is exact, but on the other hand, it would be perceived only by someone intimately acquainted with both works and adept at musical analysis, since it is not apparent on the surface.

Why would Beethoven have taken such pains to do something which would be recognized, if at all, by at best a small coterie of connoisseurs?

Because Rosen says, "here was Beethoven, over 30, deciding for the first time to publish a set of quartets - and in at least one of them, he had to prove, as much to himself as anyone, tha tbe was as good as Mozart, just as the young Brahms, in his first piano sonata in C major, rarely heard, felt he had to stand up to Beethoven's "Hammerklavier."

The most revealing imitations, Rosen avers, are those hardest to detect, in which "the composer is so impressed with someone else's work that he goes and does something else, something beyond the original." But in such cases, Rosen argues, the imitation in itself is a mere curiosity, it discloses nothing about the characteristic genius of the imitator.

Rosen's most persuasive example was taken from one of the Schubert posthumous sonatas he had played the night before - the A Major, D. 959, which, as Rosen demonstrated, has close structural links with Beethoven's Op. 31.

At the end of Schubert's first movement, Rosen explained, the composer did something quite extraordinary. The proud, yearning pronouncement of the opening chordal theme returns, but in a strangely subdued and distant manner, with a magical effect. "When it comes back." Rosen says, "it has a veiled quality, like an echo. This isn't past a return to the theme, as it might have been in Haydn. Mozart or even Beethoven, but a memory of the past. The passage has an air of nostalgia and regret that was quite new in music, and became basic to later 19th-century composers, especially Schumann. Schubert's sonata is modeled on Beethoven, but you'd never discover what's most truly Schubertian about it by examining just the imitative aspects."

Of course, if this kind of imitation is larcenous, then the entire history of music can be seen as an avalanche of plagiarism, because it is quite evident that the art has evolved by building upon - and reacting against, which is the same thing in another guise - its own past.

The dependence on precedent has taken many forms. In the middle ages and the Renaissance, a whole corpus of church melody - the Gregorian chant - and popular song as well was considered fair ground for all comers. Composers took these tunes and fashioned their own structures around them much as the painters of those eras used the imagery of the Madonna over and over. In certain periods, the 18th century among them, standard musical conventions arose which also were regarded as common property - scale passages, arpeggios, the so-called "Alberti bass" (it has a 20th-century analogue in the "boogie bass") and so forth.

At a time when, as in the days of Haydn and Mozart, all composers drew upon a common stock of melodic and harmonic configurations, a certain amount of coincidental similarities were to be expected. This may have been the case, for example, with the resemblance of the start of the young Mozart's "Bastien et Bastienne" Over-ture to the first theme of Beethoven's "Eroica" Symphony - both tunes are built simply upon the tones of the common triad and the resemblance may well have been sheer accident.

In other cases, unconscious replication may have been involved. A composer heard a melody somewhere, stored it automatically in his psyche, and years later it popped up unsummoned in a score of his own. The opening theme of Mozart's "The Magic Flute" Overture duplicates that of a piano sonata by Clementi which the latter swore he composed much earlier.

The deliberate, premeditated but covert "imitation" which Rosen calls structural borrowing is of another order entirely, and perhaps increasingly more usual in our own times. Joyce's "Ulysses" is a related literary phenomenon, not only following Homer's plan but recapitulating virtually all of Western literature in its stylistic peregrinations.

From this standpoint, the music of the 20th century looks like an orgy of quotation, reformulation and reminiscence.

Stravinsky was a prime example of a composer who raided the musical past continually, using the loot to striking advantage in forming his own style, and giving us a whole new perspective on Pergolesi, Bach, Tchaikovsky, Webern and others from whom he "borrowed." More recently, composers like Lukas Foss, Luciano Berio, George Rochberg and others have interpolated large chunks of familiar masterpieces into their otherwise contrastingly discordant textures, by way of parodying - or paying homage to - their forbears.

Surely the 20th century must be the most "plagiaristic" of times in this sense, because the past has become an integral part of our present. In her recent book on the subject, Susan Sontag notes that the advent of photography endowed past events with the illusion of permanence. And just as the entire history of the movies is available to the filmmaker at the flick of a television switch, so the whole of our musical past is now laid out in scores and recordings for the contemporary composer to "plunder" at will.

It follows that contemporary music is a kind of palimpsest of the ages, all the rest of Western musical tradition rolled into one and "reinterpreted" in the light of modern sensibilities. What future forms such trading on the past may take is hard to guess. We can only be sure that some way or other the wisdom of ancestors will continue to guide the hands of composers to come, for nothing under the sun can be entirely new.