Module: MTK::Lang::Intervals

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

Overview

Defines a constant for intervals up to an octave using diatonic naming conventions (see en.wikipedia.org/wiki/Interval_(music)#Main_intervals)

Naming conventions

P#: perfect interval
M#: major interval
m#: minor interval
TT: tritone (AKA augmented 4th or diminished 5th)

These can be thought of like constants, but in order to succinctly distinguish ‘m2’ (minor) from ‘M2’ (major), it was necessary to use lower-case names for some of the values and therefore define them as “pseudo constant” methods. The methods are available either through the module (MTK::Core::Intervals::m2) or via mixin (include MTK::Core::Intervals; m2)

Constant Summary collapse

INTERVALS =

The values of all “psuedo constants” defined in this module

[P1, m2, M2, m3, M3, P4, TT, P5, m6, M6, m7, M7, P8].freeze
INTERVAL_NAMES =

The names of all “psuedo constants” defined in this module

MTK::Core::Interval::NAMES

Instance Attribute Summary collapse

Method Summary

Methods included from PseudoConstants

define_constant

Instance Attribute Details

#M2MTK::Core::Interval[2] (readonly)

major second

Returns:



33
# File 'lib/mtk/lang/intervals.rb', line 33

define_constant 'M2', MTK::Core::Interval[2]

#m2MTK::Core::Interval[1] (readonly)

Returns number of semitones in the interval m2.

Returns:



30
# File 'lib/mtk/lang/intervals.rb', line 30

define_constant 'm2', MTK::Core::Interval[1]

#M3MTK::Core::Interval[4] (readonly)

major third

Returns:



39
# File 'lib/mtk/lang/intervals.rb', line 39

define_constant 'M3', MTK::Core::Interval[4]

#m3MTK::Core::Interval[3] (readonly)

minor third

Returns:



36
# File 'lib/mtk/lang/intervals.rb', line 36

define_constant 'm3', MTK::Core::Interval[3]

#M6MTK::Core::Interval[9] (readonly)

major sixth

Returns:



54
# File 'lib/mtk/lang/intervals.rb', line 54

define_constant 'M6', MTK::Core::Interval[9]

#m6MTK::Core::Interval[8] (readonly)

minor sixth

Returns:



51
# File 'lib/mtk/lang/intervals.rb', line 51

define_constant 'm6', MTK::Core::Interval[8]

#m7MTK::Core::Interval[10] (readonly)

minor seventh

Returns:



57
# File 'lib/mtk/lang/intervals.rb', line 57

define_constant 'm7', MTK::Core::Interval[10]

#M7MTK::Core::Interval[11] (readonly)

major seventh

Returns:



60
# File 'lib/mtk/lang/intervals.rb', line 60

define_constant 'M7', MTK::Core::Interval[11]

#P1MTK::Core::Interval[0] (readonly)

Returns number of semitones in the interval P1.

Returns:



24
# File 'lib/mtk/lang/intervals.rb', line 24

define_constant 'P1', MTK::Core::Interval[0]

#P4MTK::Core::Interval[5] (readonly)

pefect fourth

Returns:



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

define_constant 'P4', MTK::Core::Interval[5]

#P5MTK::Core::Interval[7] (readonly)

perfect fifth

Returns:



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

define_constant 'P5', MTK::Core::Interval[7]

#P8MTK::Core::Interval[12] (readonly)

pefect octave

Returns:



63
# File 'lib/mtk/lang/intervals.rb', line 63

define_constant 'P8', MTK::Core::Interval[12]

#TTMTK::Core::Interval[6] (readonly)

tritone (AKA augmented fourth or diminished fifth)

Returns:



45
# File 'lib/mtk/lang/intervals.rb', line 45

define_constant 'TT', MTK::Core::Interval[6]