Class: Pachelbel::AudioNode

Inherits:
Object
  • Object
show all
Defined in:
lib/project/Pachelbel.rb

Direct Known Subclasses

AudioDestinationNode, GainNode, OscillatorNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#audio_contextObject (readonly)

Returns the value of attribute audio_context.



88
89
90
# File 'lib/project/Pachelbel.rb', line 88

def audio_context
  @audio_context
end

Instance Method Details

#_audio_context=(value) ⇒ Object



94
95
96
# File 'lib/project/Pachelbel.rb', line 94

def _audio_context=(value)
  @audio_context = value
end

#_index=(value) ⇒ Object



98
99
100
# File 'lib/project/Pachelbel.rb', line 98

def _index=(value)
  @index = value
end

#_js_snippetObject



102
103
104
# File 'lib/project/Pachelbel.rb', line 102

def _js_snippet
  "audio_nodes[#{@index}]"
end

#connect(destination) ⇒ Object

API Methods



108
109
110
# File 'lib/project/Pachelbel.rb', line 108

def connect(destination)
  run_js("#{_js_snippet}.connect(#{destination._js_snippet});")
end

#disconnectObject



112
113
114
# File 'lib/project/Pachelbel.rb', line 112

def disconnect
  run_js("#{_js_snippet}.disconnect();")
end

#run_js(script) ⇒ Object



90
91
92
# File 'lib/project/Pachelbel.rb', line 90

def run_js(script)
  @audio_context.run_js script
end