Class: Juicy::Scale

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/juicy/scale.rb

Overview

0 1 2 3 4 5 6 7 8 9 10 11 12

 |- |- |- |- |- |- |- |- |- |- |- |- |
do di re ri mi fa fi so si la li ti do

chromatic |- |- |- |- |- |- |- |- |- |- |- |- |

do    re    mi fa    so    la    ti do

diatonic |- - |- - |- |- - |- - |- - |- |

do    re    mi       so    la       do

pentatonic |- - |- - |- - - |- - |- - - |

do    re    mi    fi    si    li    do

whole note |- - |- - |- - |- - |- - |- - |

do    re ri    fa fi    si la    ti do

octotonic |- - |- |- - |- |- - |- |- - |- |

Instance Method Summary collapse

Constructor Details

#initialize(type = :major, root = Note.new) ⇒ Scale

Returns a new instance of Scale.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/juicy/scale.rb', line 28

def initialize(type = :major, root = Note.new)
  case type
  when :major
  @type = :diatonic
  when :minor
  @type = :diatonic
  else
  @type = type
  end
  @mode = Mode.new(type)
  @root = root
  generate_notes

end

Instance Method Details

#[](element) ⇒ Object



47
48
49
# File 'lib/juicy/scale.rb', line 47

def[](element)
  
end

#each {|| ... } ⇒ Object

Yields:

  • ()


65
66
67
# File 'lib/juicy/scale.rb', line 65

def each
  yield SCALE_TYPES[@type]
end

#each_noteObject



69
70
71
72
73
# File 'lib/juicy/scale.rb', line 69

def each_note
  (SCALE_TYPES[@type].size+1).times do
    yield @notes.next
  end
end

#mode=(type) ⇒ Object



55
56
57
58
# File 'lib/juicy/scale.rb', line 55

def mode=(type)
  @mode = Mode.new(type)
  generate_notes
end

#playObject



51
52
53
# File 'lib/juicy/scale.rb', line 51

def play

end

#root=(root) ⇒ Object



60
61
62
63
# File 'lib/juicy/scale.rb', line 60

def root=(root)
  @root = root
  generate_notes
end

#to_sObject



43
44
45
# File 'lib/juicy/scale.rb', line 43

def to_s
  "scale type: #{@type}, mode: #{@mode}, root: #{@root}"
end