├── .gitattributes ├── .gitignore ├── .jshintrc ├── .npmignore ├── GPL-LICENSE.txt ├── Gruntfile.js ├── MIT-LICENSE.txt ├── README.md ├── build-support └── js │ ├── amd-footer.js │ └── amd-header.js ├── demos ├── audio-file │ ├── css │ │ └── audiofile.css │ └── index.html ├── audio-input │ ├── index.html │ └── js │ │ └── audio-input.js ├── demos.css ├── media-element-input │ ├── index.html │ └── js │ │ └── media-element-input.js ├── playground │ ├── css │ │ ├── playground.css │ │ └── shake.css │ ├── demos │ │ ├── .jshintrc │ │ ├── adsr.js │ │ ├── am.js │ │ ├── asr.js │ │ ├── audio-in-granulated.js │ │ ├── audio-in.js │ │ ├── band.js │ │ ├── bandlimited-impulse.js │ │ ├── bandpass-filter.js │ │ ├── bandreject-filter.js │ │ ├── chop-buffer.js │ │ ├── custom-envelope.js │ │ ├── decay.js │ │ ├── declarative-scheduling.js │ │ ├── dejong-distortion.js │ │ ├── delay.js │ │ ├── dust.js │ │ ├── fm.js │ │ ├── for-ann-rising.js │ │ ├── glissando.js │ │ ├── granulator.js │ │ ├── highpass-filter.js │ │ ├── impulse-pm.js │ │ ├── impulse.js │ │ ├── latch.js │ │ ├── lfNoise.js │ │ ├── line-fm.js │ │ ├── line-pm.js │ │ ├── lowpass-filter.js │ │ ├── moog.js │ │ ├── mouse-click.js │ │ ├── mouse-x.js │ │ ├── mouse-xy.js │ │ ├── mouse-y.js │ │ ├── multiple-synths.js │ │ ├── noise-fm.js │ │ ├── pinknoise.js │ │ ├── play-buffer.js │ │ ├── playBuffer-trigger.js │ │ ├── pm.js │ │ ├── polyphonicSynth.js │ │ ├── quadraphonic.js │ │ ├── readBuffer-phasor.js │ │ ├── readBuffer.js │ │ ├── sample-accurate-scheduling.js │ │ ├── saw.js │ │ ├── scope.js │ │ ├── sequencer.js │ │ ├── sine.js │ │ ├── square.js │ │ ├── stereo.js │ │ ├── sum.js │ │ ├── tanh-distortion.js │ │ ├── tarrabia-dejong-distortion.js │ │ ├── tri.js │ │ ├── trigger-callback.js │ │ └── whitenoise.js │ ├── index.html │ ├── js │ │ ├── demo-list.js │ │ ├── demo-selector.js │ │ ├── error-console.js │ │ ├── playground.js │ │ └── source-evaluators.js │ └── live │ │ ├── css │ │ └── live-playground.css │ │ ├── demos │ │ ├── adsr.json │ │ ├── am.json │ │ ├── asr.json │ │ ├── audio-in-granulated.json │ │ ├── audio-in.json │ │ ├── band.json │ │ ├── bandlimited-impulse.json │ │ ├── bandpass-filter.json │ │ ├── bandreject-filter.json │ │ ├── chop-buffer.json │ │ ├── custom-envelope.json │ │ ├── decay.json │ │ ├── declarative-scheduling.json │ │ ├── dejong-distortion.json │ │ ├── delay.json │ │ ├── dust.json │ │ ├── fm.json │ │ ├── glissando.json │ │ ├── granulator.json │ │ ├── highpass-filter.json │ │ ├── impulse-pm.json │ │ ├── impulse.json │ │ ├── latch.json │ │ ├── lfNoise.json │ │ ├── line-fm.json │ │ ├── line-pm.json │ │ ├── lowpass-filter.json │ │ ├── moog.json │ │ ├── mouse-click.json │ │ ├── mouse-x.json │ │ ├── mouse-xy.json │ │ ├── mouse-y.json │ │ ├── noise-fm.json │ │ ├── pinknoise.json │ │ ├── play-buffer.json │ │ ├── playBuffer-trigger.json │ │ ├── pm.json │ │ ├── quadraphonic.json │ │ ├── readBuffer-phasor.json │ │ ├── readBuffer.json │ │ ├── sample-accurate-scheduling.json │ │ ├── saw.json │ │ ├── scope.json │ │ ├── sequencer.json │ │ ├── sine.json │ │ ├── square.json │ │ ├── stereo.json │ │ ├── tanh-distortion.json │ │ ├── tarrabia-dejong-distortion.json │ │ ├── tri.json │ │ └── whitenoise.json │ │ ├── index.html │ │ └── js │ │ ├── live-demo-list.js │ │ └── visual-editor.js └── shared │ ├── audio │ ├── hillier-first-chord.wav │ └── where-the-honey-is.mp3 │ ├── css │ └── demos.css │ └── js │ └── demo-utils.js ├── docs ├── buffers │ └── about-buffers.md ├── building-flocking.md ├── getting-started.md ├── responding-to-user-input.md ├── scheduling.md ├── synths │ └── creating-synths.md └── ugens │ ├── buffers.md │ ├── distortions.md │ ├── mouse.md │ ├── oscillators.md │ └── triggers.md ├── favicon.ico ├── flocking-website.css ├── images ├── flocking-tentative-logo.png ├── pause.ai ├── pause.png ├── play.ai └── play.png ├── index.html ├── package.json ├── src ├── audiofile-encoder.js ├── audiofile.js ├── buffers.js ├── core.js ├── evaluators.js ├── flocking-audiofile-compatibility.js ├── flocking-audiofile-converters.js ├── flocking-audiofile-worker.js ├── gfx.js ├── node-list.js ├── parser.js ├── scheduler.js ├── synths │ ├── band.js │ ├── frame-rate.js │ ├── group.js │ ├── model.js │ ├── polyphonic.js │ ├── synth.js │ └── value.js ├── testing.js ├── ugens │ ├── bandlimited.js │ ├── browser.js │ ├── buffer.js │ ├── core.js │ ├── debugging.js │ ├── distortion.js │ ├── dynamics.js │ ├── envelopes.js │ ├── filters.js │ ├── gates.js │ ├── granular.js │ ├── listening.js │ ├── math.js │ ├── midi.js │ ├── multichannel.js │ ├── oscillators.js │ ├── random.js │ ├── scheduling.js │ └── triggers.js ├── ui │ ├── editor │ │ ├── css │ │ │ └── editor.css │ │ └── js │ │ │ └── editor.js │ ├── play-button │ │ ├── css │ │ │ └── play-button.css │ │ └── js │ │ │ └── play-button.js │ ├── selectbox │ │ └── js │ │ │ └── selectbox.js │ ├── shared │ │ ├── css │ │ │ └── flocking-icon-font.css │ │ └── fonts │ │ │ ├── flocking-icon-font.eot │ │ │ ├── flocking-icon-font.svg │ │ │ ├── flocking-icon-font.ttf │ │ │ └── flocking-icon-font.woff │ └── third-party │ │ └── normalize │ │ └── css │ │ └── normalize.css └── web │ ├── audio-system.js │ ├── buffer-writer.js │ ├── input-device-manager.js │ ├── native-node-manager.js │ ├── output-manager.js │ └── webaudio-core.js ├── tests ├── manual │ └── aiff-playback-11Khz │ │ ├── README.md │ │ ├── hockey.aiff │ │ ├── hockey.wav │ │ └── index.html ├── performance │ ├── css │ │ └── benchmarks.css │ ├── html │ │ ├── audiofile-benchmarks.html │ │ ├── standalone-ugen-benchmarks.html │ │ └── synth-benchmarks.html │ └── js │ │ ├── audiofile-benchmarks.js │ │ ├── standalone-ugen-benchmarks.js │ │ └── synth-benchmarks.js ├── shared │ ├── audio │ │ ├── long-triangle-int16-44100.wav │ │ ├── long-triangle-int16-48000.wav │ │ ├── long-triangle-int16-88200.wav │ │ └── long-triangle-int16-96000.wav │ └── js │ │ └── audiofile-dataurls.js └── unit │ ├── all-tests.html │ ├── html │ ├── audiofile-decoder-tests.html │ ├── audiofile-tests.html │ ├── band-tests.html │ ├── bandlimited-ugen-tests.html │ ├── buffer-tests.html │ ├── buffer-ugen-tests.html │ ├── bus-tests.html │ ├── core-tests.html │ ├── core-utilities-tests.html │ ├── dynamics-ugen-tests.html │ ├── envelope-ugen-tests.html │ ├── envgen-ugen-tests.html │ ├── filter-ugen-tests.html │ ├── gate-ugen-tests.html │ ├── ioc-integration-tests.html │ ├── listening-ugen-tests.html │ ├── math-ugen-tests.html │ ├── midi-ugen-tests.html │ ├── model-synth-tests.html │ ├── multichannel-ugen-tests.html │ ├── nodelist-tests.html │ ├── osc-ugen-tests.html │ ├── parser-tests.html │ ├── perf-tests.html │ ├── phasor-ugen-tests.html │ ├── playbuffer-ugen-tests.html │ ├── random-ugen-tests.html │ ├── require-tests.html │ ├── scheduler-tests.html │ ├── scheduler-timing-tests.html │ ├── scheduling-ugen-tests.html │ ├── synth-environment-tests.html │ ├── synth-evaluation-tests.html │ ├── synth-group-tests.html │ ├── synth-instantiation-tests.html │ ├── synth-note-target-tests.html │ ├── synth-removal-tests.html │ ├── synth-scheduled-tests.html │ ├── synth-tests.html │ ├── test-utils-tests.html │ ├── trigger-ugen-tests.html │ ├── ugen-tests.html │ ├── webaudio-tests.html │ └── writebuffer-ugen-tests.html │ ├── js │ ├── audiofile-decoder-tests.js │ ├── audiofile-test-utils.js │ ├── audiofile-tests.js │ ├── band-tests.js │ ├── bandlimited-ugen-tests.js │ ├── buffer-tests.js │ ├── buffer-ugen-tests.js │ ├── bus-tests.js │ ├── core-tests.js │ ├── core-utilities-tests.js │ ├── dynamics-ugen-tests.js │ ├── envelope-ugen-tests.js │ ├── envgen-ugen-tests.js │ ├── filter-ugen-tests.js │ ├── flocking-test-utils.js │ ├── gate-ugen-tests.js │ ├── ioc-integration-tests.js │ ├── listening-ugen-tests.js │ ├── math-ugen-tests.js │ ├── midi-ugen-tests.js │ ├── model-synth-tests.js │ ├── multichannel-ugen-tests.js │ ├── nodelist-tests.js │ ├── osc-ugen-tests.js │ ├── parser-tests.js │ ├── perf-tests.js │ ├── phasor-ugen-tests.js │ ├── playbuffer-ugen-tests.js │ ├── random-ugen-tests.js │ ├── require-tests.js │ ├── scheduler-tests.js │ ├── scheduler-timing-tests.js │ ├── scheduling-ugen-tests.js │ ├── synth-environment-tests.js │ ├── synth-evaluation-tests.js │ ├── synth-group-tests.js │ ├── synth-instantiation-tests.js │ ├── synth-note-target-tests.js │ ├── synth-removal-tests.js │ ├── synth-scheduled-tests.js │ ├── synth-tests.js │ ├── test-utils-tests.js │ ├── trigger-ugen-tests.js │ ├── ugen-tests.js │ ├── webaudio-tests.js │ └── writebuffer-ugen-tests.js │ └── testem.json └── third-party ├── simjs └── js │ └── random-0.26.js └── webarraymath └── js └── webarraymath.js /.gitattributes: -------------------------------------------------------------------------------- 1 | dist/*.js binary 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | /.vagrant/ 4 | package-lock.json 5 | yarn.lock 6 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "white": false, 3 | "newcap": true, 4 | "regexp": true, 5 | "browser": true, 6 | "forin": false, 7 | "nomen": true, 8 | "bitwise": false, 9 | "maxerr": 100, 10 | "indent": 4, 11 | "plusplus": false, 12 | "curly": true, 13 | "eqeqeq": true, 14 | "freeze": true, 15 | "latedef": true, 16 | "noarg": true, 17 | "nonew": true, 18 | "quotmark": "double", 19 | "undef": true, 20 | "unused": true, 21 | "strict": true, 22 | "asi": false, 23 | "boss": false, 24 | "evil": false, 25 | "expr": false, 26 | "funcscope": false 27 | } 28 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /tests 2 | -------------------------------------------------------------------------------- /MIT-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2016 Colin Clark 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /build-support/js/amd-footer.js: -------------------------------------------------------------------------------- 1 | 2 | window.fluid = fluid; 3 | 4 | return flock; 5 | })); 6 | -------------------------------------------------------------------------------- /build-support/js/amd-header.js: -------------------------------------------------------------------------------- 1 | (function (root, factory) { 2 | if (typeof exports === "object") { 3 | // We're in a CommonJS-style loader. 4 | root.flock = exports; // Always create the "flock" global. 5 | factory(exports, require("jquery")); 6 | } else if (typeof define === "function" && define.amd) { 7 | // We're in an AMD-style loader. 8 | define(["exports", "jquery"], function (exports, jQuery) { 9 | root.flock = exports; // Always create the "flock" global. 10 | return (root.flock, factory(exports, jQuery)); 11 | }); 12 | } else { 13 | // Plain old browser. 14 | root.flock = {}; 15 | factory(root.flock, jQuery); 16 | } 17 | }(this, function (exports, jQuery) { 18 | // To hell with isolationism. 19 | window.jQuery = jQuery; 20 | -------------------------------------------------------------------------------- /demos/audio-file/css/audiofile.css: -------------------------------------------------------------------------------- 1 | @import url(https://fonts.googleapis.com/css?family=Nunito); 2 | body { 3 | margin-left: 2%; 4 | } 5 | 6 | .view { 7 | clear: both; 8 | } 9 | 10 | .selectors,#waveform { 11 | border: solid #888 5px; 12 | border-radius: 25px; 13 | } 14 | 15 | .selectors { 16 | margin-bottom: 1.5%; 17 | float: left; 18 | padding: 2%; 19 | width: 40%; 20 | } 21 | 22 | .dataUrlSelector { 23 | margin-top: 5%; 24 | } 25 | 26 | .dataUrlSelector label { 27 | float: left; 28 | margin-right: 2%; 29 | margin-top: 7%; 30 | } 31 | 32 | #dataUrlField { 33 | width:50%; 34 | height: 100px; 35 | } 36 | 37 | .speedSelector { 38 | padding-top: 1%; 39 | } 40 | 41 | .speedSelector label { 42 | padding-right: 1%; 43 | } 44 | -------------------------------------------------------------------------------- /demos/audio-input/js/audio-input.js: -------------------------------------------------------------------------------- 1 | /*global fluid*/ 2 | (function () { 3 | "use strict"; 4 | 5 | fluid.defaults("flock.demo.audioInSynth", { 6 | gradeNames: "flock.synth", 7 | 8 | synthDef: { 9 | ugen: "flock.ugen.audioIn", 10 | mul: { 11 | ugen: "flock.ugen.sinOsc", 12 | freq: { 13 | ugen: "flock.ugen.mouse.cursor", 14 | add: 60, 15 | mul: 960 16 | }, 17 | mul: { 18 | ugen: "flock.ugen.mouse.cursor", 19 | add: 0.1, 20 | mul: 0.9, 21 | options: { 22 | axis: "y" 23 | } 24 | } 25 | } 26 | } 27 | }); 28 | 29 | fluid.defaults("flock.demo.audioIn", { 30 | gradeNames: "fluid.component", 31 | 32 | components: { 33 | synth: { 34 | type: "flock.demo.audioInSynth" 35 | }, 36 | 37 | playButton: { 38 | type: "flock.ui.enviroPlayButton", 39 | container: "#play" 40 | } 41 | } 42 | }); 43 | }()); 44 | -------------------------------------------------------------------------------- /demos/demos.css: -------------------------------------------------------------------------------- 1 | body { 2 | width: 50%; 3 | margin-left: 2%; 4 | } 5 | 6 | h1, h2 { 7 | font-family: sans-serif; 8 | margin-top: 9%; 9 | } 10 | 11 | h2 { 12 | margin-bottom: 5%; 13 | } 14 | 15 | .button-list { 16 | text-align: left; 17 | list-style: none; 18 | padding: 0; 19 | width: 55%; 20 | } 21 | 22 | .button-list li { 23 | display: block; 24 | margin-bottom: 3%; 25 | } 26 | 27 | .button-list li a { 28 | font-size: 125%; 29 | font-family: sans-serif; 30 | text-decoration: none; 31 | font-weight: bold; 32 | background-color: #eee; 33 | display: block; 34 | width: 100%; 35 | border-radius: 10px 10px 10px 10px; 36 | padding: 7%; 37 | } 38 | 39 | .button-list li:nth-child(2n) a { 40 | background-color: #ccc; 41 | } 42 | 43 | .button-list li a:hover { 44 | background-color: #999; 45 | border-color: #aaa; 46 | color: #fff; 47 | } 48 | 49 | a { 50 | color: #333; 51 | } 52 | 53 | a:visited { 54 | color: #555; 55 | text-decoration: none; 56 | } 57 | 58 | a:hover { 59 | color: #fff; 60 | text-decoration: none; 61 | } 62 | 63 | a:active { 64 | color: #ccc; 65 | text-decoration: none; 66 | } 67 | -------------------------------------------------------------------------------- /demos/playground/css/playground.css: -------------------------------------------------------------------------------- 1 | *, 2 | *:before, 3 | *:after { 4 | -moz-box-sizing: border-box; 5 | -webkit-box-sizing: border-box; 6 | box-sizing: border-box; 7 | } 8 | html, body, .everything { 9 | height: 100%; 10 | font-family: sans-serif; 11 | } 12 | 13 | select { 14 | font-family: "Lucida Grande"; 15 | font-size: 0.8em; 16 | } 17 | 18 | label { 19 | font-weight: bold; 20 | font-size: 0.8em; 21 | } 22 | 23 | .everything { 24 | width: 100%; 25 | height: 100%; 26 | background-color: #272822; 27 | } 28 | 29 | .toolbar { 30 | background-color: #ddd; 31 | padding: 0.5em; 32 | } 33 | 34 | /* Clearfix. Get this from somewhere else or factor into a utility. */ 35 | .toolbar:after { 36 | content: " "; 37 | display: table; 38 | clear: both; 39 | } 40 | 41 | .toolbar .left { 42 | float: left; 43 | padding-top: 0.4em; 44 | } 45 | 46 | .toolbar .right { 47 | float: right; 48 | } 49 | 50 | .synthSelector { 51 | float: left; 52 | margin-top: 0.45em; 53 | } 54 | 55 | #gfx { 56 | float: right; 57 | padding-right: 1em; 58 | padding-top: 0.25em; 59 | background-color: #ddd; 60 | border-radius: 1em; 61 | } 62 | 63 | .mainPanel { 64 | height: 100%; 65 | width: 100%; 66 | padding-top: 3.1em; 67 | background-color: #272822; 68 | } 69 | 70 | #source-view { 71 | font-size: 12pt; 72 | float: left; 73 | border-right: 1px dotted #aaa; 74 | } 75 | 76 | .CodeMirror { 77 | height: 95%; 78 | border-bottom: 1px solid #aaa; 79 | } 80 | 81 | .CodeMirror-scroll { 82 | overflow: auto; 83 | } 84 | 85 | .masthead { 86 | background-color: #aaa; 87 | padding: 0.5em; 88 | position: fixed; 89 | top: 0; 90 | width: 100%; 91 | z-index: 100; 92 | } 93 | 94 | .console { 95 | color: #f77; 96 | background-color: #272822; 97 | padding: 0.5%; 98 | width: 100%; 99 | position: fixed; 100 | bottom: 0px; 101 | font-family: "Lucida Console", monospace; 102 | font-size: 0.75em; 103 | } 104 | -------------------------------------------------------------------------------- /demos/playground/demos/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "white": false, 3 | "newcap": true, 4 | "regexp": true, 5 | "browser": true, 6 | "forin": false, 7 | "nomen": true, 8 | "bitwise": false, 9 | "maxerr": 100, 10 | "indent": 4, 11 | "plusplus": false, 12 | "curly": true, 13 | "eqeqeq": true, 14 | "freeze": true, 15 | "latedef": true, 16 | "noarg": true, 17 | "nonew": true, 18 | "quotmark": "double", 19 | "undef": true, 20 | "unused": true, 21 | "asi": false, 22 | "boss": false, 23 | "evil": false, 24 | "expr": false, 25 | "funcscope": false, 26 | "predef": ["flock", "fluid", "$"] 27 | } 28 | 29 | -------------------------------------------------------------------------------- /demos/playground/demos/am.js: -------------------------------------------------------------------------------- 1 | // Creates a new synth with a sine wave that is 2 | // slowly being amplitude moduled by another sine wave. 3 | 4 | flock.synth({ 5 | synthDef: { 6 | id: "carrier", 7 | ugen: "flock.ugen.sinOsc", 8 | freq: 440, 9 | mul: { 10 | id: "mod", 11 | ugen: "flock.ugen.sinOsc", 12 | freq: 1.0, 13 | mul: 0.25 14 | } 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /demos/playground/demos/asr.js: -------------------------------------------------------------------------------- 1 | // Sine tone shaped by a simple attack/sustain/release envelope and periodically triggered. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.sinOsc", 6 | freq: 440, 7 | mul: { 8 | ugen: "flock.ugen.asr", 9 | start: 0.0, 10 | attack: 0.25, 11 | sustain: 0.25, 12 | release: 1.0, 13 | gate: { 14 | ugen: "flock.ugen.impulse", 15 | rate: "control", 16 | freq: 0.75, 17 | phase: 1.0 18 | } 19 | } 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /demos/playground/demos/audio-in-granulated.js: -------------------------------------------------------------------------------- 1 | // Granulates live audio from the microphone. 2 | // Wear headphones to prevent feedback. 3 | 4 | flock.synth({ 5 | synthDef: { 6 | ugen: "flock.ugen.granulator", 7 | delayDur: 0.25, 8 | numGrains: { 9 | ugen: "flock.ugen.lfNoise", 10 | freq: 0.5, 11 | mul: 75, 12 | add: 75, 13 | options: { 14 | interpolation: "linear" 15 | } 16 | }, 17 | source: { 18 | ugen: "flock.ugen.audioIn" 19 | } 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /demos/playground/demos/audio-in.js: -------------------------------------------------------------------------------- 1 | // Plays back live audio from the microphone. 2 | // Wear headphones to prevent feedback. 3 | 4 | flock.synth({ 5 | synthDef: { 6 | ugen: "flock.ugen.audioIn" 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /demos/playground/demos/band.js: -------------------------------------------------------------------------------- 1 | fluid.defaults("flock.demo.sequencedSine", { 2 | gradeNames: ["flock.synth"], 3 | synthDef: { 4 | ugen: "flock.ugen.out", 5 | expand: 1, 6 | sources: { 7 | ugen: "flock.ugen.sinOsc", 8 | freq: { 9 | ugen: "flock.ugen.sequence", 10 | loop: 1 11 | }, 12 | mul: 0.5 13 | } 14 | } 15 | }); 16 | 17 | flock.band({ 18 | components: { 19 | left: { 20 | type: "flock.demo.sequencedSine", 21 | options: { 22 | synthDef: { 23 | bus: 0, 24 | sources: { 25 | freq: { 26 | values: [1, 4/3, 5/4], 27 | freq: 3, 28 | mul: 440 29 | } 30 | } 31 | } 32 | } 33 | }, 34 | 35 | right: { 36 | type: "flock.demo.sequencedSine", 37 | options: { 38 | synthDef: { 39 | bus: 1, 40 | sources: { 41 | freq: { 42 | values: [1, 3/2], 43 | freq: 2, 44 | mul: 220 45 | } 46 | } 47 | } 48 | } 49 | } 50 | } 51 | }); 52 | -------------------------------------------------------------------------------- /demos/playground/demos/bandlimited-impulse.js: -------------------------------------------------------------------------------- 1 | flock.synth({ 2 | synthDef: [ 3 | // The left channel aliases alias at high frequencies (you'll hear it wobble). 4 | { 5 | ugen: "flock.ugen.impulse", 6 | freq: { 7 | ugen: "flock.ugen.xLine", 8 | start: 10000, 9 | end: 20, 10 | duration: 10 11 | }, 12 | mul: 0.5 13 | }, 14 | // The right channel is bandlimited, so it does not alias. 15 | { 16 | ugen: "flock.ugen.blit", 17 | freq: { 18 | ugen: "flock.ugen.xLine", 19 | start: 10000, 20 | end: 20, 21 | duration: 10 22 | }, 23 | mul: 0.5 24 | } 25 | ] 26 | }); 27 | -------------------------------------------------------------------------------- /demos/playground/demos/bandpass-filter.js: -------------------------------------------------------------------------------- 1 | flock.synth({ 2 | synthDef: { 3 | ugen: "flock.ugen.filter.biquad.bp", 4 | freq: { 5 | ugen: "flock.ugen.mouse.cursor", 6 | options: { 7 | interpolation: "exponential" 8 | }, 9 | mul: 10000, 10 | add: 100, 11 | lag: 1 12 | }, 13 | q: 3.0, 14 | source: { 15 | ugen: "flock.ugen.lfSaw", 16 | freq: 200, 17 | mul: 0.1 18 | } 19 | } 20 | }); 21 | -------------------------------------------------------------------------------- /demos/playground/demos/bandreject-filter.js: -------------------------------------------------------------------------------- 1 | flock.synth({ 2 | synthDef: { 3 | ugen: "flock.ugen.filter.biquad.br", 4 | freq: { 5 | ugen: "flock.ugen.mouse.cursor", 6 | options: { 7 | interpolation: "exponential" 8 | }, 9 | mul: 10000, 10 | add: 100, 11 | lag: 1 12 | }, 13 | q: 3.0, 14 | source: { 15 | ugen: "flock.ugen.lfSaw", 16 | freq: 200, 17 | mul: 0.1 18 | } 19 | } 20 | }); 21 | -------------------------------------------------------------------------------- /demos/playground/demos/chop-buffer.js: -------------------------------------------------------------------------------- 1 | // Move the mouse horizontally in the browser window to control 2 | // the amount that the buffer is chopped. 3 | flock.synth({ 4 | synthDef: { 5 | id: "chopper", 6 | ugen: "flock.ugen.chopBuffer", 7 | start: 0.1, 8 | amount: { 9 | ugen: "flock.ugen.triOsc", 10 | rate: "control", 11 | freq: 1/30, 12 | mul: 0.5, 13 | add: 0.5 14 | }, 15 | speed: { 16 | ugen: "flock.ugen.lfNoise", 17 | rate: "audio", 18 | options: { 19 | interpolation: "linear" 20 | }, 21 | freq: 1/5, 22 | mul: 0.5, 23 | add: 0.5 24 | }, 25 | minDuration: { 26 | ugen: "flock.ugen.lfNoise", 27 | freq: 1/5, 28 | mul: 0.5, 29 | add: 0.001 30 | }, 31 | gap: -0.001, 32 | buffer: { 33 | url: "../shared/audio/where-the-honey-is.mp3" 34 | }, 35 | 36 | mul: 0.1, 37 | 38 | options: { 39 | maxVoices: 10 40 | } 41 | } 42 | }); 43 | -------------------------------------------------------------------------------- /demos/playground/demos/custom-envelope.js: -------------------------------------------------------------------------------- 1 | var customEnvelope = { 2 | levels: [0, 1, 0.4, 1.0, 0.6, 0], 3 | times: [0.5, 0.3, 0.5, 0.3, 0.5], 4 | curve: ["sin", "exponential", "linear", "welsh", 3] 5 | }; 6 | 7 | var gateDef = { 8 | ugen: "flock.ugen.lfPulse", 9 | rate: "control", 10 | freq: 0.39, 11 | width: 0.5 12 | }; 13 | 14 | flock.synth({ 15 | synthDef: { 16 | ugen: "flock.ugen.sinOsc", 17 | freq: 270, 18 | phase: { 19 | ugen: "flock.ugen.sinOsc", 20 | freq: { 21 | ugen: "flock.ugen.envGen", 22 | rate: "control", 23 | envelope: customEnvelope, 24 | mul: 473, 25 | gate: gateDef 26 | } 27 | }, 28 | mul: { 29 | ugen: "flock.ugen.envGen", 30 | rate: "control", 31 | envelope: customEnvelope, 32 | mul: 0.5, 33 | gate: gateDef 34 | } 35 | } 36 | }); 37 | -------------------------------------------------------------------------------- /demos/playground/demos/decay.js: -------------------------------------------------------------------------------- 1 | // The decay unit generator enveloping white noise, 2 | // creating percussive sounds. 3 | 4 | flock.synth({ 5 | synthDef: { 6 | ugen: "flock.ugen.decay", 7 | source: { 8 | ugen: "flock.ugen.impulse", 9 | rate: "audio", 10 | freq: { 11 | ugen: "flock.ugen.xLine", 12 | rate: "control", 13 | start: 1, 14 | end: 50, 15 | duration: 20 16 | }, 17 | phase: 0.25, 18 | mul: 0.25 19 | }, 20 | time: 0.2, 21 | mul: { 22 | ugen: "flock.ugen.whiteNoise" 23 | } 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /demos/playground/demos/declarative-scheduling.js: -------------------------------------------------------------------------------- 1 | // Schedules an increase in frequency every second. 2 | flock.band({ 3 | components: { 4 | sinSynth: { 5 | type: "flock.synth", 6 | options: { 7 | synthDef: { 8 | id: "carrier", 9 | ugen: "flock.ugen.sinOsc", 10 | freq: 220, 11 | mul: { 12 | ugen: "flock.ugen.line", 13 | start: 0, 14 | end: 0.25, 15 | duration: 1.0 16 | } 17 | } 18 | } 19 | }, 20 | 21 | scheduler: { 22 | type: "flock.scheduler.async", 23 | options: { 24 | components: { 25 | synthContext: "{sinSynth}" 26 | }, 27 | 28 | score: [ 29 | { 30 | interval: "repeat", 31 | time: 1.0, 32 | change: { 33 | values: { 34 | "carrier.freq": { 35 | synthDef: { 36 | ugen: "flock.ugen.sequence", 37 | values: [330, 440, 550, 660, 880, 990, 1100, 1210] 38 | } 39 | } 40 | } 41 | } 42 | }, 43 | 44 | { 45 | interval: "once", 46 | time: 8, 47 | change: { 48 | values: { 49 | "carrier.mul.start": 0.25, 50 | "carrier.mul.end": 0.0, 51 | "carrier.mul.duration": 1.0 52 | } 53 | } 54 | } 55 | ] 56 | } 57 | } 58 | } 59 | }); 60 | -------------------------------------------------------------------------------- /demos/playground/demos/dejong-distortion.js: -------------------------------------------------------------------------------- 1 | flock.synth({ 2 | synthDef: { 3 | ugen: "flock.ugen.distortion.deJong", 4 | amount: { 5 | ugen: "flock.ugen.sin", 6 | mul: 99, 7 | add: 100, 8 | freq: 0.1 9 | }, 10 | source: { 11 | ugen: "flock.ugen.sawOsc", 12 | freq: 45, 13 | mul: 0.01 14 | } 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /demos/playground/demos/delay.js: -------------------------------------------------------------------------------- 1 | // Use Dust to trigger the Delay unit generator 2 | // as an envelope for a Decaying WhiteNoise source 3 | 4 | flock.synth({ 5 | synthDef: { 6 | ugen: "flock.ugen.delay", 7 | source: { 8 | ugen: "flock.ugen.decay", 9 | source: { 10 | ugen: "flock.ugen.dust", 11 | density: 1.0, 12 | mul: 0.5 13 | }, 14 | time: 0.3, 15 | mul: { 16 | ugen: "flock.ugen.whiteNoise" 17 | } 18 | }, 19 | maxTime: 1.0, 20 | time: 0.2, 21 | add: { 22 | ugen: "flock.ugen.decay", 23 | source: { 24 | ugen: "flock.ugen.dust", 25 | density: 1.0, 26 | mul: 0.5 27 | }, 28 | time: 0.3, 29 | mul: { 30 | ugen: "flock.ugen.whiteNoise" 31 | } 32 | } 33 | } 34 | }); 35 | -------------------------------------------------------------------------------- /demos/playground/demos/dust.js: -------------------------------------------------------------------------------- 1 | // Using dust to generate random audio noise. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.dust", 6 | density: 200, 7 | mul: 0.25 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /demos/playground/demos/fm.js: -------------------------------------------------------------------------------- 1 | flock.synth({ 2 | synthDef: { 3 | ugen: "flock.ugen.sin", 4 | freq: { 5 | ugen: "flock.ugen.value", 6 | rate: "audio", 7 | value: 400, 8 | add: { 9 | ugen: "flock.ugen.sin", 10 | freq: { 11 | ugen: "flock.ugen.mouse.cursor", 12 | mul: 124, 13 | add: 62, 14 | }, 15 | mul: { 16 | ugen: "flock.ugen.mouse.cursor", 17 | mul: 100, 18 | add: 100, 19 | options: { 20 | axis: "y" 21 | } 22 | } 23 | } 24 | }, 25 | mul: 0.3 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /demos/playground/demos/for-ann-rising.js: -------------------------------------------------------------------------------- 1 | // James Tenney's For Ann Rising. 2 | 3 | var sked = flock.environment.asyncScheduler, 4 | numSynths = 240, 5 | synths = [], 6 | nextSynthIdx = 0, 7 | synthToRemoveIdx = 0; 8 | 9 | var forAnnSynthDef = { 10 | ugen: "flock.ugen.sinOsc", 11 | freq: { 12 | ugen: "flock.ugen.envGen", 13 | envelope: { 14 | levels: [40, 10240], 15 | times: [33.6], 16 | curve: "exponential" 17 | }, 18 | gate: 1.0 19 | }, 20 | mul: { 21 | ugen: "flock.ugen.envGen", 22 | envelope: { 23 | type: "flock.envelope.linear", 24 | attack: 8.4, 25 | sustain: 16.8, 26 | release: 8.4 27 | }, 28 | gate: 1.0, 29 | mul: 0.1 30 | } 31 | }; 32 | 33 | // To save cycles during performance, 34 | // create all the voices ahead of time. 35 | for (var i = 0; i < numSynths; i++) { 36 | var synth = flock.synth({ 37 | synthDef: forAnnSynthDef, 38 | addToEnvironment: false 39 | }); 40 | 41 | synths[i] = synth; 42 | } 43 | 44 | // Use the scheduler to start a new synth playing 45 | // every 2.8 seconds. 46 | var adder = sked.repeat(2.8, function () { 47 | var synth = synths[nextSynthIdx]; 48 | synth.addToEnvironment("tail"); 49 | 50 | nextSynthIdx++; 51 | if (nextSynthIdx >= numSynths) { 52 | sked.clear(adder); 53 | } 54 | }); 55 | 56 | // Remove each synth after its envelope has reached its target. 57 | // (Flocking doesn't yet have "done actions" like in SuperCollider). 58 | sked.repeat(34, function () { 59 | var synth = synths[synthToRemoveIdx]; 60 | 61 | // Destroying a synth will remove it from the environment as well, 62 | // but means that it can't be reused later. 63 | synth.destroy(); 64 | 65 | synthToRemoveIdx++; 66 | if (synthToRemoveIdx >= numSynths) { 67 | sked.clearAll(); 68 | } 69 | }); 70 | -------------------------------------------------------------------------------- /demos/playground/demos/glissando.js: -------------------------------------------------------------------------------- 1 | // An descending glissando using a line ugen. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.sinOsc", 6 | freq: { 7 | ugen: "flock.ugen.xLine", 8 | rate: "control", 9 | duration: 1.0, 10 | start: 2000, 11 | end: 200 12 | }, 13 | mul: 0.25 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /demos/playground/demos/granulator.js: -------------------------------------------------------------------------------- 1 | // Granulates a filtered sawtooth wave. 2 | // Demo by Mayank Sanganeria and Adam Tindale. 3 | 4 | flock.synth({ 5 | synthDef: { 6 | ugen: "flock.ugen.granulator", 7 | numGrains: { 8 | ugen: "flock.ugen.line", 9 | start: 1, 10 | end: 40, 11 | duration: 20 12 | }, 13 | grainDur: { 14 | ugen: "flock.ugen.line", 15 | start: 0.1, 16 | end: 0.005, 17 | duration: 100 18 | }, 19 | delayDur: 8, 20 | mul: 0.5, 21 | source: { 22 | ugen: "flock.ugen.filter.biquad.lp", 23 | freq: { 24 | ugen: "flock.ugen.sin", 25 | rate: "control", 26 | freq: { 27 | ugen: "flock.ugen.xLine", 28 | rate: "control", 29 | start: 0.7, 30 | end: 3000, 31 | duration: 60 32 | }, 33 | phase: 0, 34 | mul: 2000, 35 | add: 4000 36 | }, 37 | source: { 38 | ugen: "flock.ugen.lfSaw", 39 | freq: { 40 | ugen: "flock.ugen.sin", 41 | freq: 0.1, 42 | mul: 1000, 43 | add: 3000, 44 | }, 45 | mul: 0.25 46 | } 47 | } 48 | } 49 | }); 50 | -------------------------------------------------------------------------------- /demos/playground/demos/highpass-filter.js: -------------------------------------------------------------------------------- 1 | flock.synth({ 2 | synthDef: { 3 | ugen: "flock.ugen.filter.biquad.hp", 4 | freq: { 5 | ugen: "flock.ugen.sin", 6 | rate: "control", 7 | freq: { 8 | ugen: "flock.ugen.xLine", 9 | rate: "control", 10 | start: 0.7, 11 | end: 300, 12 | duration: 20 13 | }, 14 | phase: 0, 15 | mul: 3600, 16 | add: 4000 17 | }, 18 | source: { 19 | ugen: "flock.ugen.lfSaw", 20 | freq: 200, 21 | mul: 0.1 22 | } 23 | } 24 | }); 25 | -------------------------------------------------------------------------------- /demos/playground/demos/impulse-pm.js: -------------------------------------------------------------------------------- 1 | // A stereo pair of Impulses, one being phase modulated with the mouse cursor. 2 | 3 | flock.synth({ 4 | synthDef: [ 5 | { 6 | ugen: "flock.ugen.impulse", 7 | freq: 4, 8 | mul: 0.3, 9 | phase: 0 10 | }, 11 | { 12 | ugen: "flock.ugen.impulse", 13 | freq: 4, 14 | mul: 0.3, 15 | phase: { 16 | ugen: "flock.ugen.mouse.cursor" 17 | } 18 | } 19 | ] 20 | }); 21 | -------------------------------------------------------------------------------- /demos/playground/demos/impulse.js: -------------------------------------------------------------------------------- 1 | // The impulse ugen's frequency controlled by a descending xLine. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.impulse", 6 | freq: { 7 | ugen: "flock.ugen.xLine", 8 | start: 880, 9 | end: 2, 10 | duration: 3.0 11 | }, 12 | mul: 0.25 13 | } 14 | }); 15 | -------------------------------------------------------------------------------- /demos/playground/demos/latch.js: -------------------------------------------------------------------------------- 1 | /* 2 | David Michael Cottle's first Latch example from http://rhoadley.net/courses/tech_resources/supercollider/tutorials/cottle/CMSC7105.pdf 3 | 4 | "The patterns that emerge are more varied than a single sequence, 5 | but more cohesive than an LFNoise control. 6 | Try the example below and listen for the shape of the Saw wave in the frequencies. 7 | In this patch I change the frequency of the wave being sampled. 8 | I use a MouseX.kr to control the frequency of the sampled LFSaw. 9 | It begins at 0.1, or once every ten seconds and then moves to 20. 10 | When the mouse is at the left of the screen you should hear the shape 11 | of the wave in the resulting frequency control. 12 | As you move to the right, you are essentially shortening the sampled wave 13 | in relation to the sample rate, and the smooth ramp will begin to disappear, 14 | but there will always be a pattern" (Cottle 168). 15 | */ 16 | 17 | flock.synth({ 18 | synthDef: { 19 | ugen: "flock.ugen.sin", 20 | mul: 0.3, 21 | freq: { 22 | ugen: "flock.ugen.latch", 23 | rate: "control", 24 | source: { 25 | ugen: "flock.ugen.lfSaw", 26 | freq: { 27 | ugen: "flock.ugen.mouse.cursor", 28 | rate: "control", 29 | mul: 18.9, 30 | add: 1.1 31 | }, 32 | mul: 500, 33 | add: 600 34 | }, 35 | trigger: { 36 | ugen: "flock.ugen.impulse", 37 | rate: "control", 38 | freq: 10 39 | } 40 | } 41 | } 42 | }); 43 | -------------------------------------------------------------------------------- /demos/playground/demos/lfNoise.js: -------------------------------------------------------------------------------- 1 | // Random audio noise with lfNoise. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.lfNoise", 6 | freq: 1000, 7 | mul: 0.25 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /demos/playground/demos/line-fm.js: -------------------------------------------------------------------------------- 1 | // Frequency modulation controlled by an exponential line. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.sinOsc", 6 | freq: { 7 | ugen: "flock.ugen.sinOsc", 8 | freq: { 9 | ugen: "flock.ugen.xLine", 10 | rate: "control", 11 | start: 1, 12 | end: 1000, 13 | duration: 9 14 | }, 15 | mul: 200, 16 | add: 800 17 | }, 18 | mul: 0.25 19 | } 20 | }); 21 | -------------------------------------------------------------------------------- /demos/playground/demos/line-pm.js: -------------------------------------------------------------------------------- 1 | // Line modulating the phase of a sine oscillator. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.sinOsc", 6 | freq: 800, 7 | phase: { 8 | ugen: "flock.ugen.sinOsc", 9 | freq: { 10 | ugen: "flock.ugen.xLine", 11 | rate: "control", 12 | start: 1, 13 | end: 1000, 14 | duration: 9 15 | }, 16 | mul: flock.TWOPI 17 | }, 18 | mul: 0.25 19 | } 20 | }); 21 | -------------------------------------------------------------------------------- /demos/playground/demos/lowpass-filter.js: -------------------------------------------------------------------------------- 1 | flock.synth({ 2 | synthDef: { 3 | ugen: "flock.ugen.filter.biquad.lp", 4 | freq: { 5 | ugen: "flock.ugen.sin", 6 | rate: "control", 7 | freq: { 8 | ugen: "flock.ugen.xLine", 9 | rate: "control", 10 | start: 0.7, 11 | end: 300, 12 | duration: 20 13 | }, 14 | phase: 0, 15 | mul: 3600, 16 | add: 4000 17 | }, 18 | source: { 19 | ugen: "flock.ugen.lfSaw", 20 | freq: 200, 21 | mul: 0.1 22 | } 23 | } 24 | }); 25 | -------------------------------------------------------------------------------- /demos/playground/demos/moog.js: -------------------------------------------------------------------------------- 1 | // A 24db low pass moog-style filter. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.filter.moog", 6 | cutoff: { 7 | ugen: "flock.ugen.sinOsc", 8 | freq: 1/4, 9 | mul: 5000, 10 | add: 7000 11 | }, 12 | resonance: { 13 | ugen: "flock.ugen.sinOsc", 14 | freq: 1/2, 15 | mul: 1.5, 16 | add: 1.5 17 | }, 18 | source: { 19 | ugen: "flock.ugen.lfSaw", 20 | freq: { 21 | ugen: "flock.ugen.sequence", 22 | freq: 1/2, 23 | loop: 1, 24 | values: [220, 220 * 5/4, 220, 220 * 3/2, 220 * 4/3, 220], 25 | options: { 26 | interpolation: "linear" 27 | } 28 | } 29 | }, 30 | mul: 0.5 31 | } 32 | }); 33 | -------------------------------------------------------------------------------- /demos/playground/demos/mouse-click.js: -------------------------------------------------------------------------------- 1 | // Triggers a note whenever the mouse is clicked. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.sinOsc", 6 | freq: 440, 7 | mul: { 8 | ugen: "flock.ugen.asr", 9 | attack: 0.25, 10 | sustain: 0.25, 11 | release: 0.5, 12 | gate: { 13 | ugen: "flock.ugen.mouse.click" 14 | } 15 | } 16 | } 17 | }); 18 | -------------------------------------------------------------------------------- /demos/playground/demos/mouse-x.js: -------------------------------------------------------------------------------- 1 | // Tracks the mouse's horizonal movement across the window. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.sinOsc", 6 | freq: { 7 | ugen: "flock.ugen.mouse.cursor", 8 | rate: "control", 9 | mul: 880, 10 | add: 110 11 | }, 12 | mul: 0.25 13 | } 14 | }); 15 | -------------------------------------------------------------------------------- /demos/playground/demos/mouse-xy.js: -------------------------------------------------------------------------------- 1 | // Tracks the mouse's vertical and horizontal movement within the editor area only. 2 | // Maps y position to amplitude and its x position to pitch. 3 | 4 | flock.synth({ 5 | synthDef: { 6 | ugen: "flock.ugen.sinOsc", 7 | freq: { 8 | ugen: "flock.ugen.mouse.cursor", 9 | rate: "control", 10 | mul: 880, 11 | add: 110, 12 | options: { 13 | axis: "width", 14 | interpolation: "exponential", 15 | target: ".CodeMirror" 16 | } 17 | }, 18 | mul: { 19 | ugen: "flock.ugen.mouse.cursor", 20 | rate: "control", 21 | options: { 22 | axis: "height", 23 | target: ".CodeMirror" 24 | }, 25 | mul: 0.5 26 | } 27 | } 28 | }); 29 | -------------------------------------------------------------------------------- /demos/playground/demos/mouse-y.js: -------------------------------------------------------------------------------- 1 | // Tracks the mouse's vertical movement across the window. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.sinOsc", 6 | freq: { 7 | ugen: "flock.ugen.mouse.cursor", 8 | rate: "control", 9 | mul: 880, 10 | add: 110, 11 | options: { 12 | axis: "y" 13 | } 14 | }, 15 | mul: 0.25 16 | } 17 | }); 18 | -------------------------------------------------------------------------------- /demos/playground/demos/multiple-synths.js: -------------------------------------------------------------------------------- 1 | /*global flock, $*/ 2 | 3 | /* 4 | * Multiple synths playing back simultaneously, playing shifting chords. 5 | */ 6 | 7 | // Creates an array of synths, each playing a degree of the chord specified in "intervals." 8 | function makeIntervallicSynths (fundamental, intervals) { 9 | var ampScale = 0.4 / intervals.length; 10 | return $.map(intervals, function (interval) { 11 | return flock.synth({ 12 | synthDef: { 13 | id: "carrier", 14 | ugen: "flock.ugen.sin", 15 | freq: fundamental * interval, 16 | mul: ampScale 17 | } 18 | }); 19 | }); 20 | } 21 | 22 | var fundamental = 440, 23 | baseIntervals = [1/1, 5/4, 3/2], 24 | weightedIntervals = baseIntervals.concat([4/3, 6/5, 7/6, 2/1]).concat(baseIntervals), 25 | synths = makeIntervallicSynths(fundamental, baseIntervals), 26 | clock = flock.scheduler.async.tempo({ 27 | bpm: 60 28 | }); 29 | 30 | // Every second, change one of the intervals by randomly choosing a synth 31 | // and assigning it a new frequency from the list of intervals. 32 | clock.repeat(1, function () { 33 | var intervalSynth = flock.choose(synths), 34 | newInterval = flock.choose(weightedIntervals); 35 | intervalSynth.set("carrier.freq", fundamental * newInterval); 36 | }); 37 | -------------------------------------------------------------------------------- /demos/playground/demos/noise-fm.js: -------------------------------------------------------------------------------- 1 | // LFNoise randomly changing the pitch of a sine 2 | // oscillator every quarter second. 3 | 4 | flock.synth({ 5 | synthDef: { 6 | ugen: "flock.ugen.sinOsc", 7 | mul: 0.25, 8 | freq: { 9 | ugen: "flock.ugen.lfNoise", 10 | freq: 4, 11 | mul: 400, 12 | add: 450 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /demos/playground/demos/pinknoise.js: -------------------------------------------------------------------------------- 1 | flock.synth({ 2 | synthDef: { 3 | ugen: "flock.ugen.pinkNoise", 4 | mul: 0.5 5 | } 6 | }); 7 | -------------------------------------------------------------------------------- /demos/playground/demos/play-buffer.js: -------------------------------------------------------------------------------- 1 | // Plays back a sound file in a loop. 2 | // The playback rate is controlled by the mouse cursor's vertical position, 3 | // while the end point in the sound file is determined by the mouse's horizontal position. 4 | 5 | flock.synth({ 6 | synthDef: { 7 | ugen: "flock.ugen.playBuffer", 8 | buffer: { 9 | id: "chord", 10 | url: "../shared/audio/hillier-first-chord.wav" 11 | }, 12 | 13 | speed: { 14 | ugen: "flock.ugen.mouse.cursor", 15 | options: { 16 | axis: "y" 17 | }, 18 | add: 0.5 19 | }, 20 | 21 | loop: 1, 22 | 23 | start: 0, 24 | 25 | end: { 26 | ugen: "flock.ugen.mouse.cursor", 27 | options: { 28 | axis: "x" 29 | } 30 | } 31 | } 32 | }); 33 | -------------------------------------------------------------------------------- /demos/playground/demos/playBuffer-trigger.js: -------------------------------------------------------------------------------- 1 | // Triggers the playback of a sound file from the beginning 2 | // every time the user clicks the mouse. 3 | 4 | flock.synth({ 5 | synthDef: { 6 | ugen: "flock.ugen.playBuffer", 7 | buffer: { 8 | id: "chord", 9 | url: "../shared/audio/hillier-first-chord.wav" 10 | }, 11 | 12 | trigger: { 13 | ugen: "flock.ugen.mouse.click" 14 | } 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /demos/playground/demos/pm.js: -------------------------------------------------------------------------------- 1 | // Phase modulation with sine waves. 2 | // Demo courtesty of Adam Tindale (http://www.adamtindale.com/). 3 | 4 | flock.synth({ 5 | synthDef: { 6 | id: "carrier", 7 | ugen: "flock.ugen.sinOsc", 8 | freq: 440, 9 | phase: { 10 | id: "mod", 11 | ugen: "flock.ugen.sinOsc", 12 | freq: 34.0, 13 | mul: { 14 | ugen: "flock.ugen.sinOsc", 15 | freq: 1/20, 16 | mul: flock.PI 17 | }, 18 | add: flock.PI 19 | }, 20 | mul: 0.25 21 | } 22 | }); 23 | -------------------------------------------------------------------------------- /demos/playground/demos/polyphonicSynth.js: -------------------------------------------------------------------------------- 1 | var fundamental = 440; 2 | 3 | var polySynth = flock.synth.polyphonic({ 4 | synthDef: { 5 | id: "carrier", 6 | ugen: "flock.ugen.sin", 7 | freq: fundamental, 8 | mul: { 9 | id: "env", 10 | ugen: "flock.ugen.asr", 11 | attack: 0.25, 12 | sustain: 1.0, 13 | release: 0.5 14 | } 15 | } 16 | }); 17 | 18 | var score = [ 19 | { 20 | action: "noteOn", 21 | noteName: "root", 22 | change: { 23 | "carrier.freq": fundamental 24 | } 25 | }, 26 | 27 | { 28 | action: "noteOn", 29 | noteName: "mediant", 30 | change: { 31 | "carrier.freq": fundamental * 5/4 32 | } 33 | }, 34 | 35 | { 36 | action: "noteOn", 37 | noteName: "dominant", 38 | change: { 39 | "carrier.freq": fundamental * 3/2 40 | } 41 | }, 42 | 43 | { 44 | action: "noteOff", 45 | noteName: "root" 46 | }, 47 | 48 | { 49 | action: "noteOff", 50 | noteName: "mediant" 51 | }, 52 | 53 | { 54 | action: "noteOff", 55 | noteName: "dominant" 56 | } 57 | ]; 58 | 59 | var idx = 0; 60 | polySynth.enviro.asyncScheduler.repeat(0.5, function () { 61 | if (idx >= score.length) { 62 | idx = 0; 63 | } 64 | var event = score[idx]; 65 | polySynth[event.action](event.noteName, event.change); 66 | idx++; 67 | }); 68 | -------------------------------------------------------------------------------- /demos/playground/demos/readBuffer-phasor.js: -------------------------------------------------------------------------------- 1 | // Plays back a sound file while the user holds down the mouse button. 2 | // If the user lets go of the mouse and clicks it again, playback will resume at its previous location. 3 | // Uses a phasor and the bufferPhaseStep unit generator to play back the sound at its normal rate. 4 | 5 | flock.synth({ 6 | synthDef: { 7 | ugen: "flock.ugen.readBuffer", 8 | buffer: { 9 | id: "chord", 10 | url: "../shared/audio/hillier-first-chord.wav" 11 | }, 12 | phase: { 13 | rate: "audio", 14 | ugen: "flock.ugen.phasor", 15 | step: { 16 | ugen: "flock.ugen.mouse.click", 17 | mul: { 18 | ugen: "flock.ugen.bufferPhaseStep", 19 | buffer: "chord" 20 | } 21 | } 22 | } 23 | } 24 | }); 25 | -------------------------------------------------------------------------------- /demos/playground/demos/readBuffer.js: -------------------------------------------------------------------------------- 1 | // Modulates the playback rate of a sound file with a sine wave oscillator. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.readBuffer", 6 | buffer: { 7 | id: "chord", 8 | url: "../shared/audio/hillier-first-chord.wav" 9 | }, 10 | phase: { 11 | ugen: "flock.ugen.sin", 12 | freq: 1/5, 13 | mul: 0.5, 14 | add: 0.5 15 | } 16 | } 17 | }); 18 | -------------------------------------------------------------------------------- /demos/playground/demos/sample-accurate-scheduling.js: -------------------------------------------------------------------------------- 1 | // Schedules a series of input changes. 2 | // Composition by Colin Clark. 3 | 4 | flock.synth({ 5 | synthDef: { 6 | ugen: "flock.ugen.out", 7 | sources: { 8 | ugen: "flock.ugen.change", 9 | initial: { 10 | ugen: "flock.ugen.sin", 11 | freq: { 12 | ugen: "flock.ugen.xLine", 13 | start: 211, 14 | end: 200, 15 | duration: 1 16 | } 17 | }, 18 | target: { 19 | ugen: "flock.ugen.change", 20 | initial: { 21 | ugen: "flock.ugen.lfSaw", 22 | freq: { 23 | ugen: "flock.ugen.xLine", 24 | start: 200, 25 | end: 90, 26 | duration: 30 27 | }, 28 | mul: 1.0 29 | }, 30 | target: { 31 | ugen: "flock.ugen.change", 32 | initial: { 33 | ugen: "flock.ugen.sin", 34 | freq: { 35 | ugen: "flock.ugen.xLine", 36 | start: 200, 37 | end: 211, 38 | duration: 30 39 | } 40 | }, 41 | target: { 42 | ugen: "flock.ugen.sin", 43 | freq: { 44 | ugen: "flock.ugen.change", 45 | initial: { 46 | ugen: "flock.ugen.sin", 47 | freq: 200, 48 | mul: 111 49 | }, 50 | target: { 51 | ugen: "flock.ugen.xLine", 52 | start: 200, 53 | end: 211, 54 | duration: 45 55 | }, 56 | time: 35, 57 | crossfade: 10 58 | }, 59 | mul: { 60 | ugen: "flock.ugen.line", 61 | start: 1.0, 62 | end: 0.0, 63 | duration: 47.5 64 | } 65 | }, 66 | time: 25, 67 | crossfade: 20 68 | } 69 | }, 70 | time: 2.0, 71 | crossfade: 15.0 72 | } 73 | } 74 | }); 75 | -------------------------------------------------------------------------------- /demos/playground/demos/saw.js: -------------------------------------------------------------------------------- 1 | // A band-limited saw oscillator. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.saw", 6 | freq: 440, 7 | mul: 0.25 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /demos/playground/demos/scope.js: -------------------------------------------------------------------------------- 1 | // Visually displays the synth's output with an oscilliscope. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.scope", 6 | source: { 7 | ugen: "flock.ugen.sinOsc", 8 | freq: 440, 9 | mul: 0.25 10 | }, 11 | options: { 12 | canvas: "#gfx", 13 | styles: { 14 | strokeColor: "#777777", 15 | strokeWidth: 2 16 | } 17 | } 18 | } 19 | }); 20 | -------------------------------------------------------------------------------- /demos/playground/demos/sequencer.js: -------------------------------------------------------------------------------- 1 | flock.synth({ 2 | synthDef: { 3 | ugen: "flock.ugen.sin", 4 | freq: { 5 | ugen: "flock.ugen.sequencer", 6 | durations: [0.25, 0.25, 0.16666667, 0.16666667, 0.33, 0.25, 0.25], 7 | values: [1, 9/8, 4/3, 3/2, 4/3, 5/4, 1], 8 | mul: 440, 9 | loop: 1.0, 10 | options: { 11 | holdLastValue: true 12 | } 13 | }, 14 | mul: { 15 | ugen: "flock.ugen.envGen", 16 | envelope: { 17 | levels: [0, 1, 0], 18 | times: [0.03, 0.2] 19 | }, 20 | gate: { 21 | ugen: "flock.ugen.sequencer", 22 | durations: [0.25, 0.25, 0.16666667, 0.16666667, 0.33, 0.25, 0.25], 23 | values: [1, 1, 1, 1, 1, 1, 1], 24 | loop: 1.0, 25 | options: { 26 | resetOnNext: true 27 | } 28 | } 29 | } 30 | } 31 | }); 32 | -------------------------------------------------------------------------------- /demos/playground/demos/sine.js: -------------------------------------------------------------------------------- 1 | // A table-lookup sine wave oscillator. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.sinOsc", 6 | freq: 440, 7 | mul: 0.25 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /demos/playground/demos/square.js: -------------------------------------------------------------------------------- 1 | // A band-limited square wave oscillator. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.square", 6 | freq: 440, 7 | mul: 0.25 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /demos/playground/demos/stereo.js: -------------------------------------------------------------------------------- 1 | // Two different channels: both are sine waves with slightly different frequencies. 2 | 3 | flock.synth({ 4 | synthDef: [ 5 | { 6 | id: "leftSine", 7 | ugen: "flock.ugen.sinOsc", 8 | freq: 440, 9 | mul: 0.25 10 | }, 11 | { 12 | id: "rightSine", 13 | ugen: "flock.ugen.sinOsc", 14 | freq: 444, 15 | mul: 0.25 16 | } 17 | ] 18 | }); 19 | -------------------------------------------------------------------------------- /demos/playground/demos/sum.js: -------------------------------------------------------------------------------- 1 | /*global flock*/ 2 | 3 | // Adds together a bank of sine oscillators to make 4 | // a rudimentary clarinet tone with additive synthesis. 5 | 6 | var fundamental = 440, 7 | harmonics = [1, 3, 5, 7, 9, 13, 15], // Clarinets only have odd partials. 8 | baseHarmonicDef = { 9 | ugen: "flock.ugen.saw", 10 | freq: 440, 11 | mul: { 12 | ugen: "flock.ugen.envGen", 13 | envelope: { 14 | type: "flock.envelope.adsr", 15 | attack: 0.1, 16 | decay: 0.05, 17 | sustain: 0.75, 18 | release: 0.2 19 | }, 20 | gate: { 21 | id: "gate", 22 | ugen: "flock.ugen.inputChangeTrigger", 23 | source: 1.0, 24 | duration: 0.8 25 | }, 26 | mul: 1.0 27 | } 28 | }; 29 | 30 | function expandHarmonics(fundamental, harmonics) { 31 | return fluid.transform(harmonics, function (harmonic, i) { 32 | var partialNum = i + 1; 33 | 34 | // Merge together the base ugenDef for all harmonics 35 | // with the parameters for this specific harmonic. 36 | return $.extend(true, {}, baseHarmonicDef, { 37 | freq: fundamental * harmonic, 38 | mul: { 39 | // Amplitude for a clarient should be the 40 | // inverse of the partial number. Then we scale 41 | // the amplitude for the number of partials 42 | // so that we don't clip. 43 | mul: (1 / partialNum) / harmonics.length 44 | } 45 | }); 46 | }); 47 | } 48 | 49 | function updateHarmonics(fundamental, harmonics, ugens) { 50 | fluid.each(harmonics, function (harmonic, i) { 51 | var ugen = ugens[i], 52 | freq = fundamental * harmonic; 53 | 54 | ugen.set({ 55 | "freq": freq, 56 | "mul.gate.source": 1.0 57 | }); 58 | }); 59 | } 60 | 61 | var synth = flock.synth({ 62 | synthDef: { 63 | ugen: "flock.ugen.filter.biquad.bp", 64 | freq: 500, 65 | q: 3.0, 66 | source: { 67 | id: "sum", 68 | ugen: "flock.ugen.sum", 69 | sources: expandHarmonics(fundamental, harmonics) 70 | } 71 | } 72 | }); 73 | 74 | synth.enviro.asyncScheduler.repeat(1.0, function () { 75 | var fundamental = Math.random() * 1000 + 100; 76 | updateHarmonics(fundamental, harmonics, synth.get("sum.sources")); 77 | }); 78 | -------------------------------------------------------------------------------- /demos/playground/demos/tanh-distortion.js: -------------------------------------------------------------------------------- 1 | flock.synth({ 2 | synthDef: { 3 | ugen: "flock.ugen.sum", 4 | sources: [ 5 | { 6 | ugen: "flock.ugen.distortion.tanh", 7 | source: { 8 | ugen: "flock.ugen.sinOsc", 9 | freq: 500, 10 | mul: { 11 | ugen: "flock.ugen.asr", 12 | attack: 0.1, 13 | sustain: 0.1, 14 | release: 0.1, 15 | mul: 2, 16 | gate: { 17 | ugen: "flock.ugen.impulse", 18 | rate: "control", 19 | freq: 0.7, 20 | phase: 0 21 | } 22 | } 23 | } 24 | }, 25 | { 26 | ugen: "flock.ugen.sinOsc", 27 | freq: 600, 28 | mul: { 29 | ugen: "flock.ugen.asr", 30 | attack: 0.1, 31 | sustain: 0.1, 32 | release: 0.1, 33 | mul: 2, 34 | gate: { 35 | ugen: "flock.ugen.impulse", 36 | rate: "control", 37 | freq: 0.7, 38 | phase: 0.5 39 | } 40 | } 41 | } 42 | ] 43 | } 44 | }); 45 | -------------------------------------------------------------------------------- /demos/playground/demos/tarrabia-dejong-distortion.js: -------------------------------------------------------------------------------- 1 | // Frequency-modulated saw wave by ring-modulated square wave through modulated distortion 2 | flock.synth({ 3 | synthDef: { 4 | ugen: "flock.ugen.distortion.tarrabiaDeJong", 5 | amount: { 6 | ugen: "flock.ugen.sin", 7 | rate: "control", 8 | freq: 0.25 9 | }, 10 | source: { 11 | ugen: "flock.ugen.saw", 12 | freq: { 13 | ugen: "flock.ugen.square", 14 | mul: { 15 | ugen: "flock.ugen.sin", 16 | mul: 30, 17 | freq: 2 18 | }, 19 | add: 100 20 | } 21 | } 22 | } 23 | }); 24 | -------------------------------------------------------------------------------- /demos/playground/demos/tri.js: -------------------------------------------------------------------------------- 1 | // A band-limited triangle oscillator. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.tri", 6 | freq: 440, 7 | mul: 0.25 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /demos/playground/demos/trigger-callback.js: -------------------------------------------------------------------------------- 1 | // Periodically trigger a function that causes the scope area to shake. 2 | 3 | flock.synth({ 4 | synthDef: { 5 | ugen: "flock.ugen.triggerCallback", 6 | trigger: { 7 | ugen: "flock.ugen.impulse", 8 | freq: 0.75, 9 | phase: 0.5 10 | }, 11 | options: { 12 | callback: { 13 | func: function () { 14 | $("#gfx").toggleClass("shake"); 15 | } 16 | } 17 | } 18 | } 19 | }); 20 | -------------------------------------------------------------------------------- /demos/playground/demos/whitenoise.js: -------------------------------------------------------------------------------- 1 | // Filters white noise with a bandpass filter 2 | // controlled by the mouse's horizontal position. 3 | 4 | flock.synth({ 5 | synthDef: { 6 | ugen: "flock.ugen.filter.biquad.bp", 7 | source: { 8 | ugen: "flock.ugen.whiteNoise", 9 | mul: 0.5 10 | }, 11 | freq: { 12 | ugen: "flock.ugen.mouse.cursor", 13 | mul: 1660, 14 | add: 40, 15 | options: { 16 | interoplation: "exponential" 17 | } 18 | }, 19 | q: 2.0 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /demos/playground/js/error-console.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Flocking Playground Error Console 3 | * Copyright 2018, Colin Clark 4 | * 5 | * Dual licensed under the MIT and GPL Version 2 licenses. 6 | */ 7 | 8 | /*global require*/ 9 | 10 | var fluid = fluid || require("infusion"), 11 | flock = fluid.registerNamespace("flock"); 12 | 13 | (function () { 14 | "use strict"; 15 | 16 | fluid.defaults("flock.playground.errorConsole", { 17 | gradeNames: "fluid.viewComponent", 18 | 19 | invokers: { 20 | clearErrors: { 21 | "this": "{that}.container", 22 | method: "empty" 23 | } 24 | }, 25 | 26 | events: { 27 | onEvaluationError: "{sourceEvaluator}.events.onEvaluationError", 28 | afterEvaluated: "{sourceEvaluator}.events.afterEvaluated" 29 | }, 30 | 31 | listeners: { 32 | "afterEvaluated.clearErrors": "{that}.clearErrors()", 33 | 34 | "onEvaluationError.clearErrors": "{that}.clearErrors()", 35 | 36 | "onEvaluationError.renderError": { 37 | priority: "after:clearErrors", 38 | funcName: "flock.playground.errorConsole.renderError", 39 | args: ["{arguments}.0", "{that}"] 40 | } 41 | }, 42 | 43 | markup: { 44 | err: "%name: %message" 45 | } 46 | }); 47 | 48 | flock.playground.errorConsole.renderError = function (e, that) { 49 | var renderedHTML = fluid.stringTemplate(that.options.markup.err, { 50 | name: e.name, 51 | message: e.message 52 | }); 53 | that.container.append(renderedHTML); 54 | }; 55 | }()); 56 | -------------------------------------------------------------------------------- /demos/playground/live/css/live-playground.css: -------------------------------------------------------------------------------- 1 | .mainPanel.split-large { 2 | width: 60%; 3 | } 4 | 5 | .mainPanel.split-small { 6 | width: 40%; 7 | } 8 | 9 | #source-view { 10 | border-right: 0px; 11 | height: 95%; 12 | border-bottom: 1px solid #aaa; 13 | } 14 | 15 | .CodeMirror { 16 | height: 100%; 17 | border-bottom: 0px; 18 | } 19 | 20 | #visual-view { 21 | color: #fff; 22 | overflow: auto; 23 | position: relative; 24 | float: right; 25 | height: 95%; 26 | border-bottom: 1px solid #aaa; 27 | } 28 | 29 | .node { 30 | width: 6em; 31 | height: 1em; 32 | background-color: #999; 33 | color: #fff; 34 | border-radius: 0.5em; 35 | border: 0.1em solid #999; 36 | padding-bottom: 2.2em; 37 | padding-top: 1.5em; 38 | text-align: center; 39 | letter-spacing: 0.1em; 40 | z-index: 1; 41 | font-size: 0.75em; 42 | } 43 | 44 | .node.flock\.ugen\.value { 45 | width: 5em; 46 | height: 1em; 47 | font-family: monospace; 48 | font-weight: normal; 49 | background-color: #272822; 50 | font-size: 0.75em; 51 | border: 0.2em solid #999; 52 | overflow: hidden; 53 | } 54 | 55 | .node.flock\.buffer { 56 | width: 6em; 57 | font-family: monospace; 58 | font-weight: normal; 59 | background-color: #272822; 60 | border: 0.2em solid #999; 61 | overflow: hidden; 62 | } 63 | 64 | .node.flock\.list { 65 | font-family: monospace; 66 | font-weight: normal; 67 | background-color: #272822; 68 | font-size: 0.75em; 69 | } 70 | 71 | .node.flock\.envelope { 72 | width: 6em; 73 | font-family: monospace; 74 | font-weight: normal; 75 | background-color: #272822; 76 | } 77 | 78 | ._jsPlumb_overlay { 79 | border-radius: 0.5em; 80 | background-color: rgba(68, 85, 102, 1); 81 | color: #fff; 82 | padding: 0.5em 0.5em; 83 | font-size: 0.75em; 84 | z-index: 2; 85 | letter-spacing: 0.1em; 86 | } 87 | 88 | ._jsPlumb_endpoint { 89 | z-index: 1; 90 | } 91 | 92 | ._jsPlumb_endpoint circle { 93 | fill: #272822; 94 | z-index: 1; 95 | stroke: #999; 96 | } 97 | -------------------------------------------------------------------------------- /demos/playground/live/demos/am.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Creates a new synth consisting of a sine wave whose amplitude is slowly moduled by another sine wave.", 3 | "synthDef": { 4 | "id": "carrier", 5 | "ugen": "flock.ugen.sinOsc", 6 | "freq": 440, 7 | "mul": { 8 | "id": "mod", 9 | "ugen": "flock.ugen.sinOsc", 10 | "freq": 1.0, 11 | "mul": 0.25 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /demos/playground/live/demos/asr.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Sine tone shaped by a periodically triggered attack/sustain/release envelope.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.sinOsc", 5 | "freq": 440, 6 | "mul": { 7 | "ugen": "flock.ugen.asr", 8 | "start": 0.0, 9 | "attack": 0.25, 10 | "sustain": 0.25, 11 | "release": 1.0, 12 | "gate": { 13 | "ugen": "flock.ugen.impulse", 14 | "rate": "control", 15 | "freq": 0.75, 16 | "phase": 1.0 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /demos/playground/live/demos/audio-in-granulated.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Granulates live audio from the microphone. Wear headphones to prevent feedback.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.granulator", 5 | "delayDur": 0.25, 6 | "numGrains": { 7 | "ugen": "flock.ugen.lfNoise", 8 | "freq": 0.5, 9 | "mul": 75, 10 | "add": 75, 11 | "options": { 12 | "interpolation": "linear" 13 | } 14 | }, 15 | "source": { 16 | "ugen": "flock.ugen.audioIn" 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /demos/playground/live/demos/audio-in.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Plays back live audio from the microphone. Wear headphones to prevent feedback.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.audioIn" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /demos/playground/live/demos/band.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "flock.band", 3 | "options": { 4 | "components": { 5 | "left": { 6 | "type": "flock.synth", 7 | "options": { 8 | "synthDef": { 9 | "ugen": "flock.ugen.out", 10 | "bus": 0, 11 | "expand": 1, 12 | "sources": [ 13 | { 14 | "ugen": "flock.ugen.sinOsc", 15 | "freq": { 16 | "ugen": "flock.ugen.sequence", 17 | "values": [1, 1.333333, 1.25], 18 | "loop": 1, 19 | "freq": 3, 20 | "mul": 440 21 | }, 22 | "mul": 0.5 23 | } 24 | ] 25 | } 26 | } 27 | }, 28 | "right": { 29 | "type": "flock.synth", 30 | "options": { 31 | "synthDef": { 32 | "ugen": "flock.ugen.out", 33 | "bus": 1, 34 | "expand": 1, 35 | "sources": [ 36 | { 37 | "ugen": "flock.ugen.sinOsc", 38 | "freq": { 39 | "ugen": "flock.ugen.sequence", 40 | "values": [1, 1.5], 41 | "loop": 1, 42 | "freq": 2, 43 | "mul": 220 44 | }, 45 | "mul": 0.5 46 | } 47 | ] 48 | } 49 | } 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /demos/playground/live/demos/bandlimited-impulse.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Comparison between regular and band-limited impulse generators. The left channel aliases at high frequencies (you'll hear it wobble). The right channel is band-limited, and thus smooth throughout the spectrum.", 3 | "synthDef": [ 4 | { 5 | "ugen": "flock.ugen.impulse", 6 | "freq": { 7 | "ugen": "flock.ugen.xLine", 8 | "start": 10000, 9 | "end": 20, 10 | "duration": 10 11 | }, 12 | "mul": 0.5 13 | }, 14 | 15 | { 16 | "ugen": "flock.ugen.blit", 17 | "freq": { 18 | "ugen": "flock.ugen.xLine", 19 | "start": 10000, 20 | "end": 20, 21 | "duration": 10 22 | }, 23 | "mul": 0.5 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /demos/playground/live/demos/bandpass-filter.json: -------------------------------------------------------------------------------- 1 | { 2 | "synthDef": { 3 | "ugen": "flock.ugen.filter.biquad.bp", 4 | "freq": { 5 | "ugen": "flock.ugen.mouse.cursor", 6 | "options": { 7 | "interpolation": "exponential" 8 | }, 9 | "mul": 10000, 10 | "add": 100, 11 | "lag": 1 12 | }, 13 | "q": 3.0, 14 | "source": { 15 | "ugen": "flock.ugen.saw", 16 | "freq": 200, 17 | "mul": 0.1 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /demos/playground/live/demos/bandreject-filter.json: -------------------------------------------------------------------------------- 1 | { 2 | "synthDef": { 3 | "ugen": "flock.ugen.filter.biquad.br", 4 | "freq": { 5 | "ugen": "flock.ugen.mouse.cursor", 6 | "options": { 7 | "interpolation": "exponential" 8 | }, 9 | "mul": 10000, 10 | "add": 100, 11 | "lag": 1 12 | }, 13 | "q": 3.0, 14 | "source": { 15 | "ugen": "flock.ugen.saw", 16 | "freq": 200, 17 | "mul": 0.1 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /demos/playground/live/demos/chop-buffer.json: -------------------------------------------------------------------------------- 1 | { 2 | "synthDef": { 3 | "id": "chopper", 4 | "ugen": "flock.ugen.chopBuffer", 5 | "start": 0.1, 6 | "amount": { 7 | "ugen": "flock.ugen.triOsc", 8 | "rate": "control", 9 | "freq": 0.03333333, 10 | "mul": 0.5, 11 | "add": 0.5 12 | }, 13 | "speed": { 14 | "ugen": "flock.ugen.lfNoise", 15 | "rate": "audio", 16 | "options": { 17 | "interpolation": "linear" 18 | }, 19 | "freq": 0.2, 20 | "mul": 0.5, 21 | "add": 0.5 22 | }, 23 | "minDuration": { 24 | "ugen": "flock.ugen.lfNoise", 25 | "freq": 0.2, 26 | "mul": 0.5, 27 | "add": 0.001 28 | }, 29 | "gap": -0.001, 30 | "buffer": { 31 | "url": "../../shared/audio/where-the-honey-is.mp3" 32 | }, 33 | 34 | "mul": 0.1, 35 | 36 | "options": { 37 | "maxVoices": 10 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /demos/playground/live/demos/custom-envelope.json: -------------------------------------------------------------------------------- 1 | { 2 | "synthDef": { 3 | "ugen": "flock.ugen.sinOsc", 4 | "freq": 270, 5 | "phase": { 6 | "ugen": "flock.ugen.sinOsc", 7 | "freq": { 8 | "ugen": "flock.ugen.envGen", 9 | "rate": "control", 10 | "envelope": { 11 | "levels": [0, 1, 0.4, 1.0, 0.6, 0], 12 | "times": [0.5, 0.3, 0.5, 0.3, 0.5], 13 | "curve": ["sin", "exponential", "linear", "welsh", 3] 14 | }, 15 | "mul": 473, 16 | "gate": { 17 | "ugen": "flock.ugen.lfPulse", 18 | "rate": "control", 19 | "freq": 0.39, 20 | "width": 0.5 21 | } 22 | } 23 | }, 24 | "mul": { 25 | "ugen": "flock.ugen.envGen", 26 | "rate": "control", 27 | "envelope": { 28 | "levels": [0, 1, 0.4, 1.0, 0.6, 0], 29 | "times": [0.5, 0.3, 0.5, 0.3, 0.5], 30 | "curve": ["sin", "exponential", "linear", "welsh", 3] 31 | }, 32 | "mul": 0.5, 33 | "gate": { 34 | "ugen": "flock.ugen.lfPulse", 35 | "rate": "control", 36 | "freq": 0.39, 37 | "width": 0.5 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /demos/playground/live/demos/decay.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "The decay unit generator enveloping white noise, creating percussive sounds.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.decay", 5 | "source": { 6 | "ugen": "flock.ugen.impulse", 7 | "rate": "audio", 8 | "freq": { 9 | "ugen": "flock.ugen.xLine", 10 | "rate": "control", 11 | "start": 1, 12 | "end": 50, 13 | "duration": 20 14 | }, 15 | "phase": 0.25, 16 | "mul": 0.25 17 | }, 18 | "time": 0.2, 19 | "mul": { 20 | "ugen": "flock.ugen.whiteNoise" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /demos/playground/live/demos/declarative-scheduling.json: -------------------------------------------------------------------------------- 1 | { 2 | "components": { 3 | "sinSynth": { 4 | "type": "flock.synth", 5 | "options": { 6 | "synthDef": { 7 | "id": "carrier", 8 | "ugen": "flock.ugen.sinOsc", 9 | "freq": 220, 10 | "mul": { 11 | "ugen": "flock.ugen.line", 12 | "start": 0, 13 | "end": 0.25, 14 | "duration": 1.0 15 | } 16 | } 17 | } 18 | }, 19 | 20 | "scheduler": { 21 | "type": "flock.scheduler.async", 22 | "options": { 23 | "components": { 24 | "synthContext": "{sinSynth}" 25 | }, 26 | 27 | "score": [ 28 | { 29 | "interval": "repeat", 30 | "time": 1.0, 31 | "change": { 32 | "values": { 33 | "carrier.freq": { 34 | "synthDef": { 35 | "ugen": "flock.ugen.sequence", 36 | "values": [330, 440, 550, 660, 880, 990, 1100, 1210] 37 | } 38 | } 39 | } 40 | } 41 | }, 42 | 43 | { 44 | "interval": "once", 45 | "time": 8, 46 | "change": { 47 | "values": { 48 | "carrier.mul.start": 0.25, 49 | "carrier.mul.end": 0.0, 50 | "carrier.mul.duration": 1.0 51 | } 52 | } 53 | } 54 | ] 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /demos/playground/live/demos/dejong-distortion.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Sine-modulated distortion of a sawtooth wave", 3 | "synthDef": { 4 | "ugen": "flock.ugen.distortion.deJong", 5 | "amount": { 6 | "ugen": "flock.ugen.sin", 7 | "mul": 99, 8 | "add": 100, 9 | "freq": 0.1 10 | }, 11 | "source": { 12 | "ugen": "flock.ugen.sawOsc", 13 | "freq": 45, 14 | "mul": 0.01 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /demos/playground/live/demos/delay.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Use dust to trigger the delay unit generator as an envelope for a decaying whiteNoise source", 3 | "synthDef": { 4 | "ugen": "flock.ugen.delay", 5 | "source": { 6 | "ugen": "flock.ugen.decay", 7 | "source": { 8 | "ugen": "flock.ugen.dust", 9 | "density": 1.0, 10 | "mul": 0.5 11 | }, 12 | "time": 0.3, 13 | "mul": { 14 | "ugen": "flock.ugen.whiteNoise" 15 | } 16 | }, 17 | "maxTime": 1.0, 18 | "time": 0.2, 19 | "add": { 20 | "ugen": "flock.ugen.decay", 21 | "source": { 22 | "ugen": "flock.ugen.dust", 23 | "density": 1.0, 24 | "mul": 0.5 25 | }, 26 | "time": 0.3, 27 | "mul": { 28 | "ugen": "flock.ugen.whiteNoise" 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /demos/playground/live/demos/dust.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Using dust to generate random audio noise.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.dust", 5 | "density": 200, 6 | "mul": 0.25 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /demos/playground/live/demos/fm.json: -------------------------------------------------------------------------------- 1 | { 2 | "synthDef": { 3 | "ugen": "flock.ugen.sin", 4 | "freq": { 5 | "ugen": "flock.ugen.value", 6 | "value": 400, 7 | "add": { 8 | "ugen": "flock.ugen.sin", 9 | "freq": { 10 | "ugen": "flock.ugen.mouse.cursor", 11 | "mul": 124, 12 | "add": 62 13 | }, 14 | "mul": { 15 | "ugen": "flock.ugen.mouse.cursor", 16 | "mul": 100, 17 | "add": 100, 18 | "options": { 19 | "axis": "y" 20 | } 21 | } 22 | } 23 | }, 24 | "mul": 0.3 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /demos/playground/live/demos/glissando.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "An descending sinOsc glissando using a line ugen.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.sinOsc", 5 | "freq": { 6 | "ugen": "flock.ugen.xLine", 7 | "rate": "control", 8 | "duration": 1.0, 9 | "start": 2000, 10 | "end": 200 11 | }, 12 | "mul": 0.25 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /demos/playground/live/demos/granulator.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Granulates a filtered sawtooth wave. Demo by Mayank Sanganeria and Adam Tindale.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.granulator", 5 | "numGrains": { 6 | "ugen": "flock.ugen.line", 7 | "start": 1, 8 | "end": 40, 9 | "duration": 20 10 | }, 11 | "grainDur": { 12 | "ugen": "flock.ugen.line", 13 | "start": 0.1, 14 | "end": 0.005, 15 | "duration": 100 16 | }, 17 | "delayDur": 8, 18 | "mul": 0.5, 19 | "source": { 20 | "ugen": "flock.ugen.filter.biquad.lp", 21 | "freq": { 22 | "ugen": "flock.ugen.sin", 23 | "rate": "control", 24 | "freq": { 25 | "ugen": "flock.ugen.xLine", 26 | "rate": "control", 27 | "start": 0.7, 28 | "end": 3000, 29 | "duration": 60 30 | }, 31 | "phase": 0, 32 | "mul": 2000, 33 | "add": 4000 34 | }, 35 | "source": { 36 | "ugen": "flock.ugen.lfSaw", 37 | "freq": { 38 | "ugen": "flock.ugen.sin", 39 | "freq": 0.1, 40 | "mul": 1000, 41 | "add": 3000 42 | }, 43 | "mul": 0.25 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /demos/playground/live/demos/highpass-filter.json: -------------------------------------------------------------------------------- 1 | { 2 | "synthDef": { 3 | "ugen": "flock.ugen.filter.biquad.hp", 4 | "freq": { 5 | "ugen": "flock.ugen.sin", 6 | "rate": "control", 7 | "freq": { 8 | "ugen": "flock.ugen.xLine", 9 | "rate": "control", 10 | "start": 0.7, 11 | "end": 300, 12 | "duration": 20 13 | }, 14 | "phase": 0, 15 | "mul": 3600, 16 | "add": 4000 17 | }, 18 | "source": { 19 | "ugen": "flock.ugen.saw", 20 | "freq": 200, 21 | "mul": 0.1 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /demos/playground/live/demos/impulse-pm.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "A stereo pair of impulses, one being phase modulated with the mouse cursor.", 3 | "synthDef": [ 4 | { 5 | "ugen": "flock.ugen.impulse", 6 | "freq": 4, 7 | "mul": 0.3, 8 | "phase": 0 9 | }, 10 | { 11 | "ugen": "flock.ugen.impulse", 12 | "freq": 4, 13 | "mul": 0.3, 14 | "phase": { 15 | "ugen": "flock.ugen.mouse.cursor" 16 | } 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /demos/playground/live/demos/impulse.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "The impulse ugen's frequency controlled by a descending xLine", 3 | "synthDef": { 4 | "ugen": "flock.ugen.impulse", 5 | "freq": { 6 | "ugen": "flock.ugen.xLine", 7 | "start": 880, 8 | "end": 2, 9 | "duration": 3.0 10 | }, 11 | "mul": 0.25 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /demos/playground/live/demos/latch.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "description": "David Michael Cottle's first Latch example from http://rhoadley.net/courses/tech_resources/supercollider/tutorials/cottle/CMSC7105.pdf", 4 | "synthDef": { 5 | "ugen": "flock.ugen.sin", 6 | "mul": 0.3, 7 | "freq": { 8 | "ugen": "flock.ugen.latch", 9 | "rate": "control", 10 | "source": { 11 | "ugen": "flock.ugen.lfSaw", 12 | "freq": { 13 | "ugen": "flock.ugen.mouse.cursor", 14 | "rate": "control", 15 | "mul": 18.9, 16 | "add": 1.1 17 | }, 18 | "mul": 500, 19 | "add": 600 20 | }, 21 | "trigger": { 22 | "ugen": "flock.ugen.impulse", 23 | "rate": "control", 24 | "freq": 10 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /demos/playground/live/demos/lfNoise.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Generating random audio noise with lfNoise.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.lfNoise", 5 | "freq": 1000, 6 | "mul": 0.25 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /demos/playground/live/demos/line-fm.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Frequency modulation controlled by an exponential line", 3 | "synthDef": { 4 | "ugen": "flock.ugen.sinOsc", 5 | "freq": { 6 | "ugen": "flock.ugen.sinOsc", 7 | "freq": { 8 | "ugen": "flock.ugen.xLine", 9 | "rate": "control", 10 | "start": 1, 11 | "end": 1000, 12 | "duration": 9 13 | }, 14 | "mul": 200, 15 | "add": 800 16 | }, 17 | "mul": 0.25 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /demos/playground/live/demos/line-pm.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Line modulating the phase of a sine oscillator.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.sinOsc", 5 | "freq": 800, 6 | "phase": { 7 | "ugen": "flock.ugen.sinOsc", 8 | "freq": { 9 | "ugen": "flock.ugen.xLine", 10 | "rate": "control", 11 | "start": 1, 12 | "end": 1000, 13 | "duration": 9 14 | }, 15 | "mul": 6.28318531 16 | }, 17 | "mul": 0.25 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /demos/playground/live/demos/lowpass-filter.json: -------------------------------------------------------------------------------- 1 | { 2 | "synthDef": { 3 | "ugen": "flock.ugen.filter.biquad.lp", 4 | "freq": { 5 | "ugen": "flock.ugen.sin", 6 | "rate": "control", 7 | "freq": { 8 | "ugen": "flock.ugen.xLine", 9 | "rate": "control", 10 | "start": 0.7, 11 | "end": 300, 12 | "duration": 20 13 | }, 14 | "phase": 0, 15 | "mul": 3600, 16 | "add": 4000 17 | }, 18 | "source": { 19 | "ugen": "flock.ugen.saw", 20 | "freq": 200, 21 | "mul": 0.1 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /demos/playground/live/demos/moog.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "A 24db low pass Moog-style filter", 3 | "synthDef": { 4 | "ugen": "flock.ugen.filter.moog", 5 | "cutoff": { 6 | "ugen": "flock.ugen.sinOsc", 7 | "freq": 0.25, 8 | "mul": 5000, 9 | "add": 7000 10 | }, 11 | "resonance": { 12 | "ugen": "flock.ugen.sinOsc", 13 | "freq": 0.5, 14 | "mul": 1.5, 15 | "add": 1.5 16 | }, 17 | "source": { 18 | "ugen": "flock.ugen.saw", 19 | "freq": { 20 | "ugen": "flock.ugen.sequence", 21 | "freq": 0.5, 22 | "loop": 1, 23 | "values": [220, 275, 220, 330, 293.34, 220], 24 | "options": { 25 | "interpolation": "linear" 26 | } 27 | } 28 | }, 29 | "mul": 0.5 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /demos/playground/live/demos/mouse-click.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Triggers a note whenever the mouse is clicked.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.sinOsc", 5 | "freq": 440, 6 | "mul": { 7 | "ugen": "flock.ugen.asr", 8 | "attack": 0.25, 9 | "sustain": 0.25, 10 | "release": 0.5, 11 | "gate": { 12 | "ugen": "flock.ugen.mouse.click" 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /demos/playground/live/demos/mouse-x.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Tracks the mouse's horizonal movement across the window.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.sinOsc", 5 | "freq": { 6 | "ugen": "flock.ugen.mouse.cursor", 7 | "rate": "control", 8 | "mul": 880, 9 | "add": 110 10 | }, 11 | "mul": 0.25 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /demos/playground/live/demos/mouse-xy.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Tracks the mouse's vertical and horizontal movement within the editor area only. Maps the y axis to amplitude and the x axis to pitch.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.sinOsc", 5 | "freq": { 6 | "ugen": "flock.ugen.mouse.cursor", 7 | "rate": "control", 8 | "mul": 880, 9 | "add": 110, 10 | "options": { 11 | "axis": "width", 12 | "interpolation": "exponential", 13 | "target": ".CodeMirror" 14 | } 15 | }, 16 | "mul": { 17 | "ugen": "flock.ugen.mouse.cursor", 18 | "rate": "control", 19 | "options": { 20 | "axis": "height", 21 | "target": ".CodeMirror" 22 | }, 23 | "mul": 0.5 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /demos/playground/live/demos/mouse-y.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Tracks the mouse's vertical movement across the window.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.sinOsc", 5 | "freq": { 6 | "ugen": "flock.ugen.mouse.cursor", 7 | "rate": "control", 8 | "mul": 880, 9 | "add": 110, 10 | "options": { 11 | "axis": "y" 12 | } 13 | }, 14 | "mul": 0.25 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /demos/playground/live/demos/noise-fm.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "LFNoise randomly changing the pitch of a sine oscillator every quarter second.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.sinOsc", 5 | "mul": 0.25, 6 | "freq": { 7 | "ugen": "flock.ugen.lfNoise", 8 | "freq": 4, 9 | "mul": 400, 10 | "add": 450 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /demos/playground/live/demos/pinknoise.json: -------------------------------------------------------------------------------- 1 | { 2 | "synthDef": { 3 | "ugen": "flock.ugen.pinkNoise", 4 | "mul": 0.5 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /demos/playground/live/demos/play-buffer.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Plays back a sound file in a loop. The playback rate is controlled by the mouse cursor's vertical position, while the end point in the sound file is determined by the mouse's horizontal position.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.playBuffer", 5 | "buffer": { 6 | "id": "chord", 7 | "url": "../../shared/audio/hillier-first-chord.wav" 8 | }, 9 | 10 | "speed": { 11 | "ugen": "flock.ugen.mouse.cursor", 12 | "options": { 13 | "axis": "y" 14 | }, 15 | "add": 0.5 16 | }, 17 | 18 | "loop": 1, 19 | 20 | "start": 0, 21 | 22 | "end": { 23 | "ugen": "flock.ugen.mouse.cursor", 24 | "options": { 25 | "axis": "x" 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /demos/playground/live/demos/playBuffer-trigger.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Triggers the playback of a sound file from the beginning every time the user clicks the mouse.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.playBuffer", 5 | "buffer": { 6 | "id": "chord", 7 | "url": "../../shared/audio/hillier-first-chord.wav" 8 | }, 9 | 10 | "trigger": { 11 | "ugen": "flock.ugen.mouse.click" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /demos/playground/live/demos/pm.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Phase modulation with sine waves. Demo courtesty of Adam Tindale (http://www.adamtindale.com/).", 3 | "synthDef": { 4 | "id": "carrier", 5 | "ugen": "flock.ugen.sinOsc", 6 | "freq": 440, 7 | "phase": { 8 | "id": "mod", 9 | "ugen": "flock.ugen.sinOsc", 10 | "freq": 34.0, 11 | "mul": { 12 | "ugen": "flock.ugen.sinOsc", 13 | "freq": 0.05, 14 | "mul": 3.141592653589793 15 | }, 16 | "add": 3.141592653589793 17 | }, 18 | "mul": 0.25 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /demos/playground/live/demos/readBuffer-phasor.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Plays back a sound file while the user holds down the mouse button. If the user lets go of the mouse and clicks it again, playback will resume at its previous location. Uses a phasor and the bufferPhaseStep unit generator to play back the sound at its normal rate.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.readBuffer", 5 | "buffer": { 6 | "id": "chord", 7 | "url": "../../shared/audio/hillier-first-chord.wav" 8 | }, 9 | "phase": { 10 | "rate": "audio", 11 | "ugen": "flock.ugen.phasor", 12 | "step": { 13 | "ugen": "flock.ugen.mouse.click", 14 | "mul": { 15 | "ugen": "flock.ugen.bufferPhaseStep", 16 | "buffer": "chord" 17 | } 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /demos/playground/live/demos/readBuffer.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Modulates the playback rate of a sound file with a sine wave oscillator.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.readBuffer", 5 | "buffer": { 6 | "id": "chord", 7 | "url": "../../shared/audio/hillier-first-chord.wav" 8 | }, 9 | "phase": { 10 | "ugen": "flock.ugen.sin", 11 | "freq": 0.2, 12 | "mul": 0.5, 13 | "add": 0.5 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /demos/playground/live/demos/sample-accurate-scheduling.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Schedules a series of input changes. Composition by Colin Clark.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.out", 5 | "sources": { 6 | "ugen": "flock.ugen.change", 7 | "initial": { 8 | "ugen": "flock.ugen.sin", 9 | "freq": { 10 | "ugen": "flock.ugen.xLine", 11 | "start": 211, 12 | "end": 200, 13 | "duration": 1 14 | } 15 | }, 16 | "target": { 17 | "ugen": "flock.ugen.change", 18 | "initial": { 19 | "ugen": "flock.ugen.lfSaw", 20 | "freq": { 21 | "ugen": "flock.ugen.xLine", 22 | "start": 200, 23 | "end": 90, 24 | "duration": 30 25 | }, 26 | "mul": 1.0 27 | }, 28 | "target": { 29 | "ugen": "flock.ugen.change", 30 | "initial": { 31 | "ugen": "flock.ugen.sin", 32 | "freq": { 33 | "ugen": "flock.ugen.xLine", 34 | "start": 200, 35 | "end": 211, 36 | "duration": 30 37 | } 38 | }, 39 | "target": { 40 | "ugen": "flock.ugen.sin", 41 | "freq": { 42 | "ugen": "flock.ugen.change", 43 | "initial": { 44 | "ugen": "flock.ugen.sin", 45 | "freq": 200, 46 | "mul": 111 47 | }, 48 | "target": { 49 | "ugen": "flock.ugen.xLine", 50 | "start": 200, 51 | "end": 211, 52 | "duration": 45 53 | }, 54 | "time": 35, 55 | "crossfade": 10 56 | }, 57 | "mul": { 58 | "ugen": "flock.ugen.line", 59 | "start": 1.0, 60 | "end": 0.0, 61 | "duration": 47.5 62 | } 63 | }, 64 | "time": 25, 65 | "crossfade": 20 66 | } 67 | }, 68 | "time": 2.0, 69 | "crossfade": 15.0 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /demos/playground/live/demos/saw.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Non-band limited saw oscillator.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.saw", 5 | "freq": 440, 6 | "mul": 0.25 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /demos/playground/live/demos/scope.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Display a synth's output with an oscilliscope.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.scope", 5 | "source": { 6 | "ugen": "flock.ugen.sinOsc", 7 | "freq": 440, 8 | "mul": 0.25 9 | }, 10 | "options": { 11 | "canvas": "#gfx", 12 | "styles": { 13 | "strokeColor": "#777777", 14 | "strokeWidth": 2 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /demos/playground/live/demos/sequencer.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Sequencing notes using the sequencer unit generator", 3 | "synthDef": { 4 | "ugen": "flock.ugen.sin", 5 | "freq": { 6 | "ugen": "flock.ugen.sequencer", 7 | "durations": [0.25, 0.25, 0.16666667, 0.16666667, 0.33, 0.25, 0.25], 8 | "values": [440, 495, 586.666666, 660, 586.666666, 550, 440], 9 | "loop": 1.0, 10 | "options": { 11 | "holdLastValue": true 12 | } 13 | }, 14 | "mul": { 15 | "ugen": "flock.ugen.envGen", 16 | "envelope": { 17 | "levels": [0, 1, 0], 18 | "times": [0.03, 0.2] 19 | }, 20 | "gate": { 21 | "ugen": "flock.ugen.sequencer", 22 | "durations": [0.25, 0.25, 0.16666667, 0.16666667, 0.33, 0.25, 0.25], 23 | "values": [1, 1, 1, 1, 1, 1, 1], 24 | "loop": 1.0, 25 | "options": { 26 | "resetOnNext": true 27 | } 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /demos/playground/live/demos/sine.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Simple sine wave oscillator", 3 | "synthDef": { 4 | "ugen": "flock.ugen.sinOsc", 5 | "freq": 440, 6 | "mul": 0.25 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /demos/playground/live/demos/square.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Non-band limited square wave oscillator", 3 | "synthDef": { 4 | "ugen": "flock.ugen.square", 5 | "freq": 440, 6 | "mul": 0.25 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /demos/playground/live/demos/stereo.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Two different channels: both are sine waves with slightly different frequencies.", 3 | "synthDef": [ 4 | { 5 | "id": "leftSine", 6 | "ugen": "flock.ugen.sinOsc", 7 | "freq": 440, 8 | "mul": 0.25 9 | }, 10 | { 11 | "id": "rightSine", 12 | "ugen": "flock.ugen.sinOsc", 13 | "freq": 444, 14 | "mul": 0.25 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /demos/playground/live/demos/tanh-distortion.json: -------------------------------------------------------------------------------- 1 | { 2 | "synthDef": { 3 | "ugen": "flock.ugen.sum", 4 | "sources": [ 5 | { 6 | "ugen": "flock.ugen.distortion.tanh", 7 | "source": { 8 | "ugen": "flock.ugen.sinOsc", 9 | "freq": 500, 10 | "mul": { 11 | "ugen": "flock.ugen.asr", 12 | "attack": 0.1, 13 | "sustain": 0.1, 14 | "release": 0.1, 15 | "mul": 2, 16 | "gate": { 17 | "ugen": "flock.ugen.impulse", 18 | "rate": "control", 19 | "freq": 0.7, 20 | "phase": 0 21 | } 22 | } 23 | } 24 | }, 25 | { 26 | "ugen": "flock.ugen.sinOsc", 27 | "freq": 600, 28 | "mul": { 29 | "ugen": "flock.ugen.asr", 30 | "attack": 0.1, 31 | "sustain": 0.1, 32 | "release": 0.1, 33 | "mul": 2, 34 | "gate": { 35 | "ugen": "flock.ugen.impulse", 36 | "rate": "control", 37 | "freq": 0.7, 38 | "phase": 0.5 39 | } 40 | } 41 | } 42 | ] 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /demos/playground/live/demos/tarrabia-dejong-distortion.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Frequency-modulated saw wave by ring-modulated square wave through modulated distortion", 3 | "synthDef": { 4 | "ugen": "flock.ugen.distortion.tarrabiaDeJong", 5 | "amount": { 6 | "ugen": "flock.ugen.sin", 7 | "rate": "control", 8 | "freq": 0.25 9 | }, 10 | "source": { 11 | "ugen": "flock.ugen.saw", 12 | "freq": { 13 | "ugen": "flock.ugen.square", 14 | "mul": { 15 | "ugen": "flock.ugen.sin", 16 | "mul": 30, 17 | "freq": 2 18 | }, 19 | "add": 100 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /demos/playground/live/demos/tri.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Non-band limited triangle oscillator", 3 | "synthDef": { 4 | "ugen": "flock.ugen.tri", 5 | "freq": 440, 6 | "mul": 0.25 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /demos/playground/live/demos/whitenoise.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Filtering white noise with the mouse.", 3 | "synthDef": { 4 | "ugen": "flock.ugen.filter.biquad.bp", 5 | "source": { 6 | "ugen": "flock.ugen.whiteNoise", 7 | "mul": 0.5 8 | }, 9 | "freq": { 10 | "ugen": "flock.ugen.mouse.cursor", 11 | "mul": 1660, 12 | "add": 40, 13 | "options": { 14 | "interoplation": "exponential" 15 | } 16 | }, 17 | "q": 2.0 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /demos/shared/audio/hillier-first-chord.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lichen-community-systems/Flocking/0b023ea4bfbf5ef3c089f2f1736ad9910d912f7b/demos/shared/audio/hillier-first-chord.wav -------------------------------------------------------------------------------- /demos/shared/audio/where-the-honey-is.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lichen-community-systems/Flocking/0b023ea4bfbf5ef3c089f2f1736ad9910d912f7b/demos/shared/audio/where-the-honey-is.mp3 -------------------------------------------------------------------------------- /demos/shared/css/demos.css: -------------------------------------------------------------------------------- 1 | @import url(https://fonts.googleapis.com/css?family=Nunito); 2 | body { 3 | font-family: "Nunito", sans-serif; 4 | background: #eee; 5 | } 6 | 7 | th, td { 8 | background-color: #DDDDDD; 9 | padding: 10px; 10 | } 11 | 12 | th { 13 | text-align: left; 14 | width: 130px; 15 | } 16 | 17 | td { 18 | width: 50px; 19 | } 20 | 21 | .playButton { 22 | border: none; 23 | height: 77px; 24 | width: 77px; 25 | float: left; 26 | margin: 5% 0% 0% 2%; 27 | color: transparent; 28 | } 29 | 30 | .playButton.playing { 31 | background: transparent url("../../../images/pause.png") no-repeat center center; 32 | background-size: cover; 33 | } 34 | 35 | .playButton.paused { 36 | background: transparent url("../../../images/play.png") no-repeat center center; 37 | background-size: cover; 38 | } 39 | 40 | .fileSelector label { 41 | display: none; 42 | } 43 | 44 | .fileSelector .fileBrowser { 45 | display: none; 46 | padding: 10px; 47 | } 48 | 49 | .fileSelector .filePath { 50 | font-family: courier, monospace; 51 | font-size: 80%; 52 | padding-top: 2.5%; 53 | padding-right: 3%; 54 | padding-left: 3%; 55 | } 56 | 57 | .fileSelector .browse { 58 | border: 2px solid #888; 59 | border-radius: 10px; 60 | font-size: 100%; 61 | font-style: italic; 62 | background: #fff; 63 | padding: 1.5%; 64 | } 65 | 66 | .instructions { 67 | font-style: italic; 68 | font-size: 80%; 69 | } 70 | 71 | label { 72 | font-family: serif; 73 | } 74 | 75 | select { 76 | margin-left: 0.5em; 77 | margin-right: 0.5em; 78 | min-width: 20em; 79 | } 80 | -------------------------------------------------------------------------------- /docs/building-flocking.md: -------------------------------------------------------------------------------- 1 | # Building Flocking # 2 | 3 | Flocking ships with pre-built development and production files in the dist directory. For most users, it's suitable to simply load flocking-all.min.js in your HTML file. 4 | 5 | For more advanced users, however, Flocking includes a build system that takes care of linting, concatenating, minifying, and organizing the Flocking source tree. The build system is powered by [Grunt](https://gruntjs.com). 6 | 7 | The build system will generate a single file that is easy to include in your web page. Before you start, you'll need to have [Node.js](https://nodejs.org) installed. Flocking supports the latest Node.js LTS release. Once you've installed it, you simply need to install Flocking's depedencies and then run _grunt_. 8 | 9 | Install grunt and related dependencies: 10 | 11 | npm install -g grunt-cli 12 | npm install 13 | 14 | To make a build, simply run: 15 | 16 | grunt 17 | 18 | And then link to the Flocking file in your HTML: 19 | 20 | 21 | 22 | Description of Each Build 23 | -------------------------- 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | 35 | 36 | 38 | 39 | 40 | 45 |
FilenameDescription
flocking-all.jsAll of Flocking and all its dependencies. Use this file if you're not using a module loader and want a simple way to link Flocking into your web page. 33 |
flocking-no-jquery.jsAll of Flocking's dependencies except jQuery. This build is CommonJS/AMD/CMD/whatever module system friendly. 37 |
flocking-base.jsThis build doesn't include include any view-related code whatsoever. 41 | You must provide your own builds of Infusion and jQuery. 42 | It also does not contain any unit generators beyond the basic set. Use this if you want to choose which unit generators to ship with your application, and if you don't intend to use 43 | Flocking's UI components, Infusion Views, or jQuery for access to the DOM. This build is also not compatible with browser-based module loaders. 44 |
46 | -------------------------------------------------------------------------------- /docs/scheduling.md: -------------------------------------------------------------------------------- 1 | # Scheduling Changes in Flocking # 2 | 3 | ## Using Unit Generators to Trigger Changes ## 4 | There are a number of ways to schedule changes in Flocking. One way is to trigger periodic signal changes 5 | using unit generators. Impulse is particularly useful for this task. For example, here's how to play a sound file every 2 seconds: 6 | 7 | flock.synth({ 8 | synthDef: { 9 | ugen: "flock.ugen.playBuffer", 10 | buffer: { 11 | id: "drum", 12 | url: "audio/kick.wav" 13 | }, 14 | loop: 1, 15 | trigger: { 16 | ugen: "flock.ugen.impulse", 17 | freq: 1/2 18 | } 19 | } 20 | }); 21 | -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lichen-community-systems/Flocking/0b023ea4bfbf5ef3c089f2f1736ad9910d912f7b/favicon.ico -------------------------------------------------------------------------------- /images/flocking-tentative-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lichen-community-systems/Flocking/0b023ea4bfbf5ef3c089f2f1736ad9910d912f7b/images/flocking-tentative-logo.png -------------------------------------------------------------------------------- /images/pause.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lichen-community-systems/Flocking/0b023ea4bfbf5ef3c089f2f1736ad9910d912f7b/images/pause.ai -------------------------------------------------------------------------------- /images/pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lichen-community-systems/Flocking/0b023ea4bfbf5ef3c089f2f1736ad9910d912f7b/images/pause.png -------------------------------------------------------------------------------- /images/play.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lichen-community-systems/Flocking/0b023ea4bfbf5ef3c089f2f1736ad9910d912f7b/images/play.ai -------------------------------------------------------------------------------- /images/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lichen-community-systems/Flocking/0b023ea4bfbf5ef3c089f2f1736ad9910d912f7b/images/play.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flocking", 3 | "version": "3.0.1", 4 | "description": "Creative audio synthesis for the Web", 5 | "author": "Colin Clark", 6 | "homepage": "https://flockingjs.org/", 7 | "repository": { 8 | "type": "git", 9 | "url": "git://github.com/continuing-creativity/Flocking.git" 10 | }, 11 | "bugs": "https://github.com/continuing-creativity/Flocking/issues", 12 | "license": "(MIT OR GPL-2.0)", 13 | "keywords": [ 14 | "Flocking", 15 | "WebAudio", 16 | "sound", 17 | "audio", 18 | "music", 19 | "synthesis" 20 | ], 21 | "readmeFilename": "README.md", 22 | "browser": "dist/flocking-all.js", 23 | "devDependencies": { 24 | "grunt": "1.5.2", 25 | "grunt-contrib-clean": "2.0.1", 26 | "grunt-contrib-concat": "2.1.0", 27 | "grunt-contrib-uglify": "5.2.1", 28 | "grunt-contrib-copy": "1.0.0", 29 | "grunt-contrib-jshint": "3.2.0", 30 | "sheep-benchmark": "colinbdclark/sheep.js", 31 | "requirejs": "2.3.6", 32 | "testem": "3.6.0" 33 | }, 34 | "dependencies": { 35 | "jquery": "3.6.0", 36 | "infusion": "3.0.0", 37 | "codemirror-infusion": "2.4.1", 38 | "jsplumb": "1.7.9", 39 | "dagre": "0.8.5", 40 | "normalize.css": "8.0.1" 41 | }, 42 | "scripts": { 43 | "prepare": "node_modules/.bin/grunt", 44 | "test": "node_modules/.bin/testem ci --file tests/unit/testem.json" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/evaluators.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Flocking Synth Evaluator 3 | * https://github.com/continuing-creativity/flocking 4 | * 5 | * Copyright 2011-2015, Colin Clark 6 | * Dual licensed under the MIT and GPL Version 2 licenses. 7 | */ 8 | 9 | /*global require*/ 10 | /*jshint white: false, newcap: true, regexp: true, browser: true, 11 | forin: false, nomen: true, bitwise: false, maxerr: 100, 12 | indent: 4, plusplus: false, curly: true, eqeqeq: true, 13 | freeze: true, latedef: true, noarg: true, nonew: true, quotmark: double, undef: true, 14 | unused: true, strict: true, asi: false, boss: false, evil: false, expr: false, 15 | funcscope: false*/ 16 | 17 | var fluid = fluid || require("infusion"), 18 | flock = fluid.registerNamespace("flock"); 19 | 20 | (function () { 21 | "use strict"; 22 | 23 | flock.evaluate = { 24 | synth: function (synth) { 25 | flock.evaluate.ugens(synth.nodeList.nodes); 26 | }, 27 | 28 | synthValue: function (synth) { 29 | flock.evaluate.synth(synth); 30 | 31 | // Update the synth's model. 32 | if (synth.out) { 33 | synth.value = synth.out.model.value; 34 | } 35 | 36 | return synth.value; 37 | }, 38 | 39 | synthModel: function (synth) { 40 | var value = flock.evaluate.synthValue(synth); 41 | synth.applier.change("value", value); 42 | }, 43 | 44 | synths: function (synths) { 45 | for (var i = 0; i < synths.length; i++) { 46 | var synth = synths[i]; 47 | synth.generatorFunc(synth); 48 | } 49 | }, 50 | 51 | synthGroup: function (group) { 52 | flock.evaluate.synths(group.nodeList.nodes); 53 | }, 54 | 55 | // TODO: Move this elsewhere? 56 | clearBuses: function (buses, numBuses, busLen) { 57 | for (var i = 0; i < numBuses; i++) { 58 | var bus = buses[i]; 59 | for (var j = 0; j < busLen; j++) { 60 | bus[j] = 0; 61 | } 62 | } 63 | }, 64 | 65 | ugens: function (ugens) { 66 | var ugen; 67 | 68 | for (var i = 0; i < ugens.length; i++) { 69 | ugen = ugens[i]; 70 | if (ugen.gen !== undefined) { 71 | ugen.gen(ugen.model.blockSize); 72 | } 73 | } 74 | } 75 | }; 76 | 77 | }()); 78 | -------------------------------------------------------------------------------- /src/flocking-audiofile-worker.js: -------------------------------------------------------------------------------- 1 | /*! Flocking audio file web worker decoder, Copyright 2011-2014 Colin Clark | flockingjs.org */ 2 | 3 | /*global importScripts, postMessage, self*/ 4 | /*jshint white: false, newcap: true, regexp: true, browser: true, 5 | forin: false, nomen: true, bitwise: false, maxerr: 100, 6 | indent: 4, plusplus: false, curly: true, eqeqeq: true, 7 | freeze: true, latedef: true, noarg: true, nonew: true, quotmark: double, undef: true, 8 | unused: true, strict: true, asi: false, boss: false, evil: false, expr: false, 9 | funcscope: false*/ 10 | 11 | var flock = {}; 12 | 13 | (function () { 14 | 15 | "use strict"; 16 | 17 | flock.audio = { 18 | decode: {}, 19 | workerDecoder: {} 20 | }; 21 | 22 | // TODO: Allow toggling of these files with a production concatenated build. 23 | importScripts( 24 | "./flocking-audiofile-compatibility.js", 25 | "./flocking-audiofile-converters.js" 26 | ); 27 | 28 | flock.audio.workerDecoder.sendBuffer = function (buffer, type) { 29 | postMessage({ 30 | msg: "afterDecoded", 31 | buffer: buffer, 32 | type: type 33 | }); 34 | }; 35 | 36 | flock.audio.workerDecoder.sendError = function (errorMsg) { 37 | postMessage({ 38 | msg: "onError", 39 | errorMsg: errorMsg 40 | }); 41 | }; 42 | 43 | self.addEventListener("message", function (e) { 44 | var data = e.data, 45 | type = data.type; 46 | 47 | if (data.msg === "decode") { 48 | try { 49 | var buffer = flock.audio.decodeArrayBuffer(data.rawData, type); 50 | flock.audio.workerDecoder.sendBuffer(buffer, type); 51 | } catch (err) { 52 | flock.audio.workerDecoder.sendError(err.message); 53 | } finally { 54 | self.close(); 55 | } 56 | } 57 | }); 58 | 59 | }()); 60 | -------------------------------------------------------------------------------- /src/synths/band.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Flocking Band 3 | * https://github.com/continuing-creativity/flocking 4 | * 5 | * Copyright 2013-2015, Colin Clark 6 | * Dual licensed under the MIT and GPL Version 2 licenses. 7 | */ 8 | 9 | /*global require, flock*/ 10 | /*jshint white: false, newcap: true, regexp: true, browser: true, 11 | forin: false, nomen: true, bitwise: false, maxerr: 100, 12 | indent: 4, plusplus: false, curly: true, eqeqeq: true, 13 | freeze: true, latedef: true, noarg: true, nonew: true, quotmark: double, undef: true, 14 | unused: true, strict: true, asi: false, boss: false, evil: false, expr: false, 15 | funcscope: false*/ 16 | 17 | var fluid = fluid || require("infusion"), 18 | flock = fluid.registerNamespace("flock"); 19 | 20 | (function () { 21 | "use strict"; 22 | 23 | /** 24 | * flock.band provides an IoC-friendly interface for a collection of named synths. 25 | */ 26 | // TODO: Unit tests. 27 | // TODO: It seems likely that this component should be a flock.node, too. 28 | fluid.defaults("flock.band", { 29 | gradeNames: ["fluid.component"], 30 | synthGrade: "flock.noteTarget", 31 | invokers: { 32 | play: { 33 | func: "{that}.events.onPlay.fire" 34 | }, 35 | 36 | pause: { 37 | func: "{that}.events.onPause.fire" 38 | }, 39 | 40 | set: { 41 | func: "{that}.events.onSet.fire" 42 | }, 43 | getSynths: { 44 | funcName: "fluid.queryIoCSelector", 45 | args: ["{that}", "{that}.options.synthGrade"] 46 | } 47 | }, 48 | 49 | events: { 50 | onPlay: null, 51 | onPause: null, 52 | onSet: null 53 | }, 54 | 55 | distributeOptions: [ 56 | { 57 | source: "{that}.options.synthListeners", 58 | removeSource: true, 59 | target: "{that flock.synth}.options.listeners" 60 | } 61 | ], 62 | 63 | synthListeners: { 64 | "{band}.events.onPlay": { 65 | func: "{that}.play" 66 | }, 67 | 68 | "{band}.events.onPause": { 69 | func: "{that}.pause" 70 | }, 71 | 72 | "{band}.events.onSet": { 73 | func: "{that}.set" 74 | } 75 | } 76 | }); 77 | }()); 78 | -------------------------------------------------------------------------------- /src/synths/frame-rate.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Flocking Frame Rate Synth 3 | * https://github.com/continuing-creativity/flocking 4 | * 5 | * Copyright 2013-2018, Colin Clark 6 | * Dual licensed under the MIT and GPL Version 2 licenses. 7 | */ 8 | 9 | /*global require, flock*/ 10 | 11 | var fluid = fluid || require("infusion"), 12 | flock = fluid.registerNamespace("flock"); 13 | 14 | fluid.defaults("flock.synth.frameRate", { 15 | gradeNames: ["flock.synth.value"], 16 | 17 | rate: "scheduled", 18 | 19 | fps: 60, 20 | 21 | members: { 22 | audioSettings: { 23 | rates: { 24 | scheduled: "{that}.options.fps" 25 | } 26 | } 27 | } 28 | }); 29 | -------------------------------------------------------------------------------- /src/synths/model.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Flocking Modelized Synth 3 | * https://github.com/continuing-creativity/flocking 4 | * 5 | * Copyright 2013-2015, Colin Clark 6 | * Copyright 2015, OCAD University 7 | * 8 | * Dual licensed under the MIT and GPL Version 2 licenses. 9 | */ 10 | 11 | /*global require*/ 12 | /*jshint white: false, newcap: true, regexp: true, browser: true, 13 | forin: false, nomen: true, bitwise: false, maxerr: 100, 14 | indent: 4, plusplus: false, curly: true, eqeqeq: true, 15 | freeze: true, latedef: true, noarg: true, nonew: true, quotmark: double, undef: true, 16 | unused: true, strict: true, asi: false, boss: false, evil: false, expr: false, 17 | funcscope: false*/ 18 | 19 | var fluid = fluid || require("infusion"), 20 | flock = fluid.registerNamespace("flock"); 21 | 22 | (function () { 23 | "use strict"; 24 | 25 | fluid.defaults("flock.modelSynth", { 26 | gradeNames: "flock.synth", 27 | 28 | model: { 29 | inputs: {}, 30 | value: undefined 31 | }, 32 | 33 | modelListeners: { 34 | "inputs": [ 35 | { 36 | funcName: "flock.modelSynth.updateUGens", 37 | args: ["{that}.set", "{that}.options.ugens", "{change}"] 38 | } 39 | ] 40 | }, 41 | 42 | invokers: { 43 | generate: { 44 | funcName: "flock.evaluate.synthModel" 45 | } 46 | } 47 | }); 48 | 49 | flock.modelSynth.updateUGens = function (set, ugens, change) { 50 | var changeSpec = {}; 51 | flock.modelSynth.flattenModel("", change.value, changeSpec); 52 | set(changeSpec); 53 | }; 54 | 55 | flock.modelSynth.shouldFlattenValue = function (value) { 56 | return fluid.isPrimitive(value) || flock.isIterable(value) || value.ugen; 57 | }; 58 | 59 | flock.modelSynth.flattenModel = function (path, model, changeSpec) { 60 | for (var key in model) { 61 | var value = model[key], 62 | newPath = fluid.pathUtil.composePath(path, key.toString()); 63 | 64 | if (flock.modelSynth.shouldFlattenValue(value)) { 65 | changeSpec[newPath] = value; 66 | } else { 67 | flock.modelSynth.flattenModel(newPath, value, changeSpec); 68 | } 69 | } 70 | 71 | return changeSpec; 72 | }; 73 | }()); 74 | -------------------------------------------------------------------------------- /src/synths/value.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Flocking Value Synth 3 | * https://github.com/continuing-creativity/flocking 4 | * 5 | * Copyright 2013-2018, Colin Clark 6 | * Dual licensed under the MIT and GPL Version 2 licenses. 7 | */ 8 | 9 | /*global require, flock*/ 10 | 11 | var fluid = fluid || require("infusion"), 12 | flock = fluid.registerNamespace("flock"); 13 | 14 | fluid.defaults("flock.synth.value", { 15 | gradeNames: ["flock.synth"], 16 | 17 | rate: "demand", 18 | addToEnvironment: false, 19 | 20 | invokers: { 21 | generate: { 22 | funcName: "flock.evaluate.synthValue" 23 | } 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /src/ugens/dynamics.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Flocking Dynamics Unit Generators 3 | * https://github.com/continuing-creativity/flocking 4 | * 5 | * Copyright 2011-2015, Colin Clark 6 | * Dual licensed under the MIT and GPL Version 2 licenses. 7 | */ 8 | 9 | /*global require*/ 10 | /*jshint white: false, newcap: true, regexp: true, browser: true, 11 | forin: false, nomen: true, bitwise: false, maxerr: 100, 12 | indent: 4, plusplus: false, curly: true, eqeqeq: true, 13 | freeze: true, latedef: true, noarg: true, nonew: true, quotmark: double, undef: true, 14 | unused: true, strict: true, asi: false, boss: false, evil: false, expr: false, 15 | funcscope: false*/ 16 | 17 | var fluid = fluid || require("infusion"), 18 | flock = fluid.registerNamespace("flock"); 19 | 20 | (function () { 21 | "use strict"; 22 | 23 | flock.ugen.normalize = function (inputs, output, options) { 24 | var that = flock.ugen(inputs, output, options); 25 | 26 | that.gen = function () { 27 | var m = that.model, 28 | out = that.output, 29 | max = that.inputs.max.output[0], // Max is kr. 30 | source = that.inputs.source.output; 31 | 32 | // Note, this normalizes the source input ugen's output buffer directly in place. 33 | flock.normalize(source, max, out); 34 | m.value = m.unscaledValue = out[out.length - 1]; 35 | }; 36 | 37 | that.onInputChanged(); 38 | return that; 39 | }; 40 | 41 | flock.ugenDefaults("flock.ugen.normalize", { 42 | rate: "audio", 43 | inputs: { 44 | max: 1.0, 45 | source: null 46 | } 47 | }); 48 | 49 | }()); 50 | -------------------------------------------------------------------------------- /src/ui/editor/css/editor.css: -------------------------------------------------------------------------------- 1 | /* Based on CodeMirror's Monokai theme, which is... */ 2 | /* Based on Sublime Text's Monokai theme */ 3 | 4 | .cm-s-flockingcm.CodeMirror {background: #272822; color: #f8f8f2;} 5 | .cm-s-flockingcm div.CodeMirror-selected {background: #49483E !important;} 6 | 7 | .cm-s-flockingcm .CodeMirror-gutters { 8 | background-color: #49483e; 9 | border-right: 1px solid #75715e; 10 | padding-right: 0.25%; 11 | } 12 | .cm-s-flockingcm .CodeMirror-linenumber { 13 | color: #75715e; 14 | font-size: 75%; 15 | } 16 | 17 | .cm-s-flockingcm .CodeMirror-code div { 18 | padding: 0.1% 0; 19 | } 20 | 21 | .cm-s-flockingcm .CodeMirror-cursor {border-left: 1px solid #f8f8f0 !important;} 22 | 23 | .cm-s-flockingcm span.cm-comment {color: #75715e;} 24 | .cm-s-flockingcm span.cm-atom {color: #ae81ff;} 25 | .cm-s-flockingcm span.cm-number {color: #ae81ff;} 26 | 27 | /*.cm-s-flockingcm span.cm-property, .cm-s-monokai span.cm-attribute {color: #a6e22e;}*/ 28 | .cm-s-flockingcm span.cm-keyword {color: #f92672;} 29 | .cm-s-flockingcm span.cm-string {color: #e6db74;} 30 | 31 | .cm-s-flockingcm span.cm-def {color: #fd971f;} 32 | .cm-s-flockingcm span.cm-bracket {color: #f8f8f2;} 33 | .cm-s-flockingcm span.cm-tag {color: #f92672;} 34 | .cm-s-flockingcm span.cm-link {color: #ae81ff;} 35 | .cm-s-flockingcm span.cm-error {background: #f92672; color: #f8f8f0;} 36 | 37 | .cm-s-flockingcm .CodeMirror-activeline-background {background: #373831 !important;} 38 | .cm-s-flockingcm .CodeMirror-matchingbracket { 39 | text-decoration: underline; 40 | color: white !important; 41 | } 42 | -------------------------------------------------------------------------------- /src/ui/play-button/css/play-button.css: -------------------------------------------------------------------------------- 1 | .flock-playButton { 2 | height: 1.75em; 3 | width: 1.75em; 4 | padding: 0; 5 | border: 0 none; 6 | border-radius: 2em; 7 | font-size: 125%; 8 | float: left; 9 | background-color: #777; 10 | color: #fff; 11 | text-align: center; 12 | margin-left: 0.5em; 13 | margin-top: 0; 14 | } 15 | 16 | .flock-playButton.paused { 17 | padding-left: 0.45em; 18 | padding-right: 0.45em; 19 | } 20 | 21 | .flock-playButton:disabled { 22 | color: #888; 23 | } 24 | 25 | .flock-playButton:focus { 26 | padding-left: 0.3em; 27 | border: 0.1em solid #ddd; 28 | outline: none; 29 | } 30 | 31 | .flock-playButton.playing:focus { 32 | padding-left: 0em; 33 | } 34 | -------------------------------------------------------------------------------- /src/ui/shared/css/flocking-icon-font.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'flocking-icon-font'; 3 | src:url('../fonts/flocking-icon-font.eot'); 4 | src:url('../fonts/flocking-icon-font.eot?#iefix') format('embedded-opentype'), 5 | url('../fonts/flocking-icon-font.ttf') format('truetype'), 6 | url('../fonts/flocking-icon-font.woff') format('woff'), 7 | url('../fonts/flocking-icon-font.svg#flocking-icon-font') format('svg'); 8 | font-weight: normal; 9 | font-style: normal; 10 | } 11 | 12 | [class^="icon-"], [class*=" icon-"] { 13 | font-family: 'flocking-icon-font'; 14 | speak: none; 15 | font-style: normal; 16 | font-weight: normal; 17 | font-variant: normal; 18 | text-transform: none; 19 | line-height: 1; 20 | 21 | /* Enable Ligatures ================ */ 22 | -webkit-font-feature-settings: "liga"; 23 | -moz-font-feature-settings: "liga=1"; 24 | -moz-font-feature-settings: "liga"; 25 | -ms-font-feature-settings: "liga" 1; 26 | -o-font-feature-settings: "liga"; 27 | font-feature-settings: "liga"; 28 | 29 | /* Better Font Rendering =========== */ 30 | -webkit-font-smoothing: antialiased; 31 | -moz-osx-font-smoothing: grayscale; 32 | } 33 | 34 | .icon-play:before { 35 | content: "\e600"; 36 | } 37 | .icon-pause:before { 38 | content: "\e601"; 39 | } 40 | -------------------------------------------------------------------------------- /src/ui/shared/fonts/flocking-icon-font.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lichen-community-systems/Flocking/0b023ea4bfbf5ef3c089f2f1736ad9910d912f7b/src/ui/shared/fonts/flocking-icon-font.eot -------------------------------------------------------------------------------- /src/ui/shared/fonts/flocking-icon-font.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Generated by IcoMoon 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/ui/shared/fonts/flocking-icon-font.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lichen-community-systems/Flocking/0b023ea4bfbf5ef3c089f2f1736ad9910d912f7b/src/ui/shared/fonts/flocking-icon-font.ttf -------------------------------------------------------------------------------- /src/ui/shared/fonts/flocking-icon-font.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lichen-community-systems/Flocking/0b023ea4bfbf5ef3c089f2f1736ad9910d912f7b/src/ui/shared/fonts/flocking-icon-font.woff -------------------------------------------------------------------------------- /src/web/buffer-writer.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Flocking Web Audio Buffer Writer 3 | * https://github.com/continuing-creativity/flocking 4 | * 5 | * Copyright 2013-2015, Colin Clark 6 | * Dual licensed under the MIT and GPL Version 2 licenses. 7 | */ 8 | 9 | /*global require*/ 10 | /*jshint white: false, newcap: true, regexp: true, browser: true, 11 | forin: false, nomen: true, bitwise: false, maxerr: 100, 12 | indent: 4, plusplus: false, curly: true, eqeqeq: true, 13 | freeze: true, latedef: true, noarg: true, nonew: true, quotmark: double, undef: true, 14 | unused: true, strict: true, asi: false, boss: false, evil: false, expr: false, 15 | funcscope: false*/ 16 | 17 | var fluid = fluid || require("infusion"), 18 | flock = fluid.registerNamespace("flock"); 19 | 20 | (function () { 21 | "use strict"; 22 | 23 | fluid.defaults("flock.webAudio.bufferWriter", { 24 | gradeNames: "fluid.component", 25 | 26 | invokers: { 27 | save: "flock.webAudio.bufferWriter.saveBuffer({arguments}.0)" 28 | } 29 | }); 30 | 31 | // TODO: This should move into its own component. 32 | flock.webAudio.bufferWriter.saveBuffer = function (o) { 33 | try { 34 | var encoded = flock.audio.encode.wav(o.buffer, o.format), 35 | blob = new Blob([encoded], { 36 | type: "audio/wav" 37 | }); 38 | 39 | flock.webAudio.bufferWriter.download(o.path, blob); 40 | 41 | if (o.success) { 42 | o.success(encoded); 43 | } 44 | 45 | return encoded; 46 | } catch (e) { 47 | if (!o.error) { 48 | flock.fail("There was an error while trying to download the buffer named " + 49 | o.buffer.id + ". Error: " + e); 50 | } else { 51 | o.error(e); 52 | } 53 | } 54 | }; 55 | 56 | flock.webAudio.bufferWriter.download = function (fileName, blob) { 57 | var dataURL = flock.shim.URL.createObjectURL(blob), 58 | a = window.document.createElement("a"), 59 | click = document.createEvent("Event"); 60 | 61 | // TODO: This approach currently only works in Chrome. 62 | // Although Firefox apparently supports it, this method of 63 | // programmatically clicking the link doesn't seem to have an 64 | // effect in it. 65 | // https://caniuse.com/#feat=download 66 | a.href = dataURL; 67 | a.download = fileName; 68 | click.initEvent("click", true, true); 69 | a.dispatchEvent(click); 70 | }; 71 | }()); 72 | -------------------------------------------------------------------------------- /tests/manual/aiff-playback-11Khz/README.md: -------------------------------------------------------------------------------- 1 | This manual test illustrates [gh-192](https://github.com/continuing-creativity/Flocking/issues/192), a bug in Flocking that causes (at minimum) low sample rate (i.e. < 44.1 KHz) AIFF-encoded audio files to play back at an inappropriately high speed using flock.ugen.playBuffer. This only seems to be an issue when the speed input is set to 1.0; a value of, say, 0.999999 causes the playback to be normal. Converting the AIFF file to WAVE format, even at the same sample rate, also does not exhibit the issue. 2 | -------------------------------------------------------------------------------- /tests/manual/aiff-playback-11Khz/hockey.aiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lichen-community-systems/Flocking/0b023ea4bfbf5ef3c089f2f1736ad9910d912f7b/tests/manual/aiff-playback-11Khz/hockey.aiff -------------------------------------------------------------------------------- /tests/manual/aiff-playback-11Khz/hockey.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lichen-community-systems/Flocking/0b023ea4bfbf5ef3c089f2f1736ad9910d912f7b/tests/manual/aiff-playback-11Khz/hockey.wav -------------------------------------------------------------------------------- /tests/manual/aiff-playback-11Khz/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Example of Triggering a Flocking playBuffer Unit Generator with a Button 7 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 |
23 | 24 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /tests/performance/css/benchmarks.css: -------------------------------------------------------------------------------- 1 | table, tr, th, td { 2 | border: 2px solid #666; 3 | } 4 | 5 | table { 6 | width: 50%; 7 | margin: 2%; 8 | border-collapse: collapse; 9 | } 10 | 11 | th { 12 | background: #666; 13 | color: #fff; 14 | border: none; 15 | } 16 | 17 | th, td { 18 | text-align: left; 19 | padding: 2%; 20 | } 21 | 22 | tr:nth-child(odd) { 23 | background: #eee; 24 | } 25 | 26 | td:nth-child(1) { 27 | width: 50%; 28 | } -------------------------------------------------------------------------------- /tests/performance/html/audiofile-benchmarks.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Audio File Benchmarks (Flocking) 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /tests/performance/js/audiofile-benchmarks.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Flocking Audio File Benchmark Tests 3 | * https://github.com/continuing-creativity/flocking 4 | * 5 | * Copyright 2012-2014, Colin Clark 6 | * Dual licensed under the MIT and GPL Version 2 licenses. 7 | */ 8 | 9 | /*global require, sheep*/ 10 | 11 | var fluid = fluid || require("infusion"), 12 | flock = fluid.registerNamespace("flock"); 13 | 14 | (function () { 15 | "use strict"; 16 | 17 | fluid.registerNamespace("flock.test"); 18 | 19 | var environment = flock.init(); 20 | 21 | var testConfigs = [ 22 | { 23 | name: "Decode 16 bit WAV file from base64-encoded dataURL", 24 | url: flock.test.audio.triangleInt16WAV 25 | }, 26 | { 27 | name: "Decode 16 bit AIFF file from base64-encoded dataURL", 28 | url: flock.test.audio.triangleInt16AIFF 29 | } 30 | ]; 31 | 32 | var emptyFn = function () {}; 33 | 34 | var makeTestSpec = function (config) { 35 | return { 36 | name: config.name, 37 | numReps: 200000, 38 | test: function () { 39 | // TODO: This code assumes flock.audio.decode will run synchronously, 40 | // which it doesn't always do and can't be relied upon. 41 | flock.audio.decode({ 42 | src: config.url, 43 | sampleRate: environment.audioSystem.model.sampleRate, 44 | success: emptyFn 45 | }); 46 | } 47 | }; 48 | }; 49 | 50 | flock.test.timeDecodeAudioFileFromDataURL = function () { 51 | var testSpecs = [], 52 | i, 53 | config; 54 | 55 | for (i = 0; i < testConfigs.length; i++) { 56 | config = testConfigs[i]; 57 | testSpecs.push(makeTestSpec(config)); 58 | } 59 | 60 | sheep.test(testSpecs, true); 61 | }; 62 | 63 | }()); 64 | -------------------------------------------------------------------------------- /tests/performance/js/synth-benchmarks.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Flocking Synth Benchmark Tests 3 | * https://github.com/continuing-creativity/flocking 4 | * 5 | * Copyright 2011-2014, Colin Clark 6 | * Dual licensed under the MIT and GPL Version 2 licenses. 7 | */ 8 | 9 | /*global sheep*/ 10 | 11 | var flock = flock || {}; 12 | 13 | (function () { 14 | "use strict"; 15 | 16 | flock.init(); 17 | 18 | flock.test = flock.test || {}; 19 | 20 | var makeSynthDefTestSpec = function (synthDef, rate, numSampleBlocks) { 21 | return { 22 | setup: function () { 23 | var synth = flock.synth({ 24 | synthDef: synthDef 25 | }); 26 | 27 | var i, 28 | ugen; 29 | 30 | // Change the rate of each unit generator to the specified rate. 31 | for (i = 0; i < synth.nodeList.nodes.length; i++) { 32 | ugen = synth.nodeList.nodes[i]; 33 | if (ugen.id !== "audio-only") { // TODO: Craziness. 34 | ugen.rate = rate; 35 | } 36 | } 37 | 38 | // And then whip through again and poke everyone to update their input assumptions. 39 | for (i = 0; i < synth.nodeList.nodes.length; i++) { 40 | ugen = synth.nodeList.nodes[i]; 41 | ugen.onInputChanged(); 42 | } 43 | 44 | return synth; 45 | }, 46 | 47 | test: function (synth) { 48 | for (var i = 0; i < numSampleBlocks; i++) { 49 | flock.evaluate.synth(synth); 50 | } 51 | } 52 | }; 53 | }; 54 | 55 | flock.test.timeSynthDefs = function (name, synthDefs, rates, numSampleBlocks) { 56 | var testSpecs = [], 57 | testSpec, 58 | i, 59 | rate, 60 | j; 61 | 62 | if (!flock.isIterable(synthDefs)) { 63 | synthDefs = [synthDefs]; 64 | } 65 | 66 | if (!flock.isIterable(rates)) { 67 | rates = [rates]; 68 | } 69 | 70 | for (i = 0; i < rates.length; i++) { 71 | rate = rates[i]; 72 | 73 | for (j = 0; j < synthDefs.length; j++) { 74 | testSpec = makeSynthDefTestSpec(synthDefs[j], rate, numSampleBlocks); 75 | testSpec.name = name + " " + rate + " rate."; 76 | testSpecs.push(testSpec); 77 | testSpec.numReps = 200; 78 | testSpec.batchSize = 25; 79 | } 80 | } 81 | 82 | sheep.test(testSpecs, true); 83 | }; 84 | 85 | }()); 86 | -------------------------------------------------------------------------------- /tests/shared/audio/long-triangle-int16-44100.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lichen-community-systems/Flocking/0b023ea4bfbf5ef3c089f2f1736ad9910d912f7b/tests/shared/audio/long-triangle-int16-44100.wav -------------------------------------------------------------------------------- /tests/shared/audio/long-triangle-int16-48000.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lichen-community-systems/Flocking/0b023ea4bfbf5ef3c089f2f1736ad9910d912f7b/tests/shared/audio/long-triangle-int16-48000.wav -------------------------------------------------------------------------------- /tests/shared/audio/long-triangle-int16-88200.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lichen-community-systems/Flocking/0b023ea4bfbf5ef3c089f2f1736ad9910d912f7b/tests/shared/audio/long-triangle-int16-88200.wav -------------------------------------------------------------------------------- /tests/shared/audio/long-triangle-int16-96000.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lichen-community-systems/Flocking/0b023ea4bfbf5ef3c089f2f1736ad9910d912f7b/tests/shared/audio/long-triangle-int16-96000.wav -------------------------------------------------------------------------------- /tests/unit/all-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | All Flocking Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 60 | 61 | 62 |
63 |
64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /tests/unit/html/audiofile-decoder-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Audio File Decoder Tests (Flocking) 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |

Audio File JavaScript Decoder Tests

46 |

47 |
48 |

49 |
    50 | 51 | 52 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /tests/unit/html/band-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Flocking Band Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |

    Flocking Band Unit Tests

    49 |

    50 |
    51 |

    52 |
      53 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /tests/unit/html/buffer-ugen-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Buffer Unit Generator Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |

      Buffer Unit Generator Unit Tests

      41 |

      42 |
      43 |

      44 |
        45 | 46 | 47 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /tests/unit/html/bus-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Flocking Bus Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |

        Flocking Bus Unit Tests

        48 |

        49 |
        50 |

        51 |
          52 | 53 | 54 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /tests/unit/html/envelope-ugen-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Envelope Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |

          Envelope Unit Tests

          43 |

          44 |
          45 |

          46 |
            47 | 48 | 49 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/unit/html/envgen-ugen-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | EnvGen Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |

            EnvGen Unit Tests

            44 |

            45 |
            46 |

            47 |
              48 | 49 | 50 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /tests/unit/html/filter-ugen-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Filter Unit Generator Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |

              Filter Unit Generator Unit Tests

              45 |

              46 |
              47 |

              48 |
                49 | 50 | 51 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /tests/unit/html/osc-ugen-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Oscillator Unit Generator Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |

                Oscillator Unit Generator Unit Tests

                44 |

                45 |
                46 |

                47 |
                  48 | 49 | 50 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /tests/unit/html/perf-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Performance Tests (Flocking) 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |

                  Performance Tests (Flocking)

                  43 |

                  44 |
                  45 |

                  46 |
                    47 | 48 | 49 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/unit/html/playbuffer-ugen-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PlayBuffer Unit Generator Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |

                    PlayBuffer Unit Generator Unit Tests

                    43 |

                    44 |
                    45 |

                    46 |
                      47 | 48 | 49 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/unit/html/random-ugen-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Random Unit Generator Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |

                      Random Unit Generator Unit Tests

                      44 |

                      45 |
                      46 |

                      47 |
                        48 | 49 | 50 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /tests/unit/html/require-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Require/AMD Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |

                        Require/AMD Unit Tests

                        17 |

                        18 |
                        19 |

                        20 |
                          21 | 22 | 23 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /tests/unit/html/scheduler-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Scheduler Unit Tests (Flocking) 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |

                          Flocking Scheduler Unit Tests

                          43 |

                          44 |
                          45 |

                          46 |
                            47 | 48 | 49 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/unit/html/scheduler-timing-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Scheduler Timing Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |

                            Scheduler Timing Unit Tests

                            42 |

                            43 |
                            44 |

                            45 |
                              46 | 47 | 48 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /tests/unit/html/synth-environment-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Synth Environment Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |

                              Synth Environment Unit Tests

                              49 |

                              50 |
                              51 |

                              52 |
                                53 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /tests/unit/html/synth-group-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Synth Group Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |

                                Synth Group Unit Tests

                                49 |

                                50 |
                                51 |

                                52 |
                                  53 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /tests/unit/html/synth-instantiation-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Synth Instantation Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |

                                  Synth Instantiation Unit Tests

                                  49 |

                                  50 |
                                  51 |

                                  52 |
                                    53 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /tests/unit/html/synth-note-target-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Synth Note Target Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |

                                    Synth Note Target Unit Tests

                                    49 |

                                    50 |
                                    51 |

                                    52 |
                                      53 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /tests/unit/html/synth-removal-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Synth Environment Removal Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |

                                      Synth Environment Removal Unit Tests

                                      49 |

                                      50 |
                                      51 |

                                      52 |
                                        53 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /tests/unit/html/synth-scheduled-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Scheduled Synth Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |

                                        Scheduled Synth Unit Tests

                                        47 |

                                        48 |
                                        49 |

                                        50 |
                                          51 | 52 | 53 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /tests/unit/html/synth-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Synth Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |

                                          Synth Unit Tests

                                          49 |

                                          50 |
                                          51 |

                                          52 |
                                            53 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /tests/unit/html/test-utils-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Flocking Test Utilities Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |

                                            Flocking Test Utilities Tests

                                            41 |

                                            42 |
                                            43 |

                                            44 |
                                              45 | 46 | 47 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /tests/unit/html/writebuffer-ugen-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | WriteBuffer Unit Generator Unit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |

                                              WriteBuffer Unit Generator Unit Tests

                                              42 |

                                              43 |
                                              44 |

                                              45 |
                                                46 | 47 | 48 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /tests/unit/js/dynamics-ugen-tests.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Flocking Dynamics Unit Generator Tests 3 | * https://github.com/continuing-creativity/flocking 4 | * 5 | * Copyright 2011-2017, Colin Clark 6 | * Dual licensed under the MIT or GPL Version 2 licenses. 7 | */ 8 | 9 | /*global require*/ 10 | 11 | var fluid = fluid || require("infusion"), 12 | jqUnit = jqUnit || fluid.require("node-jqunit"), 13 | flock = fluid.registerNamespace("flock"); 14 | 15 | (function () { 16 | "use strict"; 17 | 18 | var QUnit = fluid.registerNamespace("QUnit"); 19 | 20 | var module = flock.test.module({ 21 | name: "Normalizer" 22 | }); 23 | 24 | QUnit.test("flock.ugen.normalize()", function () { 25 | var testBuffer = flock.test.ascendingBuffer(64, -31), 26 | mock = { 27 | ugen: "flock.test.ugen.mock", 28 | options: { 29 | buffer: testBuffer 30 | } 31 | }; 32 | 33 | var normalizerSynth = flock.synth({ 34 | synthDef: { 35 | id: "normalizer", 36 | ugen: "flock.ugen.normalize", 37 | inputs: { 38 | source: { 39 | ugen: "flock.ugen.sum", 40 | inputs: { 41 | sources: [mock, mock] 42 | } 43 | }, 44 | max: 1.0 45 | } 46 | } 47 | }); 48 | 49 | var normalizer = normalizerSynth.nodeList.namedNodes.normalizer; 50 | flock.evaluate.synth(normalizerSynth); 51 | 52 | var expected = flock.normalize(flock.test.ascendingBuffer(64, -31), 1.0); 53 | QUnit.deepEqual(normalizer.output, expected, 54 | "The signal should be normalized to 1.0."); 55 | 56 | normalizer.set("max", 0.5); 57 | normalizer.gen(64); 58 | expected = flock.normalize(flock.test.ascendingBuffer(64, -31), 0.5); 59 | QUnit.deepEqual(normalizer.output, expected, 60 | "When the 'max' input is changed to 0.5, the signal should be normalized to 0.5"); 61 | }); 62 | 63 | module.destroy(); 64 | }()); 65 | -------------------------------------------------------------------------------- /tests/unit/js/ioc-integration-tests.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Flocking IoC Integration Tests 3 | * https://github.com/continuing-creativity/flocking 4 | * 5 | * Copyright 2011-2015, Colin Clark 6 | * Dual licensed under the MIT or GPL Version 2 licenses. 7 | */ 8 | 9 | /*global require*/ 10 | 11 | var fluid = fluid || require("infusion"), 12 | jqUnit = jqUnit || fluid.require("node-jqunit"), 13 | flock = fluid.registerNamespace("flock"); 14 | 15 | (function () { 16 | "use strict"; 17 | 18 | var QUnit = fluid.registerNamespace("QUnit"); 19 | 20 | QUnit.test("Destroying a synth with an IoC-configured Environment", function () { 21 | QUnit.expect(3); 22 | fluid.defaults("flock.test.synthAndEnviroParent", { 23 | gradeNames: "fluid.component", 24 | 25 | components: { 26 | enviro: { 27 | type: "flock.silentEnviro" 28 | }, 29 | 30 | synth: { 31 | type: "flock.synth", 32 | options: { 33 | synthDef: { 34 | ugen: "flock.ugen.sinOsc" 35 | } 36 | } 37 | } 38 | } 39 | }); 40 | 41 | var parent = flock.test.synthAndEnviroParent(); 42 | 43 | try { 44 | parent.destroy(); 45 | QUnit.equal(parent.synth.lifecycleStatus, "destroyed", 46 | "The synth was successfully destroyed."); 47 | 48 | QUnit.equal(parent.enviro.lifecycleStatus, "destroyed", 49 | "The enviro was successfully destroyed."); 50 | 51 | QUnit.equal(parent.lifecycleStatus, "destroyed", 52 | "The parent component was successfully destroyed."); 53 | } catch (e) { 54 | QUnit.ok(false, "An exception was thrown while attempting to destroy a parent component containing " + 55 | "both an enviro and a synth."); 56 | } 57 | }); 58 | }()); 59 | -------------------------------------------------------------------------------- /tests/unit/js/require-tests.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Flocking Module Require Tests 3 | * https://github.com/continuing-creativity/flocking 4 | * 5 | * Copyright 2013-16, Colin Clark 6 | * Dual licensed under the MIT or GPL Version 2 licenses. 7 | */ 8 | 9 | /*global require, QUnit*/ 10 | 11 | (function () { 12 | "use strict"; 13 | 14 | // Simulate a full-on require environment. 15 | window.module = { 16 | exports: {} 17 | }; 18 | 19 | require.config({ 20 | paths: { 21 | jquery: "../../../node_modules/jquery/dist/jquery" 22 | } 23 | }); 24 | 25 | var flockingBuildPath = "../../../dist/flocking-no-jquery"; 26 | 27 | QUnit.module("Require.js AMD tests"); 28 | 29 | QUnit.asyncTest("Flocking is defined and populated using the AMD style", function () { 30 | require([flockingBuildPath], function (flock) { 31 | QUnit.ok(flock, "The 'flock' variable should be defined"); 32 | 33 | var environment = flock.init(); 34 | QUnit.ok(environment, "The shared environment can successfully be initialized."); 35 | 36 | var synth = flock.synth({ 37 | synthDef: { 38 | ugen: "flock.ugen.impulse" 39 | } 40 | }); 41 | 42 | QUnit.ok(synth, "A synth can be correct instantiated."); 43 | 44 | environment.play(); 45 | environment.stop(); 46 | 47 | QUnit.start(); 48 | }); 49 | }); 50 | 51 | }()); 52 | -------------------------------------------------------------------------------- /tests/unit/js/synth-scheduled-tests.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Flocking Framerate Synth Tests 3 | * https://github.com/continuing-creativity/flocking 4 | * 5 | * Copyright 2011-2017, Colin Clark 6 | * Dual licensed under the MIT or GPL Version 2 licenses. 7 | */ 8 | 9 | /*global require*/ 10 | 11 | var fluid = fluid || require("infusion"), 12 | jqUnit = jqUnit || fluid.require("node-jqunit"), 13 | flock = fluid.registerNamespace("flock"); 14 | 15 | (function () { 16 | "use strict"; 17 | 18 | var QUnit = fluid.registerNamespace("QUnit"); 19 | 20 | QUnit.module("Scheduled Synth"); 21 | 22 | QUnit.test("Frame rate synth gets set up with the correct scheduled rate", function () { 23 | var s = flock.synth.frameRate({ 24 | fps: 60, 25 | 26 | synthDef: { 27 | id: "oscillator", 28 | ugen: "flock.ugen.sin", 29 | freq: 1 30 | } 31 | }); 32 | 33 | QUnit.equal(s.audioSettings.rates.scheduled, 60, 34 | "The frame rate should have been specified as the synth's scheduled rate."); 35 | QUnit.equal(s.get("oscillator").model.sampleRate, 60, 36 | "The unit generator should have its sample rate set to 60 fps."); 37 | }); 38 | 39 | }()); 40 | -------------------------------------------------------------------------------- /tests/unit/testem.json: -------------------------------------------------------------------------------- 1 | { 2 | "test_page": "tests/unit/all-tests.html", 3 | "timeout": 300, 4 | "skip": "PhantomJS,IE,Headless Chrome", 5 | "browser_args": { 6 | "Chrome": [ 7 | "--autoplay-policy=no-user-gesture-required" 8 | ], 9 | "Chrome Canary": [ 10 | "--autoplay-policy=no-user-gesture-required" 11 | ] 12 | } 13 | } 14 | --------------------------------------------------------------------------------