synthesizer 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb327b711e81b9980b065cb446c278e1b74207ef4f2351646c1dc217c52925de
4
- data.tar.gz: 621c2d0970d3d5d5c2663bc56cce7ddc1e4c9e369b9fad56121a597d619a7637
3
+ metadata.gz: 4a95a731872fa95f54f2e2dd8d47644efd958a567488bd90301696135dab30c3
4
+ data.tar.gz: b0c112eafb0267e56f208c3b3d8bad22167157744653268ed7c0bead8efefd45
5
5
  SHA512:
6
- metadata.gz: '028d65fe391817a4e4c52e9dee9bea5803698e348d64a92fa41c239da7219fb60afe0dfb8b7e63fc5a96839544bd264ee3813dfa4c1ba4dd043d09ba9b104c5b'
7
- data.tar.gz: b39b4a1860af12bbe5c45c2d972ab4b41c0944ab849380cec8445a8a940a03ae92bad717f7fb50a9573de82a7512f2663e4ff642c021b157e9c34bc25766b8fd
6
+ metadata.gz: 6ec6733402383474e8aa8f1447d974f374e70bcb22f2e627f8de276491d714bebd00d688e60c9a3840893ed2c7ba9009670b3ad561b9044887df364d341e525c
7
+ data.tar.gz: e11cb3401bd994c946c6e62000d2b34e17e2f28c0086f62cb4b0138fcf7b1e6d8c961865cb1195e9cadb5cc2e59a4010f9851340247c9d43139c2a0282357657
@@ -20,6 +20,7 @@ require 'synthesizer/note'
20
20
  require 'synthesizer/note_perform'
21
21
  require 'synthesizer/unison'
22
22
  require 'synthesizer/processor'
23
+ require 'synthesizer/quality'
23
24
  require 'synthesizer/utils'
24
25
 
25
26
  module Synthesizer
@@ -6,12 +6,12 @@ module Synthesizer
6
6
  @bandwidth = ModulationValue.create(bandwidth)
7
7
  end
8
8
 
9
- def generator(note_perform)
9
+ def generator(note_perform, samplecount)
10
10
  soundinfo = note_perform.synth.soundinfo
11
11
  filter = AudioStream::Fx::BandPassFilter.new(soundinfo)
12
12
 
13
- freq_mod = ModulationValue.balance_generator(note_perform, @freq)
14
- bandwidth_mod = ModulationValue.balance_generator(note_perform, @bandwidth)
13
+ freq_mod = ModulationValue.balance_generator(note_perform, samplecount, @freq)
14
+ bandwidth_mod = ModulationValue.balance_generator(note_perform, samplecount, @bandwidth)
15
15
 
16
16
  -> {
17
17
  filter.update_coef(freq: freq_mod[], bandwidth: bandwidth_mod[])
@@ -6,12 +6,12 @@ module Synthesizer
6
6
  @q = ModulationValue.create(q)
7
7
  end
8
8
 
9
- def generator(note_perform)
9
+ def generator(note_perform, samplecount)
10
10
  soundinfo = note_perform.synth.soundinfo
11
11
  filter = AudioStream::Fx::HighPassFilter.new(soundinfo)
12
12
 
13
- freq_mod = ModulationValue.balance_generator(note_perform, @freq)
14
- q_mod = ModulationValue.balance_generator(note_perform, @q)
13
+ freq_mod = ModulationValue.balance_generator(note_perform, samplecount, @freq)
14
+ q_mod = ModulationValue.balance_generator(note_perform, samplecount, @q)
15
15
 
16
16
  -> {
17
17
  filter.update_coef(freq: freq_mod[], q: q_mod[])
@@ -7,13 +7,13 @@ module Synthesizer
7
7
  @gain = ModulationValue.create(gain)
8
8
  end
9
9
 
10
- def generator(note_perform)
10
+ def generator(note_perform, samplecount)
11
11
  soundinfo = note_perform.synth.soundinfo
12
12
  filter = AudioStream::Fx::HighShelfFilter.new(soundinfo)
13
13
 
14
- freq_mod = ModulationValue.balance_generator(note_perform, @freq)
15
- q_mod = ModulationValue.balance_generator(note_perform, @q)
16
- gain_mod = ModulationValue.balance_generator(note_perform, @gain)
14
+ freq_mod = ModulationValue.balance_generator(note_perform, samplecount, @freq)
15
+ q_mod = ModulationValue.balance_generator(note_perform, samplecount, @q)
16
+ gain_mod = ModulationValue.balance_generator(note_perform, samplecount, @gain)
17
17
 
18
18
  -> {
19
19
  filter.update_coef(freq: freq_mod[], q: q_mod[], gain: gain_mod[])
@@ -6,12 +6,12 @@ module Synthesizer
6
6
  @q = ModulationValue.create(q)
7
7
  end
8
8
 
9
- def generator(note_perform)
9
+ def generator(note_perform, samplecount)
10
10
  soundinfo = note_perform.synth.soundinfo
11
11
  filter = AudioStream::Fx::LowPassFilter.new(soundinfo)
12
12
 
13
- freq_mod = ModulationValue.balance_generator(note_perform, @freq)
14
- q_mod = ModulationValue.balance_generator(note_perform, @q)
13
+ freq_mod = ModulationValue.balance_generator(note_perform, samplecount, @freq)
14
+ q_mod = ModulationValue.balance_generator(note_perform, samplecount, @q)
15
15
 
16
16
  -> {
17
17
  filter.update_coef(freq: freq_mod[], q: q_mod[])
@@ -7,13 +7,13 @@ module Synthesizer
7
7
  @gain = ModulationValue.create(gain)
8
8
  end
9
9
 
10
- def generator(note_perform)
10
+ def generator(note_perform, samplecount)
11
11
  soundinfo = note_perform.synth.soundinfo
12
12
  filter = AudioStream::Fx::LowShelfFilter.new(soundinfo)
13
13
 
14
- freq_mod = ModulationValue.balance_generator(note_perform, @freq)
15
- q_mod = ModulationValue.balance_generator(note_perform, @q)
16
- gain_mod = ModulationValue.balance_generator(note_perform, @gain)
14
+ freq_mod = ModulationValue.balance_generator(note_perform, samplecount, @freq)
15
+ q_mod = ModulationValue.balance_generator(note_perform, samplecount, @q)
16
+ gain_mod = ModulationValue.balance_generator(note_perform, samplecount, @gain)
17
17
 
18
18
  -> {
19
19
  filter.update_coef(freq: freq_mod[], q: q_mod[], gain: gain_mod[])
@@ -5,9 +5,9 @@ module Synthesizer
5
5
  @filters = filters
6
6
  end
7
7
 
8
- def generator(note_perform)
8
+ def generator(note_perform, samplecount)
9
9
  filter_mods = @filters.map {|filter|
10
- filter.generator(note_perform)
10
+ filter.generator(note_perform, samplecount)
11
11
  }
12
12
 
13
13
  -> {
@@ -7,13 +7,13 @@ module Synthesizer
7
7
  @gain = ModulationValue.create(gain)
8
8
  end
9
9
 
10
- def generator(note_perform)
10
+ def generator(note_perform, samplecount)
11
11
  soundinfo = note_perform.synth.soundinfo
12
12
  filter = AudioStream::Fx::LowShelfFilter.new(soundinfo)
13
13
 
14
- freq_mod = ModulationValue.balance_generator(note_perform, @freq)
15
- bandwidth_mod = ModulationValue.balance_generator(note_perform, @bandwidth)
16
- gain_mod = ModulationValue.balance_generator(note_perform, @gain)
14
+ freq_mod = ModulationValue.balance_generator(note_perform, samplecount, @freq)
15
+ bandwidth_mod = ModulationValue.balance_generator(note_perform, samplecount, @bandwidth)
16
+ gain_mod = ModulationValue.balance_generator(note_perform, samplecount, @gain)
17
17
 
18
18
  -> {
19
19
  filter.update_coef(freq: freq_mod[], bandwidth: bandwidth_mod[], gain: gain_mod[])
@@ -5,9 +5,9 @@ module Synthesizer
5
5
  @filters = filters
6
6
  end
7
7
 
8
- def generator(note_perform)
8
+ def generator(note_perform, samplecount)
9
9
  filter_mods = @filters.map {|filter|
10
- filter.generator(note_perform)
10
+ filter.generator(note_perform, samplecount)
11
11
  }
12
12
 
13
13
  -> {
@@ -21,10 +21,10 @@ module Synthesizer
21
21
  @release_curve = release_curve
22
22
  end
23
23
 
24
- def note_on_envelope(soundinfo, sustain: false, &block)
24
+ def note_on_envelope(soundinfo, samplecount, sustain: false, &block)
25
25
  Enumerator.new do |yld|
26
26
  # attack
27
- attack_len = @attack.frame(soundinfo).to_i
27
+ attack_len = (@attack.sample(soundinfo) / samplecount).to_i
28
28
  attack_len.times {|i|
29
29
  x = i.to_f / attack_len
30
30
  y = @attack_curve[x]
@@ -32,12 +32,12 @@ module Synthesizer
32
32
  }
33
33
 
34
34
  # hold
35
- @hold.frame(soundinfo).to_i.times {|i|
35
+ (@hold.sample(soundinfo) / samplecount).to_i.times {|i|
36
36
  yld << 1.0
37
37
  }
38
38
 
39
39
  # decay
40
- decay_len = @decay.frame(soundinfo).to_i
40
+ decay_len = (@decay.sample(soundinfo) / samplecount).to_i
41
41
  decay_len.times {|i|
42
42
  x = i.to_f / decay_len
43
43
  y = 1.0 - @sustain_curve[x] * (1.0 - @sustain)
@@ -53,10 +53,10 @@ module Synthesizer
53
53
  end.each(&block)
54
54
  end
55
55
 
56
- def note_off_envelope(soundinfo, sustain: false, &block)
56
+ def note_off_envelope(soundinfo, samplecount, sustain: false, &block)
57
57
  Enumerator.new do |yld|
58
58
  # release
59
- release_len = @release.frame(soundinfo).to_i
59
+ release_len = (@release.sample(soundinfo) / samplecount).to_i
60
60
  release_len.times {|i|
61
61
  x = i.to_f / release_len
62
62
  y = 1.0 - @release_curve[x]
@@ -72,11 +72,11 @@ module Synthesizer
72
72
  end.each(&block)
73
73
  end
74
74
 
75
- def generator(note_perform, release_sustain:)
75
+ def generator(note_perform, samplecount, release_sustain:)
76
76
  soundinfo = note_perform.synth.soundinfo
77
77
 
78
- note_on = note_on_envelope(soundinfo, sustain: true)
79
- note_off = note_off_envelope(soundinfo, sustain: release_sustain)
78
+ note_on = note_on_envelope(soundinfo, samplecount, sustain: true)
79
+ note_off = note_off_envelope(soundinfo, samplecount, sustain: release_sustain)
80
80
  last = 0.0
81
81
 
82
82
  -> {
@@ -89,17 +89,17 @@ module Synthesizer
89
89
  end
90
90
 
91
91
 
92
- def amp_generator(note_perform, depth, &block)
92
+ def amp_generator(note_perform, samplecount, depth, &block)
93
93
  bottom = 1.0 - depth
94
- gen = generator(note_perform, release_sustain: 0.0<bottom)
94
+ gen = generator(note_perform, samplecount, release_sustain: 0.0<bottom)
95
95
 
96
96
  -> {
97
97
  gen[] * depth + bottom
98
98
  }
99
99
  end
100
100
 
101
- def balance_generator(note_perform, depth, &block)
102
- gen = generator(note_perform, release_sustain: true)
101
+ def balance_generator(note_perform, samplecount, depth, &block)
102
+ gen = generator(note_perform, samplecount, release_sustain: true)
103
103
 
104
104
  -> {
105
105
  gen[] * depth
@@ -26,9 +26,9 @@ module Synthesizer
26
26
  @diff = target - @current
27
27
  end
28
28
 
29
- def generator(note_perform)
29
+ def generator(note_perform, samplecount)
30
30
  soundinfo = note_perform.synth.soundinfo
31
- rate = @time.frame(soundinfo)
31
+ rate = @time.sample(soundinfo) / samplecount
32
32
 
33
33
  -> {
34
34
  ret = nil
@@ -61,8 +61,8 @@ module Synthesizer
61
61
  }
62
62
  end
63
63
 
64
- def balance_generator(note_perform, depth)
65
- gen = generator(note_perform)
64
+ def balance_generator(note_perform, samplecount, depth)
65
+ gen = generator(note_perform, samplecount)
66
66
 
67
67
  -> {
68
68
  gen[] * depth
@@ -17,20 +17,20 @@ module Synthesizer
17
17
  @rate = rate
18
18
  end
19
19
 
20
- def generator(note_perform, &block)
20
+ def generator(note_perform, samplecount, &block)
21
21
  soundinfo = note_perform.synth.soundinfo
22
22
  hz = @rate.freq(soundinfo)
23
23
 
24
24
  Enumerator.new do |yld|
25
- pos = ShapePos.new(soundinfo.samplerate, @phase)
25
+ pos = ShapePos.new(soundinfo.samplerate / samplecount, @phase)
26
26
 
27
27
  # delay
28
- @delay.frame(soundinfo).to_i.times {|i|
28
+ (@delay.sample(soundinfo) / samplecount).to_i.times {|i|
29
29
  yld << 0.0
30
30
  }
31
31
 
32
32
  # attack
33
- attack_len = @attack.frame(soundinfo).to_i
33
+ attack_len = (@attack.sample(soundinfo) / samplecount).to_i
34
34
  attack_len.times {|i|
35
35
  x = i.to_f / attack_len
36
36
  y = @attack_curve[x]
@@ -45,9 +45,9 @@ module Synthesizer
45
45
  end.each(&block)
46
46
  end
47
47
 
48
- def amp_generator(note_perform, depth, &block)
48
+ def amp_generator(note_perform, samplecount, depth, &block)
49
49
  bottom = 1.0 - depth
50
- gen = generator(note_perform)
50
+ gen = generator(note_perform, samplecount)
51
51
 
52
52
  -> {
53
53
  val = (gen.next + 1) / 2
@@ -55,8 +55,8 @@ module Synthesizer
55
55
  }
56
56
  end
57
57
 
58
- def balance_generator(note_perform, depth, &block)
59
- gen = generator(note_perform)
58
+ def balance_generator(note_perform, samplecount, depth, &block)
59
+ gen = generator(note_perform, samplecount)
60
60
 
61
61
  -> {
62
62
  gen.next * depth
@@ -35,7 +35,7 @@ module Synthesizer
35
35
  end
36
36
  end
37
37
 
38
- def self.amp_generator(note_perform, *modvals)
38
+ def self.amp_generator(note_perform, samplecount, *modvals)
39
39
  modvals = modvals.flatten.compact
40
40
 
41
41
  # value
@@ -45,7 +45,7 @@ module Synthesizer
45
45
  mods = []
46
46
  modvals.each {|modval|
47
47
  modval.mods.each {|mod, depth|
48
- mods << mod.amp_generator(note_perform, depth)
48
+ mods << mod.amp_generator(note_perform, samplecount, depth)
49
49
  }
50
50
  }
51
51
 
@@ -55,7 +55,7 @@ module Synthesizer
55
55
  }
56
56
  end
57
57
 
58
- def self.balance_generator(note_perform, *modvals, center: 0)
58
+ def self.balance_generator(note_perform, samplecount, *modvals, center: 0)
59
59
  modvals = modvals.flatten.compact
60
60
 
61
61
  # value
@@ -66,7 +66,7 @@ module Synthesizer
66
66
  mods = []
67
67
  modvals.each {|modval|
68
68
  modval.mods.each {|mod, depth|
69
- mods << mod.balance_generator(note_perform, depth)
69
+ mods << mod.balance_generator(note_perform, samplecount, depth)
70
70
  }
71
71
  }
72
72
 
@@ -6,6 +6,7 @@ module Synthesizer
6
6
  attr_reader :amplifier
7
7
  attr_reader :processor
8
8
 
9
+ attr_reader :quality
9
10
  attr_reader :soundinfo
10
11
 
11
12
  attr_reader :glide
@@ -15,15 +16,17 @@ module Synthesizer
15
16
  # @param filter [Synthesizer::Filter] filter
16
17
  # @param amplifier [Synthesizer::Amplifier] amplifier
17
18
  # @param glide [AudioStream::Rate] glide time sec (0.0~)
19
+ # @param quality [Synthesizer::Quality] processor quality
18
20
  # @param soundinfo [AudioStream::SoundInfo]
19
- def initialize(oscillators:, filter: nil, amplifier:, glide: AudioStream::Rate.sec(0.1), soundinfo:)
21
+ def initialize(oscillators:, filter: nil, amplifier:, glide: AudioStream::Rate.sec(0.1), quality: Quality::LOW, soundinfo:)
20
22
  @oscillators = [oscillators].flatten.compact
21
23
  @filter = filter
22
24
  @amplifier = amplifier
23
25
 
26
+ @quality = quality
24
27
  @soundinfo = soundinfo
25
28
 
26
- @processor = Processor.new
29
+ @processor = Processor.create(quality)
27
30
  @note_nums = []
28
31
  @perform = nil
29
32
  @glide = Modulation::Glide.new(time: glide)
@@ -6,6 +6,7 @@ module Synthesizer
6
6
  attr_reader :amplifier
7
7
  attr_reader :processor
8
8
 
9
+ attr_reader :quality
9
10
  attr_reader :soundinfo
10
11
 
11
12
  attr_reader :glide
@@ -14,15 +15,17 @@ module Synthesizer
14
15
  # @param oscillators [Synthesizer::Oscillator] Oscillator
15
16
  # @param filter [Synthesizer::Filter] filter
16
17
  # @param amplifier [Synthesizer::Amplifier] amplifier
18
+ # @param quality [Synthesizer::Quality] processor quality
17
19
  # @param soundinfo [AudioStream::SoundInfo]
18
- def initialize(oscillators:, filter: nil, amplifier:, soundinfo:)
20
+ def initialize(oscillators:, filter: nil, amplifier:, quality: Quality::LOW, soundinfo:)
19
21
  @oscillators = [oscillators].flatten.compact
20
22
  @filter = filter
21
23
  @amplifier = amplifier
22
24
 
25
+ @quality = quality
23
26
  @soundinfo = soundinfo
24
27
 
25
- @processor = Processor.new
28
+ @processor = Processor.create(quality)
26
29
  @performs = {}
27
30
  @pitch_bend = 0.0
28
31
  end
@@ -1,55 +1,10 @@
1
- module Synthesizer
2
- class Processor
3
- def generator(osc, note_perform)
4
- synth = note_perform.synth
5
- filter = synth.filter
6
- amp = synth.amplifier
7
-
8
- # Oscillator, Amplifier
9
- volume_mod = ModulationValue.amp_generator(note_perform, osc.volume, amp.volume)
10
- pan_mod = ModulationValue.balance_generator(note_perform, osc.pan, amp.pan)
11
- tune_semis_mod = ModulationValue.balance_generator(note_perform, osc.tune_semis, amp.tune_semis, synth.glide&.to_modval)
12
- tune_cents_mod = ModulationValue.balance_generator(note_perform, osc.tune_cents, amp.tune_cents)
13
-
14
- sym_mod = ModulationValue.balance_generator(note_perform, osc.sym)
15
- sync_mod = ModulationValue.balance_generator(note_perform, osc.sync)
16
-
17
- uni_num_mod = ModulationValue.balance_generator(note_perform, osc.uni_num, amp.uni_num, center: 1.0)
18
- uni_detune_mod = ModulationValue.balance_generator(note_perform, osc.uni_detune, amp.uni_detune)
19
- uni_stereo_mod = ModulationValue.balance_generator(note_perform, osc.uni_stereo, amp.uni_stereo)
20
-
21
- unison = Unison.new(note_perform, osc.source, osc.phase)
22
-
23
- # Filter
24
- filter_mod = nil
25
- if filter
26
- filter_mod = filter.generator(note_perform)
27
- end
1
+ require 'synthesizer/processor/low'
2
+ require 'synthesizer/processor/high'
28
3
 
29
- -> {
30
- # Oscillator, Amplifier
31
- volume = volume_mod[] * note_perform.velocity
32
- pan = pan_mod[]
33
- tune_semis = tune_semis_mod[] + synth.pitch_bend
34
- tune_cents = tune_cents_mod[]
35
-
36
- sym = sym_mod[]
37
- sync = sync_mod[]
38
-
39
- uni_num = uni_num_mod[]
40
- uni_detune = uni_detune_mod[]
41
- uni_stereo = uni_stereo_mod[]
42
-
43
- buf = unison.next(uni_num, uni_detune, uni_stereo, volume, pan, tune_semis, tune_cents, sym, sync)
44
-
45
- # Filter
46
- if filter_mod
47
- filter_fx = filter_mod[]
48
- buf = filter_fx.process(buf)
49
- end
50
-
51
- buf
52
- }
4
+ module Synthesizer
5
+ module Processor
6
+ def self.create(quality)
7
+ const_get(quality, false).new
53
8
  end
54
9
  end
55
10
  end
@@ -0,0 +1,63 @@
1
+ module Synthesizer
2
+ module Processor
3
+ class High
4
+ def generator(osc, note_perform)
5
+ synth = note_perform.synth
6
+ filter = synth.filter
7
+ amp = synth.amplifier
8
+
9
+ samplecount = synth.soundinfo.window_size.to_f
10
+
11
+ # Oscillator, Amplifier
12
+ volume_mod = ModulationValue.amp_generator(note_perform, 1, osc.volume, amp.volume)
13
+ pan_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.pan, amp.pan)
14
+ tune_semis_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.tune_semis, amp.tune_semis, synth.glide&.to_modval)
15
+ tune_cents_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.tune_cents, amp.tune_cents)
16
+
17
+ sym_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.sym)
18
+ sync_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.sync)
19
+
20
+ uni_num_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.uni_num, amp.uni_num, center: 1.0)
21
+ uni_detune_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.uni_detune, amp.uni_detune)
22
+ uni_stereo_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.uni_stereo, amp.uni_stereo)
23
+
24
+ unison = Unison.new(note_perform, osc.source, osc.phase)
25
+
26
+ # Filter
27
+ filter_mod = nil
28
+ if filter
29
+ filter_mod = filter.generator(note_perform, samplecount)
30
+ end
31
+
32
+ -> {
33
+ # Oscillator, Amplifier
34
+ volume = Vdsp::DoubleArray.create(
35
+ samplecount.to_i.times.map {|i|
36
+ volume_mod[] * note_perform.velocity
37
+ }
38
+ )
39
+ pan = pan_mod[]
40
+ tune_semis = tune_semis_mod[] + synth.pitch_bend
41
+ tune_cents = tune_cents_mod[]
42
+
43
+ sym = sym_mod[]
44
+ sync = sync_mod[]
45
+
46
+ uni_num = uni_num_mod[]
47
+ uni_detune = uni_detune_mod[]
48
+ uni_stereo = uni_stereo_mod[]
49
+
50
+ buf = unison.next(uni_num, uni_detune, uni_stereo, volume, pan, tune_semis, tune_cents, sym, sync)
51
+
52
+ # Filter
53
+ if filter_mod
54
+ filter_fx = filter_mod[]
55
+ buf = filter_fx.process(buf)
56
+ end
57
+
58
+ buf
59
+ }
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,59 @@
1
+ module Synthesizer
2
+ module Processor
3
+ class Low
4
+ def generator(osc, note_perform)
5
+ synth = note_perform.synth
6
+ filter = synth.filter
7
+ amp = synth.amplifier
8
+
9
+ samplecount = synth.soundinfo.window_size.to_f
10
+
11
+ # Oscillator, Amplifier
12
+ volume_mod = ModulationValue.amp_generator(note_perform, samplecount, osc.volume, amp.volume)
13
+ pan_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.pan, amp.pan)
14
+ tune_semis_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.tune_semis, amp.tune_semis, synth.glide&.to_modval)
15
+ tune_cents_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.tune_cents, amp.tune_cents)
16
+
17
+ sym_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.sym)
18
+ sync_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.sync)
19
+
20
+ uni_num_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.uni_num, amp.uni_num, center: 1.0)
21
+ uni_detune_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.uni_detune, amp.uni_detune)
22
+ uni_stereo_mod = ModulationValue.balance_generator(note_perform, samplecount, osc.uni_stereo, amp.uni_stereo)
23
+
24
+ unison = Unison.new(note_perform, osc.source, osc.phase)
25
+
26
+ # Filter
27
+ filter_mod = nil
28
+ if filter
29
+ filter_mod = filter.generator(note_perform, samplecount)
30
+ end
31
+
32
+ -> {
33
+ # Oscillator, Amplifier
34
+ volume = volume_mod[] * note_perform.velocity
35
+ pan = pan_mod[]
36
+ tune_semis = tune_semis_mod[] + synth.pitch_bend
37
+ tune_cents = tune_cents_mod[]
38
+
39
+ sym = sym_mod[]
40
+ sync = sync_mod[]
41
+
42
+ uni_num = uni_num_mod[]
43
+ uni_detune = uni_detune_mod[]
44
+ uni_stereo = uni_stereo_mod[]
45
+
46
+ buf = unison.next(uni_num, uni_detune, uni_stereo, volume, pan, tune_semis, tune_cents, sym, sync)
47
+
48
+ # Filter
49
+ if filter_mod
50
+ filter_fx = filter_mod[]
51
+ buf = filter_fx.process(buf)
52
+ end
53
+
54
+ buf
55
+ }
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,6 @@
1
+ module Synthesizer
2
+ module Quality
3
+ HIGH = :High
4
+ LOW = :Low
5
+ end
6
+ end
@@ -25,9 +25,9 @@ module Synthesizer
25
25
  l_gain, r_gain = Utils.panning(pan)
26
26
  hz = @note_perform.note.hz(semis: tune_semis, cents: tune_cents)
27
27
 
28
- @source.next(context, AudioStream::Rate.freq(hz), sym, sync, l_gain * volume, r_gain * volume)
28
+ buffer = @source.next(context, AudioStream::Rate.freq(hz), sym, sync, l_gain, r_gain)
29
29
  else
30
- uni_num.ceil.times.map {|i|
30
+ buffer = uni_num.ceil.times.map {|i|
31
31
  context = @source_contexts[i]
32
32
 
33
33
  uni_volume = 1.0
@@ -44,9 +44,13 @@ module Synthesizer
44
44
  l_gain, r_gain = Utils.panning(pan + diff_pan)
45
45
  hz = @note_perform.note.hz(semis: tune_semis, cents: tune_cents + detune_cents)
46
46
 
47
- @source.next(context, AudioStream::Rate.freq(hz), sym, sync, l_gain * volume * uni_volume / uni_num, r_gain * volume * uni_volume / uni_num)
47
+ @source.next(context, AudioStream::Rate.freq(hz), sym, sync, l_gain * uni_volume / uni_num, r_gain * uni_volume / uni_num)
48
48
  }.inject(:+)
49
49
  end
50
+
51
+ AudioStream::Buffer.new(*buffer.streams.map {|stream|
52
+ stream * volume
53
+ })
50
54
  end
51
55
  end
52
56
  end
@@ -1,3 +1,3 @@
1
1
  module Synthesizer
2
- VERSION = "3.2.0"
2
+ VERSION = "3.3.0"
3
3
  end
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "rake", "~> 12.0"
31
31
  spec.add_development_dependency "minitest", "~> 5.0"
32
32
 
33
- spec.add_dependency "audio_stream", ">= 3.3.1"
33
+ spec.add_dependency "audio_stream", ">= 3.3.2"
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synthesizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshida Tetsuya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-02 00:00:00.000000000 Z
11
+ date: 2019-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 3.3.1
61
+ version: 3.3.2
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 3.3.1
68
+ version: 3.3.2
69
69
  description: Synthesizer implemented in Ruby.
70
70
  email:
71
71
  - yoshida.eth0@gmail.com
@@ -123,6 +123,9 @@ files:
123
123
  - lib/synthesizer/oscillator_source/pulse.rb
124
124
  - lib/synthesizer/poly_synth.rb
125
125
  - lib/synthesizer/processor.rb
126
+ - lib/synthesizer/processor/high.rb
127
+ - lib/synthesizer/processor/low.rb
128
+ - lib/synthesizer/quality.rb
126
129
  - lib/synthesizer/shape.rb
127
130
  - lib/synthesizer/shape_pos.rb
128
131
  - lib/synthesizer/step_editor.rb