Created
April 22, 2009 05:32
-
-
Save vikhyat/99607 to your computer and use it in GitHub Desktop.
Very simple metronome
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
#!/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