Class: FlameChannelParser::FramecurveWriters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/framecurve_writers/base.rb

Overview

Writes out a framecurve setup

Direct Known Subclasses

SoftfxTimewarp

Defined Under Namespace

Classes: KeyWriter

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extensionObject

Should return the desired extension for the exported file



26
27
28
# File 'lib/framecurve_writers/base.rb', line 26

def self.extension
  '.timewarp'
end

.inherited(by) ⇒ Object



15
16
17
18
# File 'lib/framecurve_writers/base.rb', line 15

def self.inherited(by)
  @@writers ||= []
  @@writers.push(by)
end

.with_each_writerObject

Yields each defined writer class to the block



21
22
23
# File 'lib/framecurve_writers/base.rb', line 21

def self.with_each_writer
  @@writers.each(&Proc.new)
end

Instance Method Details

#run_export(io) {|w| ... } ⇒ Object

Run the exporter writing the result to the passed IO. Will yield a KeyWriter to the caller for writing frames (call key(at, value) on it)

Yields:

  • (w)


32
33
34
35
36
37
38
# File 'lib/framecurve_writers/base.rb', line 32

def run_export(io)
  w = KeyWriter.new
  yield(w)
  w.keys.each do | at, value |
    io.puts("%d %.5f" % [at, value])
  end
end

#run_export_from_framecurve(io, curve) ⇒ Object

Run the exporter writing the result to it, and pulling framecurve frames from the passed Curve object



42
43
44
45
46
47
48
# File 'lib/framecurve_writers/base.rb', line 42

def run_export_from_framecurve(io, curve)
  run_export(io) do | writer |
    curve.to_materialized_curve.each_tuple do | t |
      writer.key(t.at, t.value)
    end
  end
end