Sha256: f427c84cb135ee95337cd4ea4284e645c4be450d067ae52f50c84e0818d0e48f
Contents?: true
Size: 619 Bytes
Versions: 31
Compression:
Stored size: 619 Bytes
Contents
class Numeric #:doc: # # +pchtooctsemi+: pitch class to [octave, semitones] converter # # interprets its receiver as a pitch class and returns an array # in the format [+octave+, +semitones+] # #:nodoc: def pchtooctsemi p_octave = self.to_i p_note = (self - p_octave) * 100 ref = self < 0.0 ? -CHROMATIC_NOTES_PER_OCTAVE : CHROMATIC_NOTES_PER_OCTAVE p_octave += (p_note / CHROMATIC_NOTES_PER_OCTAVE).to_i # cater for octave wrapping p_note = (p_note % ref); # reduce note in a 0-11 space (keeping track of sign) [p_octave, p_note] end end
Version data entries
31 entries across 31 versions & 1 rubygems