Skip to content

Instantly share code, notes, and snippets.

@douo
Created January 24, 2013 07:25
Show Gist options
  • Save douo/4618316 to your computer and use it in GitHub Desktop.
Save douo/4618316 to your computer and use it in GitHub Desktop.
打印出大调式
class Tona
def initialize
@_u = ["B", "C", "C'", "D", "Ds", "E", "F", "Fs", "G", "Gs", "A", "As"]
@_d = ["B", "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb"]
@_a = [0, 2, 2, 1, 2, 2, 2, 1]
end
["B", "C", "Cs", "D", "Ds", "E", "F", "Fs", "G", "Gs", "A", "As"].each do |t|
class_eval <<-RUBY
def #{t}
c = @_u.index("#{t}")
r = []
@_a.each do |i|
c+=i
r << @_u[c%@_u.count]
end
r
end
RUBY
end
["B", "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb"].each do |t|
class_eval <<-RUBY
def _#{t}
c = @_d.index("#{t}")
r = []
@_a.each do |i|
c+=i
r << @_d[c%@_u.count]
end
r
end
RUBY
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment