Module: MTK::Lang::Durations

Extended by:
PseudoConstants
Defined in:
lib/mtk/lang/durations.rb

Overview

Note:

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

Method Summary

Methods included from PseudoConstants

define_constant

Instance Attribute Details

#eMTK::Core::Duration (readonly)

eighth note: 1/2 beat(s)

Returns:



44
# File 'lib/mtk/lang/durations.rb', line 44

define_duration 'e', MTK::Core::Duration[Rational(1,2)], 'eighth note', '1/2'

#hMTK::Core::Duration (readonly)

half note: 2 beat(s)

Returns:



40
# File 'lib/mtk/lang/durations.rb', line 40

define_duration 'h', MTK::Core::Duration[2], 'half note', 2

#qMTK::Core::Duration (readonly)

quarter note: 1 beat(s)

Returns:



42
# File 'lib/mtk/lang/durations.rb', line 42

define_duration 'q', MTK::Core::Duration[1], 'quarter note', 1

#rMTK::Core::Duration (readonly)

thirty-second note: 1/8 beat(s)

Returns:



48
# File 'lib/mtk/lang/durations.rb', line 48

define_duration 'r', MTK::Core::Duration[Rational(1,8)], 'thirty-second note', '1/8'

#sMTK::Core::Duration (readonly)

sixteenth note: 1/4 beat(s)

Returns:



46
# File 'lib/mtk/lang/durations.rb', line 46

define_duration 's', MTK::Core::Duration[Rational(1,4)], 'sixteenth note', '1/4'

#wMTK::Core::Duration (readonly)

whole note: 4 beat(s)

Returns:



38
# File 'lib/mtk/lang/durations.rb', line 38

define_duration 'w', MTK::Core::Duration[4], 'whole note', 4

#xMTK::Core::Duration (readonly)

sixty-fourth note: 1/16 beat(s)

Returns:



50
# File 'lib/mtk/lang/durations.rb', line 50

define_duration 'x', MTK::Core::Duration[Rational(1,16)], 'sixty-fourth note', '1/16'