Class: Deftones::Destination

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/deftones/destination.rb

Defined Under Namespace

Classes: VolumeProxy

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context:) ⇒ Destination

Returns a new instance of Destination.



87
88
89
90
91
92
# File 'lib/deftones/destination.rb', line 87

def initialize(context:)
  @context = context
  @volume = VolumeProxy.new(self)
  @mute = false
  apply_volume!
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



61
62
63
# File 'lib/deftones/destination.rb', line 61

def context
  @context
end

#muteObject

Returns the value of attribute mute.



61
62
63
# File 'lib/deftones/destination.rb', line 61

def mute
  @mute
end

#volumeObject (readonly)

Returns the value of attribute volume.



61
62
63
# File 'lib/deftones/destination.rb', line 61

def volume
  @volume
end

Class Method Details

.node(context: Deftones.context) ⇒ Object



71
72
73
# File 'lib/deftones/destination.rb', line 71

def node(context: Deftones.context)
  registry[context.object_id] ||= new(context: context)
end

.registryObject (private)



82
83
84
# File 'lib/deftones/destination.rb', line 82

def registry
  @registry ||= {}
end

.reset!Object



75
76
77
78
# File 'lib/deftones/destination.rb', line 75

def reset!
  @registry = {}
  self
end

Instance Method Details

#apply_volume!Object



147
148
149
150
# File 'lib/deftones/destination.rb', line 147

def apply_volume!
  node.gain.value = mute ? 0.0 : Deftones.db_to_gain(@volume.value)
  self
end

#block_timeObject Also known as: blockTime



123
124
125
# File 'lib/deftones/destination.rb', line 123

def block_time
  context.buffer_size.to_f / context.sample_rate
end

#chain(*nodes) ⇒ Object



139
140
141
# File 'lib/deftones/destination.rb', line 139

def chain(*nodes)
  node.chain(*nodes)
end

#connect(*arguments, **keywords) ⇒ Object



131
132
133
# File 'lib/deftones/destination.rb', line 131

def connect(*arguments, **keywords)
  node.connect(*arguments, **keywords)
end

#disconnect(*arguments) ⇒ Object



135
136
137
# File 'lib/deftones/destination.rb', line 135

def disconnect(*arguments)
  node.disconnect(*arguments)
end

#fan(*nodes) ⇒ Object



143
144
145
# File 'lib/deftones/destination.rb', line 143

def fan(*nodes)
  node.fan(*nodes)
end

#inputObject



94
95
96
# File 'lib/deftones/destination.rb', line 94

def input
  node
end

#max_channel_countObject Also known as: maxChannelCount



127
128
129
# File 'lib/deftones/destination.rb', line 127

def max_channel_count
  context.channels
end

#mute?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/deftones/destination.rb', line 111

def mute?
  @mute
end

#nameObject



115
116
117
# File 'lib/deftones/destination.rb', line 115

def name
  "Destination"
end

#nodeObject



102
103
104
# File 'lib/deftones/destination.rb', line 102

def node
  context.output
end

#outputObject



98
99
100
# File 'lib/deftones/destination.rb', line 98

def output
  node
end

#sample_timeObject Also known as: sampleTime



119
120
121
# File 'lib/deftones/destination.rb', line 119

def sample_time
  1.0 / context.sample_rate
end