Created
August 25, 2020 12:46
-
-
Save Dan-Q/2d3214731cf6f642bf57a8c67f84ae53 to your computer and use it in GitHub Desktop.
Runs in the background, makes an (inaudible?) sound every so often to keep your soundbar awake.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dependencies | |
require 'bundler/inline' | |
gemfile(true) do | |
source 'https://rubygems.org' | |
gem 'win32-sound', require: 'win32/sound' | |
end | |
include Win32 | |
FREQUENCY = 37 # Hz; 37-32767 - what pitch sound? | |
DURATION = 1 # Ms - how long to play for? | |
DELAY = 60 * 19 # s - how often to play? | |
def every sec, &pr | |
loop do | |
pr.call | |
t = Time.now.to_f | |
frac = t.modulo(sec.to_f) | |
sleep(sec - frac) | |
end | |
end | |
every DELAY do | |
Sound.beep(FREQUENCY, DURATION) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment