Class: SynthBlocks::Mixer::MixerChannel
- Inherits:
-
Core::Sound
- Object
- Core::Sound
- SynthBlocks::Mixer::MixerChannel
- Defined in:
- lib/synth_blocks/mixer/mixer_channel.rb
Overview
Emulation of a mixer channel on a mixing desk has a built in EQ, compressor and ducker, can run an arbitrary number of insert effects and send channels
Direct Known Subclasses
Constant Summary collapse
- LIVE_PARAMS =
These params can be automated
[:volume, :eq_low_gain, :eq_high_gain, :eq_mid_gain]
Instance Attribute Summary collapse
-
#preset ⇒ Object
:nodoc:.
Attributes inherited from Core::Sound
Instance Method Summary collapse
-
#duck(t) ⇒ Object
Schedule ducking at time t (in seconds).
-
#initialize(srate, source, insert_effects: [], sends: [], preset: {}) ⇒ MixerChannel
constructor
-
source - Source sound generator - insert_effects - Array of effects instances - sends - Array of send values === Parameters - volume - channel volume - eq_low_freq, eq_high_freq - shelving frequencies for equalizer - eq_low_gain, eq_mid_gain, eq_high_gain - Equalizer gains per band - comp_threshold, comp_ratio, comp_attack, comp_release - Compressor params - duck - Duck amount (0-1) - duck attack, duck_release - Ducker envelope params in s.
-
-
#live_params ⇒ Object
:nodoc:.
-
#run(offset) ⇒ Object
runs channel.
-
#send(index) ⇒ Object
returns send portion of output signal for send index.
Methods inherited from Core::Sound
#active_events, #duration, #get, #release, #set, #start, #stop
Constructor Details
#initialize(srate, source, insert_effects: [], sends: [], preset: {}) ⇒ MixerChannel
-
source - Source sound generator
-
insert_effects - Array of effects instances
-
sends - Array of send values
Parameters
-
volume - channel volume
-
eq_low_freq, eq_high_freq - shelving frequencies for equalizer
-
eq_low_gain, eq_mid_gain, eq_high_gain - Equalizer gains per band
-
comp_threshold, comp_ratio, comp_attack, comp_release - Compressor params
-
duck - Duck amount (0-1)
-
duck attack, duck_release - Ducker envelope params in s
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/synth_blocks/mixer/mixer_channel.rb', line 30 def initialize(srate, source, insert_effects: [], sends: [], preset: {}) @source = source @insert_effects = insert_effects @sends = sends @preset = { volume: 0.2, eq_low_freq: 880, eq_high_freq: 5000, eq_low_gain: 1.0, eq_mid_gain: 1.0, eq_high_gain: 1.0, comp_threshold: -50.0, comp_ratio: 0.4, comp_attack: 80.0, comp_release: 200.0, duck: 0.0, duck_attack: 0.01, duck_release: 0.5 }.merge(preset) super(srate) @ducks = [] @duck_env = SynthBlocks::Mod::Envelope.new(@preset[:duck_attack], @preset[:duck_release]) @eq = SynthBlocks::Fx::Eq.new(srate, lowfreq: @preset[:eq_low_freq], highfreq: @preset[:eq_high_freq]) @compressor = SynthBlocks::Fx::Compressor.new(srate, attack: @preset[:comp_attack], release: @preset[:comp_release], ratio: @preset[:comp_ratio], threshold: @preset[:comp_threshold]) update_live_params(0) end |
Instance Attribute Details
#preset ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/synth_blocks/mixer/mixer_channel.rb', line 13 def preset @preset end |
Instance Method Details
#duck(t) ⇒ Object
Schedule ducking at time t (in seconds)
60 61 62 63 |
# File 'lib/synth_blocks/mixer/mixer_channel.rb', line 60 def duck(t) @ducks << t @ducks.sort end |
#live_params ⇒ Object
:nodoc:
15 16 17 |
# File 'lib/synth_blocks/mixer/mixer_channel.rb', line 15 def live_params # :nodoc: LIVE_PARAMS end |
#run(offset) ⇒ Object
runs channel
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/synth_blocks/mixer/mixer_channel.rb', line 73 def run(offset) t = time(offset) update_live_params(t) out = @eq.run(@source.run(offset)) @insert_effects.each do |effect| out = effect.run(out) end if @preset[:duck] != 0.0 duck = current_duck(t) if duck local_duck = t - duck out = out * (1.0 - @preset[:duck] * @duck_env.run(local_duck)) end end out = @compressor.run(out) @output = out * @preset[:volume] end |
#send(index) ⇒ Object
returns send portion of output signal for send index
67 68 69 |
# File 'lib/synth_blocks/mixer/mixer_channel.rb', line 67 def send(index) @output * (@sends[index] || 0.0) end |