One of the Django Reinhardt songs I have is “Mystery Pacific.” The sounds at the very beginning emulate a train. This isn’t an isolated occurrence in swing music either. Erhard Bauschke’s “Nachtexpress nach Warschau” and the Ramblers’ “Hilversum Express” do the same thing. Even the “The Train Kept A-Rollin’,” which I have by Johnny Burnette and by the Yardbirds. There are probably others that I can’t think of. In any case, trying to emulate the sounds of a train is pretty common.
Thinking about this, I realized that Brian Wilson does the same sort of thing in “Cabinessence” from the SMiLE album. But he does it differently. While most of the swing songs imitate the train whistle, provide a sense of the train’s momentum in getting started (by increasing the tempo), or try to impart some sense of the intensity once the train has started moving (by maintaining a fast tempo), the way Brian Wilson does it is to musically illustrate the train. The moving melody describes either the pistons or maybe rolling hills that the train is going over. Regardless of how you perceive it, Brian Wilson uses the moving melody, not the intense tempo, to give you the effect of a train (although there is a rather intense tempo, too).
One of the videos that the Beach Boys released around the time that the SMiLE sessions were released shows this better than I can describe it.