Is it possible to recognize sound from the microphone as the program is running?

For example, if there is sound coming from the microphone, then do this and that.

Thanks.