Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/mtk/numeric_extensions.rb
Overview
you must require ‘mtk/numeric_extensions’ to use these methods.
Optional Numeric methods for converting to MTK::Core objects.
Instance Method Summary collapse
-
#cents ⇒ Object
(also: #cent)
Convert a Numeric cents value to a MTK::Core::Interval.
-
#octaves ⇒ Object
(also: #octave)
Convert a Numeric octaves value to a MTK::Core::Interval.
-
#percent_intensity ⇒ Object
Convert a Numeric percentage to a MTK::Core::Intensity.
-
#to_duration ⇒ Object
(also: #beats, #beat)
Convert a Numeric to a MTK::Core::Duration.
-
#to_intensity ⇒ Object
Convert a Numeric to a MTK::Core::Intensity.
-
#to_interval ⇒ Object
(also: #semitones, #semitone)
Convert a Numeric to a MTK::Core::Interval.
-
#to_pitch ⇒ Object
Convert a Numeric to a MTK::Core::Pitch.
-
#to_pitch_class ⇒ Object
Convert a Numeric to a MTK::Core::PitchClass.
Instance Method Details
#cents ⇒ Object Also known as: cent
Convert a Numeric cents value to a MTK::Core::Interval
54 55 56 |
# File 'lib/mtk/numeric_extensions.rb', line 54 def cents MTK::Core::Interval.from_f(self/100.0) end |
#octaves ⇒ Object Also known as: octave
Convert a Numeric octaves value to a MTK::Core::Interval
61 62 63 |
# File 'lib/mtk/numeric_extensions.rb', line 61 def octaves MTK::Core::Interval.from_f(self * 12) end |
#percent_intensity ⇒ Object
The standard range of intensity percentages is from 0 - 100
Convert a Numeric percentage to a MTK::Core::Intensity
40 41 42 |
# File 'lib/mtk/numeric_extensions.rb', line 40 def percent_intensity MTK::Core::Intensity.from_f(self/100.0) end |
#to_duration ⇒ Object Also known as: beats, beat
Convert a Numeric to a MTK::Core::Duration
23 24 25 |
# File 'lib/mtk/numeric_extensions.rb', line 23 def to_duration MTK::Core::Duration.from_f(self) end |
#to_intensity ⇒ Object
The standard range of intensity values is from 0.0 - 1.0
Convert a Numeric to a MTK::Core::Intensity
33 34 35 |
# File 'lib/mtk/numeric_extensions.rb', line 33 def to_intensity MTK::Core::Intensity.from_f(self) end |
#to_interval ⇒ Object Also known as: semitones, semitone
Convert a Numeric to a MTK::Core::Interval
46 47 48 |
# File 'lib/mtk/numeric_extensions.rb', line 46 def to_interval MTK::Core::Interval.from_f(self) end |
#to_pitch ⇒ Object
Convert a Numeric to a MTK::Core::Pitch
9 10 11 |
# File 'lib/mtk/numeric_extensions.rb', line 9 def to_pitch MTK::Core::Pitch.from_f(self) end |
#to_pitch_class ⇒ Object
Convert a Numeric to a MTK::Core::PitchClass
16 17 18 |
# File 'lib/mtk/numeric_extensions.rb', line 16 def to_pitch_class MTK::Core::PitchClass.from_f(self) end |