From earliest times, music has been central to the business of waging war.

It was used as a means of communication to pass orders, it regulated the working day and provided a diversion for soldiers. Equally importantly, in the aftermath of battle it pulled exhausted soldiers together and helped to produce a sense of normality and stability.

It was no different in the Scottish regiments. Indeed, as the process of Victorian tartanisation got into full swing, pipers became the epitome of the Scottish soldier, brave and unyielding, lions in the field but lambs in the house. Bagpipes could also be force multipliers: in 1897 while storming the Heights of Dargai in India's mettlesome North-West Frontier, 1st Gordon Highlanders went into the attack with the pipes playing encouragement.

Even when Piper George Findlater was wounded in both legs he continued playing and in time this incident became one of the celebrated images of the age. On his return to Britain, Findlater was feted as a hero and according to the regimental history "the Scotsmen in London would have let him swim in champagne" but that fame was bought at a cost. Findlater was tempted to take part in re-enactments of the battle and these performances led to considerable ill-feeling within the regiment.

Even in the First World War, which saw the introduction of modern industrialised warfare, pipers still had a role to play in the front line and casualties were inevitably high. At the Battle of Loos, which began on September 25 1915, and which saw the first use of the newly raised volunteer battalions, the pipers of the King's Own Scottish Borderers repeated Findlater's deeds of the previous century.

As the regiment's 6th and 7th battalions went into the attack against heavily defended German positions, they were played on by Pipe-Major Robert Mackenzie, a 60-year-old veteran who later died of his wounds. In the same action Piper Daniel Laidlaw also piped his men into battle, rallying them after a gas attack with the regimental march, All The Blue Bonnets, before leading them over the top with the regimental charge, The Standard On The Braes Of Mar. Laidlaw was awarded the regiment's first Victoria Cross of the war. In the same battle, pipers of the Seaforth Highlanders kept on playing even when the attack got bogged down under heavy German fire. A watching Seaforth officer saw tired and frightened men being revitalised when the pipes broke into the regimental march, Caber Feidh. He later wrote: "The effect was instantaneous - the sorely pressed men braced themselves together and charged forward. The Germans soon got to realise the value of the pipes and tried to pick off the pipers."

Although the practice of playing men over the top became less frequent as the war dragged on, it survived into the great killing battles of 1916. On the first day of the Battle of the Somme, men of the 17th Highland Light Infantry succeeded in taking their first-day objective on the Leipzig Redoubt but soon faced a ferocious counter-attack. They were volunteer soldiers representing Glasgow's Chamber of Commerce and were unsupported during the defence but their commanding officer knew what had to be done. "I told the Pipe Major to play; he at once responded, getting into a small hollow, and playing and greatly heartening the men as they lay there hanging on to the captured position," he wrote in his report. "Pipe Major Gilbert showed a total disregard of danger and played as if he were on a route march."

Later in the battle, when the same battalion captured and occupied the German trenches at Beaumont Hamel, Piper Major Gilbert caused amusement and pleasure when he started playing The Mucking O' Geordie's Byre, a reminder of quieter, happier times. There are also many recorded incidents of pipers playing familiar tunes to steady the men before going over the top. As a battalion of the Cameron Highlanders waited for the approach of zero hour, the pipe major sensed the men were getting nervous and responded accordingly.

"I looked down at the company and I could see they were shaken," he said after the battle. "I slung my rifle over my back and took up the pipes; that cheered them. I played through two or three tunes and then birled up Tullochgorum. They fairly hooched it and stamped time with their feet."

The tradition continues. Despite the arrival of modern high-tech warfare, no Scottish regiment has gone to Afghanistan in recent deployments without its pipes and drums.