Martial music
Types: 

March music: The notion of march music began to be borrowed from the Ottoman Empire in the 16th century. The Ottomans were believed to have introduced the first military bands in the thirteenth century, called mehter or Janissary bands. The music is characterized by an often shrill sound combining bass drums, horns (boru), bells, the triangle and cymbals (zil) and several other traditional instruments. The sound associated with the mehterân exercised an influence on European classical music, with such composers as Joseph Haydn, Wolfgang Amadeus Mozart, and Ludwig van Beethoven all writing compositions inspired by or designed to imitate the Ottoman music.

Marching songs: Marching songs, typically with patriotic and sometimes nostalgic lyrics, are often sung by soldiers as they march. The songs invariably feature a rhythm timed to the cadence of the march. There are many examples from the American Civil War, such as "Marching Song of the First Arkansas" and "John Brown's Body". "P'tit quinquin was popular during the Franco Prussian War of 1870. The Boer War generated numerous marching songs among which "Marching to Pretoria" is well known. "It's a Long Way to Tipperary" was a marching song of World War I that became a popular hit. One of the most enduring marching songs from that war is probably the "Colonel Bogey March", which was popular in World War II as "Hitler Has Only Got One Ball"; the tune found later fame as part of the soundtrack for Bridge on the River Kwai. The "Dadao March" was a patriotic song sung in China during the Second Sino-Japanese War. "White Army, Black Baron" was written as a combat hymn for the Red Army of Russia in 1920, while "Erika" was sung by the German army during World War II.

Bugle calls: The bugle call is a short tune announcing scheduled and certain non-scheduled events on a military installation, battlefield, or ship. These short music pieces are played from an instrument called the bugle, it has been used by militaries as means of communication. This instrument can be heard from afar and in very noisy environments (during battle). It is a very effective way of giving orders and communicating. Although no longer required by armies for communicating, these music pieces are still played for tradition and during ceremonies. Well-known bugle calls include "Taps", "The Last Post", and "Reveille", and also El Degüello.

Ruffles and flourishes: Ruffles and flourishes are fanfares for ceremonial music for distinguished people or groups. Ruffles are typically played on drums, and flourishes are played on bugles.

Recorded music: The Vietnam War produced a hit song in 1966, "Ballad of the Green Berets" which has a martial rhythm. Curtis Mayfield's 1963 hit "Amen" also features a marching rhythm, as does the US Top 40 hit, "Burning Bridges" by The Mike Curb Congregation (1971). In Vietnam and in particular in the Second Gulf War and in Afghanistan, recorded music (often featuring rap music) has been used by some soldiers as they travel, prepare for and engage in battle. Performers such as Eminem have written songs with specific reference to the current wars including "Bagpipes From Baghdad", and Mark Knopfler, whose Brothers in Arms (song) was written during the Falklands War (1982). Also see: "Soundtrack to War".

Instruments: Historically, trumpets, drums, cymbals, bagpipes, and other loud musical instruments were used for clear communication in the noise and confusion of a battlefield. They are easily carried while the instrumentalist is in motion, i.e., marching. Modern additions include the upright glockenspiel and several brass instruments including trombone and sousaphone, which are often used by military bands.

Drum: Chinese troops used tàigǔ drums to motivate troops, to help set a marching pace, and to call out orders or announcements. For example, during a war between Qi and Lu in 684 BC, the effect of drums on soldier's morale is employed to change the result of a major battle. In the late fourteenth century the first timpani arose in Ottoman military ensembles known as Janissary bands. During the fifteenth and sixteenth centuries janissary bands began to influence European court musicians with new percussion instruments such as the timpani originally known as Kös, cymbals, and rattle. Fife-and-drum corps of Swiss mercenary foot soldiers also used drums. They used an early version of the snare drum carried over the player's right shoulder, suspended by a strap (typically played with one hand using traditional grip). Similarly, during the English Civil War rope-tension drums would be carried by junior officers as a means to relay commands from senior officers over the noise of battle. These were also hung over the shoulder of the drummer and typically played with two drum sticks. Different regiments and companies would have distinctive and unique drum beats which only they would recognize.

Trumpet: The earliest trumpets were signaling instruments used for military or religious purposes and the modern bugle continues this signaling tradition.
Officers in command gave orders via sound from the trumpet because it had a piercing tone and high volume, which meant it could be heard in the midst of combat. Cavalry trumpets had a different timbre, so their calls would not be mistaken for other sounds meant for the infantry.

Bagpipe: An instrument with a piercing sound and graceful melody which is meant to be played outdoors, its main goal is to inspire men and women in the midst of conflict. It is also used in mourning the fallen and celebrating victory. Music was played in the build up to battle, but not during.
Textual evidence for the use of Scottish bagpipes in battle dates from in 1396, when records of the Battle of the North Inch of Perth reference "warpipes" being carried into battle, though it is believed that bagpipes were originally intended for peaceful music. The Irish were also inspired by bagpipes, as witness in this 1586 account: "This sort of instrument is held among the Irish to be a whetstone for martial courage: for just as other soldiers are stirred by the sound of trumpets, so they are hotly stimulated to battle by the noise of this affair. In World War I German soldiers referred to Scottish pipers as Die Damen aus der Hölle [Ladies from Hell]. 
Also see: Great Irish Warpipes.

Shawm: One of several woodwind instruments used in battle as early as the 12th century. This instrument rose in popularity during the Renaissance period and is believed to be a successor of an instrument called the zurna. It was mostly used as a military instrument. The overpowering noise coming from this instrument was used as a psychological weapon. The shawm found its way to Europe during the Crusades.

See also: Battle cry
Martial industrial
March music
Military band
War song
Royal Artillery Band
British Grenadiers March
Henry George Farmer
Kneller Hall

References: 

Further reading: Mark A. Snell and Bruce C. Kelley, editors, Bugle Resounding: Music and Musicians of the Civil War era, National Conference on Music of the Civil War Era, 2004.
Lee Andresen, Battle Notes: Music of the Vietnam War, Savage Press, 2003.
John H. Beck, Encyclopedia of Percussion, Routledge Press, 2007.