Edinburgh power-pop rabble The Spook School are chronicling the rock 'n' roll carnage that beset the making of their second album. “We got a hotel room near our recording studio in Leeds, with four little single beds,” recalls vocalist and guitarist Nye Todd, misty-eyed. “It was really cute. We all watched Harry Potter. But Niall, our drummer, got over-excited. Every night at nine o'clock, he started jumping around the room. It was ridiculous.”

The ensuing Spook School album is ridiculously good, and considerably more raucous than such quaint origins might suggest. True to its title, Try To Be Hopeful, the record's hurtling indie-punk is optimistic, resilient and joyous: a hyper-melodic DIY blare of Buzzcocks, Rezillos, Violent Femmes and XTC. And it's important, too. On incendiary opening track, Burn Masculinity, they blast male privilege and the patriarchy, while brilliantly upending conventions of sexuality and gender (“And I'll never be as strong as my mother will be, it's just not on the male side / And I'll never be as sensitive as my brother, it's just not within me”).

As album salutations go, it's quite a statement of intent. “We recorded that song first, a month or two before the bulk of the album,” offers Nye's brother, guitarist and vocalist Adam. “And I think fairly on we were like, 'It would be nice to have Burn Masculinity first – that way, we can get it over and done with,'” he says with a laugh. The song recently sound-tracked a Rolling Stone magazine documentary on the band, which saw Nye discuss his transgender identity with US trans rocker Laura Jane Grace.

The album's politicised opening salvo is bookended by an optimistic, gentle sign-off, Try To Be Hopeful, which is also rooted in Nye's trans identity. “I started testosterone last year, and I thought everything was going to happen really quickly. I thought my voice would change right away, but it didn't, so I had a few months in between,” he recalls. “When you put everything into something, and you're like, 'When I do this thing, everything's going to change, it'll be so much better', and then it's not what you expect – it's about that kind of emotion. But I didn't want to write a depressed song about it. I wanted to write a hopeful song about it. A song with repeated refrains that you can join in with,” he adds with a laugh.

The testosterone started affecting Nye's voice just before the band went into the studio, as Adam recalls. “The album was recorded over a fairly long time scale, so you can hear Nye's voice changing over the course of the record – from the first song we recorded, Burn Masculinity, to the last one, Binary,” he says.

The record is direct, infectious, wry and righteous, from the glorious Vicious Machine – a wry falsetto art-punk ode to never knowing what's going on in someone else's head – to the life-affirming I Want To Kiss You, whose loved-up euphoria culminates in a somewhat controversial brass wig-out. “I really like Dexy's Midnight Runners, they're my favourite band to listen to while I wash the dishes, so I really wanted the end of that song to sound like Dexy's,” Nye recalls. “But Niall [McCamley], our drummer, didn't want brass. So there was a long negotiation of me being like, 'I really want brass at the end of this song!'”

Fanfare warfare notwithstanding, The Spook School are an easy-going, amiable band. The songwriting is split between McCamley, the Todds and bassist and vocalist Anna Cory, and their fired-up live shows are equal parts performance and party. They're interactive, too: the gender-overthrowing, Joy Division-evoking Binary has already become a clamorous gig favourite, replete with unlikely shout-a-long chorus (“I am bigger than a hexadecimal!”).

It's also at the heart of the album, Nye suggests. “We had Binary pretty early on,” he recalls. “I could never understand gender when trying to think about it as a choice between ‘men’ and ‘women’. When I discovered the idea of gender as something a lot messier and more nuanced than two categories, something that could be defined according to how people actually wanted to identify and place themselves, things made a lot more sense,” he explains. “I’m so proud and fortunate to know quite a few amazing people who openly identify as non-binary or genderqueer – they exist in the world on their own terms and consistently challenge something that so many people just take as read, that there are men and women and nothing else.”

Binary, as with the rest of the album, is forthright and driven, but never angry. The Spook School's brand of political punk is tolerant, compassionate and inclusive. “If we sing about things like gender, and identity, perhaps people who wouldn't usually feel that comfortable at gigs might feel like, 'Oh, this is my thing, I can go to this,'” offers Adam.

Plus, says Nye, pop can be a vital conduit for shifting perceptions. “It's a lot less effort for someone to listen to a song,” he says. “Compared to, say – well, for example – when I first joined the department I'm in at work, I was at a meeting early on, and someone was doing a presentation. They were talking about how they were changing this website, and they said, 'We've got this drop-down list that's currently male or female. But some people have suggested that we maybe have another option.' And I was just about to go – 'Yeah! That sounds like a really good idea!' – but then everybody started laughing. And I was just like, 'Oh God'”. He puts his head in his hands.

As ever though, Nye looks on the brighter side. “But then, you fast forward three, four months,” he continues. “And somebody else from that same department did a talk on non-binary genders, and being trans-inclusive. That can happen if you're working with people, and they know you and like you, and they get invested in the things that affect your life. But you can't get to know every single person in the world. So you might as well just put it in a song,” he smiles. “It's much easier.”

Nye and Adam have been writing songs together since high school, and their effervescent punk-pop has long explored the vagaries (and expectations) of sexuality and gender. “It's funny now, looking back on very early songs like Devil of Mine or History, which were written before I came out as trans, or really realised it myself,” Nye offers. “Because those lyrics are quite – you know...” He quotes History. (“I was a boy or so I was told / I was a girl or so I was told / Don't believe a word you're told...”)

History and Devil of Mine later featured on The Spook School's 2013 debut album, Dress Up. “A lot of the lyrics on the rest of that album were me figuring out my identity,” Nye continues. “Whereas this album's more like, 'Hey! I've got this identity! Don't you try and stop me!'” he laughs. His brother laughs along. The Spook School could teach us all about boldness, hope, and having fun.

The Spook School play Edinburgh Summerhall (with Joanna Gruesome) on September 23; at Glasgow Lighthouse Late (with Supermoon and FOUND) on October 9; and at Dundee's Book Yer Ane Fest, Nov 27-29.

Try To Be Hopeful is out on October 9 on Fortuna Pop.