Skip to content

Instantly share code, notes, and snippets.

@Dan-Q
Created August 25, 2020 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dan-Q/2d3214731cf6f642bf57a8c67f84ae53 to your computer and use it in GitHub Desktop.
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.
# 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