• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Execute script (GPIO Relay) based on if sound is being played

Scheduled Pinned Locked Moved Solved Troubleshooting
2 Posts 1 Posters 743 Views 1 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    yep_DD
    last edited by Oct 14, 2018, 12:47 PM

    Hi guys, I want to monitor if audio is being played, e.g:

    cat /proc/asound/card*/pcm*/sub*/status
    

    And if any status contains running I want to execute a script (in my case turn on the amplifier). I want a simple solution and initially I thought it might be possible with udev or python or bash. Does any of you have a great and easy idea?

    Thanks

    1 Reply Last reply Reply Quote 0
    • Y Offline
      yep_DD
      last edited by Oct 14, 2018, 1:37 PM

      while sleep 1; do
        if grep -q 'RUNNING' '/proc/asound/card0/pcm0p/sub0/status';
        then
          echo "Running!"
        else
          echo "Not Running!"
        fi
      done
      

      this seems to work but the amplifier produces a too loud cracking sound when switching on, I have two spare relais und my MagicMirror, I will hook up the speakers to those and try again.

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      1 / 1
      • First post
        1/2
        Last post
      Enjoying MagicMirror? Please consider a donation!
      MagicMirror created by Michael Teeuw.
      Forum managed by Sam, technical setup by Karsten.
      This forum is using NodeBB as its core | Contributors
      Contact | Privacy Policy