Class: Browser::Audio::Node::Oscillator

Inherits:
Base show all
Defined in:
opal/browser/audio/node.rb

Constant Summary collapse

TYPES =
%i(sine square sawtooth triangle custom)

Instance Method Summary collapse

Methods inherited from Base

#connect, #disconnect, #method_missing, #respond_to_missing?

Constructor Details

#initialize(audio_context) ⇒ Oscillator

Returns a new instance of Oscillator.



60
61
62
# File 'opal/browser/audio/node.rb', line 60

def initialize(audio_context)
  super `#{audio_context.to_n}.createOscillator()`
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Browser::Audio::Node::Base

Instance Method Details

#typeObject



72
73
74
# File 'opal/browser/audio/node.rb', line 72

def type
  `#@native.type`
end

#type=(type) ⇒ Object



64
65
66
67
68
69
70
# File 'opal/browser/audio/node.rb', line 64

def type=(type)
  unless TYPES.include?(type)
    raise ArgumentError, "type #{type} doesn't exists"
  end

  `#@native.type =  type`
end