# Tries to play a leg-of-lamb, side-of-beef rhythm; i.e.: # the ratio of the interval between "leg" and "lamb" to the interval between # "leg" and "of" = the interval between "leg" and "of" to the interval between # "of" and "lamb". require 'sound' include Math include Win32 a = 0.5 b = (a * ((1 + sqrt(5))/2)) - a puts "a==#{a}; b==#{b}" puts "(a+b)/a==#{(a+b)/a}" count = 1 20.times do print "."; Sound.beep(440, 100) count += 1; if count % 2 == 0 or count % 6 == 0 then sleep(a+b); next end sleep(a - 0.1) # Subtract the length of the "A" note from a print "."; Sound.beep(440, 100) # Play an "A" for 100 milliseconds sleep(b - 0.1) end print "."; Sound.beep(440, 100)