class Coltrane::Theory::Frequency
Attributes
frequency[R]
Public Class Methods
new(frequency)
click to toggle source
# File lib/coltrane/theory/frequency.rb, line 9 def initialize(frequency) @frequency = frequency.to_f end
Also aliased as: []
Public Instance Methods
/(other)
click to toggle source
# File lib/coltrane/theory/frequency.rb, line 45 def /(other) case other when Frequency then FrequencyInterval[1200 * Math.log2(other.frequency / frequency)] when Numeric then Frequency[frequency / other] end end
<=>(other)
click to toggle source
# File lib/coltrane/theory/frequency.rb, line 13 def <=>(other) to_f <=> other.to_f end
==(other)
click to toggle source
# File lib/coltrane/theory/frequency.rb, line 33 def ==(other) frequency == (other.is_a?(Frequency) ? other.frequency : other) end
method_missing(method, *args)
click to toggle source
# File lib/coltrane/theory/frequency.rb, line 52 def method_missing(method, *args) Frequency[frequency.send(method, args[0].to_f)] end
octave(n)
click to toggle source
# File lib/coltrane/theory/frequency.rb, line 29 def octave(n) Frequency[frequency * 2**n] end
octave_down(n = 1)
click to toggle source
# File lib/coltrane/theory/frequency.rb, line 41 def octave_down(n = 1) octave(-n) end
octave_up(n = 1)
click to toggle source
# File lib/coltrane/theory/frequency.rb, line 37 def octave_up(n = 1) octave(n) end
to_f()
click to toggle source
# File lib/coltrane/theory/frequency.rb, line 25 def to_f frequency end
to_s()
click to toggle source
# File lib/coltrane/theory/frequency.rb, line 21 def to_s "#{frequency}hz" end