synthesizer 1.4.0 → 2.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/audio_stream/audio_input_synth.rb +12 -1
- data/lib/synthesizer/filter.rb +1 -0
- data/lib/synthesizer/filter/band_pass_filter.rb +1 -1
- data/lib/synthesizer/filter/high_pass_filter.rb +2 -2
- data/lib/synthesizer/filter/high_shelf_filter.rb +2 -2
- data/lib/synthesizer/filter/low_pass_filter.rb +2 -2
- data/lib/synthesizer/filter/low_shelf_filter.rb +2 -2
- data/lib/synthesizer/filter/parallel.rb +2 -24
- data/lib/synthesizer/filter/peaking_filter.rb +1 -1
- data/lib/synthesizer/filter/serial.rb +2 -4
- data/lib/synthesizer/mono_synth.rb +1 -1
- data/lib/synthesizer/poly_synth.rb +4 -2
- data/lib/synthesizer/processor/high.rb +8 -4
- data/lib/synthesizer/processor/low.rb +11 -6
- 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: 0abef47757011239dac5fe3bf5b746504491ba44eca05ce22fc6564fe00e390b
|
4
|
+
data.tar.gz: f34263d9c956a57a096987824371ea1baf69f0a4cbc87fc40059101b07ce436c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60974d1c179a679d67cd5c044378f64b31b000a83baf2c989937969165fd7d317b3ef2f8747734a75fad24d40fb1cd1de02137dd1f1ffff5e6b758968e5e9626
|
7
|
+
data.tar.gz: 97c4177887836a7a0d48165e6b6181eefe9e7993b53dd451f176e427620b42f8aed431d3b24e7fe33399a5e15c1e8479426054f21355001f5cd64898e5100896
|
@@ -6,10 +6,21 @@ module AudioStream
|
|
6
6
|
super()
|
7
7
|
|
8
8
|
@synth = synth
|
9
|
-
|
10
9
|
@soundinfo = soundinfo
|
11
10
|
end
|
12
11
|
|
12
|
+
def connect
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def disconnect
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
20
|
+
def connected?
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
13
24
|
def each(&block)
|
14
25
|
Enumerator.new do |y|
|
15
26
|
loop {
|
data/lib/synthesizer/filter.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module Synthesizer
|
2
2
|
module Filter
|
3
3
|
class HighPassFilter
|
4
|
-
def initialize(freq:, q:
|
4
|
+
def initialize(freq:, q: DEFAULT_Q)
|
5
5
|
@freq = ModulationValue.create(freq)
|
6
|
-
@q = ModulationValue.create(q
|
6
|
+
@q = ModulationValue.create(q)
|
7
7
|
end
|
8
8
|
|
9
9
|
def generator(note_perform, framerate, &block)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Synthesizer
|
2
2
|
module Filter
|
3
3
|
class HighShelfFilter
|
4
|
-
def initialize(freq:, q:
|
4
|
+
def initialize(freq:, q: DEFAULT_Q, gain: 1.0)
|
5
5
|
@freq = ModulationValue.create(freq)
|
6
|
-
@q = ModulationValue.create(q
|
6
|
+
@q = ModulationValue.create(q)
|
7
7
|
@gain = ModulationValue.create(gain)
|
8
8
|
end
|
9
9
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Synthesizer
|
2
2
|
module Filter
|
3
3
|
class LowPassFilter
|
4
|
-
def initialize(freq:, q:
|
4
|
+
def initialize(freq:, q: DEFAULT_Q)
|
5
5
|
@freq = ModulationValue.create(freq)
|
6
|
-
@q = ModulationValue.create(q
|
6
|
+
@q = ModulationValue.create(q)
|
7
7
|
end
|
8
8
|
|
9
9
|
def generator(note_perform, framerate, &block)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Synthesizer
|
2
2
|
module Filter
|
3
3
|
class LowShelfFilter
|
4
|
-
def initialize(freq:, q:
|
4
|
+
def initialize(freq:, q: DEFAULT_Q, gain: 1.0)
|
5
5
|
@freq = ModulationValue.create(freq)
|
6
|
-
@q = ModulationValue.create(q
|
6
|
+
@q = ModulationValue.create(q)
|
7
7
|
@gain = ModulationValue.create(gain)
|
8
8
|
end
|
9
9
|
|
@@ -19,37 +19,15 @@ module Synthesizer
|
|
19
19
|
end
|
20
20
|
|
21
21
|
class Fx
|
22
|
-
include AudioStream::Fx::BangProcess
|
23
|
-
|
24
22
|
def initialize(fxs)
|
25
23
|
@fxs = fxs
|
26
24
|
end
|
27
25
|
|
28
|
-
def process
|
29
|
-
window_size = input.size
|
30
|
-
channels = input.channels
|
31
|
-
fx_size = @fxs.size
|
32
|
-
|
26
|
+
def process(input)
|
33
27
|
outputs = @fxs.map {|fx|
|
34
28
|
fx.process(input)
|
35
29
|
}
|
36
|
-
|
37
|
-
case channels
|
38
|
-
when 1
|
39
|
-
input.size.times {|i|
|
40
|
-
input[i] = outputs.map{|buf| buf[i]}.sum / fx_size
|
41
|
-
}
|
42
|
-
when 2
|
43
|
-
input.size.times {|i|
|
44
|
-
samples = outputs.map{|buf| buf[i]}
|
45
|
-
input[i] = [
|
46
|
-
samples.map{|sval| sval[0]}.sum / fx_size,
|
47
|
-
samples.map{|sval| sval[1]}.sum / fx_size
|
48
|
-
]
|
49
|
-
}
|
50
|
-
end
|
51
|
-
|
52
|
-
input
|
30
|
+
AudioStream::Buffer.merge(outputs, average: true)
|
53
31
|
end
|
54
32
|
end
|
55
33
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Synthesizer
|
2
2
|
module Filter
|
3
3
|
class PeakingFilter
|
4
|
-
def initialize(freq:, bandwidth: 1.0, gain:)
|
4
|
+
def initialize(freq:, bandwidth: 1.0, gain: 40.0)
|
5
5
|
@freq = ModulationValue.create(freq)
|
6
6
|
@bandwidth = ModulationValue.create(bandwidth)
|
7
7
|
@gain = ModulationValue.create(gain)
|
@@ -19,15 +19,13 @@ module Synthesizer
|
|
19
19
|
end
|
20
20
|
|
21
21
|
class Fx
|
22
|
-
include AudioStream::Fx::BangProcess
|
23
|
-
|
24
22
|
def initialize(fxs)
|
25
23
|
@fxs = fxs
|
26
24
|
end
|
27
25
|
|
28
|
-
def process
|
26
|
+
def process(input)
|
29
27
|
@fxs.each {|fx|
|
30
|
-
fx.process
|
28
|
+
input = fx.process(input)
|
31
29
|
}
|
32
30
|
input
|
33
31
|
end
|
@@ -40,7 +40,7 @@ module Synthesizer
|
|
40
40
|
@perform = nil
|
41
41
|
end
|
42
42
|
end
|
43
|
-
buf || AudioStream::Buffer.
|
43
|
+
buf || AudioStream::Buffer.create(@soundinfo.window_size, @soundinfo.channels)
|
44
44
|
end
|
45
45
|
|
46
46
|
# @param note [Synthesizer::Note]
|
@@ -37,9 +37,11 @@ module Synthesizer
|
|
37
37
|
# delete released note performs
|
38
38
|
@performs.delete_if {|note_num, perform| perform.released? }
|
39
39
|
|
40
|
-
|
40
|
+
if 0<bufs.length
|
41
|
+
buf = AudioStream::Buffer.merge(bufs)
|
42
|
+
end
|
41
43
|
end
|
42
|
-
buf || AudioStream::Buffer.
|
44
|
+
buf || AudioStream::Buffer.create(@soundinfo.window_size, @soundinfo.channels)
|
43
45
|
end
|
44
46
|
|
45
47
|
# @param note [Synthesizer::Note]
|
@@ -29,7 +29,8 @@ module Synthesizer
|
|
29
29
|
case channels
|
30
30
|
when 1
|
31
31
|
loop {
|
32
|
-
buf = AudioStream::Buffer.
|
32
|
+
buf = AudioStream::Buffer.create_mono(window_size)
|
33
|
+
dst0 = buf.streams[0]
|
33
34
|
|
34
35
|
window_size.times.each {|i|
|
35
36
|
# Oscillator, Amplifier
|
@@ -49,14 +50,16 @@ module Synthesizer
|
|
49
50
|
mval = filter_fx.process_mono(mval)
|
50
51
|
end
|
51
52
|
|
52
|
-
|
53
|
+
dst0[i] = mval
|
53
54
|
}
|
54
55
|
|
55
56
|
y << buf
|
56
57
|
}
|
57
58
|
when 2
|
58
59
|
loop {
|
59
|
-
buf = AudioStream::Buffer.
|
60
|
+
buf = AudioStream::Buffer.create_stereo(window_size)
|
61
|
+
dst0 = buf.streams[0]
|
62
|
+
dst1 = buf.streams[1]
|
60
63
|
|
61
64
|
window_size.times.each {|i|
|
62
65
|
# Oscillator, Amplifier
|
@@ -76,7 +79,8 @@ module Synthesizer
|
|
76
79
|
sval = filter_fx.process_stereo(sval)
|
77
80
|
end
|
78
81
|
|
79
|
-
|
82
|
+
dst0[i] = sval[0]
|
83
|
+
dst1[i] = sval[1]
|
80
84
|
}
|
81
85
|
|
82
86
|
y << buf
|
@@ -29,7 +29,8 @@ module Synthesizer
|
|
29
29
|
case channels
|
30
30
|
when 1
|
31
31
|
loop {
|
32
|
-
buf = AudioStream::Buffer.
|
32
|
+
buf = AudioStream::Buffer.create_mono(window_size)
|
33
|
+
dst0 = buf.streams[0]
|
33
34
|
|
34
35
|
# Oscillator, Amplifier
|
35
36
|
volume = volume_mod.next * note_perform.velocity
|
@@ -41,20 +42,22 @@ module Synthesizer
|
|
41
42
|
|
42
43
|
window_size.times.each {|i|
|
43
44
|
val = unison.next(uni_num, uni_detune, volume, 0.0, tune_semis, tune_cents)
|
44
|
-
|
45
|
+
dst0[i] = (val[0] + val[1]) / 2.0
|
45
46
|
}
|
46
47
|
|
47
48
|
# Filter
|
48
49
|
if filter_mod
|
49
50
|
filter_fx = filter_mod.next
|
50
|
-
filter_fx.process
|
51
|
+
buf = filter_fx.process(buf)
|
51
52
|
end
|
52
53
|
|
53
54
|
y << buf
|
54
55
|
}
|
55
56
|
when 2
|
56
57
|
loop {
|
57
|
-
buf = AudioStream::Buffer.
|
58
|
+
buf = AudioStream::Buffer.create_stereo(window_size)
|
59
|
+
dst0 = buf.streams[0]
|
60
|
+
dst1 = buf.streams[1]
|
58
61
|
|
59
62
|
# Oscillator, Amplifier
|
60
63
|
volume = volume_mod.next * note_perform.velocity
|
@@ -66,13 +69,15 @@ module Synthesizer
|
|
66
69
|
uni_detune = uni_detune_mod.next
|
67
70
|
|
68
71
|
window_size.times.each {|i|
|
69
|
-
|
72
|
+
val = unison.next(uni_num, uni_detune, volume, pan, tune_semis, tune_cents)
|
73
|
+
dst0[i] = val[0]
|
74
|
+
dst1[i] = val[1]
|
70
75
|
}
|
71
76
|
|
72
77
|
# Filter
|
73
78
|
if filter_mod
|
74
79
|
filter_fx = filter_mod.next
|
75
|
-
filter_fx.process
|
80
|
+
buf = filter_fx.process(buf)
|
76
81
|
end
|
77
82
|
|
78
83
|
y << buf
|
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: 2.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-08-11 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: 2.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: 2.0.0
|
69
69
|
description: Synthesizer implemented in Ruby.
|
70
70
|
email:
|
71
71
|
- yoshida.eth0@gmail.com
|