synthesizer 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/synthesizer/filter/band_pass_filter.rb +9 -11
- data/lib/synthesizer/filter/high_pass_filter.rb +9 -11
- data/lib/synthesizer/filter/high_shelf_filter.rb +10 -12
- data/lib/synthesizer/filter/low_pass_filter.rb +9 -11
- data/lib/synthesizer/filter/low_shelf_filter.rb +10 -12
- data/lib/synthesizer/filter/parallel.rb +8 -10
- data/lib/synthesizer/filter/peaking_filter.rb +10 -12
- data/lib/synthesizer/filter/serial.rb +8 -10
- data/lib/synthesizer/modulation/adsr.rb +21 -21
- data/lib/synthesizer/modulation/glide.rb +32 -28
- data/lib/synthesizer/modulation/lfo.rb +9 -6
- data/lib/synthesizer/modulation_value.rb +8 -12
- data/lib/synthesizer/note_perform.rb +1 -1
- data/lib/synthesizer/processor/high.rb +82 -84
- data/lib/synthesizer/processor/low.rb +67 -69
- data/lib/synthesizer/version.rb +1 -1
- data/synthesizer.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed8a308cdf0bcb0baf27daffd40c86c4998c8ca5d49ee90d1c0a2aac7a69c64d
|
4
|
+
data.tar.gz: 46fbff7561bb5883dac304b083bed46bd6690e840096cd7c4b48f04d32542bac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e9444d9132322cb3382e809a77a4803e895f5dd5aedf4de86272f616e27abc525734124d915cd1dd47f24e98e7b9d31716c88783337bc18f47e1b09d4e12ea3
|
7
|
+
data.tar.gz: 2141b9541d1700616b9d131887218727284210b28488dd9007d08adfd05190320993099145d016b0c84b75cf19a61e74c3bcdf8b0f19249d260d7c05b7e6697d
|
@@ -6,19 +6,17 @@ module Synthesizer
|
|
6
6
|
@bandwidth = ModulationValue.create(bandwidth)
|
7
7
|
end
|
8
8
|
|
9
|
-
def generator(note_perform, framerate
|
10
|
-
|
11
|
-
|
12
|
-
filter = AudioStream::Fx::BandPassFilter.new(soundinfo)
|
9
|
+
def generator(note_perform, framerate)
|
10
|
+
soundinfo = note_perform.synth.soundinfo
|
11
|
+
filter = AudioStream::Fx::BandPassFilter.new(soundinfo)
|
13
12
|
|
14
|
-
|
15
|
-
|
13
|
+
freq_mod = ModulationValue.balance_generator(note_perform, framerate, @freq)
|
14
|
+
bandwidth_mod = ModulationValue.balance_generator(note_perform, framerate, @bandwidth)
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end.each(&block)
|
16
|
+
-> {
|
17
|
+
filter.update_coef(freq: freq_mod[], bandwidth: bandwidth_mod[])
|
18
|
+
filter
|
19
|
+
}
|
22
20
|
end
|
23
21
|
end
|
24
22
|
end
|
@@ -6,19 +6,17 @@ module Synthesizer
|
|
6
6
|
@q = ModulationValue.create(q)
|
7
7
|
end
|
8
8
|
|
9
|
-
def generator(note_perform, framerate
|
10
|
-
|
11
|
-
|
12
|
-
filter = AudioStream::Fx::HighPassFilter.new(soundinfo)
|
9
|
+
def generator(note_perform, framerate)
|
10
|
+
soundinfo = note_perform.synth.soundinfo
|
11
|
+
filter = AudioStream::Fx::HighPassFilter.new(soundinfo)
|
13
12
|
|
14
|
-
|
15
|
-
|
13
|
+
freq_mod = ModulationValue.balance_generator(note_perform, framerate, @freq)
|
14
|
+
q_mod = ModulationValue.balance_generator(note_perform, framerate, @q)
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end.each(&block)
|
16
|
+
-> {
|
17
|
+
filter.update_coef(freq: freq_mod[], q: q_mod[])
|
18
|
+
filter
|
19
|
+
}
|
22
20
|
end
|
23
21
|
end
|
24
22
|
end
|
@@ -7,20 +7,18 @@ module Synthesizer
|
|
7
7
|
@gain = ModulationValue.create(gain)
|
8
8
|
end
|
9
9
|
|
10
|
-
def generator(note_perform, framerate
|
11
|
-
|
12
|
-
|
13
|
-
filter = AudioStream::Fx::HighShelfFilter.new(soundinfo)
|
10
|
+
def generator(note_perform, framerate)
|
11
|
+
soundinfo = note_perform.synth.soundinfo
|
12
|
+
filter = AudioStream::Fx::HighShelfFilter.new(soundinfo)
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
freq_mod = ModulationValue.balance_generator(note_perform, framerate, @freq)
|
15
|
+
q_mod = ModulationValue.balance_generator(note_perform, framerate, @q)
|
16
|
+
gain_mod = ModulationValue.balance_generator(note_perform, framerate, @gain)
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end.each(&block)
|
18
|
+
-> {
|
19
|
+
filter.update_coef(freq: freq_mod[], q: q_mod[], gain: gain_mod[])
|
20
|
+
filter
|
21
|
+
}
|
24
22
|
end
|
25
23
|
end
|
26
24
|
end
|
@@ -6,19 +6,17 @@ module Synthesizer
|
|
6
6
|
@q = ModulationValue.create(q)
|
7
7
|
end
|
8
8
|
|
9
|
-
def generator(note_perform, framerate
|
10
|
-
|
11
|
-
|
12
|
-
filter = AudioStream::Fx::LowPassFilter.new(soundinfo)
|
9
|
+
def generator(note_perform, framerate)
|
10
|
+
soundinfo = note_perform.synth.soundinfo
|
11
|
+
filter = AudioStream::Fx::LowPassFilter.new(soundinfo)
|
13
12
|
|
14
|
-
|
15
|
-
|
13
|
+
freq_mod = ModulationValue.balance_generator(note_perform, framerate, @freq)
|
14
|
+
q_mod = ModulationValue.balance_generator(note_perform, framerate, @q)
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end.each(&block)
|
16
|
+
-> {
|
17
|
+
filter.update_coef(freq: freq_mod[], q: q_mod[])
|
18
|
+
filter
|
19
|
+
}
|
22
20
|
end
|
23
21
|
end
|
24
22
|
end
|
@@ -7,20 +7,18 @@ module Synthesizer
|
|
7
7
|
@gain = ModulationValue.create(gain)
|
8
8
|
end
|
9
9
|
|
10
|
-
def generator(note_perform, framerate
|
11
|
-
|
12
|
-
|
13
|
-
filter = AudioStream::Fx::LowShelfFilter.new(soundinfo)
|
10
|
+
def generator(note_perform, framerate)
|
11
|
+
soundinfo = note_perform.synth.soundinfo
|
12
|
+
filter = AudioStream::Fx::LowShelfFilter.new(soundinfo)
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
freq_mod = ModulationValue.balance_generator(note_perform, framerate, @freq)
|
15
|
+
q_mod = ModulationValue.balance_generator(note_perform, framerate, @q)
|
16
|
+
gain_mod = ModulationValue.balance_generator(note_perform, framerate, @gain)
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end.each(&block)
|
18
|
+
-> {
|
19
|
+
filter.update_coef(freq: freq_mod[], q: q_mod[], gain: gain_mod[])
|
20
|
+
filter
|
21
|
+
}
|
24
22
|
end
|
25
23
|
end
|
26
24
|
end
|
@@ -5,17 +5,15 @@ module Synthesizer
|
|
5
5
|
@filters = filters
|
6
6
|
end
|
7
7
|
|
8
|
-
def generator(note_perform, framerate
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
}
|
8
|
+
def generator(note_perform, framerate)
|
9
|
+
filter_mods = @filters.map {|filter|
|
10
|
+
filter.generator(note_perform, framerate)
|
11
|
+
}
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end.each(&block)
|
13
|
+
-> {
|
14
|
+
fxs = filter_mods.map(&:[])
|
15
|
+
Fx.new(fxs)
|
16
|
+
}
|
19
17
|
end
|
20
18
|
|
21
19
|
class Fx
|
@@ -7,20 +7,18 @@ module Synthesizer
|
|
7
7
|
@gain = ModulationValue.create(gain)
|
8
8
|
end
|
9
9
|
|
10
|
-
def generator(note_perform, framerate
|
11
|
-
|
12
|
-
|
13
|
-
filter = AudioStream::Fx::LowShelfFilter.new(soundinfo)
|
10
|
+
def generator(note_perform, framerate)
|
11
|
+
soundinfo = note_perform.synth.soundinfo
|
12
|
+
filter = AudioStream::Fx::LowShelfFilter.new(soundinfo)
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
freq_mod = ModulationValue.balance_generator(note_perform, framerate, @freq)
|
15
|
+
bandwidth_mod = ModulationValue.balance_generator(note_perform, framerate, @bandwidth)
|
16
|
+
gain_mod = ModulationValue.balance_generator(note_perform, framerate, @gain)
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end.each(&block)
|
18
|
+
-> {
|
19
|
+
filter.update_coef(freq: freq_mod[], bandwidth: bandwidth_mod[], gain: gain_mod[])
|
20
|
+
filter
|
21
|
+
}
|
24
22
|
end
|
25
23
|
end
|
26
24
|
end
|
@@ -5,17 +5,15 @@ module Synthesizer
|
|
5
5
|
@filters = filters
|
6
6
|
end
|
7
7
|
|
8
|
-
def generator(note_perform, framerate
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
}
|
8
|
+
def generator(note_perform, framerate)
|
9
|
+
filter_mods = @filters.map {|filter|
|
10
|
+
filter.generator(note_perform, framerate)
|
11
|
+
}
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end.each(&block)
|
13
|
+
-> {
|
14
|
+
fxs = filter_mods.map(&:[])
|
15
|
+
Fx.new(fxs)
|
16
|
+
}
|
19
17
|
end
|
20
18
|
|
21
19
|
class Fx
|
@@ -73,36 +73,36 @@ module Synthesizer
|
|
73
73
|
end.each(&block)
|
74
74
|
end
|
75
75
|
|
76
|
-
def generator(note_perform, framerate, release_sustain
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
89
|
-
}
|
90
|
-
end.each(&block)
|
76
|
+
def generator(note_perform, framerate, release_sustain:)
|
77
|
+
note_on = note_on_envelope(framerate, sustain: true)
|
78
|
+
note_off = note_off_envelope(framerate, sustain: release_sustain)
|
79
|
+
last = 0.0
|
80
|
+
|
81
|
+
-> {
|
82
|
+
if note_perform.note_on?
|
83
|
+
last = note_on.next
|
84
|
+
else
|
85
|
+
note_off.next * last
|
86
|
+
end
|
87
|
+
}
|
91
88
|
end
|
92
89
|
|
93
90
|
|
94
91
|
def amp_generator(note_perform, framerate, depth, &block)
|
95
92
|
bottom = 1.0 - depth
|
93
|
+
gen = generator(note_perform, framerate, release_sustain: 0.0<bottom)
|
96
94
|
|
97
|
-
|
98
|
-
|
99
|
-
}
|
95
|
+
-> {
|
96
|
+
gen[] * depth + bottom
|
97
|
+
}
|
100
98
|
end
|
101
99
|
|
102
100
|
def balance_generator(note_perform, framerate, depth, &block)
|
103
|
-
generator(note_perform, framerate, release_sustain: true)
|
104
|
-
|
105
|
-
|
101
|
+
gen = generator(note_perform, framerate, release_sustain: true)
|
102
|
+
|
103
|
+
-> {
|
104
|
+
gen[] * depth
|
105
|
+
}
|
106
106
|
end
|
107
107
|
|
108
108
|
def plot_data(framerate: 44100)
|
@@ -26,42 +26,46 @@ module Synthesizer
|
|
26
26
|
@diff = target - @current
|
27
27
|
end
|
28
28
|
|
29
|
-
def generator(note_perform, samplerate
|
30
|
-
|
31
|
-
rate = @time * samplerate
|
29
|
+
def generator(note_perform, samplerate)
|
30
|
+
rate = @time * samplerate
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
# Note On
|
36
|
-
if 0<@time && @target!=@current
|
37
|
-
# Gliding
|
38
|
-
x = @diff / rate
|
39
|
-
if x.abs<(@target-@current).abs
|
40
|
-
@current += x
|
41
|
-
else
|
42
|
-
@current = @target
|
43
|
-
end
|
32
|
+
-> {
|
33
|
+
ret = nil
|
44
34
|
|
45
|
-
|
35
|
+
if note_perform.note_on?
|
36
|
+
# Note On
|
37
|
+
if 0<@time && @target!=@current
|
38
|
+
# Gliding
|
39
|
+
x = @diff / rate
|
40
|
+
if x.abs<(@target-@current).abs
|
41
|
+
@current += x
|
46
42
|
else
|
47
|
-
|
48
|
-
yld << @target - @base
|
43
|
+
@current = @target
|
49
44
|
end
|
45
|
+
|
46
|
+
ret = @current - @base
|
50
47
|
else
|
51
|
-
#
|
52
|
-
|
53
|
-
@target = 0.0
|
54
|
-
@diff = 0.0
|
55
|
-
yld << 0.0
|
48
|
+
# Stay
|
49
|
+
ret = @target - @base
|
56
50
|
end
|
57
|
-
|
58
|
-
|
51
|
+
else
|
52
|
+
# Note Off
|
53
|
+
@current = 0.0
|
54
|
+
@target = 0.0
|
55
|
+
@diff = 0.0
|
56
|
+
ret = 0.0
|
57
|
+
end
|
58
|
+
|
59
|
+
ret
|
60
|
+
}
|
59
61
|
end
|
60
62
|
|
61
|
-
def balance_generator(note_perform, samplerate, depth
|
62
|
-
generator(note_perform, samplerate)
|
63
|
-
|
64
|
-
|
63
|
+
def balance_generator(note_perform, samplerate, depth)
|
64
|
+
gen = generator(note_perform, samplerate)
|
65
|
+
|
66
|
+
-> {
|
67
|
+
gen[] * depth
|
68
|
+
}
|
65
69
|
end
|
66
70
|
|
67
71
|
def to_modval
|
@@ -47,17 +47,20 @@ module Synthesizer
|
|
47
47
|
|
48
48
|
def amp_generator(note_perform, framerate, depth, &block)
|
49
49
|
bottom = 1.0 - depth
|
50
|
+
gen = generator(note_perform, framerate)
|
50
51
|
|
51
|
-
|
52
|
-
val = (
|
52
|
+
-> {
|
53
|
+
val = (gen.next + 1) / 2
|
53
54
|
val * depth + bottom
|
54
|
-
}
|
55
|
+
}
|
55
56
|
end
|
56
57
|
|
57
58
|
def balance_generator(note_perform, framerate, depth, &block)
|
58
|
-
generator(note_perform, framerate)
|
59
|
-
|
60
|
-
|
59
|
+
gen = generator(note_perform, framerate)
|
60
|
+
|
61
|
+
-> {
|
62
|
+
gen.next * depth
|
63
|
+
}
|
61
64
|
end
|
62
65
|
end
|
63
66
|
end
|
@@ -49,12 +49,10 @@ module Synthesizer
|
|
49
49
|
}
|
50
50
|
}
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
}
|
57
|
-
end
|
52
|
+
-> {
|
53
|
+
depth = mods.map(&:[]).inject(1.0, &:*)
|
54
|
+
value * depth
|
55
|
+
}
|
58
56
|
end
|
59
57
|
|
60
58
|
def self.balance_generator(note_perform, framerate, *modvals, center: 0)
|
@@ -72,12 +70,10 @@ module Synthesizer
|
|
72
70
|
}
|
73
71
|
}
|
74
72
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
}
|
80
|
-
end
|
73
|
+
-> {
|
74
|
+
depth = mods.map(&:[]).sum
|
75
|
+
value + depth
|
76
|
+
}
|
81
77
|
end
|
82
78
|
end
|
83
79
|
end
|
@@ -1,92 +1,90 @@
|
|
1
1
|
module Synthesizer
|
2
2
|
module Processor
|
3
3
|
class High
|
4
|
-
def generator(osc, note_perform
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
# Filter
|
48
|
-
if filter_mod
|
49
|
-
filter_fx = filter_mod.next
|
50
|
-
mval = filter_fx.process_mono(mval)
|
51
|
-
end
|
52
|
-
|
53
|
-
dst0[i] = mval
|
54
|
-
}
|
55
|
-
|
56
|
-
y << buf
|
4
|
+
def generator(osc, note_perform)
|
5
|
+
synth = note_perform.synth
|
6
|
+
filter = synth.filter
|
7
|
+
amp = synth.amplifier
|
8
|
+
channels = synth.soundinfo.channels
|
9
|
+
window_size = synth.soundinfo.window_size
|
10
|
+
framerate = synth.soundinfo.samplerate.to_f
|
11
|
+
|
12
|
+
# Oscillator, Amplifier
|
13
|
+
volume_mod = ModulationValue.amp_generator(note_perform, framerate, osc.volume, amp.volume)
|
14
|
+
pan_mod = ModulationValue.balance_generator(note_perform, framerate, osc.pan, amp.pan)
|
15
|
+
tune_semis_mod = ModulationValue.balance_generator(note_perform, framerate, osc.tune_semis, amp.tune_semis, synth.glide&.to_modval)
|
16
|
+
tune_cents_mod = ModulationValue.balance_generator(note_perform, framerate, osc.tune_cents, amp.tune_cents)
|
17
|
+
|
18
|
+
uni_num_mod = ModulationValue.balance_generator(note_perform, framerate, osc.uni_num, amp.uni_num, center: 1.0)
|
19
|
+
uni_detune_mod = ModulationValue.balance_generator(note_perform, framerate, osc.uni_detune, amp.uni_detune)
|
20
|
+
unison = Unison.new(note_perform, osc.shape, osc.phase)
|
21
|
+
|
22
|
+
# Filter
|
23
|
+
filter_mod = nil
|
24
|
+
if filter
|
25
|
+
filter_mod = filter.generator(note_perform, framerate / window_size)
|
26
|
+
end
|
27
|
+
|
28
|
+
case channels
|
29
|
+
when 1
|
30
|
+
-> {
|
31
|
+
buf = AudioStream::Buffer.create_mono(window_size)
|
32
|
+
dst0 = buf.streams[0]
|
33
|
+
|
34
|
+
window_size.times.each {|i|
|
35
|
+
# Oscillator, Amplifier
|
36
|
+
volume = volume_mod[] * note_perform.velocity
|
37
|
+
tune_semis = tune_semis_mod[] + synth.pitch_bend
|
38
|
+
tune_cents = tune_cents_mod[]
|
39
|
+
|
40
|
+
uni_num = uni_num_mod[]
|
41
|
+
uni_detune = uni_detune_mod[]
|
42
|
+
|
43
|
+
sval = unison.next(uni_num, uni_detune, volume, 0.0, tune_semis, tune_cents)
|
44
|
+
mval = (sval[0] + sval[1]) / 2.0
|
45
|
+
|
46
|
+
dst0[i] = mval
|
57
47
|
}
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
48
|
+
|
49
|
+
# Filter
|
50
|
+
if filter_mod
|
51
|
+
filter_fx = filter_mod[]
|
52
|
+
buf = filter_fx.process(buf)
|
53
|
+
end
|
54
|
+
|
55
|
+
buf
|
56
|
+
}
|
57
|
+
when 2
|
58
|
+
-> {
|
59
|
+
buf = AudioStream::Buffer.create_stereo(window_size)
|
60
|
+
dst0 = buf.streams[0]
|
61
|
+
dst1 = buf.streams[1]
|
62
|
+
|
63
|
+
window_size.times.each {|i|
|
64
|
+
# Oscillator, Amplifier
|
65
|
+
volume = volume_mod[] * note_perform.velocity
|
66
|
+
pan = pan_mod[]
|
67
|
+
tune_semis = tune_semis_mod[] + synth.pitch_bend
|
68
|
+
tune_cents = tune_cents_mod[]
|
69
|
+
|
70
|
+
uni_num = uni_num_mod[]
|
71
|
+
uni_detune = uni_detune_mod[]
|
72
|
+
|
73
|
+
sval = unison.next(uni_num, uni_detune, volume, pan, tune_semis, tune_cents)
|
74
|
+
|
75
|
+
dst0[i] = sval[0]
|
76
|
+
dst1[i] = sval[1]
|
87
77
|
}
|
88
|
-
|
89
|
-
|
78
|
+
|
79
|
+
# Filter
|
80
|
+
if filter_mod
|
81
|
+
filter_fx = filter_mod[]
|
82
|
+
buf = filter_fx.process(buf)
|
83
|
+
end
|
84
|
+
|
85
|
+
buf
|
86
|
+
}
|
87
|
+
end
|
90
88
|
end
|
91
89
|
end
|
92
90
|
end
|
@@ -1,89 +1,87 @@
|
|
1
1
|
module Synthesizer
|
2
2
|
module Processor
|
3
3
|
class Low
|
4
|
-
def generator(osc, note_perform
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
framerate = synth.soundinfo.samplerate.to_f / window_size
|
4
|
+
def generator(osc, note_perform)
|
5
|
+
synth = note_perform.synth
|
6
|
+
filter = synth.filter
|
7
|
+
amp = synth.amplifier
|
8
|
+
channels = synth.soundinfo.channels
|
9
|
+
window_size = synth.soundinfo.window_size
|
10
|
+
framerate = synth.soundinfo.samplerate.to_f / window_size
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
# Oscillator, Amplifier
|
13
|
+
volume_mod = ModulationValue.amp_generator(note_perform, framerate, osc.volume, amp.volume)
|
14
|
+
pan_mod = ModulationValue.balance_generator(note_perform, framerate, osc.pan, amp.pan)
|
15
|
+
tune_semis_mod = ModulationValue.balance_generator(note_perform, framerate, osc.tune_semis, amp.tune_semis, synth.glide&.to_modval)
|
16
|
+
tune_cents_mod = ModulationValue.balance_generator(note_perform, framerate, osc.tune_cents, amp.tune_cents)
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
uni_num_mod = ModulationValue.balance_generator(note_perform, framerate, osc.uni_num, amp.uni_num, center: 1.0)
|
19
|
+
uni_detune_mod = ModulationValue.balance_generator(note_perform, framerate, osc.uni_detune, amp.uni_detune)
|
20
|
+
unison = Unison.new(note_perform, osc.shape, osc.phase)
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
# Filter
|
23
|
+
filter_mod = nil
|
24
|
+
if filter
|
25
|
+
filter_mod = filter.generator(note_perform, framerate)
|
26
|
+
end
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
case channels
|
29
|
+
when 1
|
30
|
+
-> {
|
31
|
+
buf = AudioStream::Buffer.create_mono(window_size)
|
32
|
+
dst0 = buf.streams[0]
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
# Oscillator, Amplifier
|
35
|
+
volume = volume_mod[] * note_perform.velocity
|
36
|
+
tune_semis = tune_semis_mod[] + synth.pitch_bend
|
37
|
+
tune_cents = tune_cents_mod[]
|
39
38
|
|
40
|
-
|
41
|
-
|
39
|
+
uni_num = uni_num_mod[]
|
40
|
+
uni_detune = uni_detune_mod[]
|
42
41
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
}
|
47
|
-
|
48
|
-
# Filter
|
49
|
-
if filter_mod
|
50
|
-
filter_fx = filter_mod.next
|
51
|
-
buf = filter_fx.process(buf)
|
52
|
-
end
|
53
|
-
|
54
|
-
y << buf
|
42
|
+
window_size.times.each {|i|
|
43
|
+
val = unison.next(uni_num, uni_detune, volume, 0.0, tune_semis, tune_cents)
|
44
|
+
dst0[i] = (val[0] + val[1]) / 2.0
|
55
45
|
}
|
56
|
-
when 2
|
57
|
-
loop {
|
58
|
-
buf = AudioStream::Buffer.create_stereo(window_size)
|
59
|
-
dst0 = buf.streams[0]
|
60
|
-
dst1 = buf.streams[1]
|
61
46
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
47
|
+
# Filter
|
48
|
+
if filter_mod
|
49
|
+
filter_fx = filter_mod[]
|
50
|
+
buf = filter_fx.process(buf)
|
51
|
+
end
|
67
52
|
|
68
|
-
|
69
|
-
|
53
|
+
buf
|
54
|
+
}
|
55
|
+
when 2
|
56
|
+
-> {
|
57
|
+
buf = AudioStream::Buffer.create_stereo(window_size)
|
58
|
+
dst0 = buf.streams[0]
|
59
|
+
dst1 = buf.streams[1]
|
70
60
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
61
|
+
# Oscillator, Amplifier
|
62
|
+
volume = volume_mod[] * note_perform.velocity
|
63
|
+
pan = pan_mod[]
|
64
|
+
tune_semis = tune_semis_mod[] + synth.pitch_bend
|
65
|
+
tune_cents = tune_cents_mod[]
|
76
66
|
|
77
|
-
|
78
|
-
|
79
|
-
filter_fx = filter_mod.next
|
80
|
-
buf = filter_fx.process(buf)
|
81
|
-
end
|
67
|
+
uni_num = uni_num_mod[]
|
68
|
+
uni_detune = uni_detune_mod[]
|
82
69
|
|
83
|
-
|
70
|
+
window_size.times.each {|i|
|
71
|
+
val = unison.next(uni_num, uni_detune, volume, pan, tune_semis, tune_cents)
|
72
|
+
dst0[i] = val[0]
|
73
|
+
dst1[i] = val[1]
|
84
74
|
}
|
85
|
-
|
86
|
-
|
75
|
+
|
76
|
+
# Filter
|
77
|
+
if filter_mod
|
78
|
+
filter_fx = filter_mod[]
|
79
|
+
buf = filter_fx.process(buf)
|
80
|
+
end
|
81
|
+
|
82
|
+
buf
|
83
|
+
}
|
84
|
+
end
|
87
85
|
end
|
88
86
|
end
|
89
87
|
end
|
data/lib/synthesizer/version.rb
CHANGED
data/synthesizer.gemspec
CHANGED
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:
|
4
|
+
version: 3.0.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-
|
11
|
+
date: 2019-10-02 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:
|
61
|
+
version: 3.0.0
|
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:
|
68
|
+
version: 3.0.0
|
69
69
|
description: Synthesizer implemented in Ruby.
|
70
70
|
email:
|
71
71
|
- yoshida.eth0@gmail.com
|