As far as written music is concerned, the trumpet and cornet are interchangeable. They play in the same key, and usually play identical parts. Often composers, such as Debussy, Rimsky-Korsakov, Vaughan-Williams, and Tchaikovsky, wish to assign separate trumpet and cornet parts in their music (usually three cornet parts and two trumpet parts) in order to display the different characteristics of each instrument. This does not mean that these parts must be played on these instruments, but they should be if they are available to obtain the texture of sound that the composer intended.
The trumpet was the first of the two instruments to evolve, coming from the natural trumpets of the Baroque and Renaissance times. The trumpet's bore diameter (the size of the tubing) remains constant throughout the entire instrument until it reaches the bell. The tubing is also kept as straight as possible in the construction. These two features are very important, because they produce a more open and "bright" sound. Since the 1950's, trumpets have been the dominant instrument in bands and orchestras in America.
The cornet, on the other hand, was developed in the 19th century and was made famous by the cornet virtuoso J.B. Arban of France. His style, phrasing, and technique helped to give the cornet a role as premiere melody instrument along side the flute and violin. For this reason, when both cornet and trumpet parts are called for in a piece of music, the cornet part usually contains most of the technique and flair while the trumpets keep rhythm and fanfares. The tubing on a cornet, as opposed to a trumpet, increases in diameter as the overall length increases (this is called "conical"). The tubing is also wound more compactly, and therefore is not as "free-blowing" as a trumpet. This means that when the player plays, he will feel a slight increase in resistance from the air having to take extra turns in the tubing. As a result of these two factors, the cornet has a more mellow sound than the trumpet. This sound is often called for in many military marches, such as those by Fillmore or Sousa.
The modern cornet is not nearly as mellow
as those produced in the 1800's. The primary reason for this
was the redesign of cornet mouthpieces by Vincent Bach, to
compete with the trumpet in the 1940's and 50's. Older cornet
mouthpeices are "V" shaped, instead of having a round cup.
This produced a very mellow sound, and many leading orchestral
principals still try to play on an old cornet and mouthpeice
to obtain the more mellow sound. The problem with old cornet
mouthpeices is that they are difficult to play at high
dynamic levels or in the upper register, so often it is
necessary to switch to a more modern trumpet-like mouthpiece
Old cornets also have a "Shepherd's Crook" in the base of the bell. This bend also
helps to give the cornet its wonderful round, dark sound, but has unfortunately been removed from many cornets today. Just now, some manufacturers are re-introducing the "crook" into their construction.
In order to hear what a good cornet sound is, try to seek out good British brass band recordings. Britian is one of the few places that have held on to the old cornet sound, and continues this great tradition of the cornet.