I would like to write a program which is capable of storing a sound pattern, such as a train whistle, horn (beep beep)...listening for the sound via the microphone...and the
Sphinx is a speech recognition system. It may be able to be modified or even trained to work in the way you are expecting.