Class: Musicality::SuperCollider::SynthDef
- Inherits:
-
Object
- Object
- Musicality::SuperCollider::SynthDef
- Includes:
- Packable
- Defined in:
- lib/musicality/performance/supercollider/synthdef.rb
Defined Under Namespace
Classes: Settings
Constant Summary
Constants included from Packable
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#credit ⇒ Object
readonly
Returns the value of attribute credit.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(name: "", params: {}, body: "", credit: "", source: "") ⇒ SynthDef
constructor
A new instance of SynthDef.
- #settings(args = {}) ⇒ Object
- #to_sclang ⇒ Object
Methods included from Packable
#class_str, included, #init_params, #pack, pack_val, recover_class, unpack_val
Constructor Details
#initialize(name: "", params: {}, body: "", credit: "", source: "") ⇒ SynthDef
Returns a new instance of SynthDef.
8 9 10 11 12 13 14 |
# File 'lib/musicality/performance/supercollider/synthdef.rb', line 8 def initialize name: "", params: {}, body: "", credit: "", source: "" raise ArgumentError if name.empty? raise ArgumentError if body.empty? @name, @params, @body = name, params, body @credit, @source = credit, source end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
7 8 9 |
# File 'lib/musicality/performance/supercollider/synthdef.rb', line 7 def body @body end |
#credit ⇒ Object (readonly)
Returns the value of attribute credit.
7 8 9 |
# File 'lib/musicality/performance/supercollider/synthdef.rb', line 7 def credit @credit end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/musicality/performance/supercollider/synthdef.rb', line 7 def name @name end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
7 8 9 |
# File 'lib/musicality/performance/supercollider/synthdef.rb', line 7 def params @params end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
7 8 9 |
# File 'lib/musicality/performance/supercollider/synthdef.rb', line 7 def source @source end |
Instance Method Details
#settings(args = {}) ⇒ Object
44 45 46 |
# File 'lib/musicality/performance/supercollider/synthdef.rb', line 44 def settings args = {} Settings.new(self, args) end |
#to_sclang ⇒ Object
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 |