How to detect if microphone is in use macOS

Hello all,

I would like to know how I could detect if microphone is being used in MacOS system.

Is there an API or something similar? Code snippet as example or explanation about APIs to use would be great.

Thanks in advance and regards