Prince announced that his music had undergone a dramatic transformation with the robotic, pulsating opening beats of "Dirty Mind," the title track to his third album.

It was just one of many changes heralded by this 1980 masterpiece, along with shockingly risque sexual lyrics and a less polished, punk and new wave-influenced sound. The song also marked the first time Prince shared a co-writing credit with a member of his backing band, in this case keyboardist Dr. Fink.

Dr. Fink, who ranks as one of Prince's longest-serving collaborators, having worked alongside him from 1979 to 1991, revealed the amazing story of just how quickly "Dirty Mind" came together in an exclusive interview with Ultimate Prince.

"It germinated in the midst of a rehearsal jam session," he recalls. "We would always warm up before working on songs for a new record. Just off the top of my head during one of those jams, I started that chord progression. It wasn't something I had been working on, it was one of those spontaneous things, which happened a lot. You know... the creative juices got flowing and suddenly something pops out of you."

Clearly, Prince liked what he heard, and directed the band to continue experimenting with the groove for a while. "Then at the end of rehearsal that day he said, 'I want you to come to the house tonight' – he had a studio set up in his house at that time – 'I want to work on that jam you did, I recorded it on my boombox while we were working on it, so I have a copy, that way we can remember what you did."

Watch Prince Perform 'Dirty Mind' in Concert

Naturally, Fink jumped at the opportunity. "I'd always wanted to write something with him. I'd been in the band a couple of years at that point. So I went over there, and we laid down the song, the music side of it, the arrangement, which he kind of already had in his head when I got there. Then he said 'OK that's it, you can leave'.. and that was at about maybe 10 at night, something like that. He hadn't really done any vocals on it, or given it a title."

By now, tales of Prince's marathon late-night recording sessions have become so commonplace we're guessing you already know what happened next. But it's still a good story: "So the next morning at rehearsal – around 11AM – he came in with a finished demo version with full vocals and lyrics and guitars on it and everything all done. He says, 'Have a listen to this guys, I think this is gonna be the title track to the third album.'"

"To me that was just really the ultimate nod from him, to have that happen at that point," Fink explains. "None of us certainly expected to be collaborators, you know? You never know if he's going to go there or not. It was his record deal, he was a solo artist before he even hired the band, and was playing primarily everything on those first two records. I thought it was very generous of him to do that. And as time went on, he did that with all the members of the group to varying degrees - either having us play on stuff or as writers."

"Dirty Mind" was released as the second single from Dirty Mind, enjoying modest success on the R&B charts. But the album, which found him completely and seemingly effortlessly shedding the more commonplace sounds and romantic poses of his first two efforts, earned Prince the best critical reviews of his career to date, and opened the door to the crossover success of future albums such as 1999 and Purple Rain.

Prince Year by Year: 1977-2016 Photographs