Queen Elizabeth II
Image: Commons Wikimedia

When a piece of music was premiered in front of a global audience at Queen Elizabeth II's funeral, there was one viewer who surprisingly had also never heard it before - its composer, Sir James MacMillan. 

His wife had broken her foot - and although Sir James had been invited to Westminster Abbey, in London, for the funeral, he had stayed at home, in Scotland, to help her.

Sir James had not even heard a rehearsal of the piece, which he had written in secret, and, until the night before the funeral, was not completely sure it would be performed.

So the first time he heard his choral piece was when it was sung in front of the Royal Family and world leaders crammed into the abbey.

"I watched it with my wife on the television," the 63-year-old told BBC News. "It was a pinch-me moment really." He remained "astonished" and very proud to have become part of such a historic moment.

It was also a glimpse into the extent of long-term planning for the funeral.

"I was approached by the abbey in deep secrecy in 2011," Sir James said.

"It was for the commendation part of the funeral service and I was asked to keep very quiet about it and not tell anybody.

"It was the text 'Who shall separate us from the love of Christ?', which I was told was one of the Queen's favourite passages from scripture and that strangely hadn't been set a lot to music."

A recording of the piece is being released on Friday.

Sir James said he had written it quickly, despite being well aware of the huge responsibility.

It had needed to be music for an intense personal and national event, a key spiritual moment in the funeral, not just "entertainment", he said.

And when it was finished, the music went to Westminster Abbey, where it stayed out of sight.

"They didn't want any indication of these plans coming out," Sir James said.

When news of the Queen's death broke, he realised his music, written more than a decade earlier, could now be used.

"I got the score out and looked at it again to remind myself of what the music would sound like," Sir James said. "It's always different when you play it on the piano - but that's what composing is, you've got to imagine sounds that are not in the room with you."

With the funeral preparations under way, Sir James was told his music was being rehearsed in London - but it was not confirmed it would be performed until 22:00 on the night before.

There was also a new piece from master of the Queen's music Judith Weir, who set to music the words of Psalm 42, "Like as the hart". The composer, now master of the King's music, declined to comment on her commission.

'Deep faith'

In the solemn grandeur of the state funeral, Sir James heard voices singing his piece for the very first time. The choristers performed his elegiac anthem on the most public stage imaginable.

Sir James said he still did not know how much the Queen had been involved in choosing the music for her funeral. He had met her on a number of occasions and in 2015 been knighted in her birthday honours.

King Charles III had always been supportive of his music, Sir James said. But he believes the Queen liked the chosen Bible text, because of its optimism.

"There's a sense of hope for the future," Sir James said, with the words assuming death was not the end and there was a heaven.

They begin: "Who shall separate us from the love of Christ? Neither death, nor life, nor angels, nor principalities, nor powers, nor things present, nor things to come."

"The words pointed to her deep faith, she was a persuasive and quiet advocate of the Christian perspective, communicating in a way that many clergy can't manage," Sir James said.

And he rejected suggestions the text "Who shall separate us... ?" contained a coded message about the Scottish independent debate, saying: "There's not a lot in St Paul's letter to the Romans that's about Scottish constitutional reform."

Greater reach

Sir James is the only living composer whose music was played at both the funeral and the thanksgiving service for the Queen at St Giles's Cathedral in Edinburgh.

His choral music is a blend of ancient and modern, spiritual and contemplative, often with a Scottish inflection - a mix that might well have appealed to the Queen, who he said seemed to combine "the deep past and the modern".

Sir James was already recognised as a leading modern composer but the spotlight of the Queen's funeral has brought him an even greater reach.

"I'm beginning to hear about performances of the piece all over the world," he said.

"It's one the most significant things that has ever happened to me."