Class: Synthesizer::Processor::High

Inherits:
Object
  • Object
show all
Defined in:
lib/synthesizer/processor/high.rb

Instance Method Summary collapse

Instance Method Details

#generator(osc, note_perform) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
57
58
59
60
# File 'lib/synthesizer/processor/high.rb', line 4

def generator(osc, note_perform)
  synth = note_perform.synth
  filter = synth.filter
  amp = synth.amplifier

  samplecount = synth.soundinfo.window_size.to_f

  # Oscillator, Amplifier
  volume_mod = ModulationValue.amp_generator(note_perform, 1, osc.volume, amp.volume)
  pan_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.pan, amp.pan)
  tune_semis_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.tune_semis, amp.tune_semis, synth.glide&.to_modval)
  tune_cents_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.tune_cents, amp.tune_cents)

  sym_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.sym)
  sync_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.sync)

  uni_num_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.uni_num, amp.uni_num, center: 1.0)
  uni_detune_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.uni_detune, amp.uni_detune)
  uni_stereo_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.uni_stereo, amp.uni_stereo)

  unison = Unison.new(note_perform, osc.source, osc.phase)

  # Filter
  filter_mod = nil
  if filter
    filter_mod = filter.generator(note_perform, samplecount)
  end

  -> {
    # Oscillator, Amplifier
    volume = Vdsp::DoubleArray.create(
      samplecount.to_i.times.map {|i|
        volume_mod[] * note_perform.velocity
      }
    )
    pan = pan_mod[]
    tune_semis = tune_semis_mod[] + synth.pitch_bend
    tune_cents = tune_cents_mod[]

    sym = sym_mod[]
    sync = sync_mod[]

    uni_num = uni_num_mod[]
    uni_detune = uni_detune_mod[]
    uni_stereo = uni_stereo_mod[]

    buf = unison.next(uni_num, uni_detune, uni_stereo, volume, pan, tune_semis, tune_cents, sym, sync)

    # Filter
    if filter_mod
      filter_fx = filter_mod[]
      buf = filter_fx.process(buf)
    end

    buf
  }
end