synthesizer 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7f45da04dde77d57f659a2be426c7128d6da179afb23be0c9a247e88079d9d6b
4
+ data.tar.gz: 564028cc062f4327a17d3384e2d9acf9ed69b4827768349fe3a6101b0cb3d0e2
5
+ SHA512:
6
+ metadata.gz: 6ea8c7397ed25c859d27e1eb68d7ed7551070ab5df1d94015bdc25a10e407b1a986a64c4f0d1be9bc2878d957299df50a75bfffd5230dfaa293a192e4286dff4
7
+ data.tar.gz: 5b3e73218fa8f402ff6e5b966734217cbd33a182b114fedeab4cff9c3d0c1484078220496826cd0682d6195a3209d1f051ddaee27aaefd67c63263f3f66fcb97
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.7.0
7
+ before_install: gem install bundler -v 2.0.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in synthesizer.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 yoshida
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Synthesizer
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/synthesizer`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'synthesizer'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install synthesizer
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/synthesizer.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "synthesizer"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,90 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "data": {
10
+ "text/html": [
11
+ "\n",
12
+ " <script>\n",
13
+ " requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min'] }})\n",
14
+ " </script>\n",
15
+ "\n",
16
+ "\n",
17
+ "<div id=\"50d8de42-6cb0-4c57-b91c-98ead58c25f7\" style=\"height: 100%; width: 100%;\"></div>\n",
18
+ "\n",
19
+ "<script>\n",
20
+ " require(['plotly'], function(Plotly) { \n",
21
+ "Plotly.newPlot(\n",
22
+ " '50d8de42-6cb0-4c57-b91c-98ead58c25f7',\n",
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
+ " {},\n",
25
+ " {\"linkText\":\"Export to plot.ly\",\"showLink\":true}\n",
26
+ ")\n",
27
+ "\n",
28
+ "window.addEventListener('resize', function() {\n",
29
+ " Plotly.Plots.resize(document.getElementById('50d8de42-6cb0-4c57-b91c-98ead58c25f7'))\n",
30
+ "})\n",
31
+ " }) \n",
32
+ "</script>"
33
+ ],
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>"
36
+ ]
37
+ },
38
+ "metadata": {},
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
+ }
51
+ ],
52
+ "source": [
53
+ "$LOAD_PATH << File.dirname(__FILE__) + \"/../lib\"\n",
54
+ "require 'synthesizer'\n",
55
+ "\n",
56
+ "include Synthesizer\n",
57
+ "\n",
58
+ "Modulation::Adsr.new(\n",
59
+ " attack: 0.1,\n",
60
+ " hold: 0.1,\n",
61
+ " decay: 0.4,\n",
62
+ " sustain: 0.8,\n",
63
+ " release: 0.2\n",
64
+ ").plot(samplerate: 100).show\n"
65
+ ]
66
+ },
67
+ {
68
+ "cell_type": "code",
69
+ "execution_count": null,
70
+ "metadata": {},
71
+ "outputs": [],
72
+ "source": []
73
+ }
74
+ ],
75
+ "metadata": {
76
+ "kernelspec": {
77
+ "display_name": "Ruby 2.7.0",
78
+ "language": "ruby",
79
+ "name": "ruby"
80
+ },
81
+ "language_info": {
82
+ "file_extension": ".rb",
83
+ "mimetype": "application/x-ruby",
84
+ "name": "ruby",
85
+ "version": "2.6.3"
86
+ }
87
+ },
88
+ "nbformat": 4,
89
+ "nbformat_minor": 2
90
+ }
@@ -0,0 +1,105 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "data": {
10
+ "text/html": [
11
+ "\n",
12
+ " <script>\n",
13
+ " requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min'] }})\n",
14
+ " </script>\n",
15
+ "\n",
16
+ "\n",
17
+ "<div id=\"580ec476-272b-4fc0-9f5a-ab6b96838f43\" style=\"height: 100%; width: 100%;\"></div>\n",
18
+ "\n",
19
+ "<script>\n",
20
+ " require(['plotly'], function(Plotly) { \n",
21
+ "Plotly.newPlot(\n",
22
+ " '580ec476-272b-4fc0-9f5a-ab6b96838f43',\n",
23
+ " [{\"x\":[0.0,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.1,0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.19,0.2,0.21,0.22,0.23,0.24,0.25,0.26,0.27,0.28,0.29,0.3,0.31,0.32,0.33,0.34,0.35000000000000003,0.36,0.37,0.38,0.39,0.4,0.41000000000000003,0.42,0.43,0.44,0.45,0.46,0.47000000000000003,0.48,0.49,0.5,0.51,0.52,0.53,0.54,0.55,0.56,0.5700000000000001,0.58,0.59,0.6,0.61,0.62,0.63,0.64,0.65,0.66,0.67,0.68,0.6900000000000001,0.7000000000000001,0.71,0.72,0.73,0.74,0.75,0.76,0.77,0.78,0.79,0.8,0.81,0.8200000000000001,0.8300000000000001,0.84,0.85,0.86,0.87,0.88,0.89,0.9,0.91,0.92,0.93,0.9400000000000001,0.9500000000000001,0.96,0.97,0.98,0.99],\"y\":[0.01,0.02,0.03,0.04,0.05,0.060000000000000005,0.07,0.08,0.09,0.09999999999999999,0.10999999999999999,0.11999999999999998,0.12999999999999998,0.13999999999999999,0.15,0.16,0.17,0.18000000000000002,0.19000000000000003,0.20000000000000004,0.21000000000000005,0.22000000000000006,0.23000000000000007,0.24000000000000007,0.25000000000000006,0.26000000000000006,0.2700000000000001,0.2800000000000001,0.2900000000000001,0.3000000000000001,0.3100000000000001,0.3200000000000001,0.3300000000000001,0.34000000000000014,0.35000000000000014,0.36000000000000015,0.37000000000000016,0.38000000000000017,0.3900000000000002,0.4000000000000002,0.4100000000000002,0.4200000000000002,0.4300000000000002,0.4400000000000002,0.45000000000000023,0.46000000000000024,0.47000000000000025,0.48000000000000026,0.49000000000000027,0.5000000000000002,0.5100000000000002,0.5200000000000002,0.5300000000000002,0.5400000000000003,0.5500000000000003,0.5600000000000003,0.5700000000000003,0.5800000000000003,0.5900000000000003,0.6000000000000003,0.6100000000000003,0.6200000000000003,0.6300000000000003,0.6400000000000003,0.6500000000000004,0.6600000000000004,0.6700000000000004,0.6800000000000004,0.6900000000000004,0.7000000000000004,0.7100000000000004,0.7200000000000004,0.7300000000000004,0.7400000000000004,0.7500000000000004,0.7600000000000005,0.7700000000000005,0.7800000000000005,0.7900000000000005,0.8000000000000005,0.8100000000000005,0.8200000000000005,0.8300000000000005,0.8400000000000005,0.8500000000000005,0.8600000000000005,0.8700000000000006,0.8800000000000006,0.8900000000000006,0.9000000000000006,0.9100000000000006,0.9200000000000006,0.9300000000000006,0.9400000000000006,0.9500000000000006,0.9600000000000006,0.9700000000000006,0.9800000000000006,0.9900000000000007,1.0000000000000007],\"name\":\"Straight\"},{\"x\":[0.0,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.1,0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.19,0.2,0.21,0.22,0.23,0.24,0.25,0.26,0.27,0.28,0.29,0.3,0.31,0.32,0.33,0.34,0.35000000000000003,0.36,0.37,0.38,0.39,0.4,0.41000000000000003,0.42,0.43,0.44,0.45,0.46,0.47000000000000003,0.48,0.49,0.5,0.51,0.52,0.53,0.54,0.55,0.56,0.5700000000000001,0.58,0.59,0.6,0.61,0.62,0.63,0.64,0.65,0.66,0.67,0.68,0.6900000000000001,0.7000000000000001,0.71,0.72,0.73,0.74,0.75,0.76,0.77,0.78,0.79,0.8,0.81,0.8200000000000001,0.8300000000000001,0.84,0.85,0.86,0.87,0.88,0.89,0.9,0.91,0.92,0.93,0.9400000000000001,0.9500000000000001,0.96,0.97,0.98,0.99],\"y\":[0.0001,0.0004,0.0009,0.0016,0.0025000000000000005,0.0036000000000000008,0.004900000000000001,0.0064,0.0081,0.009999999999999998,0.012099999999999998,0.014399999999999996,0.016899999999999995,0.019599999999999996,0.0225,0.0256,0.028900000000000006,0.032400000000000005,0.036100000000000014,0.040000000000000015,0.04410000000000002,0.048400000000000026,0.05290000000000003,0.05760000000000003,0.06250000000000003,0.06760000000000004,0.07290000000000003,0.07840000000000004,0.08410000000000005,0.09000000000000007,0.09610000000000007,0.10240000000000007,0.10890000000000008,0.11560000000000009,0.1225000000000001,0.1296000000000001,0.13690000000000013,0.14440000000000014,0.15210000000000015,0.16000000000000014,0.16810000000000017,0.17640000000000017,0.18490000000000018,0.1936000000000002,0.2025000000000002,0.21160000000000023,0.22090000000000024,0.23040000000000024,0.24010000000000026,0.2500000000000002,0.2601000000000002,0.27040000000000025,0.28090000000000026,0.2916000000000003,0.30250000000000027,0.3136000000000003,0.3249000000000003,0.33640000000000037,0.34810000000000035,0.3600000000000004,0.3721000000000004,0.3844000000000004,0.3969000000000004,0.40960000000000046,0.4225000000000005,0.4356000000000005,0.4489000000000005,0.46240000000000053,0.4761000000000005,0.49000000000000055,0.5041000000000005,0.5184000000000006,0.5329000000000006,0.5476000000000006,0.5625000000000007,0.5776000000000007,0.5929000000000008,0.6084000000000007,0.6241000000000008,0.6400000000000008,0.6561000000000008,0.6724000000000008,0.6889000000000008,0.7056000000000009,0.7225000000000009,0.7396000000000009,0.7569000000000009,0.774400000000001,0.792100000000001,0.810000000000001,0.8281000000000011,0.846400000000001,0.8649000000000011,0.8836000000000012,0.9025000000000012,0.9216000000000012,0.9409000000000013,0.9604000000000013,0.9801000000000013,1.0000000000000013],\"name\":\"EaseIn\"},{\"x\":[0.0,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.1,0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.19,0.2,0.21,0.22,0.23,0.24,0.25,0.26,0.27,0.28,0.29,0.3,0.31,0.32,0.33,0.34,0.35000000000000003,0.36,0.37,0.38,0.39,0.4,0.41000000000000003,0.42,0.43,0.44,0.45,0.46,0.47000000000000003,0.48,0.49,0.5,0.51,0.52,0.53,0.54,0.55,0.56,0.5700000000000001,0.58,0.59,0.6,0.61,0.62,0.63,0.64,0.65,0.66,0.67,0.68,0.6900000000000001,0.7000000000000001,0.71,0.72,0.73,0.74,0.75,0.76,0.77,0.78,0.79,0.8,0.81,0.8200000000000001,0.8300000000000001,0.84,0.85,0.86,0.87,0.88,0.89,0.9,0.91,0.92,0.93,0.9400000000000001,0.9500000000000001,0.96,0.97,0.98,0.99],\"y\":[0.0199,0.0396,0.0591,0.0784,0.0975,0.1164,0.1351,0.1536,0.1719,0.18999999999999997,0.2079,0.22559999999999997,0.24309999999999998,0.26039999999999996,0.2775,0.2944,0.31110000000000004,0.32760000000000006,0.34390000000000004,0.3600000000000001,0.37590000000000007,0.3916000000000001,0.40710000000000013,0.4224000000000001,0.4375000000000001,0.45240000000000014,0.4671000000000001,0.48160000000000014,0.4959000000000001,0.5100000000000001,0.5239000000000001,0.5376000000000002,0.5511000000000001,0.5644000000000002,0.5775000000000002,0.5904000000000003,0.6031000000000002,0.6156000000000003,0.6279000000000002,0.6400000000000002,0.6519000000000003,0.6636000000000003,0.6751000000000003,0.6864000000000002,0.6975000000000002,0.7084000000000003,0.7191000000000003,0.7296000000000002,0.7399000000000003,0.7500000000000002,0.7599000000000002,0.7696000000000003,0.7791000000000002,0.7884000000000002,0.7975000000000002,0.8064000000000002,0.8151000000000003,0.8236000000000002,0.8319000000000002,0.8400000000000003,0.8479000000000002,0.8556000000000002,0.8631000000000002,0.8704000000000003,0.8775000000000003,0.8844000000000003,0.8911000000000002,0.8976000000000003,0.9039000000000003,0.9100000000000003,0.9159000000000003,0.9216000000000002,0.9271000000000003,0.9324000000000002,0.9375000000000002,0.9424000000000002,0.9471000000000002,0.9516000000000002,0.9559000000000002,0.9600000000000002,0.9639000000000002,0.9676000000000002,0.9711000000000002,0.9744000000000002,0.9775000000000001,0.9804000000000002,0.9831000000000002,0.9856000000000001,0.9879000000000001,0.9900000000000001,0.9919000000000001,0.9936000000000001,0.9951000000000001,0.9964000000000001,0.9975,0.9984000000000001,0.9991,0.9996,0.9999,1.0],\"name\":\"EaseOut\"}],\n",
24
+ " {},\n",
25
+ " {\"linkText\":\"Export to plot.ly\",\"showLink\":true}\n",
26
+ ")\n",
27
+ "\n",
28
+ "window.addEventListener('resize', function() {\n",
29
+ " Plotly.Plots.resize(document.getElementById('580ec476-272b-4fc0-9f5a-ab6b96838f43'))\n",
30
+ "})\n",
31
+ " }) \n",
32
+ "</script>"
33
+ ],
34
+ "text/plain": [
35
+ "#<Plotly::Offline::HTML:0x00007ffe401d02b8 @id=\"580ec476-272b-4fc0-9f5a-ab6b96838f43\", @data=[{:x=>[0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35000000000000003, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41000000000000003, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47000000000000003, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.5700000000000001, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.6900000000000001, 0.7000000000000001, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8, 0.81, 0.8200000000000001, 0.8300000000000001, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.9400000000000001, 0.9500000000000001, 0.96, 0.97, 0.98, 0.99], :y=>[0.01, 0.02, 0.03, 0.04, 0.05, 0.060000000000000005, 0.07, 0.08, 0.09, 0.09999999999999999, 0.10999999999999999, 0.11999999999999998, 0.12999999999999998, 0.13999999999999999, 0.15, 0.16, 0.17, 0.18000000000000002, 0.19000000000000003, 0.20000000000000004, 0.21000000000000005, 0.22000000000000006, 0.23000000000000007, 0.24000000000000007, 0.25000000000000006, 0.26000000000000006, 0.2700000000000001, 0.2800000000000001, 0.2900000000000001, 0.3000000000000001, 0.3100000000000001, 0.3200000000000001, 0.3300000000000001, 0.34000000000000014, 0.35000000000000014, 0.36000000000000015, 0.37000000000000016, 0.38000000000000017, 0.3900000000000002, 0.4000000000000002, 0.4100000000000002, 0.4200000000000002, 0.4300000000000002, 0.4400000000000002, 0.45000000000000023, 0.46000000000000024, 0.47000000000000025, 0.48000000000000026, 0.49000000000000027, 0.5000000000000002, 0.5100000000000002, 0.5200000000000002, 0.5300000000000002, 0.5400000000000003, 0.5500000000000003, 0.5600000000000003, 0.5700000000000003, 0.5800000000000003, 0.5900000000000003, 0.6000000000000003, 0.6100000000000003, 0.6200000000000003, 0.6300000000000003, 0.6400000000000003, 0.6500000000000004, 0.6600000000000004, 0.6700000000000004, 0.6800000000000004, 0.6900000000000004, 0.7000000000000004, 0.7100000000000004, 0.7200000000000004, 0.7300000000000004, 0.7400000000000004, 0.7500000000000004, 0.7600000000000005, 0.7700000000000005, 0.7800000000000005, 0.7900000000000005, 0.8000000000000005, 0.8100000000000005, 0.8200000000000005, 0.8300000000000005, 0.8400000000000005, 0.8500000000000005, 0.8600000000000005, 0.8700000000000006, 0.8800000000000006, 0.8900000000000006, 0.9000000000000006, 0.9100000000000006, 0.9200000000000006, 0.9300000000000006, 0.9400000000000006, 0.9500000000000006, 0.9600000000000006, 0.9700000000000006, 0.9800000000000006, 0.9900000000000007, 1.0000000000000007], :name=>\"Straight\"}, {:x=>[0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35000000000000003, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41000000000000003, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47000000000000003, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.5700000000000001, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.6900000000000001, 0.7000000000000001, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8, 0.81, 0.8200000000000001, 0.8300000000000001, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.9400000000000001, 0.9500000000000001, 0.96, 0.97, 0.98, 0.99], :y=>[0.0001, 0.0004, 0.0009, 0.0016, 0.0025000000000000005, 0.0036000000000000008, 0.004900000000000001, 0.0064, 0.0081, 0.009999999999999998, 0.012099999999999998, 0.014399999999999996, 0.016899999999999995, 0.019599999999999996, 0.0225, 0.0256, 0.028900000000000006, 0.032400000000000005, 0.036100000000000014, 0.040000000000000015, 0.04410000000000002, 0.048400000000000026, 0.05290000000000003, 0.05760000000000003, 0.06250000000000003, 0.06760000000000004, 0.07290000000000003, 0.07840000000000004, 0.08410000000000005, 0.09000000000000007, 0.09610000000000007, 0.10240000000000007, 0.10890000000000008, 0.11560000000000009, 0.1225000000000001, 0.1296000000000001, 0.13690000000000013, 0.14440000000000014, 0.15210000000000015, 0.16000000000000014, 0.16810000000000017, 0.17640000000000017, 0.18490000000000018, 0.1936000000000002, 0.2025000000000002, 0.21160000000000023, 0.22090000000000024, 0.23040000000000024, 0.24010000000000026, 0.2500000000000002, 0.2601000000000002, 0.27040000000000025, 0.28090000000000026, 0.2916000000000003, 0.30250000000000027, 0.3136000000000003, 0.3249000000000003, 0.33640000000000037, 0.34810000000000035, 0.3600000000000004, 0.3721000000000004, 0.3844000000000004, 0.3969000000000004, 0.40960000000000046, 0.4225000000000005, 0.4356000000000005, 0.4489000000000005, 0.46240000000000053, 0.4761000000000005, 0.49000000000000055, 0.5041000000000005, 0.5184000000000006, 0.5329000000000006, 0.5476000000000006, 0.5625000000000007, 0.5776000000000007, 0.5929000000000008, 0.6084000000000007, 0.6241000000000008, 0.6400000000000008, 0.6561000000000008, 0.6724000000000008, 0.6889000000000008, 0.7056000000000009, 0.7225000000000009, 0.7396000000000009, 0.7569000000000009, 0.774400000000001, 0.792100000000001, 0.810000000000001, 0.8281000000000011, 0.846400000000001, 0.8649000000000011, 0.8836000000000012, 0.9025000000000012, 0.9216000000000012, 0.9409000000000013, 0.9604000000000013, 0.9801000000000013, 1.0000000000000013], :name=>\"EaseIn\"}, {:x=>[0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35000000000000003, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41000000000000003, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47000000000000003, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.5700000000000001, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.6900000000000001, 0.7000000000000001, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8, 0.81, 0.8200000000000001, 0.8300000000000001, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.9400000000000001, 0.9500000000000001, 0.96, 0.97, 0.98, 0.99], :y=>[0.0199, 0.0396, 0.0591, 0.0784, 0.0975, 0.1164, 0.1351, 0.1536, 0.1719, 0.18999999999999997, 0.2079, 0.22559999999999997, 0.24309999999999998, 0.26039999999999996, 0.2775, 0.2944, 0.31110000000000004, 0.32760000000000006, 0.34390000000000004, 0.3600000000000001, 0.37590000000000007, 0.3916000000000001, 0.40710000000000013, 0.4224000000000001, 0.4375000000000001, 0.45240000000000014, 0.4671000000000001, 0.48160000000000014, 0.4959000000000001, 0.5100000000000001, 0.5239000000000001, 0.5376000000000002, 0.5511000000000001, 0.5644000000000002, 0.5775000000000002, 0.5904000000000003, 0.6031000000000002, 0.6156000000000003, 0.6279000000000002, 0.6400000000000002, 0.6519000000000003, 0.6636000000000003, 0.6751000000000003, 0.6864000000000002, 0.6975000000000002, 0.7084000000000003, 0.7191000000000003, 0.7296000000000002, 0.7399000000000003, 0.7500000000000002, 0.7599000000000002, 0.7696000000000003, 0.7791000000000002, 0.7884000000000002, 0.7975000000000002, 0.8064000000000002, 0.8151000000000003, 0.8236000000000002, 0.8319000000000002, 0.8400000000000003, 0.8479000000000002, 0.8556000000000002, 0.8631000000000002, 0.8704000000000003, 0.8775000000000003, 0.8844000000000003, 0.8911000000000002, 0.8976000000000003, 0.9039000000000003, 0.9100000000000003, 0.9159000000000003, 0.9216000000000002, 0.9271000000000003, 0.9324000000000002, 0.9375000000000002, 0.9424000000000002, 0.9471000000000002, 0.9516000000000002, 0.9559000000000002, 0.9600000000000002, 0.9639000000000002, 0.9676000000000002, 0.9711000000000002, 0.9744000000000002, 0.9775000000000001, 0.9804000000000002, 0.9831000000000002, 0.9856000000000001, 0.9879000000000001, 0.9900000000000001, 0.9919000000000001, 0.9936000000000001, 0.9951000000000001, 0.9964000000000001, 0.9975, 0.9984000000000001, 0.9991, 0.9996, 0.9999, 1.0], :name=>\"EaseOut\"}], @layout={}, @config={:linkText=>\"Export to plot.ly\", :showLink=>true}, @embedded=true>"
36
+ ]
37
+ },
38
+ "metadata": {},
39
+ "output_type": "display_data"
40
+ },
41
+ {
42
+ "data": {
43
+ "text/plain": [
44
+ "#<CZTop::Socket::PUB:0x7ffe3df8edc0 last_endpoint=\"tcp://127.0.0.1:52424\">"
45
+ ]
46
+ },
47
+ "execution_count": 1,
48
+ "metadata": {},
49
+ "output_type": "execute_result"
50
+ }
51
+ ],
52
+ "source": [
53
+ "$LOAD_PATH << File.dirname(__FILE__) + \"/../lib\"\n",
54
+ "require 'synthesizer'\n",
55
+ "\n",
56
+ "include Synthesizer\n",
57
+ "\n",
58
+ "xs = []\n",
59
+ "ys1 = []\n",
60
+ "ys2 = []\n",
61
+ "ys3 = []\n",
62
+ "\n",
63
+ "pos = ShapePos.new\n",
64
+ "step = 0.01\n",
65
+ "\n",
66
+ "(1/step).to_i.times {|i|\n",
67
+ " phase = pos.next(step)\n",
68
+ " xs << i * step\n",
69
+ " ys1 << Modulation::Curve::Straight[phase]\n",
70
+ " ys2 << Modulation::Curve::EaseIn[phase]\n",
71
+ " ys3 << Modulation::Curve::EaseOut[phase]\n",
72
+ "}\n",
73
+ "\n",
74
+ "traces = [\n",
75
+ " {x: xs, y: ys1, name: \"Straight\"},\n",
76
+ " {x: xs, y: ys2, name: \"EaseIn\"},\n",
77
+ " {x: xs, y: ys3, name: \"EaseOut\"},\n",
78
+ "]\n",
79
+ "Plotly::Plot.new(data: traces).show\n"
80
+ ]
81
+ },
82
+ {
83
+ "cell_type": "code",
84
+ "execution_count": null,
85
+ "metadata": {},
86
+ "outputs": [],
87
+ "source": []
88
+ }
89
+ ],
90
+ "metadata": {
91
+ "kernelspec": {
92
+ "display_name": "Ruby 2.7.0",
93
+ "language": "ruby",
94
+ "name": "ruby"
95
+ },
96
+ "language_info": {
97
+ "file_extension": ".rb",
98
+ "mimetype": "application/x-ruby",
99
+ "name": "ruby",
100
+ "version": "2.6.3"
101
+ }
102
+ },
103
+ "nbformat": 4,
104
+ "nbformat_minor": 2
105
+ }
data/examples/mono.rb ADDED
@@ -0,0 +1,85 @@
1
+ require 'synthesizer'
2
+ require 'audio_stream/core_ext'
3
+
4
+ include AudioStream
5
+
6
+ soundinfo = SoundInfo.new(
7
+ channels: 2,
8
+ samplerate: 44100,
9
+ window_size: 1024,
10
+ format: RubyAudio::FORMAT_WAV|RubyAudio::FORMAT_PCM_16
11
+ )
12
+
13
+ synth = Synthesizer::Mono.new(
14
+ oscillators: [
15
+ Synthesizer::Oscillator.new(
16
+ shape: Synthesizer::Shape::SquareSawtooth,
17
+ uni_num: Synthesizer::ModulationValue.new(4),
18
+ #.add(Synthesizer::Modulation::Lfo.new(
19
+ #)),
20
+ uni_detune: 0.1,
21
+ ),
22
+ #Synthesizer::Oscillator.new(
23
+ # shape: Synthesizer::Shape::SquareSawtooth,
24
+ # tune_cents: 0.1,
25
+ # uni_num: 4,
26
+ # uni_detune: 0.1,
27
+ #),
28
+ #Synthesizer::Oscillator.new(
29
+ # shape: Synthesizer::Shape::SquareSawtooth,
30
+ # tune_semis: -12,
31
+ # uni_num: 4,
32
+ # uni_detune: 0.1,
33
+ #),
34
+ ],
35
+ amplifier: Synthesizer::Amplifier.new(
36
+ volume: Synthesizer::ModulationValue.new(1.0)
37
+ .add(Synthesizer::Modulation::Adsr.new(
38
+ attack: 0.05,
39
+ hold: 0.1,
40
+ decay: 0.4,
41
+ sustain: 0.8,
42
+ release: 0.2
43
+ ), depth: 1.0),
44
+ ),
45
+ glide: 0.2,
46
+ quality: Synthesizer::Quality::LOW,
47
+ soundinfo: soundinfo,
48
+ )
49
+ bufs = []
50
+
51
+ synth.note_on(Synthesizer::Note.new(60))
52
+ bufs += 50.times.map {|_| synth.next}
53
+ synth.note_on(Synthesizer::Note.new(62))
54
+ bufs += 50.times.map {|_| synth.next}
55
+ synth.note_on(Synthesizer::Note.new(64))
56
+ bufs += 50.times.map {|_| synth.next}
57
+ synth.note_on(Synthesizer::Note.new(62))
58
+ bufs += 50.times.map {|_| synth.next}
59
+
60
+ synth.note_off(Synthesizer::Note.new(62))
61
+ bufs += 50.times.map {|_| synth.next}
62
+ synth.note_off(Synthesizer::Note.new(64))
63
+ bufs += 50.times.map {|_| synth.next}
64
+ synth.note_off(Synthesizer::Note.new(60))
65
+ synth.note_on(Synthesizer::Note.new(65))
66
+ bufs += 50.times.map {|_| synth.next}
67
+ synth.note_off(Synthesizer::Note.new(65))
68
+ bufs += 50.times.map {|_| synth.next}
69
+
70
+
71
+ track1 = AudioInput.buffer(bufs)
72
+
73
+ stereo_out = AudioOutput.device(soundinfo: soundinfo)
74
+
75
+ track1
76
+ .stream
77
+ .send_to(stereo_out, gain: 0.3)
78
+
79
+
80
+ conductor = Conductor.new(
81
+ input: [track1],
82
+ output: [stereo_out]
83
+ )
84
+ conductor.connect
85
+ conductor.join
data/examples/poly.rb ADDED
@@ -0,0 +1,79 @@
1
+ require 'synthesizer'
2
+ require 'audio_stream/core_ext'
3
+
4
+ include AudioStream
5
+
6
+ soundinfo = SoundInfo.new(
7
+ channels: 2,
8
+ samplerate: 44100,
9
+ window_size: 1024,
10
+ format: RubyAudio::FORMAT_WAV|RubyAudio::FORMAT_PCM_16
11
+ )
12
+
13
+ synth = Synthesizer::Poly.new(
14
+ oscs: [
15
+ Synthesizer::Osc.new(
16
+ shape: Synthesizer::Shape::SquareSawtooth,
17
+ uni_num: Synthesizer::ModulationValue.new(4)
18
+ .add(Synthesizer::Modulation::Lfo.new(
19
+ )),
20
+ uni_detune: 0.1,
21
+ ),
22
+ #Synthesizer::Osc.new(
23
+ # shape: Synthesizer::Shape::SquareSawtooth,
24
+ # tune_cents: 0.1,
25
+ # uni_num: 4,
26
+ # uni_detune: 0.1,
27
+ #),
28
+ #Synthesizer::Osc.new(
29
+ # shape: Synthesizer::Shape::SquareSawtooth,
30
+ # tune_semis: -12,
31
+ # uni_num: 4,
32
+ # uni_detune: 0.1,
33
+ #),
34
+ ],
35
+ amp: Synthesizer::Amp.new(
36
+ volume: Synthesizer::ModulationValue.new(1.0)
37
+ .add(Synthesizer::Modulation::Adsr.new(
38
+ attack: 0.05,
39
+ hold: 0.1,
40
+ decay: 0.4,
41
+ sustain: 0.8,
42
+ release: 0.2
43
+ ), depth: 1.0),
44
+ ),
45
+ quality: Synthesizer::Quality::LOW,
46
+ soundinfo: soundinfo,
47
+ )
48
+ bufs = []
49
+
50
+ synth.note_on(Synthesizer::Note.new(60))
51
+ synth.note_on(Synthesizer::Note.new(62))
52
+ synth.note_on(Synthesizer::Note.new(64))
53
+ bufs += 10.times.map {|_| synth.next}
54
+ synth.pitch_bend = 1
55
+ bufs += 10.times.map {|_| synth.next}
56
+ synth.pitch_bend = 2
57
+ bufs += 10.times.map {|_| synth.next}
58
+
59
+ synth.note_off(Synthesizer::Note.new(60))
60
+ synth.note_off(Synthesizer::Note.new(62))
61
+ synth.note_off(Synthesizer::Note.new(64))
62
+ bufs += 50.times.map {|_| synth.next}
63
+
64
+
65
+ track1 = AudioInput.buffer(bufs)
66
+
67
+ stereo_out = AudioOutput.device(soundinfo: soundinfo)
68
+
69
+ track1
70
+ .stream
71
+ .send_to(stereo_out, gain: 0.25)
72
+
73
+
74
+ conductor = Conductor.new(
75
+ input: [track1],
76
+ output: [stereo_out]
77
+ )
78
+ conductor.connect
79
+ conductor.join