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).
In order to avoid conflict with pitch class ‘e’, the constant for eighth note is ‘i’
These can be thought of like constants, but they use lower-case names and therefore define them as “pseudo constant” methods. The methods are available either through the module (MTK::Core::Durations::e) or via mixin (include MTK::Core::Durations; q)
These values assume the quarter note is one beat (1.0), so they work best with 4/4 and other */4 time signatures.
Constant Summary collapse
- DURATIONS =
The values of all “psuedo constants” defined in this module
[w, h, q, i, s, r, x].freeze
- DURATION_NAMES =
The names of all “psuedo constants” defined in this module
MTK::Core::Duration::NAMES
Instance Attribute Summary collapse
-
#h ⇒ MTK::Core::Duration[2]
readonly
half note.
-
#i ⇒ MTK::Core::Duration[Rational(1,2)]
readonly
eight note.
-
#q ⇒ MTK::Core::Duration[1]
readonly
quarter note.
-
#r ⇒ MTK::Core::Duration[Rational(1,8)]
readonly
thirty-second note.
-
#s ⇒ MTK::Core::Duration[Rational(1,4)]
readonly
sixteenth note.
-
#w ⇒ MTK::Core::Duration[4]
readonly
Number of beats for w.
-
#x ⇒ MTK::Core::Duration[Rational(1,16)]
readonly
sixty-fourth note.
Method Summary
Methods included from PseudoConstants
Instance Attribute Details
#h ⇒ MTK::Core::Duration[2] (readonly)
half note
32 |
# File 'lib/mtk/lang/durations.rb', line 32 define_constant 'h', MTK::Core::Duration[2] |
#i ⇒ MTK::Core::Duration[Rational(1,2)] (readonly)
eight note
38 |
# File 'lib/mtk/lang/durations.rb', line 38 define_constant 'i', MTK::Core::Duration[Rational(1,2)] |
#q ⇒ MTK::Core::Duration[1] (readonly)
quarter note
35 |
# File 'lib/mtk/lang/durations.rb', line 35 define_constant 'q', MTK::Core::Duration[1] |
#r ⇒ MTK::Core::Duration[Rational(1,8)] (readonly)
thirty-second note
44 |
# File 'lib/mtk/lang/durations.rb', line 44 define_constant 'r', MTK::Core::Duration[Rational(1,8)] |
#s ⇒ MTK::Core::Duration[Rational(1,4)] (readonly)
sixteenth note
41 |
# File 'lib/mtk/lang/durations.rb', line 41 define_constant 's', MTK::Core::Duration[Rational(1,4)] |
#w ⇒ MTK::Core::Duration[4] (readonly)
Returns number of beats for w.
29 |
# File 'lib/mtk/lang/durations.rb', line 29 define_constant 'w', MTK::Core::Duration[4] |
#x ⇒ MTK::Core::Duration[Rational(1,16)] (readonly)
sixty-fourth note
47 |
# File 'lib/mtk/lang/durations.rb', line 47 define_constant 'x', MTK::Core::Duration[Rational(1,16)] |