class Music::Transcription::Meter

Constants

CONVERSION_METHOD
PARSER

Attributes

beat_duration[R]
beats_per_measure[R]
measure_duration[R]

Public Class Methods

new(beats_per_measure, beat_duration) click to toggle source
# File lib/music-transcription/model/meter.rb, line 9
def initialize beats_per_measure, beat_duration
  @beats_per_measure = beats_per_measure
  @beat_duration = beat_duration
  @measure_duration = beats_per_measure * beat_duration    
end

Public Instance Methods

==(other) click to toggle source
# File lib/music-transcription/model/meter.rb, line 39
def ==(other)
  return (@beats_per_measure == other.beats_per_measure &&
    @beat_duration == other.beat_duration)
end
check_beat_duration() click to toggle source
# File lib/music-transcription/model/meter.rb, line 29
def check_beat_duration
  unless @beat_duration > 0
    raise NonPositiveError, "beat duration #{@beat_duration} is not positive"
  end
  
  unless @beat_duration > 0
    raise NonRationalError, "beat duration #{@beat_duration} is a rational"
  end
end
check_beats_per_measure() click to toggle source
# File lib/music-transcription/model/meter.rb, line 19
def check_beats_per_measure
  unless @beats_per_measure > 0
    raise NonPositiveError, "beats per measure #{@beats_per_measure} is not positive"
  end
  
  unless @beats_per_measure.is_a?(Integer)
    raise NonIntegerError, "beats per measure #{@beats_per_measure} is not an integer"
  end
end
check_methods() click to toggle source
# File lib/music-transcription/model/meter.rb, line 15
def check_methods
  [ :check_beats_per_measure, :check_beat_duration ]
end
to_s() click to toggle source
# File lib/music-transcription/model/meter.rb, line 44
def to_s
  if beat_duration.numerator == 1
    num = beats_per_measure * beat_duration.numerator
    den = beat_duration.denominator
    "#{num}/#{den}"
  else
    "#{beats_per_measure}*#{beat_duration}"
  end
end