James MacMillan's grandfather, George Loy, was a coal miner at the Barony Colliery near Auchinleck in Ayrshire.

My grandfather, Hugh Devine, was the area gasworks manager. My dad grew up in the gasworks manager's house just off Main Street, Auchinleck; one of his brothers moved to Cumnock, the town in which MacMillan was growing up around the same time my childish self would be visiting cousins of his age. So in July, when I heard the composer talking about his new piece based on the old Barony mine A Frame structure on Radio 4's Playing The Skyline series, the hair on my neck stood up and I almost stopped in my tracks.

Here was our most prominent living composer daring to talk up the very two much-maligned former mining towns in which I spent much of my childhood. Yet rather than speak of the all too obvious dilapidation and deprivation, he was describing picturesque villages, rolling hills, viaducts, church spires and the "great sweeping vistas" of the East Ayrshire to which I, like him, remain sentimentally attached.

At the same time, his brassy, reedy, energetic music, underscored by a relentless metronomic beat, was vividly depicting the Barony and its noisy machinery, while conjuring the colliery band his grandfather played euphonium in as an escape from the pit.

In a musical masterstroke, he had nailed the special feminine/masculine character of the part of Scotland dearest to his heart. "My grandfather and his friends found beauty in music and in the walks through these hills and fields," MacMillan was saying. "When you're down in the dark bowels of the earth, you want to reach out from the dark place." Engcouraged by his grandfather, young MacMillan played cornet and trumpet.

In the programme he mentioned, in his characteristic throwaway style, the significant news that a specially written version of this striking new piece would be played by the string orchestra of Greenmill Primary School in his home town during the inaugural Cumnock Tryst music festival in October. It will be performed over a musical weekend featuring the likes of Nicola Benedetti, The Sixteen choral group, and theorbo soloist Elizabeth Kenny.

Driving to Ayrshire to meet him, I am somewhat overawed by the dawning realisation the composer has clearly been working on the idea of turning the international music world's focus on to his beleaguered birthplace for rather longer than it takes me to remember the back road to Cumnock from dad's childhood home. The Tryst is a wonderful idea and evokes in me an embarrassingly emotional response; over coffee at the Dumfries Arms Hotel, a festival venue, MacMillan is mercifully quick to admit it was inspired by the achievements of his lifelong mentor and friend Peter Maxwell Davies with the St Magnus Festival in Orkney, and his musical hero Benjamin Britten with the Aldeburgh Festival.

"These most notable composers set up festivals in places that were dear to them," he says . "It was not a question of imposing high culture on the community; music was in the fabric of those places, as it is in Cumnock and the surrounding area."

Auchinleck had a thriving amateur operatic society that performed Lehar's The Merry Widow and G&S operettas, and the local tenor Willy Strachan was renowned (and its continuing Boswell Book Festival is unique in focusing on biographical works). As a boy in the 1960s and 1970s, MacMillan remembers hearing the Berlin Octet at Cumnock Academy, thanks to a local lawyer called RD Hunter who was "the most incredible impresario".

"My grandfather and his colleagues in the mines could aspire to classical music," he says. "In some places it has been appropriated by the wealthy and perceived as elitist, but that has not been my experience, otherwise people like me would never have had access to it. It has always been at the back of my mind to do this (festival). I always thought, even when I was a youngster, 'Will I do this one day?'. In some ways the Cumnock Tryst has been inspired by RD Hunter. I hope he will look down and see his legacy being revived."

MacMillan's nurturing role has been confirmed in his new appointment as the first Honorary Professor Of Composition at the Royal Conservatoire of Scotland. He is determined to encourage local young people from Cumnock and the wider Doon Valley into composing, as well as playing, music: children from P4 and P5 helped write the new version of Playing The Skyline; S4-S6 students at Cumnock and Auchinleck Academies will perform their music with the SCO; and young New Cumnock composer Jay Capperauld of the Royal Conservatoire of Scotland will premiere his Sehnsucht, specially commissioned by MacMillan for the festival. "I feel like an informal composer-in-residence for the area," he says. "It's a great thrill to be involved."

He is helping organise a composition course for Higher and Advanced Higher music students in local secondary schools. The music that comes out of that course will find "pride of place" in next year's Cumnock Tryst.

"East Ayrshire schools' music provision keeps winning prizes for high standards, so something has remained constant since I was here. I see that when I come down here," he says. "I have had a lifetime of travelling the world and been lucky enough to have met the most wonderful musicians. I feel I am at the stage now where I can give something back. One of the most fulfilling things an artist can do is inspire young people."

He says when he was a boy being musical was not seen as very masculine and he wants to help boys who are interested to develop their talent without shame or embarrassment. But he can't help lobbing another bombshell when he adds, again with that quiet understatement of his: "The Scottish artistic temperament is sullen, anxious, insular, aggressive. Some writers from working-class backgrounds over-compensate by being overly aggressive in their writing. But I want to encourage young boys to develop musical talent." He will not name names.

It emerges he has plans to write a children's opera to be performed by local school children. "It's on the agenda and the subject will be a local one," is all he will say. He refers to Britten's Noye's Fludde and Max's Cinderella.

MacMillan believes music has a transformational effect, and says that when people hear The Sixteen "they will think they're in Heaven". However, although celebrated for his religious liturgical music, informed by his devout Catholicism, MacMillan says The Cumnock Tryst is not a religious music festival. He is careful to define it as "spiritual in a very broad and general sense".

After he announced the launch of the Cumnock Tryst on his blog back in 2013, someone posted an apparently inflammatory comment. It pointed out the Auchinleck International Gathering, a celebration of opera, ballet and ecumenical dialogue, had already been scheduled for the very same week, and the writer suggested it be moved forward to 2015 "or to a more suitable location, such as Wick". A respondent challenged this by asking if it were driven by "sectarianism".

Sectarianism is, of course, one of MacMillan's great hobbyhorses, and in 2011 he caused a furore when he publicly declared Scotland was "still disfigured by anti-Catholic bigotry". When asked about religious divide in East Ayrshire, however, he says: "It's not my debate any more. I'm delighted if others have run with it, though anonymous blog comments just show there are a lot of nutters out there.

"Music and the arts can be a healing force, and if there are wounds to be healed I certainly want to be involved in that. On a lighter note, perhaps one of the issues is whether 'Cumnock' is a problem with the title of the festival because there is so much friendly rivalry between the local villages. But I want the beautiful local churches of Ochiltree and Stair to be our venues in the future.

"There has been much talk about the regeneration of Cumnock and the surrounding areas in recent years, and that's a task for the politicians and economists and so on; but there is such a thing as spiritual regeneration, and that can go hand in hand with a more concerted regeneration.

"People who love music describe it as spiritual; it's a word that keeps coming back. I particularly wanted to use it in relation to this festival. Music gets into the crevices of the soul in a way that's quite mysterious and brings about transformation in people's perceptions, relationships, emotions and even philosophy.

"If the Cumnock Tryst can get those embers burning, who knows what can happen?"

The Cumnock Tryst runs from Thursday, October 2 until Sunday, October 4. See the website: thecumnocktryst.com.