├── .babelrc ├── .eslintignore ├── .eslintrc.json ├── .gitattributes ├── .gitignore ├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── 0.html ├── LICENSE.md ├── README.md ├── dist ├── assets │ ├── 0de3b51742ed3ac61435875bccd8973b.png │ ├── 208a290102a4ada58a04de354a1354d7.png │ ├── 73a1fd052c9d84c0ee0bea3ee85892ed.png │ ├── 971364734f3b603e5d363a2634898b42.png │ ├── a4c733ec4baef9ad3896d4e34a8a5448.png │ ├── bf27228a7d3957983584fa7698121ea1.png │ ├── faust-lib │ │ ├── all.lib │ │ ├── analyzers.lib │ │ ├── basics.lib │ │ ├── compressors.lib │ │ ├── delays.lib │ │ ├── demos.lib │ │ ├── dx7.lib │ │ ├── envelopes.lib │ │ ├── filters.lib │ │ ├── hoa.lib │ │ ├── instruments.lib │ │ ├── maths.lib │ │ ├── maxmsp.lib │ │ ├── mi.lib │ │ ├── misceffects.lib │ │ ├── noises.lib │ │ ├── oscillators.lib │ │ ├── phaflangers.lib │ │ ├── physmodels.lib │ │ ├── reducemaps.lib │ │ ├── reverbs.lib │ │ ├── routes.lib │ │ ├── sf.lib │ │ ├── signals.lib │ │ ├── soundfiles.lib │ │ ├── spats.lib │ │ ├── stdfaust.lib │ │ ├── synths.lib │ │ ├── tonestacks.lib │ │ ├── tubes.lib │ │ └── vaeffects.lib │ └── fonts │ │ ├── lato-v14-latin-700.woff │ │ ├── lato-v14-latin-700.woff2 │ │ ├── lato-v14-latin-700italic.woff │ │ ├── lato-v14-latin-700italic.woff2 │ │ ├── lato-v14-latin-italic.woff │ │ ├── lato-v14-latin-italic.woff2 │ │ ├── lato-v14-latin-regular.woff │ │ └── lato-v14-latin-regular.woff2 ├── bundle.js ├── font_Lato.css ├── libfaust-wasm.wasm └── mixer32.wasm ├── favicon.png ├── index.html ├── main.js ├── package-lock.json ├── package.json ├── patchers ├── com.json ├── example1.jpg ├── example2.jpg ├── faust.json ├── faust_poly.json ├── fetch.json ├── js.json ├── patcher.json ├── prnn.json ├── sensors.json ├── src │ └── models │ │ ├── dljs │ │ ├── fully_connected_biases │ │ ├── fully_connected_weights │ │ ├── manifest.json │ │ ├── rnn_multi_rnn_cell_cell_0_basic_lstm_cell_bias │ │ ├── rnn_multi_rnn_cell_cell_0_basic_lstm_cell_kernel │ │ ├── rnn_multi_rnn_cell_cell_1_basic_lstm_cell_bias │ │ ├── rnn_multi_rnn_cell_cell_1_basic_lstm_cell_kernel │ │ ├── rnn_multi_rnn_cell_cell_2_basic_lstm_cell_bias │ │ └── rnn_multi_rnn_cell_cell_2_basic_lstm_cell_kernel │ │ └── tfjs │ │ ├── group1-shard1of6 │ │ ├── group1-shard2of6 │ │ ├── group1-shard3of6 │ │ ├── group1-shard4of6 │ │ ├── group1-shard5of6 │ │ ├── group1-shard6of6 │ │ └── weights_manifest.json └── tf.json ├── renderer.js ├── semantic.json ├── semantic └── dist │ ├── semantic.min.css │ ├── semantic.min.js │ └── themes │ └── default │ └── assets │ ├── fonts │ ├── icons.eot │ ├── icons.svg │ ├── icons.ttf │ ├── icons.woff │ └── icons.woff2 │ └── images │ └── flags.png ├── src ├── Patcher.js ├── UIObj.js ├── UIObj.jsx ├── index.js ├── maxObj.js ├── maxpat.js ├── object │ ├── AutoImporter.js │ ├── Base.css │ ├── Base.js │ ├── Default.css │ ├── Events.js │ ├── JS.css │ ├── JS.js │ ├── JSArray.js │ ├── JSDate.js │ ├── JSMath.js │ ├── JSOp.js │ ├── WA.js │ ├── WebAPI.js │ ├── Xebra.js │ ├── faust │ │ ├── Faust.css │ │ ├── Faust.js │ │ ├── Faust2WebAudio.js │ │ ├── SHA1.js │ │ ├── codemirror │ │ │ └── mode │ │ │ │ └── faust │ │ │ │ └── faust.js │ │ ├── libfaust-wasm.js │ │ ├── libfaust-wasm.wasm │ │ └── webaudio-wasm-wrapper.js │ └── max │ │ └── Max.js └── selection-js │ └── src │ ├── selection.js │ └── utils.js └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", { 5 | "targets": "defaults" 6 | } 7 | ] 8 | ] 9 | } -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /src/object/faust/libfaust-wasm.js 2 | /src/object/faust/webaudio-wasm-wrapper.js 3 | /semantic/dist/* -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "babel-eslint", 4 | "plugins": [ 5 | "react", "import" 6 | ], 7 | "extends": ["eslint:recommended", "plugin:react/recommended"], 8 | "env": { 9 | "browser": true, 10 | "node": true, 11 | "es6": true 12 | }, 13 | "rules": { 14 | "no-unused-vars": "off", 15 | "no-console": "warn" 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 18 | .grunt 19 | 20 | # node-waf configuration 21 | .lock-wscript 22 | 23 | # Compiled binary addons (http://nodejs.org/api/addons.html) 24 | build/Release 25 | 26 | # Dependency directories 27 | node_modules 28 | jspm_packages 29 | 30 | # Optional npm cache directory 31 | .npm 32 | 33 | # Optional REPL history 34 | .node_repl_history 35 | 36 | # ========================= 37 | # Operating System Files 38 | # ========================= 39 | 40 | # OSX 41 | # ========================= 42 | 43 | .DS_Store 44 | .AppleDouble 45 | .LSOverride 46 | 47 | # Thumbnails 48 | ._* 49 | 50 | # Files that might appear in the root of a volume 51 | .DocumentRevisions-V100 52 | .fseventsd 53 | .Spotlight-V100 54 | .TemporaryItems 55 | .Trashes 56 | .VolumeIcon.icns 57 | 58 | # Directories potentially created on remote AFP share 59 | .AppleDB 60 | .AppleDesktop 61 | Network Trash Folder 62 | Temporary Items 63 | .apdisk 64 | 65 | # Windows 66 | # ========================= 67 | 68 | # Windows image file caches 69 | Thumbs.db 70 | ehthumbs.db 71 | 72 | # Folder config file 73 | Desktop.ini 74 | 75 | # Recycle Bin used on file shares 76 | $RECYCLE.BIN/ 77 | 78 | # Windows Installer files 79 | *.cab 80 | *.msi 81 | *.msm 82 | *.msp 83 | 84 | # Windows shortcuts 85 | *.lnk 86 | 87 | # Semantic 88 | semantic/src/ 89 | semantic/tasks/ 90 | semantic/gulpfile.js 91 | 92 | app.js 93 | cycle-dac.maxpat 94 | maxpat.js 95 | 96 | # Local files 97 | local/ -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "启动程序", 11 | "cwd": "${workspaceRoot}", 12 | //"preLaunchTask": "webpack", 13 | "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron", 14 | "windows": { 15 | "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd" 16 | }, 17 | "args": [ 18 | "." 19 | ] 20 | }, 21 | { 22 | "type": "chrome", 23 | "request": "launch", 24 | "name": "Chrome Debugger", 25 | "cwd": "${workspaceRoot}", 26 | "sourceMaps": false, 27 | "file": "${workspaceFolder}/index.html" 28 | } 29 | ] 30 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "eslint.workingDirectories": [ 3 | "./src" 4 | ], 5 | "eslint.autoFixOnSave": true, 6 | "eslint.nodePath": "./node_modules", 7 | "cSpell.enabled": false, 8 | "search.usePCRE2": true 9 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "watch", 6 | "command": "${workspaceFolder}/node_modules/.bin/babel", 7 | "args": [ 8 | "src", 9 | "--out-dir", 10 | "lib", 11 | "-w", 12 | "--source-maps" 13 | ], 14 | "type": "shell", 15 | "group": "none", 16 | "isBackground": true 17 | }, 18 | 19 | { 20 | "label": "webpack", 21 | "command": "${workspaceFolder}/node_modules/.bin/webpack", 22 | "type": "process", 23 | "group": { 24 | "kind": "build", 25 | "isDefault": true 26 | }, 27 | "isBackground": true 28 | } 29 | ] 30 | } -------------------------------------------------------------------------------- /0.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | JSPatcher 11 | 19 | 20 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [WebAudio-Patcher](https://fr0stbyter.github.io/) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) 2 | 3 | 4 | A web environment allows you to play with JavaScript and WebAudio. 5 | 6 | It's a playground, Every function, variable, method or object are boxes patching with each other. Messages are passing from right to left. (as MaxMSP) 7 | 8 | ## Examples 9 | 10 | Listen MouseMove event, than transform the value to the frequency used to generate a sine wave. Then you can visalize your spectrum. 11 | 12 | ![Example1](./patchers/example1.jpg) 13 | 14 | Or Fetch a Tensorflow model. 15 | 16 | ![Example2](./patchers/example2.jpg) 17 | 18 | Or try [Performance RNN](https://magenta.tensorflow.org/performance-rnn) with TensorFlow.js and [Faust](https://faust.grame.fr) 19 | 20 | https://fr0stbyter.github.io/webaudio-patcher/#prnn.json 21 | 22 | ## Usage 23 | 24 | Press N or double click to create a new box. 25 | 26 | Press M to create a message. 27 | 28 | Ctrl + Click to Lock / Unlock patcher. -------------------------------------------------------------------------------- /dist/assets/0de3b51742ed3ac61435875bccd8973b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/dist/assets/0de3b51742ed3ac61435875bccd8973b.png -------------------------------------------------------------------------------- /dist/assets/208a290102a4ada58a04de354a1354d7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/dist/assets/208a290102a4ada58a04de354a1354d7.png -------------------------------------------------------------------------------- /dist/assets/73a1fd052c9d84c0ee0bea3ee85892ed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/dist/assets/73a1fd052c9d84c0ee0bea3ee85892ed.png -------------------------------------------------------------------------------- /dist/assets/971364734f3b603e5d363a2634898b42.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/dist/assets/971364734f3b603e5d363a2634898b42.png -------------------------------------------------------------------------------- /dist/assets/a4c733ec4baef9ad3896d4e34a8a5448.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/dist/assets/a4c733ec4baef9ad3896d4e34a8a5448.png -------------------------------------------------------------------------------- /dist/assets/bf27228a7d3957983584fa7698121ea1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/dist/assets/bf27228a7d3957983584fa7698121ea1.png -------------------------------------------------------------------------------- /dist/assets/faust-lib/all.lib: -------------------------------------------------------------------------------- 1 | //##################################### all.lib ########################################## 2 | // The purpose of this library is to give access to all the Faust standard libraries 3 | // from a single point. 4 | //######################################################################################## 5 | 6 | import("analyzers.lib"); 7 | import("basics.lib"); 8 | import("compressors.lib"); 9 | import("delays.lib"); 10 | import("demos.lib"); 11 | import("dx7.lib"); 12 | import("envelopes.lib"); 13 | import("filters.lib"); 14 | import("hoa.lib"); 15 | import("maths.lib"); 16 | import("misceffects.lib"); 17 | import("oscillators.lib"); 18 | import("noises.lib"); 19 | import("phaflangers.lib"); 20 | import("physmodels.lib"); 21 | import("reverbs.lib"); 22 | import("routes.lib"); 23 | import("signals.lib"); 24 | import("soundfiles.lib"); 25 | import("spats.lib"); 26 | import("synths.lib"); 27 | import("vaeffects.lib"); 28 | -------------------------------------------------------------------------------- /dist/assets/faust-lib/compressors.lib: -------------------------------------------------------------------------------- 1 | //#################################### compressors.lib #################################### 2 | // A library of compressor effects. Its official prefix is `co`. 3 | //######################################################################################## 4 | 5 | /************************************************************************ 6 | ************************************************************************ 7 | FAUST library file 8 | Copyright (C) 2003-2016 GRAME, Centre National de Creation Musicale 9 | ---------------------------------------------------------------------- 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as 12 | published by the Free Software Foundation; either version 2.1 of the 13 | License, or (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with the GNU C Library; if not, write to the Free 22 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 23 | 02111-1307 USA. 24 | 25 | EXCEPTION TO THE LGPL LICENSE : As a special exception, you may create a 26 | larger FAUST program which directly or indirectly imports this library 27 | file and still distribute the compiled code generated by the FAUST 28 | compiler, or a modified version of this compiled code, under your own 29 | copyright and license. This EXCEPTION TO THE LGPL LICENSE explicitly 30 | grants you the right to freely choose the license for the resulting 31 | compiled code. In particular the resulting compiled code has no obligation 32 | to be LGPL or GPL. For example you are free to choose a commercial or 33 | closed source license or any other license if you decide so. 34 | ************************************************************************ 35 | ************************************************************************/ 36 | 37 | ba = library("basics.lib"); 38 | si = library("signals.lib"); 39 | an = library("analyzers.lib"); 40 | 41 | 42 | declare name "Faust Compressor Effect Library"; 43 | declare version "0.0"; 44 | 45 | //=============================Functions Reference======================================== 46 | //======================================================================================== 47 | 48 | //--------------------`(co.)compressor_mono`------------------- 49 | // Mono dynamic range compressors. 50 | // `compressor_mono` is a standard Faust function. 51 | // 52 | // #### Usage 53 | // 54 | // ``` 55 | // _ : compressor_mono(ratio,thresh,att,rel) : _ 56 | // ``` 57 | // 58 | // Where: 59 | // 60 | // * `ratio`: compression ratio (1 = no compression, >1 means compression) 61 | // * `thresh`: dB level threshold above which compression kicks in (0 dB = max level) 62 | // * `att`: attack time = time constant (sec) when level & compression going up 63 | // * `rel`: release time = time constant (sec) coming out of compression 64 | // 65 | // #### References 66 | // 67 | // * 68 | // * 69 | // * Albert Graef's "faust2pd"/examples/synth/compressor_.dsp 70 | // * More features: 71 | //------------------------------------------------------------ 72 | // TODO: author JOS, revised by RM 73 | compressor_mono(ratio,thresh,att,rel,x) = x * compression_gain_mono(ratio,thresh,att,rel,x); 74 | 75 | 76 | //--------------------`(co.)compressor_stereo`------------------- 77 | // Stereo dynamic range compressors. 78 | // 79 | // #### Usage 80 | // 81 | // ``` 82 | // _,_ : compressor_stereo(ratio,thresh,att,rel) : _,_ 83 | // ``` 84 | // 85 | // Where: 86 | // 87 | // * `ratio`: compression ratio (1 = no compression, >1 means compression) 88 | // * `thresh`: dB level threshold above which compression kicks in (0 dB = max level) 89 | // * `att`: attack time = time constant (sec) when level & compression going up 90 | // * `rel`: release time = time constant (sec) coming out of compression 91 | // 92 | // #### References 93 | // 94 | // * 95 | // * 96 | // * Albert Graef's "faust2pd"/examples/synth/compressor_.dsp 97 | // * More features: 98 | //------------------------------------------------------------ 99 | // TODO: author JOS, revised by RM 100 | compressor_stereo(ratio,thresh,att,rel,x,y) = cgm*x, cgm*y with { 101 | cgm = compression_gain_mono(ratio,thresh,att,rel,abs(x)+abs(y)); 102 | }; 103 | 104 | compression_gain_mono(ratio,thresh,att,rel) = 105 | an.amp_follower_ar(att,rel) : ba.linear2db : outminusindb(ratio,thresh) : 106 | kneesmooth(att) : ba.db2linear 107 | with { 108 | // kneesmooth(att) installs a "knee" in the dynamic-range compression, 109 | // where knee smoothness is set equal to half that of the compression-attack. 110 | // A general 'knee' parameter could be used instead of tying it to att/2: 111 | kneesmooth(att) = si.smooth(ba.tau2pole(att/2.0)); 112 | // compression gain in dB: 113 | outminusindb(ratio,thresh,level) = max(level-thresh,0.0) * (1.0/float(ratio)-1.0); 114 | // Note: "float(ratio)" REQUIRED when ratio is an integer > 1! 115 | }; 116 | 117 | 118 | //----------------`(co.)limiter_1176_R4_mono`---------------------- 119 | // A limiter guards against hard-clipping. It can be can be 120 | // implemented as a compressor having a high threshold (near the 121 | // clipping level), fast attack and release, and high ratio. Since 122 | // the ratio is so high, some knee smoothing is 123 | // desirable ("soft limiting"). This example is intended 124 | // to get you started using compressor_* as a limiter, so all 125 | // parameters are hardwired to nominal values here. 126 | // Ratios: 4 (moderate compression), 8 (severe compression), 127 | // 12 (mild limiting), or 20 to 1 (hard limiting) 128 | // Att: 20-800 MICROseconds (Note: scaled by ratio in the 1176) 129 | // Rel: 50-1100 ms (Note: scaled by ratio in the 1176) 130 | // Mike Shipley likes 4:1 (Grammy-winning mixer for Queen, Tom Petty, etc.) 131 | // Faster attack gives "more bite" (e.g. on vocals) 132 | // He hears a bright, clear eq effect as well (not implemented here). 133 | // `limiter_1176_R4_mono` is a standard Faust function. 134 | // 135 | // #### Usage 136 | // 137 | // ``` 138 | // _ : limiter_1176_R4_mono : _; 139 | // ``` 140 | // 141 | // #### Reference: 142 | // 143 | // 144 | //------------------------------------------------------------ 145 | // TODO: author JOS, revised by RM 146 | limiter_1176_R4_mono = compressor_mono(4,-6,0.0008,0.5); 147 | 148 | 149 | //-------------------`(co.)limiter_1176_R4_stereo`--------------------- 150 | // A limiter guards against hard-clipping. It can be can be 151 | // implemented as a compressor having a high threshold (near the 152 | // clipping level), fast attack and release, and high ratio. Since 153 | // the ratio is so high, some knee smoothing is 154 | // desirable ("soft limiting"). This example is intended 155 | // to get you started using compressor_* as a limiter, so all 156 | // parameters are hardwired to nominal values here. 157 | // Ratios: 4 (moderate compression), 8 (severe compression), 158 | // 12 (mild limiting), or 20 to 1 (hard limiting) 159 | // Att: 20-800 MICROseconds (Note: scaled by ratio in the 1176) 160 | // Rel: 50-1100 ms (Note: scaled by ratio in the 1176) 161 | // Mike Shipley likes 4:1 (Grammy-winning mixer for Queen, Tom Petty, etc.) 162 | // Faster attack gives "more bite" (e.g. on vocals) 163 | // He hears a bright, clear eq effect as well (not implemented here) 164 | // 165 | // #### Usage 166 | // 167 | // ``` 168 | // _,_ : limiter_1176_R4_stereo : _,_; 169 | // ``` 170 | // 171 | // #### Reference: 172 | // 173 | // 174 | //------------------------------------------------------------ 175 | // TODO: author JOS, revised by RM 176 | limiter_1176_R4_stereo = compressor_stereo(4,-6,0.0008,0.5); 177 | -------------------------------------------------------------------------------- /dist/assets/faust-lib/hoa.lib: -------------------------------------------------------------------------------- 1 | //################################### hoa.lib ############################################ 2 | // Faust library for high order ambisonic. Its official prefix is `ho`. 3 | //######################################################################################## 4 | 5 | /************************************************************************ 6 | ************************************************************************ 7 | FAUST library file 8 | Copyright (C) 2003-2012 GRAME, Centre National de Creation Musicale 9 | ---------------------------------------------------------------------- 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as 12 | published by the Free Software Foundation; either version 2.1 of the 13 | License, or (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with the GNU C Library; if not, write to the Free 22 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 23 | 02111-1307 USA. 24 | 25 | EXCEPTION TO THE LGPL LICENSE : As a special exception, you may create a 26 | larger FAUST program which directly or indirectly imports this library 27 | file and still distribute the compiled code generated by the FAUST 28 | compiler, or a modified version of this compiled code, under your own 29 | copyright and license. This EXCEPTION TO THE LGPL LICENSE explicitly 30 | grants you the right to freely choose the license for the resulting 31 | compiled code. In particular the resulting compiled code has no obligation 32 | to be LGPL or GPL. For example you are free to choose a commercial or 33 | closed source license or any other license if you decide so. 34 | 35 | ************************************************************************ 36 | ************************************************************************/ 37 | 38 | declare name "High Order Ambisonics library"; 39 | declare author "Pierre Guillot"; 40 | declare author "Eliott Paris"; 41 | declare author "Julien Colafrancesco"; 42 | declare copyright "2012-2013 Guillot, Paris, Colafrancesco, CICM labex art H2H, U. Paris 8"; 43 | 44 | ma = library("maths.lib"); 45 | si = library("signals.lib"); 46 | 47 | 48 | //----------------------`(ho.)encoder`--------------------------------- 49 | // Ambisonic encoder. Encodes a signal in the circular harmonics domain 50 | // depending on an order of decomposition and an angle. 51 | // 52 | // #### Usage 53 | // 54 | // ``` 55 | // encoder(n, x, a) : _ 56 | // ``` 57 | // 58 | // Where: 59 | // 60 | // * `n`: the order 61 | // * `x`: the signal 62 | // * `a`: the angle 63 | //---------------------------------------------------------------- 64 | encoder(0, x, a) = x; 65 | encoder(n, x, a) = encoder(n-1, x, a), x*sin(n*a), x*cos(n*a); 66 | 67 | 68 | 69 | //--------------------------`(ho.)decoder`-------------------------------- 70 | // Decodes an ambisonics sound field for a circular array of loudspeakers. 71 | // 72 | // #### Usage 73 | // 74 | // ``` 75 | // _ : decoder(n, p) : _ 76 | // ``` 77 | // 78 | // Where: 79 | // 80 | // * `n`: the order 81 | // * `p`: the number of speakers 82 | // 83 | // #### Note 84 | // 85 | // Number of loudspeakers must be greater or equal to 2n+1. It's preferable 86 | // to use 2n+2 loudspeakers. 87 | //------------------------------------------------------------------- 88 | decoder(n, p) = par(i, 2*n+1, _) <: par(i, p, speaker(n, 2*ma.PI*i/p)) 89 | with 90 | { 91 | speaker(n,a) = /(2), par(i, 2*n, _), encoder(n,2/(2*n+1),a) : si.dot(2*n+1); 92 | }; 93 | 94 | 95 | 96 | //-----------------------`(ho.)decoderStereo`------------------------ 97 | // Decodes an ambisonic sound field for stereophonic configuration. 98 | // An "home made" ambisonic decoder for stereophonic restitution 99 | // (30° - 330°) : Sound field lose energy around 180°. You should 100 | // use `inPhase` optimization with ponctual sources. 101 | // #### Usage 102 | // 103 | // ``` 104 | // _ : decoderStereo(n) : _ 105 | // ``` 106 | // 107 | // Where: 108 | // 109 | // * `n`: the order 110 | //-------------------------------------------------------------- 111 | decoderStereo(n) = decoder(n, p) <: (par(i, 2*n+2, gainLeft(360 * i / p)) :> _), 112 | (par(i, 2*n+2, gainRight(360 * i / p)) :> _) 113 | with 114 | { 115 | p = 2*n+2; 116 | 117 | gainLeft(a) = _ * sin(ratio_minus + ratio_cortex) 118 | with 119 | { 120 | ratio_minus = ma.PI*.5 * abs( (30 + a) / 60 * ((a <= 30)) + (a - 330) / 60 * (a >= 330) ); 121 | ratio_cortex= ma.PI*.5 * abs( (120 + a) / 150 * (a > 30) * (a <= 180)); 122 | }; 123 | 124 | gainRight(a) = _ * sin(ratio_minus + ratio_cortex) 125 | with 126 | { 127 | ratio_minus = ma.PI*.5 * abs( (390 - a) / 60 * (a >= 330) + (30 - a) / 60 * (a <= 30) ); 128 | ratio_cortex= ma.PI*.5 * abs( (180 - a) / 150 * (a < 330) * (a >= 180)); 129 | }; 130 | }; 131 | 132 | 133 | //============================Optimization Functions====================================== 134 | // Functions to weight the circular harmonics signals depending to the 135 | // ambisonics optimization. 136 | // It can be `basic` for no optimization, `maxRe` or `inPhase`. 137 | //======================================================================================== 138 | 139 | 140 | //----------------`(ho.)optimBasic`------------------------- 141 | // The basic optimization has no effect and should be used for a perfect 142 | // circle of loudspeakers with one listener at the perfect center loudspeakers 143 | // array. 144 | // 145 | // #### Usage 146 | // 147 | // ``` 148 | // _ : optimBasic(n) : _ 149 | // ``` 150 | // 151 | // Where: 152 | // 153 | // * `n`: the order 154 | //----------------------------------------------------- 155 | optimBasic(n) = par(i, 2*n+1, _); 156 | 157 | 158 | //----------------`(ho.)optimMaxRe`------------------------- 159 | // The maxRe optimization optimize energy vector. It should be used for an 160 | // auditory confined in the center of the loudspeakers array. 161 | // 162 | // #### Usage 163 | // 164 | // ``` 165 | // _ : optimMaxRe(n) : _ 166 | // ``` 167 | // 168 | // Where: 169 | // 170 | // * `n`: the order 171 | //----------------------------------------------------- 172 | optimMaxRe(n) = par(i, 2*n+1, optim(i, n, _)) 173 | with { 174 | optim(i, n, _)= _ * cos(indexabs / (2*n+1) * ma.PI) 175 | with { 176 | numberOfharmonics = 2 *n + 1; 177 | indexabs = (int)((i - 1) / 2 + 1); 178 | }; 179 | }; 180 | 181 | 182 | //----------------`(ho.)optimInPhase`------------------------- 183 | // The inPhase Optimization optimize energy vector and put all loudspeakers signals 184 | // in phase. It should be used for an auditory. 185 | // 186 | // #### Usage 187 | // 188 | // ``` 189 | // _ : optimInPhase(n) : _ 190 | // ``` 191 | // 192 | // Where: 193 | // 194 | // * `n`: the order 195 | //----------------------------------------------------- 196 | optimInPhase(n) = par(i, 2*n+1, optim(i, n, _)) 197 | with 198 | { 199 | optim(i, n, _)= _ * (fact(n)^2.) / (fact(n+indexabs) * fact(n-indexabs)) 200 | with 201 | { 202 | indexabs = (int)((i - 1) / 2 + 1); 203 | fact(0) = 1; 204 | fact(n) = n * fact(n-1); 205 | }; 206 | }; 207 | 208 | 209 | //----------------`(ho.)wider`------------------------- 210 | // Can be used to wide the diffusion of a localized sound. The order 211 | // depending signals are weighted and appear in a logarithmic way to 212 | // have linear changes. 213 | // 214 | // #### Usage 215 | // 216 | // ``` 217 | // _ : wider(n,w) : _ 218 | // ``` 219 | // 220 | // Where: 221 | // 222 | // * `n`: the order 223 | // * `w`: the width value between 0 - 1 224 | //----------------------------------------------------- 225 | wider(n, w) = par(i, 2*n+1, perform(n, w, i, _)) 226 | with 227 | { 228 | perform(n, w, i, _) = _ * (log(n+1) * (1 - w) + 1) * clipweight 229 | with 230 | { 231 | clipweight = weighter(n, w, i) * (weighter(n, w, i) > 0) * (weighter(n, w, i) <= 1) + (weighter(n, w, i) > 1) 232 | with 233 | { 234 | weighter(n, w, 0) = 1.; 235 | weighter(n, w, i) = (((w * log(n+1)) - log(indexabs)) / (log(indexabs+1) - log(indexabs))) 236 | with 237 | { 238 | indexabs = (int)((i - 1) / 2 + 1); 239 | }; 240 | }; 241 | }; 242 | }; 243 | 244 | 245 | 246 | //----------------`(ho.)map`------------------------- 247 | // It simulate the distance of the source by applying a gain 248 | // on the signal and a wider processing on the soundfield. 249 | // 250 | // #### Usage 251 | // 252 | // ``` 253 | // map(n, x, r, a) 254 | // ``` 255 | // 256 | // Where: 257 | // 258 | // * `n`: the order 259 | // * `x`: the signal 260 | // * `r`: the radius 261 | // * `a`: the angle in radian 262 | //----------------------------------------------------- 263 | map(n, x, r, a) = encoder(n, x * volume(r), a) : wider(n, ouverture(r)) 264 | with 265 | { 266 | volume(r) = 1. / (r * r * (r > 1) + (r < 1)); 267 | ouverture(r) = r * (r < 1) + (r > 1); 268 | }; 269 | 270 | 271 | 272 | 273 | //----------------`(ho.)rotate`------------------------- 274 | // Rotates the sound field. 275 | // 276 | // #### Usage 277 | // 278 | // ``` 279 | // _ : rotate(n, a) : _ 280 | // ``` 281 | // 282 | // Where: 283 | // 284 | // * `n`: the order 285 | // * `a`: the angle in radian 286 | //----------------------------------------------------- 287 | rotate(n, a) = par(i, 2*n+1, _) <: par(i, 2*n+1, rotation(i, a)) 288 | with 289 | { 290 | rotation(i, a) = (par(j, 2*n+1, gain1(i, j, a)), par(j, 2*n+1, gain2(i, j, a)), par(j, 2*n+1, gain3(i, j, a)) :> _) 291 | with 292 | { 293 | indexabs = (int)((i - 1) / 2 + 1); 294 | gain1(i, j, a) = _ * cos(a * indexabs) * (j == i); 295 | gain2(i, j, a) = _ * sin(a * indexabs) * (j-1 == i) * (j != 0) * (i%2 == 1); 296 | gain3(i, j, a) = (_ * sin(a * indexabs)) * (j+1 == i) * (j != 0) * (i%2 == 0); 297 | }; 298 | }; 299 | -------------------------------------------------------------------------------- /dist/assets/faust-lib/instruments.lib: -------------------------------------------------------------------------------- 1 | //instruments.lib - Faust function of various types useful for building physical model instruments 2 | 3 | declare name "Faust-STK Tools Library"; 4 | declare author "Romain Michon (rmichon@ccrma.stanford.edu)"; 5 | declare copyright "Romain Michon"; 6 | declare version "1.0"; 7 | declare licence "STK-4.3"; // Synthesis Tool Kit 4.3 (MIT style license); 8 | 9 | no = library("noises.lib"); 10 | en = library("envelopes.lib"); 11 | ma = library("maths.lib"); 12 | ba = library("basics.lib"); 13 | de = library("delays.lib"); 14 | si = library("signals.lib"); 15 | fi = library("filters.lib"); 16 | os = library("oscillators.lib"); 17 | re = library("reverbs.lib"); 18 | 19 | //========================= ENVELOPE GENERATORS =============================== 20 | 21 | //----------------------- VIBRATO ENVELOPE ---------------------------- 22 | // 4 phases envelope to control vibrato gain 23 | // 24 | // USAGE: 25 | // _ : *(envVibrato(b,a,s,r,t)) : _ 26 | // where 27 | // b = beginning duration (silence) in seconds 28 | // a = attack duration in seconds 29 | // s = sustain as a percentage of the amplitude to be modified 30 | // r = release duration in seconds 31 | // t = trigger signal 32 | 33 | envVibrato(b,a,s,r,t) = env ~ (_,_,_) : (!,!,_) // the 3 'state' signals are fed back 34 | with { 35 | env (p2,cnt,y) = 36 | (t>0) & (p2|(y>=1)), 37 | (cnt + 1)*(t>0), // counter for the first step "b" 38 | (y + p1*p3*u*(s/100) - p4*w*y)*((p4==0)|(y>=eps)) // y = envelop signal 39 | //*(y>=eps) // cut off tails to prevent denormals 40 | with { 41 | p1 = (p2==0) & (t>0) & (y<1) & (cnt>(b*ma.SR)); // p1 = attack phase 42 | p3 = 1-(cnt<(nb)); // p3 = beginning phase 43 | p4 = (t<=0) & (y>0); // p4 = release phase 44 | // #samples in attack, release, must be >0 45 | nb = ma.SR*b+(b==0.0) ; na = ma.SR*a+(a==0.0); nr = ma.SR*r+(r==0.0); 46 | // attack and (-60dB) release rates 47 | z = s+(s==0.0)*ba.db2linear(-60); 48 | u = 1/na; w = 1-1/pow(z*ba.db2linear(60), 1/nr); 49 | // values below this threshold are considered zero in the release phase 50 | eps = ba.db2linear(-120); 51 | }; 52 | }; 53 | 54 | //----------------------- ASYMPT60 ---------------------------- 55 | // Envelope generator which asymptotically approaches a target value. 56 | // 57 | // USAGE: 58 | // asympT60(value,trgt,T60,trig) : _ 59 | // where 60 | // value = starting value 61 | // trgt = target value 62 | // T60 = ramping time 63 | // trig = trigger signal 64 | 65 | asympT60(value,trgt,T60,trig) = (_*factor + constant)~_ 66 | with { 67 | cntSample = *(trig) + 1~_ : -(1); 68 | attDur = float(2); 69 | cndFirst = ((cntSample < attDur) & (trig > 0)); 70 | target = value*cndFirst + trgt*(cndFirst < 1); 71 | factorAtt = exp(-7/attDur); 72 | factorT60 = exp(-7/(T60*float(ma.SR))); 73 | factor = factorAtt*((cntSample < attDur) & (trig > 0)) + 74 | ((cntSample >= attDur) | (trig < 1))*factorT60; 75 | constant = (1 - factor)*target; 76 | }; 77 | 78 | //========================= TABLES =============================== 79 | 80 | //----------------------- CLIPPING FUNCTION ---------------------------- 81 | // Positive and negative clipping functions. 82 | // 83 | // USAGE: 84 | // _ : saturationPos : _ 85 | // _ : saturationNeg : _ 86 | // _ : saturationPos : saturationNeg : _ 87 | 88 | saturationPos(x) = x <: (_>1),(_<=1 : *(x)) :> +; 89 | saturationNeg(x) = x <: (_<-1),(_>=-1 : *(x)) :> *(-1) + _; 90 | 91 | //----------------------- BOW TABLE ---------------------------- 92 | // Simple bow table. 93 | // 94 | // USAGE: 95 | // index : bow(offset,slope) : _ 96 | // where 97 | // 0 <= index <= 1 98 | 99 | bow(offset,slope) = pow(abs(sample) + 0.75, -4) : saturationPos 100 | with { 101 | sample(y) = (y + offset)*slope; 102 | }; 103 | 104 | //----------------------- REED TABLE ---------------------------- 105 | // Simple reed table to be used with waveguide models of clanrinet, saxophone, etc. 106 | // 107 | // USAGE: 108 | // _ : reed(offset,slope) : _ 109 | // where 110 | // offset = offset between 0 and 1 111 | // slope = slope between 0 and 1 112 | // REFERENCE: 113 | // https://ccrma.stanford.edu/~jos/pasp/View_Single_Reed_Oscillation.html 114 | 115 | reed(offset,slope) = reedTable : saturationPos : saturationNeg 116 | with { 117 | reedTable = offset + (slope*_); 118 | }; 119 | 120 | //========================= FILTERS =============================== 121 | 122 | //----------------------- ONE POLE ---------------------------- 123 | 124 | onePole(b0,a1,x) = (b0*x - a1*_)~_; 125 | 126 | //----------------------- ONE POLE SWEPT ---------------------------- 127 | 128 | onePoleSwep(a1,x) = (1 + a1)*x - a1*x'; 129 | 130 | //----------------------- POLE ZERO ---------------------------- 131 | 132 | poleZero(b0,b1,a1,x) = (b0*x + b1*x' - a1*_)~_; 133 | 134 | //----------------------- ONE ZEROS ---------------------------- 135 | // Simple One zero and One zero recursive filters 136 | // 137 | // USAGE: 138 | // _ : oneZero0(b0,b1) : _ 139 | // _ : oneZero1(b0,b1) : _ 140 | // REFERENCE: 141 | // https://ccrma.stanford.edu/~jos/fp2/One_Zero.html 142 | 143 | oneZero0(b0,b1,x) = (*(b1) + x*b0)~_; 144 | oneZero1(b0,b1,x) = (x'*b1 + x*b0); 145 | 146 | //----------------------- BANDPASS FILTER WITH CONSTANT UNITY PEAK GAIN BASED ON A BIQUAD ---------------------------- 147 | 148 | bandPass(resonance,radius) = fi.TF2(b0,b1,b2,a1,a2) 149 | with { 150 | a2 = radius*radius; 151 | a1 = -2*radius*cos(ma.PI*2*resonance/ma.SR); 152 | b0 = 0.5-0.5*a2; 153 | b1 = 0; 154 | b2 = -b0; 155 | }; 156 | 157 | //----------------------- BANDPASS FILTER BASED ON A BIQUAD ---------------------------- 158 | // Band pass filter using a biquad (TF2 is declared in filter.lib) 159 | // 160 | // USAGE: 161 | // _ : bandPassH(resonance,radius) : _ 162 | // where 163 | // resonance = center frequency 164 | // radius = radius 165 | 166 | bandPassH(resonance,radius) = fi.TF2(b0,b1,b2,a1,a2) 167 | with { 168 | a2 = radius*radius; 169 | a1 = -2*radius*cos(ma.PI*2*resonance/ma.SR); 170 | b0 = 1; 171 | b1 = 0; 172 | b2 = 0; 173 | }; 174 | 175 | //----------------------- FLUE JET NON-LINEAR FUNCTION ---------------------------- 176 | // Jet Table: flue jet non-linear function, computed by a polynomial calculation 177 | 178 | jetTable(x) = x <: _*(_*_-1) : saturationPos : saturationNeg; 179 | 180 | //----------------------- NON LINEAR MODULATOR ---------------------------- 181 | // nonLinearModulator adapts the function allpassnn from filter.lib for using it with waveguide instruments 182 | // 183 | // USAGE: 184 | // _ : nonLinearModulator(nonlinearity,env,freq,typeMod,freqMod,order) : _ 185 | // where 186 | // nonlinearity = nonlinearity coefficient between 0 and 1 187 | // env = input to connect any kind of envelope 188 | // freq = current tone frequency 189 | // typeMod = if 0: theta is modulated by the incoming signal; 190 | // if 1: theta is modulated by the averaged incoming signal; 191 | // if 2: theta is modulated by the squared incoming signal; 192 | // if 3: theta is modulated by a sine wave of frequency freqMod; 193 | // if 4: theta is modulated by a sine wave of frequency freq; 194 | // freqMod = frequency of the sine wave modulation 195 | // order = order of the filter 196 | 197 | nonLinearModulator(nonlinearity,env,freq,typeMod,freqMod,order) = 198 | //theta is modulated by a sine wave 199 | _ <: nonLinearFilterOsc*(typeMod >= 3), 200 | //theta is modulated by the incoming signal 201 | (_ <: nonLinearFilterSig*nonlinearity,_*(1 - nonlinearity) :> +)*(typeMod < 3) 202 | :> + 203 | with { 204 | //which frequency to use for the sine wave oscillator? 205 | freqOscMod = (typeMod == 4)*freq + (typeMod != 4)*freqMod; 206 | 207 | //the incoming signal is scaled and the envelope is applied 208 | tsignorm(x) = nonlinearity*ma.PI*x*env; 209 | tsigsquared(x) = nonlinearity*ma.PI*x*x*env; //incoming signal is squared 210 | tsigav(x) = nonlinearity*ma.PI*((x + x')/2)*env; //incoming signal is averaged with its previous sample 211 | 212 | //select which version of the incoming signal of theta to use 213 | tsig(x) = tsignorm(x)*(typeMod == 0) + tsigav(x)*(typeMod == 1) 214 | + tsigsquared(x)*(typeMod == 2); 215 | 216 | //theta is modulated by a sine wave generator 217 | tosc = nonlinearity*ma.PI*os.osc(freqOscMod)*env; 218 | 219 | //incoming signal is sent to the nonlinear passive allpass ladder filter 220 | nonLinearFilterSig(x) = x <: fi.allpassnn(order,(par(i,order,tsig(x)))); 221 | nonLinearFilterOsc = _ <: fi.allpassnn(order,(par(i,order,tosc))); 222 | }; 223 | 224 | //========================= TOOLS =============================== 225 | 226 | //----------------------- STEREOIZER ---------------------------- 227 | // This function takes a mono input signal and spacialize it in stereo 228 | // in function of the period duration of the tone being played. 229 | // 230 | // USAGE: 231 | // _ : stereo(periodDuration) : _,_ 232 | // where 233 | // periodDuration = period duration of the tone being played in number of samples 234 | // REFERENCE: 235 | // https://ccrma.stanford.edu/realsimple/faust_strings/ 236 | 237 | stereoizer(periodDuration) = _ <: _,widthdelay : stereopanner 238 | with { 239 | W = hslider("v:Spat/spatial width", 0.5, 0, 1, 0.01); 240 | A = hslider("v:Spat/pan angle", 0.6, 0, 1, 0.01); 241 | widthdelay = de.delay(4096,W*periodDuration/2); 242 | stereopanner = _,_ : *(1.0-A), *(A); 243 | }; 244 | 245 | //----------------------- INSTRREVERB ---------------------------- 246 | // GUI for zita_rev1_stereo from reverbs.lib 247 | // 248 | // USAGE: 249 | // _,_ : instrRerveb 250 | 251 | instrReverb = _,_ <: *(reverbGain),*(reverbGain),*(1 - reverbGain),*(1 - reverbGain) : 252 | re.zita_rev1_stereo(rdel,f1,f2,t60dc,t60m,fsmax),_,_ <: _,!,_,!,!,_,!,_ : +,+ 253 | with { 254 | reverbGain = hslider("v:Reverb/reverbGain",0.137,0,1,0.01) : si.smoo; 255 | roomSize = hslider("v:Reverb/roomSize",0.72,0.01,2,0.01); 256 | rdel = 20; 257 | f1 = 200; 258 | f2 = 6000; 259 | t60dc = roomSize*3; 260 | t60m = roomSize*2; 261 | fsmax = 48000; 262 | }; 263 | -------------------------------------------------------------------------------- /dist/assets/faust-lib/maxmsp.lib: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | ************************************************************************ 3 | FAUST library file 4 | Copyright (C) 2003-2011 GRAME, Centre National de Creation Musicale 5 | --------------------------------------------------------------------- 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as 8 | published by the Free Software Foundation; either version 2.1 of the 9 | License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, write to the Free 18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 | 02111-1307 USA. 20 | ************************************************************************ 21 | ************************************************************************/ 22 | 23 | declare name "MaxMSP compatibility Library"; 24 | declare author "GRAME"; 25 | declare copyright "GRAME"; 26 | declare version "1.1"; 27 | declare license "LGPL"; 28 | 29 | ba = library("basics.lib"); 30 | ma = library("maths.lib"); 31 | 32 | atodb = db2lin; 33 | 34 | //------------------------------------------------------------------------- 35 | // 36 | // Implementation of MaxMSP filtercoeff 37 | // 38 | // from : Cookbook formulae for audio EQ biquad filter coefficients 39 | // by : Robert Bristow-Johnson 40 | // URL : http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt 41 | // 42 | //------------------------------------------------------------------------- 43 | 44 | filtercoeff(f0, dBgain, Q) = environment 45 | { 46 | //---------------------------------------- 47 | // biquad coeffs for various filters 48 | // usage : filtercoeff(f0, dBgain, Q).LPF 49 | //---------------------------------------- 50 | 51 | LPF = rbjcoef( a0, a1, a2, b0, b1, b2 ) 52 | with { 53 | b0 = (1 - cos(w0))/2; 54 | b1 = 1 - cos(w0); 55 | b2 = (1 - cos(w0))/2; 56 | a0 = 1 + alpha; 57 | a1 = -2*cos(w0); 58 | a2 = 1 - alpha; 59 | }; 60 | 61 | HPF = rbjcoef( a0, a1, a2, b0, b1, b2 ) 62 | with { 63 | b0 = (1 + cos(w0))/2; 64 | b1 = -1 - cos(w0); 65 | b2 = (1 + cos(w0))/2; 66 | a0 = 1 + alpha; 67 | a1 = -2*cos(w0); 68 | a2 = 1 - alpha; 69 | }; 70 | 71 | BPF = rbjcoef( a0, a1, a2, b0, b1, b2 ) // constant 0 dB peak gain 72 | with { 73 | b0 = alpha; 74 | b1 = 0; 75 | b2 = -alpha; 76 | a0 = 1 + alpha; 77 | a1 = -2*cos(w0); 78 | a2 = 1 - alpha; 79 | }; 80 | 81 | notch = rbjcoef( a0, a1, a2, b0, b1, b2 ) 82 | with { 83 | b0 = 1; 84 | b1 = -2*cos(w0); 85 | b2 = 1; 86 | a0 = 1 + alpha; 87 | a1 = -2*cos(w0); 88 | a2 = 1 - alpha; 89 | }; 90 | 91 | APF = rbjcoef( a0, a1, a2, b0, b1, b2 ) 92 | with { 93 | b0 = 1 - alpha; 94 | b1 = -2*cos(w0); 95 | b2 = 1 + alpha; 96 | a0 = 1 + alpha; 97 | a1 = -2*cos(w0); 98 | a2 = 1 - alpha; 99 | }; 100 | 101 | peakingEQ = rbjcoef( a0, a1, a2, b0, b1, b2 ) 102 | with { 103 | b0 = 1 + alpha*A; 104 | b1 = -2*cos(w0); 105 | b2 = 1 - alpha*A; 106 | a0 = 1 + alpha/A; 107 | a1 = -2*cos(w0); 108 | a2 = 1 - alpha/A; 109 | }; 110 | 111 | peakNotch = rbjcoef( a0, a1, a2, b0, b1, b2 ) 112 | with { 113 | b0 = 1 + alpha*G; 114 | b1 = -2*cos(w0); 115 | b2 = 1 - alpha*G; 116 | a0 = 1 + alpha/G; 117 | a1 = -2*cos(w0); 118 | a2 = 1 - alpha/G; 119 | }; 120 | 121 | lowShelf = rbjcoef( a0, a1, a2, b0, b1, b2 ) 122 | with { 123 | b0 = A*( (A+1) - (A-1)*cos(w0) + 2*sqrt(A)*alpha ); 124 | b1 = 2*A*( (A-1) - (A+1)*cos(w0) ); 125 | b2 = A*( (A+1) - (A-1)*cos(w0) - 2*sqrt(A)*alpha ); 126 | a0 = (A+1) + (A-1)*cos(w0) + 2*sqrt(A)*alpha; 127 | a1 = -2*( (A-1) + (A+1)*cos(w0) ); 128 | a2 = (A+1) + (A-1)*cos(w0) - 2*sqrt(A)*alpha; 129 | }; 130 | 131 | highShelf = rbjcoef( a0, a1, a2, b0, b1, b2 ) 132 | with { 133 | b0 = A*( (A+1) + (A-1)*cos(w0) + 2*sqrt(A)*alpha ); 134 | b1 = -2*A*( (A-1) + (A+1)*cos(w0) ); 135 | b2 = A*( (A+1) + (A-1)*cos(w0) - 2*sqrt(A)*alpha ); 136 | a0 = (A+1) - (A-1)*cos(w0) + 2*sqrt(A)*alpha; 137 | a1 = 2*( (A-1) - (A+1)*cos(w0) ); 138 | a2 = (A+1) - (A-1)*cos(w0) - 2*sqrt(A)*alpha; 139 | }; 140 | 141 | // --------------------- implementation ------------------------------ 142 | 143 | // convert rbj coeffs to biquad coeffs 144 | rbjcoef(a0,a1,a2,b0,b1,b2) = (b0/a0, b1/a0, b2/a0, a1/a0, a2/a0); 145 | 146 | // common values 147 | // alpha = sin(w0)/(2*Q); 148 | // w0 = 2*ma.PI*f0/Fs; 149 | alpha = sin(w0)/(2*max(0.001,Q)); 150 | w0 = 2*ma.PI*max(0,f0)/Fs; 151 | Fs = ma.SR; 152 | A = 10^(dBgain/40); // (for peaking and shelving EQ filters only) 153 | G = sqrt(max(0.00001, dBgain)); // When gain is a linear values (i.e. not in dB) 154 | }; 155 | 156 | 157 | //------------------------------------------------------------------------- 158 | // Implementation of MaxMSP biquad~ 159 | // y[n] = a0 * x[n] + a1 * x[n-1] + a2 * x[n-2] - b1 * y[n-1] - b2 * y[n-2] 160 | //------------------------------------------------------------------------- 161 | 162 | biquad(x,a0,a1,a2,b1,b2) = x : + ~ ((-1)*conv2(b1, b2)) : conv3(a0, a1, a2) 163 | with { 164 | conv2(c0,c1,x) = c0*x+c1*x'; 165 | conv3(c0,c1,c2,x) = c0*x+c1*x'+c2*x''; 166 | }; 167 | 168 | //------------------------------------------------------------------------- 169 | // 170 | // Filters using filtercoeff and biquad 171 | // 172 | //------------------------------------------------------------------------- 173 | 174 | // Low Pass Filter 175 | LPF(x, f0, gain, Q) = x , filtercoeff(f0,gain,Q).LPF : biquad; 176 | 177 | // High Pass Filter 178 | HPF(x, f0, gain, Q) = x , filtercoeff(f0,gain,Q).HPF : biquad; 179 | 180 | // Band Pass Filter 181 | BPF(x, f0, gain, Q) = x , filtercoeff(f0,gain,Q).BPF : biquad; 182 | 183 | // notch Filter 184 | notch(x, f0, gain, Q) = x , filtercoeff(f0,gain,Q).notch : biquad; 185 | 186 | // All Pass Filter 187 | APF(x, f0, gain, Q) = x , filtercoeff(f0,gain,Q).APF : biquad; 188 | 189 | // ???? 190 | peakingEQ(x, f0, gain, Q) = x , filtercoeff(f0,gain,Q).peakingEQ : biquad; 191 | 192 | // Max peakNotch is like peakingEQ but with a linear gain 193 | peakNotch(x, f0, gain, Q) = x , filtercoeff(f0,gain,Q).peakNotch : biquad; 194 | 195 | // ???? 196 | lowShelf(x, f0, gain, Q) = x , filtercoeff(f0,gain,Q).lowShelf : biquad; 197 | 198 | // ???? 199 | highShelf(x, f0, gain, Q) = x , filtercoeff(f0,gain,Q).highShelf : biquad; 200 | 201 | 202 | //------------------------------------------------------------------------- 203 | // Implementation of Max/MSP line~. Generate signal ramp or envelope 204 | // 205 | // USAGE : line(value, time) 206 | // value : the desired output value 207 | // time : the interpolation time to reach this value (in milliseconds) 208 | // 209 | // NOTE : the interpolation process is restarted every time the desired 210 | // output value changes. The interpolation time is sampled only then. 211 | //------------------------------------------------------------------------- 212 | 213 | line (value, time) = state~(_,_):!,_ 214 | with { 215 | state (t, c) = nt, ba.if (nt <= 0, value, c+(value - c) / nt) 216 | with { 217 | nt = ba.if( value != value', samples, t-1); 218 | samples = time*ma.SR/1000.0; 219 | }; 220 | }; 221 | -------------------------------------------------------------------------------- /dist/assets/faust-lib/mi.lib: -------------------------------------------------------------------------------- 1 | ma = library("maths.lib"); 2 | ba = library("basics.lib"); 3 | 4 | 5 | // integrated oscillator (mass-spring-ground system) 6 | // m, k, z: mass, stiffness, damping (algorithmic values) 7 | // x0, x1: initial position and delayed position 8 | osc(m,k,z,x0,x1) = equation 9 | with{ 10 | A = 2-(k+z)/m; 11 | B = z/m-1; 12 | C = 1/m; 13 | equation = x 14 | letrec{ 15 | 'x = A*(x + (x0 : ba.impulsify)) + B*(x' + (x1 : ba.impulsify)) + C*_; 16 | }; 17 | }; 18 | 19 | // punctual mass module 20 | // m: mass (algorithmic value) 21 | // x0, x1: initial position and delayed position 22 | mass(m,x0,x1) = equation 23 | with{ 24 | A = 2; 25 | B = -1; 26 | C = 1/m; 27 | equation = x 28 | letrec{ 29 | 'x = A*(x + (x0 : ba.impulsify)) + B*(x' + (x1 : ba.impulsify) + (x0 : ba.impulsify)') + C*_; 30 | }; 31 | }; 32 | 33 | // punctual ground module 34 | // x0: initial position 35 | ground(x0) = equation 36 | with{ 37 | // could this term be removed or simlified? Need "unused" input force signal for routing scheme 38 | C = 0; 39 | equation = x 40 | letrec{ 41 | 'x = x + (x0 : ba.impulsify) + C*_; 42 | }; 43 | }; 44 | 45 | // spring 46 | // k,z: stiffness and daming (algorithmic values) 47 | spring(k,z,x1r0,x2r0,x1,x2) = k*(x1-x2) + z*((x1-(x1' + (x1r0 : ba.impulsify)))-(x2 - (x2' + (x2r0 : ba.impulsify)))) <: _*-1,_; 48 | 49 | // nlPluck 50 | // 1D non-linear picking Interaction algorithm 51 | nlPluck(k,scale,x1,x2) = 52 | select2( 53 | absdeltapos>scale, 54 | select2( 55 | absdeltapos>scale*0.5, 56 | k*deltapos, 57 | k*(ma.signum(deltapos)*scale*0.5-deltapos)), 58 | 0) <: _*-1,_ 59 | with{ 60 | deltapos = x1 - x2; 61 | absdeltapos = abs(deltapos); 62 | }; 63 | 64 | // nlBow 65 | // 1D non-linear bowing Interaction algorithm 66 | // JL: corrected error: force = 0 if beyond the scale distance value 67 | nlBow(z,scale,x1,x2) = 68 | select2( 69 | absspeed < (scale/3), 70 | z*speed, 71 | select2( 72 | absspeed0, 75 | (scale/3)*z + (-z/4)*speed, 76 | (-scale/3)*z + (-z/4)*speed 77 | ), 78 | 0 79 | ) 80 | ) <: _*-1,_ 81 | with{ 82 | speed = (x1-x1') - (x2-x2'); 83 | absspeed = abs(speed); 84 | }; 85 | 86 | // collision 87 | // k,z: stiffness and daming (algorithmic values) 88 | // thres: position threshold for the collision to be active 89 | collision(k,z,thres,x1,x2) = spring(k,z,x1,x2) : (select2(comp,0,_),select2(comp,0,_)) 90 | with{ 91 | comp = (x2-x1) 20 | ([jos](http://ccrma.stanford.edu/~jos/)), and released under the 21 | (MIT-style) [STK-4.3](#stk-4.3-license) license. 22 | 23 | All MarkDown comments in this section are Copyright 2016-2017 by Romain 24 | Michon and Julius O. Smith III, and are released under the 25 | [CCA4I](https://creativecommons.org/licenses/by/4.0/) license (TODO: if/when Romain agrees!) 26 | 27 | ************************************************************************/ 28 | 29 | //=============================Functions Reference======================================== 30 | //======================================================================================== 31 | 32 | //---------------`(pf.)flanger_mono`------------- 33 | // Mono flanging effect. 34 | // 35 | // #### Usage: 36 | // 37 | // ``` 38 | // _ : flanger_mono(dmax,curdel,depth,fb,invert) : _; 39 | // ``` 40 | // 41 | // Where: 42 | // 43 | // * `dmax`: maximum delay-line length (power of 2) - 10 ms typical 44 | // * `curdel`: current dynamic delay (not to exceed dmax) 45 | // * `depth`: effect strength between 0 and 1 (1 typical) 46 | // * `fb`: feedback gain between 0 and 1 (0 typical) 47 | // * `invert`: 0 for normal, 1 to invert sign of flanging sum 48 | // 49 | // #### Reference 50 | // 51 | // 52 | //------------------------------------------------------------ 53 | flanger_mono(dmax,curdel,depth,fb,invert) 54 | = _ <: _, (- : de.fdelay(dmax,curdel)) ~ *(fb) : _, 55 | *(select2(invert,depth,0-depth)) 56 | : + : *(0.5); 57 | 58 | //---------------`(pf.)flanger_stereo`------------- 59 | // Stereo flanging effect. 60 | // `flanger_stereo` is a standard Faust function. 61 | // 62 | // #### Usage: 63 | // 64 | // ``` 65 | // _,_ : flanger_stereo(dmax,curdel1,curdel2,depth,fb,invert) : _,_; 66 | // ``` 67 | // 68 | // Where: 69 | // 70 | // * `dmax`: maximum delay-line length (power of 2) - 10 ms typical 71 | // * `curdel`: current dynamic delay (not to exceed dmax) 72 | // * `depth`: effect strength between 0 and 1 (1 typical) 73 | // * `fb`: feedback gain between 0 and 1 (0 typical) 74 | // * `invert`: 0 for normal, 1 to invert sign of flanging sum 75 | // 76 | // #### Reference 77 | // 78 | // 79 | //------------------------------------------------------------ 80 | flanger_stereo(dmax,curdel1,curdel2,depth,fb,invert) 81 | = flanger_mono(dmax,curdel1,depth,fb,invert), 82 | flanger_mono(dmax,curdel2,depth,fb,invert); 83 | 84 | 85 | vibrato2_mono(sections,phase01,fb,width,frqmin,fratio,frqmax,speed) = 86 | (+ : seq(i,sections,ap2p(R,th(i)))) ~ *(fb) 87 | with { 88 | //tf2 = component("filters.lib").tf2; 89 | // second-order resonant digital allpass given pole radius and angle: 90 | ap2p(R,th) = fi.tf2(a2,a1,1,a1,a2) with { 91 | a2 = R^2; 92 | a1 = -2*R*cos(th); 93 | }; 94 | R = exp(-pi*width/ma.SR); 95 | cososc = os.oscrc; // oscillators.lib 96 | sinosc = os.oscrs; // oscillators.lib 97 | osc = cososc(speed) * phase01 + sinosc(speed) * (1-phase01); 98 | lfo = (1-osc)/2; // in [0,1] 99 | pi = 4*atan(1); 100 | thmin = 2*pi*frqmin/ma.SR; 101 | thmax = 2*pi*frqmax/ma.SR; 102 | th1 = thmin + (thmax-thmin)*lfo; 103 | th(i) = (fratio^(i+1))*th1; 104 | }; 105 | 106 | 107 | //-------`(pf.)phaser2_mono`----------------- 108 | // Mono phasing effect. 109 | // 110 | // #### Phaser 111 | // 112 | // ``` 113 | // _ : phaser2_mono(Notches,phase,width,frqmin,fratio,frqmax,speed,depth,fb,invert) : _; 114 | // ``` 115 | // 116 | // Where: 117 | // 118 | // * `Notches`: number of spectral notches (MACRO ARGUMENT - not a signal) 119 | // * `phase`: phase of the oscillator (0-1) 120 | // * `width`: approximate width of spectral notches in Hz 121 | // * `frqmin`: approximate minimum frequency of first spectral notch in Hz 122 | // * `fratio`: ratio of adjacent notch frequencies 123 | // * `frqmax`: approximate maximum frequency of first spectral notch in Hz 124 | // * `speed`: LFO frequency in Hz (rate of periodic notch sweep cycles) 125 | // * `depth`: effect strength between 0 and 1 (1 typical) (aka "intensity") 126 | // when depth=2, "vibrato mode" is obtained (pure allpass chain) 127 | // * `fb`: feedback gain between -1 and 1 (0 typical) 128 | // * `invert`: 0 for normal, 1 to invert sign of flanging sum 129 | // 130 | // Reference: 131 | // 132 | // * 133 | // * 134 | // * 'An Allpass Approach to Digital Phasing and Flanging', Julius O. Smith III, 135 | // Proc. Int. Computer Music Conf. (ICMC-84), pp. 103-109, Paris, 1984. 136 | // * CCRMA Tech. Report STAN-M-21: 137 | //------------------------------------------------------------ 138 | phaser2_mono(Notches,phase01,width,frqmin,fratio,frqmax,speed,depth,fb,invert) = 139 | _ <: *(g1) + g2mi*vibrato2_mono(Notches,phase01,fb,width,frqmin,fratio,frqmax,speed) 140 | with { // depth=0 => direct-signal only 141 | g1 = 1-depth/2; // depth=1 => phaser mode (equal sum of direct and allpass-chain) 142 | g2 = depth/2; // depth=2 => vibrato mode (allpass-chain signal only) 143 | g2mi = select2(invert,g2,-g2); // inversion negates the allpass-chain signal 144 | }; 145 | 146 | 147 | //-------`(pf.)phaser2_stereo`------- 148 | // Stereo phasing effect. 149 | // `phaser2_stereo` is a standard Faust function. 150 | // 151 | // #### Phaser 152 | // 153 | // ``` 154 | // _ : phaser2_stereo(Notches,phase,width,frqmin,fratio,frqmax,speed,depth,fb,invert) : _; 155 | // ``` 156 | // 157 | // Where: 158 | // 159 | // * `Notches`: number of spectral notches (MACRO ARGUMENT - not a signal) 160 | // * `phase`: phase of the oscillator (0-1) 161 | // * `width`: approximate width of spectral notches in Hz 162 | // * `frqmin`: approximate minimum frequency of first spectral notch in Hz 163 | // * `fratio`: ratio of adjacent notch frequencies 164 | // * `frqmax`: approximate maximum frequency of first spectral notch in Hz 165 | // * `speed`: LFO frequency in Hz (rate of periodic notch sweep cycles) 166 | // * `depth`: effect strength between 0 and 1 (1 typical) (aka "intensity") 167 | // when depth=2, "vibrato mode" is obtained (pure allpass chain) 168 | // * `fb`: feedback gain between -1 and 1 (0 typical) 169 | // * `invert`: 0 for normal, 1 to invert sign of flanging sum 170 | // 171 | // Reference: 172 | // 173 | // * 174 | // * 175 | // * 'An Allpass Approach to Digital Phasing and Flanging', Julius O. Smith III, 176 | // Proc. Int. Computer Music Conf. (ICMC-84), pp. 103-109, Paris, 1984. 177 | // * CCRMA Tech. Report STAN-M-21: 178 | //------------------------------------------------------------ 179 | phaser2_stereo(Notches,width,frqmin,fratio,frqmax,speed,depth,fb,invert) 180 | = phaser2_mono(Notches,0,width,frqmin,fratio,frqmax,speed,depth,fb,invert), 181 | phaser2_mono(Notches,1,width,frqmin,fratio,frqmax,speed,depth,fb,invert); 182 | 183 | // end jos section 184 | /************************************************************************ 185 | ************************************************************************ 186 | FAUST library file, GRAME section 187 | 188 | Except where noted otherwise, Copyright (C) 2003-2017 by GRAME, 189 | Centre National de Creation Musicale. 190 | ---------------------------------------------------------------------- 191 | GRAME LICENSE 192 | 193 | This program is free software; you can redistribute it and/or modify 194 | it under the terms of the GNU Lesser General Public License as 195 | published by the Free Software Foundation; either version 2.1 of the 196 | License, or (at your option) any later version. 197 | 198 | This program is distributed in the hope that it will be useful, 199 | but WITHOUT ANY WARRANTY; without even the implied warranty of 200 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 201 | GNU Lesser General Public License for more details. 202 | 203 | You should have received a copy of the GNU Lesser General Public 204 | License along with the GNU C Library; if not, write to the Free 205 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 206 | 02111-1307 USA. 207 | 208 | EXCEPTION TO THE LGPL LICENSE : As a special exception, you may create a 209 | larger FAUST program which directly or indirectly imports this library 210 | file and still distribute the compiled code generated by the FAUST 211 | compiler, or a modified version of this compiled code, under your own 212 | copyright and license. This EXCEPTION TO THE LGPL LICENSE explicitly 213 | grants you the right to freely choose the license for the resulting 214 | compiled code. In particular the resulting compiled code has no obligation 215 | to be LGPL or GPL. For example you are free to choose a commercial or 216 | closed source license or any other license if you decide so. 217 | ************************************************************************ 218 | ************************************************************************/ 219 | 220 | // TODO: Add GRAME functions here 221 | 222 | //######################################################################################## 223 | /************************************************************************ 224 | FAUST library file, further contributions section 225 | 226 | All contributions below should indicate both the contributor and terms 227 | of license. If no such indication is found, "git blame" will say who 228 | last edited each line, and that person can be emailed to inquire about 229 | license disposition, if their license choice is not already indicated 230 | elsewhere among the libraries. It is expected that all software will be 231 | released under LGPL, STK-4.3, MIT, BSD, or a similar FOSS license. 232 | ************************************************************************/ 233 | -------------------------------------------------------------------------------- /dist/assets/faust-lib/reducemaps.lib: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | ************************************************************************ 3 | FAUST library file 4 | Copyright (C) 2010-2011 GRAME, Centre National de Creation Musicale 5 | --------------------------------------------------------------------- 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as 8 | published by the Free Software Foundation; either version 2.1 of the 9 | License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, write to the Free 18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 | 02111-1307 USA. 20 | ************************************************************************ 21 | ************************************************************************/ 22 | 23 | declare name "Reduce Library"; 24 | declare author "Yann Orlarey (orlarey at grame.fr)"; 25 | declare copyright "Grame"; 26 | declare version "0.1"; 27 | declare license "LGPL"; 28 | 29 | 30 | //--------------------------------------------------------------- 31 | // Provides various operations on block of samples 32 | // using a high order 'reduce(op, n)' fold-like function : 33 | // 34 | // sumn(n) : the sum of a block of n input samples 35 | // maxn(n) : the max of a block of n input samples 36 | // minn(n) : the min of a block of n input samples 37 | // mean(n) : the mean of a block of n input samples 38 | // RMS(n) : the RMS of a block of n input samples 39 | //--------------------------------------------------------------- 40 | 41 | 42 | 43 | //--------------------------------------------------------------- 44 | // reduce (op, n, x) 45 | //--------------------------------------------------------------- 46 | // Fold-like high order function. Apply a binary operation 47 | // on a block of consecutive samples of a signal . 48 | // For example : reduce(max,128) will compute the maximun of each 49 | // block of 128 samples. Please note that the resulting 50 | // value, while produced continuously, will be constant for 51 | // the duration of a block. A new value is only produced 52 | // at the end of a block. Note also that blocks should be of at 53 | // least one sample (n>0). 54 | reduce(op, n, x) = compute ~ (_,_,_) : (!,!,_) 55 | with { 56 | compute (acc, count, val) = 57 | if(count (xn,..,x2,x1)`. 50 | // `cross` is a standard Faust function. 51 | // 52 | // #### Usage 53 | // 54 | // ``` 55 | // cross(n) 56 | // _,_,_ : cross(3) : _,_,_ 57 | // ``` 58 | // 59 | // Where: 60 | // 61 | // * `n`: number of signals (int, must be known at compile time) 62 | // 63 | // #### Note 64 | // 65 | // Special case: `cross2`: 66 | // 67 | // ``` 68 | // cross2 = _,cross(2),_; 69 | // ``` 70 | //----------------------------------------------------------------------------- 71 | // cross n cables : (x1,x2,..,xn) -> (xn,..,x2,x1) 72 | cross(n) = si.bus(n) <: par(i,n,ba.selector(n-i-1,n)); 73 | cross2 = _,cross(2),_; // for compatibility with some old misceffects.lib functions 74 | 75 | 76 | //--------------`(ro.)crossnn`-------------- 77 | // Cross two `bus(n)`s. 78 | // 79 | // #### Usage 80 | // 81 | // ``` 82 | // _,_,... : crossmm(n) : _,_,... 83 | // ``` 84 | // 85 | // Where: 86 | // 87 | // * `n`: the number of signals in the `bus` 88 | //-------------------------------------- 89 | crossnn(n) = si.bus(n),si.bus(n) <: si.block(n),si.bus(n),si.bus(n),si.block(n); 90 | 91 | 92 | //--------------`(ro.)crossn1`-------------- 93 | // Cross bus(n) and bus(1). 94 | // 95 | // #### Usage 96 | // 97 | // ``` 98 | // _,_,... : crossn1(n) : _,_,... 99 | // ``` 100 | // 101 | // Where: 102 | // 103 | // * `n`: the number of signals in the first `bus` 104 | //-------------------------------------- 105 | crossn1(n) = si.bus(n),(si.bus(1)<:si.bus(n)) <: si.block(n),si.bus(n),si.bus(n), 106 | si.block(n):si.bus(1),si.block(n-1),si.bus(n); 107 | 108 | 109 | //--------------------------`(ro.)interleave`------------------------------ 110 | // Interleave row*col cables from column order to row order. 111 | // input : x(0), x(1), x(2) ..., x(row*col-1) 112 | // output: x(0+0*row), x(0+1*row), x(0+2*row), ..., x(1+0*row), x(1+1*row), x(1+2*row), ... 113 | // 114 | // #### Usage 115 | // 116 | // ``` 117 | // _,_,_,_,_,_ : interleave(row,column) : _,_,_,_,_,_ 118 | // ``` 119 | // 120 | // Where: 121 | // 122 | // * `row`: the number of row (int, known at compile time) 123 | // * `column`: the number of column (int, known at compile time) 124 | //----------------------------------------------------------------------------- 125 | interleave(row,col) = si.bus(row*col) <: par(r, row, par(c, col, ba.selector(r+c*row,row*col))); 126 | 127 | 128 | //-------------------------------`(ro.)butterfly`-------------------------------- 129 | // Addition (first half) then substraction (second half) of interleaved signals. 130 | // 131 | // #### Usage 132 | // 133 | // ``` 134 | // _,_,_,_ : butterfly(n) : _,_,_,_ 135 | // ``` 136 | // 137 | // Where: 138 | // 139 | // * `n`: size of the butterfly (n is int, even and known at compile time) 140 | //----------------------------------------------------------------------------- 141 | butterfly(n) = si.bus(n) <: interleave(n/2,2), interleave(n/2,2) : par(i, n/2, +), par(i, n/2, -); 142 | 143 | 144 | //------------------------------`(ro.)hadamard`---------------------------------- 145 | // Hadamard matrix function of size `n = 2^k`. 146 | // 147 | // #### Usage 148 | // 149 | // ``` 150 | // _,_,_,_ : hadamard(n) : _,_,_,_ 151 | // ``` 152 | // 153 | // Where: 154 | // 155 | // * `n`: `2^k`, size of the matrix (int, must be known at compile time) 156 | // 157 | // #### Note: 158 | // 159 | // Implementation contributed by Remy Muller. 160 | //----------------------------------------------------------------------------- 161 | // TODO: author: Remy Muller, revised by RM 162 | hadamard(2) = butterfly(2); 163 | hadamard(n) = butterfly(n) : (hadamard(n/2) , hadamard(n/2)); 164 | 165 | 166 | //---------------`(ro.)recursivize`------------- 167 | // Create a recursion from two arbitrary processors p and q. 168 | // 169 | // #### Usage 170 | // 171 | // ``` 172 | // _,_ : recursivize(p,q) : _,_ 173 | // 174 | // ``` 175 | // 176 | // Where: 177 | // 178 | // * `p`: the forward arbitrary processor 179 | // * `q`: the feedback arbitrary processor 180 | //---------------------------------------- 181 | recursivize(p,q) = (_,_,_,_ :> sp.stereoize(p)) ~ sp.stereoize(q); 182 | -------------------------------------------------------------------------------- /dist/assets/faust-lib/sf.lib: -------------------------------------------------------------------------------- 1 | /* 2 | sf.lib - aliases all prefixes to sf = all.lib, so that both old and new prefixes can be mixed. 3 | 4 | The Faust team is committed to unique names for standard Faust 5 | functions, allowing them to all be in the same namespace. 6 | Therefore, only two namespaces are needed: (1) the highest-level 7 | scope (no prefix), and (2) the Standard Faust scope, using prefix 'sf'. 8 | */ 9 | 10 | sf = library("all.lib"); // "Standard Faust" prefix 11 | 12 | //--- use old library prefixes using old libraries --- 13 | /* 14 | ml = library("old/music.lib"); 15 | fl = library("old/filter.lib"); 16 | ol = library("old/oscillator.lib"); 17 | el = library("old/effect.lib"); 18 | */ 19 | //--- use old library prefixes using new libraries --- 20 | ol = sf; 21 | fl = sf; 22 | ml = sf; 23 | el = sf; 24 | //--- new library prefixes --- 25 | an = sf; 26 | ba = sf; 27 | co = sf; 28 | de = sf; 29 | dm = sf; 30 | dx = sf; 31 | en = sf; 32 | fi = sf; 33 | ho = sf; 34 | ma = sf; 35 | ef = sf; 36 | os = sf; 37 | no = sf; 38 | pf = sf; 39 | pm = sf; 40 | re = sf; 41 | ro = sf; 42 | sp = sf; 43 | si = sf; 44 | so = sf; 45 | sy = sf; 46 | ve = sf; 47 | //----- 48 | -------------------------------------------------------------------------------- /dist/assets/faust-lib/soundfiles.lib: -------------------------------------------------------------------------------- 1 | //#################################### soundfiles.lib ######################################## 2 | // A library to handle soundfiles in Faust. Its official prefix is `so`. 3 | //######################################################################################## 4 | 5 | /************************************************************************ 6 | ************************************************************************ 7 | FAUST library file 8 | Copyright (C) 2018 GRAME, Centre National de Creation Musicale 9 | ---------------------------------------------------------------------- 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU Lesser General Public License as 12 | published by the Free Software Foundation; either version 2.1 of the 13 | License, or (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public 21 | License along with the GNU C Library; if not, write to the Free 22 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 23 | 02111-1307 USA. 24 | 25 | EXCEPTION TO THE LGPL LICENSE : As a special exception, you may create a 26 | larger FAUST program which directly or indirectly imports this library 27 | file and still distribute the compiled code generated by the FAUST 28 | compiler, or a modified version of this compiled code, under your own 29 | copyright and license. This EXCEPTION TO THE LGPL LICENSE explicitly 30 | grants you the right to freely choose the license for the resulting 31 | compiled code. In particular the resulting compiled code has no obligation 32 | to be LGPL or GPL. For example you are free to choose a commercial or 33 | closed source license or any other license if you decide so. 34 | ************************************************************************ 35 | ************************************************************************/ 36 | 37 | declare name "Faust Soundfile Library"; 38 | declare version "0.4"; 39 | 40 | ma = library("maths.lib"); 41 | si = library("signals.lib"); 42 | 43 | //=============================Functions Reference======================================== 44 | //======================================================================================== 45 | 46 | //--------------------------------`(so.)loop`----------------------------------- 47 | // Play a soundfile in a loop taking into account its sampling rate 48 | // `loop` is a standard Faust function. 49 | // 50 | // #### Usage 51 | // 52 | // ``` 53 | // loop(s, part) 54 | // ``` 55 | // 56 | // Where: 57 | // 58 | // * `s`: the soundfile 59 | // * `part`: the part in the soundfile list 60 | // 61 | //----------------------------------------------------------------------------- 62 | 63 | loop(s, part) = (part, reader(s)) : outs(s) 64 | with { 65 | length(s) = part,0 : s : _,si.block(outputs(s)-1); 66 | srate(s) = part,0 : s : !,_,si.block(outputs(s)-2); 67 | outs(s) = s : si.block(2), si.bus(outputs(s)-2); 68 | reader(s) = float(srate(s))/ma.SR : (+,length(s):fmod)~_ : int; 69 | }; 70 | 71 | //--------------------------------`(so.)loop_speed`----------------------------------- 72 | // Play a soundfile in a loop taking into account its sampling rate, with speed control 73 | // `loop_speed` is a standard Faust function. 74 | // 75 | // #### Usage 76 | // 77 | // ``` 78 | // loop_speed(s, part, speed) 79 | // ``` 80 | // 81 | // Where: 82 | // 83 | // * `s`: the soundfile 84 | // * `part`: the part in the soundfile list 85 | // * `speed`: the speed between 0 and n 86 | // 87 | //----------------------------------------------------------------------------- 88 | 89 | loop_speed(s, part, speed) = (part, reader(s)) : outs(s) 90 | with { 91 | length(s) = part,0 : s : _,si.block(outputs(s)-1); 92 | srate(s) = part,0 : s : !,_,si.block(outputs(s)-2); 93 | outs(s) = s : si.block(2), si.bus(outputs(s)-2); 94 | reader(s) = float(speed*srate(s))/ma.SR : (+,length(s):fmod)~_ : int; 95 | }; 96 | 97 | //--------------------------------`(so.)loop_speed_level`----------------------------------- 98 | // Play a soundfile in a loop taking into account its sampling rate, with speed and level controls 99 | // `loop_speed_level` is a standard Faust function. 100 | // 101 | // #### Usage 102 | // 103 | // ``` 104 | // loop_speed_level(s, part, speed, level) 105 | // ``` 106 | // 107 | // Where: 108 | // 109 | // * `s`: the soundfile 110 | // * `part`: the part in the soundfile list 111 | // * `speed`: the speed between 0 and n 112 | // * `level`: the volume between 0 and n 113 | // 114 | //----------------------------------------------------------------------------- 115 | 116 | loop_speed_level(s, part, speed, level) = (part, reader(s)) : outs(s) 117 | with { 118 | length(s) = part,0 : s : _,si.block(outputs(s)-1); 119 | srate(s) = part,0 : s : !,_,si.block(outputs(s)-2); 120 | outs(s) = s : si.block(2), bus_level(outputs(s)-2); 121 | bus_level(n) = par(i,n,*(level)); 122 | reader(s) = float(speed*srate(s))/ma.SR : (+,length(s):fmod)~_ : int; 123 | }; 124 | 125 | -------------------------------------------------------------------------------- /dist/assets/faust-lib/spats.lib: -------------------------------------------------------------------------------- 1 | //#################################### spats.lib ########################################## 2 | // This library contains a collection of tools for sound spatialization. 3 | // Its official prefix is `sp`. 4 | //######################################################################################## 5 | 6 | /************************************************************************ 7 | ************************************************************************ 8 | FAUST library file 9 | Copyright (C) 2003-2012 GRAME, Centre National de Creation Musicale 10 | ---------------------------------------------------------------------- 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU Lesser General Public License as 13 | published by the Free Software Foundation; either version 2.1 of the 14 | License, or (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU Lesser General Public License for more details. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with the GNU C Library; if not, write to the Free 23 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 24 | 02111-1307 USA. 25 | 26 | EXCEPTION TO THE LGPL LICENSE : As a special exception, you may create a 27 | larger FAUST program which directly or indirectly imports this library 28 | file and still distribute the compiled code generated by the FAUST 29 | compiler, or a modified version of this compiled code, under your own 30 | copyright and license. This EXCEPTION TO THE LGPL LICENSE explicitly 31 | grants you the right to freely choose the license for the resulting 32 | compiled code. In particular the resulting compiled code has no obligation 33 | to be LGPL or GPL. For example you are free to choose a commercial or 34 | closed source license or any other license if you decide so. 35 | 36 | ************************************************************************ 37 | ************************************************************************/ 38 | 39 | si = library("signals.lib"); 40 | 41 | declare name "Faust Spatialization Library"; 42 | declare version "0.0"; 43 | 44 | 45 | //-----------------------`(sp.)panner`------------------------ 46 | // A simple linear stereo panner. 47 | // `panner` is a standard Faust function. 48 | // 49 | // #### Usage 50 | // 51 | // ``` 52 | // _ : panner(g) : _,_ 53 | // ``` 54 | // 55 | // Where: 56 | // 57 | // * `g`: the panning (0-1) 58 | //------------------------------------------------------------ 59 | panner(g) = _ <: *(1-g), *(g); 60 | 61 | // TODO: need demo function for panner here 62 | 63 | 64 | //-----------------------`(sp.)spat`------------------------ 65 | // GMEM SPAT: n-outputs spatializer. 66 | // `spat` is a standard Faust function. 67 | // 68 | // #### Usage 69 | // 70 | // ``` 71 | // _ : spat(n,r,d) : _,_,... 72 | // ``` 73 | // 74 | // Where: 75 | // 76 | // * `n`: number of outputs 77 | // * `r`: rotation (between 0 et 1) 78 | // * `d`: distance of the source (between 0 et 1) 79 | //------------------------------------------------------ 80 | // TODO: author Laurent Pottier, revised by RM 81 | spat(n,a,d) = _ <: par(i, n, *( scaler(i, n, a, d) : si.smooth(0.9999) )) 82 | with { 83 | scaler(i,n,a,d) = (d/2.0+0.5) 84 | * sqrt( max(0.0, 1.0 - abs(fmod(a+0.5+float(n-i)/n, 1.0) - 0.5) * n * d) ); 85 | }; 86 | 87 | 88 | //---------------`(sp.)stereoize`------------- 89 | // Transform an arbitrary processor `p` into a stereo processor with 2 inputs 90 | // and 2 outputs. 91 | // 92 | // #### Usage 93 | // 94 | // ``` 95 | // _,_ : stereoize(p) : _,_ 96 | // ``` 97 | // 98 | // Where: 99 | // 100 | // * `p`: the arbitrary processor 101 | //---------------------------------------- 102 | // NOTE: where are inputs and outputs declared? 103 | stereoize(p) = S(inputs(p), outputs(p)) 104 | with { 105 | // degenerated processor with no outputs 106 | S(n,0) = !,! : 0,0; // just in case, probably a rare case 107 | // processors with no inputs 108 | S(0,1) = !,! : p <: _,_; // add two fake inputs and split output 109 | S(0,2) = !,! : p; 110 | S(0,n) = !,! : p,p :> _,_; // we are sure this will work if n is odd 111 | // processors with one input 112 | S(1,1) = p,p; // add two fake inputs and split output 113 | S(1,n) = p,p :> _,_; // we are sure this will work if n is odd 114 | // processors with two inputs 115 | S(2,1) = p <: _,_; // split the output 116 | S(2,2) = p; // nothing to do, p is already stereo 117 | // processors with inputs > 2 and outputs > 2 118 | S(n,m) = _,_ <: p,p :> _,_; // we are sure this works if n or p are odd 119 | }; 120 | 121 | // TODO: need demo function of spat here 122 | 123 | ////////////////////////////////////////////////////////////////////////////////////////// 124 | // UNDOCUMENTED/DISMISSED ELEMENTS 125 | ////////////////////////////////////////////////////////////////////////////////////////// 126 | 127 | // music.lib: 128 | // The following functions could remain available but they would have to be 129 | // factorized and reimplemented using the `par` function... 130 | // bus2 = _,_; 131 | // bus3 = _,_,_; 132 | // bus4 = _,_,_,_; 133 | // bus5 = _,_,_,_,_; 134 | // bus6 = _,_,_,_,_,_; 135 | // bus7 = _,_,_,_,_,_,_; 136 | // bus8 = _,_,_,_,_,_,_,_; 137 | // gain2(g) = *(g),*(g); 138 | // gain3(g) = *(g),*(g),*(g); 139 | // gain4(g) = *(g),*(g),*(g),*(g); 140 | // gain5(g) = *(g),*(g),*(g),*(g),*(g); 141 | // gain6(g) = *(g),*(g),*(g),*(g),*(g),*(g); 142 | // gain7(g) = *(g),*(g),*(g),*(g),*(g),*(g),*(g); 143 | // gain8(g) = *(g),*(g),*(g),*(g),*(g),*(g),*(g),*(g); 144 | -------------------------------------------------------------------------------- /dist/assets/faust-lib/stdfaust.lib: -------------------------------------------------------------------------------- 1 | //################################ stdfaust.lib ########################################## 2 | // The purpose of this library is to give access to all the Faust standard libraries 3 | // through a series of environment. 4 | //######################################################################################## 5 | 6 | an = library("analyzers.lib"); 7 | ba = library("basics.lib"); 8 | co = library("compressors.lib"); 9 | de = library("delays.lib"); 10 | dm = library("demos.lib"); 11 | dx = library("dx7.lib"); 12 | en = library("envelopes.lib"); 13 | fi = library("filters.lib"); 14 | ho = library("hoa.lib"); 15 | ma = library("maths.lib"); 16 | ef = library("misceffects.lib"); 17 | os = library("oscillators.lib"); 18 | no = library("noises.lib"); 19 | pf = library("phaflangers.lib"); 20 | pm = library("physmodels.lib"); 21 | re = library("reverbs.lib"); 22 | ro = library("routes.lib"); 23 | sp = library("spats.lib"); 24 | si = library("signals.lib"); 25 | so = library("soundfiles.lib"); 26 | sy = library("synths.lib"); 27 | ve = library("vaeffects.lib"); 28 | sf = library("all.lib"); 29 | -------------------------------------------------------------------------------- /dist/assets/faust-lib/synths.lib: -------------------------------------------------------------------------------- 1 | //################################### synths.lib ########################################## 2 | // This library contains a collection of synthesizers. Its official 3 | // prefix is `sy`. 4 | //######################################################################################## 5 | 6 | /************************************************************************ 7 | ************************************************************************ 8 | FAUST library file 9 | Copyright (C) 2003-2016 GRAME, Centre National de Creation Musicale 10 | ---------------------------------------------------------------------- 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU Lesser General Public License as 13 | published by the Free Software Foundation; either version 2.1 of the 14 | License, or (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU Lesser General Public License for more details. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with the GNU C Library; if not, write to the Free 23 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 24 | 02111-1307 USA. 25 | 26 | EXCEPTION TO THE LGPL LICENSE : As a special exception, you may create a 27 | larger FAUST program which directly or indirectly imports this library 28 | file and still distribute the compiled code generated by the FAUST 29 | compiler, or a modified version of this compiled code, under your own 30 | copyright and license. This EXCEPTION TO THE LGPL LICENSE explicitly 31 | grants you the right to freely choose the license for the resulting 32 | compiled code. In particular the resulting compiled code has no obligation 33 | to be LGPL or GPL. For example you are free to choose a commercial or 34 | closed source license or any other license if you decide so. 35 | ************************************************************************ 36 | ************************************************************************/ 37 | 38 | declare name "Faust Synthesizer Library"; 39 | declare version "0.0"; 40 | 41 | ma = library("maths.lib"); 42 | ba = library("basics.lib"); 43 | en = library("envelopes.lib"); 44 | fi = library("filters.lib"); 45 | os = library("oscillators.lib"); 46 | no = library("noises.lib"); 47 | 48 | //-----------------------------------`(sy.)popFilterPerc`-------------------------------------- 49 | // A simple percussion instrument based on a "popped" resonant bandpass filter. 50 | // `popFilterPerc` is a standard Faust function. 51 | // 52 | // #### Usage 53 | // 54 | // ``` 55 | // popFilterDrum(freq,q,gate) : _; 56 | // ``` 57 | // 58 | // Where: 59 | // 60 | // * `freq`: the resonance frequency of the instrument 61 | // * `q`: the q of the res filter (typically, 5 is a good value) 62 | // * `gate`: the trigger signal (0 or 1) 63 | //---------------------------------------------------------------------------------------- 64 | // TODO: author RM 65 | popFilterDrum(freq,q,gate) = en.ar(0.001,0.001,gate)*no.noise : fi.resonbp(freq,q,1); 66 | 67 | 68 | //---------------------------------------`(sy.)dubDub`----------------------------------------- 69 | // A simple synth based on a sawtooth wave filtered by a resonant lowpass. 70 | // `dubDub` is a standard Faust function. 71 | // 72 | // #### Usage 73 | // 74 | // ``` 75 | // dubDub(freq,ctFreq,q,gate) : _; 76 | // ``` 77 | // 78 | // Where: 79 | // 80 | // * `freq`: frequency of the sawtooth 81 | // * `ctFreq`: cutoff frequency of the filter 82 | // * `q`: Q of the filter 83 | // * `gate`: the trigger signal (0 or 1) 84 | //---------------------------------------------------------------------------------------- 85 | // TODO: author RM 86 | dubDub(freq,ctFreq,q,gate) = os.sawtooth(freq)*gainEnvelope : fi.resonlp(ctFreq,q,1) 87 | with{ 88 | maxGain = 0.5; 89 | gainEnvelope = en.smoothEnvelope(0.01,gate)*maxGain; 90 | }; 91 | 92 | 93 | //-----------------------------------`(sy.)sawTrombone`---------------------------------------- 94 | // A simple trombone based on a lowpassed sawtooth wave. 95 | // `sawTrombone` is a standard Faust function. 96 | // 97 | // #### Usage 98 | // 99 | // ``` 100 | // sawTrombone(att,freq,gain,gate) : _ 101 | // ``` 102 | // 103 | // Where: 104 | // 105 | // * `att`: exponential attack duration in s (typically 0.01) 106 | // * `freq`: the frequency 107 | // * `gain`: the gain (0-1) 108 | // * `gate`: the gate (0 or 1) 109 | //---------------------------------------------------------------------------------------- 110 | // TODO: author RM 111 | sawTrombone(freq,gain,gate) = os.sawtooth(freq)*gainEnvelope : fi.lowpass(3,cutoff) 112 | with{ 113 | // controls both the gain of the instrument and the lowpass frequency 114 | gainEnvelope = en.smoothEnvelope(0.01,gate)*gain; 115 | cutoff = gainEnvelope*5000+50; 116 | }; 117 | 118 | 119 | //-----------------------------------`(sy.)combString`----------------------------------------- 120 | // Simplest string physical model ever based on a comb filter. 121 | // `combString` is a standard Faust function. 122 | // 123 | // #### Usage 124 | // 125 | // ``` 126 | // combString(freq,res,gate) : _; 127 | // ``` 128 | // 129 | // Where: 130 | // 131 | // * `freq`: the frequency of the string 132 | // * `res`: string T60 (resonance time) in second 133 | // * `gate`: trigger signal (0 or 1) 134 | //---------------------------------------------------------------------------------------- 135 | // TODO: author RM 136 | combString(freq,res,gate) = excitation : fi.fb_fcomb(maxDel,N,b0,aN) 137 | with{ 138 | maxDel = 1024; 139 | N = ma.SR/freq; 140 | b0 = 1; 141 | aN = ba.tau2pole(res*0.001)*-1; 142 | excitation = no.noise*en.ar(0.001,0.001,gate); 143 | }; 144 | 145 | 146 | //-----------------------------------`(sy.)additiveDrum`--------------------------------------- 147 | // A simple drum using additive synthesis. 148 | // `additiveDrum` is a standard Faust function. 149 | // 150 | // #### Usage 151 | // 152 | // ``` 153 | // additiveDrum(freq,freqRatio,gain,harmDec,att,rel,gate) : _ 154 | // ``` 155 | // 156 | // Where: 157 | // 158 | // * `freq`: the resonance frequency of the drum 159 | // * `freqRatio`: a list of ratio to choose the frequency of the mode in 160 | // function of `freq` e.g.(1 1.2 1.5 ...). The first element should always 161 | // be one (fundamental). 162 | // * `gain`: the gain of each mode as a list (1 0.9 0.8 ...). The first element 163 | // is the gain of the fundamental. 164 | // * `harmDec`: harmonic decay ratio (0-1): configure the speed at which 165 | // higher modes decay compare to lower modes. 166 | // * `att`: attack duration in second 167 | // * `rel`: release duration in second 168 | // * `gate`: trigger signal (0 or 1) 169 | //---------------------------------------------------------------------------------------- 170 | // TODO: author RM 171 | additiveDrum(freq,freqRatio,gain,modeDec,att,rel,gate) = par(i,N,os.osc(modeFreq(i))*gainEnvelope(i)) :> _ 172 | with{ 173 | N = ba.count(freqRatio); 174 | modeFreq(i) = freq*ba.take(i+1,freqRatio); 175 | modeGain(i) = ba.take(i+1,gain); 176 | gainEnvelope(i) = modeGain(i)*en.ar(att,rel*(1-(modeDec*(i/N))),gate); 177 | }; 178 | 179 | 180 | //-----------------------------------`(sy.)fm`--------------------------------------- 181 | // An FM synthesizer with an arbitrary number of modulators connected as a sequence. 182 | // `fm` is a standard Faust function. 183 | // 184 | // #### Usage 185 | // 186 | // ``` 187 | // freqs = (300,400,...); 188 | // indices = (20,...); 189 | // fm(freqs,indices) : _ 190 | // ``` 191 | // 192 | // Where: 193 | // 194 | // * `freqs`: a list of frequencies where the first one is the frequency of the carrier 195 | // and the others, the frequency of the modulator(s) 196 | // * `indices`: the indices of modulation (Nfreqs-1) 197 | //---------------------------------------------------------------------------------------- 198 | // TODO: author RM 199 | fm(freqs,indices) = seq(i,N,fmBlock(i)) 200 | with{ 201 | N = ba.count(freqs); 202 | freq(i) = ba.take(N-i,freqs); 203 | gain(i) = ba.take(N-i,indices); 204 | fmBlock(0) = freq(0) : os.osc; 205 | fmBlock(i) = *(gain(i))+freq(i) : os.osc; 206 | }; 207 | -------------------------------------------------------------------------------- /dist/assets/faust-lib/vaeffects.lib: -------------------------------------------------------------------------------- 1 | //#################################### vaeffects.lib ######################################## 2 | // A library of virtual analog filter effects. Its official prefix is `ve`. 3 | //######################################################################################## 4 | 5 | ma = library("maths.lib"); 6 | si = library("signals.lib"); 7 | an = library("analyzers.lib"); 8 | fi = library("filters.lib"); 9 | 10 | declare name "Faust Virtual Analog Filter Effect Library"; 11 | declare version "0.0"; 12 | 13 | //######################################################################################## 14 | /************************************************************************ 15 | FAUST library file, jos section 16 | 17 | Except where noted otherwise, The Faust functions below in this 18 | section are Copyright (C) 2003-2017 by Julius O. Smith III 19 | ([jos](http://ccrma.stanford.edu/~jos/)), and released under the 20 | (MIT-style) [STK-4.3](#stk-4.3-license) license. 21 | 22 | All MarkDown comments in this section are Copyright 2016-2017 by Romain 23 | Michon and Julius O. Smith III, and are released under the 24 | [CCA4I](https://creativecommons.org/licenses/by/4.0/) license (TODO: if/when Romain agrees!) 25 | 26 | ************************************************************************/ 27 | 28 | //=============================Functions Reference======================================== 29 | //======================================================================================== 30 | 31 | //-------------------------`(ve.)moog_vcf`--------------------------- 32 | // Moog "Voltage Controlled Filter" (VCF) in "analog" form. Moog VCF 33 | // implemented using the same logical block diagram as the classic 34 | // analog circuit. As such, it neglects the one-sample delay associated 35 | // with the feedback path around the four one-poles. 36 | // This extra delay alters the response, especially at high frequencies 37 | // (see reference [1] for details). 38 | // See `moog_vcf_2b` below for a more accurate implementation. 39 | // 40 | // #### Usage 41 | // 42 | // ``` 43 | // moog_vcf(res,fr) 44 | // ``` 45 | // Where: 46 | // 47 | // * `res`: normalized amount of corner-resonance between 0 and 1 48 | // (0 is no resonance, 1 is maximum) 49 | // * `fr`: corner-resonance frequency in Hz (less than SR/6.3 or so) 50 | // 51 | // #### References 52 | // * 53 | // * 54 | //------------------------------------------------------------ 55 | moog_vcf(res,fr) = (+ : seq(i,4,fi.pole(p)) : *(unitygain(p))) ~ *(mk) 56 | with { 57 | p = 1.0 - fr * 2.0 * ma.PI / ma.SR; // good approximation for fr << SR 58 | unitygain(p) = pow(1.0-p,4.0); // one-pole unity-gain scaling 59 | mk = -4.0*max(0,min(res,0.999999)); // need mk > -4 for stability 60 | }; 61 | 62 | //-----------------------`(ve.)moog_vcf_2b[n]`--------------------------- 63 | // Moog "Voltage Controlled Filter" (VCF) as two biquads. Implementation 64 | // of the ideal Moog VCF transfer function factored into second-order 65 | // sections. As a result, it is more accurate than `moog_vcf` above, but 66 | // its coefficient formulas are more complex when one or both parameters 67 | // are varied. Here, res is the fourth root of that in `moog_vcf`, so, as 68 | // the sampling rate approaches infinity, `moog_vcf(res,fr)` becomes equivalent 69 | // to `moog_vcf_2b[n](res^4,fr)` (when res and fr are constant). 70 | // `moog_vcf_2b` uses two direct-form biquads (`tf2`). 71 | // `moog_vcf_2bn` uses two protected normalized-ladder biquads (`tf2np`). 72 | // 73 | // #### Usage 74 | // 75 | // ``` 76 | // moog_vcf_2b(res,fr) 77 | // moog_vcf_2bn(res,fr) 78 | // ``` 79 | // 80 | // Where: 81 | // 82 | // * `res`: normalized amount of corner-resonance between 0 and 1 83 | // (0 is min resonance, 1 is maximum) 84 | // * `fr`: corner-resonance frequency in Hz 85 | //------------------------------------------------------------ 86 | moog_vcf_2b(res,fr) = fi.tf2s(0,0,b0,a11,a01,w1) : fi.tf2s(0,0,b0,a12,a02,w1) 87 | with { 88 | s = 1; // minus the open-loop location of all four poles 89 | frl = max(20,min(10000,fr)); // limit fr to reasonable 20-10k Hz range 90 | w1 = 2*ma.PI*frl; // frequency-scaling parameter for bilinear xform 91 | // Equivalent: w1 = 1; s = 2*PI*frl; 92 | kmax = sqrt(2)*0.99999; // 0.99999 gives stability margin (tf2 is unprotected) 93 | k = min(kmax,sqrt(2)*res); // fourth root of Moog VCF feedback gain 94 | b0 = s^2; 95 | s2k = sqrt(2) * k; 96 | a11 = s * (2 + s2k); 97 | a12 = s * (2 - s2k); 98 | a01 = b0 * (1 + s2k + k^2); 99 | a02 = b0 * (1 - s2k + k^2); 100 | }; 101 | 102 | moog_vcf_2bn(res,fr) = fi.tf2snp(0,0,b0,a11,a01,w1) : fi.tf2snp(0,0,b0,a12,a02,w1) 103 | with { 104 | s = 1; // minus the open-loop location of all four poles 105 | w1 = 2*ma.PI*max(fr,20); // frequency-scaling parameter for bilinear xform 106 | k = sqrt(2)*0.99999*res; // fourth root of Moog VCF feedback gain 107 | b0 = s^2; 108 | s2k = sqrt(2) * k; 109 | a11 = s * (2 + s2k); 110 | a12 = s * (2 - s2k); 111 | a01 = b0 * (1 + s2k + k^2); 112 | a02 = b0 * (1 - s2k + k^2); 113 | }; 114 | 115 | //--------------------------`(ve.)wah4`------------------------------- 116 | // Wah effect, 4th order. 117 | // `wah4` is a standard Faust function. 118 | // 119 | // #### Usage 120 | // 121 | // ``` 122 | // _ : wah4(fr) : _ 123 | // ``` 124 | // 125 | // Where: 126 | // 127 | // * `fr`: resonance frequency in Hz 128 | // 129 | // #### Reference 130 | // 131 | // 132 | //------------------------------------------------------------ 133 | wah4(fr) = 4*moog_vcf((3.2/4),fr:si.smooth(0.999)); 134 | 135 | //------------------------`(ve.)autowah`----------------------------- 136 | // Auto-wah effect. 137 | // `autowah` is a standard Faust function. 138 | // 139 | // #### Usage 140 | // 141 | // ``` 142 | // _ : autowah(level) : _; 143 | // ``` 144 | // 145 | // Where: 146 | // 147 | // * `level`: amount of effect desired (0 to 1). 148 | //------------------------------------------------------------ 149 | autowah(level,x) = level * crybaby(an.amp_follower(0.1,x),x) + (1.0-level)*x; 150 | 151 | //--------------------------`(ve.)crybaby`----------------------------- 152 | // Digitized CryBaby wah pedal. 153 | // `crybaby` is a standard Faust function. 154 | // 155 | // #### Usage 156 | // 157 | // ``` 158 | // _ : crybaby(wah) : _ 159 | // ``` 160 | // 161 | // Where: 162 | // 163 | // * `wah`: "pedal angle" from 0 to 1 164 | // 165 | // #### Reference 166 | // 167 | // 168 | //------------------------------------------------------------ 169 | crybaby(wah) = *(gs) : fi.tf2(1,-1,0,a1s,a2s) 170 | with { 171 | Q = pow(2.0,(2.0*(1.0-wah)+1.0)); // Resonance "quality factor" 172 | fr = 450.0*pow(2.0,2.3*wah); // Resonance tuning 173 | g = 0.1*pow(4.0,wah); // gain (optional) 174 | 175 | // Biquad fit using z = exp(s T) ~ 1 + sT for low frequencies: 176 | frn = fr/ma.SR; // Normalized pole frequency (cycles per sample) 177 | R = 1 - ma.PI*frn/Q; // pole radius 178 | theta = 2*ma.PI*frn; // pole angle 179 | a1 = 0-2.0*R*cos(theta); // biquad coeff 180 | a2 = R*R; // biquad coeff 181 | 182 | // dezippering of slider-driven signals: 183 | s = 0.999; // smoothing parameter (one-pole pole location) 184 | a1s = a1 : si.smooth(s); 185 | a2s = a2 : si.smooth(s); 186 | gs = g : si.smooth(s); 187 | 188 | //tf2 = component("filters.lib").tf2; 189 | }; 190 | 191 | // end jos section 192 | /************************************************************************ 193 | ************************************************************************ 194 | FAUST library file, GRAME section 195 | 196 | Except where noted otherwise, Copyright (C) 2003-2017 by GRAME, 197 | Centre National de Creation Musicale. 198 | ---------------------------------------------------------------------- 199 | GRAME LICENSE 200 | 201 | This program is free software; you can redistribute it and/or modify 202 | it under the terms of the GNU Lesser General Public License as 203 | published by the Free Software Foundation; either version 2.1 of the 204 | License, or (at your option) any later version. 205 | 206 | This program is distributed in the hope that it will be useful, 207 | but WITHOUT ANY WARRANTY; without even the implied warranty of 208 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 209 | GNU Lesser General Public License for more details. 210 | 211 | You should have received a copy of the GNU Lesser General Public 212 | License along with the GNU C Library; if not, write to the Free 213 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 214 | 02111-1307 USA. 215 | 216 | EXCEPTION TO THE LGPL LICENSE : As a special exception, you may create a 217 | larger FAUST program which directly or indirectly imports this library 218 | file and still distribute the compiled code generated by the FAUST 219 | compiler, or a modified version of this compiled code, under your own 220 | copyright and license. This EXCEPTION TO THE LGPL LICENSE explicitly 221 | grants you the right to freely choose the license for the resulting 222 | compiled code. In particular the resulting compiled code has no obligation 223 | to be LGPL or GPL. For example you are free to choose a commercial or 224 | closed source license or any other license if you decide so. 225 | ************************************************************************ 226 | ************************************************************************/ 227 | 228 | //----------------------------`(ve.)vocoder`------------------------- 229 | // A very simple vocoder where the spectrum of the modulation signal 230 | // is analyzed using a filter bank. 231 | // `vocoder` is a standard Faust function. 232 | // 233 | // #### Usage 234 | // 235 | // ``` 236 | // _ : vocoder(nBands,att,rel,BWRatio,source,excitation) : _; 237 | // ``` 238 | // 239 | // Where: 240 | // 241 | // * `nBands`: Number of vocoder bands 242 | // * `att`: Attack time in seconds 243 | // * `rel`: Release time in seconds 244 | // * `BWRatio`: Coefficient to adjust the bandwidth of each band (0.1 - 2) 245 | // * `source`: Modulation signal 246 | // * `excitation`: Excitation/Carrier signal 247 | //------------------------------------------------------------ 248 | // TODO: author RM 249 | oneVocoderBand(band,bandsNumb,bwRatio,bandGain,x) = x : fi.resonbp(bandFreq,bandQ,bandGain) with{ 250 | bandFreq = 25*pow(2,(band+1)*(9/bandsNumb)); 251 | BW = (bandFreq - 25*pow(2,(band)*(9/bandsNumb)))*bwRatio; 252 | bandQ = bandFreq/BW; 253 | }; 254 | 255 | vocoder(nBands,att,rel,BWRatio,source,excitation) = source <: par(i,nBands,oneVocoderBand(i,nBands,BWRatio,1) : 256 | an.amp_follower_ar(att,rel) : _,excitation : oneVocoderBand(i,nBands,BWRatio)) :> _ ; 257 | 258 | //######################################################################################## 259 | /************************************************************************ 260 | FAUST library file, further contributions section 261 | 262 | All contributions below should indicate both the contributor and terms 263 | of license. If no such indication is found, "git blame" will say who 264 | last edited each line, and that person can be emailed to inquire about 265 | license disposition, if their license choice is not already indicated 266 | elsewhere among the libraries. It is expected that all software will be 267 | released under LGPL, STK-4.3, MIT, BSD, or a similar FOSS license. 268 | ************************************************************************/ 269 | 270 | // end further further contributions section 271 | -------------------------------------------------------------------------------- /dist/assets/fonts/lato-v14-latin-700.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/dist/assets/fonts/lato-v14-latin-700.woff -------------------------------------------------------------------------------- /dist/assets/fonts/lato-v14-latin-700.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/dist/assets/fonts/lato-v14-latin-700.woff2 -------------------------------------------------------------------------------- /dist/assets/fonts/lato-v14-latin-700italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/dist/assets/fonts/lato-v14-latin-700italic.woff -------------------------------------------------------------------------------- /dist/assets/fonts/lato-v14-latin-700italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/dist/assets/fonts/lato-v14-latin-700italic.woff2 -------------------------------------------------------------------------------- /dist/assets/fonts/lato-v14-latin-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/dist/assets/fonts/lato-v14-latin-italic.woff -------------------------------------------------------------------------------- /dist/assets/fonts/lato-v14-latin-italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/dist/assets/fonts/lato-v14-latin-italic.woff2 -------------------------------------------------------------------------------- /dist/assets/fonts/lato-v14-latin-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/dist/assets/fonts/lato-v14-latin-regular.woff -------------------------------------------------------------------------------- /dist/assets/fonts/lato-v14-latin-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/dist/assets/fonts/lato-v14-latin-regular.woff2 -------------------------------------------------------------------------------- /dist/font_Lato.css: -------------------------------------------------------------------------------- 1 | /* lato-regular - latin */ 2 | @font-face { 3 | font-family: 'Lato'; 4 | font-style: normal; 5 | font-weight: 400; 6 | src: local('Lato Regular'), local('Lato-Regular'), 7 | url('./assets//fonts/lato-v14-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */ 8 | url('./assets//fonts/lato-v14-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ 9 | } 10 | /* lato-italic - latin */ 11 | @font-face { 12 | font-family: 'Lato'; 13 | font-style: italic; 14 | font-weight: 400; 15 | src: local('Lato Italic'), local('Lato-Italic'), 16 | url('./assets//fonts/lato-v14-latin-italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */ 17 | url('./assets//fonts/lato-v14-latin-italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ 18 | } 19 | /* lato-700 - latin */ 20 | @font-face { 21 | font-family: 'Lato'; 22 | font-style: normal; 23 | font-weight: 700; 24 | src: local('Lato Bold'), local('Lato-Bold'), 25 | url('./assets//fonts/lato-v14-latin-700.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */ 26 | url('./assets//fonts/lato-v14-latin-700.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ 27 | } 28 | /* lato-700italic - latin */ 29 | @font-face { 30 | font-family: 'Lato'; 31 | font-style: italic; 32 | font-weight: 700; 33 | src: local('Lato Bold Italic'), local('Lato-BoldItalic'), 34 | url('./assets//fonts/lato-v14-latin-700italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */ 35 | url('./assets//fonts/lato-v14-latin-700italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ 36 | } -------------------------------------------------------------------------------- /dist/libfaust-wasm.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/dist/libfaust-wasm.wasm -------------------------------------------------------------------------------- /dist/mixer32.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/dist/mixer32.wasm -------------------------------------------------------------------------------- /favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/favicon.png -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | const electron = require('electron') 2 | // Module to control application life. 3 | const app = electron.app 4 | // Module to create native browser window. 5 | const BrowserWindow = electron.BrowserWindow 6 | 7 | const path = require('path') 8 | const url = require('url') 9 | 10 | // Keep a global reference of the window object, if you don't, the window will 11 | // be closed automatically when the JavaScript object is garbage collected. 12 | let mainWindow 13 | 14 | function createWindow() { 15 | // Create the browser window. 16 | mainWindow = new BrowserWindow({ 17 | width: 800, 18 | height: 600 19 | }) 20 | mainWindow.setMenuBarVisibility(false); 21 | mainWindow.setAutoHideMenuBar(true); 22 | 23 | // and load the index.html of the app. 24 | mainWindow.loadURL(url.format({ 25 | pathname: path.join(__dirname, 'index.html'), 26 | protocol: 'file:', 27 | slashes: true 28 | })) 29 | 30 | // Open the DevTools. 31 | // mainWindow.webContents.openDevTools() 32 | 33 | // Emitted when the window is closed. 34 | mainWindow.on('closed', function () { 35 | // Dereference the window object, usually you would store windows 36 | // in an array if your app supports multi windows, this is the time 37 | // when you should delete the corresponding element. 38 | mainWindow = null; 39 | }) 40 | } 41 | 42 | // This method will be called when Electron has finished 43 | // initialization and is ready to create browser windows. 44 | // Some APIs can only be used after this event occurs. 45 | app.on('ready', createWindow) 46 | 47 | // Quit when all windows are closed. 48 | app.on('window-all-closed', function () { 49 | // On OS X it is common for applications and their menu bar 50 | // to stay active until the user quits explicitly with Cmd + Q 51 | if (process.platform !== 'darwin') { 52 | app.quit() 53 | } 54 | }) 55 | 56 | app.on('activate', function () { 57 | // On OS X it's common to re-create a window in the app when the 58 | // dock icon is clicked and there are no other windows open. 59 | if (mainWindow === null) { 60 | createWindow() 61 | } 62 | }) 63 | 64 | // In this file you can include the rest of your app's specific main process 65 | // code. You can also put them in separate files and require them here. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webaudio-patcher", 3 | "version": "1.0.0", 4 | "description": "A minimal Electron application", 5 | "main": "main.js", 6 | "scripts": { 7 | "build": "webpack", 8 | "start": "electron .", 9 | "debug": "webpack && electron --inspect=9559 ." 10 | }, 11 | "repository": "https://github.com/electron/electron-quick-start", 12 | "keywords": [ 13 | "Electron", 14 | "quick", 15 | "start", 16 | "tutorial", 17 | "demo" 18 | ], 19 | "author": "GitHub", 20 | "license": "CC0-1.0", 21 | "devDependencies": { 22 | "@babel/cli": "^7.0.0", 23 | "@babel/core": "^7.3.3", 24 | "@babel/polyfill": "^7.0.0", 25 | "@babel/preset-env": "^7.3.1", 26 | "@babel/preset-react": "^7.0.0", 27 | "@magenta/music": "^1.4.5", 28 | "@simonwep/selection-js": "^0.1.4", 29 | "@tensorflow/tfjs": "^0.14.0", 30 | "babel-cli": "^6.26.0", 31 | "babel-eslint": "^9.0.0", 32 | "babel-loader": "^8.0.2", 33 | "codemirror": "^5.40.0", 34 | "css-loader": "^1.0.0", 35 | "electron": "^3.0.4", 36 | "eslint": "^5.14.0", 37 | "eslint-config-google": "^0.10.0", 38 | "eslint-loader": "^2.1.0", 39 | "eslint-plugin-import": "^2.14.0", 40 | "eslint-plugin-react": "^7.11.1", 41 | "event": "^1.0.0", 42 | "file-loader": "^2.0.0", 43 | "jquery": "^3.3.1", 44 | "jquery-ui": "^1.12.1", 45 | "jquery-ui-touch-punch": "^0.2.3", 46 | "prop-types": "^15.6.2", 47 | "react": "^16.5.0", 48 | "react-dom": "^16.5.0", 49 | "react-draggable": "^3.0.5", 50 | "seedrandom": "^2.4.4", 51 | "socket.io-client": "^2.2.0", 52 | "style-loader": "^0.23.0", 53 | "three": "^0.101.1", 54 | "tslint": "^5.12.1", 55 | "typescript": "^3.3.3", 56 | "webpack": "^4.18.0", 57 | "webpack-cli": "^3.1.0", 58 | "ws": "^6.0.0", 59 | "xebra.js": "^1.2.2" 60 | }, 61 | "dependencies": { 62 | "semantic-ui": "^2.4.2" 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /patchers/example1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/patchers/example1.jpg -------------------------------------------------------------------------------- /patchers/example2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/patchers/example2.jpg -------------------------------------------------------------------------------- /patchers/faust_poly.json: -------------------------------------------------------------------------------- 1 | { 2 | "lines": { 3 | "line-39": { 4 | "src": [ 5 | "box-25", 6 | 0 7 | ], 8 | "dest": [ 9 | "box-26", 10 | 0 11 | ], 12 | "id": "line-39", 13 | "disabled": false, 14 | "positionHash": 57671875 15 | }, 16 | "line-40": { 17 | "src": [ 18 | "box-25", 19 | 0 20 | ], 21 | "dest": [ 22 | "box-27", 23 | 0 24 | ], 25 | "id": "line-40", 26 | "disabled": false, 27 | "positionHash": 73400515 28 | }, 29 | "line-41": { 30 | "src": [ 31 | "box-25", 32 | 0 33 | ], 34 | "dest": [ 35 | "box-8", 36 | 0 37 | ], 38 | "id": "line-41", 39 | "disabled": false, 40 | "positionHash": 655855 41 | }, 42 | "line-46": { 43 | "src": [ 44 | "box-25", 45 | 1 46 | ], 47 | "dest": [ 48 | "box-29", 49 | 0 50 | ], 51 | "id": "line-46", 52 | "disabled": false, 53 | "positionHash": 57671680 54 | }, 55 | "line-47": { 56 | "src": [ 57 | "box-31", 58 | 0 59 | ], 60 | "dest": [ 61 | "box-25", 62 | 0 63 | ], 64 | "id": "line-47", 65 | "disabled": false, 66 | "positionHash": 655390 67 | }, 68 | "line-51": { 69 | "src": [ 70 | "box-35", 71 | 0 72 | ], 73 | "dest": [ 74 | "box-25", 75 | 1 76 | ], 77 | "id": "line-51", 78 | "disabled": false, 79 | "positionHash": 55377950 80 | }, 81 | "line-52": { 82 | "src": [ 83 | "box-36", 84 | 0 85 | ], 86 | "dest": [ 87 | "box-25", 88 | 1 89 | ], 90 | "id": "line-52", 91 | "disabled": false, 92 | "positionHash": 55377950 93 | } 94 | }, 95 | "boxes": { 96 | "box-8": { 97 | "id": "box-8", 98 | "text": "WA.Destination", 99 | "name": "box-8", 100 | "class": "WA.Destination", 101 | "inlets": 1, 102 | "outlets": 0, 103 | "patching_rect": [ 104 | 0, 105 | 495, 106 | 126, 107 | 22 108 | ], 109 | "args": [], 110 | "props": {}, 111 | "prevData": { 112 | "storage": {} 113 | } 114 | }, 115 | "box-25": { 116 | "id": "box-25", 117 | "text": "Faust.DSP  @bufferSize 1024  @useWorklet true @poly true", 118 | "name": "box-25", 119 | "class": "Faust.DSP", 120 | "inlets": 2, 121 | "outlets": 2, 122 | "patching_rect": [ 123 | 0, 124 | 30, 125 | 855, 126 | 22 127 | ], 128 | "args": [], 129 | "props": { 130 | "bufferSize": 1024, 131 | "useWorklet": true, 132 | "poly": true 133 | }, 134 | "prevData": { 135 | "storage": { 136 | "showEditor": false, 137 | "code": "import(\"stdfaust.lib\");\nprocess = os.osc(freq) * gain * gate with {\n freq = hslider(\"freq\", 440, 40, 8000, 1);\n gain = hslider(\"gain\", 0.5, 0, 1, 0.01);\n gate = button(\"gate\") : en.adsr(0.01, 0.1, 0.9, 0.5);\n};\neffect = dm.freeverb_demo;" 138 | } 139 | } 140 | }, 141 | "box-26": { 142 | "id": "box-26", 143 | "text": "WA.Oscilloscope 512", 144 | "name": "box-26", 145 | "class": "WA.Oscilloscope", 146 | "inlets": 1, 147 | "outlets": 0, 148 | "patching_rect": [ 149 | 870, 150 | 195, 151 | 225, 152 | 180 153 | ], 154 | "args": [ 155 | 512 156 | ], 157 | "props": {}, 158 | "prevData": { 159 | "storage": {} 160 | } 161 | }, 162 | "box-27": { 163 | "id": "box-27", 164 | "text": "WA.Spectrogram 512", 165 | "name": "box-27", 166 | "class": "WA.Spectrogram", 167 | "inlets": 1, 168 | "outlets": 0, 169 | "patching_rect": [ 170 | 1110, 171 | 195, 172 | 272, 173 | 180 174 | ], 175 | "args": [ 176 | 512 177 | ], 178 | "props": {}, 179 | "prevData": { 180 | "storage": {} 181 | } 182 | }, 183 | "box-29": { 184 | "id": "box-29", 185 | "text": "Faust.Diagram", 186 | "name": "box-29", 187 | "class": "Faust.Diagram", 188 | "inlets": 1, 189 | "outlets": 0, 190 | "patching_rect": [ 191 | 870, 192 | 0, 193 | 508, 194 | 178 195 | ], 196 | "args": [], 197 | "props": {}, 198 | "prevData": { 199 | "storage": {} 200 | } 201 | }, 202 | "box-31": { 203 | "id": "box-31", 204 | "text": "adc~", 205 | "name": "box-31", 206 | "class": "adc~", 207 | "inlets": 0, 208 | "outlets": 1, 209 | "patching_rect": [ 210 | 0, 211 | 0, 212 | 53, 213 | 22 214 | ], 215 | "args": [], 216 | "props": {}, 217 | "prevData": { 218 | "storage": {} 219 | } 220 | }, 221 | "box-35": { 222 | "id": "box-35", 223 | "text": "Message", 224 | "name": "box-35", 225 | "class": "Message", 226 | "inlets": 2, 227 | "outlets": 1, 228 | "patching_rect": [ 229 | 900, 230 | 435, 231 | 57.0313, 232 | 22 233 | ], 234 | "args": [ 235 | "[69, 100]" 236 | ], 237 | "props": {}, 238 | "prevData": { 239 | "storage": { 240 | "text": "[69, 100]" 241 | } 242 | } 243 | }, 244 | "box-36": { 245 | "id": "box-36", 246 | "text": "Message", 247 | "name": "box-36", 248 | "class": "Message", 249 | "inlets": 2, 250 | "outlets": 1, 251 | "patching_rect": [ 252 | 900, 253 | 480, 254 | 57.0313, 255 | 22 256 | ], 257 | "args": [ 258 | "[69, 0]" 259 | ], 260 | "props": {}, 261 | "prevData": { 262 | "storage": { 263 | "text": "[69, 0]" 264 | } 265 | } 266 | } 267 | }, 268 | "data": { 269 | "box-8": { 270 | "WA.Destination": { 271 | "storage": {} 272 | } 273 | }, 274 | "box-25": { 275 | "Faust.DSP": { 276 | "storage": { 277 | "showEditor": false, 278 | "code": "import(\"stdfaust.lib\");\nprocess = os.osc(freq) * gain * gate with {\n freq = hslider(\"freq\", 440, 40, 8000, 1);\n gain = hslider(\"gain\", 0.5, 0, 1, 0.01);\n gate = button(\"gate\") : en.adsr(0.01, 0.1, 0.9, 0.5);\n};\neffect = dm.freeverb_demo;" 279 | } 280 | } 281 | }, 282 | "box-26": { 283 | "WA.Oscilloscope": { 284 | "storage": {} 285 | } 286 | }, 287 | "box-27": { 288 | "WA.Spectrogram": { 289 | "storage": {} 290 | } 291 | }, 292 | "box-29": { 293 | "Faust.Diagram": { 294 | "storage": {} 295 | } 296 | }, 297 | "box-31": { 298 | "adc~": { 299 | "storage": {} 300 | } 301 | }, 302 | "box-35": { 303 | "Message": { 304 | "storage": { 305 | "text": "[69, 100]" 306 | } 307 | } 308 | }, 309 | "box-36": { 310 | "Message": { 311 | "storage": { 312 | "text": "[69, 0]" 313 | } 314 | } 315 | } 316 | }, 317 | "state": { 318 | "locked": true, 319 | "presentation": false, 320 | "showGrid": true 321 | }, 322 | "boxIndexCount": 37, 323 | "lineIndexCount": 52, 324 | "bgcolor": [ 325 | 61, 326 | 65, 327 | 70, 328 | 1 329 | ], 330 | "editing_bgcolor": [ 331 | 82, 332 | 87, 333 | 94, 334 | 1 335 | ], 336 | "grid": [ 337 | 15, 338 | 15 339 | ] 340 | } -------------------------------------------------------------------------------- /patchers/fetch.json: -------------------------------------------------------------------------------- 1 | { 2 | "lines": { 3 | "line-3": { 4 | "src": [ 5 | "box-2", 6 | 0 7 | ], 8 | "dest": [ 9 | "box-5", 10 | 0 11 | ], 12 | "id": "line-3", 13 | "disabled": false, 14 | "positionHash": 10485895 15 | }, 16 | "line-4": { 17 | "src": [ 18 | "box-5", 19 | 0 20 | ], 21 | "dest": [ 22 | "box-3", 23 | 0 24 | ], 25 | "id": "line-4", 26 | "disabled": false, 27 | "positionHash": 10485925 28 | }, 29 | "line-6": { 30 | "src": [ 31 | "box-8", 32 | 0 33 | ], 34 | "dest": [ 35 | "box-7", 36 | 0 37 | ], 38 | "id": "line-6", 39 | "disabled": false, 40 | "positionHash": 10486150 41 | }, 42 | "line-7": { 43 | "src": [ 44 | "box-3", 45 | 1 46 | ], 47 | "dest": [ 48 | "box-8", 49 | 0 50 | ], 51 | "id": "line-7", 52 | "disabled": false, 53 | "positionHash": 10485955 54 | }, 55 | "line-8": { 56 | "src": [ 57 | "box-2", 58 | 0 59 | ], 60 | "dest": [ 61 | "box-9", 62 | 0 63 | ], 64 | "id": "line-8", 65 | "disabled": false, 66 | "positionHash": 18350245 67 | }, 68 | "line-9": { 69 | "src": [ 70 | "box-9", 71 | 0 72 | ], 73 | "dest": [ 74 | "box-8", 75 | 1 76 | ], 77 | "id": "line-9", 78 | "disabled": false, 79 | "positionHash": 12707011 80 | }, 81 | "line-10": { 82 | "src": [ 83 | "box-11", 84 | 0 85 | ], 86 | "dest": [ 87 | "box-2", 88 | 0 89 | ], 90 | "id": "line-10", 91 | "disabled": false, 92 | "positionHash": 10485865 93 | } 94 | }, 95 | "boxes": { 96 | "box-2": { 97 | "id": "box-2", 98 | "text": "Button", 99 | "name": "box-2", 100 | "class": "Button", 101 | "inlets": 1, 102 | "outlets": 1, 103 | "patching_rect": [ 104 | 150, 105 | 105, 106 | 45, 107 | 22 108 | ], 109 | "prevData": { 110 | "storage": {} 111 | } 112 | }, 113 | "box-3": { 114 | "id": "box-3", 115 | "text": "Response.json", 116 | "name": "box-3", 117 | "class": "Response.json", 118 | "inlets": 2, 119 | "outlets": 3, 120 | "patching_rect": [ 121 | 150, 122 | 165, 123 | 102.5, 124 | 22 125 | ], 126 | "prevData": { 127 | "storage": {} 128 | } 129 | }, 130 | "box-5": { 131 | "id": "box-5", 132 | "text": "fetch \"http://localhost/magenta-demos/performance_rnn/models/tfjs/weights_manifest.json\"", 133 | "name": "box-5", 134 | "class": "fetch", 135 | "inlets": 2, 136 | "outlets": 1, 137 | "patching_rect": [ 138 | 150, 139 | 135, 140 | 527.125, 141 | 22 142 | ], 143 | "prevData": { 144 | "storage": {} 145 | } 146 | }, 147 | "box-7": { 148 | "id": "box-7", 149 | "text": "Print", 150 | "name": "box-7", 151 | "class": "Print", 152 | "inlets": 1, 153 | "outlets": 0, 154 | "patching_rect": [ 155 | 150, 156 | 390, 157 | 45, 158 | 22 159 | ], 160 | "prevData": { 161 | "storage": {} 162 | } 163 | }, 164 | "box-8": { 165 | "id": "box-8", 166 | "text": "TF.io.loadWeights", 167 | "name": "box-8", 168 | "class": "TF.io.loadWeights", 169 | "inlets": 4, 170 | "outlets": 2, 171 | "patching_rect": [ 172 | 150, 173 | 195, 174 | 121.703, 175 | 22 176 | ], 177 | "prevData": { 178 | "storage": {} 179 | } 180 | }, 181 | "box-9": { 182 | "id": "box-9", 183 | "text": "Message", 184 | "name": "box-9", 185 | "class": "Message", 186 | "inlets": 2, 187 | "outlets": 1, 188 | "patching_rect": [ 189 | 270, 190 | 165, 191 | 349.516, 192 | 22 193 | ], 194 | "prevData": { 195 | "storage": { 196 | "text": "http://localhost/magenta-demos/performance_rnn/models/tfjs/" 197 | } 198 | } 199 | }, 200 | "box-11": { 201 | "id": "box-11", 202 | "text": "Loadbang", 203 | "name": "box-11", 204 | "class": "Loadbang", 205 | "inlets": 1, 206 | "outlets": 1, 207 | "patching_rect": [ 208 | 150, 209 | 75, 210 | 78.6719, 211 | 22 212 | ] 213 | } 214 | }, 215 | "data": { 216 | "box-2": { 217 | "Button": { 218 | "storage": {} 219 | } 220 | }, 221 | "box-3": { 222 | "Response.json": { 223 | "storage": {} 224 | } 225 | }, 226 | "box-5": { 227 | "fetch": { 228 | "storage": {} 229 | } 230 | }, 231 | "box-7": { 232 | "Print": { 233 | "storage": {} 234 | } 235 | }, 236 | "box-8": { 237 | "TF.io.loadWeights": { 238 | "storage": {} 239 | } 240 | }, 241 | "box-9": { 242 | "Message": { 243 | "storage": { 244 | "text": "http://localhost/magenta-demos/performance_rnn/models/tfjs/" 245 | } 246 | } 247 | }, 248 | "box-11": { 249 | "Loadbang": { 250 | "storage": {} 251 | } 252 | } 253 | }, 254 | "state": { 255 | "locked": false, 256 | "presentation": false, 257 | "showGrid": true 258 | }, 259 | "boxIndexCount": 11, 260 | "lineIndexCount": 10, 261 | "bgcolor": [ 262 | 61, 263 | 65, 264 | 70, 265 | 1 266 | ], 267 | "editing_bgcolor": [ 268 | 82, 269 | 87, 270 | 94, 271 | 1 272 | ], 273 | "grid": [ 274 | 15, 275 | 15 276 | ] 277 | } -------------------------------------------------------------------------------- /patchers/sensors.json: -------------------------------------------------------------------------------- 1 | { 2 | "lines": { 3 | "line-5": { 4 | "src": [ 5 | "box-5", 6 | 0 7 | ], 8 | "dest": [ 9 | "box-8", 10 | 0 11 | ], 12 | "id": "line-5", 13 | "disabled": false, 14 | "positionHash": 17367280 15 | }, 16 | "line-6": { 17 | "src": [ 18 | "box-6", 19 | 0 20 | ], 21 | "dest": [ 22 | "box-8", 23 | 1 24 | ], 25 | "id": "line-6", 26 | "disabled": false, 27 | "positionHash": 24250608 28 | }, 29 | "line-7": { 30 | "src": [ 31 | "box-7", 32 | 0 33 | ], 34 | "dest": [ 35 | "box-8", 36 | 2 37 | ], 38 | "id": "line-7", 39 | "disabled": false, 40 | "positionHash": 31133936 41 | }, 42 | "line-8": { 43 | "src": [ 44 | "box-8", 45 | 0 46 | ], 47 | "dest": [ 48 | "box-9", 49 | 1 50 | ], 51 | "id": "line-8", 52 | "disabled": false, 53 | "positionHash": 48496910 54 | }, 55 | "line-13": { 56 | "src": [ 57 | "box-3", 58 | 0 59 | ], 60 | "dest": [ 61 | "box-5", 62 | 0 63 | ], 64 | "id": "line-13", 65 | "disabled": false, 66 | "positionHash": 17367160 67 | }, 68 | "line-14": { 69 | "src": [ 70 | "box-3", 71 | 0 72 | ], 73 | "dest": [ 74 | "box-6", 75 | 0 76 | ], 77 | "id": "line-14", 78 | "disabled": false, 79 | "positionHash": 24248440 80 | }, 81 | "line-15": { 82 | "src": [ 83 | "box-3", 84 | 0 85 | ], 86 | "dest": [ 87 | "box-7", 88 | 0 89 | ], 90 | "id": "line-15", 91 | "disabled": false, 92 | "positionHash": 31129720 93 | } 94 | }, 95 | "boxes": { 96 | "box-3": { 97 | "id": "box-3", 98 | "text": "E.deviceorientation", 99 | "name": "box-3", 100 | "class": "E.deviceorientation", 101 | "inlets": 0, 102 | "outlets": 1, 103 | "patching_rect": [ 104 | 255, 105 | 60, 106 | 130.125, 107 | 22 108 | ], 109 | "prevData": { 110 | "storage": {} 111 | } 112 | }, 113 | "box-5": { 114 | "id": "box-5", 115 | "text": "Get alpha", 116 | "name": "box-5", 117 | "class": "Get", 118 | "inlets": 2, 119 | "outlets": 1, 120 | "patching_rect": [ 121 | 255, 122 | 120, 123 | 75.4844, 124 | 22 125 | ], 126 | "prevData": { 127 | "storage": {} 128 | } 129 | }, 130 | "box-6": { 131 | "id": "box-6", 132 | "text": "Get beta", 133 | "name": "box-6", 134 | "class": "Get", 135 | "inlets": 2, 136 | "outlets": 1, 137 | "patching_rect": [ 138 | 360, 139 | 120, 140 | 70.2344, 141 | 22 142 | ], 143 | "prevData": { 144 | "storage": {} 145 | } 146 | }, 147 | "box-7": { 148 | "id": "box-7", 149 | "text": "Get gamma", 150 | "name": "box-7", 151 | "class": "Get", 152 | "inlets": 2, 153 | "outlets": 1, 154 | "patching_rect": [ 155 | 465, 156 | 120, 157 | 85.0469, 158 | 22 159 | ], 160 | "prevData": { 161 | "storage": {} 162 | } 163 | }, 164 | "box-8": { 165 | "id": "box-8", 166 | "text": "Array [] @inlets 3", 167 | "name": "box-8", 168 | "class": "Array", 169 | "inlets": 3, 170 | "outlets": 2, 171 | "patching_rect": [ 172 | 255, 173 | 240, 174 | 230.063, 175 | 22 176 | ], 177 | "prevData": { 178 | "storage": {} 179 | } 180 | }, 181 | "box-9": { 182 | "id": "box-9", 183 | "text": "Message", 184 | "name": "box-9", 185 | "class": "Message", 186 | "inlets": 2, 187 | "outlets": 1, 188 | "patching_rect": [ 189 | 255, 190 | 270, 191 | 495, 192 | 22 193 | ], 194 | "prevData": { 195 | "storage": { 196 | "text": "[ -100.43926580586498, 121.90271710330656, 4.71696776510281 ]" 197 | } 198 | } 199 | } 200 | }, 201 | "data": { 202 | "box-3": { 203 | "E.deviceorientation": { 204 | "storage": {} 205 | } 206 | }, 207 | "box-5": { 208 | "Get": { 209 | "storage": {} 210 | } 211 | }, 212 | "box-6": { 213 | "Get": { 214 | "storage": {} 215 | } 216 | }, 217 | "box-7": { 218 | "Get": { 219 | "storage": {} 220 | } 221 | }, 222 | "box-8": { 223 | "Array": { 224 | "storage": {} 225 | } 226 | }, 227 | "box-9": { 228 | "Message": { 229 | "storage": { 230 | "text": "[ -100.43926580586498, 121.90271710330656, 4.71696776510281 ]" 231 | } 232 | } 233 | } 234 | }, 235 | "state": { 236 | "locked": true, 237 | "presentation": false, 238 | "showGrid": true 239 | }, 240 | "boxIndexCount": 12, 241 | "lineIndexCount": 15, 242 | "bgcolor": [ 243 | 61, 244 | 65, 245 | 70, 246 | 1 247 | ], 248 | "editing_bgcolor": [ 249 | 82, 250 | 87, 251 | 94, 252 | 1 253 | ], 254 | "grid": [ 255 | 15, 256 | 15 257 | ] 258 | } -------------------------------------------------------------------------------- /patchers/src/models/dljs/fully_connected_biases: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/patchers/src/models/dljs/fully_connected_biases -------------------------------------------------------------------------------- /patchers/src/models/dljs/fully_connected_weights: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/patchers/src/models/dljs/fully_connected_weights -------------------------------------------------------------------------------- /patchers/src/models/dljs/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "fully_connected/biases": { 3 | "filename": "fully_connected_biases", 4 | "shape": [ 5 | 388 6 | ] 7 | }, 8 | "fully_connected/weights": { 9 | "filename": "fully_connected_weights", 10 | "shape": [ 11 | 512, 12 | 388 13 | ] 14 | }, 15 | "rnn/multi_rnn_cell/cell_0/basic_lstm_cell/bias": { 16 | "filename": "rnn_multi_rnn_cell_cell_0_basic_lstm_cell_bias", 17 | "shape": [ 18 | 2048 19 | ] 20 | }, 21 | "rnn/multi_rnn_cell/cell_0/basic_lstm_cell/kernel": { 22 | "filename": "rnn_multi_rnn_cell_cell_0_basic_lstm_cell_kernel", 23 | "shape": [ 24 | 921, 25 | 2048 26 | ] 27 | }, 28 | "rnn/multi_rnn_cell/cell_1/basic_lstm_cell/bias": { 29 | "filename": "rnn_multi_rnn_cell_cell_1_basic_lstm_cell_bias", 30 | "shape": [ 31 | 2048 32 | ] 33 | }, 34 | "rnn/multi_rnn_cell/cell_1/basic_lstm_cell/kernel": { 35 | "filename": "rnn_multi_rnn_cell_cell_1_basic_lstm_cell_kernel", 36 | "shape": [ 37 | 1024, 38 | 2048 39 | ] 40 | }, 41 | "rnn/multi_rnn_cell/cell_2/basic_lstm_cell/bias": { 42 | "filename": "rnn_multi_rnn_cell_cell_2_basic_lstm_cell_bias", 43 | "shape": [ 44 | 2048 45 | ] 46 | }, 47 | "rnn/multi_rnn_cell/cell_2/basic_lstm_cell/kernel": { 48 | "filename": "rnn_multi_rnn_cell_cell_2_basic_lstm_cell_kernel", 49 | "shape": [ 50 | 1024, 51 | 2048 52 | ] 53 | } 54 | } -------------------------------------------------------------------------------- /patchers/src/models/dljs/rnn_multi_rnn_cell_cell_0_basic_lstm_cell_bias: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/patchers/src/models/dljs/rnn_multi_rnn_cell_cell_0_basic_lstm_cell_bias -------------------------------------------------------------------------------- /patchers/src/models/dljs/rnn_multi_rnn_cell_cell_0_basic_lstm_cell_kernel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/patchers/src/models/dljs/rnn_multi_rnn_cell_cell_0_basic_lstm_cell_kernel -------------------------------------------------------------------------------- /patchers/src/models/dljs/rnn_multi_rnn_cell_cell_1_basic_lstm_cell_bias: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/patchers/src/models/dljs/rnn_multi_rnn_cell_cell_1_basic_lstm_cell_bias -------------------------------------------------------------------------------- /patchers/src/models/dljs/rnn_multi_rnn_cell_cell_1_basic_lstm_cell_kernel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/patchers/src/models/dljs/rnn_multi_rnn_cell_cell_1_basic_lstm_cell_kernel -------------------------------------------------------------------------------- /patchers/src/models/dljs/rnn_multi_rnn_cell_cell_2_basic_lstm_cell_bias: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/patchers/src/models/dljs/rnn_multi_rnn_cell_cell_2_basic_lstm_cell_bias -------------------------------------------------------------------------------- /patchers/src/models/dljs/rnn_multi_rnn_cell_cell_2_basic_lstm_cell_kernel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/patchers/src/models/dljs/rnn_multi_rnn_cell_cell_2_basic_lstm_cell_kernel -------------------------------------------------------------------------------- /patchers/src/models/tfjs/group1-shard1of6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/patchers/src/models/tfjs/group1-shard1of6 -------------------------------------------------------------------------------- /patchers/src/models/tfjs/group1-shard2of6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/patchers/src/models/tfjs/group1-shard2of6 -------------------------------------------------------------------------------- /patchers/src/models/tfjs/group1-shard3of6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/patchers/src/models/tfjs/group1-shard3of6 -------------------------------------------------------------------------------- /patchers/src/models/tfjs/group1-shard4of6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/patchers/src/models/tfjs/group1-shard4of6 -------------------------------------------------------------------------------- /patchers/src/models/tfjs/group1-shard5of6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/patchers/src/models/tfjs/group1-shard5of6 -------------------------------------------------------------------------------- /patchers/src/models/tfjs/group1-shard6of6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/patchers/src/models/tfjs/group1-shard6of6 -------------------------------------------------------------------------------- /patchers/src/models/tfjs/weights_manifest.json: -------------------------------------------------------------------------------- 1 | [{"paths": ["group1-shard1of6", "group1-shard2of6", "group1-shard3of6", "group1-shard4of6", "group1-shard5of6", "group1-shard6of6"], "weights": [{"dtype": "float32", "shape": [921, 2048], "name": "rnn/multi_rnn_cell/cell_0/basic_lstm_cell/kernel"}, {"dtype": "float32", "shape": [2048], "name": "rnn/multi_rnn_cell/cell_1/basic_lstm_cell/bias"}, {"dtype": "float32", "shape": [512, 388], "name": "fully_connected/weights"}, {"dtype": "float32", "shape": [1024, 2048], "name": "rnn/multi_rnn_cell/cell_1/basic_lstm_cell/kernel"}, {"dtype": "float32", "shape": [2048], "name": "rnn/multi_rnn_cell/cell_2/basic_lstm_cell/bias"}, {"dtype": "float32", "shape": [388], "name": "fully_connected/biases"}, {"dtype": "float32", "shape": [2048], "name": "rnn/multi_rnn_cell/cell_0/basic_lstm_cell/bias"}, {"dtype": "float32", "shape": [1024, 2048], "name": "rnn/multi_rnn_cell/cell_2/basic_lstm_cell/kernel"}]}] -------------------------------------------------------------------------------- /renderer.js: -------------------------------------------------------------------------------- 1 | // This file is required by the index.html file and will 2 | // be executed in the renderer process for that window. 3 | // All of the Node.js APIs are available in this process. 4 | -------------------------------------------------------------------------------- /semantic.json: -------------------------------------------------------------------------------- 1 | { 2 | "base": "semantic\\", 3 | "paths": { 4 | "source": { 5 | "config": "src/theme.config", 6 | "definitions": "src/definitions/", 7 | "site": "src\\site\\", 8 | "themes": "src/themes/" 9 | }, 10 | "output": { 11 | "packaged": "dist\\", 12 | "uncompressed": "dist\\components\\", 13 | "compressed": "dist\\components\\", 14 | "themes": "dist/themes/" 15 | }, 16 | "clean": "dist/" 17 | }, 18 | "permission": false, 19 | "autoInstall": false, 20 | "rtl": false, 21 | "components": ["reset", "site", "button", "container", "divider", "flag", "header", "icon", "image", "input", "label", "list", "loader", "rail", "reveal", "segment", "step", "breadcrumb", "form", "grid", "menu", "message", "table", "ad", "card", "comment", "feed", "item", "statistic", "accordion", "checkbox", "dimmer", "dropdown", "embed", "modal", "nag", "popup", "progress", "rating", "search", "shape", "sidebar", "sticky", "tab", "transition", "api", "form", "state", "visibility"], 22 | "version": "2.4.2" 23 | } -------------------------------------------------------------------------------- /semantic/dist/themes/default/assets/fonts/icons.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/semantic/dist/themes/default/assets/fonts/icons.eot -------------------------------------------------------------------------------- /semantic/dist/themes/default/assets/fonts/icons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/semantic/dist/themes/default/assets/fonts/icons.ttf -------------------------------------------------------------------------------- /semantic/dist/themes/default/assets/fonts/icons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/semantic/dist/themes/default/assets/fonts/icons.woff -------------------------------------------------------------------------------- /semantic/dist/themes/default/assets/fonts/icons.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/semantic/dist/themes/default/assets/fonts/icons.woff2 -------------------------------------------------------------------------------- /semantic/dist/themes/default/assets/images/flags.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/semantic/dist/themes/default/assets/images/flags.png -------------------------------------------------------------------------------- /src/UIObj.js: -------------------------------------------------------------------------------- 1 | 2 | let inlet = ($, props) => { 3 | return $("
") 4 | .addClass(["box-port", "box-inlet", props.isHot ? "box-inlet-hot" : "box-inlet-cold"]) 5 | .attr("data-content", props.type + ": " + props.description) 6 | .attr("data-variation", "mini inverted") 7 | .popup({ 8 | boundary : ".boxes", 9 | position : "top left", 10 | delay: { show: 500, hide: 0 } 11 | }); 12 | } 13 | let outlet = ($, props) => { 14 | return $("
").addClass(["box-port", "box-outlet"]) 15 | .attr("data-content", props.type + ": " + props.description) 16 | .attr("data-variation", "mini inverted") 17 | .popup({ 18 | boundary : ".boxes", 19 | position : "bottom left", 20 | delay: { show: 500, hide: 0 } 21 | }); 22 | } 23 | let inlets = ($, count, props) => { 24 | let div = $("
").addClass("box-inlets"); 25 | for (let i = 0; i < count; i++) { 26 | let propsI = { isHot : false, type : "anything", description : "" }; 27 | if (props) propsI = i >= props.length ? props[props.length - 1] : props[i]; 28 | div.append(inlet($, propsI).attr("data-index", i)); 29 | } 30 | return div; 31 | } 32 | let outlets = ($, count, props) => { 33 | let div = $("
").addClass("box-outlets"); 34 | for (let i = 0; i < count; i++) { 35 | let propsI = { type : "anything", description : "" }; 36 | if (props) propsI = i >= props.length ? props[props.length - 1] : props[i]; 37 | div.append(outlet($, propsI).attr("data-index", i)); 38 | } 39 | return div; 40 | } 41 | let box = ($, box, props) => { 42 | let rect = box.patching_rect; 43 | let is = box.inlets; 44 | let os = box.outlets; 45 | let id = box.id; 46 | let ui = $("
").addClass("box-ui"); 47 | let div = $("
").attr({"id": id, "tabindex": 0}).addClass(["box", "box-default"]); 48 | div.css({"left": rect[0], "top": rect[1], "width": rect[2], "height": rect[3]}); 49 | div.append(inlets($, is, props.inlets)).append(outlets($, os, props.outlets)).append(ui); 50 | return div; 51 | } 52 | let line = ($, line) => { 53 | let path = $("").addClass("line-path"); 54 | let svg = $("").addClass("line-svg").append(path).attr({"width": "100%", "height": "100%"}); 55 | let handlerSrc = $("
").addClass(["line-handler", "line-handler-src"]); 56 | let handlerDest = $("
").addClass(["line-handler", "line-handler-dest"]); 57 | let div = $("
").attr({"id": line.id, "tabindex": 0}).addClass("line"); 58 | div.html(svg.prop("outerHTML")).append(handlerSrc).append(handlerDest); //svg update hack 59 | return div; 60 | } 61 | export default { 62 | box, 63 | line, 64 | inlets, 65 | outlets 66 | } -------------------------------------------------------------------------------- /src/UIObj.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | class Inlet extends React.Component { 4 | render() { 5 | return ( 6 |
7 | ) 8 | } 9 | } 10 | 11 | Inlet.propTypes = { 12 | isHot: PropTypes.bool.isRequired, 13 | } 14 | 15 | class Outlet extends React.Component { 16 | render() { 17 | return ( 18 |
19 | ); 20 | } 21 | } 22 | 23 | class Box extends React.Component { 24 | render() { 25 | let divStyle = { 26 | "left": this.props.patching_rect[0], 27 | "top": this.props.patching_rect[1], 28 | "width": this.props.patching_rect[2]//, 29 | // "height": this.props.patching_rect[3] 30 | }; 31 | let inlets = []; 32 | for (let i = 0; i < this.props.inlets; i++) { 33 | inlets.push() 34 | } 35 | let outlets = []; 36 | for (let i = 0; i < this.props.outlets; i++) { 37 | outlets.push() 38 | } 39 | return ( 40 |
41 |
42 | {inlets} 43 |
44 |
45 | {outlets} 46 |
47 |

{this.props.text}

48 |
49 | ); 50 | } 51 | } 52 | 53 | Box.propTypes = { 54 | id: PropTypes.string.isRequired, 55 | text: PropTypes.string, 56 | patching_rect: PropTypes.arrayOf(PropTypes.number).isRequired, 57 | inlets: PropTypes.number, 58 | outlets: PropTypes.number, 59 | } 60 | 61 | class Line extends React.Component { 62 | render() { 63 | 64 | let start = this.props.start; 65 | let dest = this.props.dest; 66 | 67 | let style = { 68 | "left": Math.min(start[0], dest[0]) - 5, 69 | "top": Math.min(start[1], dest[1]) - 10, 70 | "width": Math.abs(start[0] - dest[0]) + 10, 71 | "height": Math.abs(start[1] - dest[1]) + 20, 72 | }; 73 | let d = ["M", start[0] - style.left, start[1] - style.top, "L", dest[0] - style.left, dest[1] - style.top]; 74 | return ( 75 |
76 | 77 | 78 | 79 |
80 |
81 |
82 | ) 83 | } 84 | } 85 | Line.propTypes = { 86 | id: PropTypes.string, 87 | start: PropTypes.arrayOf(PropTypes.number), 88 | dest: PropTypes.arrayOf(PropTypes.number), 89 | } 90 | 91 | class Boxes extends React.Component { 92 | render() { 93 | let boxes = this.props.boxes; 94 | let doms = []; 95 | 96 | for (const id in boxes) { 97 | const box = boxes[id]; 98 | doms.push(); 99 | } 100 | return ( 101 | doms 102 | ); 103 | } 104 | } 105 | Boxes.propTypes = { 106 | boxes: PropTypes.object 107 | } 108 | -------------------------------------------------------------------------------- /src/maxObj.js: -------------------------------------------------------------------------------- 1 | class MaxObjBase { 2 | constructor(strArg) { 3 | this.ioInit = [0, 0]; 4 | this.ioMax = [0, 0]; 5 | this.function; 6 | let argsArray = strArg.split(" "); 7 | this.maxObjClass = argsArray.shift(); 8 | this.args = []; 9 | this.attrs = {}; 10 | if (argsArray.length > 0) { 11 | let lastProperty = ""; 12 | let lastValue = []; 13 | let attrsMode = 0; 14 | while (argsArray.length) { 15 | let curStr = argsArray.shift(); 16 | attrsMode = attrsMode || curStr[0] == "@"; 17 | if (!attrsMode) this.args.push(isNaN(curStr) ? curStr : +curStr); 18 | if (curStr[0] == "@") { 19 | if (lastProperty.length) { 20 | if (lastValue.length > 1) this.attrs[lastProperty] = lastValue; 21 | else if (lastValue.length == 1) this.attrs[lastProperty] = lastValue[0]; 22 | else this.attrs[lastProperty] = true; 23 | } 24 | lastValue = []; 25 | } 26 | if (curStr[0] == "@") lastProperty = curStr.substr(1); 27 | else lastValue.push(isNaN(curStr) ? curStr : +curStr); 28 | } 29 | if (lastProperty.length) { 30 | if (lastValue.length > 1) this.attrs[lastProperty] = lastValue; 31 | else if (lastValue.length == 1) this.attrs[lastProperty] = lastValue[0]; 32 | else this.attrs[lastProperty] = true; 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/object/AutoImporter.js: -------------------------------------------------------------------------------- 1 | import Base from "./Base.js" 2 | export default class AutoImporter { 3 | static importer(pkgName, pkg, depth, out, pathIn, fromProto) { 4 | if (depth <= 0) return out; 5 | if (depth === undefined) depth = 1; 6 | if (!out) out = {}; 7 | for (const key in pkg) { 8 | if (!pkg.hasOwnProperty(key)) continue; 9 | try { 10 | const el = pkg[key]; 11 | const path = pathIn ? pathIn + "." + key : key; 12 | if (typeof el === "object" && !Array.isArray(el)) { 13 | AutoImporter.importer(pkgName, el, depth - 1, out, path); 14 | } else { 15 | out[path] = AutoImporter.generator(el, pkgName, key, fromProto); 16 | if (el.hasOwnProperty("prototype")) AutoImporter.importer(pkgName, el.prototype, depth - 1, out, path, true); 17 | } 18 | continue; 19 | } catch (e) { 20 | continue; 21 | } 22 | } 23 | return out; 24 | } 25 | static generator(el, pkgName, name, fromProto) { 26 | if (typeof el === "function") { 27 | return class extends Base.BaseObject { 28 | static get _meta() { 29 | return Object.assign(super._meta, { 30 | package : pkgName, 31 | name : name, 32 | description : fromProto ? "Auto-imported OOP method" : "Auto-imported static function", 33 | inlets : fromProto ? [{ 34 | isHot : true, 35 | type : "anything", 36 | description : fromProto ? "Instance of this prototype" : "Function argument" 37 | }, { 38 | isHot : false, 39 | type : "anything", 40 | varLength : true, 41 | description : "Method argument" 42 | }] : [{ 43 | isHot : true, 44 | type : "anything", 45 | description : "Method argument" 46 | }, { 47 | isHot : false, 48 | type : "anything", 49 | varLength : true, 50 | description : "Method argument" 51 | }], 52 | outlets : fromProto ? [{ 53 | type : "anything", 54 | description : "Instance with method called" 55 | }, { 56 | type : "anything", 57 | description : "Return value of method called" 58 | },{ 59 | type : "anything", 60 | description : "Arguments with method called as list" 61 | }] : [{ 62 | type : "anything", 63 | description : "Return value of method called" 64 | },{ 65 | type : "anything", 66 | description : "Arguments with method called as list" 67 | }], 68 | props : [{ 69 | name : "inlets", 70 | type : "number", 71 | description : "arguments count for " + fromProto ? "method" : "function" 72 | }] 73 | }); 74 | } 75 | constructor(box, patcher) { 76 | super(box, patcher); 77 | this._inlets = (fromProto ? 1 : 0) + (el.length == 0 ? 1 : el.length); 78 | this._outlets = (fromProto ? 1 : 0) + 2; 79 | this._mem.name = name; 80 | this._mem.fn = el; 81 | this._mem.instance = null; 82 | this._mem.inputs = box._args.slice(); // copy array 83 | this._mem.result = null; 84 | this._mem.fromProto = fromProto ? true : false; 85 | this.update(this._mem.inputs, box._props); 86 | } 87 | update(args, props) { 88 | if (props && props.hasOwnProperty("inlets") && typeof props.inlets === "number") { 89 | this._inlets = (this._mem.fromProto ? 1 : 0) + props.inlets; 90 | } 91 | if (!args) return this; 92 | this._mem.inputs = args; 93 | //if (!this._mem.fromProto) this.execute(); 94 | return this; 95 | } 96 | fn(data, inlet) { 97 | if (inlet == 0 && data instanceof Base.Bang) { 98 | if (this.execute()) this.output(); 99 | return this; 100 | } 101 | if (this._mem.fromProto) { 102 | if (inlet == 0) this._mem.instance = data; 103 | else this._mem.inputs[inlet - 1] = data; 104 | } else this._mem.inputs[inlet] = data; 105 | if (inlet == 0) { 106 | if (this.execute()) this.output(); 107 | } 108 | return this; 109 | } 110 | output() { 111 | let callback = () => { 112 | if (this._mem.fromProto) this.outlet(2, this._mem.inputs).outlet(1, this._mem.result).outlet(0, this._mem.instance); 113 | else this.outlet(1, this._mem.inputs).outlet(0, this._mem.result); 114 | } 115 | if (this._mem.result instanceof Promise) { 116 | this.loading(true); 117 | this._mem.result.then((r) => { 118 | this.loading(false); 119 | this._mem.result = r; 120 | callback(); 121 | }, (r) => { 122 | this.loading(false); 123 | this.error(r); 124 | }); 125 | } else { 126 | callback(); 127 | } 128 | } 129 | loading(bool) { 130 | if (bool) { 131 | for (const id in this._uiList) { 132 | this._uiList[id].find(".icon").removeClass(this._meta.icon).addClass(["spinner", "loading"]); 133 | } 134 | } else { 135 | for (const id in this._uiList) { 136 | this._uiList[id].find(".icon").removeClass(["spinner", "loading"]).addClass(this._meta.icon); 137 | } 138 | } 139 | } 140 | execute() { 141 | try { 142 | if (this._mem.fromProto) { 143 | if (this._mem.instance) this._mem.result = this._mem.instance[this._mem.name](...this._mem.inputs); 144 | else return false; 145 | } else try { 146 | this._mem.result = new this._mem.fn(...this._mem.inputs); 147 | } catch (e) { 148 | this._mem.result = this._mem.fn(...this._mem.inputs); 149 | } 150 | return true; 151 | } catch (e) { 152 | this.error(e); 153 | return false; 154 | } 155 | } 156 | } 157 | } else { 158 | return class extends Base.BaseObject { 159 | static get _meta() { 160 | return Object.assign(super._meta, { 161 | package : pkgName, 162 | name : name, 163 | description : "Auto-imported " + fromProto ? "Property getter" : "Static value", 164 | inlets : [{ 165 | isHot : true, 166 | type : "anything", 167 | description : fromProto ? "Instance of this prototype" : "Anything to output value" 168 | }], 169 | outlets : [{ 170 | type : "anything", 171 | description : fromProto ? "Property got" : "Static value imported" 172 | }] 173 | }); 174 | } 175 | constructor(box, patcher) { 176 | super(box, patcher); 177 | this._inlets = 1; 178 | this._outlets = 1; 179 | } 180 | fn(data, inlet) { 181 | this.outlet(0, fromProto ? data[name] : el); 182 | return this; 183 | } 184 | } 185 | } 186 | } 187 | } -------------------------------------------------------------------------------- /src/object/Base.css: -------------------------------------------------------------------------------- 1 | div.package-base-button { 2 | word-break: break-all; 3 | padding: 4px 5px !important; 4 | width: 100%; 5 | line-height: 14px !important; 6 | font-weight: bold !important; 7 | margin-right: 0px !important; 8 | } 9 | 10 | div.package-base-message .box-ui-text-container { 11 | word-break: break-all; 12 | text-align: left; 13 | padding: 4px 5px !important; 14 | width: 100%; 15 | line-height: 14px !important; 16 | font-weight: bold !important; 17 | margin-right: 0px; 18 | } 19 | 20 | div.package-base-message .box-ui-text-container:empty::before { 21 | content: "\200b"; 22 | } 23 | 24 | #patcher.unlocked div.package-base-message .box-ui-text-container { 25 | cursor: default; 26 | margin-right: 0px; 27 | } 28 | 29 | #patcher.unlocked div.package-base-message .box-ui-text-container.editing { 30 | cursor: text; 31 | } 32 | 33 | div.package-base-invalidobject .box-ui-text-container { 34 | background-color: rgb(128, 64, 64); 35 | } 36 | 37 | #patcher.unlocked div.box.selected .box-ui-text-container { 38 | pointer-events: auto; 39 | } 40 | 41 | ul.ui-menu.ui-autocomplete { 42 | display: table-row-group; 43 | font-family: Lato; 44 | width: auto; 45 | max-height: 200px; 46 | box-shadow: 0px 2px 5px #0008; 47 | overflow: auto; 48 | z-index: 120; 49 | } 50 | 51 | ul.ui-menu.ui-autocomplete li { 52 | display: table-row; 53 | } 54 | 55 | ul.ui-menu.ui-autocomplete li:nth-child(2n){ 56 | background-color: rgba(255, 255, 255, 0.05); 57 | } 58 | 59 | ul.ui-menu.ui-autocomplete li>* { 60 | display: table-cell; 61 | border-width: 0px; 62 | padding: 0.4em 0.6em; 63 | transition: background 0.1s ease 0s, color 0.1s ease 0s; 64 | font-size: 12px; 65 | } 66 | 67 | ul.ui-menu.ui-autocomplete li>*:last-child { 68 | overflow: hidden; 69 | } 70 | -------------------------------------------------------------------------------- /src/object/Default.css: -------------------------------------------------------------------------------- 1 | div.box-ui-default { 2 | background-color: rgb(73, 80, 77); 3 | } 4 | div.box-ui-default.box-ui-container { 5 | display: flex; 6 | flex-direction: column; 7 | height: 100%; 8 | overflow: auto; 9 | } 10 | 11 | div.box-ui-default.box-ui-container .box-ui-dropdown-container { 12 | flex: 1 1 100%; 13 | display: flex; 14 | flex-direction: column; 15 | width: 100%; 16 | border: rgb(125, 126, 132) solid; 17 | padding: 0px; 18 | border-width: 0px 0px 4px 0px; 19 | overflow: auto; 20 | } 21 | 22 | div.box-ui-default.box-ui-container .box-ui-toggle { 23 | cursor: pointer; 24 | } 25 | 26 | div.box-ui-default.box-ui-text-container { 27 | display: inline-flex; 28 | flex: 0 0 auto; 29 | padding: 0px 5px; 30 | width: 100%; 31 | color: white; 32 | font-family: Lato; 33 | font-size: 12px; 34 | margin: 0px; 35 | overflow-wrap: break-word; 36 | cursor: default; 37 | user-select: none; 38 | border: rgb(125, 126, 132) solid; 39 | border-width: 0px; 40 | } 41 | 42 | div.box-ui-default.box-ui-text-container:first-child { 43 | border-top-width: 4px; 44 | } 45 | 46 | div.box-ui-default.box-ui-text-container:last-child { 47 | border-bottom-width: 4px; 48 | } 49 | 50 | div.box-ui-default.box-ui-text-container span { 51 | word-break: break-all; 52 | width: 100%; 53 | line-height: 14px; 54 | font-weight: normal; 55 | } 56 | 57 | 58 | div.box-ui-default.box-ui-text-container i.icon { 59 | line-height: 14px; 60 | } 61 | 62 | div.box-ui-default.box-ui-text-container span.editing { 63 | pointer-events: auto; 64 | cursor: text; 65 | user-select: auto; 66 | } 67 | 68 | div.box-ui-default.box-ui-text-container span:empty::before { 69 | content: "\200b"; 70 | } 71 | -------------------------------------------------------------------------------- /src/object/Events.js: -------------------------------------------------------------------------------- 1 | import Base from "./Base.js"; 2 | 3 | class EventObject extends Base.BaseObject { 4 | static get _meta() { 5 | return Object.assign(super._meta, { 6 | package : "E", 7 | icon : "node js", 8 | author : "Fr0stbyteR", 9 | version : "1.0.0", 10 | inlets : [], 11 | outlets : [{ 12 | type : "object", 13 | description : "Output event object when fired" 14 | }], 15 | args : [], 16 | props : [] 17 | }); 18 | } 19 | constructor(box, patcher) { 20 | super(box, patcher); 21 | this._inlets = 0; 22 | this._outlets = 1; 23 | this._mem.callback = e => this.outlet(0, e); 24 | this._mem.off = () => {}; 25 | } 26 | destroy() { 27 | this._mem.off(); 28 | return super.destroy() 29 | } 30 | } 31 | let pkg = { document : [] }; 32 | let docEvents = ["readystatechange","pointerlockchange","pointerlockerror","beforecopy","beforecut","beforepaste","search","visibilitychange","copy","cut","paste","abort","blur","cancel","canplay","canplaythrough","change","click","close","contextmenu","cuechange","dblclick","drag","dragend","dragenter","dragleave","dragover","dragstart","drop","durationchange","emptied","ended","error","focus","input","invalid","keydown","keypress","keyup","load","loadeddata","loadedmetadata","loadstart","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","pause","play","playing","progress","ratechange","reset","resize","scroll","seeked","seeking","select","stalled","submit","suspend","timeupdate","toggle","volumechange","waiting","wheel","auxclick","gotpointercapture","lostpointercapture","pointerdown","pointermove","pointerup","pointercancel","pointerover","pointerout","pointerenter","pointerleave","selectstart","selectionchange","webkitfullscreenchange","webkitfullscreenerror","fullscreenchange","fullscreenerror","freeze","resume"]; 33 | let winEvents = ["animationend","animationiteration","animationstart","search","transitionend","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend","abort","blur","cancel","canplay","canplaythrough","change","click","close","contextmenu","cuechange","dblclick","drag","dragend","dragenter","dragleave","dragover","dragstart","drop","durationchange","emptied","ended","error","focus","input","invalid","keydown","keypress","keyup","load","loadeddata","loadedmetadata","loadstart","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","pause","play","playing","progress","ratechange","reset","resize","scroll","seeked","seeking","select","stalled","submit","suspend","timeupdate","toggle","volumechange","waiting","wheel","auxclick","gotpointercapture","lostpointercapture","pointerdown","pointermove","pointerup","pointercancel","pointerover","pointerout","pointerenter","pointerleave","selectstart","selectionchange","afterprint","beforeprint","beforeunload","hashchange","languagechange","message","messageerror","offline","online","pagehide","pageshow","popstate","rejectionhandled","storage","unhandledrejection","unload","appinstalled","beforeinstallprompt","devicemotion","deviceorientation","deviceorientationabsolute"]; 34 | /* 35 | for (const property in document) { 36 | const match = property.match(/^on(.*)/); 37 | if (match) docEvents.push(match[1]); 38 | } 39 | for (const property in window) { 40 | const match = property.match(/^on(.*)/); 41 | if (match) winEvents.push(match[1]); 42 | } 43 | */ 44 | for (const event of winEvents) { 45 | pkg[event] = class extends EventObject { 46 | static get _meta() { 47 | return Object.assign(super._meta, { 48 | name : event 49 | }); 50 | } 51 | constructor(box, patcher) { 52 | super(box, patcher); 53 | window.addEventListener(event, this._mem.callback); 54 | this._mem.off = () => window.removeEventListener(event, this._mem.callback); 55 | } 56 | } 57 | } 58 | for (const event of docEvents) { 59 | pkg.document[event] = class extends EventObject { 60 | static get _meta() { 61 | return Object.assign(super._meta, { 62 | name : event 63 | }); 64 | } 65 | constructor(box, patcher) { 66 | super(box, patcher); 67 | document.addEventListener(event, this._mem.callback); 68 | this._mem.off = () => document.removeEventListener(event, this._mem.callback); 69 | } 70 | } 71 | } 72 | 73 | export default pkg; -------------------------------------------------------------------------------- /src/object/JS.css: -------------------------------------------------------------------------------- 1 | 2 | div.package-js .box-ui-text-container { 3 | display: inline-flex; 4 | padding: 4px 5px; 5 | line-height: 14px; 6 | font-weight: bold; 7 | width: 100%; 8 | overflow-wrap: break-word; 9 | cursor: default; 10 | user-select: none; 11 | } 12 | 13 | div.package-js .box-ui-text-container>i.icon { 14 | margin: 0 .25rem 0 0; 15 | } 16 | 17 | div.package-js .box-ui-text-container span { 18 | word-break: break-all; 19 | width: 100%; 20 | line-height: 14px; 21 | font-weight: bold; 22 | } 23 | 24 | div.package-js .box-ui-text-container span.editing { 25 | pointer-events: auto; 26 | cursor: text; 27 | user-select: auto; 28 | } 29 | 30 | div.package-js .box-ui-text-container span:empty::before { 31 | content: "\200b"; 32 | } -------------------------------------------------------------------------------- /src/object/JSArray.js: -------------------------------------------------------------------------------- 1 | import AutoImporter from "./AutoImporter.js"; 2 | let JSArrayProto = { 3 | concat : Array.prototype.concat, 4 | copyWithin : Array.prototype.copyWithin, 5 | entries : Array.prototype.entries, 6 | every : Array.prototype.every, 7 | fill : Array.prototype.fill, 8 | filter : Array.prototype.filter, 9 | find : Array.prototype.find, 10 | findIndex : Array.prototype.findIndex, 11 | flat : Array.prototype.flat, 12 | flatMap : Array.prototype.flatMap, 13 | forEach : Array.prototype.forEach, 14 | includes : Array.prototype.includes, 15 | indexOf : Array.prototype.indexOf, 16 | join : Array.prototype.join, 17 | keys : Array.prototype.keys, 18 | lastIndexOf : Array.prototype.lastIndexOf, 19 | length : Array.prototype.length, 20 | map : Array.prototype.map, 21 | pop : Array.prototype.pop, 22 | push : Array.prototype.push, 23 | reduce : Array.prototype.reduce, 24 | reduceRight : Array.prototype.reduceRight, 25 | reverse : Array.prototype.reverse, 26 | shift : Array.prototype.shift, 27 | slice : Array.prototype.slice, 28 | some : Array.prototype.some, 29 | sort : Array.prototype.sort, 30 | splice : Array.prototype.splice, 31 | toLocaleString : Array.prototype.toLocaleString, 32 | toString : Array.prototype.toString, 33 | unshift : Array.prototype.unshift, 34 | values : Array.prototype.values 35 | } 36 | 37 | export default Object.assign( 38 | AutoImporter.importer("Array", JSArrayProto, 1, undefined, undefined, true), 39 | { Array : AutoImporter.generator(Array, "Array", "Array", false) } 40 | ); -------------------------------------------------------------------------------- /src/object/JSDate.js: -------------------------------------------------------------------------------- 1 | import AutoImporter from "./AutoImporter.js"; 2 | let JSDateProto = { 3 | getDate: Date.prototype.getDate, 4 | getDay: Date.prototype.getDay, 5 | getFullYear: Date.prototype.getFullYear, 6 | getHours: Date.prototype.getHours, 7 | getMilliseconds: Date.prototype.getMilliseconds, 8 | getMinutes: Date.prototype.getMinutes, 9 | getMonth: Date.prototype.getMonth, 10 | getSeconds: Date.prototype.getSeconds, 11 | getTime: Date.prototype.getTime, 12 | getTimezoneOffset: Date.prototype.getTimezoneOffset, 13 | getUTCDate: Date.prototype.getUTCDate, 14 | getUTCDay: Date.prototype.getUTCDay, 15 | getUTCFullYear: Date.prototype.getUTCFullYear, 16 | getUTCHours: Date.prototype.getUTCHours, 17 | getUTCMilliseconds: Date.prototype.getUTCMilliseconds, 18 | getUTCMinutes: Date.prototype.getUTCMinutes, 19 | getUTCMonth: Date.prototype.getUTCMonth, 20 | getUTCSeconds: Date.prototype.getUTCSeconds, 21 | getYear: Date.prototype.getYear, 22 | setDate: Date.prototype.setDate, 23 | setFullYear: Date.prototype.setFullYear, 24 | setHours: Date.prototype.setHours, 25 | setMilliseconds: Date.prototype.setMilliseconds, 26 | setMinutes: Date.prototype.setMinutes, 27 | setMonth: Date.prototype.setMonth, 28 | setSeconds: Date.prototype.setSeconds, 29 | setTime: Date.prototype.setTime, 30 | setUTCDate: Date.prototype.setUTCDate, 31 | setUTCFullYear: Date.prototype.setUTCFullYear, 32 | setUTCHours: Date.prototype.setUTCHours, 33 | setUTCMilliseconds: Date.prototype.setUTCMilliseconds, 34 | setUTCMinutes: Date.prototype.setUTCMinutes, 35 | setUTCMonth: Date.prototype.setUTCMonth, 36 | setUTCSeconds: Date.prototype.setUTCSeconds, 37 | setYear: Date.prototype.setYear, 38 | toDateString: Date.prototype.toDateString, 39 | toGMTString: Date.prototype.toGMTString, 40 | toISOString: Date.prototype.toISOString, 41 | //toJSON: Date.prototype.toJSON, 42 | toLocaleDateString: Date.prototype.toLocaleDateString, 43 | toLocaleFormat: Date.prototype.toLocaleFormat, 44 | toLocaleString: Date.prototype.toLocaleString, 45 | toLocaleTimeString: Date.prototype.toLocaleTimeString, 46 | toSource: Date.prototype.toSource, 47 | toString: Date.prototype.toString, 48 | toTimeString: Date.prototype.toTimeString, 49 | toUTCString: Date.prototype.toUTCString, 50 | valueOf: Date.prototype.valueOf 51 | } 52 | 53 | export default Object.assign( 54 | AutoImporter.importer("Date", JSDateProto, 1, undefined, undefined, true), { 55 | Date: AutoImporter.generator(Date, "Date", "Date", false), 56 | UTC: AutoImporter.generator(Date.UTC, "Date", "UTC", false), 57 | now: AutoImporter.generator(Date.now, "Date", "now", false), 58 | parse: AutoImporter.generator(Date.parse, "Date", "parse", false) 59 | } 60 | ); -------------------------------------------------------------------------------- /src/object/JSMath.js: -------------------------------------------------------------------------------- 1 | import AutoImporter from "./AutoImporter.js"; 2 | let JSMath = { 3 | E: Math.E, 4 | LN2: Math.LN2, 5 | LN10: Math.LN10, 6 | LOG2E: Math.LOG2E, 7 | LOG10E: Math.LOG10E, 8 | PI: Math.PI, 9 | SQRT1_2: Math.SQRT1_2, 10 | SQRT2: Math.SQRT2, 11 | abs: Math.abs, 12 | acos: Math.acos, 13 | acosh: Math.acosh, 14 | asin: Math.asin, 15 | asinh: Math.asinh, 16 | atan: Math.atan, 17 | atan2: Math.atan2, 18 | atanh: Math.atanh, 19 | cbrt: Math.cbrt, 20 | ceil: Math.ceil, 21 | clz32: Math.clz32, 22 | cos: Math.cos, 23 | cosh: Math.cosh, 24 | exp: Math.exp, 25 | expm1: Math.expm1, 26 | floor: Math.floor, 27 | fround: Math.fround, 28 | hypot: Math.hypot, 29 | imul: Math.imul, 30 | log: Math.log, 31 | log1p: Math.log1p, 32 | log2: Math.log2, 33 | log10: Math.log10, 34 | max: Math.max, 35 | min: Math.min, 36 | pow: Math.pow, 37 | random: Math.random, 38 | round: Math.round, 39 | sign: Math.sign, 40 | sin: Math.sin, 41 | sinh: Math.sinh, 42 | sqrt: Math.sqrt, 43 | tan: Math.tan, 44 | tanh: Math.tanh, 45 | trunc: Math.trunc 46 | } 47 | 48 | export default AutoImporter.importer("Math", JSMath, 1); -------------------------------------------------------------------------------- /src/object/JSOp.js: -------------------------------------------------------------------------------- 1 | import JS from "./JS.js"; 2 | import Base from "./Base.js"; 3 | 4 | class JSUnaryOp extends JS.JSBaseObject { 5 | static get _meta() { 6 | return Object.assign(super._meta, { 7 | description : "Unary Operation", 8 | inlets : [{ 9 | isHot : true, 10 | type : "anything", 11 | description : "First element" 12 | }], 13 | outlets : [{ 14 | type : "anything", 15 | description : "Result" 16 | }], 17 | args : [] 18 | }); 19 | } 20 | constructor(box, patcher) { 21 | super(box, patcher); 22 | this._inlets = 1; 23 | this._outlets = 1; 24 | this._mem.result = 0; 25 | this.update(box._args); 26 | } 27 | update(args, props) { 28 | this._mem.result = 0; 29 | } 30 | fn(data, inlet) { 31 | if (inlet == 0 && data instanceof Base.Bang) { 32 | this.outlet(0, this._mem.result); 33 | return this; 34 | } 35 | if (inlet == 0) { 36 | try { 37 | this._mem.result = this.execute(data); 38 | this.outlet(0, this._mem.result); 39 | } catch (e) { 40 | this.error(e); 41 | } 42 | } 43 | return this; 44 | } 45 | execute(a) { 46 | return; 47 | } 48 | } 49 | 50 | class JSBinaryOp extends JS.JSBaseObject { 51 | static get _meta() { 52 | return Object.assign(super._meta, { 53 | description : "Binary Operation", 54 | inlets : [{ 55 | isHot : true, 56 | type : "anything", 57 | description : "First element" 58 | }, { 59 | isHot : false, 60 | type : "anything", 61 | description : "Second element" 62 | }], 63 | outlets : [{ 64 | type : "anything", 65 | description : "Result" 66 | }], 67 | args : [{ 68 | type : "anything", 69 | optional : true, 70 | default : 0, 71 | description : "Initial second element" 72 | }] 73 | }); 74 | } 75 | constructor(box, patcher) { 76 | super(box, patcher); 77 | this._inlets = 2; 78 | this._outlets = 1; 79 | this._mem.arg = 0; 80 | this._mem.result = 0; 81 | this.update(box._args); 82 | } 83 | update(args, props) { 84 | this._mem.arg = 0; 85 | this._mem.result = 0; 86 | if (args.length == 0) return this; 87 | this._mem.arg = args[0]; 88 | } 89 | fn(data, inlet) { 90 | if (inlet == 0 && data instanceof Base.Bang) { 91 | this.outlet(0, this._mem.result); 92 | return this; 93 | } 94 | if (inlet == 1) { 95 | this._mem.arg = data; 96 | } 97 | if (inlet == 0) { 98 | try { 99 | this._mem.result = this.execute(data, this._mem.arg); 100 | this.outlet(0, this._mem.result); 101 | } catch (e) { 102 | this.error(e); 103 | } 104 | } 105 | return this; 106 | } 107 | execute(a, b) { 108 | return; 109 | } 110 | } 111 | 112 | class JSTernaryOp extends JS.JSBaseObject { 113 | static get _meta() { 114 | return Object.assign(super._meta, { 115 | description : "Ternary Operation", 116 | inlets : [{ 117 | isHot : true, 118 | type : "anything", 119 | description : "Test" 120 | }, { 121 | isHot : false, 122 | type : "anything", 123 | description : "True output" 124 | }, { 125 | isHot : false, 126 | type : "anything", 127 | description : "False output" 128 | }], 129 | outlets : [{ 130 | type : "anything", 131 | description : "Result" 132 | }], 133 | args : [{ 134 | type : "anything", 135 | optional : true, 136 | default : true, 137 | description : "Initial true output" 138 | }, { 139 | type : "anything", 140 | optional : true, 141 | default : false, 142 | description : "Initial false output" 143 | }] 144 | }); 145 | } 146 | constructor(box, patcher) { 147 | super(box, patcher); 148 | this._inlets = 3; 149 | this._outlets = 1; 150 | this._mem.args = [true, false]; 151 | this._mem.result = true; 152 | this.update(box._args); 153 | } 154 | update(args, props) { 155 | this._mem.args = [true, false]; 156 | this._mem.result = true; 157 | if (args.length == 0) return this; 158 | this._mem.args[0] = args[0]; 159 | this._mem.args[1] = args[1]; 160 | } 161 | fn(data, inlet) { 162 | if (inlet == 0 && data instanceof Base.Bang) { 163 | this.outlet(0, this._mem.result); 164 | return this; 165 | } 166 | if (inlet == 1) { 167 | this._mem.args[0] = data; 168 | } 169 | if (inlet == 2) { 170 | this._mem.args[1] = data; 171 | } 172 | if (inlet == 0) { 173 | try { 174 | this._mem.result = data ? this._mem.args[0] : this._mem.args[1]; 175 | this.outlet(0, this._mem.result); 176 | } catch (e) { 177 | this.error(e); 178 | } 179 | } 180 | return this; 181 | } 182 | } 183 | 184 | class Add extends JSBinaryOp { 185 | execute(a, b) { 186 | return a + b; 187 | } 188 | } 189 | 190 | class Sub extends JSBinaryOp { 191 | execute(a, b) { 192 | return a - b; 193 | } 194 | } 195 | 196 | class Mul extends JSBinaryOp { 197 | execute(a, b) { 198 | return a * b; 199 | } 200 | } 201 | 202 | class Div extends JSBinaryOp { 203 | execute(a, b) { 204 | return a / b; 205 | } 206 | } 207 | 208 | class Exp extends JSBinaryOp { 209 | execute(a, b) { 210 | return a ** b; 211 | } 212 | } 213 | 214 | class Mod extends JSBinaryOp { 215 | execute(a, b) { 216 | return a % b; 217 | } 218 | } 219 | 220 | class Inc extends JSUnaryOp { 221 | execute(a) { 222 | return ++a; 223 | } 224 | } 225 | 226 | class Dec extends JSUnaryOp { 227 | execute(a) { 228 | return --a; 229 | } 230 | } 231 | 232 | class Eql extends JSBinaryOp { 233 | execute(a, b) { 234 | return a == b; 235 | } 236 | } 237 | 238 | class EqlS extends JSBinaryOp { 239 | execute(a, b) { 240 | return a === b; 241 | } 242 | } 243 | 244 | class NEql extends JSBinaryOp { 245 | execute(a, b) { 246 | return a != b; 247 | } 248 | } 249 | 250 | class NEqlS extends JSBinaryOp { 251 | execute(a, b) { 252 | return a !== b; 253 | } 254 | } 255 | 256 | class Gtr extends JSBinaryOp { 257 | execute(a, b) { 258 | return a > b; 259 | } 260 | } 261 | 262 | class Geq extends JSBinaryOp { 263 | execute(a, b) { 264 | return a >= b; 265 | } 266 | } 267 | 268 | class Lss extends JSBinaryOp { 269 | execute(a, b) { 270 | return a < b; 271 | } 272 | } 273 | 274 | class Leq extends JSBinaryOp { 275 | execute(a, b) { 276 | return a <= b; 277 | } 278 | } 279 | 280 | class And extends JSBinaryOp { 281 | execute(a, b) { 282 | return a && b; 283 | } 284 | } 285 | 286 | class Or extends JSBinaryOp { 287 | execute(a, b) { 288 | return a || b; 289 | } 290 | } 291 | 292 | class Not extends JSUnaryOp { 293 | execute(a) { 294 | return !a; 295 | } 296 | } 297 | 298 | class Typeof extends JSUnaryOp { 299 | execute(a) { 300 | return typeof a; 301 | } 302 | } 303 | 304 | class Instanceof extends JSBinaryOp { 305 | execute(a, b) { 306 | return a instanceof b; 307 | } 308 | } 309 | 310 | export default { 311 | "+" : Add, 312 | "-" : Sub, 313 | "*" : Mul, 314 | "/" : Div, 315 | "**" : Exp, 316 | "%" : Mod, 317 | "++" : Inc, 318 | "--" : Dec, 319 | "==" : Eql, 320 | "===" : EqlS, 321 | "!=" : NEql, 322 | "!==" : NEqlS, 323 | ">" : Gtr, 324 | ">=" : Geq, 325 | "<" : Lss, 326 | "<=" : Leq, 327 | "&&" : And, 328 | "||" : Or, 329 | "!" : Not, 330 | Typeof, 331 | Instanceof, 332 | "?" : JSTernaryOp 333 | } -------------------------------------------------------------------------------- /src/object/WebAPI.js: -------------------------------------------------------------------------------- 1 | import Base from "./Base.js"; 2 | import AutoImporter from "./AutoImporter.js"; 3 | 4 | class WebAPIObject extends Base.BaseObject { 5 | static get _meta() { 6 | return Object.assign(super._meta, { 7 | package : "WebAPI", 8 | icon : "globe", 9 | author : "Fr0stbyteR", 10 | version : "1.0.0" 11 | }); 12 | } 13 | } 14 | let Fetch = class Fetch extends WebAPIObject { 15 | static get _meta() { 16 | return Object.assign(super._meta, { 17 | description : "Fetching a resource from the network", 18 | inlets : [{ 19 | isHot : true, 20 | type : "anything", 21 | description : "Input, a string or a Request object" 22 | }, { 23 | isHot : false, 24 | type : "object", 25 | description : "An options object containing any custom settings that you want to apply to the request." 26 | }], 27 | outlets : [{ 28 | type : "object", 29 | description : "Response object" 30 | }], 31 | args : [{ 32 | type : "string", 33 | optional : true, 34 | description : "Default input url" 35 | }], 36 | props : [] 37 | }); 38 | } 39 | constructor(box, patcher) { 40 | super(box, patcher); 41 | this._inlets = 2; 42 | this._outlets = 1; 43 | this._mem.inputs = box._args.slice(); 44 | this._mem.result = null; 45 | this.update(this._mem.inputs, box._props); 46 | } 47 | update(args, props) { 48 | if (!args) return this; 49 | this._mem.inputs = args; 50 | return this; 51 | } 52 | fn(data, inlet) { 53 | if (inlet == 0 && data instanceof Base.Bang) { 54 | if (this.execute()) this.output(); 55 | return this; 56 | } 57 | this._mem.inputs[inlet] = data; 58 | if (inlet == 0) { 59 | if (this.execute()) this.output(); 60 | } 61 | return this; 62 | } 63 | output() { 64 | this.loading(true); 65 | this._mem.result.then((r) => { 66 | this.loading(false); 67 | this._mem.result = r; 68 | this.outlet(0, this._mem.result); 69 | }, (r) => { 70 | this.loading(false); 71 | this.error(r); 72 | }); 73 | } 74 | loading(bool) { 75 | if (bool) { 76 | for (const id in this._uiList) { 77 | this._uiList[id].find(".icon").removeClass(this._meta.icon).addClass(["spinner", "loading"]); 78 | } 79 | } else { 80 | for (const id in this._uiList) { 81 | this._uiList[id].find(".icon").removeClass(["spinner", "loading"]).addClass(this._meta.icon); 82 | } 83 | } 84 | } 85 | execute() { 86 | try { 87 | this._mem.result = fetch(...this._mem.inputs); 88 | return true; 89 | } catch (e) { 90 | this.error(e); 91 | return false; 92 | } 93 | } 94 | } 95 | let FetchAPI = { 96 | Request : window.Request, 97 | Response : window.Response, 98 | Headers : window.Headers 99 | } 100 | export default { 101 | FetchAPI : Object.assign( 102 | AutoImporter.importer("FetchAPI", FetchAPI, 2), 103 | { fetch : Fetch } 104 | ) 105 | }; -------------------------------------------------------------------------------- /src/object/Xebra.js: -------------------------------------------------------------------------------- 1 | import Base from "./Base.js"; 2 | import * as Xebra from "xebra.js"; 3 | let states = {}; 4 | let count = {}; 5 | class State extends Base.BaseObject { 6 | static get _meta() { 7 | return Object.assign(super._meta, { 8 | package : "Xebra", 9 | icon : "microchip", 10 | author : "Fr0stbyteR", 11 | version : "1.0.0", 12 | }); 13 | } 14 | constructor(box, patcher) { 15 | super(box, patcher); 16 | this._mem.hostname = null; 17 | this._mem.port = null; 18 | this._mem.channel = null; 19 | } 20 | 21 | update(args, props) { 22 | if (!args) { 23 | this._mem.hostname = null; 24 | this._mem.port = null; 25 | this._mem.channel = null; 26 | return this.error("Address not defined"); 27 | } 28 | const curAddress = this._mem.hostname + ":" + this._mem.port; 29 | if (args[0] && typeof args[0] === "string" && args[0] != curAddress) { 30 | if (count[curAddress]) count[curAddress]-- 31 | if (count[curAddress] == 0) { 32 | states[curAddress].close(); 33 | delete states[curAddress]; 34 | delete count[curAddress]; 35 | } 36 | const split = args[0].split(":"); 37 | if (split.length == 2) { 38 | this._mem.hostname = split[0]; 39 | this._mem.port = split[1]; 40 | if (states[args[0]]) count[args[0]]++; 41 | else try { 42 | let state = new Xebra.State({ hostname : split[0], port : split[1] }); 43 | state.connect(); 44 | states[args[0]] = state; 45 | count[args[0]] = 1; 46 | } catch (e) { 47 | this.error(e); 48 | } 49 | } else { 50 | this.error("Address parsing failed.") 51 | } 52 | } 53 | if (args[1] && typeof args[1] === "string") this._mem.channel = args[1]; 54 | else this._mem.channel = null; 55 | return this; 56 | } 57 | 58 | destroy() { 59 | const curAddress = this._mem.hostname + ":" + this._mem.port; 60 | if (count[curAddress]) count[curAddress]-- 61 | if (count[curAddress] == 0) { 62 | states[curAddress].close(); 63 | delete states[curAddress]; 64 | delete count[curAddress]; 65 | } 66 | return super.destroy(); 67 | } 68 | } 69 | 70 | class Receive extends State { 71 | static get _meta() { 72 | return Object.assign(super._meta, { 73 | description : "Receive messages from Xebra channel", 74 | outlets : [{ 75 | isHot : true, 76 | type : "anything", 77 | description : "Received from Xebra channel" 78 | }], 79 | args : [{ 80 | type : "string", 81 | optional : false, 82 | description : "hostname:port" 83 | }, { 84 | type : "string", 85 | optional : true, 86 | description : "channel name" 87 | }] 88 | }); 89 | } 90 | 91 | constructor(box, patcher) { 92 | super(box, patcher); 93 | this._inlets = 0; 94 | this._outlets = 2; 95 | this._mem.callback = (chan, data) => { 96 | if (!this._mem.channel || chan == this._mem.channel) return this.outlet(1, chan).outlet(0, data); 97 | }; 98 | this.update(box._args, box._props); 99 | } 100 | 101 | update(args, props) { 102 | const curAddress = this._mem.hostname + ":" + this._mem.port; 103 | if (args && args[0] == curAddress && args[1] == this._mem.channel) return this; 104 | super.update(args, props); 105 | const newAddress = this._mem.hostname + ":" + this._mem.port; 106 | if (!this._mem.hostname || !this._mem.port) return this.error("Address not defined"); 107 | if (curAddress != newAddress) { 108 | if (states[curAddress]) states[curAddress].removeListener("channel_message_received", this._mem.callback); 109 | if (states[newAddress]) states[newAddress].on("channel_message_received", this._mem.callback); 110 | } 111 | return this; 112 | } 113 | 114 | destroy() { 115 | const curAddress = this._mem.hostname + ":" + this._mem.port; 116 | if (states[curAddress]) { 117 | states[curAddress].removeListener("channel_message_received", this._mem.callback); 118 | } 119 | return super.destroy(); 120 | } 121 | } 122 | 123 | class Send extends State { 124 | static get _meta() { 125 | return Object.assign(super._meta, { 126 | description : "Send messages to Xebra channel", 127 | inlets : [{ 128 | isHot : true, 129 | type : "anything", 130 | description : "Send to Xebra channel" 131 | }], 132 | args : [{ 133 | type : "string", 134 | optional : false, 135 | description : "hostname:port" 136 | }, { 137 | type : "string", 138 | optional : false, 139 | description : "channel name" 140 | }] 141 | }); 142 | } 143 | 144 | constructor(box, patcher) { 145 | super(box, patcher); 146 | this._inlets = 1; 147 | this._outlets = 0; 148 | this.update(box.args, box._props); 149 | } 150 | 151 | update(args, props) { 152 | const curAddress = this._mem.hostname + ":" + this._mem.port; 153 | if (args && args[0] == curAddress && args[1] == this._mem.channel) return this; 154 | super.update(args, props); 155 | if (!this._mem.hostname || !this._mem.port) return this.error("Address not defined"); 156 | if (!this._mem.channel) return this.error("Channel not defined."); 157 | return this; 158 | } 159 | 160 | fn(data, inlet) { 161 | const state = states[this._mem.hostname + ":" + this._mem.port]; 162 | if (!state) return this.error("State not initiated") 163 | if (state.connectionState !== Xebra.CONNECTION_STATES.CONNECTED) return this.error("State not connected"); 164 | if (!this._mem.channel) return this.error("Channel not specified") 165 | state.sendMessageToChannel(this._mem.channel, data); 166 | } 167 | } 168 | export default { 169 | Send, 170 | Receive 171 | } -------------------------------------------------------------------------------- /src/object/faust/Faust.css: -------------------------------------------------------------------------------- 1 | div.package-faust-dsp.box-ui-container .dsp-editor { 2 | flex: 1 1 100%; 3 | display: flex; 4 | width: 100%; 5 | padding: 0px; 6 | overflow: auto; 7 | } 8 | 9 | div.package-faust-dsp.box-ui-container .dsp-editor .CodeMirror { 10 | height: auto; 11 | width: 100%; 12 | font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace; 13 | } 14 | 15 | div.package-faust-dsp.box-ui-container .box-ui-toggle { 16 | cursor: pointer; 17 | } 18 | 19 | div.package-faust-dsp.box-ui-container .faust-ui { 20 | margin: 0px 1px; 21 | } 22 | 23 | div.package-faust-dsp.box-ui-container .faust-ui .faust-ui-item { 24 | display: flex; 25 | align-items: center; 26 | padding-bottom: 5px; 27 | } 28 | 29 | div.package-faust-dsp.box-ui-container div.faust-ui-group { 30 | display: grid !important; 31 | grid-column: span 4; 32 | grid-template-columns: repeat(4, 25%); 33 | } 34 | 35 | div.package-faust-dsp.box-ui-container .faust-ui-group .faust-ui-hslider { 36 | grid-column: span 2; 37 | padding-right: 10px; 38 | } 39 | 40 | div.package-faust-dsp.box-ui-container .faust-ui-group .faust-ui-vslider { 41 | display: inline-block; 42 | grid-row: span 4; 43 | } 44 | 45 | div.package-faust-dsp.box-ui-container .faust-ui-vgroup { 46 | grid-column: span 4; 47 | } 48 | 49 | div.package-faust-dsp.box-ui-container .faust-ui-hgroup { 50 | grid-row: span 4; 51 | } 52 | 53 | div.package-faust-dsp.box-ui-container .faust-ui-tgroup { 54 | grid-column: span 4; 55 | grid-row: span 4; 56 | } 57 | 58 | div.package-faust-dsp.box-ui-container .faust-ui .faust-ui-item .label { 59 | min-width: 60px; 60 | overflow-x: hidden; 61 | } 62 | 63 | div.package-faust-dsp.box-ui-container .faust-ui .faust-ui-item .ui-slider-horizontal { 64 | width: 100%; 65 | } 66 | 67 | .faust-ui-label ~ .faust-ui-item { 68 | margin-top: 2rem; 69 | } 70 | 71 | .faust-ui-hbargraph, 72 | .faust-ui-vbargraph { 73 | grid-column: span 2; 74 | padding-right: 10px; 75 | } 76 | 77 | .faust-ui-hbargraph>.ui.progress, 78 | .faust-ui-vbargraph>.ui.progress { 79 | width: 100%; 80 | margin: auto !important; 81 | } 82 | 83 | .faust-ui-hbargraph>.ui.progress>.bar, 84 | .faust-ui-vbargraph>.ui.progress>.bar { 85 | background-image: linear-gradient(to right, rgb(0, 255, 0) 0%, rgb(255, 255, 0) 60%, rgb(255, 255, 0) 80%, rgb(255, 0, 0)); 86 | background-color: rgba(0, 0, 0, 0); 87 | min-width: auto; 88 | width: 100%; 89 | padding-right: 100%; 90 | background-origin: padding-box; 91 | background-repeat: no-repeat; 92 | background-clip: content-box; 93 | } 94 | 95 | .faust-ui-hbargraph>.ui.progress>.bar>.progress, 96 | .faust-ui-vbargraph>.ui.progress>.bar>.progress {left: 0.5em; 97 | right: auto; 98 | color: #00000080; 99 | text-shadow: 0px 0px 2px #808080; 100 | } 101 | -------------------------------------------------------------------------------- /src/object/faust/SHA1.js: -------------------------------------------------------------------------------- 1 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 2 | /* SHA-1 implementation in JavaScript | (c) Chris Veness 2002-2013 | www.movable-type.co.uk */ 3 | /* - see http://csrc.nist.gov/groups/ST/toolkit/secure_hashing.html */ 4 | /* http://csrc.nist.gov/groups/ST/toolkit/examples.html */ 5 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 6 | 7 | var Sha1 = {}; // Sha1 namespace 8 | 9 | /** 10 | * Generates SHA-1 hash of string 11 | * 12 | * @param {String} msg String to be hashed 13 | * @param {Boolean} [utf8encode=true] Encode msg as UTF-8 before generating hash 14 | * @returns {String} Hash of msg as hex character string 15 | */ 16 | Sha1.hash = function(msg, utf8encode) { 17 | utf8encode = (typeof utf8encode == 'undefined') ? true : utf8encode; 18 | 19 | // convert string to UTF-8, as SHA only deals with byte-streams 20 | if (utf8encode) msg = Utf8.encode(msg); 21 | 22 | // constants [§4.2.1] 23 | var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6]; 24 | 25 | // PREPROCESSING 26 | 27 | msg += String.fromCharCode(0x80); // add trailing '1' bit (+ 0's padding) to string [§5.1.1] 28 | 29 | // convert string msg into 512-bit/16-integer blocks arrays of ints [§5.2.1] 30 | var l = msg.length/4 + 2; // length (in 32-bit integers) of msg + ‘1’ + appended length 31 | var N = Math.ceil(l/16); // number of 16-integer-blocks required to hold 'l' ints 32 | var M = new Array(N); 33 | 34 | for (var i=0; i>> 32, but since JS converts 43 | // bitwise-op args to 32 bits, we need to simulate this by arithmetic operators 44 | M[N-1][14] = ((msg.length-1)*8) / Math.pow(2, 32); M[N-1][14] = Math.floor(M[N-1][14]) 45 | M[N-1][15] = ((msg.length-1)*8) & 0xffffffff; 46 | 47 | // set initial hash value [§5.3.1] 48 | var H0 = 0x67452301; 49 | var H1 = 0xefcdab89; 50 | var H2 = 0x98badcfe; 51 | var H3 = 0x10325476; 52 | var H4 = 0xc3d2e1f0; 53 | 54 | // HASH COMPUTATION [§6.1.2] 55 | 56 | var W = new Array(80); var a, b, c, d, e; 57 | for (var i=0; i>>(32-n)); 106 | } 107 | 108 | // 109 | // hexadecimal representation of a number 110 | // (note toString(16) is implementation-dependant, and 111 | // in IE returns signed numbers when used on full words) 112 | // 113 | Sha1.toHexStr = function(n) { 114 | var s="", v; 115 | for (var i=7; i>=0; i--) { v = (n>>>(i*4)) & 0xf; s += v.toString(16); } 116 | return s; 117 | } 118 | 119 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 120 | /* Utf8 class: encode / decode between multi-byte Unicode characters and UTF-8 multiple */ 121 | /* single-byte character encoding (c) Chris Veness 2002-2013 */ 122 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 123 | 124 | var Utf8 = {}; // Utf8 namespace 125 | 126 | /** 127 | * Encode multi-byte Unicode string into utf-8 multiple single-byte characters 128 | * (BMP / basic multilingual plane only) 129 | * 130 | * Chars in range U+0080 - U+07FF are encoded in 2 chars, U+0800 - U+FFFF in 3 chars 131 | * 132 | * @param {String} strUni Unicode string to be encoded as UTF-8 133 | * @returns {String} encoded string 134 | */ 135 | Utf8.encode = function(strUni) { 136 | // use regular expressions & String.replace callback function for better efficiency 137 | // than procedural approaches 138 | var strUtf = strUni.replace( 139 | /[\u0080-\u07ff]/g, // U+0080 - U+07FF => 2 bytes 110yyyyy, 10zzzzzz 140 | function(c) { 141 | var cc = c.charCodeAt(0); 142 | return String.fromCharCode(0xc0 | cc>>6, 0x80 | cc&0x3f); } 143 | ); 144 | strUtf = strUtf.replace( 145 | /[\u0800-\uffff]/g, // U+0800 - U+FFFF => 3 bytes 1110xxxx, 10yyyyyy, 10zzzzzz 146 | function(c) { 147 | var cc = c.charCodeAt(0); 148 | return String.fromCharCode(0xe0 | cc>>12, 0x80 | cc>>6&0x3F, 0x80 | cc&0x3f); } 149 | ); 150 | return strUtf; 151 | } 152 | 153 | /** 154 | * Decode utf-8 encoded string back into multi-byte Unicode characters 155 | * 156 | * @param {String} strUtf UTF-8 string to be decoded back to Unicode 157 | * @returns {String} decoded string 158 | */ 159 | Utf8.decode = function(strUtf) { 160 | // note: decode 3-byte chars first as decoded 2-byte strings could appear to be 3-byte char! 161 | var strUni = strUtf.replace( 162 | /[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g, // 3-byte chars 163 | function(c) { // (note parentheses for precence) 164 | var cc = ((c.charCodeAt(0)&0x0f)<<12) | ((c.charCodeAt(1)&0x3f)<<6) | ( c.charCodeAt(2)&0x3f); 165 | return String.fromCharCode(cc); } 166 | ); 167 | strUni = strUni.replace( 168 | /[\u00c0-\u00df][\u0080-\u00bf]/g, // 2-byte chars 169 | function(c) { // (note parentheses for precence) 170 | var cc = (c.charCodeAt(0)&0x1f)<<6 | c.charCodeAt(1)&0x3f; 171 | return String.fromCharCode(cc); } 172 | ); 173 | return strUni; 174 | } 175 | 176 | export default Sha1; -------------------------------------------------------------------------------- /src/object/faust/codemirror/mode/faust/faust.js: -------------------------------------------------------------------------------- 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 | // Distributed under an MIT license: http://codemirror.net/LICENSE 3 | 4 | (function(mod) { 5 | if (typeof exports == "object" && typeof module == "object") // CommonJS 6 | mod(require("codemirror"), require("codemirror/mode/clike/clike.js")); 7 | })(function(CodeMirror) { 8 | "use strict"; 9 | 10 | var keywords = 11 | "process component import library declare with environment waveform" 12 | .split(" "); 13 | var blockKeywords = ""; 14 | var builtins = ""; 15 | var atoms = 16 | "mem prefix int float rdtable rwtable select2 select3 ffunction fconstant fvariable button checkbox vslider hslider nentry vgroup hgroup tgroup vbargraph hbargraph attach acos asin atan atan2 cos sin tan exp log log10 pow sqrt abs min max fmod remainder floor ceil rint" 17 | .split(" "); 18 | 19 | function set(words) { 20 | var obj = {}; 21 | for (var i = 0; i < words.length; ++i) obj[words[i]] = true; 22 | return obj; 23 | } 24 | 25 | CodeMirror.defineMIME("application/faust", { 26 | name: "clike", 27 | keywords: set(keywords), 28 | multiLineStrings: true, 29 | blockKeywords: set(blockKeywords), 30 | builtin: set(builtins), 31 | atoms: set(atoms), 32 | hooks: { 33 | "@": function(stream) { 34 | return "meta"; 35 | }, 36 | "'": function(stream) { 37 | return "meta"; 38 | } 39 | } 40 | }); 41 | 42 | CodeMirror.registerHelper("hintWords", "application/faust", keywords.concat( 43 | atoms).concat(builtins)); 44 | 45 | // This is needed to make loading through meta.js work. 46 | CodeMirror.defineMode("faust", function(conf) { 47 | return CodeMirror.getMode(conf, "application/faust"); 48 | }, "clike"); 49 | }); 50 | -------------------------------------------------------------------------------- /src/object/faust/libfaust-wasm.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fr0stbyteR/webaudio-patcher/685e941591e565e6b651741047d4d483cf085822/src/object/faust/libfaust-wasm.wasm -------------------------------------------------------------------------------- /src/object/max/Max.js: -------------------------------------------------------------------------------- 1 | import Base from "../Base.js"; 2 | 3 | class MaxObject extends Base.BaseObject { 4 | static get _meta() { 5 | return Object.assign(super._meta, { 6 | package : "Max", 7 | icon : "microchip", 8 | author : "Fr0stbyteR", 9 | version : "1.0.0" 10 | }); 11 | } 12 | } 13 | // class Message (?<=^|\s)(\$\d) 14 | import RNG from "seedrandom"; 15 | class random extends MaxObject { 16 | static get _meta() { 17 | return Object.assign(super._meta, { 18 | description : "Generate a random number", 19 | inlets : [{ 20 | isHot : true, 21 | type : "anything", 22 | description : "Causes Random Number Output" 23 | }, { 24 | isHot : false, 25 | type : "anything", 26 | description : "Set the Random Number Range" 27 | }], 28 | outlets : [{ 29 | type : "number", 30 | description : "Random Number Output" 31 | }] 32 | }); 33 | } 34 | constructor(box, patcher) { 35 | super(box, patcher); 36 | this._inlets = 2; 37 | this._outlets = 1; 38 | this._mem.seed = 0; 39 | this._mem.rng = Math.random; 40 | this._mem.maximum = 0; 41 | this.update(box._args, box._props); 42 | } 43 | 44 | update(args, props) { 45 | if (args && args[0] && Base.Utils.toNumber(args[0]) >= 0) { 46 | this._mem.maximum = Base.Utils.toNumber(args[0]); 47 | } 48 | if (args && args[1]) { 49 | if (args[1] !== 0) this._mem.rng = new RNG(args[0]); 50 | else this._mem.rng = Math.random; 51 | } 52 | } 53 | 54 | fn(data, inlet) { 55 | let arrayIn = Base.Utils.list2Array(data); 56 | if (inlet == 0) { 57 | if (data instanceof Base.Bang) this.outlet(0, Math.floor(this._mem.rng() * this._mem.maximum)); 58 | if (arrayIn && arrayIn.length >= 2 && arrayIn[0] == "seed") this.update([null, arrayIn[0]]); 59 | 60 | } 61 | if (inlet == 1) { 62 | this.update([data]); 63 | } 64 | } 65 | } 66 | class metro extends MaxObject { 67 | static get _meta() { 68 | return Object.assign(super._meta, { 69 | description : "Output a bang message at regular intervals", 70 | inlets : [{ 71 | isHot : true, 72 | type : "boolean", 73 | description : "Start/Stop Metronome" 74 | }, { 75 | isHot : false, 76 | type : "anything", 77 | description : "Set Metronome Time Interval" 78 | }], 79 | outlets : [{ 80 | type : "object", 81 | description : "Output Ticks of Metronome" 82 | }] 83 | }); 84 | } 85 | constructor(box, patcher) { 86 | super(box, patcher); 87 | this._inlets = 2; 88 | this._outlets = 1; 89 | this._mem.interval = 5; 90 | this._mem.active = 0; 91 | this._mem.timeoutID = null; 92 | this.update(box._args, box._props); 93 | } 94 | update(args, props) { 95 | let callback = () => { 96 | return () => { 97 | if (this._mem.active) { 98 | this.outlet(0, new Base.Bang()); 99 | this._mem.timeoutID = window.setTimeout(callback(), this._mem.interval); 100 | } 101 | } 102 | } 103 | if ((args && args[0]) || (props && props.hasOwnProperty("interval"))) { 104 | let interval = Base.Utils.toNumber(args[0]); 105 | if (interval === null) { 106 | this.error("Don't understand" + args[0]); 107 | } else { 108 | this._mem.interval = interval < 1 ? 1 : interval; 109 | } 110 | } 111 | if (props && props.hasOwnProperty("active")) { 112 | let active = Base.Utils.toNumber(props.active); 113 | if (active === null) { 114 | this.error("Don't understand" + props.active); 115 | } else { 116 | this._mem.active = active !== 0; 117 | if (this._mem.active) { 118 | window.clearTimeout(this._mem.timeoutID); 119 | this.outlet(0, new Base.Bang()); 120 | this._mem.timeoutID = window.setTimeout(callback(), this._mem.interval); 121 | } else { 122 | window.clearTimeout(this._mem.timeoutID); 123 | } 124 | } 125 | } 126 | return this; 127 | } 128 | fn(data, inlet) { 129 | if (inlet == 0) { 130 | this.update(null, {active : data}); 131 | } 132 | if (inlet == 1) { 133 | this.update([data]); 134 | } 135 | } 136 | } 137 | 138 | export default { 139 | metro, 140 | random 141 | } -------------------------------------------------------------------------------- /src/selection-js/src/utils.js: -------------------------------------------------------------------------------- 1 | function eventListener(method, elements, events, fn, options = {}) { 2 | 3 | // Normalize array 4 | if (elements instanceof HTMLCollection || elements instanceof NodeList) { 5 | elements = Array.from(elements); 6 | } else if (!Array.isArray(elements)) { 7 | elements = [elements]; 8 | } 9 | 10 | if (!Array.isArray(events)) events = [events]; 11 | 12 | for (const element of elements) { 13 | for (const event of events) { 14 | element[method](event, fn, {capture: false, ...options}); 15 | } 16 | } 17 | 18 | return Array.prototype.slice.call(arguments, 1); 19 | } 20 | 21 | /** 22 | * Add event(s) to element(s). 23 | * @param elements DOM-Elements 24 | * @param events Event names 25 | * @param fn Callback 26 | * @param options Optional options 27 | * @return Array passed arguments 28 | */ 29 | export const on = eventListener.bind(null, 'addEventListener'); 30 | 31 | /** 32 | * Remove event(s) from element(s). 33 | * @param elements DOM-Elements 34 | * @param events Event names 35 | * @param fn Callback 36 | * @param options Optional options 37 | * @return Array passed arguments 38 | */ 39 | export const off = eventListener.bind(null, 'removeEventListener'); 40 | 41 | const unitify = (val, unit = 'px') => typeof val === 'number' ? val + unit : '' + val; 42 | 43 | /** 44 | * Add css to a DOM-Element or returns the current 45 | * value of a property. 46 | * 47 | * @param el The Element. 48 | * @param attr The attribute or a object which holds css key-properties. 49 | * @param val The value for a single attribute. 50 | * @returns {*} 51 | */ 52 | export function css(el, attr, val) { 53 | const style = el && el.style; 54 | if (!style) return; 55 | 56 | if (typeof attr === 'object') { 57 | 58 | for (const prop in attr) { 59 | style[prop] = unitify(attr[prop]); 60 | } 61 | 62 | } else if (val == null) { 63 | 64 | const dw = document.defaultView; 65 | if (dw && dw.getComputedStyle) { 66 | val = dw.getComputedStyle(el, null); 67 | } else if (el.currentStyle) { 68 | val = el.currentStyle; 69 | } 70 | 71 | return attr == null ? val : val[attr]; 72 | } else { 73 | style[attr] = unitify(val); 74 | } 75 | } 76 | 77 | /** 78 | * Check if two DOM-Elements intersects each other. 79 | * @param ela First DOM-Element. 80 | * @param elb Second DOM-Element. 81 | * @param mode Options are center, cover or touch. 82 | * @returns {boolean} If both elements intersects each other. 83 | */ 84 | export function intersects(ela, elb, mode = 'touch') { 85 | const a = ela.getBoundingClientRect(); 86 | const b = elb.getBoundingClientRect(); 87 | 88 | if (mode === 'center') { 89 | const bxc = b.left + b.width / 2; 90 | const byc = b.top + b.height / 2; 91 | 92 | return bxc >= a.left 93 | && bxc <= a.right 94 | && byc >= a.top 95 | && byc <= a.bottom; 96 | } else if (mode === 'cover') { 97 | return b.left >= a.left 98 | && b.top >= a.top 99 | && b.right <= a.right 100 | && b.bottom <= a.bottom; 101 | } else if (mode === 'touch') { 102 | return a.right >= b.left 103 | && a.left <= b.right 104 | && a.bottom >= b.top 105 | && a.top <= b.bottom; 106 | } 107 | } 108 | 109 | /** 110 | * Takes a selector (or array of selectors) and returns the matched nodes. 111 | * @param selector The selector or an Array of selectors. 112 | * @returns {Array} Array of DOM-Nodes. 113 | */ 114 | export function selectAll(selector) { 115 | if (!Array.isArray(selector)) selector = [selector]; 116 | 117 | const nodes = []; 118 | for (const sel of selector) { 119 | nodes.push(...document.querySelectorAll(sel)); 120 | } 121 | 122 | return nodes; 123 | } 124 | 125 | /** 126 | * Polyfill for safari & firefox for the eventPath event property. 127 | * @param evt The event object. 128 | * @return [String] event path. 129 | */ 130 | export function eventPath(evt) { 131 | let path = evt.path || (evt.composedPath && evt.composedPath()); 132 | if (path) return path; 133 | 134 | let el = evt.target.parentElement; 135 | path = [evt.target, el]; 136 | while (el == el.parentElement) path.push(el); 137 | 138 | path.push(document, window); 139 | return path; 140 | } 141 | 142 | /** 143 | * Removes an element from an Array. 144 | */ 145 | export function removeElement(arr, el) { 146 | const index = arr.indexOf(el); 147 | if (~index) arr.splice(index, 1); 148 | } 149 | 150 | export function simplifyEvent(evt) { 151 | const tap = (evt.touches && evt.touches[0] || evt); 152 | return { 153 | tap, 154 | x: tap.clientX, 155 | y: tap.clientY, 156 | target: tap.target 157 | }; 158 | } -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const webpack = require('webpack'); 3 | module.exports = { 4 | optimization: { 5 | minimize: false 6 | }, 7 | node: { 8 | fs: 'empty' 9 | }, 10 | mode: 'development', 11 | entry: './src/index.js', 12 | output: { 13 | filename: 'bundle.js', 14 | path: path.resolve(__dirname, 'dist') 15 | }, 16 | resolve: { 17 | alias: { 18 | "jquery-ui": "jquery-ui" 19 | } 20 | }, 21 | // expose jquery's $ for imports 22 | plugins: [ 23 | new webpack.ProvidePlugin({ 24 | $: 'jquery', 25 | jQuery: 'jquery' 26 | }) 27 | ], 28 | module: { 29 | rules: [ 30 | { 31 | enforce: "pre", 32 | test: /\.js$/, 33 | exclude: /node_modules/, 34 | loader: "eslint-loader", 35 | options: { 36 | configFile: path.resolve('.eslintrc.json'), 37 | eslint: { 38 | configFile: path.resolve(__dirname, '.eslintrc.json') 39 | } 40 | } 41 | }, 42 | { 43 | test: /\.jsx$/, 44 | exclude: /node_modules/, 45 | loader: 'babel-loader', 46 | query: { 47 | presets: ['@babel/preset-react', '@babel/preset-env'], 48 | 49 | } 50 | }, 51 | { 52 | test: /\.css$/, 53 | use: [ 'style-loader', 'css-loader' ] 54 | }, 55 | { 56 | test: /\.(png|jpg|gif)$/, 57 | use: [ 58 | { 59 | loader: 'file-loader', 60 | options: { 61 | outputPath: 'assets/', 62 | publicPath: 'dist/assets/' 63 | } 64 | } 65 | ] 66 | } 67 | ] 68 | } 69 | }; --------------------------------------------------------------------------------