Class: Deftones::Core::Instrument
Direct Known Subclasses
Instrument::AMSynth, Instrument::DuoSynth, Instrument::FMSynth, Instrument::MembraneSynth, Instrument::MetalSynth, Instrument::MonoSynth, Instrument::NoiseSynth, Instrument::PluckSynth, Instrument::PolySynth, Instrument::Sampler, Instrument::Synth
Defined Under Namespace
Classes: VolumeProxy
Instance Attribute Summary collapse
Attributes inherited from AudioNode
#context
Instance Method Summary
collapse
Methods inherited from AudioNode
#>>, #attach_destination, #attach_source, #block_time, #chain, #channel_count, #channel_count_mode, #channel_interpretation, #connect, #connected?, #default_input_channels, #default_output_channels, #destination_for_connection, #detach_all_destinations, #detach_destination, #detach_source, #disconnect, #disposed?, #fan, #immediate, #input_for_index, #inputs, #mix_source_blocks, #multichannel_process?, #name, #normalize_connection_index, #normalize_output_block, #now, #number_of_inputs, #number_of_outputs, #output_for_connection, #output_for_index, #outputs, #process, #raise_connection_index_error!, #reaches_node?, #sample_time, #to_destination, #to_frequency, #to_master, #to_midi, #to_output, #to_s, #to_seconds, #to_ticks, #uses_legacy_render_for_block?, #validate_connectable!, #validate_connection_index!
Constructor Details
#initialize(context: Deftones.context) ⇒ Instrument
Returns a new instance of Instrument.
63
64
65
66
67
68
69
|
# File 'lib/deftones/core/instrument.rb', line 63
def initialize(context: Deftones.context)
super(context: context)
@output = Gain.new(context: context, gain: 1.0)
@volume = VolumeProxy.new(self)
@mute = false
apply_volume!
end
|
Instance Attribute Details
#mute ⇒ Object
Returns the value of attribute mute.
61
62
63
|
# File 'lib/deftones/core/instrument.rb', line 61
def mute
@mute
end
|
#output ⇒ Object
Returns the value of attribute output.
60
61
62
|
# File 'lib/deftones/core/instrument.rb', line 60
def output
@output
end
|
#volume ⇒ Object
Returns the value of attribute volume.
60
61
62
|
# File 'lib/deftones/core/instrument.rb', line 60
def volume
@volume
end
|
Instance Method Details
#apply_volume! ⇒ Object
145
146
147
148
|
# File 'lib/deftones/core/instrument.rb', line 145
def apply_volume!
@output.gain.value = mute ? 0.0 : Deftones.db_to_gain(@volume.value)
self
end
|
#dispose ⇒ Object
124
125
126
127
|
# File 'lib/deftones/core/instrument.rb', line 124
def dispose
@output.dispose
super
end
|
#get(*keys, strict: false) ⇒ Object
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/deftones/core/instrument.rb', line 103
def get(*keys, strict: false)
requested = keys.flatten
unknown = []
values = requested.each_with_object({}) do |key, collected|
reader = key.to_sym
if respond_to?(reader)
collected[reader] = public_send(reader)
else
unknown << reader
end
end
raise ArgumentError, "Unknown parameter(s): #{unknown.join(', ')}" if strict && unknown.any?
values
end
|
71
72
73
|
# File 'lib/deftones/core/instrument.rb', line 71
def input
@output
end
|
#mute? ⇒ Boolean
88
89
90
|
# File 'lib/deftones/core/instrument.rb', line 88
def mute?
@mute
end
|
#release_all(time = nil) ⇒ Object
119
120
121
122
|
# File 'lib/deftones/core/instrument.rb', line 119
def release_all(time = nil)
trigger_release(time) if respond_to?(:trigger_release)
self
end
|
#releaseAll(time = nil) ⇒ Object
141
142
143
|
# File 'lib/deftones/core/instrument.rb', line 141
def releaseAll(time = nil)
release_all(time)
end
|
#render(num_frames, start_frame = 0, cache = {}) ⇒ Object
75
76
77
|
# File 'lib/deftones/core/instrument.rb', line 75
def render(num_frames, start_frame = 0, cache = {})
@output.render(num_frames, start_frame, cache)
end
|
#render_block(num_frames, start_frame = 0, cache = {}) ⇒ Object
79
80
81
|
# File 'lib/deftones/core/instrument.rb', line 79
def render_block(num_frames, start_frame = 0, cache = {})
@output.send(:render_block, num_frames, start_frame, cache)
end
|
#set(strict: false, **params) ⇒ Object
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/deftones/core/instrument.rb', line 92
def set(strict: false, **params)
unknown = params.keys.reject { |key| respond_to?(:"#{key}=") }
raise ArgumentError, "Unknown parameter(s): #{unknown.join(', ')}" if strict && unknown.any?
params.each do |key, value|
writer = :"#{key}="
public_send(writer, value) if respond_to?(writer)
end
self
end
|
#triggerAttack(*arguments) ⇒ Object
129
130
131
|
# File 'lib/deftones/core/instrument.rb', line 129
def triggerAttack(*arguments)
trigger_attack(*arguments)
end
|
#triggerAttackRelease(*arguments) ⇒ Object
137
138
139
|
# File 'lib/deftones/core/instrument.rb', line 137
def triggerAttackRelease(*arguments)
trigger_attack_release(*arguments)
end
|
#triggerRelease(*arguments) ⇒ Object
133
134
135
|
# File 'lib/deftones/core/instrument.rb', line 133
def triggerRelease(*arguments)
trigger_release(*arguments)
end
|