class Diatone::Chord
Public Class Methods
abbr(t)
click to toggle source
# File lib/diatone.rb, line 161 def self.abbr (t) t.gsub!(' major','maj') t.gsub!('major','maj') t.gsub!(' minor','m') t.gsub!('minor','m') t.gsub!('min','m') t.gsub!('aug','+') return t end
get(s,relative=false)
click to toggle source
# File lib/diatone.rb, line 171 def self.get (s,relative=false) notes = [] s.sub!("#","♯") if s[1] == '♯' or s[1] == 'b' scale = Scale.get s[0..1] type = abbr(s[2..-1]) else scale = Scale.get s[0] type = abbr(s[1..-1]) end if CHORDS.include? type CHORDS[type].each do |n| if relative notes.push(n.floor + 1) else if n == n.to_i notes.push scale[n%scale.length] else r = ((n*10).to_i%10)-5 s = scale[n.to_i%scale.length] f = Note.fix(s) + r n = Note.key(f, false) notes.push(n) end end end else return [false,type] end return notes end
name(s)
click to toggle source
# File lib/diatone.rb, line 203 def self.name (s) if s[1] == '♯' or s[1] == 'b' note = Note.key s[0..1], false type = abbr(s[2..-1]) else note = Note.key s[0], false type = abbr(s[1..-1]) end return note+type end