class SMF::Sequence

Attributes

division[RW]
format[RW]
tc[RW]

Public Class Methods

decoceio(io) click to toggle source
# File lib/smf/io.rb, line 1234
def decoceio(io)
  warn('decodeio is deprecated; use read') if $VERBOSE
  read(io)
end
decode(s) click to toggle source
# File lib/smf/io.rb, line 1217
def decode(s)
  self::RS.new(s, self::Decode.new).read
end
decode_text(s) click to toggle source
# File lib/smf/toy/text.rb, line 187
def decode_text(s)
  self::RSText.new(s, self::Decode.new).read
end
decode_xml(s) click to toggle source
# File lib/smf/toy/xml.rb, line 143
def decode_xml(s)
  self::RSXML.new(s, self::Decode.new).read
end
decodefile(fn) click to toggle source
# File lib/smf/io.rb, line 1245
def decodefile(fn)
  warn('decodefile is deprecated; use load') if $VERBOSE
  load(fn)
end
load(fn) click to toggle source
# File lib/smf/io.rb, line 1239
def load(fn)
  open(fn) do |io|
    read(io)
  end
end
load_text(fn) click to toggle source
# File lib/smf/toy/text.rb, line 195
def load_text(fn)
  open(fn) do |io|
    read_text(io)
  end
end
load_xml(fn) click to toggle source
# File lib/smf/toy/xml.rb, line 151
def load_xml(fn)
  open(fn) do |io|
    read_xml(io)
  end
end
new(format=1, division=96, tc=nil) click to toggle source
# File lib/smf.rb, line 11
def initialize(format=1, division=96, tc=nil)
  # format:0/2
  # division:1/2**15-1(if tc=nil):1/2**8-1(otherwise)
  # tc:nil,24,25,29,30
  @format, @division, @tc, @arr = format, division, tc, []
end
read(io) click to toggle source
# File lib/smf/io.rb, line 1230
def read(io)
  decode(io.binmode.read)
end
read_text(io) click to toggle source
# File lib/smf/toy/text.rb, line 191
def read_text(io)
  decode_text(io.binmode.read)
end
read_xml(io) click to toggle source
# File lib/smf/toy/xml.rb, line 147
def read_xml(io)
  decode_xml(io.binmode.read)
end

Public Instance Methods

&(other) click to toggle source
# File lib/smf.rb, line 65
def & (other) calc_set(self, other){|a, b| a & b} end
*(times) click to toggle source
# File lib/smf.rb, line 68
def * (times)
  sq = self.class.new(format, division, tc)
  sq.replace(self.to_a * times)
  sq
end
+(other) click to toggle source
# File lib/smf.rb, line 63
def + (other) calc_set(self, other){|a, b| a + b} end
-(other) click to toggle source
# File lib/smf.rb, line 64
def - (other) calc_set(self, other){|a, b| a - b} end
<<(tr) click to toggle source
# File lib/smf.rb, line 74
def << (tr)
  @arr << tr
  self
end
==(other) click to toggle source
# File lib/smf.rb, line 45
def == (other)
  self.class == other.class &&
    format == other.format &&
    division == other.division &&
    tc == other.tc &&
    to_a == other.to_a
end
>>(tr) click to toggle source
# File lib/smf.rb, line 79
def >> (tr)
  @arr.reject!{|x| x.object_id == tr.object_id}
  self
end
concat(other) click to toggle source
# File lib/smf.rb, line 84
def concat(other) replace(self + other) end
each() { |tr| ... } click to toggle source
# File lib/smf.rb, line 86
def each
  @arr.compact.each do |tr|
    yield tr
  end
  self
end
encode() click to toggle source
# File lib/smf/io.rb, line 1252
def encode
  self.class::WS.new(self, self.class::Encode.new).read
end
encode_text() click to toggle source
# File lib/smf/toy/text.rb, line 353
def encode_text
  self.class::WS.new(self, self.class::EncodeText.new).read
end
encode_xml() click to toggle source
# File lib/smf/toy/xml.rb, line 361
def encode_xml
  self.class::WS.new(self, self.class::EncodeXML.new).read
end
encodefile(fn) click to toggle source
# File lib/smf/io.rb, line 1271
def encodefile(fn)
  warn('encodefile is deprecated; use save') if $VERBOSE
  save(fn)
end
encodeio(io) click to toggle source
# File lib/smf/io.rb, line 1260
def encodeio(io)
  warn('encodeio is deprecated; use write') if $VERBOSE
  write(io)
end
eql?(other) click to toggle source
# File lib/smf.rb, line 43
def eql? (other) self == other end
hash() click to toggle source
# File lib/smf.rb, line 42
def hash() @format.hash ^ @division.hash ^ @arr.hash end
join() click to toggle source
# File lib/smf.rb, line 93
def join
  sq = self.class.new(format, division, tc)
  tr = Track.new
  sq << @arr.inject(tr){|t, x| t + x}
  sq
end
join!() click to toggle source
# File lib/smf.rb, line 100
def join!
  @arr.replace(join)
  self
end
ntrks() click to toggle source
# File lib/smf.rb, line 32
def ntrks() @arr.count{|x| x} end
replace(another) click to toggle source
# File lib/smf.rb, line 105
def replace(another)
  if Sequence === another
    @format = another.format
    @division = another.division
    @tc = another.tc
  end
  @arr.replace(another.to_a)
  self
end
save(fn) click to toggle source
# File lib/smf/io.rb, line 1265
def save(fn)
  open(fn, 'w') do |io|
    write(io)
  end
end
save_text(fn) click to toggle source
# File lib/smf/toy/text.rb, line 361
def save_text(fn)
  open(fn, 'w') do |io|
    write_text(io)
  end
end
save_xml(fn) click to toggle source
# File lib/smf/toy/xml.rb, line 369
def save_xml(fn)
  open(fn, 'w') do |io|
    write_xml(io)
  end
end
smpte() click to toggle source
# File lib/smf.rb, line 20
def smpte()
  warn('smpte is deprecated; use tc') if $VERBOSE
  self.tc
end
smpte=(v) click to toggle source
# File lib/smf.rb, line 25
def smpte=(v)
  warn('smpte= is deprecated; use tc=') if $VERBOSE
  self.tc = v
end
to_virtual() click to toggle source
# File lib/smf/toy/virtual.rb, line 8
def to_virtual
  v = VirtualSequence.new(format, division, tc)
  each do |tr|
    v << tr.to_virtual
  end
  v
end
write(io) click to toggle source
# File lib/smf/io.rb, line 1256
def write(io)
  io.binmode.write(encode)
end
write_text(io) click to toggle source
# File lib/smf/toy/text.rb, line 357
def write_text(io)
  io.write(encode_text)
end
write_xml(io) click to toggle source
# File lib/smf/toy/xml.rb, line 365
def write_xml(io)
  io.write(encode_xml)
end
|(other) click to toggle source
# File lib/smf.rb, line 66
def | (other) calc_set(self, other){|a, b| a | b} end

Private Instance Methods

calc_set(a, b) { |a, b| ... } click to toggle source
# File lib/smf.rb, line 53
def calc_set(a, b)
  sq = self.class.new(format, division, tc)
  a, b = a.to_a, b.to_a
  n = yield(a, b)
  sq.replace(n)
  sq
end