Class: Synthesizer::Filter::BandPassFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/synthesizer/filter/band_pass_filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(freq:, bandwidth: 1.0) ⇒ BandPassFilter

Returns a new instance of BandPassFilter.



4
5
6
7
# File 'lib/synthesizer/filter/band_pass_filter.rb', line 4

def initialize(freq:, bandwidth: 1.0)
  @freq = ModulationValue.create(freq)
  @bandwidth = ModulationValue.create(bandwidth)
end

Instance Method Details

#generator(note_perform, samplecount) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/synthesizer/filter/band_pass_filter.rb', line 9

def generator(note_perform, samplecount)
  soundinfo = note_perform.synth.soundinfo
  filter = AudioStream::Fx::BandPassFilter.new(soundinfo)

  freq_mod = ModulationValue.balance_generator(note_perform, samplecount, @freq)
  bandwidth_mod = ModulationValue.balance_generator(note_perform, samplecount, @bandwidth)

  -> {
    filter.update_coef(freq: freq_mod[], bandwidth: bandwidth_mod[])
    filter
  }
end