Class: Diatone::Chord
- Inherits:
-
Object
- Object
- Diatone::Chord
- Defined in:
- lib/diatone.rb
Class Method Summary collapse
Class Method Details
.abbr(t) ⇒ Object
161 162 163 164 165 166 167 168 169 |
# 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) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# 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 |