Class: AudioStream::Fx::Distortion
- Inherits:
-
Object
- Object
- AudioStream::Fx::Distortion
- Defined in:
- lib/audio_stream/fx/distortion.rb
Instance Method Summary collapse
-
#initialize(gain: 40.0, level: -20.0)) ⇒ Distortion
constructor
A new instance of Distortion.
- #process(input) ⇒ Object
Constructor Details
#initialize(gain: 40.0, level: -20.0)) ⇒ Distortion
Returns a new instance of Distortion.
6 7 8 9 |
# File 'lib/audio_stream/fx/distortion.rb', line 6 def initialize(gain: 40.0, level: -20.0) @gain = Decibel.db(gain).mag @level = Decibel.db(level).mag end |
Instance Method Details
#process(input) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/audio_stream/fx/distortion.rb', line 11 def process(input) streams = input.streams.map {|stream| dst = Vdsp::DoubleArray.new(input.window_size) Vdsp::UnsafeDouble.vclip(stream * @gain, 0, 1, -1.0, 1.0, dst, 0, 1, input.window_size) dst * @level } Buffer.new(*streams) end |