# Plays notes separated by intervals that conform to the golden ratio, i.e.: # The first note is followed by an interval of 'a' seconds, then the second # note is followed by an interval of 'b' seconds, where (a+b)/a = a/b. # (The length of the note is subtracted from the interval.) # # Thread scheduling and other operating-system effects are an issue of course, # but a shuffle rhythm is easily detectable. require 'sound' include Math include Win32 a = 0.3 b = (a * ((1 + sqrt(5))/2)) - a puts "a==#{a}; b==#{b}" puts "(a+b)/a==#{(a+b)/a}" 20.times do #print ".\a" # Plays the computer's "beep" sound, should work on all platforms print "."; Sound.beep(440, 100) # Play an "A" for 100 milliseconds sleep(b - 0.1) # Subtract 100 milliseconds from "b" #print ".\a" print "."; Sound.beep(440, 100) sleep(a - 0.1) end