Skip to content

Instantly share code, notes, and snippets.

@vikhyat
Created April 22, 2009 05:32
Show Gist options
  • Save vikhyat/99607 to your computer and use it in GitHub Desktop.
Save vikhyat/99607 to your computer and use it in GitHub Desktop.
Very simple metronome
#!/usr/bin/env ruby
def every(delay)
loop do
sleep(delay)
yield
end
end
def beep
Thread.new { print "\a" }
end
# Get the BPM
if ARGV[0] == nil
puts "Enter the BPM"
bpm = gets.to_f
else
bpm = ARGV[0].to_f
end
delay_seconds = 60 / bpm
every delay_seconds do
beep
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment