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_str = ", metadata: (\n"
unless @credit.empty?
metadata_str += " credit: \"#{@credit}\",\n"
end
unless @source.empty?
metadata_str += " source: \"#{@source}\"\n"
end
metadata_str += ")\n"
output += metadata_str
end
output += ").writeDefFile;"
end
|