class Praat::Intervals

Currently, we can only extract one IntervalTier at a time Intervals is actually a single interval (thx, Praat)

Public Instance Methods

extract_formant(formant) click to toggle source
# File lib/praat_textgrid.rb, line 34
def extract_formant formant
  out = Marshal.load(Marshal.dump(formant))
  out.frames.clear
  x1 = formant.x1
  dx = formant.dx
  # Select the frames which fall within the range of the textgrid
  formant.frames.each_with_index do |f, i|
    time = i * dx + x1
    if range.include? time
      out.frames << f
    end
  end
  out
end
extract_pitch(pitch) click to toggle source
# File lib/praat_textgrid.rb, line 19
def extract_pitch pitch
  out = Marshal.load(Marshal.dump(pitch))
  out.frames.clear
  x1 = pitch.x1
  dx = pitch.dx
  # Select the frames which fall within the pitch range
  pitch.frames.each_with_index do |f, i|
    time = i * dx + x1
    if range.include? time
      out.frames << f
    end
  end
  out
end
has_text?() click to toggle source
# File lib/praat_textgrid.rb, line 7
def has_text?
  self.text != ""
end
minmax() click to toggle source
# File lib/praat_textgrid.rb, line 11
def minmax
  [self.xmin, self.xmax]
end
range() click to toggle source
# File lib/praat_textgrid.rb, line 15
def range
  Range.new(self.xmin, self.xmax)
end