the frequency changes as the train passes and the high note is when the train is coming towards us and the low one when the train is going away, and you get the same effect with light except that instead of being high and low it's blue shifted if the object is coming towards us and red if it's going away.