Method: Musicality::SuperCollider::SynthDef#to_sclang

Defined in:
lib/musicality/performance/supercollider/synthdef.rb

#to_sclangObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/musicality/performance/supercollider/synthdef.rb', line 16

def to_sclang
  params_str = "|" + @params.map {|k,v| v.nil? ? k.to_s : "#{k} = #{v}" }.join(", ") + "|"
  output = "SynthDef(\"#{@name}\", {" + params_str + "\n" + @body + "#{"\n" unless @body[-1] == "\n"}\}"
  
  unless (@credit.empty? && @source.empty?)
     = ", metadata: (\n"
    unless @credit.empty?
       += "  credit: \"#{@credit}\",\n"
    end
    unless @source.empty?
       += "  source: \"#{@source}\"\n"
    end
     += ")\n"
    output += 
  end

  output += ").writeDefFile;"
end