The melon is a mass of adipose tissue found in the foreheads of all toothed whales.  It focuses and modulates the animal's vocalizations and acts as a sound lens.  It is thus a key organ involved in communication and echolocation.

Description
The melon is structurally part of the nasal apparatus and comprises most of the mass tissue between the blowhole and the tip of the snout. The function of the melon is not completely understood, but scientists believe it is a bioacoustic component, providing a means of focusing sounds used in echolocation and creating a similarity between characteristics of its tissue and the surrounding water so that acoustic energy can flow out of the head and into the environment with the least loss of energy. In the past, some scientists believed that the melon had functions in deep diving and buoyancy, but these ideas have been discounted over the last 40 years, so are no longer considered valid by cetologists.

The varying composition of the melon creates a sound velocity gradient that refracts sound directionally.  Sounds also bounce off the skull and air sacs that surround the melon.

Melon size is unrelated to maximum dive depth in toothed whales. The particular characteristics of the melon probably have more to do with odontocete phylogeny, the taxonomic relationships over evolutionary time.  In some species, melons are more specialized than in others. The sperm whale has the largest nose of any animal in the world.  The bulk of that nose is composed of two large, fatty structures, the spermaceti organ and the "junk".  The junk is structurally the same as the melon (homologous to it). The melon is not homologous to the spermaceti organ.

Composition
The melon is a mixture of triglycerides and wax esters.  The exact composition varies throughout the melon.  Typically, the inner core of the melon has a higher wax content than the outer parts and conducts sound more slowly.  This gradient refracts sound and focuses it like a lens.

The lipids in the melon cannot be digested by the animal, as they are metabolically toxic.  A starving dolphin has a robust melon even if the rest of its body is emaciated. The lipids in the melon tend to be of lower molecular weight and more saturated than the blubber.

The melons of the Delphinidae (dolphins) and Physeteroidea (sperm whales) have a significant amount of wax ester, whereas those of the Phocoenidae (porpoises) and Monodontidae (narwhals and beluga whales) contain little or no wax. The speed of sound in the melon is lowest in the Delphinidae, Phocoenidae, and Monodontidae, intermediate in the Ziphiidae (beaked whales), and highest in the Physeteridae and Platanistidae (South Asian river dolphins).

Pilot whales
The melon of pilot whales (Globicephala) is a mixture of wax esters and triglycerides.  The inner core of the melon is about 33% wax esters, while the outer layer is about 5% wax esters.  Most of the fats are saturated.

Pygmy sperm whale
In the pygmy sperm whale (Kogia breviceps), the melon consists of an outer layer and an inner core, which has a generally larger proportion of wax esters than the outer layer.

Behind the melon is a cornucopia-shaped organ that many scientists refer to as the "spermaceti organ".  This organ is different in form and composition from the spermaceti organ of the sperm whale.

Sperm whale
The analogous structure in the sperm whale is traditionally called "the junk" because whalers dismissed it as worthless for extracting sperm oil.  It contains compartments of spermaceti separated by walls of cartilage.

Beluga whale
The melon of the beluga whale is also unique in that the whale can change the melon's shape at will.  These changes in shape probably have the effect of changing the size, shape, direction, and frequency composition of the echolocation beam.

References

Cetacean anatomy
Whale sounds