audio_stream 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,7 @@ require 'audio_stream/fx/high_shelf_filter'
14
14
  require 'audio_stream/fx/peaking_filter'
15
15
  require 'audio_stream/fx/equalizer_2band'
16
16
  require 'audio_stream/fx/equalizer_3band'
17
+ require 'audio_stream/fx/graphic_equalizer'
17
18
  require 'audio_stream/fx/tremolo'
18
19
  require 'audio_stream/fx/delay'
19
20
  require 'audio_stream/fx/chorus'
@@ -107,7 +107,7 @@ module AudioStream
107
107
  {x: x, magnitude: mag_res, phase: phase_res}
108
108
  end
109
109
 
110
- def plot(width=1000)
110
+ def plot(width=500)
111
111
  data = plot_data(width)
112
112
 
113
113
  Plotly::Plot.new(
@@ -13,7 +13,7 @@ module AudioStream
13
13
  @high_filter.process!(input)
14
14
  end
15
15
 
16
- def plot(width=1000)
16
+ def plot(width=500)
17
17
  data1 = @low_filter.plot_data(width)
18
18
  data2 = @high_filter.plot_data(width)
19
19
 
@@ -15,7 +15,7 @@ module AudioStream
15
15
  @high_filter.process!(input)
16
16
  end
17
17
 
18
- def plot(width=1000)
18
+ def plot(width=500)
19
19
  data1 = @low_filter.plot_data(width)
20
20
  data2 = @mid_filter.plot_data(width)
21
21
  data3 = @high_filter.plot_data(width)
@@ -0,0 +1,43 @@
1
+ module AudioStream
2
+ module Fx
3
+ class GraphicEqualizer
4
+ include BangProcess
5
+
6
+ def initialize(soundinfo)
7
+ @soundinfo = soundinfo
8
+ @filters = []
9
+ end
10
+
11
+ def add(freq:, bandwidth: nil, gain:)
12
+ bandwidth ||= 1.0/Math.sqrt(2.0)
13
+ @filters << PeakingFilter.create(@soundinfo, freq: freq, bandwidth: bandwidth, gain: gain)
14
+ self
15
+ end
16
+
17
+ def process!(input)
18
+ @filters.each {|filter|
19
+ filter.process!(input)
20
+ }
21
+ end
22
+
23
+ def plot(width=500)
24
+ data_arr = @filters.map{|filter| filter.plot_data(width)}
25
+
26
+ data = {
27
+ x: data_arr[0][:x],
28
+ magnitude: data_arr.map{|d| d[:magnitude]}.transpose.map {|a| a.sum},
29
+ phase: data_arr.map{|d| d[:phase]}.transpose.map {|a| a.sum},
30
+ }
31
+
32
+ Plotly::Plot.new(
33
+ data: [{x: data[:x], y: data[:magnitude], name: 'Magnitude', yaxis: 'y1'}, {x: data[:x], y: data[:phase], name: 'Phase', yaxis: 'y2'}],
34
+ layout: {
35
+ xaxis: {title: 'Frequency (Hz)', type: 'log'},
36
+ yaxis: {side: 'left', title: 'Magnitude (dB)', showgrid: false},
37
+ yaxis2: {side: 'right', title: 'Phase (deg)', showgrid: false, overlaying: 'y'}
38
+ }
39
+ )
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,3 @@
1
1
  module AudioStream
2
- VERSION = "1.4.0"
2
+ VERSION = "1.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audio_stream
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshida Tetsuya
@@ -162,6 +162,7 @@ files:
162
162
  - lib/audio_stream/fx/distortion.rb
163
163
  - lib/audio_stream/fx/equalizer_2band.rb
164
164
  - lib/audio_stream/fx/equalizer_3band.rb
165
+ - lib/audio_stream/fx/graphic_equalizer.rb
165
166
  - lib/audio_stream/fx/hanning_window.rb
166
167
  - lib/audio_stream/fx/high_pass_filter.rb
167
168
  - lib/audio_stream/fx/high_shelf_filter.rb