Module: Ruby2Faust

Defined in:
lib/ruby2faust.rb,
lib/ruby2faust/ir.rb,
lib/ruby2faust/dsl.rb,
lib/ruby2faust/live.rb,
lib/ruby2faust/emitter.rb,
lib/ruby2faust/version.rb

Defined Under Namespace

Modules: DSL, Emitter, Live, NodeType Classes: DSP, Error, Node, Program

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.generate(pretty: false) { ... } ⇒ String

Convenience method to generate Faust code from a block

Examples:

code = Ruby2Faust.generate do
  osc(440).then(gain(0.3))
end

Yields:

  • Block that returns a DSP

Returns:

  • (String)

    Faust source code



21
22
23
24
25
26
# File 'lib/ruby2faust.rb', line 21

def self.generate(pretty: false, &block)
  context = Object.new
  context.extend(DSL)
  process = context.instance_eval(&block)
  Emitter.program(process, pretty: pretty)
end