Module: MTK::Lang::Durations
- Extended by:
- PseudoConstants
- Defined in:
- lib/mtk/lang/durations.rb
Overview
Including this module defines a bunch of single-character variables, which may shadow existing variable names. Just be mindful of what is defined in this module when including it.
Defines duration constants using abbreviations for standard rhythm values (‘w’ for whole note, ‘h’ for half note, etc).
These can be thought of like constants, but in order to support the lower case names, it was necessary to define them as “pseudo constant” methods. Like constants, these methods are available either through the module (MTK::Lang::Durations::q) or via mixin (include MTK::Lang::Durations; q). They are listed under the “Instance Attribute Summary” of this page.
These values assume the quarter note is one beat, so you may find they work best with 4/4 and other */4 time signatures (although it’s certainly possible to use them with less common time signatures like 5/8).
Constant Summary collapse
- DURATIONS =
All “psuedo constants” defined in this module
[w, h, q, e, s, r, x].freeze
- DURATION_NAMES =
The names of all “psuedo constants” defined in this module
MTK::Core::Duration::NAMES
Instance Attribute Summary collapse
-
#e ⇒ MTK::Core::Duration
readonly
eighth note: 1/2 beat(s).
-
#h ⇒ MTK::Core::Duration
readonly
half note: 2 beat(s).
-
#q ⇒ MTK::Core::Duration
readonly
quarter note: 1 beat(s).
-
#r ⇒ MTK::Core::Duration
readonly
thirty-second note: 1/8 beat(s).
-
#s ⇒ MTK::Core::Duration
readonly
sixteenth note: 1/4 beat(s).
-
#w ⇒ MTK::Core::Duration
readonly
whole note: 4 beat(s).
-
#x ⇒ MTK::Core::Duration
readonly
sixty-fourth note: 1/16 beat(s).
Method Summary
Methods included from PseudoConstants
Instance Attribute Details
#e ⇒ MTK::Core::Duration (readonly)
eighth note: 1/2 beat(s)
44 |
# File 'lib/mtk/lang/durations.rb', line 44 define_duration 'e', MTK::Core::Duration[Rational(1,2)], 'eighth note', '1/2' |
#h ⇒ MTK::Core::Duration (readonly)
half note: 2 beat(s)
40 |
# File 'lib/mtk/lang/durations.rb', line 40 define_duration 'h', MTK::Core::Duration[2], 'half note', 2 |
#q ⇒ MTK::Core::Duration (readonly)
quarter note: 1 beat(s)
42 |
# File 'lib/mtk/lang/durations.rb', line 42 define_duration 'q', MTK::Core::Duration[1], 'quarter note', 1 |
#r ⇒ MTK::Core::Duration (readonly)
thirty-second note: 1/8 beat(s)
48 |
# File 'lib/mtk/lang/durations.rb', line 48 define_duration 'r', MTK::Core::Duration[Rational(1,8)], 'thirty-second note', '1/8' |
#s ⇒ MTK::Core::Duration (readonly)
sixteenth note: 1/4 beat(s)
46 |
# File 'lib/mtk/lang/durations.rb', line 46 define_duration 's', MTK::Core::Duration[Rational(1,4)], 'sixteenth note', '1/4' |
#w ⇒ MTK::Core::Duration (readonly)
whole note: 4 beat(s)
38 |
# File 'lib/mtk/lang/durations.rb', line 38 define_duration 'w', MTK::Core::Duration[4], 'whole note', 4 |
#x ⇒ MTK::Core::Duration (readonly)
sixty-fourth note: 1/16 beat(s)
50 |
# File 'lib/mtk/lang/durations.rb', line 50 define_duration 'x', MTK::Core::Duration[Rational(1,16)], 'sixty-fourth note', '1/16' |