Taps was devised during the Civil War. In 1862, the Union Army of the Potomac, under Major General George McClellan, was transported to the Virginia Peninsula to launch a campaign against the Confederate capital at Richmond. The Army met stiff resistance at the outskirts of Richmond. After a series of battles, McClellan, a cautious general by nature, and misinformed as to the strength of the Confederate army confronting him, elected to "change bases" - a carefully worded synonym for retreat - to a site to the south, on the bank of the James River.
During this retreat, the Army of the Potomac was forced to stand and fight the pursuing Confederate army at Malvern Hill. The Confederate army, rather unwisely, charged the Union line and was defeated. The battle of Malvern Hill was fought on June 28 - July 1, 1862.
On July 2 (134 years ago today), in a miserable rain, the Army of the Potomac completed its depressing and embarrassing retreat to Harrison's Landing on the James River. The retreat was a grim disillusionment for the North, which had expected a short war. For the Army of the Potomac, it was its darkest and saddest hour.
Encamped at Harrison's Landing that summer was Brigadier General Daniel Butterfield. He was the commander of the 3rd brigade of the 1st division of the Army of the Potomac's 5th corps. A fairly undistinguished officer otherwise, General Butterfield had an ear for music. Previously, he had observed that his brigade's bugle call caused confusion in camp, because it could not be distinguished from that of other brigades. So he devised a unique bugle call for the 3rd brigade.
Now, in camp along the James, he noted that the regulation evening bugle call for lights out was neither musical nor inspirational, nor tranquilizing. He devised a alternative tune for his bugler, which, after a couple of attempts, became Taps. The tune became popular, and soon the entire Army of the Potomac was using the call in place of the regulation call for lights out.
Eventually, Taps was adopted by all Union armies, and became official army regulation. Taps remains regulation to this day. The story of Taps is particularly appropriate for July 2, given that today is the anniversary of the Army of the Potomac's long retreat to the Harrison's Landing camp.