PHIL Cunningham has played accordion in almost as many interesting locations around the world as a television presenter as he has done as a working musician. The cameras have captured him duetting with an erhu (two stringed violin) player by a lake in Beijing’s Black Bamboo Park and dancing out a tune on the world's biggest accordion in the Italian accordion town of Castelfidardo.

How Cunningham came to be playing in the church of country music, the Ryman auditorium, home of the venerable Grand Old Opry, is a story that takes some 400 years and the three instalments of his latest series, Wayfaring Stranger, to unfold.

Wayfaring Stranger examines in considerable detail Scotland's contribution to, as Cunningham puts it, America's greatest gift to the world: music. It takes its name from an American anthem that began as a 17th century Scottish border ballad, The Dowie Dens of Yarrow. It was carried, first, to Northern Ireland and then gained new words to its melody as the successors of those who moved from one promised land moved on to another one down what’s known as the Wagon Road, the route that travels down the Appalachian Mountains from Pennsylvania to North Carolina.

As he accompanied the emerging star of roots music and star of another television series, Nashville, Rhiannon Giddens singing Wayfaring Stranger with her banjo for the first instalment, Cunningham couldn’t help thinking, there and then as players of the music world’s most joked about instruments, that they could form the most unpopular duo in the history of music. His amusement, he points out, however, shouldn’t detract from Giddens’ wonderful rendition of the song and there were plenty of other moments along the way that brought a lump to his throat.

“Every time I go into one of these series about music I discover how little I know,” he says. “I’d heard American people saying how they were Irish Scots or Scots Irish and I just assumed they meant that one parent or grandparent was Irish and the other Scottish, rather than them being descended from the Ulster Scots. Something else that never occurred to me was that hillbillies might be Billies – Protestants - from the hills. That never entered my mind when I was watching the Beverley Hillbillies on TV back in the 1960s.”

As the programme follows the migration of Scots to Ulster in the seventeenth century, we hear of the historical cultural links between Scotland and Ireland and how music was carried as a way of documenting events, as entertainment and as an expression of faith. People of all classes are involved. King James V’s contribution to folklore as the proto singer-songwriter in his guise as the Goodman of Ballangeich was complemented by the Stewarts’ commissioning of higher flown Latinate church music that became superseded by psalms and hymns sung in the people’s own language.

Two hundred years on, as a quarter of a million Ulster Scots left Londonderry for America, ballads, fiddle tunes and a way of singing faith songs with conviction would coalesce and ultimately feed into country music.

“I drove down the Wagon Road,” says Cunningham, “and it’s one thing to get in a car and head down a motorway, as it is now, but it would be another thing entirely to hack your way through forests and whatever else these people faced. It brought home to me that carrying a song or a tune in your head might be the only way of taking something from the old country with you and when these pioneers got together with Scandinavians and African-Americans, who introduced the banjo, the music would change and develop.”

Among the musical contributors featured are the great Ulster singer Len Graham and his younger countryman Jarlath Henderson, singing his updated take on Courting is A Pleasure. Scots Karine Polwart and Archie Fisher illustrate how a 17th century scandal, when the wife of an Ayrshire lord ran off with king of the gypsies, was first told as the Raggle Taggle Gypsy and emerged in its transatlantic form as a rockbilly hit, Black Jack David, and in the repertoires of the Carter Family, Woody Guthrie, who substituted “boss” for “lord”, and Bob Dylan.

Before we leave Ireland, Altan fiddler Mairéad Ní Mhaonaigh illustrates the Scottish influence on Irish dance music, both in terms of tune forms the Scots introduced and a fiddle style that’s phrased in the clipped style of their speech, and Cunningham discovers the story of the Kilmarnock-born street singer Jean Glover, who shared songs with Robert Burns, spending her final days in Donegal.

Once in America Cunningham traces all manner of Scots and Ulster Scots connections, from the perhaps not so surprising backgrounds of musicians including dobro master Jerry Douglas and bluegrass stalwarts Ricky Skaggs and Tim O’Brien to the fiddle from Ulster that featured on the first country music hit record and the walking treasure trove that is singer and folklorist Sheila Kay Adams.

“I could have spent any amount of time listening to Sheila,” says Cunningham. “Not only does she have this vast store of ballads, she explained how these songs were passed on, and it’s pretty simple really. You have these big families of children all living in cramped surroundings and needing to be kept entertained and occupied. How else would you do it other than telling them stories, except the stories happen to be songs? The songs all tell of things everyone can relate to, so they are remembered and passed on, and on.”

Just as singing together helped to forge communities, many of them named after the homes that had been left behind, where the church became the centre of life, the fiddles that were either brought from Ireland or acquired in the new settlements brought people from different backgrounds together.

The fiddle’s importance and prevalence are underlined by the establishment of a fiddling contest in Hanover County, Virginia on St Andrew’s Day, 1736, the first such recorded and with a violin from Cremona, no less, as the prize. This drew huge crowds. Within a short time these events were being held all over the Carolinas, Virginia and Kentucky as the precursors to the massive similar events that proliferate today.

As we move into the age of broadcasting and recording, Ulster Scots and their traditions are well to the fore. In 1922 Henry Gilliland, a fiddler of Irish descent, made what is considered to be the first recording of traditional music, Arkansas Traveler and Turkey in the Straw, and the following year, Fiddlin’ John Carson, a seven-times fiddle champion of Georgia, became a million selling artist with You Will Never Miss Your Mother Until She Is Gone, reputedly played on a fiddle brought by his family from Ireland one hundred and fifty years earlier.

Other notable musicians with Ulster Scots backgrounds who forged the music that became the American mainstream included the prolific Charlie Poole, Clayton McMichen of the Skillet Lickers, whose Ida Red was reborn as Chuck Berry’s Maybeline and Dock Boggs, a hero of Pete Seeger who combined his own Scots-Irish tradition with the blues he grew up hearing from black neighbours.

“It’s a fascinating story and one we possibly take for granted,” says Cunningham. “But I suspect the more we keep digging the more we’re likely to find.”

Wayfaring Stranger goes out on BBC Two Scotland from Tuesday, September 26 at 7pm.