Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: f7aa157984
Fetching contributors…

Cannot retrieve contributors at this time

file 49 lines (41 sloc) 1.012 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
module Niki
  module Chords

    (1..5).to_a.each do |octave|

      %w(c d e f g a b).each_with_index do |c, idx|
        rest = 0
        if idx > 2
          rest = 1
        end
        base = 24 + (12 * octave) + (idx * 2) - rest

        define_method("#{c}#{octave}") do
          base
        end

        define_method("#{c}#{octave}MAJ") do |*args|
          inversion = args.first || 1
          case inversion
          when 1
            [base, base + 4, base + 7]
          when 2
            [base + 4, base + 7, base + 12]
          when 3
            [base + 7, base + 12, base + 16]
          end
        end

        define_method("#{c}#{octave}MIN") do |*args|
          inversion = args.first || 1
          case inversion
          when 1
            [base, base + 3, base + 7]
          when 2
            [base + 3, base + 7, base + 12]
          when 3
            [base + 7, base + 12, base + 15]
          end
        end
      end

    end

    def silence
      0
    end

  end
end
Something went wrong with that request. Please try again.