The soundtrack to Felix van Groeningen’s film Belgica, a Sundance hit, is a hugely entertaining compilation of songs by unfamiliar artists, ranging from synth-pop to psychobilly, hardcore punk to Turkish acid house. What makes it particularly impressive is that none of the artists featured exist. They are all the imaginings of David and Stephen Dewaele, the Belgian brothers who lead the band Soulwax.

The Belgica soundtrack by Soulwax including fake band names including the Shitz. Photograph: PR

Van Groeningen, an old friend of the band, approached Soulwax in 2014 to help him choose songs for Belgica, a drama about two brothers who run a club in Ghent, Belgium. The problem was that the film takes place in an unspecified period somewhere between 1995 and 2005 and any existing song would pin the action to a particular year, so the Dewaeles proposed inventing their own artists. “The film is loosely based on an existing club,” David Dewaele says. “Whatever he was doing with the ambiguity between fiction and reality, we could do the same with the music.”

Soulwax, who are known for crafting epic, omnivorous DJ sets under the names Radio Soulwax and 2manydjs, ended up writing and recording 16 songs, about half of which appear in the final cut of Belgica, each with its own specific role in the narrative. “We had to make it work on multiple levels,” Dewaele says. “It had to be sort of timeless and not linked to a certain year. Secondly, it had to serve the function of the scene, to depress you or lift you up. And then, thirdly, it had to exist as something we would like.”

Convincingly portraying fictional musicians on screen is notoriously hard, especially when a drama uses original material rather than cover versions. Successful attempts such as Almost Famous or Hedwig and the Angry Inch are rare. If a song sounds weak or phony, musically clued-up viewers will cry foul and lose faith in the story’s credibility. Recently, critics of HBO’s music-industry drama Vinyl protested that the music of British proto-punk band the Nasty Bits, written by Mick Jagger and his actor son James, rings false in the context of 1973. “I had to stop watching it,” Dewaele says. “I thought it was dreadful.”

The Nasty Bits band from the HBO series Vinyl. Photograph: HBO

“I think that’s the reason most movies about musicians are terrible,” says Adam Schlesinger, whose diverse songwriting credits include Josie and the Pussycats, Sesame Street, Stephen Colbert’s Christmas special and, currently, the musical comedy-drama Crazy Ex-Girlfriend. “Generally, the music’s not good enough and you don’t buy it. Just like the acting has to be convincing, the songs have to be convincing. You have to believe that this music could be popular.”

Schlesinger, who is also a member of Fountains of Wayne and Ivy, has been writing songs for TV and film for over 20 years. He started out working on The Dana Carvey Show and achieved his Hollywood breakthrough when he successfully pitched the title song for Tom Hanks’ 1996 movie That Thing You Do! “They had a title, which helped, and they were very specific about the year,” Schlesinger says. “They wanted it to be 1964 and it should sound like an American band who was imitating the Beatles. I wrote three versions of it over a weekend and then I played it to a few of my friends, and everybody chose the same one. Tom Hanks had a very clear picture of what he wanted and the confidence to go with someone unknown.”

The Wonders from That Thing You Do!

The peppy, faux-Fab Four track That Thing You Do was so persuasive that it didn’t just earn Schlesinger an Oscar nomination, it became a minor hit in its own right – and it was covered live by *NSync – while the soundtrack album went gold. “The line between fictional and real has been blurred many times in music,” Schlesinger says. “It’s funny because I’m producing a Monkees album right now. They’re the ultimate case of a fictional band who became a real band, and the songs that were written for their TV show became huge hits. I try to write something that people want to listen to and that can hopefully stand on its own.”

Schlesinger’s output includes authentic-sounding imaginary hits, exaggerated parodies and songs that belong to the storytelling tradition of musical theatre, but sometimes the categories overlap. For the 2007 Hugh Grant comedy Music and Lyrics, he had to write a teen-pop smash (A Way Back Into Love), a tongue-in-cheek approximation of Wham! (Meaningless Kiss) and a plot-driven climactic ballad (Don’t Write Me Off), ratcheting the realism up or down accordingly. For the season finale of Crazy Ex-Girlfriend, on which he collaborates with creator and star Rachel Bloom, he needed to make a power ballad that was funny but also credible as a famous hit from 1984. “I wanted it to be just a little bit more ridiculous than an actual Whitney Houston song,” he says. “It’s that fine line: it sounds believable for a while and then it goes into an endless string of adjectives. I want to write something I actually want to listen to, even if it’s silly.”

White Virgins from Belgica.

Schlesinger says the key to success is getting clear, unambiguous instructions from the film-makers. “A lot of times when I miss, it’s because it wasn’t quite explained to me right. I start with understanding what the parameters are.” He then does his homework, immersing himself in music from the relevant genre and era until he’s au fait with the songwriting tropes. Similarly, Soulwax consulted friends in the Ghent music scene to make sure that their versions of different genres sounded right. “We’d say, ‘What if we were to make a song like this?’ and give them six examples,” Dewaele says. “One of Felix’s trademarks as a film-maker is making it painfully real, so it would never work if we’d gone for some pastiche.”

Once the songs are written, Schlesinger remains on hand to tweak them as the film evolves or to coach the actors in how to look convincing on stage. For Belgica, Soulwax helped to cast all of the musicians, including those with speaking roles, such as the frontman of their imaginary powerpop group the Shitz. “When it came to the live performances, almost all of them came up to us after shooting and said, ‘Can you please write more songs for us?’” Dewaele says. “If time and energy would allow, I guess we would.”

The Shitz’s How Long.

Dewaele says that the whole process, which included a long afternoon inventing in-jokey band names (Burning Phlegm, Noah’s Dark) and song titles (Got Any Chris Rea?, Cybernetic Permutations in the Key of A), was fun and surprisingly easy. For songwriters with parallel careers in their own bands, imagining fictional artists can be a liberating outlet for musical ideas that would sit badly with the day job. It sounds a little like the kind of experiment Brian Eno would initiate to get a band’s ideas flowing: now you’re psychobilly hellraisers; now you’re a punk-disco outfit from 80s New York.

“It was cathartic in that there’s a lot of stuff we were able to get out of our system which maybe wasn’t what we want Soulwax to be,” Dewaele says. “The way our career, or lack thereof, has worked is that we’re really bad at being a normal band. We simultaneously chose, and were forced, to have different ventures. Over the years we’ve done so many projects where we don’t tell people it’s us under a different name, so when this project came up it felt, as you English people say, right up our alley.”

Schlesinger also says that writing for the screen enables him to explore musical paths that he would not otherwise have taken. “It solves a big problem for me because when I was in my early 20s and trying to figure out how to be a songwriter, it would keep me up at night. What am I? What is my style? All those questions that young songwriters go through, trying to define yourself. Everybody has broad tastes and you have to make some choices so that what you’re doing has some focus. But then I had this revelation: it’s really just about having the focus for the particular project you’re working on. It doesn’t have to define you for all time.”

Soulwax realised they had achieved their goal of blurring reality and fiction when one Dutch interviewer misunderstood the nature of the Belgica soundtrack and asked them how they had discovered so many exciting new artists. “We didn’t let on,” Dewaele says with delight. “We just kept going. It was the ultimate compliment, really.”

• Belgica – Original Soundtrack by Soulwax is out now on Play It Again Sam