Class: Fet::Degrees
- Inherits:
-
Object
- Object
- Fet::Degrees
- Defined in:
- lib/fet/degrees.rb
Overview
This class handles determining the degrees for a given root
Instance Attribute Summary collapse
-
#octave_value ⇒ Object
readonly
Returns the value of attribute octave_value.
-
#root_name ⇒ Object
readonly
Returns the value of attribute root_name.
Instance Method Summary collapse
- #degree_index_of_midi_value(midi_value) ⇒ Object
- #degree_names_of_midi_value(midi_value) ⇒ Object
-
#initialize(root_name:, octave_value:) ⇒ Degrees
constructor
A new instance of Degrees.
- #note_name_of_degree(degree_name) ⇒ Object
- #root_midi_value ⇒ Object
- #select_degrees_from_midi_values(midi_value_range, number_of_degrees, degrees_filter) ⇒ Object
Constructor Details
#initialize(root_name:, octave_value:) ⇒ Degrees
Returns a new instance of Degrees.
12 13 14 15 16 |
# File 'lib/fet/degrees.rb', line 12 def initialize(root_name:, octave_value:) self.root_name = root_name self.octave_value = octave_value self.degree_to_note_name = generate_degree_to_note_name end |
Instance Attribute Details
#octave_value ⇒ Object
Returns the value of attribute octave_value.
9 10 11 |
# File 'lib/fet/degrees.rb', line 9 def octave_value @octave_value end |
#root_name ⇒ Object
Returns the value of attribute root_name.
9 10 11 |
# File 'lib/fet/degrees.rb', line 9 def root_name @root_name end |
Instance Method Details
#degree_index_of_midi_value(midi_value) ⇒ Object
26 27 28 |
# File 'lib/fet/degrees.rb', line 26 def degree_index_of_midi_value(midi_value) return MidiNote.new(midi_value).degree(root_midi_value) end |
#degree_names_of_midi_value(midi_value) ⇒ Object
22 23 24 |
# File 'lib/fet/degrees.rb', line 22 def degree_names_of_midi_value(midi_value) return Degree::DEGREE_NAMES[degree_index_of_midi_value(midi_value)] end |
#note_name_of_degree(degree_name) ⇒ Object
30 31 32 |
# File 'lib/fet/degrees.rb', line 30 def note_name_of_degree(degree_name) return degree_to_note_name[Degree.new(degree_name).degree_name] end |
#root_midi_value ⇒ Object
18 19 20 |
# File 'lib/fet/degrees.rb', line 18 def root_midi_value return MidiNote.from_note(root_name, octave_value).midi_value end |
#select_degrees_from_midi_values(midi_value_range, number_of_degrees, degrees_filter) ⇒ Object
34 35 36 |
# File 'lib/fet/degrees.rb', line 34 def select_degrees_from_midi_values(midi_value_range, number_of_degrees, degrees_filter) return select_degrees_from_midi_values_recursive(filtered_midi_values(midi_value_range, degrees_filter), [], number_of_degrees) end |