Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "Set"
- class ModeScale
- attr_accessor :key, :mode
- attr_reader :mode_scale
- def initialize(key, mode)
- @key, @mode = key, mode
- showScale
- end
- def to_s
- "KEY:#{@key} in #{@mode} \n" +
- "Scale: #{@mode_scale.to_a}"
- end
- def showScale
- scale = ["C","#C/bD","D","#D/bE","E","F","#F/bG","G","#G/bA","A","#A/bB","B"]
- @mode_scale= Set.new
- mode_hash = {
- # 1 means a semitone and 2 means two semitone
- "Ionian" => [0,2,2,1,2,2,2,1],
- "Dorian" => [0,2,1,2,2,2,1,2],
- "Phrygian" => [0,1,2,2,2,1,2,2],
- "Lydian" => [0,2,2,2,1,2,2,1],
- "Mixolydian"=> [0,2,2,1,2,2,1,2],
- "Aeolian" => [0,2,1,2,2,1,2,2],
- "Locrian" => [0,1,2,2,1,2,2,2]
- }
- # ==============================
- pos = scale.index(key)
- for i in (0..7)
- pos += (mode_hash[mode]).at(i)
- pos %= 12
- @mode_scale << scale[pos]
- end
- # ==============================
- end
- end
Add Comment
Please, Sign In to add comment