Class: HeadMusic::Instruments::StringingCourse
- Inherits:
-
Object
- Object
- HeadMusic::Instruments::StringingCourse
- Defined in:
- lib/head_music/instruments/stringing_course.rb
Overview
A single course (string or set of strings) on a stringed instrument.
A "course" is a set of strings that are played together. On most guitars, each course has a single string. On a 12-string guitar or mandolin, courses have multiple strings tuned in unison or octaves.
Examples:
- 6-string guitar: 6 courses, each with 1 string
- 12-string guitar: 6 courses, each with 2 strings (octave or unison)
- Mandolin: 4 courses, each with 2 strings in unison
Instance Attribute Summary collapse
-
#course_semitones ⇒ Object
readonly
Returns the value of attribute course_semitones.
-
#standard_pitch ⇒ Object
readonly
Returns the value of attribute standard_pitch.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #additional_pitches ⇒ Object private
-
#doubled? ⇒ Boolean
Whether this course has multiple strings.
-
#initialize(standard_pitch:, course_semitones: []) ⇒ StringingCourse
constructor
A new instance of StringingCourse.
-
#pitches ⇒ Array<HeadMusic::Rudiment::Pitch>
Returns all pitches in this course (primary + additional strings).
-
#string_count ⇒ Integer
Returns the number of physical strings in this course.
- #to_s ⇒ Object
Constructor Details
#initialize(standard_pitch:, course_semitones: []) ⇒ StringingCourse
Returns a new instance of StringingCourse.
18 19 20 21 |
# File 'lib/head_music/instruments/stringing_course.rb', line 18 def initialize(standard_pitch:, course_semitones: []) @standard_pitch = HeadMusic::Rudiment::Pitch.get(standard_pitch) @course_semitones = Array(course_semitones) end |
Instance Attribute Details
#course_semitones ⇒ Object (readonly)
Returns the value of attribute course_semitones.
14 15 16 |
# File 'lib/head_music/instruments/stringing_course.rb', line 14 def course_semitones @course_semitones end |
#standard_pitch ⇒ Object (readonly)
Returns the value of attribute standard_pitch.
14 15 16 |
# File 'lib/head_music/instruments/stringing_course.rb', line 14 def standard_pitch @standard_pitch end |
Instance Method Details
#==(other) ⇒ Object
41 42 43 44 45 |
# File 'lib/head_music/instruments/stringing_course.rb', line 41 def ==(other) return false unless other.is_a?(self.class) standard_pitch == other.standard_pitch && course_semitones == other.course_semitones end |
#additional_pitches ⇒ Object (private)
53 54 55 56 57 |
# File 'lib/head_music/instruments/stringing_course.rb', line 53 def additional_pitches course_semitones.map do |semitones| HeadMusic::Rudiment::Pitch.from_number(standard_pitch.to_i + semitones) end end |
#doubled? ⇒ Boolean
Whether this course has multiple strings
37 38 39 |
# File 'lib/head_music/instruments/stringing_course.rb', line 37 def doubled? course_semitones.any? end |
#pitches ⇒ Array<HeadMusic::Rudiment::Pitch>
Returns all pitches in this course (primary + additional strings)
25 26 27 |
# File 'lib/head_music/instruments/stringing_course.rb', line 25 def pitches [standard_pitch] + additional_pitches end |
#string_count ⇒ Integer
Returns the number of physical strings in this course
31 32 33 |
# File 'lib/head_music/instruments/stringing_course.rb', line 31 def string_count 1 + course_semitones.length end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/head_music/instruments/stringing_course.rb', line 47 def to_s standard_pitch.to_s end |