class SynthBlocks::Mixer::MixerChannel

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

Constants

LIVE_PARAMS

These params can be automated

Public Class Methods

new(srate, source, insert_effects: [], sends: [], preset: {}) click to toggle source
  • 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

Calls superclass method SynthBlocks::Core::Sound::new
# 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

Public Instance Methods

duck(t) click to toggle source

Schedule ducking at time t (in seconds)

# File lib/synth_blocks/mixer/mixer_channel.rb, line 60
def duck(t)
  @ducks << t
  @ducks.sort
end
run(offset) click to toggle source

runs channel

# 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) click to toggle source

returns send portion of output signal for send index

# File lib/synth_blocks/mixer/mixer_channel.rb, line 67
def send(index)
  @output * (@sends[index] || 0.0)
end

Private Instance Methods

current_duck(t) click to toggle source
# File lib/synth_blocks/mixer/mixer_channel.rb, line 99
def current_duck(t)
  past = @ducks.select {|duck| duck < t}
  return past.last unless past.empty?
  nil
end
update_live_params(t) click to toggle source
# File lib/synth_blocks/mixer/mixer_channel.rb, line 93
def update_live_params(t)
  @eq.low_gain = get(:eq_low_gain, t)
  @eq.mid_gain = get(:eq_low_gain, t)
  @eq.high_gain = get(:eq_low_gain, t)
end