How to know which program has just played sound?

Here is what I did to find a pesky application playing a system file. Go to System Preferences -> Sound -> Sound Effects. Toggle through the effects and make note of the sound that your mystery application is playing. When you find it go to the terminal and type:

sudo fs_usage | grep "aiff"

Enter in the system password if asked.

Wait for the sound to get played again and then look at the terminal output. Look for the name of the sound file you noted in the sound effects and look all the way to the right. On the right you should see the application that played the sound file. Now simply go to that application and tell it to disable playing the sound file if possible.


While it's not possible to check that directly, here are some workarounds:

  • If you're using Google Chrome (or similar web-browser), look for speaker icon next to tab or window (e.g. check in Window menu).
  • If you're using Safari, you should see also speaker icon next to the tab which is playing.
  • Some apps such as SoundFlower can provide extra kernel extension for pass-through audio, so then they can check which processes are accessing sound device.
  • Double check Notifications in System Preferences, and either set Do Not Disturb or disable Play sound for notifications for the recent or all apps. See this post.
  • Check for log entries, e.g. by the following command:

    log stream --level=debug
    
  • Check for any file activity by fs_usage command, e.g.

    sudo fs_usage
    
  • Using trial and error, pause and resume processes to find out about the process, e.g.

    ps d
    kill -STOP 1234 5678 # Stop processes via PID(s).
    kill -CONT 1234 5678 # Resume selected processes.