When Notorious B.I.G.’s funeral procession rolled through his native Bed-Stuy in 1997, mourners began blasting his track “Hypnotize,” and it subsequently turned the rapper’s wake into a party. Just weeks later, it gave Biggie (a k a Christopher Wallace) his first Billboard No. 1, and was instantly established as his signature song.

But that famous part of hip-hop history almost didn’t happen. The single’s famous groove was lifted from the 1979 disco-funk hit “Rise” by pop and jazz artist Herb Alpert — who begins an 11-night residency at Café Carlyle on Tuesday.

“Rise” was co-written by Herb’s nephew Randy Alpert, and Andy Armer. It was up to Randy to convince Uncle Herb (who released his latest album “Music Vol. 1” in July at age 82) that allowing it to be sampled was a good move.

“I was already a Biggie fan, and I knew he was poised to breakthrough,” Randy tells The Post. “I called up Herb, and he said, ‘Why don’t they just re-play it? Why don’t they play their own music?’ I explained that’s what hip-hop is — it’s like a patchwork that takes something from everywhere. That’s the magic of what hip-hop artists do! He’s not really a hip-hop guy; he’s more into middle-of-the-road stuff.”

Prior to the approach by Bad Boy Records for the use of “Rise,” Randy had entertained offers from numerous hip-hop artists such as Warren G and Ice Cube, but turned them down because he didn’t like their songs. “Hypnotize” was different. “I must have played it for 40 minutes straight when I first heard it,” says Randy.

Because of the deal done with Bad Boy, Randy continues to own the majority of copyright ownership of both “Rise” and “Hypnotize.”

“If Biggie’s family really want to use it on something, I won’t stand in their way. But to me, Biggie is the Bob Dylan of hip-hop, so I want to make sure that song is respected.”

As Randy notes, the legacy of “Hypnotize” is so big, it sometimes feeds back into his uncle’s performances. “To this day, when Herb plays ‘Rise,’ he still gets people shouting ‘play Hypnotize!’ ”