Image copyright PA Image caption David Gilmour and wife Polly Samson accompanied son Charlie to court in 2011

Pink Floyd guitarist David Gilmour has revealed that his new single features former inmates from the prison where his son served time.

Gilmour recorded Rattle That Lock with The Liberty Choir, a rehabilitation project that includes former Wandsworth Prison inmates and local singers.

The rock legend said the choir gives prisoners "real hope and optimism".

His son Charlie did time in Wandsworth in south London in 2011 after being arrested at a tuition fees protest.

He spent four months in jail after being convicted of violent disorder for his part in the 2010 protest, where he swung from a flag on the Cenotaph and threw a bin at a royal convoy.

Image copyright AFP Image caption Charlie Gilmour (second right) ended up serving four months of his 16-month sentence

David Gilmour told BBC News: "Charlie's experience was something that has impacted on us and has made us more aware of the prison system and what could and should be done to improve it.

"We're just helping out by being part of this initiative, which will hopefully spread."

The Liberty Choir, run by vocal coach MJ Paranzino and writer Ginny Dougary, takes members of the South London Choir into Wandsworth Prison for weekly sessions with serving inmates.

They also run regular sessions outside jail, where former offenders can join members of the South London Choir.

Seven of these former inmates were part of the 30-strong choir that sang on Rattle That Lock.

Gilmour and wife Polly Samson have also donated money to allow The Liberty Choir to expand to other jails.

Image caption David Gilmour joined the choir during a visit to Wandsworth Prison on Tuesday

Why did you get involved with The Liberty Choir?

David Gilmour: It's wonderful, seeing all these guys singing in the prison along with people from the South London Choir. They are close to the end of their sentences, and they then have a place outside prison where they feel part of the community, and that's very good for them, to feel valued.

Did Charlie's experiences make you want to get involved?

Yes, we got to see how the system worked and there's a lot wrong with the system, but there are many other initiatives that people are taking into their own hands within prisons and for prisoners.

This one, with the dual thing of doing it inside prison and on the outside as well, is a different step that we think is very good.

You went into Wandsworth on Tuesday - what did you do?

We joined a regular session where 20-something prisoners and about 20 people from the choir outside get to sing along and are taught. MJ is a brilliant teacher.

They come week in, week out, and there's a waiting list inside prison because the room available is small. The maximum number they can get in is about 20, but there are many, many more who want to take part.

What have the current or former prisoners said about the choir?

I've had conversations with some of the guys in the prison and some who have recently been released, and they all think it's a fantastic programme and are very keen for it to be widened and spread to other prisons.

It gives them real hope and optimism that they don't just come out of prison into a vacuum and the same temptations. This gives them at least one night a week with something to do where they feel valued, and they can join in with something artistic that is uplifting.

Is the song Rattle That Lock about prison?

No, it's just something to encourage people to step out and stand up for themselves and not be apathetic.

Will you continue your relationship with the choir?

Yes, Polly and I are both founder supporters. We give money to them. We have a charitable foundation that supports all sorts of things. This is one of them, and we are very keen that this should continue and expand.

We both intend to go back into Wandsworth and maybe other places if they open their doors to this sort of thing in the future.

David Gilmour's single Rattle That Lock is out now and his solo album of the same name is out on 18 September.