When Dinho talks about AfroReggae he gets an evangelical gleam in his eye. He says the band, in which he is now a vocalist, "arrived in my life like a light I didn't know I needed". Perhaps that sounds trite, but it is also perfectly true. Aged 17, Dinho was immersed in the gang culture of Vigário Geral, the shanty town, or favela, where he grew up in northern Rio de Janeiro. He and his friends regularly committed armed robberies, using the proceeds to buy guns, trainers and designer clothes. "I didn't think about what was right or wrong," he says. "I wanted money, but more than that, it was about the status."
One evening, by pure chance, some members of AfroReggae persuaded him to join a rehearsal instead of accompanying two friends who were planning to rob a local business. Later that night he found out that both friends had been shot dead during the assault. The experience shocked him into the life-changing decision to leave the gang and dedicate himself to music. "I feel that I was chosen," he says. "Why me? I don't know, but I know I have to give something back."
Ten years later, not only is Dinho performing with one of Brazil's biggest bands - AfroReggae have released two successful albums and supported the Rolling Stones when they played on Copacabana Beach in 2006 - but he is working for the AfroReggae "cultural movement", which aims to create alternatives to the gang lifestyle for a new generation of young people from Vigário Geral and other favelas in Rio. Over time, says Dinho, aspirations in his neighbourhood have changed noticeably. "Five years ago, the children in Vigário used to play at being drug traffickers with guns. Now you see them imitating the musicians from AfroReggae."
Since its foundation in 1993, AfroReggae has become a significant force for social change in some of the most violent communities in the world. The ferocious urban conflict in Rio de Janeiro was dramatised memorably in the Oscar-nominated film City of God, but the statistics still come as a shock: between 2002 and 2006, 729 minors died in the violence between Israel and Palestine; in the same period, 1,857 young people were reported murdered in Rio. Large areas of the city are entirely out of state control and are governed instead by a range of gangs, financed by the drugs trade, which administer justice as they see fit. With regular shoot-outs between the gangs and intermittent incursions by Rio's notoriously corrupt police force, there is little hope for calm in the near future. But, as so often in Latin America, this desperate situation has generated a creative response.
AfroReggae was founded in the aftermath of a police massacre in October 1993 that left 21 unarmed residents of Vigário Geral dead. A cha rismatic local music promoter called José Junior, together with a group of friends from the favela, decided to open a cultural centre offering classes in percussion and Brazilian dance. In 1995, they formed the Banda AfroReggae, which performs a double role as a professional musical outfit and the public face of the organi sation. Over the years, it has expanded to encompass more than 70 projects, including ten bands, two circus groups, documentary film-making, a radio station and a show at São Paulo Fashion Week. International demand has taken the group to India, Canada, Germany and China for performances and workshops. In the UK, the Barbican Centre has established a long-term partnership, some results of which will be showcased at the East festival from 6-11 March. The Banda AfroReggae itself will perform at the Barbican later in the year.
The group's base, however, remains Vigário Geral, where their work is needed as much as ever. As you walk through the favela today the atmosphere is still noticeably tense. The area has long been one of the most violent in the city, and in 2004 it was the site of fierce battles as one drugs faction, Comando Vermelho, which had been in control for many years, was ousted by another, Terceiro Comando. The streets are strangely quiet, and teenagers, large guns slung over their shoulders, lurk unsmilingly on street corners. My guide, AfroReggae's lead singer, Anderson Sá, mutters constantly into his mobile phone, updating a mysterious range of contacts on our exact whereabouts. "Put it this way," another associate tells me later that day - "when they bring you into the favela, everyone knows about it, from the local drug bosses to the chief of Rio State Police."
As we approach AfroReggae's cultural centre, the tension is dispelled by the sound of samba drumming. Inside the graffiti-covered building, teenagers mill around carrying instruments and costumes, chatting and laughing. A small audience of local children and their parents gathers to watch a performance by some of the AfroReggae subgroups. First up is AfroLata, an energetic bunch of teenage boys who play razor-sharp rhythms using oil canisters and tin cans. Next, a theatre company presents a piece on life in the favela, and a dance troupe performs a polished routine drawing on African, traditional Brazilian and contemporary styles.
As a samba group start to play, the audience get to their feet for a spontaneous dance session. Amid the euphoria, it is easy to forget that this is an area in which, until a few years ago, as Dinho says, "The only sounds were gunshots, and the only culture was that of violence."
Last to take the stage are Akoni, an all-female percussion group. "When it began, AfroReggae was very machista," their leader, Rosemary Santos, 27, tells me afterwards. "Women were expected just to sing and dance. But we wanted to do things women don't usually do, like play the drums." She committed herself to working at the centre after breaking up with her partner, who was one of the local drug dealers. "AfroReggae has made a huge difference to me, personally and professionally," she says. "I got my life back."
From its beginnings in Vigário Geral, Afro Reggae has slowly branched out into other parts of the city. The first offshoot project was in a neighbouring favela, Parada de Lucas. Here, there is now a newly built cultural centre housing several computer rooms, a hi-tech studio for the internet radio station, a library and classrooms. The atmosphere is quieter and more studious than in Vigário. Until Terceiro Comando's takeover of Vigário these two neighbourhoods were controlled by rival drug factions and were engaged in a bloody war that lasted more than 20 years.
Uniquely, AfroReggae managed to negotiate a relationship with both groups, establishing a neutral presence amid the hostilities. On one occasion this involved Junior and others physically standing in the middle of an armed face-off between the two gangs.
"People always ask how we manage to negotiate with all the different factions," says Anderson Sá as we walk through the pristine streets of Parada de Lucas. "The answer is, 'With great difficulty.'" However, he explains, even the drug dealers rarely want to see their children follow in their footsteps: "Everyone understands this is a good thing for the community."
A more recent side project is based inside the Escola João Luiz Alves, in one of Rio's youth detention centres, where AfroReggae is conducting weekly workshops. In the main hall of the grim, concrete building the centre's 150 inmates, all aged between 12 and 18, troop in to watch a performance by a group of AfroReggae percussionists. Although they are of similar ages and ethnicities (the population of Rio's favelas is overwhelmingly black and mixed-race), it is easy to tell the difference between them - and not only because of the prison uniforms. The AfroReggae boys have open, smiling faces, while those from the prison sit in grim silence.
When the AfroReggae instructor calls for volunteers, however, there is a stampede for the front of the room. He lines up the newcomers with their drums and starts them off on a simple rhythm. Suddenly it becomes clear why the group's technique works so well. Even the most troublesome, most hyperactive boys are completely absorbed by their drums. If they make a mistake, one of their peers will gently, unpatronisingly correct them. Within 20 minutes the whole group is playing together and moving to the music. "In the favela where I live we didn't have opportunities like this," one 15-year-old tells me afterwards. "It's good. It makes me think that things could be different when I get out."
A few days later, I meet José Junior at his apartment in a middle-class district of Rio. He is a thickset man with an intense stare and the slightly messianic manner that is a common trait of the AfroReggae leadership. His ambitions for the project are limitless. "For 15 years we have been aiming at people who have no hope," he says. "For the past four, we have expanded our remit. Now we work with the Brazilian elite, too - and also with the police. The work is very diverse: one week I'll be organising a fashion show in São Paulo, and the next negotiating a war in the favela." This shift of focus, he says, aims to challenge negative perceptions of favela culture among the higher social classes. "If you want to change things in the world, you need to have the world on your side."
Junior is an unusual combination of social activist and hard-nosed businessman. A large poster of Che Guevara adorns his office wall, yet he unashamedly takes every opportunity to praise AfroReggae's sponsors, which include such un-PC names as the state oil company Petrobras ("the biggest promoter of social and environmental projects in the country"), Banco Real ("they invest in sustainability in Brazil") and the mining company Vale do Rio Doce. His is a very 21st-century brand of idealism.
"We are living in a capitalist world, where socialism doesn't exist," says Junior. "We have to adapt to this reality without prostituting our ideology." The association with AfroReggae is, he argues, highly desirable for Brazilian business. "They don't choose us, we choose them." Nowadays, favela isn't such a dirty word.
Groups from the AfroReggae UK Partnership perform in the East festival at the Barbican, London EC2, on 9 March (www.barbican.org.uk). AfroReggae play at the Barbican in September