class Numeric
Optional Numeric
methods for converting to {MTK::Core} objects.
@note you must require ‘mtk/numeric_extensions’ to use these methods.
Public Instance Methods
Convert a Numeric
cents value to a {MTK::Core::Interval} @example 100.cents => 1.semitone
# File lib/mtk/numeric_extensions.rb, line 54 def cents MTK::Core::Interval.from_f(self/100.0) end
Convert a Numeric
octaves value to a {MTK::Core::Interval} @example 1.octave => 12.semitones
# File lib/mtk/numeric_extensions.rb, line 61 def octaves MTK::Core::Interval.from_f(self * 12) end
Convert a Numeric
percentage to a {MTK::Core::Intensity} @note The standard range of intensity percentages is from 0 - 100 @example 100.percent_intensity => fff
# File lib/mtk/numeric_extensions.rb, line 40 def percent_intensity MTK::Core::Intensity.from_f(self/100.0) end
Convert a Numeric
to a {MTK::Core::Duration} @example 3.5.to_duration + 1.beat + 2.beats
# File lib/mtk/numeric_extensions.rb, line 23 def to_duration MTK::Core::Duration.from_f(self) end
Convert a Numeric
to a {MTK::Core::Intensity} @note The standard range of intensity values is from 0.0 - 1.0 @example 1.to_pitch => fff
# File lib/mtk/numeric_extensions.rb, line 33 def to_intensity MTK::Core::Intensity.from_f(self) end
Convert a Numeric
to a {MTK::Core::Interval} @example 3.5.to_interval + 1.semitone + 2.semitones
# File lib/mtk/numeric_extensions.rb, line 46 def to_interval MTK::Core::Interval.from_f(self) end
Convert a Numeric
to a {MTK::Core::Pitch} @example 60.to_pitch => C4
# File lib/mtk/numeric_extensions.rb, line 9 def to_pitch MTK::Core::Pitch.from_f(self) end
Convert a Numeric
to a {MTK::Core::PitchClass} @example 2.to_pitch_class => D
# File lib/mtk/numeric_extensions.rb, line 16 def to_pitch_class MTK::Core::PitchClass.from_f(self) end