Sha256: 4b045552200aedd5c069d51ab6d68f2811d99a67d33fc3b13c2e9a05719306e2
Contents?: true
Size: 617 Bytes
Versions: 4
Compression:
Stored size: 617 Bytes
Contents
module Xi module Numeric def midi_to_cps 440 * (2 ** ((self - 69) / 12.0)) end def db_to_amp 10 ** (self / 20.0) end def degree_to_key(scale, steps_per_octave) accidental = (self - self.to_i) * 10.0 inner_key = scale[self % scale.size] base_key = (self / scale.size).to_i * steps_per_octave + inner_key if accidental != 0 base_key + accidental * (steps_per_octave / 12.0) else base_key end end end end class Fixnum include Xi::Numeric end class Float include Xi::Numeric end class Rational include Xi::Numeric end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
xi-lang-0.1.4 | lib/xi/core_ext/numeric.rb |
xi-lang-0.1.3 | lib/xi/core_ext/numeric.rb |
xi-lang-0.1.2 | lib/xi/core_ext/numeric.rb |
xi-lang-0.1.0 | lib/xi/core_ext/numeric.rb |