synthesizer 3.3.1 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/examples/{metronome.rb → audio_input_metronome.rb} +8 -2
  4. data/examples/{step_editor.rb → audio_input_step_editor.rb} +10 -2
  5. data/examples/filter_band_pass.rb +73 -0
  6. data/examples/{lpf.rb → filter_serial.rb} +9 -2
  7. data/examples/oscillator_pan.rb +70 -0
  8. data/examples/{formant_vocoder.rb → oscillator_source_formant_vocoder.rb} +9 -2
  9. data/examples/{formant_vocoder_sweep.rb → oscillator_source_formant_vocoder_sweep.rb} +10 -3
  10. data/examples/{sync.rb → oscillator_sync.rb} +11 -3
  11. data/examples/oscillator_unison.rb +64 -0
  12. data/examples/oscillator_volume.rb +70 -0
  13. data/examples/{mono.rb → synth_mono.rb} +10 -2
  14. data/examples/{poly.rb → synth_poly.rb} +10 -2
  15. data/{examples → jupyter}/adsr.ipynb +20 -17
  16. data/jupyter/curves.ipynb +103 -0
  17. data/jupyter/shapes.ipynb +111 -0
  18. data/lib/audio_stream/audio_input_metronome.rb +1 -1
  19. data/lib/synthesizer/modulation/adsr.rb +12 -11
  20. data/lib/synthesizer/modulation/glide.rb +2 -2
  21. data/lib/synthesizer/modulation/lfo.rb +8 -8
  22. data/lib/synthesizer/oscillator.rb +9 -9
  23. data/lib/synthesizer/oscillator_source/formant_vocoder.rb +3 -2
  24. data/lib/synthesizer/shape.rb +4 -4
  25. data/lib/synthesizer/version.rb +1 -1
  26. data/samples/cinema.rb +730 -0
  27. data/samples/cinema_drum.wav +0 -0
  28. data/samples/daijoubu.rb +811 -0
  29. data/samples/daijoubu_drum.wav +0 -0
  30. data/samples/kira_power.rb +987 -0
  31. data/samples/kira_power_drum.wav +0 -0
  32. data/synthesizer.gemspec +1 -1
  33. metadata +29 -19
  34. data/examples/curves.ipynb +0 -105
  35. data/examples/shapes.ipynb +0 -116
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ac4bf1ead86d0e4b058454f9f6e7d5d5104e500e77771f198de74cce5c5b55c
4
- data.tar.gz: c5bd7cb4dd9cc7ce7b097b144d2e60a82f40a38a46fe1c4fe497a9873fe38045
3
+ metadata.gz: a7fa2f344702317c6c1c8b713314d9462b99df22e1badf9060cd40e99a46d307
4
+ data.tar.gz: 375c35843ed1a20c3df9ef5f788df905939c182f5408e38fc8c8c717fd3b0ce2
5
5
  SHA512:
6
- metadata.gz: 9b74c6cb4ad950e791371961178cb1ae27a2318f091ca2a9034b82edab2313914c70eea8f2e6e1d57bac2ceb0803b4407124a223febb2280de4b6dddb55e98ed
7
- data.tar.gz: 0a209246fc108b969048c162f0c01f690beb4b78e052cc81300ca7b85e67a652641590923c5c26783f95deeaf9e99d8fd7189321ef7a61ef3cf3f7f0c944707c
6
+ metadata.gz: daccd539aa122c187a494abc7404ef04cb577eff981be9aab8d2a6e07cd36df638ec05c559a563c45ba55fa0c324a6f6a5ab138711e082d0b269a42c668cdc65
7
+ data.tar.gz: 150e0eb898db3763cfddd29f7ec5801e3be7d6ef6a07e329405cc6e41509a7b3f59f9e51b61a6472e5ed8b7dcc4495d7e3ead167d532c219134c6ee47c530d0d
data/.gitignore CHANGED
@@ -6,6 +6,10 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ samples/output_*
10
+ .DS_Store
11
+ Gemfile.lock
12
+ .ipynb_checkpoints
9
13
 
10
14
  # rspec failure tracking
11
15
  .rspec_status
@@ -1,13 +1,19 @@
1
+ $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
2
+ $LOAD_PATH << File.dirname(__FILE__) + "/../../ruby-audio_stream/lib"
3
+
1
4
  require 'synthesizer'
2
5
  require 'audio_stream'
3
6
 
4
7
  include AudioStream
5
8
  include AudioStream::Fx
6
9
 
10
+ samplerate_list = [44100, 48000]
11
+ available_samplerates = CoreAudio.default_output_device.available_sample_rate.flatten.uniq
12
+ samplerate = samplerate_list.find {|rate| available_samplerates.include?(rate)} || available_samplerates.max
7
13
 
8
14
  soundinfo = SoundInfo.new(
9
15
  channels: 2,
10
- samplerate: 44100,
16
+ samplerate: samplerate,
11
17
  window_size: 1024,
12
18
  format: RubyAudio::FORMAT_WAV|RubyAudio::FORMAT_PCM_16
13
19
  )
@@ -24,7 +30,7 @@ track1 = AudioInputMetronome.new(
24
30
 
25
31
  # Audio FX
26
32
 
27
- gain = AGain.new(level: 0.9)
33
+ gain = AGain.new(level: -15)
28
34
 
29
35
 
30
36
  # Bus
@@ -1,16 +1,24 @@
1
+ $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
2
+ $LOAD_PATH << File.dirname(__FILE__) + "/../../ruby-audio_stream/lib"
3
+
1
4
  require 'synthesizer'
2
5
  require 'audio_stream'
3
6
 
4
7
  include AudioStream
5
8
  include Synthesizer
6
9
 
10
+ samplerate_list = [44100, 48000]
11
+ available_samplerates = CoreAudio.default_output_device.available_sample_rate.flatten.uniq
12
+ samplerate = samplerate_list.find {|rate| available_samplerates.include?(rate)} || available_samplerates.max
13
+
7
14
  soundinfo = SoundInfo.new(
8
15
  channels: 2,
9
- samplerate: 44100,
16
+ samplerate: samplerate,
10
17
  window_size: 1024,
11
18
  format: RubyAudio::FORMAT_WAV|RubyAudio::FORMAT_PCM_16
12
19
  )
13
20
 
21
+
14
22
  synth = PolySynth.new(
15
23
  oscillators: [
16
24
  Oscillator.new(
@@ -44,7 +52,7 @@ track1 = AudioInputStepEditor.new(synth, se)
44
52
  stereo_out = AudioOutput.device(soundinfo: soundinfo)
45
53
 
46
54
  track1
47
- .send_to(stereo_out, gain: 0.25)
55
+ .send_to(stereo_out, gain: -6)
48
56
 
49
57
 
50
58
  conductor = Conductor.new(
@@ -0,0 +1,73 @@
1
+ $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
2
+ $LOAD_PATH << File.dirname(__FILE__) + "/../../ruby-audio_stream/lib"
3
+
4
+ require 'synthesizer'
5
+ require 'audio_stream'
6
+
7
+ include AudioStream
8
+ include Synthesizer
9
+
10
+ samplerate_list = [44100, 48000]
11
+ available_samplerates = CoreAudio.default_output_device.available_sample_rate.flatten.uniq
12
+ samplerate = samplerate_list.find {|rate| available_samplerates.include?(rate)} || available_samplerates.max
13
+
14
+ soundinfo = SoundInfo.new(
15
+ channels: 2,
16
+ samplerate: samplerate,
17
+ window_size: 1024,
18
+ format: RubyAudio::FORMAT_WAV|RubyAudio::FORMAT_PCM_16
19
+ )
20
+
21
+ synth = PolySynth.new(
22
+ oscillators: [
23
+ Oscillator.new(
24
+ source: OscillatorSource::Sawtooth.instance,
25
+ ),
26
+ ],
27
+ filter: Filter::BandPassFilter.new(
28
+ freq: ModulationValue.new(1100.0)
29
+ .add(Modulation::Lfo.new(
30
+ shape: Shape::Sine,
31
+ delay: 0.0,
32
+ attack: 0.0,
33
+ attack_curve: Modulation::Curve::Straight,
34
+ phase: 0.0,
35
+ rate: 1.0
36
+ ), depth: 1000.0),
37
+ bandwidth: 1.0
38
+ ),
39
+ amplifier: Amplifier.new(
40
+ volume: ModulationValue.new(1.0)
41
+ .add(Modulation::Adsr.new(
42
+ attack: 0.05,
43
+ hold: 0.1,
44
+ decay: 0.4,
45
+ sustain: 0.8,
46
+ release: 0.2
47
+ ), depth: 1.0),
48
+ ),
49
+ soundinfo: soundinfo,
50
+ )
51
+ bufs = []
52
+
53
+ bufs += 50.times.map {|_| synth.next}
54
+ synth.note_on(Note.new(60))
55
+ bufs += 200.times.map {|_| synth.next}
56
+ synth.note_off(Note.new(60))
57
+ bufs += 50.times.map {|_| synth.next}
58
+
59
+
60
+ track1 = AudioInput.buffer(bufs)
61
+
62
+ stereo_out = AudioOutput.device(soundinfo: soundinfo)
63
+
64
+ track1
65
+ .send_to(stereo_out, gain: -15)
66
+
67
+
68
+ conductor = Conductor.new(
69
+ input: [track1],
70
+ output: [stereo_out]
71
+ )
72
+ conductor.connect
73
+ conductor.join
@@ -1,12 +1,19 @@
1
+ $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
2
+ $LOAD_PATH << File.dirname(__FILE__) + "/../../ruby-audio_stream/lib"
3
+
1
4
  require 'synthesizer'
2
5
  require 'audio_stream'
3
6
 
4
7
  include AudioStream
5
8
  include Synthesizer
6
9
 
10
+ samplerate_list = [44100, 48000]
11
+ available_samplerates = CoreAudio.default_output_device.available_sample_rate.flatten.uniq
12
+ samplerate = samplerate_list.find {|rate| available_samplerates.include?(rate)} || available_samplerates.max
13
+
7
14
  soundinfo = SoundInfo.new(
8
15
  channels: 2,
9
- samplerate: 44100,
16
+ samplerate: samplerate,
10
17
  window_size: 1024,
11
18
  format: RubyAudio::FORMAT_WAV|RubyAudio::FORMAT_PCM_16
12
19
  )
@@ -65,7 +72,7 @@ track1 = AudioInput.buffer(bufs)
65
72
  stereo_out = AudioOutput.device(soundinfo: soundinfo)
66
73
 
67
74
  track1
68
- .send_to(stereo_out, gain: 0.25)
75
+ .send_to(stereo_out, gain: -6)
69
76
 
70
77
 
71
78
  conductor = Conductor.new(
@@ -0,0 +1,70 @@
1
+ $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
2
+ $LOAD_PATH << File.dirname(__FILE__) + "/../../ruby-audio_stream/lib"
3
+
4
+ require 'synthesizer'
5
+ require 'audio_stream'
6
+
7
+ include AudioStream
8
+ include Synthesizer
9
+
10
+ samplerate_list = [44100, 48000]
11
+ available_samplerates = CoreAudio.default_output_device.available_sample_rate.flatten.uniq
12
+ samplerate = samplerate_list.find {|rate| available_samplerates.include?(rate)} || available_samplerates.max
13
+
14
+ soundinfo = SoundInfo.new(
15
+ channels: 2,
16
+ samplerate: samplerate,
17
+ window_size: 1024,
18
+ format: RubyAudio::FORMAT_WAV|RubyAudio::FORMAT_PCM_16
19
+ )
20
+
21
+ synth = PolySynth.new(
22
+ oscillators: [
23
+ Oscillator.new(
24
+ source: OscillatorSource::Sawtooth.instance,
25
+ pan: ModulationValue.new(0.0)
26
+ .add(Modulation::Lfo.new(
27
+ shape: Shape::Sine,
28
+ delay: 0.0,
29
+ attack: 0.0,
30
+ attack_curve: Modulation::Curve::Straight,
31
+ phase: 0.0,
32
+ rate: 1.0
33
+ ), depth: 1),
34
+ ),
35
+ ],
36
+ amplifier: Amplifier.new(
37
+ volume: ModulationValue.new(1.0)
38
+ .add(Modulation::Adsr.new(
39
+ attack: 0.05,
40
+ hold: 0.1,
41
+ decay: 0.4,
42
+ sustain: 0.8,
43
+ release: 0.2
44
+ ), depth: 1.0),
45
+ ),
46
+ soundinfo: soundinfo,
47
+ )
48
+ bufs = []
49
+
50
+ bufs += 50.times.map {|_| synth.next}
51
+ synth.note_on(Note.new(60))
52
+ bufs += 200.times.map {|_| synth.next}
53
+ synth.note_off(Note.new(60))
54
+ bufs += 50.times.map {|_| synth.next}
55
+
56
+
57
+ track1 = AudioInput.buffer(bufs)
58
+
59
+ stereo_out = AudioOutput.device(soundinfo: soundinfo)
60
+
61
+ track1
62
+ .send_to(stereo_out, gain: -15)
63
+
64
+
65
+ conductor = Conductor.new(
66
+ input: [track1],
67
+ output: [stereo_out]
68
+ )
69
+ conductor.connect
70
+ conductor.join
@@ -1,12 +1,19 @@
1
+ $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
2
+ $LOAD_PATH << File.dirname(__FILE__) + "/../../ruby-audio_stream/lib"
3
+
1
4
  require 'synthesizer'
2
5
  require 'audio_stream'
3
6
 
4
7
  include AudioStream
5
8
  include Synthesizer
6
9
 
10
+ samplerate_list = [44100, 48000]
11
+ available_samplerates = CoreAudio.default_output_device.available_sample_rate.flatten.uniq
12
+ samplerate = samplerate_list.find {|rate| available_samplerates.include?(rate)} || available_samplerates.max
13
+
7
14
  soundinfo = SoundInfo.new(
8
15
  channels: 2,
9
- samplerate: 44100,
16
+ samplerate: samplerate,
10
17
  window_size: 1024,
11
18
  format: RubyAudio::FORMAT_WAV|RubyAudio::FORMAT_PCM_16
12
19
  )
@@ -75,7 +82,7 @@ stereo_out = AudioOutput.device(soundinfo: soundinfo)
75
82
  #stereo_out = AudioOutput.file("formant_vocoder.wav", soundinfo: soundinfo)
76
83
 
77
84
  track1
78
- .send_to(stereo_out, gain: 1.0)
85
+ .send_to(stereo_out, gain: -6)
79
86
 
80
87
 
81
88
  conductor = Conductor.new(
@@ -1,12 +1,19 @@
1
+ $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
2
+ $LOAD_PATH << File.dirname(__FILE__) + "/../../ruby-audio_stream/lib"
3
+
1
4
  require 'synthesizer'
2
5
  require 'audio_stream'
3
6
 
4
7
  include AudioStream
5
8
  include Synthesizer
6
9
 
10
+ samplerate_list = [44100, 48000]
11
+ available_samplerates = CoreAudio.default_output_device.available_sample_rate.flatten.uniq
12
+ samplerate = samplerate_list.find {|rate| available_samplerates.include?(rate)} || available_samplerates.max
13
+
7
14
  soundinfo = SoundInfo.new(
8
15
  channels: 2,
9
- samplerate: 44100,
16
+ samplerate: samplerate,
10
17
  window_size: 1024,
11
18
  format: RubyAudio::FORMAT_WAV|RubyAudio::FORMAT_PCM_16
12
19
  )
@@ -21,7 +28,7 @@ synth = PolySynth.new(
21
28
  .add(Modulation::Lfo.new(
22
29
  shape: Shape::ForeverRampUp,
23
30
  rate: 2.0,
24
- )),
31
+ ), depth: 5),
25
32
  ),
26
33
  phase: 0.0,
27
34
  ),
@@ -65,7 +72,7 @@ stereo_out = AudioOutput.device(soundinfo: soundinfo)
65
72
  #stereo_out = AudioOutput.file("formant_vocoder_sweep.wav", soundinfo: soundinfo)
66
73
 
67
74
  track1
68
- .send_to(stereo_out, gain: 1.0)
75
+ .send_to(stereo_out, gain: -6)
69
76
 
70
77
 
71
78
  conductor = Conductor.new(
@@ -1,12 +1,19 @@
1
+ $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
2
+ $LOAD_PATH << File.dirname(__FILE__) + "/../../ruby-audio_stream/lib"
3
+
1
4
  require 'synthesizer'
2
5
  require 'audio_stream'
3
6
 
4
7
  include AudioStream
5
8
  include Synthesizer
6
9
 
10
+ samplerate_list = [44100, 48000]
11
+ available_samplerates = CoreAudio.default_output_device.available_sample_rate.flatten.uniq
12
+ samplerate = samplerate_list.find {|rate| available_samplerates.include?(rate)} || available_samplerates.max
13
+
7
14
  soundinfo = SoundInfo.new(
8
15
  channels: 2,
9
- samplerate: 44100,
16
+ samplerate: samplerate,
10
17
  window_size: 1024,
11
18
  format: RubyAudio::FORMAT_WAV|RubyAudio::FORMAT_PCM_16
12
19
  )
@@ -18,11 +25,12 @@ synth = PolySynth.new(
18
25
  sync: ModulationValue.new(0.0)
19
26
  .add(Modulation::Lfo.new(
20
27
  shape: Shape::PositiveRampUp,
28
+ #shape: Shape::Sine,
21
29
  delay: 0.0,
22
30
  attack: 0.0,
23
31
  attack_curve: Modulation::Curve::Straight,
24
32
  phase: 0.0,
25
- rate: 0.2
33
+ rate: 2.0
26
34
  ), depth: 48),
27
35
  ),
28
36
  ],
@@ -52,7 +60,7 @@ track1 = AudioInput.buffer(bufs)
52
60
  stereo_out = AudioOutput.device(soundinfo: soundinfo)
53
61
 
54
62
  track1
55
- .send_to(stereo_out, gain: 0.25)
63
+ .send_to(stereo_out, gain: -15)
56
64
 
57
65
 
58
66
  conductor = Conductor.new(
@@ -0,0 +1,64 @@
1
+ $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
2
+ $LOAD_PATH << File.dirname(__FILE__) + "/../../ruby-audio_stream/lib"
3
+
4
+ require 'synthesizer'
5
+ require 'audio_stream'
6
+
7
+ include AudioStream
8
+ include Synthesizer
9
+
10
+ samplerate_list = [44100, 48000]
11
+ available_samplerates = CoreAudio.default_output_device.available_sample_rate.flatten.uniq
12
+ samplerate = samplerate_list.find {|rate| available_samplerates.include?(rate)} || available_samplerates.max
13
+
14
+ soundinfo = SoundInfo.new(
15
+ channels: 2,
16
+ samplerate: samplerate,
17
+ window_size: 1024,
18
+ format: RubyAudio::FORMAT_WAV|RubyAudio::FORMAT_PCM_16
19
+ )
20
+
21
+ synth = PolySynth.new(
22
+ oscillators: [
23
+ Oscillator.new(
24
+ source: OscillatorSource::Sawtooth.instance,
25
+ uni_num: 3,
26
+ uni_detune: 0.3,
27
+ uni_stereo: 1.0,
28
+ ),
29
+ ],
30
+ amplifier: Amplifier.new(
31
+ volume: ModulationValue.new(1.0)
32
+ .add(Modulation::Adsr.new(
33
+ attack: 0.05,
34
+ hold: 0.1,
35
+ decay: 0.4,
36
+ sustain: 0.8,
37
+ release: 0.2
38
+ ), depth: 1.0),
39
+ ),
40
+ soundinfo: soundinfo,
41
+ )
42
+ bufs = []
43
+
44
+ bufs += 50.times.map {|_| synth.next}
45
+ synth.note_on(Note.new(60))
46
+ bufs += 200.times.map {|_| synth.next}
47
+ synth.note_off(Note.new(60))
48
+ bufs += 50.times.map {|_| synth.next}
49
+
50
+
51
+ track1 = AudioInput.buffer(bufs)
52
+
53
+ stereo_out = AudioOutput.device(soundinfo: soundinfo)
54
+
55
+ track1
56
+ .send_to(stereo_out, gain: -15)
57
+
58
+
59
+ conductor = Conductor.new(
60
+ input: [track1],
61
+ output: [stereo_out]
62
+ )
63
+ conductor.connect
64
+ conductor.join
@@ -0,0 +1,70 @@
1
+ $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
2
+ $LOAD_PATH << File.dirname(__FILE__) + "/../../ruby-audio_stream/lib"
3
+
4
+ require 'synthesizer'
5
+ require 'audio_stream'
6
+
7
+ include AudioStream
8
+ include Synthesizer
9
+
10
+ samplerate_list = [44100, 48000]
11
+ available_samplerates = CoreAudio.default_output_device.available_sample_rate.flatten.uniq
12
+ samplerate = samplerate_list.find {|rate| available_samplerates.include?(rate)} || available_samplerates.max
13
+
14
+ soundinfo = SoundInfo.new(
15
+ channels: 2,
16
+ samplerate: samplerate,
17
+ window_size: 1024,
18
+ format: RubyAudio::FORMAT_WAV|RubyAudio::FORMAT_PCM_16
19
+ )
20
+
21
+ synth = PolySynth.new(
22
+ oscillators: [
23
+ Oscillator.new(
24
+ source: OscillatorSource::Sawtooth.instance,
25
+ volume: ModulationValue.new(0.0)
26
+ .add(Modulation::Lfo.new(
27
+ shape: Shape::Sine,
28
+ delay: 0.0,
29
+ attack: 0.0,
30
+ attack_curve: Modulation::Curve::Straight,
31
+ phase: 0.0,
32
+ rate: 0.5
33
+ ), depth: 1),
34
+ ),
35
+ ],
36
+ amplifier: Amplifier.new(
37
+ volume: ModulationValue.new(1.0)
38
+ .add(Modulation::Adsr.new(
39
+ attack: 0.05,
40
+ hold: 0.1,
41
+ decay: 0.4,
42
+ sustain: 0.8,
43
+ release: 0.2
44
+ ), depth: 1.0),
45
+ ),
46
+ soundinfo: soundinfo,
47
+ )
48
+ bufs = []
49
+
50
+ bufs += 50.times.map {|_| synth.next}
51
+ synth.note_on(Note.new(60))
52
+ bufs += 200.times.map {|_| synth.next}
53
+ synth.note_off(Note.new(60))
54
+ bufs += 50.times.map {|_| synth.next}
55
+
56
+
57
+ track1 = AudioInput.buffer(bufs)
58
+
59
+ stereo_out = AudioOutput.device(soundinfo: soundinfo)
60
+
61
+ track1
62
+ .send_to(stereo_out, gain: -15)
63
+
64
+
65
+ conductor = Conductor.new(
66
+ input: [track1],
67
+ output: [stereo_out]
68
+ )
69
+ conductor.connect
70
+ conductor.join
@@ -1,12 +1,20 @@
1
+ $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
2
+ $LOAD_PATH << File.dirname(__FILE__) + "/../../ruby-audio_stream/lib"
3
+
1
4
  require 'synthesizer'
2
5
  require 'audio_stream'
3
6
 
4
7
  include AudioStream
8
+ include AudioStream::Fx
5
9
  include Synthesizer
6
10
 
11
+ samplerate_list = [44100, 48000]
12
+ available_samplerates = CoreAudio.default_output_device.available_sample_rate.flatten.uniq
13
+ samplerate = samplerate_list.find {|rate| available_samplerates.include?(rate)} || available_samplerates.max
14
+
7
15
  soundinfo = SoundInfo.new(
8
16
  channels: 2,
9
- samplerate: 44100,
17
+ samplerate: samplerate,
10
18
  window_size: 1024,
11
19
  format: RubyAudio::FORMAT_WAV|RubyAudio::FORMAT_PCM_16
12
20
  )
@@ -73,7 +81,7 @@ track1 = AudioInput.buffer(bufs)
73
81
  stereo_out = AudioOutput.device(soundinfo: soundinfo)
74
82
 
75
83
  track1
76
- .send_to(stereo_out, gain: 0.3)
84
+ .send_to(stereo_out, gain: -6)
77
85
 
78
86
 
79
87
  conductor = Conductor.new(
@@ -1,12 +1,20 @@
1
+ $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
2
+ $LOAD_PATH << File.dirname(__FILE__) + "/../../ruby-audio_stream/lib"
3
+
1
4
  require 'synthesizer'
2
5
  require 'audio_stream'
3
6
 
4
7
  include AudioStream
8
+ include AudioStream::Fx
5
9
  include Synthesizer
6
10
 
11
+ samplerate_list = [44100, 48000]
12
+ available_samplerates = CoreAudio.default_output_device.available_sample_rate.flatten.uniq
13
+ samplerate = samplerate_list.find {|rate| available_samplerates.include?(rate)} || available_samplerates.max
14
+
7
15
  soundinfo = SoundInfo.new(
8
16
  channels: 2,
9
- samplerate: 44100,
17
+ samplerate: samplerate,
10
18
  window_size: 1024,
11
19
  format: RubyAudio::FORMAT_WAV|RubyAudio::FORMAT_PCM_16
12
20
  )
@@ -67,7 +75,7 @@ track1 = AudioInput.buffer(bufs)
67
75
  stereo_out = AudioOutput.device(soundinfo: soundinfo)
68
76
 
69
77
  track1
70
- .send_to(stereo_out, gain: 0.25)
78
+ .send_to(stereo_out, gain: -15)
71
79
 
72
80
 
73
81
  conductor = Conductor.new(
@@ -14,54 +14,57 @@
14
14
  " </script>\n",
15
15
  "\n",
16
16
  "\n",
17
- "<div id=\"50d8de42-6cb0-4c57-b91c-98ead58c25f7\" style=\"height: 100%; width: 100%;\"></div>\n",
17
+ "<div id=\"4d969034-0f45-4109-9224-a15d040993bb\" style=\"height: 100%; width: 100%;\"></div>\n",
18
18
  "\n",
19
19
  "<script>\n",
20
20
  " require(['plotly'], function(Plotly) { \n",
21
21
  "Plotly.newPlot(\n",
22
- " '50d8de42-6cb0-4c57-b91c-98ead58c25f7',\n",
22
+ " '4d969034-0f45-4109-9224-a15d040993bb',\n",
23
23
  " [{\"x\":[0,1,2,3,4,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,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79],\"y\":[0.0,0.19,0.36000000000000004,0.51,0.6400000000000001,0.75,0.84,0.9099999999999999,0.96,0.9900000000000001,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.990125,0.9805,0.971125,0.962,0.953125,0.9445,0.936125,0.928,0.9201250000000001,0.9125,0.905125,0.898,0.8911250000000001,0.8845000000000001,0.878125,0.872,0.866125,0.8605,0.855125,0.8500000000000001,0.845125,0.8405,0.836125,0.8320000000000001,0.828125,0.8245,0.821125,0.8180000000000001,0.8151250000000001,0.8125,0.810125,0.808,0.806125,0.8045,0.8031250000000001,0.802,0.8011250000000001,0.8005,0.8001250000000001,0.8001250000000001,0.7221128125,0.6481012500000001,0.5780903125,0.51208,0.45007031250000007,0.39206125000000003,0.33805281250000013,0.28804499999999994,0.24203781250000003,0.20003125000000002,0.16202531250000002,0.12802000000000005,0.09801531249999997,0.07201125000000007,0.050007812500000005,0.03200500000000003,0.018002812500000062,0.00800124999999992,0.0020003125000000463]}],\n",
24
24
  " {},\n",
25
25
  " {\"linkText\":\"Export to plot.ly\",\"showLink\":true}\n",
26
26
  ")\n",
27
27
  "\n",
28
28
  "window.addEventListener('resize', function() {\n",
29
- " Plotly.Plots.resize(document.getElementById('50d8de42-6cb0-4c57-b91c-98ead58c25f7'))\n",
29
+ " Plotly.Plots.resize(document.getElementById('4d969034-0f45-4109-9224-a15d040993bb'))\n",
30
30
  "})\n",
31
31
  " }) \n",
32
32
  "</script>"
33
33
  ],
34
34
  "text/plain": [
35
- "#<Plotly::Offline::HTML:0x00007f9be79abb10 @id=\"50d8de42-6cb0-4c57-b91c-98ead58c25f7\", @data=[{:x=>[0, 1, 2, 3, 4, 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, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79], :y=>[0.0, 0.19, 0.36000000000000004, 0.51, 0.6400000000000001, 0.75, 0.84, 0.9099999999999999, 0.96, 0.9900000000000001, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.990125, 0.9805, 0.971125, 0.962, 0.953125, 0.9445, 0.936125, 0.928, 0.9201250000000001, 0.9125, 0.905125, 0.898, 0.8911250000000001, 0.8845000000000001, 0.878125, 0.872, 0.866125, 0.8605, 0.855125, 0.8500000000000001, 0.845125, 0.8405, 0.836125, 0.8320000000000001, 0.828125, 0.8245, 0.821125, 0.8180000000000001, 0.8151250000000001, 0.8125, 0.810125, 0.808, 0.806125, 0.8045, 0.8031250000000001, 0.802, 0.8011250000000001, 0.8005, 0.8001250000000001, 0.8001250000000001, 0.7221128125, 0.6481012500000001, 0.5780903125, 0.51208, 0.45007031250000007, 0.39206125000000003, 0.33805281250000013, 0.28804499999999994, 0.24203781250000003, 0.20003125000000002, 0.16202531250000002, 0.12802000000000005, 0.09801531249999997, 0.07201125000000007, 0.050007812500000005, 0.03200500000000003, 0.018002812500000062, 0.00800124999999992, 0.0020003125000000463]}], @layout={}, @config={:linkText=>\"Export to plot.ly\", :showLink=>true}, @embedded=true>"
35
+ "#<Plotly::Offline::HTML:0x00007fdd0c8c4178 @id=\"4d969034-0f45-4109-9224-a15d040993bb\", @data=[{:x=>[0, 1, 2, 3, 4, 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, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79], :y=>[0.0, 0.19, 0.36000000000000004, 0.51, 0.6400000000000001, 0.75, 0.84, 0.9099999999999999, 0.96, 0.9900000000000001, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.990125, 0.9805, 0.971125, 0.962, 0.953125, 0.9445, 0.936125, 0.928, 0.9201250000000001, 0.9125, 0.905125, 0.898, 0.8911250000000001, 0.8845000000000001, 0.878125, 0.872, 0.866125, 0.8605, 0.855125, 0.8500000000000001, 0.845125, 0.8405, 0.836125, 0.8320000000000001, 0.828125, 0.8245, 0.821125, 0.8180000000000001, 0.8151250000000001, 0.8125, 0.810125, 0.808, 0.806125, 0.8045, 0.8031250000000001, 0.802, 0.8011250000000001, 0.8005, 0.8001250000000001, 0.8001250000000001, 0.7221128125, 0.6481012500000001, 0.5780903125, 0.51208, 0.45007031250000007, 0.39206125000000003, 0.33805281250000013, 0.28804499999999994, 0.24203781250000003, 0.20003125000000002, 0.16202531250000002, 0.12802000000000005, 0.09801531249999997, 0.07201125000000007, 0.050007812500000005, 0.03200500000000003, 0.018002812500000062, 0.00800124999999992, 0.0020003125000000463]}], @layout={}, @config={:linkText=>\"Export to plot.ly\", :showLink=>true}, @embedded=true>"
36
36
  ]
37
37
  },
38
38
  "metadata": {},
39
39
  "output_type": "display_data"
40
- },
41
- {
42
- "data": {
43
- "text/plain": [
44
- "#<CZTop::Socket::PUB:0x7f9be6f66c90 last_endpoint=\"tcp://127.0.0.1:52802\">"
45
- ]
46
- },
47
- "execution_count": 1,
48
- "metadata": {},
49
- "output_type": "execute_result"
50
40
  }
51
41
  ],
52
42
  "source": [
53
43
  "$LOAD_PATH << File.dirname(__FILE__) + \"/../lib\"\n",
44
+ "$LOAD_PATH << File.dirname(__FILE__) + \"/../../ruby-audio_stream/lib\"\n",
45
+ "\n",
54
46
  "require 'synthesizer'\n",
47
+ "require 'audio_stream'\n",
55
48
  "\n",
49
+ "include AudioStream\n",
56
50
  "include Synthesizer\n",
57
51
  "\n",
52
+ "soundinfo = SoundInfo.new(\n",
53
+ " channels: 2,\n",
54
+ " samplerate: 100,\n",
55
+ " window_size: 1,\n",
56
+ " format: RubyAudio::FORMAT_WAV|RubyAudio::FORMAT_PCM_16\n",
57
+ ")\n",
58
+ "\n",
58
59
  "Modulation::Adsr.new(\n",
59
60
  " attack: 0.1,\n",
60
61
  " hold: 0.1,\n",
61
62
  " decay: 0.4,\n",
62
63
  " sustain: 0.8,\n",
63
64
  " release: 0.2\n",
64
- ").plot(samplerate: 100).show\n"
65
+ ").plot(soundinfo).show\n",
66
+ "\n",
67
+ "nil"
65
68
  ]
66
69
  },
67
70
  {
@@ -74,7 +77,7 @@
74
77
  ],
75
78
  "metadata": {
76
79
  "kernelspec": {
77
- "display_name": "Ruby 2.7.0",
80
+ "display_name": "Ruby 2.7.1",
78
81
  "language": "ruby",
79
82
  "name": "ruby"
80
83
  },
@@ -82,7 +85,7 @@
82
85
  "file_extension": ".rb",
83
86
  "mimetype": "application/x-ruby",
84
87
  "name": "ruby",
85
- "version": "2.6.3"
88
+ "version": "2.7.2"
86
89
  }
87
90
  },
88
91
  "nbformat": 4,