It’s a very famous organ/calliope melody, and part of it can be heard at the beginning of “Being for the Benefit of Mr. Kite” by the Beatles.
I just listened to the Mr. Kite track on my CD of Sgt. Pepper, and I didn’t hear any famous, non-Beatles music on it.
However, my WAG is you’ve heard “Entrance of the Gladiators.” That’s the most famous circus/calliope music there is. You’ll find a pretty good midi file of it on this page under “Other Composers.”
That would be the one! Thanks. And I was wrong about Mr Kite. It was Carnival of Sorts by REM that I was thinking of. I was just too lazy to go check for myself to make sure.