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).

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.

See Also:

  • Note

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

Method Summary

Methods included from PseudoConstants

define_constant

Instance Attribute Details

#hMTK::Core::Duration[2] (readonly)

half note

Returns:



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

define_constant 'h', MTK::Core::Duration[2]

#iMTK::Core::Duration[Rational(1,2)] (readonly)

eight note

Returns:



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

define_constant 'i', MTK::Core::Duration[Rational(1,2)]

#qMTK::Core::Duration[1] (readonly)

quarter note

Returns:



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

define_constant 'q', MTK::Core::Duration[1]

#rMTK::Core::Duration[Rational(1,8)] (readonly)

thirty-second note

Returns:



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

define_constant 'r', MTK::Core::Duration[Rational(1,8)]

#sMTK::Core::Duration[Rational(1,4)] (readonly)

sixteenth note

Returns:



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

define_constant 's', MTK::Core::Duration[Rational(1,4)]

#wMTK::Core::Duration[4] (readonly)

Returns number of beats for w.

Returns:



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

define_constant 'w', MTK::Core::Duration[4]

#xMTK::Core::Duration[Rational(1,16)] (readonly)

sixty-fourth note

Returns:



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

define_constant 'x', MTK::Core::Duration[Rational(1,16)]