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.


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

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


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

def type
  `#@native.type`
end

#type=(type) ⇒ Object


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

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

  `#@native.type =  type`
end