Every time I hear about this I just get amazed by how ridiculous it sounds. And if it was a thing of like the middle Ages I can get behind that (it's still stupid tho).
But I've heard and seen pictures of people playing and Instrument in the front row even during 19th century. I think I've even heard that during WW1 armies still had musical instruments with them, playing Bagpipies and drums while marching.
Not only it would bring attention of anyone nearby (and that cannot be a good idea during war). But also It seems like a waste of space and ressources to have instruments considering all the weapons and gear they had to carry.
So how accurate is the idea that soldiers, even at beggining of 20th century, wenth chanting and playing instruments in their way to whatever their going, and that right before battle they would "declare it" with some sort of music.
How much of that is true and, why would they do it?
The link between music and military campaigns and institutions is very old and enduring. Stone reliefs suggest that the Romans marched into battle with cornus (a type of trumpet with no valves), and in the present the U.S. military still supports a number of musical ensembles.
Music has served a number of functional and symbolic purposes in militaries. Sound facilitated the movement of armies by providing a steady and consistent rhythm that helped soldiers walk as a unit. From a tactical standpoint musicians used a repertoire of signals, usually short and easily identifiable gestures that conveyed specific information to soldiers and commanders quicker than word of mouth and perhaps more reliably than visual cues, especially in the heat of battle. In these roles music's purpose was to discipline the actions of soldiers, but it was also used in a psychological sense. An army accompanied by a regiment of bagpipes could be heard long before it was seen. The goal here was to instill fear and perhaps encourage an early surrender or even a few defections. In pre-colonial Bali warlords would likewise march into battle with contingent of gamelan beleganjur (an ensemble primarily comprised of gong-like instruments), which emboldened soldiers to bravery and terrified their enemies. Turkish Janissary Bands, which used cymbals and loud double-reeds among other instruments, played during the Ottoman campaigns into Europe. Janissary Bands left such a profound influence on the cultural imagination of Vienna that Mozart, working at the end of the eighteenth century, wrote a number of works that tried to approximate their sound (although in a way that often exoticized Turkish culture).
In stratified societies such as the ones that emerged in Europe and Bali professional musicians were typically employed by the wealthiest individuals, and in turn certain types of music became a marker of one's class status. Military musicians represented a significant investment since they required musical training in addition to the combat training that all soldiers went through. To some extent the size and skill of military bands served as a symbol for the state/king/warlord's wealth and authority (even today the U.S. Marine band is described as the "President's own").
In Europe the French Revolutions initiated a fundamental reevaluation of the military band. The French National Guard Band performed in public concerts, democratizing the music that had once been the purview of the King. During the nineteenth century military bands expand and the instrumentation became more standardized. At the same time bands began playing more stylized music (often transcriptions of orchestral works) in publicly accessible venues. In the United States military bands were woven into the fabric of mass culture. By 1889 over 10,000 bands are operating in the U.S. and even today you'd be hard pressed to find a k-12 instrumental music program that doesn't offer an ensemble modeled after a military band.
By the First World War the functional purposes of military bands had essentially become obsolete. Bands were still employed by militaries, but their purpose shifted to boosting troop morale and performing in public as representatives of the military. Some aspects military culture still maintain a residue of the older roles musicians played. Bugle calls still provide signals for various actions in military camps. The tune "Taps" is played at many military funerals because it conveys the affective experiences of loss, community, and order that are central to military experiences. At the same time sonic phenomena remain a central component to how war is experienced both by soldiers and civilians. The sounds and silences of war contain tactical information, can facilitate affective intimacy, and pose very real dangers to physical well-being. Scholars have documented music's use as a weapon during the Iraq war and also as an instrument of torture in Guantanamo Bay (which may be a strange thought if you have lived in a culture that views music as an essentially positive force).
Sources:
Michael Bakan, "Walking Warriors: Battles of Culture and Ideology in the Balinese Gamelan Beleganjur World." Ethnomusicology 42/3 (Autumn 1998).
Suzanne Cusick, "Music As Torture/Music As Weapon," Transcultural Music Review (2006).
Martin Daughtry. Listening to War: Sound, Music, Trauma, and Survival in Wartime Iraq. New York: Oxford University Press, 2015.
Ronald Kingsley and Michael Edson, "The Military Musician in Eighteenth-Century America: A View from Fort Ticonderoga."