Sha256: 8c0ad1bcb3e695b83ea12bad0c63ac3510f19ca92e504c2b26bf12bfcd248cb5
Contents?: true
Size: 1.51 KB
Versions: 5
Compression:
Stored size: 1.51 KB
Contents
require 'pathname' module Scissor class Fragment attr_reader :filename, :start, :pitch def initialize(filename, start, duration, reverse = false, pitch = 100, stretch = false) @filename = Pathname.new(filename).realpath @start = start @duration = duration @reverse = reverse @pitch = pitch @is_stretched = stretch freeze end def duration @duration * (100 / pitch.to_f) end def original_duration @duration end def reversed? @reverse end def stretched? @is_stretched end def create(remaining_start, remaining_length) new_fragment = nil if remaining_start >= duration remaining_start -= duration else if remaining_start + remaining_length >= duration new_fragment = self.class.new( filename, start + remaining_start * pitch.to_f / 100, (duration - remaining_start) * pitch.to_f / 100, false, pitch, stretched?) remaining_length -= duration - remaining_start remaining_start = 0 else new_fragment = self.class.new( filename, start + remaining_start * pitch.to_f / 100, remaining_length * pitch.to_f / 100, false, pitch, stretched?) remaining_start = 0 remaining_length = 0 end end return new_fragment, remaining_start, remaining_length end end end
Version data entries
5 entries across 5 versions & 1 rubygems