Class: AudioStream::Fx::HanningWindow

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/audio_stream/fx/hanning_window.rb

Instance Method Summary collapse

Instance Method Details

#process(input) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/audio_stream/fx/hanning_window.rb', line 6

def process(input)
  #window_size = input.window_size
  #window_max = input.window_size - 1
  #channels = input.channels

  #period = 2 * Math::PI / window_max

  streams = input.streams.map {|stream|
    #stream.map.with_index {|f, i|
    #  f * (0.5 - 0.5 * Math.cos(i * period))
    #}
    stream * self.window(input.window_size)
  }

  Buffer.new(*streams)
end

#window(size) ⇒ Object



23
24
25
26
# File 'lib/audio_stream/fx/hanning_window.rb', line 23

def window(size)
  @window ||= {}
  @window[size] ||= Vdsp::DoubleArray.hann_window(size, Vdsp::FULL_WINDOW)
end