Class: AudioStream::Fx::SchroederReverb
- Inherits:
-
Object
- Object
- AudioStream::Fx::SchroederReverb
- Defined in:
- lib/audio_stream/fx/schroeder_reverb.rb
Instance Method Summary collapse
-
#initialize(soundinfo, dry: -1.0,, wet: -20.0)) ⇒ SchroederReverb
constructor
A new instance of SchroederReverb.
- #process(input) ⇒ Object
Constructor Details
#initialize(soundinfo, dry: -1.0,, wet: -20.0)) ⇒ SchroederReverb
Returns a new instance of SchroederReverb.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/audio_stream/fx/schroeder_reverb.rb', line 8 def initialize(soundinfo, dry: -1.0, wet: -20.0) @window_size = soundinfo.window_size @combs = [ CombFilter.new(soundinfo, freq: Rate.msec(39.85), q: 0.871402), CombFilter.new(soundinfo, freq: Rate.msec(36.10), q: 0.882762), CombFilter.new(soundinfo, freq: Rate.msec(33.27), q: 0.891443), CombFilter.new(soundinfo, freq: Rate.msec(30.15), q: 0.901117), ] @allpasss = [ AllPassFilter.create(soundinfo, freq: Rate.msec(5.0).freq(soundinfo), q: BiquadFilter::DEFAULT_Q), AllPassFilter.create(soundinfo, freq: Rate.msec(1.7).freq(soundinfo), q: BiquadFilter::DEFAULT_Q), ] @dry = Decibel.db(dry).mag @wet = Decibel.db(wet).mag end |
Instance Method Details
#process(input) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/audio_stream/fx/schroeder_reverb.rb', line 25 def process(input) window_size = input.window_size if @window_size!=window_size raise "window size is not match: impulse.size=#{@window_size} input.size=#{window_size}" end wets = @combs.map {|comb| comb.process(input) } wet = Buffer.merge(wets, average: true) @allpasss.each {|allpass| wet = allpass.process(wet) } streams = wet.streams.map.with_index {|wet_stream, i| dry_stream = input.streams[i] dst = Vdsp::DoubleArray.new(window_size) Vdsp::UnsafeDouble.vsmsma(dry_stream, 0, 1, @dry, wet_stream, 0, 1, @wet, dst, 0, 1, window_size) dst } Buffer.new(*streams) end |