Bach cantatas
I think you're thinking of "Weinen, Klagen, Sorgen, Zagen". Franz Liszt wrote an extensive fantasie and fugue for organ on this.