diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 76c84a024..5b41aa3d2 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -18,7 +18,14 @@ 4000, // Live reload server 35729 - ] + ], + "customizations": { + "vscode": { + "extensions": [ + "ms-azuretools.vscode-azureappservice" + ] + } + } // Uncomment the next line to run commands after the container is created. // "postCreateCommand": "jekyll --version" diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 000000000..fa1a200f9 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,51 @@ +Purpose +Provide focused, repository-specific guidance to Copilot sessions so suggestions and edits respect build, test, and release flows for this repo. + +Build / Run / Test / Lint (how to run locally) +- Dev site (Jekyll): inside the devcontainer or any environment with Ruby and Bundler installed: + - Install gems: bundle install + - Build & serve locally: bundle exec jekyll serve + - Open: http://localhost:4000/containers.dev/ + +- YAML lint used in CI for the collection index: + - Run locally: yamllint -c .github/lint-config.yaml _data/collection-index.yml + +- Images smoke tests & helpers (images/): + - Smoke/test script: images/.github/actions/smoke-test/test.sh [size-threshold-gb] + - Image linting helpers live under images/.github/linters (shellcheck, hadolint, eslint configs). + +High-level architecture (big picture) +- Static website (Jekyll): root holds site pages, layouts, _data, _config.yml and publishes to GitHub Pages. +- images/ (dev container images): a sibling project with reusable Docker-based development images under images/src/*, manifests, test-projects, and CI workflows to build/publish images. +- CI: .github/workflows contains checks for linting the collection index and publish workflows. images/ contains many image-specific workflows (smoke tests, release/push workflows). + +Key conventions and patterns +- Image manifests: images/src/*/manifest.json is authoritative for image versions and variant metadata. Any image change must bump manifest.json using semantic versioning. + - Major bump: breaking changes (e.g., base OS change). + - Minor bump: new non-breaking features. + - Patch bump: bug/security fixes. + - When adding a variant, update manifest.json: add variant to variants and build.architectures, update variantTags, and set build.latest to the appropriate tag unless the variant is a preview. +- README sync: when manifest or default tags change, update the image README and variant tables to match manifest.json. +- Dockerfile authoring: prefer combining steps in RUN with && and cleanup in the same RUN to reduce image layer size (see images/ README and docs/TIPS.md). +- Devcontainer usage: many images include a .devcontainer and test-project/ to validate the image via devcontainer exec; smoke-test scripts expect test-project/test.sh. +- collection-index.yml is strictly linted in CI; follow .github/lint-config.yaml rules. + +Where to look for more context +- README.md at repo root for local dev/Jekyll instructions. +- images/README.md and images/src/* for image-specific guidance, manifests and test-project layouts. +- images/.github/linters and images/.github/actions for scripts and linter configs used by CI. + +Notes for Copilot agents +- For edits that change an image, ensure manifest.json version bump and README update are included in the same PR. +- For changes to _data/collection-index.yml, run yamllint with .github/lint-config.yaml and aim to keep CI yamllint output clean. +- When suggesting Dockerfile changes, prefer consolidated RUN lines and avoid introducing unnecessary layers. + +Files consulted while authoring these instructions +- README.md +- images/README.md +- images/.github/copilot-instructions.md +- .github/workflows/lint.yml +- .github/lint-config.yaml +- images/.github/actions/smoke-test/test.sh + +Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> \ No newline at end of file diff --git a/.vscode/mcp.json b/.vscode/mcp.json new file mode 100644 index 000000000..09f8e643f --- /dev/null +++ b/.vscode/mcp.json @@ -0,0 +1,14 @@ +{ + "servers": { + "io.github.vercel/next-devtools-mcp": { + "type": "stdio", + "command": "npx", + "args": [ + "next-devtools-mcp@0.3.6" + ], + "gallery": "https://api.mcp.github.com", + "version": "0.3.6" + } + }, + "inputs": [] +} \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 248f60257..214c4f7b7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -205,12 +205,14 @@ GEM rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) mercenary (0.3.6) + mini_portile2 (2.8.9) minima (2.5.1) jekyll (>= 3.5, < 5.0) jekyll-feed (~> 0.9) jekyll-seo-tag (~> 2.1) minitest (5.18.0) - nokogiri (1.14.3-x86_64-linux) + nokogiri (1.14.3) + mini_portile2 (~> 2.8.0) racc (~> 1.4) octokit (4.25.1) faraday (>= 1, < 3) @@ -262,7 +264,7 @@ DEPENDENCIES webrick (~> 1.7) RUBY VERSION - ruby 3.2.2p53 + ruby 3.4.9p82 BUNDLED WITH 2.4.10 diff --git a/devcontainers.github.io b/devcontainers.github.io new file mode 160000 index 000000000..3a2875072 --- /dev/null +++ b/devcontainers.github.io @@ -0,0 +1 @@ +Subproject commit 3a28750727c23300ca71f23ef914d8da33cc5fce diff --git a/images b/images new file mode 160000 index 000000000..31b61b521 --- /dev/null +++ b/images @@ -0,0 +1 @@ +Subproject commit 31b61b521d55926d62c748b659f24ae71774c0e3 diff --git a/rsa---key b/rsa---key new file mode 100644 index 000000000..be9e71ebd --- /dev/null +++ b/rsa---key @@ -0,0 +1,8 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABASvNn4+e +OsbP20b1hJT7nZAAAAEAAAAAEAAAAzAAAAC3NzaC1lZDI1NTE5AAAAIFKVDyJERtweg6jm +y73p2hsuiugbENFTe0R/p14YRfVwAAAAoPOu0jcPNOD2TTV2Y6VLwJE/BHhhKT4rPGh9zr +DL/Eqi3EqL/HGoURYbNHCInXL757U5qVd22bu+30anePbABJafgbSSBb1ovhKwKBf3nRRO +zhJEWDESbPhMuRLna/PQpbtqdXMxUtl55UmvfUXzsOJUL+dGT0PI34Wmmt5B0JGpjnASZV +FRrz7CuY9Rr1hhRuNW+Z09vrQDC2ocY5Sx5rM= +-----END OPENSSH PRIVATE KEY----- diff --git a/rsa---key.pub b/rsa---key.pub new file mode 100644 index 000000000..f5ca77315 --- /dev/null +++ b/rsa---key.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFKVDyJERtweg6jmy73p2hsuiugbENFTe0R/p14YRfVw ackermadh@gmail diff --git a/rsa---kp b/rsa---kp new file mode 100644 index 000000000..c933261a7 --- /dev/null +++ b/rsa---kp @@ -0,0 +1,50 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABAs+BzZsT +qKOIVkKxaU0CV4AAAAEAAAAAEAAAIXAAAAB3NzaC1yc2EAAAADAQABAAACAQDmhiNQnTnw +Sy2YEPvHj7T00KfjWyPp51S9rUNLxaDE1rrQ40YA4r/Q7Vau1/RDUqfhU9ToYJDmCfT4Yr +aB1IvCuQOfbwHL3GKldse7YmQ0KFFYaVrsViE+Cs25YBWtpPmLuWcL92UylmE1C6IImZG5 +5EgSDuDqA089FfD1ValYcGqQe21/NNnH9raIWkJkRrc9VMTcITFpTWfDrGNa7m9qNlq99M +zxp4sLxGLOUbWq/vih+qTS8TkTZd00NJcKumSvZZDaUBhfXvHgdmTfWitMx+8EKtuDTHU1 +r5StsfaOgvC90T46T3qHNV7FeKKxRWDcaiwSzcQqsy+sKRxtfiXMUk+Bu9YOLzpXN81DLx +yfTMforNCCIwo8oLrYj32NxoIn5LU8CrO+K1Idk6AcbLzzxTvkJlqrB531kEE7ia7KeVPA +fxSglmsqyD2iQiIH6w/fcZEJoDEUQySYInwrH0GLnFmXQiMCdrB09xnVcMYGCcZcVAmdLh +0xc1rZZOlJSXBYD8hr1iMf/0yrVXA/rJlzepzOlEaD7xKdyHXndSLoVo3IolW5MoEva5hr +C6IjuOwwB5dU5K/2DZlKR7oOO9n8NFPVe+HT5xUhB7Cz7WicZUondPaqdgVD/us/hbczso +8lLrLUIFepbr0AsrqPjde5BhalKUTWfvNVA1Ked8dVLwAAB1D77xu1t1abmebNXC/XHX0P +6EVOc5WXAhERdl4rPiEYV6qAInNj/D1PfjMYNc+4S6uhVPJHqIXDecSSzPVmsrSS9gbfa1 +JJx4Qn7XLPEQbggc4DtqSKlX28vTCkk5rvGFM5GCyYC1r0Ff5cE8DZSW6SWc5arDkWiWMl +/ae12GEnq6TK74aCrZZrByJJZR532XOih6d+kpmDYfD6Xs51uyovLoJzw5Q8dmE2zgL+2M +qHcs7xv5Lyw6CGgh6spvjVYntnG768uJQZGRA1K7Jy0OkWggdYMc1yUwocQ/IaHcY2ImKg +CTRlhjC6gmK2t0FE7f/ItBlwbRqMbzWbjUpY8fIe4BeWFuWSPyQxlHWEdMYqga/IBXQHLe +xniGTvplr1d8iI06H2P/c1T3XCPPlmos/GWyG5Z5F4KFwWEWwlGCLW5qgEnL9GDIV22Q5/ +iTDtIzj3BJ9lO1/uC8vsEEUlzXoFfogBEaZn+l1NaM/LekqZsCOztZP0S0o+lrkeK8B0Sr +aUAC6PKWBet/waB3XoebU7QEQwVzKxYS4NSH1AMcNC5bDJDnvI+TzBO+EiaZ+VLKxa22U6 +ms/r7KixwZtjo5EbtOTjGfxY1AvKBGWHeBGd7/Mcu/0Mi+D6kZsZVjnWkW+UfHZr4+9nwb +hXwmvJKvDEojPywQAfG86f2coeajvplVBTdY/O5C8KBpbNZcZHxHtCCx92nYGLpeWyfh+u +pgO0X/MshpiGT7HmbyMQ7JV0PnULCgWkE3xxSYkoNx98SEzvVO4vnCX7GAjJohrRK8C9i6 +3CERZlE9NZfqIN4eUIYNYl4Wdj8AhoogoGk5qaEVUGyY3QWAQOrgfmi1LxblSaecbE3Mwr +RjKboj0z7kciHE0v5yiM1GZ8a15XNz0k844Vlx15D6i+Er54kIRsx7hUyIqHvw8WlCqaOw +vJwPGb1fLo+dpbnvvrrwjsUicfVMx+1LzzlhMcwODCLObsdc0CssTchxvOYTikDCFDMhUy +wu/njPW4NG0KVHe9SZzEjPUf1MKja8go6yXkPM1eO6i2uckBWCkvF3WpEbNFrDzjVIQrCl +WFj4urQTFB6LH2l7lX+MUSOYw0LAWKrLl8V4/9b84iGJjMxatEoaNuMwDPDi5EVF5fQIDh +2bb0xhOnqAeKyglI2KBeXBVSI2Ks2gGiWjiWQnOp/ww9kuRS/X5HfxcZW6ihPrwFeOQn01 +xS7OFaup1/CqnVs62IyrEqU0b6y5zWvm3wHfP/CV7TTV/66eYYCuVUmPDQEwzvRVRxRwWQ +MKmebKsm6OGfJ++mq09GT7V+O8U31j7Dg+BGVhQQNHJb4LfxhUh5k7sSbK7eHXsLR4v1VP +33QYQNrM682ic4ut0Ile5UYPTscvlLECMaEQ4iTRiNYptadAci9k7R35jPtSKKgX/tyTTa +SML1m3z3O1YM6/qrdhHsoxaaeYGOeufiHBMciZ8OvWCPRvARtGtHOkQUIKPyHGOoYUm25R +XkoRC6iVlVMXej+lJyzsh9UuoEqmzGjwd0fdXYvjafMtmlwnycEmEUirO7nOXjItrvl/E7 +iTETYnyRVb26Za8YQwccW/31vTFmi2/pCUEKd1GeE3kxSfCbVmsLn1J+teKpJ/Fk3qx6/j +HksDoBlXvCGZGgBIJGPRYixsMPgCE5g/cz2UF4lTOFsslq1GYbGgJa0XzdiNWC4AUiFdfI +Zjx47dlqgp27+JxB8TT0TU0HFkkDiBvxtvgefX0ohW70ydcliPVakwN0BCk3VtYQvZLnZn +GKjXq1OV1pRI2r557SRnDvR4wEOXMjC4o1WhwMYmhuAuXNqfMf7yZ7D9If4vl8Ddnc5nwP +mJMXXVx04tJxrlYYTHMJ0g0tJzk0yM+Od+artnOqtEBA3H8qJ39MHlIvwi5XXKhLdm58j8 +c7g/W7tCmJXnvI3NM+9j7eEzjX2nrCKoFFDE9yQVyOYa+Q1ChzmawZSggqXH77LpYspe1J +S4jwaDkpDc2JWQgmPHzcxo2OC0w+Qea27WMIMk0i6g+rAFcuHT7K3J0qV1e+05kCAo9BHD +KeiWkitut2L1GJ4P8mvsGFimif8G8W+5AzhIOXUoQN9yUl9mMaCtzkrK3hB71dqK60FdvQ +HOD7mqgLYlPgmbEHI2wsfMbudJ+B7VsRdzAPSgspRlBgpVAp9zr9T5vZGzx+mlGYtA6Jb8 +Lyp1MdVydUOq1IqTTLdgwfuzAyu+ZKk2h3ibJPgB0XlCsKwC0AV1F4qcbqWXSvJSrwp83B +kID4ik5MROLe4aEl5yIMgtZCzFmioczISh7lxrm+tHAC+feBhbB7yKrCNtTEa8lp9fs3b4 +HfK0d2+noMRS1+jHpPI1CbOYc/8sbc4J7wEQ3USWbIN9vucDuXZrfgXZ3Ou78VULs6GJI/ +Vh5X02fYGNADL7BZg+pVdqNkGPYujmSNM3nd+/7ghUFcXyFd4rw8m+EYbEaqFP1sHZEvmF +Gb5vf8lNa2XvXK7vUIw8j5WgY= +-----END OPENSSH PRIVATE KEY----- diff --git a/rsa---kp.pub b/rsa---kp.pub new file mode 100644 index 000000000..ce16bc48a --- /dev/null +++ b/rsa---kp.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDmhiNQnTnwSy2YEPvHj7T00KfjWyPp51S9rUNLxaDE1rrQ40YA4r/Q7Vau1/RDUqfhU9ToYJDmCfT4YraB1IvCuQOfbwHL3GKldse7YmQ0KFFYaVrsViE+Cs25YBWtpPmLuWcL92UylmE1C6IImZG55EgSDuDqA089FfD1ValYcGqQe21/NNnH9raIWkJkRrc9VMTcITFpTWfDrGNa7m9qNlq99Mzxp4sLxGLOUbWq/vih+qTS8TkTZd00NJcKumSvZZDaUBhfXvHgdmTfWitMx+8EKtuDTHU1r5StsfaOgvC90T46T3qHNV7FeKKxRWDcaiwSzcQqsy+sKRxtfiXMUk+Bu9YOLzpXN81DLxyfTMforNCCIwo8oLrYj32NxoIn5LU8CrO+K1Idk6AcbLzzxTvkJlqrB531kEE7ia7KeVPAfxSglmsqyD2iQiIH6w/fcZEJoDEUQySYInwrH0GLnFmXQiMCdrB09xnVcMYGCcZcVAmdLh0xc1rZZOlJSXBYD8hr1iMf/0yrVXA/rJlzepzOlEaD7xKdyHXndSLoVo3IolW5MoEva5hrC6IjuOwwB5dU5K/2DZlKR7oOO9n8NFPVe+HT5xUhB7Cz7WicZUondPaqdgVD/us/hbczso8lLrLUIFepbr0AsrqPjde5BhalKUTWfvNVA1Ked8dVLw== ackermadh@gmail diff --git a/web.archive.org/web/20150828053525cs_/http:/fonts.googleapis.com/css?family=EB+Garamond|Montserrat.css b/web.archive.org/web/20150828053525cs_/http:/fonts.googleapis.com/css?family=EB+Garamond|Montserrat.css new file mode 100644 index 000000000..8a43839cd --- /dev/null +++ b/web.archive.org/web/20150828053525cs_/http:/fonts.googleapis.com/css?family=EB+Garamond|Montserrat.css @@ -0,0 +1,70 @@ +/* cyrillic-ext */ +@font-face { + font-family: 'EB Garamond'; + font-style: normal; + font-weight: 400; + src: local('EB Garamond'), local('EBGaramond'), url(https://web.archive.org/web/20150816200228im_/http://fonts.gstatic.com/s/ebgaramond/v7/kYZt1bJ8UsGAPRGnkXPeFTTOQ_MqJVwkKsUn0wKzc2I.woff2) format('woff2'); + unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; +} +/* cyrillic */ +@font-face { + font-family: 'EB Garamond'; + font-style: normal; + font-weight: 400; + src: local('EB Garamond'), local('EBGaramond'), url(https://web.archive.org/web/20150816200228im_/http://fonts.gstatic.com/s/ebgaramond/v7/kYZt1bJ8UsGAPRGnkXPeFTUj_cnvWIuuBMVgbX098Mw.woff2) format('woff2'); + unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; +} +/* vietnamese */ +@font-face { + font-family: 'EB Garamond'; + font-style: normal; + font-weight: 400; + src: local('EB Garamond'), local('EBGaramond'), url(https://web.archive.org/web/20150816200228im_/http://fonts.gstatic.com/s/ebgaramond/v7/kYZt1bJ8UsGAPRGnkXPeFb6up8jxqWt8HVA3mDhkV_0.woff2) format('woff2'); + unicode-range: U+0102-0103, U+1EA0-1EF1, U+20AB; +} +/* latin-ext */ +@font-face { + font-family: 'EB Garamond'; + font-style: normal; + font-weight: 400; + src: local('EB Garamond'), local('EBGaramond'), url(https://web.archive.org/web/20150816200228im_/http://fonts.gstatic.com/s/ebgaramond/v7/kYZt1bJ8UsGAPRGnkXPeFSYE0-AqJ3nfInTTiDXDjU4.woff2) format('woff2'); + unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: 'EB Garamond'; + font-style: normal; + font-weight: 400; + src: local('EB Garamond'), local('EBGaramond'), url(https://web.archive.org/web/20150816200228im_/http://fonts.gstatic.com/s/ebgaramond/v7/kYZt1bJ8UsGAPRGnkXPeFY4P5ICox8Kq3LLUNMylGO4.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; +} +/* latin */ +@font-face { + font-family: 'Montserrat'; + font-style: normal; + font-weight: 400; + src: local('Montserrat-Regular'), url(https://web.archive.org/web/20150816200228im_/http://fonts.gstatic.com/s/montserrat/v6/zhcz-_WihjSQC0oHJ9TCYPk_vArhqVIZ0nv9q090hN8.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; +} + +/* + FILE ARCHIVED ON 20:02:28 Aug 16, 2015 AND RETRIEVED FROM THE + INTERNET ARCHIVE ON 03:39:56 Jun 07, 2026. + JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. + + ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. + SECTION 108(a)(3)). +*/ +/* +playback timings (ms): + capture_cache.get: 0.427 + captures_list: 0.443 + exclusion.robots: 0.05 + exclusion.robots.policy: 0.042 + esindex: 0.006 + cdx.remote: 4.64 + LoadShardBlock: 92.293 (3) + PetaboxLoader3.datanode: 61.609 (4) + PetaboxLoader3.resolve: 70.913 (2) + load_resource: 81.273 +*/ \ No newline at end of file diff --git a/web.archive.org/web/20150828053525cs_/http:/void.hi-res.net/css/app.min.0.0.0.css b/web.archive.org/web/20150828053525cs_/http:/void.hi-res.net/css/app.min.0.0.0.css new file mode 100644 index 000000000..ab35b1fb2 --- /dev/null +++ b/web.archive.org/web/20150828053525cs_/http:/void.hi-res.net/css/app.min.0.0.0.css @@ -0,0 +1,16 @@ +a,abbr,acronym,address,applet,big,blockquote,body,caption,cite,code,dd,del,dfn,div,dl,dt,em,fieldset,form,h1,h2,h3,h4,h5,h6,html,iframe,img,ins,kbd,label,legend,li,object,ol,p,pre,q,s,samp,small,span,strike,strong,sub,sup,table,tbody,td,tfoot,th,thead,tr,tt,ul,var{margin:0;padding:0;border:0;outline:0;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:100%;vertical-align:baseline}body{line-height:1;color:#000;background:#fff}ol,ul{list-style:none}table{border-collapse:separate;border-spacing:0;vertical-align:middle}caption,td,th{text-align:left;font-weight:400;vertical-align:middle}a img{border:none}html.hires_void{font-size:62.5%}html.hires_void a,html.hires_void abbr,html.hires_void acronym,html.hires_void address,html.hires_void applet,html.hires_void big,html.hires_void blockquote,html.hires_void body,html.hires_void caption,html.hires_void cite,html.hires_void code,html.hires_void dd,html.hires_void del,html.hires_void dfn,html.hires_void div,html.hires_void dl,html.hires_void dt,html.hires_void em,html.hires_void fieldset,html.hires_void form,html.hires_void h1,html.hires_void h2,html.hires_void h3,html.hires_void h4,html.hires_void h5,html.hires_void h6,html.hires_void html,html.hires_void iframe,html.hires_void img,html.hires_void ins,html.hires_void kbd,html.hires_void label,html.hires_void legend,html.hires_void li,html.hires_void object,html.hires_void ol,html.hires_void p,html.hires_void pre,html.hires_void q,html.hires_void s,html.hires_void samp,html.hires_void small,html.hires_void span,html.hires_void strike,html.hires_void strong,html.hires_void sub,html.hires_void sup,html.hires_void table,html.hires_void tbody,html.hires_void td,html.hires_void tfoot,html.hires_void th,html.hires_void thead,html.hires_void tr,html.hires_void tt,html.hires_void ul,html.hires_void var{margin:0;padding:0;border:0;outline:0;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:100%;vertical-align:baseline}html.hires_void ol,html.hires_void ul{list-style:none}html.hires_void table{border-collapse:separate;border-spacing:0;vertical-align:middle}html.hires_void caption,html.hires_void td,html.hires_void th{text-align:left;font-weight:400;vertical-align:middle}html.hires_void a img{border:none}html.hires_void *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-font-smoothing:antialiased}html.hires_void .cf{zoom:1}html.hires_void .cf:after,html.hires_void .cf:before{content:"";display:table}html.hires_void .cf:after{clear:both}html.hires_void body{background:#000;overflow:hidden}html.hires_void img{max-width:100%}html.hires_void body{font-family:"EB Garamond",sans-serif;font-size:1.4rem;line-height:2.24rem;color:#fff}html.hires_void h1{background-image:url(https://web.archive.org/web/20150827154554im_/http://void.hi-res.net/img/svg/HIRES_LOGO.svg);background-repeat:no-repeat;-webkit-background-size:100%;-moz-background-size:100%;background-size:100%;top:7%;left:50%;width:106px;width:10.6rem;height:50px;height:5rem;margin-top:-2.5rem;margin-left:-5.3rem}html.hires_void h1 a{width:10.6rem;height:5rem;display:block}@media only screen and (max-width:767px){html.hires_void h1{top:10%}}html.hires_void h2{font-size:2rem;line-height:3.2rem}html.hires_void h3{font-size:3rem;line-height:4.8rem;letter-spacing:14px;letter-spacing:1.4rem}html.hires_void h4,html.hires_void h5,html.hires_void h6{font-size:1rem;line-height:1.6rem}html.hires_void h1,html.hires_void h2,html.hires_void h3,html.hires_void h4,html.hires_void h5,html.hires_void h6{font-family:Montserrat}html.hires_void a{color:#fff;text-decoration:none}html.hires_void dd,html.hires_void dt,html.hires_void p{font-size:1.7rem;line-height:2.72rem;line-height:18px;line-height:1.8rem}@media only screen and (max-width:767px){html.hires_void dd,html.hires_void dt,html.hires_void p{font-size:1.6rem;line-height:2.56rem;line-height:18px;line-height:1.8rem}}html.hires_void .font-garamond{font-family:'EB Garamond'}html.hires_void .font-montserrat{font-family:Montserrat}html.hires_void .bold{font-weight:700}html.hires_void .caps-text{text-transform:uppercase;letter-spacing:2px;letter-spacing:.2rem}.layer{position:absolute;top:0;left:0}.layer-0{z-index:0}.layer-1{z-index:1}.layer-2{z-index:2}.layer-3{z-index:3}.layer-4{z-index:4}.layer-5{z-index:5}.layer-6{z-index:6}.layer-7{z-index:7}.layer-8{z-index:8}.layer-9{z-index:9}.layer-10{z-index:10}.layer-11{z-index:11}.layer-12{z-index:12}.layer-13{z-index:13}.layer-14{z-index:14}.layer-15{z-index:15}.layer-16{z-index:16}.layer-17{z-index:17}.layer-18{z-index:18}.layer-19{z-index:19}.content{position:relative;width:100%;height:100%}html.hires_void .dg.ac{z-index:10000!important}html.hires_void .dg.ac .hue-field{width:13px!important}@font-face{font-family:'EB Garamond';font-style:normal;font-weight:400;src:local('EB Garamond'),local('EBGaramond'),url(https://web.archive.org/web/20150827154554im_/http://void.hi-res.net/fonts/EBGaramond/kYZt1bJ8UsGAPRGnkXPeFfZraR2Tg8w2lzm7kLNL0-w.woff2) format('woff2');unicode-range:U+0460052F,U+20B4,U+2DE0-2DFF,U+A640-A69F}@font-face{font-family:'EB Garamond';font-style:normal;font-weight:400;src:local('EB Garamond'),local('EBGaramond'),url(https://web.archive.org/web/20150827154554im_/http://void.hi-res.net/fonts/EBGaramond/kYZt1bJ8UsGAPRGnkXPeFV4sYYdJg5dU2qzJEVSuta0.woff2) format('woff2');unicode-range:U+0400045F,U+04900491,U+04B004B1,U+2116}@font-face{font-family:'EB Garamond';font-style:normal;font-weight:400;src:local('EB Garamond'),local('EBGaramond'),url(https://web.archive.org/web/20150827154554im_/http://void.hi-res.net/fonts/EBGaramond/kYZt1bJ8UsGAPRGnkXPeFdDiNsR5a-9Oe_Ivpu8XWlY.woff2) format('woff2');unicode-range:U+01020103,U+1EA0-1EF1,U+20AB}@font-face{font-family:'EB Garamond';font-style:normal;font-weight:400;src:local('EB Garamond'),local('EBGaramond'),url(https://web.archive.org/web/20150827154554im_/http://void.hi-res.net/fonts/EBGaramond/kYZt1bJ8UsGAPRGnkXPeFaE8kM4xWR1_1bYURRojRGc.woff2) format('woff2');unicode-range:U+0100024F,U+1E00-1EFF,U+20A0-20AB,U+20AD-20CF,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:'EB Garamond';font-style:normal;font-weight:400;src:local('EB Garamond'),local('EBGaramond'),url(https://web.archive.org/web/20150827154554im_/http://void.hi-res.net/fonts/EBGaramond/kYZt1bJ8UsGAPRGnkXPeFZQV2lvL5Ba9FjAYK6Lx0Qk.woff2) format('woff2');unicode-range:U+000000FF,U+0131,U+01520153,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2212,U+2215,U+E0FF,U+EFFD,U+F000}@font-face{font-family:Montserrat;font-style:normal;font-weight:400;src:local('Montserrat-Regular'),url(https://web.archive.org/web/20150827154554im_/http://void.hi-res.net/fonts/Montserrat/zhcz-_WihjSQC0oHJ9TCYAsYbbCjybiHxArTLjt7FRU.woff2) format('woff2');unicode-range:U+000000FF,U+0131,U+01520153,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2212,U+2215,U+E0FF,U+EFFD,U+F000}html.hires_void #navigation{top:auto;bottom:0;width:100%;text-align:center;visibility:hidden;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0)}html.hires_void #navigation ul li{display:inline-block;margin:0 1rem}html.hires_void #navigation ul li a{padding:3rem 3rem 2rem;display:block;position:relative}html.hires_void #navigation ul li a.active span.ch,html.hires_void #navigation ul li a:hover span.ch{opacity:1;-ms-filter:none;filter:none}html.hires_void #navigation ul li a:hover span.title{opacity:1;-ms-filter:none;filter:none;letter-spacing:1px}html.hires_void #navigation ul li a span{width:100%;display:inline-block}html.hires_void #navigation ul li a span.ch{-webkit-transition:opacity .17s ease-in;-moz-transition:opacity .17s ease-in;-o-transition:opacity .17s ease-in;-ms-transition:opacity .17s ease-in;transition:opacity .17s ease-in;opacity:.4;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=40)";filter:alpha(opacity=40)}html.hires_void #navigation ul li a span.title{position:absolute;top:0;left:0;-webkit-transition:opacity .5s ease-in .1s,letter-spacing 4s ease .1s;-moz-transition:opacity .5s ease-in .1s,letter-spacing 4s ease .1s;-o-transition:opacity .5s ease-in .1s,letter-spacing 4s ease .1s;-ms-transition:opacity .5s ease-in .1s,letter-spacing 4s ease .1s;transition:opacity .5s ease-in .1s,letter-spacing 4s ease .1s;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0)}html.hires_void #notfound,html.hires_void #unsupported{background:url(https://web.archive.org/web/20150827154554im_/http://void.hi-res.net/img/ui/error-background.jpg) 50% no-repeat;-webkit-background-size:cover;-moz-background-size:cover;background-size:cover;width:100%;height:100%}html.hires_void #notfound .message,html.hires_void #unsupported .message{text-align:center;top:50%;left:50%;width:500px;width:50rem;height:385px;height:38.5rem;margin-left:-25rem;margin-top:-19.25rem}html.hires_void #notfound .message p,html.hires_void #unsupported .message p{margin-bottom:1rem}html.hires_void #notfound .message a,html.hires_void #unsupported .message a{text-decoration:underline}html.hires_void #notfound h2,html.hires_void #unsupported h2{text-align:center;font-size:5rem;line-height:8rem;letter-spacing:15px;letter-spacing:1.5rem}html.hires_void #notfound .the-future,html.hires_void #unsupported .the-future{-webkit-transform:scale(.88);-moz-transform:scale(.88);-o-transform:scale(.88);-ms-transform:scale(.88);transform:scale(.88);position:relative;margin:0 auto;width:293px;width:29.3rem;height:266px;height:26.6rem}html.hires_void #notfound .nyan,html.hires_void #unsupported .nyan{top:18px;top:1.8rem;left:94px;left:9.4rem}@media only screen and (max-width:767px){html.hires_void #notfound h2,html.hires_void #unsupported h2{font-size:2.5rem;line-height:4rem;letter-spacing:5px;letter-spacing:.5rem}html.hires_void #notfound .the-future,html.hires_void #unsupported .the-future{-webkit-transform-origin:50%;-moz-transform-origin:50%;-o-transform-origin:50%;-ms-transform-origin:50%;transform-origin:50%;-webkit-transform:scale(.7);-moz-transform:scale(.7);-o-transform:scale(.7);-ms-transform:scale(.7);transform:scale(.7);height:220px;height:22rem}html.hires_void #notfound .message,html.hires_void #unsupported .message{top:40%;width:300px;width:30rem;height:200px;height:20rem;margin-left:-15rem;margin-top:-10rem}}@media only screen and (max-width:767px) and (max-width:767px) and (orientation:landscape){html.hires_void #notfound .the-future,html.hires_void #unsupported .the-future{-webkit-transform:scale(.3);-moz-transform:scale(.3);-o-transform:scale(.3);-ms-transform:scale(.3);transform:scale(.3);height:120px;height:12rem}}@media only screen and (max-width:767px) and (max-width:767px) and (orientation:landscape){html.hires_void #notfound .message,html.hires_void #unsupported .message{width:400px;width:40rem;height:200px;height:20rem;margin-left:-20rem;margin-top:-10rem}}main.konami{-webkit-animation-name:konami;-moz-animation-name:konami;-o-animation-name:konami;-ms-animation-name:konami;animation-name:konami;-webkit-animation-duration:40s;-moz-animation-duration:40s;-o-animation-duration:40s;-ms-animation-duration:40s;animation-duration:40s;animation-playstate:running;-webkit-animation-iteration-count:infinite;-moz-animation-iteration-count:infinite;-o-animation-iteration-count:infinite;-ms-animation-iteration-count:infinite;animation-iteration-count:infinite}.sticker{position:absolute;top:0;left:0}@-moz-keyframes konami{0%{-webkit-filter:sepia(.5) saturate(100) invert(1) brightness(.8) sepia(.5) saturate(100) hue-rotate(0deg)}100%{-webkit-filter:sepia(.5) saturate(100) invert(1) brightness(.8) sepia(.5) saturate(100) hue-rotate(360deg)}}@-webkit-keyframes konami{0%{-webkit-filter:sepia(.5) saturate(100) invert(1) brightness(.8) sepia(.5) saturate(100) hue-rotate(0deg)}100%{-webkit-filter:sepia(.5) saturate(100) invert(1) brightness(.8) sepia(.5) saturate(100) hue-rotate(360deg)}}@-o-keyframes konami{0%{-webkit-filter:sepia(.5) saturate(100) invert(1) brightness(.8) sepia(.5) saturate(100) hue-rotate(0deg)}100%{-webkit-filter:sepia(.5) saturate(100) invert(1) brightness(.8) sepia(.5) saturate(100) hue-rotate(360deg)}}@keyframes konami{0%{-webkit-filter:sepia(.5) saturate(100) invert(1) brightness(.8) sepia(.5) saturate(100) hue-rotate(0deg)}100%{-webkit-filter:sepia(.5) saturate(100) invert(1) brightness(.8) sepia(.5) saturate(100) hue-rotate(360deg)}}html.hires_void .scene{width:100%;height:100%}html.hires_void .scene .dim{width:100%;height:100%;background:-webkit-radial-gradient(rgba(0,0,0,.7),rgba(0,0,0,0));background:-moz-radial-gradient(rgba(0,0,0,.7),rgba(0,0,0,0));background:-o-radial-gradient(rgba(0,0,0,.7),rgba(0,0,0,0));background:-ms-radial-gradient(rgba(0,0,0,.7),rgba(0,0,0,0));background:radial-gradient(rgba(0,0,0,.7),rgba(0,0,0,0))}html.hires_void .scene .hitarea{width:100%;height:100%;background:rgba(255,0,0,0)}html.hires_void .scene .next{top:auto;left:50%;text-align:center;visibility:hidden;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);width:600px;width:60rem;margin-left:-30rem;bottom:100px;bottom:10rem}html.hires_void .scene .next span{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0)}html.hires_void #home h1{visibility:hidden;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0)}html.hires_void #home h2{top:31.7%;width:100%;text-align:center;font-size:1.4rem;line-height:2.24rem;visibility:hidden;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);letter-spacing:5px;letter-spacing:.5rem}html.hires_void #home .paragraphs{top:52.8%;left:50%;text-align:center;width:460px;width:46rem;margin-left:-23rem}html.hires_void #home .paragraphs p{margin-bottom:2.2rem;letter-spacing:2px;letter-spacing:.2rem}html.hires_void #home .paragraphs span{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);pointer-events:none}html.hires_void #epilogue h1{background:0 0;top:43.5%;left:50%;cursor:pointer;width:200px;width:20rem;height:77px;height:7.7rem;margin-top:-3.85rem;margin-left:-10rem}html.hires_void #epilogue h2{top:31.7%;width:100%;text-align:center;font-size:1.4rem;line-height:2.24rem;visibility:hidden;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);letter-spacing:5px;letter-spacing:.5rem}html.hires_void #epilogue .paragraphs{top:52.8%;left:50%;text-align:center;width:460px;width:46rem;margin-left:-23rem}html.hires_void #epilogue .paragraphs p{margin-bottom:2.2rem;letter-spacing:2px;letter-spacing:.2rem}html.hires_void #epilogue .paragraphs span{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);pointer-events:none}html.hires_void #epilogue .paragraphs dd,html.hires_void #epilogue .paragraphs dt{display:inline-block;width:200px;width:20rem}html.hires_void #epilogue .paragraphs dt{text-align:right;padding-right:1.5rem}html.hires_void #epilogue .paragraphs dd{text-align:left;font-weight:700;padding-left:1.5rem}html.hires_void #epilogue .social{top:74%;left:50%;text-align:center;font-size:2.5rem;line-height:4rem;visibility:hidden;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);width:460px;width:46rem;margin-left:-23rem}html.hires_void #epilogue .social li{display:inline-block;margin:0 1rem;-webkit-transform:scale(.6);-moz-transform:scale(.6);-o-transform:scale(.6);-ms-transform:scale(.6);transform:scale(.6)}html.hires_void #epilogue .social li a{color:grey;display:inline-block;-webkit-transition:all .2s ease-in;-moz-transition:all .2s ease-in;-o-transition:all .2s ease-in;-ms-transition:all .2s ease-in;transition:all .2s ease-in;width:50px;height:50px}html.hires_void #epilogue .social li a:hover{color:#fff}html.hires_void #epilogue .social li a.facebook{background-image:url(https://web.archive.org/web/20150827154554im_/http://void.hi-res.net/img/ui/facebook.png)}html.hires_void #epilogue .social li a.facebook:hover{background-image:url(https://web.archive.org/web/20150827154554im_/http://void.hi-res.net/img/ui/facebook.gif)}html.hires_void #epilogue .social li a.twitter{background-image:url(https://web.archive.org/web/20150827154554im_/http://void.hi-res.net/img/ui/twitter.png)}html.hires_void #epilogue .social li a.twitter:hover{background-image:url(https://web.archive.org/web/20150827154554im_/http://void.hi-res.net/img/ui/twitter.gif)}html.hires_void #epilogue .social li a.googleplus{background-image:url(https://web.archive.org/web/20150827154554im_/http://void.hi-res.net/img/ui/google.png)}html.hires_void #epilogue .social li a.googleplus:hover{background-image:url(https://web.archive.org/web/20150827154554im_/http://void.hi-res.net/img/ui/google.gif)}html.hires_void .dim{visibility:hidden;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0)}html.hires_void .transition_black{width:100%;height:100%;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);background-color:#000}html.hires_void .ui{width:100%;height:100%}html.hires_void .chapter{top:50%;left:50%;text-align:center;width:700px;width:70rem;margin-top:-18.2rem;margin-left:-35rem}html.hires_void .chapter .chapter_index{font-size:1.8rem;line-height:2.88rem;visibility:hidden;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);margin-top:.8rem}html.hires_void .chapter h2{font-size:5rem;line-height:8rem;visibility:hidden;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);margin-top:4rem;margin-bottom:5rem;letter-spacing:22px;letter-spacing:2.2rem}html.hires_void .chapter .about{max-width:60%;margin:0 auto 3.1rem;letter-spacing:2px;letter-spacing:.2rem}html.hires_void .chapter .about span{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0)}html.hires_void .chapter .interactions{text-align:center;visibility:hidden;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0)}html.hires_void .chapter .interactions li{display:inline-block}html.hires_void .chapter .interactions li span{display:block;font-size:1.8rem;margin-top:1.5rem;line-height:20px;line-height:2rem}html.hires_void .chapter .interactions .icon.dragdrop{width:26px;width:2.6rem;height:30px;height:3rem;background-image:url(https://web.archive.org/web/20150827154554im_/http://void.hi-res.net/img/svg/icon_dragdrop.svg);background-repeat:no-repeat;-webkit-background-size:100%;-moz-background-size:100%;background-size:100%;margin:0 auto}html.hires_void .chapter .authors{position:relative;margin-top:3.4rem;visibility:hidden;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0)}html.hires_void .chapter .authors .dash{font-size:4rem;line-height:6.4rem;left:auto;top:-20px;top:-2rem;color:#999}html.hires_void .chapter .authors dd,html.hires_void .chapter .authors dt{display:inline-block}html.hires_void .chapter .authors dt{margin:0 .5rem}html.hires_void .chapter .authors dd{margin:0 2rem}html.hires_void .next{visibility:visible;opacity:1;-ms-filter:none;filter:none}html.hires_void .next h3{letter-spacing:0}html.hires_void .next h3 a{-webkit-transition:all .4s ease-out;-moz-transition:all .4s ease-out;-o-transition:all .4s ease-out;-ms-transition:all .4s ease-out;transition:all .4s ease-out;letter-spacing:14px;letter-spacing:1.4rem}html.hires_void .next h3 a:hover{letter-spacing:15px;letter-spacing:1.5rem}html.hires_void #elements nav.geometry{width:500px;width:50rem;margin-left:-25rem;bottom:215px;bottom:21.5rem;text-align:center;top:auto;left:50%}html.hires_void #elements nav.geometry ul li{display:inline-block;margin:0 2.9rem;position:relative}html.hires_void #elements nav.geometry ul li a{visibility:hidden;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0)}html.hires_void #elements nav.geometry ul li a.active [data-sequence],html.hires_void #elements nav.geometry ul li a:hover [data-sequence]{opacity:1;-ms-filter:none;filter:none}html.hires_void #elements [data-sequence]{-webkit-transform:scale(.4);-moz-transform:scale(.4);-o-transform:scale(.4);-ms-transform:scale(.4);transform:scale(.4);margin-top:-26px;margin-left:-57px;opacity:.5;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";filter:alpha(opacity=50);-webkit-transition:opacity .3s ease-in-out;-moz-transition:opacity .3s ease-in-out;-o-transition:opacity .3s ease-in-out;-ms-transition:opacity .3s ease-in-out;transition:opacity .3s ease-in-out}html.hires_void #elements .titles{top:38%;left:50%;text-align:center;visibility:hidden;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);width:600px;width:60rem;margin-left:-30rem}html.hires_void #elements .titles .title{width:100%;text-transform:uppercase;visibility:hidden;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0)}html.hires_void #elements .titles .title h3{margin-left:1.2rem;font-size:3rem;line-height:4.8rem}.disable{cursor:pointer;pointer-events:none} +/* + FILE ARCHIVED ON 15:45:54 Aug 27, 2015 AND RETRIEVED FROM THE + INTERNET ARCHIVE ON 03:40:04 Jun 07, 2026. + JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. + + ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. + SECTION 108(a)(3)). +*/ +/* +playback timings (ms): + capture_cache.get: 0.397 + load_resource: 59.33 + PetaboxLoader3.resolve: 42.292 + PetaboxLoader3.datanode: 16.511 +*/ \ No newline at end of file diff --git a/web.archive.org/web/20150828053525im_/http:/void.hi-res.net/apple-touch-icon.png b/web.archive.org/web/20150828053525im_/http:/void.hi-res.net/apple-touch-icon.png new file mode 100644 index 000000000..e2411c0fc Binary files /dev/null and b/web.archive.org/web/20150828053525im_/http:/void.hi-res.net/apple-touch-icon.png differ diff --git a/web.archive.org/web/20150828053525im_/http:/void.hi-res.net/favicon.ico b/web.archive.org/web/20150828053525im_/http:/void.hi-res.net/favicon.ico new file mode 100644 index 000000000..459ee5019 Binary files /dev/null and b/web.archive.org/web/20150828053525im_/http:/void.hi-res.net/favicon.ico differ diff --git a/web.archive.org/web/20150828053525im_/http:/void.hi-res.net/index.html b/web.archive.org/web/20150828053525im_/http:/void.hi-res.net/index.html new file mode 100644 index 000000000..1bb7ff40d --- /dev/null +++ b/web.archive.org/web/20150828053525im_/http:/void.hi-res.net/index.html @@ -0,0 +1,48 @@ + + + + + + + + +V O I D
+ \ No newline at end of file diff --git a/web.archive.org/web/20150828053525js_/http:/void.hi-res.net/js/app.min.0.0.0.js b/web.archive.org/web/20150828053525js_/http:/void.hi-res.net/js/app.min.0.0.0.js new file mode 100644 index 000000000..97f432822 --- /dev/null +++ b/web.archive.org/web/20150828053525js_/http:/void.hi-res.net/js/app.min.0.0.0.js @@ -0,0 +1,36 @@ +var _____WB$wombat$assign$function_____=function(name){return (globalThis._wb_wombat && globalThis._wb_wombat.local_init && globalThis._wb_wombat.local_init(name))||globalThis[name];};if(!globalThis.__WB_pmw){globalThis.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{ +let window = _____WB$wombat$assign$function_____("window"); +let self = _____WB$wombat$assign$function_____("self"); +let document = _____WB$wombat$assign$function_____("document"); +let location = _____WB$wombat$assign$function_____("location"); +let top = _____WB$wombat$assign$function_____("top"); +let parent = _____WB$wombat$assign$function_____("parent"); +let frames = _____WB$wombat$assign$function_____("frames"); +let opener = _____WB$wombat$assign$function_____("opener"); +!function(t){function e(n){if(i[n])return i[n].exports;var o=i[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){var n,o,s,r,a,u,h,l,d,p,_,f,m,g,y=function(t,e){return function(){return t.apply(e,arguments)}};window.PI=Math.PI,window.PI_2=2*Math.PI,window.PI_HALF=.5*Math.PI,p=i(1),u=i(2),d=i(7),_=i(4),s=i(5),o=i(6),l=i(8),m=i(9),a=i(10),r=i(11),f=i(12),h=i(13),g=i(3),n=function(){function t(){this.start=y(this.start,this),this.test=y(this.test,this),window.c=p,c.enable=!0,c.log("%c V O I D","background:#000; color: #fff"),c.log("%c Hi-ReS!","background:#000; color: #fff"),c.enable=!m.live,u.set_tests(["desktop","WebGL","AudioContext"]),l.once("loaded",this.test),l.load()}return t.prototype.test=function(){var t,e,i,n,o;for(i=window.location.pathname.replace(m.base_path,""),t=!1,n=0,o=f.length;o>n;n++)if(e=f[n],i===e.url){t=!0;break}return t?u.supported()?this.supported():this.unsupported():void this.not_found()},t.prototype.not_found=function(){return new r},t.prototype.unsupported=function(){return new a},t.prototype.supported=function(){return d.once("loaded",this.start),d.setup()},t.prototype.start=function(){return new s,new o,_.start(),h.random()},t}(),t.exports=new n},function(t,e,i){var n=[].slice;t.exports={enable:!1,clear:function(){return"undefined"!=typeof console&&null!==console&&null!=console.clear?console.clear():void 0},log:function(){var t;return t=1<=arguments.length?n.call(arguments,0):[],this.enable?"undefined"!=typeof console&&null!==console&&null!=console.log&&null!=console.log.apply?console.log.apply(console,t):console.log(t):void 0},debug:function(){var t;return t=1<=arguments.length?n.call(arguments,0):[],this.enable?"undefined"!=typeof console&&null!==console&&null!=console.debug&&null!=console.debug.apply?console.debug.apply(console,t):console.log(t):void 0},info:function(){var t;return t=1<=arguments.length?n.call(arguments,0):[],this.enable?"undefined"!=typeof console&&null!==console&&null!=console.info&&null!=console.info.apply?console.info.apply(console,t):console.log(t):void 0},warn:function(){var t;return t=1<=arguments.length?n.call(arguments,0):[],this.enable?"undefined"!=typeof console&&null!==console&&null!=console.warn&&null!=console.warn.apply?console.warn.apply(console,t):console.log(t):void 0},error:function(){var t;return t=1<=arguments.length?n.call(arguments,0):[],this.enable?"undefined"!=typeof console&&null!==console&&null!=console.error&&null!=console.error.apply?console.error.apply(console,t):console.log(t):void 0}}},function(t,e,i){var n;n=i(24),t.exports=new(function(){function t(){this.detect=new MobileDetect(window.navigator.userAgent),this.tests={},this.messages={WebGL:"WebGL",desktop:"Desktop Browser",tablet:"Tablet Browser",mobile:"Mobile Browser"}}return t.prototype.set_tests=function(t){var e,i,n,o,s;for(s=[],n=0,o=t.length;o>n;n++)switch(i=t[n]){case"desktop":s.push(this.detect.tablet()||this.detect.mobile()?this.tests.desktop=!1:this.tests.desktop=!0);break;case"tablet":s.push(this.tests.tablet=this.detect.tablet());break;case"mobile":s.push(this.tests.mobile=this.detect.mobile());break;case"AudioContext":s.push(this.tests.AudioContext=void 0!==(window.AudioContext||window.webkitAudioContext));break;case"WebGL":e=function(){var t;try{return!!window.WebGLRenderingContext&&!!document.createElement("canvas").getContext("experimental-webgl")}catch(e){return t=e,!1}},s.push(this.tests.WebGL=e());break;default:s.push(void 0)}return s},t.prototype.browser_test=function(){var t,e,i;return t="debug",i=!0,null!=env.BROWSER_SPEC[n.name]?(e=env.BROWSER_SPEC[n.name],n.versionr;r++)n=s[r],t=i(14),e=new t(n.id),this.routes.push({url:n.url,run:e.run,destroy:e.destroy,controller:e})}return t.prototype.route_index=-1,t.prototype.start=function(){return this.on_state_change()},t.prototype.on_state_change=function(){var t,e,i,n,o;for(t=History.getState(),this._url=this.get_url(),this.previous_route_index=this.route_index,e=n=0,o=s.length;o>n;e=++n)if(i=s[e],this._url===i.url){this.route_index=e;break}return null!=this.routes[this.previous_route_index]?this.routes[this.previous_route_index].controller.has_transitioned_out()?this.routes[this.previous_route_index].destroy(function(t){return function(){return t.run()}}(this)):(this.routes[this.previous_route_index].controller.once("next",function(t){return function(){return c.log("router now destroy the view"),t.routes[t.previous_route_index].destroy(function(){return c.log("view destroyed"),t.run()})}}(this)),this.routes[this.previous_route_index].controller.transition_out()):this.run(),this.emit("url:changed",this._url)},t.prototype.run=function(){return this.routes[this.route_index].controller.once("transition:in:complete",function(t){return function(){return t.emit("nav:enable")}}(this)),this.routes[this.route_index].run(function(t){return function(){return c.log("router::run -> done")}}(this))},t.prototype.go=function(t,e,i){return null==e&&(e=""),null==i&&(i={}),c.debug("go",t,e,i),t!==this._url?(History.pushState(null,document.title,r.base_path+t),this.emit("nav:disable"),this.emit("go",t)):void 0},t.prototype.transition_out_then_go=function(t){return t!==this._url?c.log("url",t):void 0},t.prototype.next=function(){var t,e,i,n,o,a,u;for(t=a=0,u=s.length;u>a;t=++a)if(n=s[t],o=n.url.match("/")?r.base_path+n.url:n.url,o.match(window.location.pathname)){e=t+1n;n++)if(i=a[n],i.id.match(t)){e=i;break}return r.go(e.url)},t.prototype.on_url_change=function(){var t,e,i,n,o,s;for(n=r.get_url(),n=n.slice(1,n.length),i=u.all(),e=null,o=0,s=i.length;s>o;o++)if(t=i[o],t.id.match(n)){e=t;break}return this.view.update(e)},t.prototype.enable=function(){return this.view.enable()},t.prototype.disable=function(){return this.view.disable()},t}()},function(t,e,i){var n,o,s,r,a,u,h=function(t,e){return function(){return t.apply(e,arguments)}};a=i(18),r=i(9),o=i(25),u=i(3),t.exports=n=function(){function t(){this.omg=h(this.omg,this),this.lols=h(this.lols,this);var t,e,i,n,o;this.el=$("body"),this.ui={main:"main"},o=this.ui;for(e in o)t=o[e],this.ui[e]=this.el.find(t);i=[],n="38,38,40,40,37,39,37,39,66,65",$(document).keydown(function(t){return function(e){return i.push(e.keyCode),i.toString().indexOf(n)>=0?($(document).unbind("keydown",arguments.callee),t.wtf(),i=[]):void 0}}(this))}return t.prototype.num_stickers=35,t.prototype.wtf=function(){return u.on("resize",this.omg),this.ui.main.addClass("konami"),this.loader=new o,this.loader.add("images",r.base_path+"/img/konami/images.json","json"),this.loader.add("lol",r.base_path+"/sound/konami/lol.mp3","sound"),this.loader.once("loaded",this.lols),this.loader.load()},t.prototype.lols=function(t){var e,i,n,o,r,a,u;for(e=this.loader.get_asset("images").data.images,n=this.loader.get_asset("lol").data,n.play(),n.loop(!0),this.stickers=[],u=[],i=r=0,a=this.num_stickers;a>=0?a>r:r>a;i=a>=0?++r:--r)o=.2*i,u.push(this.stickers.push(new s(o,e)));return u},t.prototype.omg=function(){var t,e,i,n,o,s,r,a;for(i=u.width<1280?15:u.width<1440?25:this.num_stickers,r=this.stickers,n=0,s=r.length;s>n;n++)e=r[n],e.hide();for(a=[],t=o=0;i>=0?i>o:o>i;t=i>=0?++o:--o)a.push(this.stickers[t].show());return a},t}(),s=function(){function t(t,e){this.data=e,this.img=$(""),this.img.addClass("sticker"),$("body").append(this.img),a.delay(t,function(t){return function(){return t.random()}}(this))}return t.prototype.src=function(){var t;return t=this.data[Math.floor(Math.random()*this.data.length)],this.img.attr("src",r.base_path+"/img/konami/"+t)},t.prototype.random=function(){var t,e;return this.src(),e="scale("+a.random(.3,1)+")",this.img.css({left:a.random(0,.8*u.width)+"px",top:a.random(0,.8*u.height)+"px",transform:e}),t=a.random(5,10),a.delay(t,function(t){return function(){return t.start_delay=0,t.random()}}(this))},t.prototype.show=function(){return this.img.css("display","block")},t.prototype.hide=function(){return this.img.css("display","none")},t}()},function(t,e,i){var n,o,s,r,a,u,h,l,c,d=function(t,e){return function(){return t.apply(e,arguments)}};u=i(26),c=i(3),l=i(9),a=i(15),o=i(19),r=i(20),h=i(21),s=i(22),t.exports=new(n=function(){function t(){this._resize=d(this._resize,this),this._update=d(this._update,this),u(this)}var e;return e=null,t.prototype.scene=r,t.prototype.fov=80,t.prototype.setup=function(){var t,e;return this.el=$("#void"),e=function(t,e){return t.position.set(1*e,.75*e,1*e),t.lookAt(new THREE.Vector3)},e(o.dev,160),h.setSize(c.width,c.height),this.el.append(h.domElement),l.debug&&(this.scene.add(new THREE.GridHelper(50,10)),this.scene.add(new THREE.AxisHelper(10))),l.live||(t=i(23),this.save=new t,$(window).on("keydown",function(t){return function(e){var i,n,s,r,a,u,l,d;return n=7,s=7,a=3,u=3,l=c.width*a,r=c.height*u,d=c.width*n,i=c.height*s,80===e.keyCode?(h.setSize(l,r),t._render(o.user,0,0,a,u),h.render(t.scene,o.user),t.save["export"](d,i)):void 0}}(this))),this.gui=a.addFolder("controller::engine"),this.gui.add(l,"debug"),this.gui.open(),this._bind(),this._update(),this.emit("loaded")},t.prototype.set_scene=function(t,e){this.scene=null!=t?t:r,this.config=null!=e?e:{}},t.prototype._bind=function(){return c.on("resize",this._resize)},t.prototype._update=function(){return requestAnimationFrame(this._update),this.emit("update"),s.update(),o.user.fov=this.fov,l.debug?(this._render(o.dev,0,0,1,1),this._render(o.user,0,0,.25,.25)):this._render(o.user,0,0,1,1)},t.prototype._render=function(t,e,i,n,s){var r;return e*=c.width,i*=c.height,n*=c.width,s*=c.height,o.dev.updateProjectionMatrix(),o.user.updateProjectionMatrix(),h.setViewport(e,i,n,s),h.setScissor(e,i,n,s),h.enableScissorTest(!0),r=l.debug?1184274:0,h.setClearColor(r,1),null==this.config||this.config.has_composer?void 0:h.render(this.scene,t)},t.prototype._resize=function(){return o.dev.aspect=c.width/c.height,o.user.aspect=c.width/c.height,o.dev.updateProjectionMatrix(),o.user.updateProjectionMatrix(),h.setSize(c.width,c.height)},t}())},function(t,e,i){var n,o,s,r;s=i(26),r=i(9),o=i(25),n=function(){function t(){s(this),this.objs={}}return t.prototype.default_dictionary="dictionary.xml",t.prototype.load=function(){var t;return t=new o,t.on("loading",function(t){return function(t){return c.info("[ PERCENT LOADED ] ->",t)}}(this)),t.once("loaded",function(t){return function(e){var i,n,o;for(n=0,o=e.length;o>n;n++)i=e[n],t.objs[i.id]=$(i.data);return t.emit("loaded")}}(this)),t.add("dictionary.xml",""+r.base_path+"/xml/dictionary.xml","xml"),t.add("scenes.xml",""+r.base_path+"/xml/scenes.xml","xml"),t.load()},t.prototype.get=function(t,e){var i;return null==e&&(e=this.default_dictionary),i=this.get_raw(t,e),i?i.text():""},t.prototype.get_raw=function(t,e){return null==e&&(e=this.default_dictionary),this.objs[e].find(t).length?this.objs[e].find(t):!1},t.prototype.get_dictionary=function(t){return null==t&&(t=this.default_dictionary),this.objs[t]},t}(),t.exports=new n},function(t,e,i){var n;n={debug:env.DEBUG,live:env.LIVE,retina:2===window.devicePixelRatio,base_path:env.BASE_PATH,share_url:window.location.href},n.retina_scale=n.retina?2:1,t.exports=n},function(t,e,i){var n,o,s;o=i(8),s=i(9),n=i(24),t.exports=function(){function t(){var t,e;e=i(32),t={dictionary:o,base_path:s.base_path,device:n.device},$("body").append(e(t))}return t}()},function(t,e,i){var n;n=i(8),t.exports=function(){function t(){var t,e;e=i(33),t={dictionary:n},$("body").append(e(t))}return t}()},function(t,e,i){t.exports=[{id:"home",url:"/",controller:"controllers/scene"},{id:"blackice",url:"/blackice",controller:"controllers/scene"},{id:"elements",url:"/elements",controller:"controllers/scene"},{id:"kubik",url:"/kubik",controller:"controllers/scene"},{id:"hires",url:"/hires",controller:"controllers/scene"},{id:"calvarium",url:"/calvarium",controller:"controllers/scene"},{id:"liquidice",url:"/liquidice",controller:"controllers/scene"},{id:"epilogue",url:"/epilogue",controller:"controllers/epilogue"}]},function(t,e,i){var n;n=function(){function t(){}var e;return e=["not-allowed","help","move","all-scroll","sw-resize"],t.prototype._random_to=null,t.prototype.random=function(){var t;return(t=function(t){return function(){var i;return i=Math.floor(Math.random()*e.length),$("body").css({cursor:e[i]}),t._random_to=setTimeout(arguments.callee,5e3*Math.random())}}(this))()},t.prototype.stop_random=function(){return clearTimeout(this._random_to)},t}(),t.exports=new n},function(t,e,i){var n,o,s,r,a,u=function(t,e){return function(){return t.apply(e,arguments)}};r=i(26),o=i(7),s=i(15),a=i(4),t.exports=n=function(){function t(t){this.id=t,this.next=u(this.next,this),this.destroy=u(this.destroy,this),this.run=u(this.run,this),r(this),this.gui=s.addFolder("controller::"+this.id),this.gui.open()}return t.prototype.run=function(t){var e,n,s;return c.log("controller::scene -> run "+this.id),this.scene=new THREE.Scene,e=i(27)("./"+this.id+"/index"),n=i(28)("./"+this.id+"/assets"),s=i(29)("./"+this.id+"/config"),this.view=new e(this.scene,this.gui,n,s),o.set_scene(),this.view.once("setup:complete",function(e){return function(){return o.set_scene(e.scene,s),e.view.transition_in(),t()}}(this)),this.view.once("next",this.next),this.view.once("transition:in:complete",function(t){return function(){return t.emit("transition:in:complete")}}(this)),this.view.load()},t.prototype.destroy=function(t){return c.log("controller::"+this.id+" -> destroy"),this.view.once("destroyed",function(e){return function(){return t()}}(this)),this.view.destroy()},t.prototype.has_transitioned_out=function(){return this.view.has_transitioned_out},t.prototype.transition_out=function(){return c.log("transition out scene"),this.view.off("next",this.next),this.view.once("next",function(t){return function(){return c.log("next route"),t.emit("next")}}(this)),this.view.transition_out_forward(!0),this.view.disable_transition()},t.prototype.next=function(){return i(4).next()},t}()},function(t,e,i){var n,o,s;s=i(9),n=i(30),o=new n,window.gui=o,t.exports=o},function(t,e,i){var n,o,s,r,a;a=i(8),s=i(31).Scene,n=i(31).Author,o=i(31).Interaction,t.exports=new(r=function(){function t(){}return t.prototype.get=function(t){var e,i,r;return r=$(a.get_dictionary("scenes.xml")),i=r.find('scene[id="'+t+'"]'),e=new s,e.id=i.attr("id"),e.chapter=i.find("chapter").text(),e.title=i.find("title").text(),e.nav_title=i.find("nav_title").text(),e.paragraphs=[],e.interactions=[],i.find("paragraph").each(function(t){return function(t,i){return e.paragraphs.push($(i).text())}}(this)),e.authors=[],i.find("author").each(function(t){return function(t,i){var o,s;return o=$(i),s=new n,s.name=o.find("name").text(),s.role=o.find("role").text(),e.authors.push(s)}}(this)),i.find("interaction").each(function(t){return function(t,i){var n,s;return n=$(i),s=new o,s.id=n.attr("id"),s.text=n.text(),e.interactions.push(s)}}(this)),e},t.prototype.all=function(){var t,e;return e=$(a.get_dictionary("scenes.xml")),t=[],e.find("scene").each(function(e){return function(i,n){var o;return o=$(n).attr("id"),t.push(e.get(o))}}(this)),t},t}())},function(t,e,i){var n,o,s=function(t,e){return function(){return t.apply(e,arguments)}};o=i(26),t.exports=n=function(){function t(t,e){this.gui=t,this.data=e,this.on_click=s(this.on_click,this),this.disable=s(this.disable,this),this.enable=s(this.enable,this),o(this),this.render()}return t.prototype.ui={chapters:"li a"},t.prototype.render=function(){var t,e,n,o;n=i(34),$("main").append(n({data:this.data})),this.el=$("#navigation"),o=this.ui;for(e in o)t=o[e],this.ui[e]=this.el.find(t);return this.transition_in(),this.bind(),this.disable()},t.prototype.bind=function(){return this.ui.chapters.on("click",this.on_click)},t.prototype.unbind=function(){return this.ui.chapters.off("click",this.on_click)},t.prototype.enable=function(){return this.ui.chapters.removeClass("disable")},t.prototype.disable=function(){return this.ui.chapters.addClass("disable")},t.prototype.on_click=function(t){var e;return t.preventDefault(),e=$(t.currentTarget).data("id"),this.emit("click",e)},t.prototype.transition_in=function(){var t;return t={autoAlpha:1,ease:Power1.easeInOut,delay:.5},TweenLite.to(this.el,2,t)},t.prototype.update=function(t){return this.ui.chapters.removeClass("active"),this.el.find("a[data-id="+t.id+"]").addClass("active")},t}()},function(t,e,i){t.exports={lerp:function(t,e,i){return t+(e-t)*i},random:function(t,e){return t+Math.random()*(e-t)},radians:function(t){return t*Math.PI/180},degrees:function(t){return 180*t/Math.PI},spline:function(t){var e,i,n,o;for(i=[],n=0,o=t.length;o>n;n++)e=t[n],i.push(e.clone());return new THREE.SplineCurve3(i)},delay:function(t,e){return setTimeout(e,1e3*t)},merge:function(t,e){var i,n,o,s;"object"!=typeof t&&(t={});for(o in e)if(e.hasOwnProperty(o)){if(s=e[o],"object"==typeof s){t[o]=this.merge(t[o],s);continue}t[o]=s}for(i=2,n=arguments.length;n>i;)merge(t,arguments[i]),i++;return t},path:function(t,e,i,n,o){var s,r,a,u,h,l,c,d,p,_,f,m,g,y,v;for(null==e&&(e=[]),null==i&&(i=16711680),null==n&&(n=null),null==o&&(o=100),c=function(){var t,i,n;for(n=[],a=t=0,i=e.length;i>=0?i>t:t>i;a=i>=0?++t:--t)n.push(""+a);return n}(),s=1e4,l=[],_=50,a=m=0,v=c.length;v>=0?v>m:m>v;a=v>=0?++m:--m)h=new THREE.Mesh(new THREE.SphereGeometry(_,16,16),new THREE.MeshBasicMaterial({color:i,wireframe:!0})),h.name="path_"+a,h.position.fromArray(e[a]),n&&(n.add(h,"name"),n.add(h.position,"x",-s,s).name("position x"),n.add(h.position,"y",-s,s).name("position y"),n.add(h.position,"z",-s,s).name("position z")),l.push(h);for(e=function(){var t,e,i;for(i=[],t=0,e=l.length;e>t;t++)h=l[t],i.push(h.position.clone());return i}(),f=this.spline(e),p=f.getPoints(o),r=new THREE.Geometry,g=0,y=p.length;y>g;g++)d=p[g],r.vertices.push(d.clone());return u=new THREE.Line(r,new THREE.LineBasicMaterial({color:i})),this.spline(p)},gui_controls:function(t,e,i,n){var o,s;return null==n&&(n=100),s=2*Math.PI,e.updateMatrix(),o=t.addFolder(i),o.add(e.position,"x",-n,n),o.add(e.position,"y",-n,n),o.add(e.position,"z",-n,n),o.add(e.rotation,"x",-s,s),o.add(e.rotation,"y",-s,s),o.add(e.rotation,"z",-s,s)},get_asset:function(t,e){var i,n,o,s;for(n=!1,o=0,s=e.length;s>o;o++)i=e[o],i.id.match(t)&&(n=i);return n}},window.PI=Math.PI,window.HALF_PI=Math.PI/2,window.PI_2=2*Math.PI,Number.prototype.map=function(t,e,i,n){return(this-t)*(n-i)/(e-t)+i},String.prototype.capitalizeFirstLetter=function(){return this.charAt(0).toUpperCase()+this.slice(1)}},function(t,e,i){var n,o,s;s=i(3),o=i(15),e.user=new THREE.PerspectiveCamera(80,s.width/s.height,.1,1e5),e.dev=new THREE.PerspectiveCamera(80,s.width/s.height,.1,1e5),o=o.addFolder("controller::cameras"),n=2e4,e.user.name="user",e.dev.name="dev",o.add(e.user,"name"),o.add(e.user,"fov",10,200).listen(),o.add(e.user.position,"x",-n,n).name("position x"),o.add(e.user.position,"y",-n,n).name("position y"),o.add(e.user.position,"z",-n,n).name("position z"),o.add(e.user.rotation,"x",-PI_2,PI_2).name("rotation x"),o.add(e.user.rotation,"y",-PI_2,PI_2).name("rotation y"),o.add(e.user.rotation,"z",-PI_2,PI_2).name("rotation z"),o.add(e.dev,"name"),o.add(e.dev,"fov",10,200).listen(),o.add(e.dev.position,"x",-n,n).name("position x").listen(),o.add(e.dev.position,"y",-n,n).name("position y").listen(),o.add(e.dev.position,"z",-n,n).name("position z").listen(),o.add(e.dev.rotation,"x",-PI_2,PI_2).name("rotation x").listen(),o.add(e.dev.rotation,"y",-PI_2,PI_2).name("rotation y").listen(),o.add(e.dev.rotation,"z",-PI_2,PI_2).name("rotation z").listen()},function(t,e,i){t.exports=new THREE.Scene},function(t,e,i){var n;n=i(9),t.exports=new THREE.WebGLRenderer({alpha:!1,antialias:!0,preserveDrawingBuffer:!n.live})},function(t,e,i){var n,o,s,r,a;a=i(9),o=i(19),r=i(21),n=o.dev,s=new THREE.TrackballControls(n,$("canvas")[0]),s.rotateSpeed=1,s.zoomSpeed=1.2,s.panSpeed=.8,s.noZoom=!1,s.noPan=!1,s.staticMoving=!0,s.dynamicDampingFactor=.5,t.exports=s},function(t,e,i){var n,o;o=i(21),n=i(26),t.exports=function(){function t(){n(this)}return t.prototype["export"]=function(t,e){var i;return i=Canvas2Image.convertToImage(o.domElement,t,e,"jpeg"),$.ajax({type:"POST",url:"save_image.php",dataType:"text",data:{base64Data:i.src},success:function(t){return function(e){return SaveToDisk("exports/"+e,e),t.emit("done"),c.log("emit done")}}(this),error:function(t){return function(){return console.log("error")}}(this)})},t}()},function(t,e,i){var n,o,s;o=i(41).browser,s=i(42),t.exports=new(n=function(){function t(){this.ie=o.msie,this.firefox=o.firefox,this.ltie10=o.msie&&o.version<10,this.name=o.name,this.version=o.version,this.mobile=s.phone,this.tablet=s.tablet,this.handheld=s.any,this.device=this.tablet||this.mobile,this.desktop=(this.tablet||this.mobile)===!1}return t}())},function(t,e,i){var n,o,s,r,a,u,h,l,d,p=function(t,e){return function(){return t.apply(e,arguments)}};d=i(26),s=i(35),o=i(36),a=i(37),u=i(38),r=i(39),l=i(40),Element.prototype.remove=function(){this.parentElement.removeChild(this)},NodeList.prototype.remove=HTMLCollection.prototype.remove=function(){var t,e;for(t=0,e=this.length;e>t;)this[t]&&this[t].parentElement&&this[t].parentElement.removeChild(this[t]),t++},t.exports=n=function(){function t(){this.error=p(this.error,this),this.success=p(this.success,this),d(this),this.manifest=[]}return t.prototype.add=function(t,e,i,n){var o;return o={id:t,src:e,type:i,data:n},this.manifest.push(o)},t.prototype.load=function(){var t,e,i,n,c,d;for(this.count=0,this.total=this.manifest.length,this.date=new Date,c=this.manifest,d=[],i=0,n=c.length;n>i;i++)switch(t=c[i],t.type){case"json":case"xml":e=new s,e.once("loaded",this.success),d.push(e.load(t));break;case"image":e=new a,e.once("loaded",this.success),d.push(e.load(t));break;case"binary":e=new o,e.once("loaded",this.success),d.push(e.load(t));break;case"js":e=new u,e.once("loaded",this.success),d.push(e.load(t));break;case"geometry":e=new r,e.once("loaded",this.success),d.push(e.load(t));break;case"sound":e=new l,e.once("loaded",this.success),d.push(e.load(t));break;case"sequence":e=new h,e.once("loaded",this.success),d.push(e.load(t));break;default:d.push(void 0)}return d},t.prototype.dispose=function(){var t,e,i,n,o;for(n=this.manifest,o=[],e=0,i=n.length;i>e;e++)switch(t=n[e],t.type){case"js":o.push(document.getElementById(t.id).remove());break;default:o.push(void 0)}return o},t.prototype.success=function(t){return this.count++,this.count>=this.total?this.emit("loaded",this.manifest):void 0},t.prototype.error=function(t){return c.log("error",t)},t.prototype.get_asset=function(t){var e,i,n,o,s;for(i=!1,s=this.manifest,n=0,o=s.length;o>n;n++)e=s[n],e.id.match(t)&&(i=e);return i},t}(),h=function(){function t(){this.images_loaded=p(this.images_loaded,this),this.data_loaded=p(this.data_loaded,this),d(this),this.images=[],this.data_loader=new s,this.img_loader=new n,this.data_loader.once("loaded",this.data_loaded),this.img_loader.once("loaded",this.images_loaded)}return t.prototype.load=function(t){return this.asset=t,this.data_loader.load({src:this.asset.src})},t.prototype.data_loaded=function(t){var e,i,n,o,s,r;for(this.asset.data=t.data,o=t.src.split("/"),n=o.splice(0,o.length-1).join("/"),i=s=0,r=t.data.total_spritesheets;r>=0?r>s:s>r;i=r>=0?++s:--s)e=n+"/"+i+"."+t.data.extensions[0],this.img_loader.add("frame_"+i,e,"image",{});return this.img_loader.load()},t.prototype.images_loaded=function(t){var e,i,n;for(this.asset.images=[],i=0,n=t.length;n>i;i++)e=t[i],this.asset.images.push(e.data);return delete this.data_loader,delete this.img_loader,this.emit("loaded",this.asset)},t}()},function(t,e,i){function n(t){if(!(t&&t instanceof Function))throw new Error(t+" is not a Function")}t.exports=function(t){t=t||{};for(var e in o)t[e]=o[e];return t};var o={__init:function(t){var e=this.__listeners||(this.__listeners=[]);return e[t]||(e[t]=[])},on:function(t,e){n(e),this.__init(t).push(e)},off:function(t,e){var i=this.__init(t);i.splice(i.indexOf(e),1)},once:function(t,e){n(e);var i=this,o=function(){i.off(t,o),e.apply(this,arguments)};this.on(t,o)},emit:function(t){var e,i=this.__init(t).slice(0);for(e in i)i[e].apply(this,[].slice.call(arguments,1))}}},function(t,e,i){function n(t){return i(o(t))}function o(t){return s[t]||function(){throw new Error("Cannot find module '"+t+"'.")}()}var s={"./blackice/index":44,"./calvarium/index":47,"./elements/index":50,"./epilogue/index":53,"./hires/index":56,"./home/index":59,"./kubik/index":62,"./liquidice/index":65};n.keys=function(){return Object.keys(s)},n.resolve=o,t.exports=n,n.id=27},function(t,e,i){function n(t){return i(o(t))}function o(t){return s[t]||function(){throw new Error("Cannot find module '"+t+"'.")}()}var s={"./blackice/assets":45,"./calvarium/assets":48,"./elements/assets":51,"./epilogue/assets":54,"./hires/assets":57,"./home/assets":60,"./kubik/assets":63,"./liquidice/assets":66};n.keys=function(){return Object.keys(s)},n.resolve=o,t.exports=n,n.id=28},function(t,e,i){function n(t){return i(o(t))}function o(t){return s[t]||function(){throw new Error("Cannot find module '"+t+"'.")}()}var s={"./blackice/config":46,"./calvarium/config":49,"./elements/config":52,"./epilogue/config":55,"./hires/config":58,"./home/config":61,"./kubik/config":64,"./liquidice/config":67};n.keys=function(){return Object.keys(s)},n.resolve=o,t.exports=n,n.id=29},function(t,e,i){var n,o,s,r;r=i(9),r.live?(n=function(){function t(){}return t.prototype.add=function(){return this},t.prototype.listen=function(){return this},t.prototype.name=function(){return this},t.prototype.open=function(){return this},t.prototype.onChange=function(){return this},t.prototype.addFolder=function(){return new t},t.prototype.addColor=function(){return this},t}(),o=function(){function t(){}return t.prototype.add=function(){return this},t.prototype.addFolder=function(){return new n},t.prototype.name=function(){return this},t.prototype.close=function(){return this},t.prototype.step=function(){return this},t.prototype.onChange=function(){return this},t.prototype.setValue=function(){return this},t}(),t.exports=o):(s=i(68),t.exports=s.GUI)},function(t,e,i){var n,o,s;e.Scene=s=function(){function t(){}return t.prototype.id=String,t.prototype.title=String,t.prototype.paragraphs=Array,t.prototype.authors=Array,t.prototype.interactions=Array,t}(),e.Author=n=function(){function t(){}return t.prototype.role=String,t.prototype.name=String,t}(),e.Interaction=o=function(){function t(){}return t.prototype.id=String,t.prototype.text=String,t}()},function(t,e,i){var n=i(43);t.exports=function(t){var e,i=[],o=t||{};return function(o){i.push('

'+n.escape(null==(e=o.get("unsupported_title"))?"":e)+"

"),i.push(t.device?""+(null==(e=o.get("unsupported_text_device"))?"":e):""+(null==(e=o.get("unsupported_text_desktop"))?"":e)),i.push("
")}.call(this,"dictionary"in o?o.dictionary:"undefined"!=typeof dictionary?dictionary:void 0),i.join("")}},function(t,e,i){var n=i(43);t.exports=function(t){var e,i=[],o=t||{};return function(o){i.push('

"+n.escape(null==(e=o.get("notfound_title"))?"":e)+"

")}.call(this,"dictionary"in o?o.dictionary:"undefined"!=typeof dictionary?dictionary:void 0),i.join("")}},function(t,e,i){var n=i(43);t.exports=function(t){var e,i=[];return i.push('"),i.join("")}},function(t,e,i){var n,o;o=i(26),t.exports=n=function(){function t(){o(this)}return t.prototype.load=function(t){return $.ajax({url:t.src,dataType:t.type,success:function(e){return function(i){return t.data=i,e.emit("loaded",t)}}(this),error:function(t){return function(t){return c.error("error",t)}}(this)})},t}()},function(t,e,i){var n,o;o=i(26),t.exports=n=function(){function t(){o(this)}return t.prototype.load=function(t){var e,i;if(i=this.req(),!e){e="arraybuffer";try{Blob.prototype.slice&&(e="blob")}catch(n){}}return i.open("GET",t.src,!0),i.responseType=e,i.onprogress=function(t){},i.onreadystatechange=function(e){return function(n){4===i.readyState&&(t.data=i.response,e.emit("loaded",t),i.onreadystatechange=null)}}(this),i.send(null)},t.prototype.req=function(){return window.XMLHttpRequest?new XMLHttpRequest:window.ActiveXObject?new ActiveXObject("MSXML2.XMLHTTP.3.0"):void 0},t}()},function(t,e,i){var n,o;o=i(26),t.exports=n=function(){function t(){o(this)}return t.prototype.load=function(t){var e;return e=new Image,e.onload=function(i){return function(){return t.data=e,i.emit("loaded",t)}}(this),e.src=t.src},t}()},function(t,e,i){var n,o;o=i(26),t.exports=n=function(){function t(){o(this)}return t.prototype.load=function(t){var e;return e=document.createElement("script"),e.setAttribute("type","text/javascript"),e.setAttribute("src",t.src),e.setAttribute("id",t.id),e.onload=function(e){return function(){return e.emit("loaded",t)}}(this),document.getElementsByTagName("head")[0].appendChild(e); + +},t}()},function(t,e,i){var n,o;o=i(26),t.exports=n=function(){function t(){o(this)}return t.prototype.load=function(t){var e;return e=new THREE.JSONLoader,e.load(t.src,function(e){return function(i){return t.data=i,e.emit("loaded",t)}}(this))},t}()},function(t,e,i){var n,o;o=i(26),t.exports=n=function(){function t(){o(this)}return t.prototype.load=function(t){var e;return e=new Howl({src:[t.src],onload:function(i){return function(){return t.data=e,i.emit("loaded",t)}}(this)})},t}()},function(t,e,i){var n,o;!function(s,r){"undefined"!=typeof t&&t.exports?t.exports.browser=r():(n=r,o="function"==typeof n?n.call(e,i,e,t):n,!(void 0!==o&&(t.exports=o)))}("bowser",function(){function t(t){function i(e){var i=t.match(e);return i&&i.length>1&&i[1]||""}function n(e){var i=t.match(e);return i&&i.length>1&&i[2]||""}var o,s=i(/(ipod|iphone|ipad)/i).toLowerCase(),r=/like android/i.test(t),a=!r&&/android/i.test(t),u=i(/edge\/(\d+(\.\d+)?)/i),h=i(/version\/(\d+(\.\d+)?)/i),l=/tablet/i.test(t),c=!l&&/[^-]mobi/i.test(t);/opera|opr/i.test(t)?o={name:"Opera",opera:e,version:h||i(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i)}:/windows phone/i.test(t)?(o={name:"Windows Phone",windowsphone:e},u?(o.msedge=e,o.version=u):(o.msie=e,o.version=i(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(t)?o={name:"Internet Explorer",msie:e,version:i(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:/chrome.+? edge/i.test(t)?o={name:"Microsoft Edge",msedge:e,version:u}:/chrome|crios|crmo/i.test(t)?o={name:"Chrome",chrome:e,version:i(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:s?(o={name:"iphone"==s?"iPhone":"ipad"==s?"iPad":"iPod"},h&&(o.version=h)):/sailfish/i.test(t)?o={name:"Sailfish",sailfish:e,version:i(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(t)?o={name:"SeaMonkey",seamonkey:e,version:i(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel/i.test(t)?(o={name:"Firefox",firefox:e,version:i(/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(t)&&(o.firefoxos=e)):/silk/i.test(t)?o={name:"Amazon Silk",silk:e,version:i(/silk\/(\d+(\.\d+)?)/i)}:a?o={name:"Android",version:h}:/phantom/i.test(t)?o={name:"PhantomJS",phantom:e,version:i(/phantomjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(t)||/rim\stablet/i.test(t)?o={name:"BlackBerry",blackberry:e,version:h||i(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:/(web|hpw)os/i.test(t)?(o={name:"WebOS",webos:e,version:h||i(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(t)&&(o.touchpad=e)):o=/bada/i.test(t)?{name:"Bada",bada:e,version:i(/dolfin\/(\d+(\.\d+)?)/i)}:/tizen/i.test(t)?{name:"Tizen",tizen:e,version:i(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||h}:/safari/i.test(t)?{name:"Safari",safari:e,version:h}:{name:i(/^(.*)\/(.*) /),version:n(/^(.*)\/(.*) /)},!o.msedge&&/(apple)?webkit/i.test(t)?(o.name=o.name||"Webkit",o.webkit=e,!o.version&&h&&(o.version=h)):!o.opera&&/gecko\//i.test(t)&&(o.name=o.name||"Gecko",o.gecko=e,o.version=o.version||i(/gecko\/(\d+(\.\d+)?)/i)),o.msedge||!a&&!o.silk?s&&(o[s]=e,o.ios=e):o.android=e;var d="";o.windowsphone?d=i(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):s?(d=i(/os (\d+([_\s]\d+)*) like mac os x/i),d=d.replace(/[_\s]/g,".")):a?d=i(/android[ \/-](\d+(\.\d+)*)/i):o.webos?d=i(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):o.blackberry?d=i(/rim\stablet\sos\s(\d+(\.\d+)*)/i):o.bada?d=i(/bada\/(\d+(\.\d+)*)/i):o.tizen&&(d=i(/tizen[\/\s](\d+(\.\d+)*)/i)),d&&(o.osversion=d);var p=d.split(".")[0];return l||"ipad"==s||a&&(3==p||4==p&&!c)||o.silk?o.tablet=e:(c||"iphone"==s||"ipod"==s||a||o.blackberry||o.webos||o.bada)&&(o.mobile=e),o.msedge||o.msie&&o.version>=10||o.chrome&&o.version>=20||o.firefox&&o.version>=20||o.safari&&o.version>=6||o.opera&&o.version>=10||o.ios&&o.osversion&&o.osversion.split(".")[0]>=6||o.blackberry&&o.version>=10.1?o.a=e:o.msie&&o.version<10||o.chrome&&o.version<20||o.firefox&&o.version<20||o.safari&&o.version<6||o.opera&&o.version<10||o.ios&&o.osversion&&o.osversion.split(".")[0]<6?o.c=e:o.x=e,o}var e=!0,i=t("undefined"!=typeof navigator?navigator.userAgent:"");return i.test=function(t){for(var e=0;e/g,">").replace(/"/g,""");return e===""+t?t:e},e.rethrow=function r(t,e,n,o){if(!(t instanceof Error))throw t;if(!("undefined"==typeof window&&e||o))throw t.message+=" on line "+n,t;try{o=o||i(92).readFileSync(e,"utf8")}catch(s){r(t,null,n)}var a=3,u=o.split("\n"),h=Math.max(n-a,0),l=Math.min(u.length,n+a),a=u.slice(h,l).map(function(t,e){var i=e+h+1;return(i==n?" > ":" ")+i+"| "+t}).join("\n");throw t.path=e,t.message=(e||"Jade")+":"+n+"\n"+a+"\n\n"+t.message,t}},function(t,e,i){var n,o,s,r,a,u,h,l,c,d,p,_,f,m,g,y,v=function(t,e){return function(){return t.apply(e,arguments)}},b={}.hasOwnProperty,w=function(t,e){function i(){this.constructor=t}for(var n in e)b.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},x=[].indexOf||function(t){for(var e=0,i=this.length;i>e;e++)if(e in this&&this[e]===t)return e;return-1};f=i(26),m=i(9),p=i(19),_=i(7),a=i(25),u=i(69),g=i(18),r=i(70),y=i(3),o=i(71),c=i(72),d=i(45),s=i(87),l=i(88),h=i(89),t.exports=n=function(t){function e(){return this.on_click=v(this.on_click,this),this.update=v(this.update,this),this.generate_mesh=v(this.generate_mesh,this),this.on_cubemap_url_loaded=v(this.on_cubemap_url_loaded,this),this.on_drop=v(this.on_drop,this),this.on_dragover=v(this.on_dragover,this),this.setup=v(this.setup,this),e.__super__.constructor.apply(this,arguments)}return w(e,t),e.prototype.material=null,e.prototype.accel_x=.1,e.prototype.accel_y=.1,e.prototype.accel_z=.1,e.prototype.iteration=0,e.prototype.interation_lock=!0,e.prototype.first_time=!1,e.prototype.base_mult=0,e.prototype.user_added_texture=!1,e.prototype.setup=function(t){var e,i,n,o,r,a;for(this.manifest=t,this.gui.add(this,"audio_pos_z",-30,30),this.first_time=!0,_.fov=this.config.camera_fov,this.ui=new c("blackice",this.scene,this.gui),this.config.fog_enabled&&(this.scene.fog=new THREE.FogExp2(0,this.config.fog_in_start),this.gui.add(this.scene.fog,"density",0,1)),m.debug&&(this.scene.add(new THREE.GridHelper(50,10)),this.scene.add(new THREE.AxisHelper(10)),this.scene.add(new THREE.CameraHelper(p.user))),this.hotspot=new s(this.ui.ui.hitarea,"sphere",70),this.scene.add(this.hotspot.mesh),this.path_in=new l("path_in",this.scene,this.config.path_in,this.config.path_in_lookat,65280),this.path_out=new h("path_out",this.scene,this.config.path_out,this.config.path_out_lookat,65280),this.mouse=new u($("body")),this.audio_pos_z=this.config.audio_pos_z_in,this.sounds={base_1:g.get_asset("base_1",t).data,base_2:g.get_asset("base_2",t).data,base_3:g.get_asset("base_3",t).data,melody:g.get_asset("melody",t).data},this.sounds.melody.volume(.7),this.sounds.melody.play(),this.sound_bases=[this.sounds.base_1,this.sounds.base_2,this.sounds.base_3],r=this.sound_bases,n=0,o=r.length;o>n;n++)i=r[n],i.volume(0),i.play();a=this.sounds;for(e in a)i=a[e],i.loop(!0);return this.container=new THREE.Object3D,this.scene.add(this.container),this.materials=[],this.materials.push(this.generate_material("lvl0")),this.materials.push(this.generate_material("lvl1")),this.materials.push(this.generate_material("lvl2")),this.user_material=this.generate_material("lvl0"),this.iteration=1,this.generate_mesh(this.iteration),this.bind(),this.emit("setup:complete")},e.prototype.generate_material=function(t){var e,i,n,o,s,r,a,u,h;for(s=[],o=[""+t+"-pos-x",""+t+"-neg-x",""+t+"-pos-y",""+t+"-neg-y",""+t+"-pos-z",""+t+"-neg-z"],u=this.manifest,r=0,a=u.length;a>r;r++)e=u[r],h=e.id,x.call(o,h)>=0&&s.push(e.src);return i=THREE.ImageUtils.loadTextureCube(s),i.format=THREE.RGBFormat,n=new THREE.MeshBasicMaterial({color:13421772,envMap:i,shading:THREE.FlatShading,side:THREE.DoubleSide})},e.prototype.bind=function(){return e.__super__.bind.call(this),this.hotspot.on("click",this.on_click),this.ui.bind(),this.hotspot.bind(),this.mouse.bind(),$(window).on("dragover",this.on_dragover).on("drop",this.on_drop)},e.prototype.unbind=function(){return e.__super__.unbind.call(this),this.hotspot.off("click",this.on_click),this.ui.unbind(),this.hotspot.unbind(),this.mouse.unbind(),$(window).off("dragover",this.on_dragover).on("drop",this.on_drop)},e.prototype.on_dragover=function(t){return t.preventDefault(),t.stopPropagation()},e.prototype.on_drop=function(t){var e,i;return t.preventDefault(),t.stopPropagation(),e=t.originalEvent.dataTransfer.files[0],"image/jpeg"!==e.type&&"image/png"!==e.type?void alert("File not supported, use an image instead"):(i=new FileReader,i.onload=function(t){return function(e){var i;return t.user_added_texture=!0,i=e.target.result,t.update_cube_map(i)}}(this),i.readAsDataURL(e))},e.prototype.update_cube_map=function(t){var e,i;return e=$("#cubemap"),i=new Image,i.onload=function(n){return function(){var o,s,r,a,u,h,l,c,d,p,_;for(l=i.width,r=i.height,a=4,e.css({width:l/a+"px",height:r/a+"px"}),e.find("img").attr("src",t),o=document.createElement("canvas"),o.setAttribute("width",l),o.setAttribute("height",r),s=o.getContext("2d"),s.drawImage(i,0,0),u=r/l>1?i.width/3:i.height/3,n.urls=[],n.urls.push(n.get_cubemap_tile(s,u,0,u)),n.urls.push(n.get_cubemap_tile(s,0,u,u)),n.urls.push(n.get_cubemap_tile(s,u,u,u)),n.urls.push(n.get_cubemap_tile(s,2*u,u,u)),n.urls.push(n.get_cubemap_tile(s,3*u,u,u)),n.urls.push(n.get_cubemap_tile(s,u,2*u,u)),n.counter_url=0,p=n.urls,_=[],c=0,d=p.length;d>c;c++)h=p[c],i=new Image,i.onload=n.on_cubemap_url_loaded,_.push(i.setAttribute("src",h));return _}}(this),i.setAttribute("src",t)},e.prototype.on_cubemap_url_loaded=function(){var t,e,i,n,o;if(this.counter_url++,this.counter_url===this.urls.length){for(o=this.user_material.envMap.image,t=i=0,n=o.length;n>i;t=++i)e=o[t],e.removeAttribute("crossorigin"),e.setAttribute("src",this.urls[t]);this.user_material.envMap.needsUpdate=!0,this.user_material.needsUpdate=!0}return this.generate_mesh()},e.prototype.get_cubemap_tile=function(t,e,i,n){var o,s,r,a;return o=$(""),o.attr("width",n),o.attr("height",n),s=o[0].getContext("2d"),a=t.getImageData(e,i,n,n),s.putImageData(a,0,0),r=o[0].toDataURL("image/jpeg")},e.prototype.generate_mesh=function(){var t,e,i,n,o,s,r,a,u,h,l,c,d,p,_;for(this.container.remove(this.mesh),n=[.35,.3,.2],t=n[this.iteration-1],this.vertex_sets=[0],e=new THREE.IcosahedronGeometry(50,2),i=u=0,p=this.iteration;p>=0?p>u:u>p;i=p>=0?++u:--u)for(e=this.smooth_geometry(e,i),s=e.vertices.slice(this.vertex_sets[i],this.vertex_sets[i+1]),h=0,c=s.length;c>h;h++)a=s[h],a.multiplyScalar(1+Math.random()*t);if(o=this.user_added_texture?this.user_material:this.materials[this.iteration-1],this.mesh=new THREE.Mesh(e,o),this.container.add(this.mesh),!this.first_time)for(_=this.sound_bases,l=0,d=_.length;d>l;l++)r=_[l],r.fade(1,0,500);return this.sound_bases[this.iteration-1].fade(0,1,500),this.first_time=!1},e.prototype.smooth_geometry=function(t,e){var i,n;return i=new THREE.SubdivisionModifier(e),n=t.clone(),i.modify(n),this.vertex_sets.push(n.vertices.length),n},e.prototype.transition_in=function(){var t;return e.__super__.transition_in.call(this),t={x:.3*Math.PI,y:.5*Math.PI,z:.2*Math.PI,ease:Power1.easeOut},TweenLite.to(this.mesh.rotation,this.config.camera_in_duration,t),g.delay(8,function(t){return function(){return t.interation_lock=!1,TweenLite.killTweensOf(t.mesh.rotation)}}(this)),t={audio_pos_z:0,ease:Power1.easeOut},TweenLite.to(this,this.config.camera_in_duration,t)},e.prototype.update=function(){var t,e,i,n,o;return e=this.get_preset(),i=Math.abs(this.mouse.normal_center_x),n=this.mouse.normal_center_y,o=this.audio_pos_z,t=this.sound_bases[this.iteration-1],t.pos(i,n,o),this.sounds.melody.pos(0,0,o),i*=e.vel_x,t.velocity(i,null,null,t._sounds[0]._id),this.mesh.rotation.x+=this.accel_x*this.mouse.normal_center_x*e.movement_speed,this.mesh.rotation.y+=this.accel_x*this.mouse.normal_center_y*e.movement_speed,this.mesh.rotation.z+=this.accel_y*this.mouse.normal_center_y*e.movement_speed},e.prototype.get_preset=function(){return this.config.iteration_preset[this.iteration-1]},e.prototype.on_click=function(){return this.is_transitioning_out?void 0:(this.force_transition_in_complete(),this.iteration>2?this.iteration=1:this.iteration++,this.generate_mesh(this.iteration))},e}(o)},function(t,e,i){var n,o,s,r,a;for(s=i(9),o=[{id:"lvl0-pos-x",url:"/img/blackice/lvl0/pos-x.jpg",type:"image"},{id:"lvl0-neg-x",url:"/img/blackice/lvl0/neg-x.jpg",type:"image"},{id:"lvl0-pos-y",url:"/img/blackice/lvl0/pos-y.jpg",type:"image"},{id:"lvl0-neg-y",url:"/img/blackice/lvl0/neg-y.jpg",type:"image"},{id:"lvl0-pos-z",url:"/img/blackice/lvl0/pos-z.jpg",type:"image"},{id:"lvl0-neg-z",url:"/img/blackice/lvl0/neg-z.jpg",type:"image"},{id:"lvl1-pos-x",url:"/img/blackice/lvl1/pos-x.jpg",type:"image"},{id:"lvl1-neg-x",url:"/img/blackice/lvl1/neg-x.jpg",type:"image"},{id:"lvl1-pos-y",url:"/img/blackice/lvl1/pos-y.jpg",type:"image"},{id:"lvl1-neg-y",url:"/img/blackice/lvl1/neg-y.jpg",type:"image"},{id:"lvl1-pos-z",url:"/img/blackice/lvl1/pos-z.jpg",type:"image"},{id:"lvl1-neg-z",url:"/img/blackice/lvl1/neg-z.jpg",type:"image"},{id:"lvl2-pos-x",url:"/img/blackice/lvl2/pos-x.jpg",type:"image"},{id:"lvl2-neg-x",url:"/img/blackice/lvl2/neg-x.jpg",type:"image"},{id:"lvl2-pos-y",url:"/img/blackice/lvl2/pos-y.jpg",type:"image"},{id:"lvl2-neg-y",url:"/img/blackice/lvl2/neg-y.jpg",type:"image"},{id:"lvl2-pos-z",url:"/img/blackice/lvl2/pos-z.jpg",type:"image"},{id:"lvl2-neg-z",url:"/img/blackice/lvl2/neg-z.jpg",type:"image"},{id:"base_1",url:"/sound/blackice/bass_layer_1.mp3",type:"sound"},{id:"base_2",url:"/sound/blackice/bass_layer_2.mp3",type:"sound"},{id:"base_3",url:"/sound/blackice/bass_layer_3_0.mp3",type:"sound"},{id:"melody",url:"/sound/blackice/melody_layer.mp3",type:"sound"}],r=0,a=o.length;a>r;r++)n=o[r],n.url=s.base_path+n.url;t.exports=o},function(t,e,i){t.exports={fog_enabled:!0,transition_debug:!1,camera_fov:55,path_in:[{x:0,y:0,z:500},{x:0,y:0,z:80}],path_in_lookat:{x:0,y:0,z:0},path_out:[{x:0,y:0,z:80},{x:0,y:-40.57142857142857,z:71},{x:0,y:-90.85714285714286,z:10}],path_out_lookat:[{x:0,y:0,z:0},{x:0,y:-100,z:0}],camera_in_duration:10,camera_out_duration:2,fog_in_duration:10,fog_out_duration:3,fog_in_start:.01,fog_in_end:.001,fog_out_start:.001,fog_out_end:.1,audio_pos_z_in:-10,audio_pos_z_out:15,iteration_preset:[{movement_speed:.02,vel_x:-200},{movement_speed:.05,vel_x:-250},{movement_speed:.07,vel_x:-280}]}},function(t,e,i){var n,o,s,r,a,u,h,l,c,d,p,_,f,m,g,y,v,b,w=function(t,e){return function(){return t.apply(e,arguments)}},x={}.hasOwnProperty,E=function(t,e){function i(){this.constructor=t}for(var n in e)x.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};_=i(26),g=i(9),c=i(19),p=i(7),m=i(21),o=i(25),s=i(69),v=i(18),b=i(3),n=i(71),f=i(73),d=i(49),y=i(74),h=i(72),l=i(48),a=i(88),r=i(89),t.exports=u=function(t){function e(){return this.update=w(this.update,this),this.glitch=w(this.glitch,this),this.on_mouse_up=w(this.on_mouse_up,this),this.on_mouse_move=w(this.on_mouse_move,this),this.on_transition_in_start=w(this.on_transition_in_start,this),this.on_mouse_down=w(this.on_mouse_down,this),this.setup=w(this.setup,this),e.__super__.constructor.apply(this,arguments)}return E(e,t),e.prototype.xp=0,e.prototype.yp=0,e.prototype.accel=1,e.prototype.reset_amplitude=!1,e.prototype.audio_pos_z=0,e.prototype.setup=function(t){var e,i,n;for(p.fov=d.camera_fov,this.ui=new h("calvarium",this.scene,this.gui),TweenLite.set(this.ui.ui.transition_black,{opacity:1}),d.fog_enabled&&(this.scene.fog=new THREE.FogExp2(0,d.fog_in_start),this.gui.add(this.scene.fog,"density",0,1)),g.debug&&(this.scene.add(new THREE.GridHelper(50,10)),this.scene.add(new THREE.AxisHelper(10)),this.scene.add(new THREE.CameraHelper(c.user))),i=0,n=f.length;n>i;i++)e=f[i],this.scene.add(e);return this.path_in=new a("path_in",this.scene,d.path_in,d.path_in_lookat,65280),this.path_out=new r("path_out",this.scene,d.path_out,d.path_out_lookat,65280),this.mouse=new s($(".hitarea")),this.audio_pos_z=this.config.audio_pos_z_in,this.sounds={background:this.loader.get_asset("background").data,glitch:this.loader.get_asset("glitch").data,after:this.loader.get_asset("after").data},this.update_sound_position(),this.sounds.glitch.volume(.5),this.sounds.background.play(),this.sounds.background.loop(!0),this.container=new THREE.Object3D,this.scene.add(this.container),this.attributes={displacement:{type:"v3",value:[]},customColor:{type:"c",value:[]}},this.uniforms={amplitude:{type:"f",value:0}},d.fog_enabled&&(this.uniforms.topColor={type:"c",value:new THREE.Color(30719)},this.uniforms.bottomColor={type:"c",value:new THREE.Color(16777215)},this.uniforms.offset={type:"f",value:33},this.uniforms.exponent={type:"f",value:.6},this.uniforms.fogColor={type:"c",value:this.scene.fog.color},this.uniforms.fogNear={type:"f",value:this.scene.fog.near},this.uniforms.fogFar={type:"f",value:this.scene.fog.far},this.uniforms.fogDensity={type:"f",value:this.scene.fog.density}),window.uniforms=this.uniforms,this.material=new THREE.ShaderMaterial({uniforms:this.uniforms,attributes:this.attributes,vertexShader:y.vertex(),fragmentShader:y.fragment(),shading:THREE.FlatShading,side:THREE.DoubleSide,wireframe:!0,fog:d.fog_enabled}),this.geometry=this.loader.get_asset("skull").data,this.geometry.dynamic=!0,this.mesh=new THREE.Mesh(this.geometry,this.material),this.mesh.position.y=4,this.container.add(this.mesh),this.lookat=new THREE.Vector3,this.tessellate_geometry(),this.explode_geometry(),this.colors_and_displacement(),this.glitch(),this.bind(),this.emit("setup:complete"),this.ready=!0},e.prototype.bind=function(){return e.__super__.bind.call(this),this.on("transition:in:start",this.on_transition_in_start),this.mouse.on("down",this.on_mouse_down),this.mouse.on("up",this.on_mouse_up),this.mouse.on("move",this.on_mouse_move),this.ui.bind(),this.mouse.bind()},e.prototype.unbind=function(){return e.__super__.unbind.call(this),this.off("transition:in:start",this.on_transition_in_start),this.mouse.off("down",this.on_mouse_down),this.mouse.off("up",this.on_mouse_up),this.mouse.off("move",this.on_mouse_move),this.ui.unbind(),this.mouse.unbind()},e.prototype.on_mouse_down=function(){return this.uniforms.amplitude.value=0,this.glitch_pass.generateTrigger(),this.glitch_pass.goWild=!0,this.sounds.glitch.play(),this.sounds.glitch.loop(!0),this.force_transition_in_complete()},e.prototype.on_transition_in_start=function(){return TweenLite.to(this.ui.ui.transition_black,2,{opacity:0,delay:3})},e.prototype.on_mouse_move=function(){var t,e,i,n,o;return n=2*Math.abs(this.mouse.normal_center_x),this.x=.5*HALF_PI*this.mouse.normal_center_y,this.y=HALF_PI*this.mouse.normal_center_x,null!=(o=this.rotation_tween)&&o.kill(),this.mouse.is_down?(e=Expo.easeOut,t=1.2):(e=Cubic.easeOut,t=20),i={x:this.x,y:this.y,ease:e},this.rotation_tween=TweenLite.to(this.mesh.rotation,t,i)},e.prototype.on_mouse_up=function(){var t,e;return this.glitch_pass.goWild=!1,null!=(e=this.speed_tween)&&e.kill(),this.accel=80,t={accel:1,ease:Power1.easeOut},this.speed_tween=TweenLite.to(this,.35,t),this.sounds.glitch.stop(),this.sounds.after.play()},e.prototype.glitch=function(){return this.composer=new THREE.EffectComposer(m),this.composer.addPass(new THREE.RenderPass(this.scene,c.user)),this.glitch_pass=new THREE.GlitchPass,this.glitch_pass.renderToScreen=!0,this.composer.addPass(this.glitch_pass)},e.prototype.tessellate_geometry=function(){var t,e,i,n;for(e=new THREE.TessellateModifier(1),n=[],t=i=0;12>=i;t=++i)n.push(e.modify(this.geometry));return n},e.prototype.explode_geometry=function(){var t;return t=new THREE.ExplodeModifier,t.modify(this.geometry)},e.prototype.colors_and_displacement=function(){var t,e,i,n,o,s,r,a,u,h,l,c,d,p;for(t=this.attributes.customColor.value,e=this.attributes.displacement.value,a=0,p=[],i=c=0,d=this.geometry.faces.length;d>=0?d>c:c>d;i=d>=0?++c:--c)n=0*Math.random(),r=0*Math.random(),s=.3*Math.random(),u=112*(.5-Math.random()),h=112*(.5-Math.random()),l=112*(.5-Math.random()),p.push(function(){var i,c;for(c=[],o=i=0;2>=i;o=++i)t[a]=new THREE.Color,t[a].setHSL(n,r,s),t[a].convertGammaToLinear(),e[a]=new THREE.Vector3,e[a].set(u,h,l),c.push(a+=1);return c}());return p},e.prototype.reset_amplitude=function(){var t,e;return null!=(e=this.reset_tween)&&e.kill(),this.animate_calvarium=!1,t={value:0,ease:Power1.easeInOut},this.reset_tween=TweenLite.to(this.uniforms.amplitude,1,t)},e.prototype.update_sound_position=function(){return this.sounds.background.pos(0,0,this.audio_pos_z),this.sounds.glitch.pos(0,0,this.audio_pos_z)},e.prototype.update=function(){return this.ready?(this.mouse.is_down?this.uniforms.amplitude.value-=.005*this.accel:this.uniforms.amplitude.value+=8e-4*this.accel,this.uniforms.amplitude.value=THREE.Math.clamp(this.uniforms.amplitude.value,0,1e4),this.update_sound_position(),m.setSize(b.width,b.height),this.composer.render()):void 0},e.prototype.destroy=function(){return clearTimeout(this.render_interval),e.__super__.destroy.call(this)},e}(n)},function(t,e,i){var n,o,s,r,a;for(s=i(9),o=[{id:"GlitchPass",url:"/js/calvarium/GlitchPass.js",type:"js"},{id:"skull",url:"/js/calvarium/skull.js",type:"geometry"},{id:"background",url:"/sound/calvarium/background.mp3",type:"sound"},{id:"glitch",url:"/sound/calvarium/glitch.mp3",type:"sound"},{id:"after",url:"/sound/calvarium/after.mp3",type:"sound"}],r=0,a=o.length;a>r;r++)n=o[r],n.url=s.base_path+n.url;t.exports=o},function(t,e,i){t.exports={fog_enabled:!0,transition_debug:!1,has_composer:!0,camera_fov:80,path_in:[{x:0,y:0,z:400},{x:0,y:0,z:80}],path_in_lookat:{x:0,y:0,z:0},path_out:[{x:0,y:.5714285714285836,z:80.57142857142856},{x:0,y:-10,z:0},{x:-20,y:-20,z:-30}],path_out_lookat:[{x:0,y:0,z:0},{x:0,y:0,z:-400}],camera_in_duration:15,camera_out_duration:6,fog_in_duration:16,fog_out_duration:4,fog_in_start:.03,fog_in_end:.01,fog_out_start:.001,fog_out_end:.01,audio_pos_z_in:10,audio_pos_z_out:-10}},function(t,e,i){var n,o,s,r,a,u,h,l,d,p,_,f,m,g,y,v,b,w=function(t,e){return function(){return t.apply(e,arguments)}},x={}.hasOwnProperty,E=function(t,e){function i(){this.constructor=t}for(var n in e)x.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};y=i(9),_=i(19),f=i(7),a=i(25),u=i(69),v=i(18),b=i(3),g=i(21),o=i(71),m=i(75),p=i(76),d=i(77),s=i(78),l=i(88),h=i(89),r=i(70),t.exports=n=function(t){function e(){return this.on_builder_complete=w(this.on_builder_complete,this),this.generate=w(this.generate,this),this.on_mouse_down=w(this.on_mouse_down,this),this.on_move=w(this.on_move,this),this.update=w(this.update,this),this.change_geometry=w(this.change_geometry,this),this.on_key_up=w(this.on_key_up,this),this.on_key_down=w(this.on_key_down,this),this.set_props=w(this.set_props,this),this.setup=w(this.setup,this),e.__super__.constructor.apply(this,arguments)}return E(e,t),e.prototype.ready=!1,e.prototype.geometry="",e.prototype.distance=0,e.prototype.rx=.1,e.prototype.ry=.1,e.prototype.rz=.1,e.prototype.fog_near=0,e.prototype.audio_pos_z=0,e.prototype.current_sound_vol=.5,e.prototype.fog_color=0,e.prototype.setup=function(t){var e,i,n,o,a,b,w,x,E,k;f.fov=this.config.camera_fov,this.ui=new p("elements",this.scene,t),this.keyboard=new r($(window)),this.config.fog_enabled&&(this.scene.fog=new THREE.FogExp2(this.fog_color,this.config.fog_in_start),this.gui.add(this.scene.fog,"density",0,1),this.fog_near=this.config.fog_near),y.debug&&(this.scene.add(new THREE.GridHelper(50,10)),this.scene.add(new THREE.AxisHelper(10)),this.scene.add(new THREE.CameraHelper(_.user))),this.path_in=new l("path_in",this.scene,this.config.path_in,this.config.path_in_lookat,65280),this.path_out=new h("path_out",this.scene,this.config.path_out,this.config.path_out_lookat,65280),this.mouse=new u($("body")),this.set_props("octahedron"),this.audio_pos_z=this.config.audio_pos_z_in,this.sounds={background:v.get_asset("background",t).data,dodecahedron:v.get_asset("aether",t).data,octahedron:v.get_asset("air",t).data,hexahedron:v.get_asset("earth",t).data,tetrahedron:v.get_asset("fire",t).data,icosahedron:v.get_asset("water",t).data},k=this.sounds;for(a in k)x=k[a],x.volume(0),x.play(),x.loop(!0);this.update_sound_position(),this.sounds.background.volume(.5),this.sounds.octahedron.fade(0,.5,400),g.shadowMapEnabled=!0,g.shadowMapSoft=!0,this.scene.add(m.ambient),this.scene.add(m.directional),this.container=new THREE.Object3D,this.scene.add(this.container),this.mesh_container=new THREE.Object3D,this.container.add(this.mesh_container),this.builder=new s,this.sierpinski=new d.SierpinskiPolyhedron,w={color:16711680,wireframe:!0,visible:!1},E=this.config.sphere_radius,e=64,this.sphere=new THREE.Mesh(new THREE.SphereGeometry(E,e,e),new THREE.MeshLambertMaterial(w)),this.scene.add(this.sphere),b=[];for(o in this.config.geometries)b.push(o);return n=this.gui.addFolder("controller::elements::mesh"),i=this.gui.addFolder("controller::elements::fog"),n.add(this,"geometry",b).onChange(function(t){return function(t){return c.log(t)}}(this)),n.add(this.config,"radius",20,100),n.add(this.config,"scale_ratio",0,10),n.addColor(this.config,"color"),n.add(this.config,"wireframe"),n.add(this.config,"wireframe_thickness",1,10),n.add(this.config,"blending",["NormalBlending","AdditiveBlending"]),n.add(this.config,"opacity",0,1),n.add(this.config,"deform",-5,5).onChange(function(t){return function(){return t.deform_mesh()}}(this)),n.add(this,"rx",0,2*Math.PI),n.add(this,"ry",0,2*Math.PI),n.add(this,"rz",0,2*Math.PI),i.add(this.config,"fog_near",0,.1),i.add(this.config,"fog_far",0,.2),i.add(this.config,"fog",0,.1).listen(),this.once("generated",function(t){return function(){return t.bind(),t.emit("setup:complete")}}(this)),this.generate()},e.prototype.set_props=function(t){var e,i,n,o;this.geometry_id=t,e=this.preset(),o=[];for(i in e)n=e[i],o.push(this.config[i]=n);return o},e.prototype.bind=function(){return c.debug("binding"),f.on("update",this.update),this.keyboard.on("key:down:space",this.on_key_down),this.keyboard.on("key:up:space",this.on_key_up),this.ui.on("change:geometry",this.change_geometry),this.mouse.on("move",this.on_move),this.mouse.on("down",this.on_mouse_down),this.ui.bind(),this.keyboard.bind(),this.mouse.bind()},e.prototype.unbind=function(){return c.debug("unbinding"),f.off("update",this.update),this.keyboard.off("key:down:space",this.on_key_down),this.keyboard.off("key:up:space",this.on_key_up),this.ui.off("change:geometry",this.generate),this.mouse.off("move",this.on_move),this.mouse.off("down",this.on_mouse_down),this.ui.unbind(),this.keyboard.unbind(),this.mouse.unbind()},e.prototype.on_key_down=function(){return c.log("down"),this.is_transitioning_in||this.is_transition_disabled?void 0:(c.log("x"),this.transition_out_forward())},e.prototype.on_key_up=function(){return this.transition_out_backward()},e.prototype.change_geometry=function(t){var e,i;return this.sounds[this.geometry_id].fade(this.current_sound_vol,0,400),this.set_props(t),this.disable_transition(),this.ui.show_title(t),e={opacity:1,ease:Power3.easeOut,onComplete:function(t){return function(){return t.unbind(),t.generate()}}(this)},TweenLite.to(this.ui.ui.transition_black,3.5,e),i=this.preset(),this.sounds[this.geometry_id].fade(0,.5,400)},e.prototype.calc_fog=function(){return this.config.fog_far+this.fog_near},e.prototype.update=function(){var t,e,i;return this.config.fog_enabled&&(e=Math.max(this.config.fog_near,this.fog_near),this.mouse.is_dragging&&!this.is_transitioning_out&&(i=2*Math.abs(this.mouse.normal_center_x),this.fog_near=v.lerp(this.config.fog_near,.012,i),this.sounds.background.volume(this.mouse.normal_x),this.current_sound_vol=1-this.mouse.normal_x,this.sounds[this.geometry_id].volume(this.current_sound_vol)),this.config.fog=this.calc_fog(),this.scene.fog.density=this.config.fog),this.ready?(this.mesh.material.wireframe=this.config.wireframe,this.mesh.material.wireframeLinewidth=this.config.wireframe_thickness,this.mesh.material.opacity=this.config.opacity,t=this.config.color.replace("#","0x"),this.mesh.material.color.setHex(t),this.mesh.rotation.x+=5e-4,this.mesh.rotation.y+=5e-4,this.mesh.rotation.z+=5e-4,this.update_sound_position()):void 0},e.prototype.update_sound_position=function(){return this.sounds.background.pos(0,0,this.audio_pos_z),this.sounds[this.geometry_id].pos(0,0,this.audio_pos_z)},e.prototype.on_move=function(){var t,e,i,n,o,s,r,a,u,h,l,c,d;if(!this.is_transitioning_out)return this.mouse.is_down&&(r=.5*b.width/b.width,a=.5*b.height/b.height,i=this.mouse.normal_x,null!=(h=this.deform_tween)&&h.kill(),s={distance:i,ease:Power2.easeOut,onUpdate:function(t){return function(){return t.config.deform=t.distance.map(0,1,-1,1,i),t.deform_mesh()}}(this)},this.deform_tween=TweenLite.to(this,.3,s),u=-60*Math.abs(this.mouse.normal_center_x),this.mesh_container.position.z=u),this.ready?(null!=(l=this.mesh_rotate_tween)&&l.kill(),t=.01*Math.PI,a=v.lerp(-t,t,this.mouse.normal_x),s={y:a,ease:Power4.easeOut},this.mesh_rotate_tween=TweenLite.to(this.mesh_container.rotation,5,s),e=this.config.cam_move_bounds,o=new THREE.Vector2(-e,-e),n=new THREE.Vector2(e,e),null!=(c=this.mesh_position_tween)&&c.kill(),r=v.lerp(o.x,n.x,this.mouse.normal_x),a=v.lerp(o.y,n.y,this.mouse.normal_y),s={x:r,y:-a,ease:Power4.easeOut},this.mesh_position_tween=TweenLite.to(this.mesh_container.position,5,s),null!=(d=this.cam_position_tween)?d.kill():void 0):void 0},e.prototype.on_mouse_down=function(){return this.force_transition_in_complete()},e.prototype.preset=function(){return this.config.geometries[this.geometry_id]; + +},e.prototype.generate=function(){var t;return this.mesh&&this.mesh_container.remove(this.mesh),this.ready=!1,t=this.sierpinski.generate(this.config.geometry,this.config.radius,this.config.iteration,this.config.scale_ratio,0),this.builder.build(this.config.geometry,t,this.sierpinski.logarithmic_scale(),0,this.on_builder_complete)},e.prototype.on_builder_complete=function(t){var e,i,n,o,s,r,a,u,h,l,c,d,p,_,f;for(u={color:this.config.color,wireframe:this.config.wireframe,wireframeLinewidth:this.config.wireframe_thickness,blending:THREE[this.config.blending],opacity:this.config.opacity,transparent:!0},this.mesh=new THREE.Mesh(t,new THREE.MeshLambertMaterial(u)),this.mesh.castShadow=!0,this.mesh.receiveShadow=!0,this.mesh.rotation.x=this.preset().rotate_x,this.mesh.rotation.y=this.preset().rotate_y,this.mesh.rotation.z=this.preset().rotate_z,this.mesh_container.add(this.mesh),this.data_map=[],_=this.mesh.geometry.vertices,s=l=0,d=_.length;d>l;s=++l){for(o=_[s],i=1/0,r=0,o.weight=Math.random(),o.position=new THREE.Vector3(o.x,o.y,o.z),f=this.sphere.geometry.vertices,a=c=0,p=f.length;p>c;a=++c)h=f[a],n=h.distanceTo(o),i>n&&(i=n,r=a);this.data_map.push({vertex:r,distance:i})}return this.config.deform=0,this.distance=.5,this.deform_mesh(),e=this.config.geometries[this.geometry],this.ready=!0,this.bind(),this.enable_transition(),this.mesh_container.position.z=0,this.fog_near=this.config.fog_near,u={opacity:0,ease:Power4.easeOut,delay:1.5,onComplete:function(t){return function(){return t.ui.hide_title()}}(this)},TweenLite.to(this.ui.ui.transition_black,2,u),v.delay(.3,function(t){return function(){return t.emit("generated")}}(this))},e.prototype.deform_mesh=function(){var t,e,i,n,o,s,r,a,u,h,l;for(l=this.data_map,e=u=0,h=l.length;h>u;e=++u)t=l[e],i=e,s=t.vertex,o=t.distance/50,r=this.mesh.geometry.vertices[i].position,a=this.sphere.geometry.vertices[s],0===r.x&&0===r.y&&0===r.z||(n=r.clone().lerp(a.clone(),this.config.deform),this.mesh.geometry.vertices[i].x=n.x,this.mesh.geometry.vertices[i].y=n.y,this.mesh.geometry.vertices[i].z=n.z);return this.mesh.geometry.verticesNeedUpdate=!0},e}(o)},function(t,e,i){var n,o,s,r,a;for(s=i(9),o=[{id:"dodecahedron_sequence",url:"/img/elements/dodecahedron/dodecahedron.frames.json",type:"sequence"},{id:"hexahedron_sequence",url:"/img/elements/hexahedron/hexahedron.frames.json",type:"sequence"},{id:"tetrahedron_sequence",url:"/img/elements/tetrahedron/tetrahedron.frames.json",type:"sequence"},{id:"octahedron_sequence",url:"/img/elements/octahedron/octahedron.frames.json",type:"sequence"},{id:"icosahedron_sequence",url:"/img/elements/icosahedron/icosahedron.frames.json",type:"sequence"},{id:"background",url:"/sound/elements/background.mp3",type:"sound"},{id:"aether",url:"/sound/elements/aether.mp3",type:"sound"},{id:"air",url:"/sound/elements/air.mp3",type:"sound"},{id:"earth",url:"/sound/elements/earth.mp3",type:"sound"},{id:"fire",url:"/sound/elements/fire.mp3",type:"sound"},{id:"water",url:"/sound/elements/water.mp3",type:"sound"}],r=0,a=o.length;a>r;r++)n=o[r],n.url=s.base_path+n.url;t.exports=o},function(t,e,i){t.exports={fog_enabled:!0,transition_debug:!1,camera_fov:35,path_in:[{x:0,y:0,z:400},{x:0,y:0,z:40}],path_in_lookat:{x:0,y:0,z:0},path_out:[{x:0,y:0,z:40},{x:0,y:-27,z:0},{x:0,y:-60,z:-20}],path_out_lookat:[{x:0,y:0,z:-190},{x:0,y:-260,z:-190}],camera_in_duration:10,camera_out_duration:5,fog_in_duration:10,fog_out_duration:5,fog_in_start:.1,fog_in_end:.01,fog_out_start:.01,fog_out_end:.1,audio_pos_z_in:35,audio_pos_z_out:15,cam_move_bounds:.5,sphere_radius:30,geometry:"",iteration:0,radius:0,scale_ratio:0,deform:0,color:"#ffffff",wireframe:!0,wireframe_thickness:0,blending:"",opacity:.35,fog_near:.029,fog_far:.009,cam_zoom_percent:1,geometries:{dodecahedron:{geometry:"DodecahedronGeometry",iteration:2,radius:20,scale_ratio:3.61803399,color:"#ffffff",wireframe:!0,wireframe_thickness:1.5,blending:"NormalBlending",opacity:1,rotate:!0,fog:.03,deform:0,rotate_x:0,rotate_y:1.06,rotate_z:0,sound:"aether"},icosahedron:{geometry:"IcosahedronGeometry",iteration:3,radius:20,scale_ratio:2.61803399,color:"#ffffff",wireframe:!0,wireframe_thickness:1.5,blending:"NormalBlending",opacity:1,rotate:!0,fog:.03,deform:0,rotate_x:1.27,rotate_y:1.06,rotate_z:0,sound:"water"},tetrahedron:{geometry:"TetrahedronGeometry",iteration:6,radius:20,scale_ratio:2,color:"#ffffff",wireframe:!0,wireframe_thickness:1.5,blending:"NormalBlending",opacity:1,rotate:!0,fog:.03,deform:0,rotate_x:0,rotate_y:.99,rotate_z:2.26,sound:"fire"},octahedron:{geometry:"OctahedronGeometry",iteration:5,radius:20,scale_ratio:2,color:"#ffffff",wireframe:!0,wireframe_thickness:1.5,blending:"NormalBlending",opacity:1,rotate:!0,fog:.046,deform:0,rotate_x:.21,rotate_y:0,rotate_z:0,sound:"air"},hexahedron:{geometry:"BoxGeometry",iteration:4,radius:20,scale_ratio:2.4,color:"#ffffff",wireframe:!0,wireframe_thickness:1.5,blending:"NormalBlending",opacity:1,rotate:!0,fog:.03,deform:0,rotate_x:.49,rotate_y:Math.PI/4,rotate_z:0,sound:"earth"}}}},function(t,e,i){var n,o,s,r,a,u,h,l,d,p,_,f,m,g,y=function(t,e){return function(){return t.apply(e,arguments)}};p=i(26),f=i(9),h=i(19),d=i(7),s=i(25),g=i(18),o=i(70),_=i(79),m=i(80),l=i(55),a=i(81),u=i(54),r=i(89),t.exports=n=function(){function t(t,e){this.scene=t,this.gui=e,this.next=y(this.next,this),this.update=y(this.update,this),this.setup=y(this.setup,this),p(this)}return t.prototype.camera_path=null,t.prototype.attributes=null,t.prototype.ready=!1,t.prototype.tweens=Array,t.prototype.has_transitioned_out=!1,t.prototype.is_transitioning=!1,t.prototype.transition_progress=0,t.prototype.fov_transition_progress=0,t.prototype.dolly_transition_progress=0,t.prototype.load=function(){var t,e,i;for(this.loader=new s,e=0,i=u.length;i>e;e++)t=u[e],this.loader.add(t.id,t.url,t.type);return this.loader.once("loaded",this.setup),this.loader.load()},t.prototype.setup=function(t){var e,i,n,s,u,c,p,y,v,b,w,x,E,k,T,z,R,C,A,H,M,S,P,L,O,I,B;for(d.fov=l.camera_fov,this.ui=new a(this.scene,this.gui,t),this.keyboard=new o($(window)),this.tweens=[],l.fog_enabled&&(this.scene.fog=new THREE.FogExp2(0,l.fog_in_start),this.gui.add(this.scene.fog,"density",0,.001)),f.debug&&(this.scene.add(new THREE.GridHelper(50,10)),this.scene.add(new THREE.AxisHelper(10)),this.scene.add(new THREE.CameraHelper(h.user))),S=0,O=_.length;O>S;S++)u=_[S],this.scene.add(u);for(this.sounds={start:this.loader.get_asset("start").data,loop:this.loader.get_asset("loop").data,transition_in:this.loader.get_asset("transition_in").data,transition_out:this.loader.get_asset("transition_out").data},this.sounds.start.play(),this.sounds.transition_in.play(),g.delay(19,function(t){return function(){return t.sounds.loop.volume(0),t.sounds.loop.fade(0,1,1e3),t.sounds.loop.play(),t.sounds.loop.loop(!0)}}(this)),this.container=new THREE.Object3D,this.scene.add(this.container),this.container.position.fromArray(l.container_position),this.container.rotation.fromArray(l.container_rotation),i=1e4,l.add_controls&&(this.gui.add(this.container.rotation,"x",0,PI_2).name("rotation x"),this.gui.add(this.container.rotation,"y",0,PI_2).name("rotation y"),this.gui.add(this.container.rotation,"z",0,PI_2).name("rotation z"),this.gui.add(this.container.position,"x",-i,i).name("position x"),this.gui.add(this.container.position,"y",-i,i).name("position y"),this.gui.add(this.container.position,"z",-i,i).name("position z")),this.attributes={size:{type:"f",value:[]},alpha:{type:"f",value:[]}},T={color:{type:"c",value:new THREE.Color(16777215)},texture:{type:"t",value:THREE.ImageUtils.loadTexture(this.loader.get_asset("particle").src)}},l.fog_enabled&&(T.topColor={type:"c",value:new THREE.Color(30719)},T.bottomColor={type:"c",value:new THREE.Color(16777215)},T.offset={type:"f",value:33},T.exponent={type:"f",value:.6},T.fogColor={type:"c",value:this.scene.fog.color},T.fogNear={type:"f",value:this.scene.fog.near},T.fogFar={type:"f",value:this.scene.fog.far},T.fogDensity={type:"f",value:this.scene.fog.density}),c=new THREE.ShaderMaterial({uniforms:T,attributes:this.attributes,vertexShader:m.vertex(),fragmentShader:m.fragment(),blending:THREE.AdditiveBlending,transparent:!0,fog:l.fog_enabled}),n=new THREE.Geometry,x=350*l.scale,w=2e3*l.scale,A=10,H=400*l.scale,k=20,E=40,s=P=0,I=l.partices;I>=0?I>P:P>I;s=I>=0?++P:--P)e=g.random(0,PI_2),b=g.random(x,w),R=b*Math.cos(e),C=H*Math.cos(b/w*Math.PI),M=b*Math.sin(e),n.vertices.push(new THREE.Vector3(R,C,M)),this.attributes.alpha.value[s]=g.random(.2,1),this.attributes.size.value[s]=g.random(k,E);for(this.mesh=new THREE.PointCloud(n,c),this.container.add(this.mesh),k=40,E=80,n=new THREE.Geometry,w=x,x=150*l.scale,H=1e3*l.scale,s=L=0,B=l.tunnel_particles;B>=0?B>L:L>B;s=B>=0?++L:--L)e=g.random(0,PI_2),b=g.random(x,w),v=Math.random(),R=b*Math.cos(e),C=13422+H*Math.cos(b/w*Math.PI),M=b*Math.sin(e),n.vertices.push(new THREE.Vector3(R,C,M)),y=g.random(.2,1),v=C/H,v>.5&&(y+=g.lerp(y,0,.5+v)),this.attributes.alpha.value[s]=y,this.attributes.size.value[s]=g.random(k,E);return this.tunnel_mesh=new THREE.PointCloud(n,c),this.container.add(this.tunnel_mesh),p=new THREE.Mesh(new THREE.SphereGeometry(100,4,4)),p.position.y=15e3,p.visible=!1,this.container.add(p),this.container.updateMatrixWorld(),z=new THREE.Vector3,z.setFromMatrixPosition(p.matrixWorld),l.path_camera_dolly.unshift(z.toArray()),l.path_in.unshift({x:z.x,y:z.y,z:z.z}),l.path_out.push({x:z.x,y:z.y,z:z.z}),l.path_in_lookat.unshift({x:z.x,y:z.y,z:z.z}),this.path_in=new r("path_in",this.scene,l.path_in,l.path_in_lookat,65280),this.path_out=new r("path_out",this.scene,l.path_out,l.path_in_lookat.reverse(),65280),this.ready=!0,this.emit("setup:complete"),this.bind()},t.prototype.bind=function(){return this.keyboard.bind(),d.on("update",this.update)},t.prototype.unbind=function(){return this.keyboard.unbind(),d.off("update",this.update)},t.prototype.transition_in=function(){var t,e;return this.is_transitioning=!0,this.emit("transition:in:complete"),h.user.position.fromArray(l.path_in[0]),h.user.lookAt(new THREE.Vector3),this.ui.transition_in(),this.kill_tweens(),e={progress:0},t={progress:1,ease:Power2.easeOut,onUpdate:function(t){return function(){var i;return i=t.path_in.spline.getPointAt(e.progress),h.user.position.copy(i),i=t.path_in.spline_camera.getPointAt(e.progress),h.user.lookAt(i)}}(this),onComplete:function(t){return function(){return t.is_transitioning=!1}}(this)},l.transition_debug&&(l.camera_in_duration=.1),this.tweens.push(TweenLite.to(e,l.camera_in_duration,t)),l.fog_enabled?(this.scene.fog.density=l.fog_in_start,t={density:l.fog_in_end,ease:Power2.easeOut},l.transition_debug&&(l.fog_in_duration=0),this.tweens.push(TweenLite.to(this.scene.fog,l.fog_in_duration,t))):void 0},t.prototype.transition_out_forward=function(t){var e,i;return null==t&&(t=!1),this.is_transitioning?void this.transition_out_fast():(this.is_transitioning=!0,this.ui.transition_out(),this.kill_tweens(),i={progress:0},e={progress:1,ease:Power3.easeInOut,onStart:function(t){return function(){return t.sounds.transition_out.play()}}(this),onUpdate:function(t){return function(){var e;return e=t.path_out.spline.getPointAt(i.progress),h.user.position.copy(e),e=t.path_out.spline_camera.getPointAt(i.progress),h.user.lookAt(e)}}(this),onComplete:function(t){return function(){return t.is_transitioning=!1,t.next()}}(this)},this.tweens.push(TweenLite.to(i,l.camera_out_duration,e)),l.fog_enabled?(this.scene.fog.density=l.fog_in_end,e={density:l.fog_in_start,ease:Power2.easeOut,delay:l.camera_out_duration-2},this.tweens.push(TweenLite.to(this.scene.fog,l.fog_out_duration,e))):void 0)},t.prototype.update=function(){var t;if(this.ready)return t=.001,this.mesh.rotation.y+=t,this.tunnel_mesh.rotation.y+=t},t.prototype.transition_out_fast=function(){return c.log("transition_out_fast"),this.ui.once("transition:out:fast:complete",function(t){return function(){return t.kill_tweens(),t.next()}}(this)),this.ui.transition_out_fast()},t.prototype.next=function(){return this.has_transitioned_out=!0,this.emit("next")},t.prototype.kill_tweens=function(){var t,e,i,n,o;for(n=this.tweens,o=[],e=0,i=n.length;i>e;e++)t=n[e],o.push(null!=t?t.kill():void 0);return o},t.prototype.enable_transition=function(){},t.prototype.disable_transition=function(){},t.prototype.destroy=function(){var t,e,i;i=this.sounds;for(t in i)e=i[t],e.fade(1,0,1e3);return g.delay(1,function(i){return function(){var n,o,s,r,a;for(r=i.scene.children,o=0,s=r.length;s>o;o++)n=r[o],i.scene.remove(n);a=i.sounds;for(t in a)e=a[t],e.stop(),e.unload();return i.kill_tweens(),i.unbind(),i.ui.destroy(),i.loader.dispose(),i.emit("destroyed")}}(this))},t}()},function(t,e,i){var n,o,s,r,a;for(s=i(9),o=[{id:"particle",url:"/img/home/particle.jpg",type:"image"},{id:"hires_logo",url:"/img/home/hires.png",type:"image"},{id:"hires_sequence",url:"/img/epilogue/hires.frames.json",type:"sequence"},{id:"start",url:"/sound/home/start.mp3",type:"sound"},{id:"loop",url:"/sound/home/loop.mp3",type:"sound"},{id:"transition_in",url:"/sound/epilogue/transition_in.mp3",type:"sound"},{id:"transition_out",url:"/sound/epilogue/transition_out.mp3",type:"sound"}],r=0,a=o.length;a>r;r++)n=o[r],n.url=s.base_path+n.url;t.exports=o},function(t,e,i){t.exports={add_controls:!1,transition_debug:!1,fog_enabled:!0,camera_fov:80,camera_fov_out:120,camera_fov_out_duration:10,path_in:[{x:0,y:0,z:0},{x:1200,y:2571,z:9257.142857142859},{x:-3164.0482279868447,y:13828.571428571428,z:9257.142857142859},{x:-5034.709535988308,y:2e4,z:8059.919620021923}],path_out:[{x:-5034.709535988308,y:2e4,z:8059.919620021923},{x:1200,y:3571,z:5e3},{x:0,y:0,z:0}],path_in_lookat:[{x:0,y:0,z:0}],path_camera_dolly:[[0,0,0]],camera_in_duration:40,camera_out_duration:10,fog_in_duration:2,fog_out_duration:2,ui_delay:3,fog_in_start:7e-4,fog_in_end:7e-5,scale:10,partices:4e5,tunnel_particles:3e4,container_position:[1500,1050,4400],container_rotation:[4.4,.01,.28]}},function(t,e,i){var n,o,s,r,a,u,h,l,c,d,p,_,f,m,g,y=function(t,e){return function(){return t.apply(e,arguments)}},v={}.hasOwnProperty,b=function(t,e){function i(){this.constructor=t}for(var n in e)v.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};_=i(26),m=i(9),c=i(19),p=i(7),s=i(25),r=i(69),g=i(18),n=i(71),f=i(82),d=i(58),h=i(72),l=i(57),u=i(88),a=i(89),t.exports=o=function(t){function e(){return this.update=y(this.update,this),this.on_mouse_down=y(this.on_mouse_down,this),this.setup=y(this.setup,this),e.__super__.constructor.apply(this,arguments)}return b(e,t),e.prototype.material=null,e.prototype.holding_frames=0,e.prototype.setup=function(t){var e,n,o,s,l,_,g,y,v,b,w,x,E,k,T,z,R;for(p.fov=d.camera_fov,this.ui=new h("hires",this.scene,this.gui),d.fog_enabled&&(this.scene.fog=new THREE.FogExp2(0,d.fog_in_start),this.gui.add(this.scene.fog,"density",0,1)),m.debug&&(this.scene.add(new THREE.GridHelper(50,10)),this.scene.add(new THREE.AxisHelper(10)),this.scene.add(new THREE.CameraHelper(c.user))),T=f.all,v=0,x=T.length;x>v;v++)s=T[v],this.scene.add(s);for(this.path_in=new u("path_in",this.scene,d.path_in,d.path_in_lookat,65280),this.path_out=new a("path_out",this.scene,d.path_out,d.path_out_lookat,65280,this.gui,100),this.mouse=new r($(".hitarea")),this.gui.addColor(d,"color_left").name("Left color"),this.gui.addColor(d,"color_right").name("Right color"),this.gui.addColor(d,"color_directional").name("Directional color"),this.gui.add(d,"speed",0,2).name("Movement speed"),this.gui.add(d,"camera_fov",10,200).listen().name("Field of vision"),this.gui.add(d,"line_thickness",1,8).name("Line thickness"),e=i(83),this.sound=new e,setTimeout(function(t){return function(){return t.sound.klank(),t.sound.percolation(),t.sound.clickable_distortion(),t.sound.background_atmos(15)}}(this),1e3),this.container=new THREE.Object3D,this.scene.add(this.container),g=[],b=0,E=t.length;E>b;b++)n=t[b],("pos-x"===(z=n.id)||"neg-x"===z||"pos-y"===z||"neg-y"===z||"pos-z"===z||"neg-z"===z)&&g.push(n.src);for(this.cubemap=THREE.ImageUtils.loadTextureCube(g),this.cubemap.format=THREE.RGBFormat,_=THREE.ShaderLib.cube,_.uniforms.tCube.texture=this.cubemap,this.material=new THREE.ShaderMaterial({fragmentShader:_.fragmentShader,vertexShader:_.vertexShader,uniforms:_.uniforms,depthWrite:!1,side:THREE.BackSide}),o=this.loader.get_asset("hires_logo").data,R=o.vertices,w=0,k=R.length;k>w;w++)y=R[w],y.multiplyScalar(10);return o.__dirtyVertices=!0,l={shading:THREE.FlatShading,color:16777215},this.mesh=new THREE.Mesh(o,new THREE.MeshLambertMaterial(l)),this.mesh.position.x=20,this.scene.add(this.mesh),this.add_triangles(),this.bind(),this.emit("setup:complete")},e.prototype.add_triangles=function(){var t,e,i,n,o,s,r,a,u,h,l,c,p,_,f,m,g,y,v,b,w,x,E,k,T,z,R,C;for(a=this.mesh.geometry.vertices.length,f=function(t){return Math.floor(Math.random()*t)},u=[],t=2*Math.PI,e=function(e){var i,n,o,s,r;return i=new THREE.Vector3,o=i.clone(),o.x+=e*Math.cos(Math.random()*t),o.y+=e*Math.sin(Math.random()*t),o.z+=e*Math.sin(Math.random()*t),s=i.clone(),s.x+=e*Math.cos(Math.random()*t),s.y+=e*Math.sin(Math.random()*t),s.z+=e*Math.sin(Math.random()*t),r=i.clone(),r.x+=e*Math.cos(Math.random()*t),r.y+=e*Math.sin(Math.random()*t),r.z+=e*Math.sin(Math.random()*t),n=new THREE.Geometry,n.vertices.push(o),n.vertices.push(s),n.vertices.push(r),n.faces.push(new THREE.Face3(0,1,2)),n.computeFaceNormals(),n},c=1,l=50,g=[],i=new THREE.Geometry,a=1e3,s=x=0;a>=0?a>x:x>a;s=a>=0?++x:--x){for(_=this.mesh.geometry.vertices[f(a)],m=c+Math.random()*(l-c),o=e(m),R=o.vertices,s=E=0,T=R.length;T>E;s=++E)y=R[s],o.vertices[s].x+=_.x,o.vertices[s].y+=_.y,o.vertices[s].z+=_.z;i.merge(o)}for(p={envMap:this.cubemap,shading:THREE.FlatShading,wireframe:!0,wireframeLinewidth:d.line_thickness},h=new THREE.MeshLambertMaterial(p),this.triangles_mesh=new THREE.Mesh(i,h),this.scene.add(this.triangles_mesh),C=this.triangles_mesh.geometry.faces,r=k=0,z=C.length;z>k;r=++k)n=C[r],v=this.triangles_mesh.geometry.vertices[n.a],b=this.triangles_mesh.geometry.vertices[n.b],w=this.triangles_mesh.geometry.vertices[n.c],v.pos=new THREE.Vector3(v.x,v.y,v.z),b.pos=new THREE.Vector3(b.x,b.y,b.z),w.pos=new THREE.Vector3(w.x,w.y,w.z);return this.ready=!0},e.prototype.bind=function(){return e.__super__.bind.call(this),this.mouse.on("down",this.on_mouse_down),this.ui.bind(),this.mouse.bind()},e.prototype.unbind=function(){return e.__super__.unbind.call(this),this.mouse.off("down",this.on_mouse_down),this.ui.unbind(),this.mouse.unbind()},e.prototype.transition_in=function(){var t,e,i,n;return this.emit("transition:in:complete"),this.is_transitioning=!0,e=this.config.path_in[0],c.user.position.set(e.x,e.y,e.z),c.user.lookAt(new THREE.Vector3(e.x,e.y,e.z)),c.user.rotation.z=Math.PI,this.ui.transition_in(),i={progress:0},t={progress:1,ease:Power1.easeInOut,onStart:function(){},onUpdate:function(t){return function(){return e=t.path_in.spline.getPointAt(i.progress),c.user.position.copy(e)}}(this),onComplete:function(t){return function(){return t.is_transitioning=!1}}(this)},this.config.transition_debug&&(this.config.camera_in_duration=0),TweenLite.to(i,this.config.camera_in_duration,t),n={progress:0},t={progress:1,onComplete:function(t){return function(){return t.ui.transition_out()}}(this)},this.ui_tween=TweenLite.to(n,this.config.camera_in_duration,t),t={z:2*Math.PI},this.config.transition_debug&&(this.config.camera_rotation_in=0),TweenLite.to(c.user.rotation,this.config.camera_rotation_in,t),this.config.fog_enabled&&(this.scene.fog.density=this.config.fog_in_start,t={density:this.config.fog_in_end,ease:Power2.easeOut},this.config.transition_debug&&(this.config.fog_in_duration=0),TweenLite.to(this.scene.fog,this.config.fog_in_duration,t)),p.fov=150,t={fov:d.camera_fov,ease:Power3.easeOut},this.config.transition_debug&&(this.config.fov_in_duration=0),TweenLite.to(p,this.config.fov_in_duration,t)},e.prototype.on_mouse_down=function(){return this.force_transition_in_complete()},e.prototype.update=function(){var t,e,i,n,o,s,r,a,u,h,l,c,p,_,m,g;if(this.ready){for(s=this.mouse.normal_center_x,r=this.mouse.normal_center_y,u=.3*Math.PI*-r,h=.3*Math.PI*-s,a=this.triangles_mesh.rotation,t=u-a.x,e=h-a.y,i=Math.sqrt(t*t+e*e),this.triangles_mesh.rotation.x+=t*d.speed,this.triangles_mesh.rotation.y+=e*d.speed,this.mesh.rotation.x=this.triangles_mesh.rotation.x,this.mesh.rotation.y=this.triangles_mesh.rotation.y,this.normalize(this.triangles_mesh),this.normalize(this.mesh),this.mouse.is_down&&!this.is_transitioning_out?this.holding_frames+=.5:this.holding_frames-=2,this.holding_frames=Math.max(this.holding_frames,0),this.holding_frames=Math.min(this.holding_frames,60),this.noise=this.holding_frames/10||.05,g=this.triangles_mesh.geometry.faces,o=_=0,m=g.length;m>_;o=++_)n=g[o],l=this.triangles_mesh.geometry.vertices[n.a],c=this.triangles_mesh.geometry.vertices[n.b],p=this.triangles_mesh.geometry.vertices[n.c],l.x=l.pos.x+(-this.noise+2*Math.random()*this.noise),l.y=l.pos.y+(-this.noise+2*Math.random()*this.noise),l.z=l.pos.z+(-this.noise+2*Math.random()*this.noise),c.x=c.pos.x+(-this.noise+2*Math.random()*this.noise),c.y=c.pos.y+(-this.noise+2*Math.random()*this.noise),c.z=c.pos.z+(-this.noise+2*Math.random()*this.noise),p.x=p.pos.x+(-this.noise+2*Math.random()*this.noise),p.y=p.pos.y+(-this.noise+2*Math.random()*this.noise),p.z=p.pos.z+(-this.noise+2*Math.random()*this.noise);return this.triangles_mesh.geometry.verticesNeedUpdate=!0,f.point1.intensity=.5*Math.abs(2*s),f.point2.intensity=Math.max(0,r),f.point1.color.setHex(String(d.color_left).replace("#","0x")),f.point2.color.setHex(String(d.color_right).replace("#","0x")),f.directional.color.setHex(String(d.color_directional).replace("#","0x")),this.triangles_mesh.material.wireframeLinewidth=d.line_thickness}},e.prototype.normalize=function(t){return t.rotation.x=Math.min(.5,Math.max(-.5,t.rotation.x)),t.rotation.y=Math.min(.5,Math.max(-.5,t.rotation.y))},e.prototype.destroy=function(){return e.__super__.destroy.call(this),this.sound.stop()},e}(n)},function(t,e,i){var n,o,s,r,a;for(s=i(9),o=[{id:"pos-x",url:"/img/hires/pos-x.jpg",type:"image"},{id:"neg-x",url:"/img/hires/neg-x.jpg",type:"image"},{id:"pos-y",url:"/img/hires/pos-y.jpg",type:"image"},{id:"neg-y",url:"/img/hires/neg-y.jpg",type:"image"},{id:"pos-z",url:"/img/hires/pos-z.jpg",type:"image"},{id:"neg-z",url:"/img/hires/neg-z.jpg",type:"image"},{id:"hires_logo",url:"/js/hires/hires_logo.js",type:"geometry"}],r=0,a=o.length;a>r;r++)n=o[r],n.url=s.base_path+n.url;t.exports=o},function(t,e,i){var n;n=i(9),t.exports={fog_enabled:!0,transition_debug:!1,camera_fov:66,path_in:[{x:0,y:0,z:-34},{x:0,y:0,z:142}],path_in_lookat:{x:0,y:0,z:0},path_out:[{x:0,y:0,z:142},{x:0,y:-16,z:47},{x:0,y:-16,z:-53}],path_out_lookat:[{x:0,y:0,z:-70},{x:0,y:-37,z:-70}],camera_in_duration:22.5,camera_out_duration:4,camera_rotation_in:21,fog_in_duration:5,fog_out_duration:7,fog_in_start:.1,fog_in_end:.001,fog_out_start:.001,fog_out_end:.01,audio_pos_z_in:1,audio_pos_z_out:1,fov_in_duration:21,color_left:"#FFFFFF",color_right:"#0bfdfd",color_directional:"#FFFFFF",speed:.008,line_thickness:2}},function(t,e,i){var n,o,s,r,a,u,h,l,c,d,p,_,f,m=function(t,e){return function(){return t.apply(e,arguments)}};c=i(26),p=i(9),u=i(19),l=i(7),s=i(25),f=i(18),o=i(70),d=i(79),_=i(80),h=i(61),r=i(84),a=i(60),t.exports=n=function(){function t(t,e){this.scene=t,this.gui=e,this.next=m(this.next,this),this.update=m(this.update,this),this.transition_out_forward=m(this.transition_out_forward,this),this.transition_out_backward=m(this.transition_out_backward,this),this.setup=m(this.setup,this),c(this)}return t.prototype.camera_path=null,t.prototype.attributes=null,t.prototype.ready=!1,t.prototype.tweens=Array,t.prototype.has_transitioned_out=!1,t.prototype.is_transitioning=!1,t.prototype.transition_progress=0,t.prototype.fov_transition_progress=0,t.prototype.dolly_transition_progress=0,t.prototype.load=function(){var t,e,i;for(this.loader=new s,e=0,i=a.length;i>e;e++)t=a[e],this.loader.add(t.id,t.url,t.type);return this.loader.once("loaded",this.setup),this.loader.load()},t.prototype.setup=function(){var t,e,i,n,s,a,c,m,g,y,v,b,w,x,E,k,T,z,R,C,A,H,M,S,P,L,O;for(l.fov=h.camera_fov,this.ui=new r(this.scene,this.gui,{hires_logo:this.loader.get_asset("hires_logo")}),this.keyboard=new o($(window)),this.tweens=[],h.fog_enabled&&(this.scene.fog=new THREE.FogExp2(0,h.fog_in_start),this.gui.add(this.scene.fog,"density",0,.001)),p.debug&&(this.scene.add(new THREE.GridHelper(50,10)),this.scene.add(new THREE.AxisHelper(10)),this.scene.add(new THREE.CameraHelper(u.user))),H=0,P=d.length;P>H;H++)s=d[H],this.scene.add(s);for(this.sounds={start:this.loader.get_asset("start").data,loop:this.loader.get_asset("loop").data,transition:this.loader.get_asset("transition").data},this.sounds.start.play(),f.delay(37,function(t){return function(){return t.sounds.loop.volume(0),t.sounds.loop.fade(0,1,1e3),t.sounds.loop.play(),t.sounds.loop.loop(!0)}}(this)),this.container=new THREE.Object3D,this.scene.add(this.container),this.container.position.fromArray(h.container_position),this.container.rotation.fromArray(h.container_rotation),e=1e4,h.add_controls&&(this.gui.add(this.container.rotation,"x",0,PI_2).name("rotation x"),this.gui.add(this.container.rotation,"y",0,PI_2).name("rotation y"),this.gui.add(this.container.rotation,"z",0,PI_2).name("rotation z"),this.gui.add(this.container.position,"x",-e,e).name("position x"),this.gui.add(this.container.position,"y",-e,e).name("position y"),this.gui.add(this.container.position,"z",-e,e).name("position z")),this.attributes={size:{type:"f",value:[]},alpha:{type:"f",value:[]}},E={color:{type:"c",value:new THREE.Color(16777215)},texture:{type:"t",value:THREE.ImageUtils.loadTexture(this.loader.get_asset("particle").src)}},h.fog_enabled&&(E.topColor={type:"c",value:new THREE.Color(30719)},E.bottomColor={type:"c",value:new THREE.Color(16777215)},E.offset={type:"f",value:33},E.exponent={type:"f",value:.6},E.fogColor={type:"c",value:this.scene.fog.color},E.fogNear={type:"f",value:this.scene.fog.near},E.fogFar={type:"f",value:this.scene.fog.far},E.fogDensity={type:"f",value:this.scene.fog.density}),a=new THREE.ShaderMaterial({uniforms:E,attributes:this.attributes,vertexShader:_.vertex(),fragmentShader:_.fragment(),blending:THREE.AdditiveBlending,transparent:!0,fog:h.fog_enabled}),i=new THREE.Geometry,b=350*h.scale,v=2e3*h.scale,R=10,C=400*h.scale,x=20,w=40,n=M=0,L=h.partices;L>=0?L>M:M>L;n=L>=0?++M:--M)t=f.random(0,PI_2),y=f.random(b,v),T=y*Math.cos(t),z=C*Math.cos(y/v*Math.PI),A=y*Math.sin(t),i.vertices.push(new THREE.Vector3(T,z,A)),this.attributes.alpha.value[n]=f.random(.2,1),this.attributes.size.value[n]=f.random(x,w);for(this.mesh=new THREE.PointCloud(i,a),this.container.add(this.mesh),this.container.rotation.y=.1,x=40,w=80,i=new THREE.Geometry,v=b,b=150*h.scale,C=1e3*h.scale,n=S=0,O=h.tunnel_particles;O>=0?O>S:S>O;n=O>=0?++S:--S)t=f.random(0,PI_2),y=f.random(b,v),g=Math.random(),T=y*Math.cos(t),z=13422+C*Math.cos(y/v*Math.PI),A=y*Math.sin(t),i.vertices.push(new THREE.Vector3(T,z,A)),m=f.random(.2,1),g=z/C,g>.5&&(m+=f.lerp(m,0,.5+g)),this.attributes.alpha.value[n]=m,this.attributes.size.value[n]=f.random(x,w);return this.tunnel_mesh=new THREE.PointCloud(i,a),this.container.add(this.tunnel_mesh),c=new THREE.Mesh(new THREE.SphereGeometry(100,4,4)),c.position.y=15e3,c.visible=!1,this.container.add(c),this.container.updateMatrixWorld(),k=new THREE.Vector3,k.setFromMatrixPosition(c.matrixWorld),h.path_camera_dolly.push(k.toArray()),h.path_out.push(k.toArray()),this.camera_dolly=new THREE.Mesh(new THREE.SphereGeometry(100,8,8),new THREE.MeshBasicMaterial({color:16711680})),this.camera_dolly.visible=!1,this.scene.add(this.camera_dolly),this.path_in=f.path(this.scene,h.path_in,65280),this.path_out=f.path(this.scene,h.path_out,16711680),this.path_camera_dolly=f.path(this.scene,h.path_camera_dolly,65280,null,5),this.ready=!0,this.emit("setup:complete"),this.bind()},t.prototype.bind=function(){return this.keyboard.on("key:down:space",this.transition_out_forward),this.keyboard.on("key:up:space",this.transition_out_backward),this.keyboard.bind(),l.on("update",this.update)},t.prototype.unbind=function(){return this.keyboard.off("key:down:space",this.transition_out_forward),this.keyboard.off("key:up:space",this.transition_out_backward),this.keyboard.unbind(),l.off("update",this.update)},t.prototype.transition_in=function(){var t,e;return this.emit("transition:in:complete"),this.is_transitioning=!0,u.user.position.fromArray(h.path_in[0]),u.user.lookAt(new THREE.Vector3),this.ui.transition_in(),e={progress:0},t={progress:1,ease:Power2.easeOut,onUpdate:function(t){return function(){var i;return t.ui.update(),i=t.path_in.getPointAt(e.progress),u.user.position.copy(i),u.user.lookAt(new THREE.Vector3)}}(this),onComplete:function(t){return function(){return t.is_transitioning=!1}}(this)},this.tweens.push(TweenLite.to(e,h.camera_in_duration,t)),h.fog_enabled?(this.scene.fog.density=h.fog_in_start,t={density:h.fog_in_end,ease:Power2.easeOut},this.tweens.push(TweenLite.to(this.scene.fog,h.fog_in_duration,t))):void 0},t.prototype.transition_out_backward=function(){var t,e,i,n,o,s;if(0!==this.transition_progress&&!(this.transition_progress>.6))return this.kill_tweens(),this.ui.transition_out_backward(),s={progress:this.transition_progress,percent:0},o={progress:0,percent:1,ease:Power3.easeOut,onUpdate:function(t){return function(){var e,i;return e=t.path_out.getPointAt(s.progress),u.user.position.copy(e),u.user.lookAt(t.camera_dolly.position),t.sounds.loop.volume(s.percent),i=f.lerp(1,0,s.percent),t.sounds.transition.volume(i)}}(this),onComplete:function(t){return function(){return t.is_transitioning=!1,t.sounds.transition.stop()}}(this)},t=2+2*this.transition_progress,this.tweens.push(TweenLite.to(s,t,o)),this.dolly_transition_progress>0&&(i={progress:this.dolly_transition_progress},o={progress:0,ease:Power2.easeOut,onUpdate:function(t){return function(){var e;return e=t.path_camera_dolly.getPointAt(i.progress),t.camera_dolly.position.copy(e)}}(this)},e=2+2*this.dolly_transition_progress,this.tweens.push(TweenLite.to(i,e,o))),this.fov_transition_progress>0?(o={fov:h.camera_fov,ease:Power3.easeOut},n=5+5*this.fov_transition_progress,this.tweens.push(TweenLite.to(l,n,o))):void 0},t.prototype.transition_out_forward=function(){var t,e,i,n;if(!this.is_transitioning)return this.is_transitioning=!0,this.sounds.transition.volume(1),this.sounds.transition.play(),this.kill_tweens(),this.ui.transition_out(),n={progress:0},i={progress:1,ease:Power2.easeIn,onUpdate:function(t){return function(){var e;return t.transition_progress=n.progress,e=t.path_out.getPointAt(n.progress),u.user.position.copy(e),u.user.lookAt(t.camera_dolly.position),t.sounds.loop.volume(1-n.progress)}}(this),onComplete:function(t){return function(){return t.next()}}(this)},this.tweens.push(TweenLite.to(n,h.camera_out_duration,i)),t={progress:0},i={progress:1,delay:6,ease:Power2.easeIn,onUpdate:function(e){return function(){var i;return e.dolly_transition_progress=t.progress,i=e.path_camera_dolly.getPointAt(t.progress),e.camera_dolly.position.copy(i)}}(this)},this.tweens.push(TweenLite.to(t,3.7,i)),i={fov:h.camera_fov_out,delay:5,ease:Power3.easeOut,onUpdate:function(t){return function(){return t.fov_transition_progress=e.progress()}}(this)},e=TweenLite.to(l,h.camera_fov_out_duration,i),this.tweens.push(e)},t.prototype.update=function(){var t;if(this.ready)return t=.001,this.mesh.rotation.y+=t,this.tunnel_mesh.rotation.y+=t},t.prototype.next=function(){return this.has_transitioned_out=!0,this.emit("next")},t.prototype.kill_tweens=function(){var t,e,i,n,o;for(n=this.tweens,o=[],e=0,i=n.length;i>e;e++)t=n[e],o.push(null!=t?t.kill():void 0);return o},t.prototype.enable_transition=function(){},t.prototype.disable_transition=function(){},t.prototype.destroy=function(){var t,e,i;i=this.sounds;for(t in i)e=i[t],e.fade(1,0,1e3);return f.delay(1,function(i){return function(){var n,o,s,r,a;r=i.sounds;for(t in r)e=r[t],e.unload();for(a=i.scene.children,o=0,s=a.length;s>o;o++)n=a[o], +i.scene.remove(n);return i.kill_tweens(),i.unbind(),i.ui.destroy(),i.loader.dispose(),i.emit("destroyed")}}(this))},t}()},function(t,e,i){var n,o,s,r,a;for(s=i(9),o=[{id:"particle",url:"/img/home/particle.jpg",type:"image"},{id:"hires_logo",url:"/img/home/hires.png",type:"image"},{id:"start",url:"/sound/home/start.mp3",type:"sound"},{id:"loop",url:"/sound/home/loop.mp3",type:"sound"},{id:"transition",url:"/sound/home/transition.mp3",type:"sound"}],r=0,a=o.length;a>r;r++)n=o[r],n.url=s.base_path+n.url;t.exports=o},function(t,e,i){t.exports={add_controls:!1,transition_debug:!1,fog_enabled:!0,camera_fov:80,camera_fov_out:120,camera_fov_out_duration:10,path_in:[[14660.800000000001,-16761.800000000003,12783.1],[13328,-15238,11621]],path_out:[[13328,-15238,11621],[11100,-12545,9690],[7735,-9383,7878],[4207,-4813,5272],[1501,-1205,3305],[0,0,0]],path_camera_dolly:[[0,0,0]],camera_in_duration:2,camera_out_duration:10,fog_in_duration:10,hires_in_duration:2,hires_out_duration:1,fog_in_start:7e-4,fog_in_end:7e-5,scale:10,partices:4e5,tunnel_particles:3e4,container_position:[1500,1050,4400],container_rotation:[4.4,.01,.28],title_position:[11100,-12e3,9690],title_letter_in_position:[[-1173,-25,0],[-291,-25,0],[480,-28,0],[1068,-28,0]],title_letter_in_rotation:[[0,0,-.08],[0,0,.21],[0,-.36,0],[-.08,0,0]],ui_hires_scale:20,ui_hires_position:[0,2170,0],paragraph_positions:[[0,-700,0],[0,-1435,0]],enter_position:[0,-2355,0],enter_letter_in_position:[{x:-20,y:6,z:0},{x:-8,y:3,z:0},{x:0,y:0,z:0},{x:7,y:-1,z:0},{x:19,y:-3,z:0}],enter_letter_in_rotation:[{x:0,y:7,z:11},{x:0,y:6,z:0},{x:0,y:0,z:0},{x:0,y:-3,z:0},{x:-10,y:0,z:-5}]}},function(t,e,i){var n,o,s,r,a,u,h,l,c,d,p,_,f,m,g,y=function(t,e){return function(){return t.apply(e,arguments)}},v={}.hasOwnProperty,b=function(t,e){function i(){this.constructor=t}for(var n in e)v.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};_=i(26),m=i(9),c=i(19),p=i(7),s=i(25),r=i(69),g=i(18),n=i(71),f=i(85),d=i(64),h=i(72),l=i(63),u=i(88),a=i(89),t.exports=o=function(t){function e(){return this.update=y(this.update,this),this.on_mouse_move=y(this.on_mouse_move,this),this.on_mouse_up=y(this.on_mouse_up,this),this.on_mouse_down=y(this.on_mouse_down,this),this.setup=y(this.setup,this),e.__super__.constructor.apply(this,arguments)}return b(e,t),e.prototype.spread=0,e.prototype.accel_x=.1,e.prototype.accel_y=.1,e.prototype.accel_z=.1,e.prototype.dopplerFactor=1,e.prototype.speedOfSound=343.3,e.prototype.setup=function(t){var e,i,n,o,s,l,_,y,v,b,w,x,E,k,T;for(v=10,this.gui.add(this,"audio_pos_x",-v,v),this.gui.add(this,"audio_pos_y",-v,v),this.gui.add(this,"audio_pos_z",-v,v),v=1e3,this.gui.add(this,"accel_x",-v,v),this.gui.add(this,"accel_y",-v,v),this.gui.add(this,"accel_z",-v,v),this.gui.add(c.user.position,"z",-100,1e3),p.fov=d.camera_fov,this.ui=new h("kubik",this.scene,this.gui),d.fog_enabled&&(this.scene.fog=new THREE.FogExp2(0,d.fog_in_start),this.gui.add(this.scene.fog,"density",0,1)),this.gui.add(p,"fov",0,200),m.debug&&(this.scene.add(new THREE.GridHelper(50,10)),this.scene.add(new THREE.AxisHelper(10)),this.scene.add(new THREE.CameraHelper(c.user))),E=0,k=f.length;k>E;E++)l=f[E],this.scene.add(l);this.path_in=new u("path_in",this.scene,d.path_in,d.path_in_lookat,65280),this.path_out=new a("path_out",this.scene,d.path_out,d.path_out_lookat,65280),this.mouse=new r($(".hitarea")),this.audio_pos_x=.1,this.audio_pos_z=this.config.audio_pos_z_in,this.sounds={background:g.get_asset("background",t).data,top:g.get_asset("top",t).data},this.sounds.background.play(),this.sounds.top.volume(0),this.sounds.top.play(),T=this.sounds;for(s in T)x=T[s],x.loop(!0);for(this.container=new THREE.Object3D,this.scene.add(this.container),y={side:THREE.DoubleSide,blending:2,transparent:!0,depthTest:!1,wireframeLinewidth:1,opacity:.1,map:THREE.ImageUtils.loadTexture(this.loader.get_asset("texture").src)},this.material=new THREE.MeshLambertMaterial(y),i=new THREE.BoxGeometry(1,1,1),o=0,this.cubes=[],_=160,this.object=new THREE.Object3D;_>o;)b=o/_,e=new THREE.Mesh(i,this.material),n=new THREE.Object3D,n.add(e),n.rotation.y=360*b*(Math.PI/180),this.object.add(n),this.cubes.push(e),o++;return w=40,this.object.scale.set(w,w,w),this.object.rotation.x=HALF_PI,this.container.add(this.object),this.spread=.1,this.ready=!0,this.bind(),this.emit("setup:complete")},e.prototype.spread_cubes=function(){var t,e,i,n,o;i=0,n=this.cubes,o=[];for(e in n)t=n[e],i=e/this.cubes.length,o.push(t.rotation.y=i*Math.PI*this.spread);return o},e.prototype.bind=function(){return e.__super__.bind.call(this),this.mouse.on("move",this.on_mouse_move),this.mouse.on("down",this.on_mouse_down),this.mouse.on("up",this.on_mouse_up),this.ui.bind(),this.mouse.bind()},e.prototype.unbind=function(){return e.__super__.unbind.call(this),this.mouse.off("move",this.on_mouse_move),this.mouse.off("down",this.on_mouse_down),this.mouse.off("up",this.on_mouse_up),this.ui.unbind(),this.mouse.unbind()},e.prototype.force_transition_in_complete=function(){return e.__super__.force_transition_in_complete.call(this),this.camera_tween.totalProgress(1).kill()},e.prototype.on_mouse_down=function(){var t,e,i;if(!this.is_transitioning_out)return this.force_transition_in_complete(),null!=(e=this.fov_tween)&&e.kill(),null!=(i=this.pos_tween)&&i.kill(),t={fov:200,ease:Cubic.easeOut},this.fov_tween=TweenLite.to(p,.6,t),t={z:33},this.pos_tween=TweenLite.to(c.user.position,.3,t),this.sounds.background.fade(1,.5,600),this.sounds.top.fade(0,1,600)},e.prototype.on_mouse_up=function(){var t,e,i;if(!this.is_transitioning_out)return null!=(e=this.fov_tween)&&e.kill(),null!=(i=this.pos_tween)&&i.kill(),t={fov:this.config.camera_fov,ease:Cubic.easeOut},this.fov_tween=TweenLite.to(p,.55,t),t={z:this.config.path_in[1].z},this.pos_tween=TweenLite.to(c.user.position,.3,t),this.sounds.background.fade(.5,1,600),this.sounds.top.fade(1,0,600)},e.prototype.on_mouse_move=function(){var t,e,i,n,o,s,r,a,u,h;return e=0,i=0,n=this.mouse.normal_center_x,o=this.mouse.normal_center_y,t=this.mouse.is_down?.25:1,null!=(u=this.rotation_tween)&&u.kill(),a=HALF_PI+this.mouse.normal_center_y,s={x:a},this.rotation_tween=TweenLite.to(this.object.rotation,t,s),null!=(h=this.tween)&&h.kill(),r=this.mouse.normal_x.map(0,1,0,PI_2),s={spread:r,ease:Power3.easeOut,onUpdate:function(t){return function(){return t.spread_cubes()}}(this)},this.tween=TweenLite.to(this,1,s)},e.prototype.update=function(){var t,e,i,n,o;if(this.ready){this.audio_pos_x=4*this.mouse.normal_center_x,this.sounds.background.pos(this.audio_pos_x,null,this.audio_pos_z),this.sounds.background.velocity(this.accel_x,this.accel_y,this.accel_z),n=this.cubes,o=[];for(e in n)t=n[e],i=e/this.cubes.length,o.push(t.rotation.x+=.5*Math.PI/180);return o}},e}(n)},function(t,e,i){var n,o,s,r,a;for(s=i(9),o=[{id:"texture",url:"/img/kubik/texture.png",type:"image"},{id:"background",url:"/sound/kubik/background.mp3",type:"sound"},{id:"top",url:"/sound/kubik/top.mp3",type:"sound"}],r=0,a=o.length;a>r;r++)n=o[r],n.url=s.base_path+n.url;t.exports=o},function(t,e,i){t.exports={fog_enabled:!0,transition_debug:!1,camera_fov:80,path_in:[{x:0,y:0,z:300},{x:0,y:0,z:80}],path_in_lookat:{x:0,y:0,z:0},path_out:[{x:0,y:0,z:80},{x:0,y:-50,z:200}],path_out_lookat:[{x:0,y:0,z:0},{x:0,y:-50,z:0}],camera_in_duration:5,camera_out_duration:4,fog_in_duration:12,fog_out_duration:6,fog_in_start:.1,fog_in_end:.001,fog_out_start:.001,fog_out_end:.01,audio_pos_z_in:-15,audio_pos_z_out:6,num_blobs:30,max_blobs:50,speed:.15,scalar:1}},function(t,e,i){var n,o,s,r,a,u,h,l,c,d,p,_,f,m,g,y=function(t,e){return function(){return t.apply(e,arguments)}},v={}.hasOwnProperty,b=function(t,e){function i(){this.constructor=t}for(var n in e)v.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};_=i(26),m=i(9),c=i(19),p=i(7),s=i(25),r=i(69),g=i(18),n=i(71),f=i(86),d=i(67),h=i(72),l=i(66),u=i(88),a=i(89),t.exports=o=function(t){function e(){return this.on_mouse_up=y(this.on_mouse_up,this),this.on_mouse_down=y(this.on_mouse_down,this),this.update=y(this.update,this),this.on_transition_out_forward=y(this.on_transition_out_forward,this),this.on_transition_out_backward=y(this.on_transition_out_backward,this),this.setup=y(this.setup,this),e.__super__.constructor.apply(this,arguments)}return b(e,t),e.prototype.values=null,e.prototype.points=null,e.prototype.positions=[],e.prototype.material=null,e.prototype.tween=null,e.prototype.audio_pos_x=.1,e.prototype.audio_pos_y=.1,e.prototype.audio_pos_z=0,e.prototype.setup=function(t){var e,i,n,o,s,l,_,y,v,b,w,x,E,k,T,z,R,C,A,H,M,S,P,L,O,I,B,j;for(w=1,this.gui.add(this,"audio_pos_x",-w,w),this.gui.add(this,"audio_pos_y",-w,w),this.gui.add(this,"audio_pos_z",-w,w),p.fov=d.camera_fov,this.ui=new h("liquidice",this.scene,this.gui),d.fog_enabled&&(this.scene.fog=new THREE.FogExp2(0,d.fog_in_start),this.gui.add(this.scene.fog,"density",0,1)),m.debug&&(this.scene.add(new THREE.GridHelper(50,10)),this.scene.add(new THREE.AxisHelper(10)),this.scene.add(new THREE.CameraHelper(c.user))),S=0,L=f.length;L>S;S++)b=f[S],this.scene.add(b);this.path_in=new u("path_in",this.scene,d.path_in,d.path_in_lookat,65280),this.path_out=new a("path_out",this.scene,d.path_out,d.path_out_lookat,65280),this.mouse=new r($("body")),this.audio_pos_z=this.config.audio_pos_z_in,this.sounds={background:g.get_asset("background",t).data,top:g.get_asset("top",t).data},this.sounds.background.volume(2),this.sounds.background.play(),this.sounds.top.volume(0),this.sounds.top.play(),I=this.sounds;for(v in I)T=I[v],T.loop(!0);for(this.container=new THREE.Object3D,this.scene.add(this.container),n=-6,i=6,o=i-n,x=16,E=x*x,k=x*x*x,this.points=[],y=0;x>y;){for(_=0;x>_;){for(l=0;x>l;)A=n+o*l/(x-1),H=n+o*_/(x-1),M=n+o*y/(x-1),this.points.push(new THREE.Vector3(A,H,M)),l++;_++}y++}for(this.values=[],l=0;k>l;)this.values[l]=0,l++;for(C=[],P=0,O=t.length;O>P;P++)e=t[P],("pos-x"===(B=e.id)||"neg-x"===B||"pos-y"===B||"neg-y"===B||"pos-z"===B||"neg-z"===B)&&C.push(e.src);for(z=THREE.ImageUtils.loadTextureCube(C),z.format=THREE.RGBFormat,s=THREE.FresnelShader,R={mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:z}},d.fog_enabled&&(R.topColor={type:"c",value:new THREE.Color(30719)},R.bottomColor={type:"c",value:new THREE.Color(16777215)},R.offset={type:"f",value:33},R.exponent={type:"f",value:.6},R.fogColor={type:"c",value:0},R.fogNear={type:"f",value:0},R.fogFar={type:"f",value:1},R.fogDensity={type:"f",value:.01}),this.material=new THREE.ShaderMaterial({uniforms:R,vertexShader:s.vertexShader,fragmentShader:s.fragmentShader,fog:!0,side:THREE.DoubleSide}),l=0;lO;){for(L=0;b-1>L;){for(P=0;b-1>P;){for(d=P+b*L+w*O,p=d+1,g=d+b,_=g+1,v=d+w,m=p+w,y=g+w,f=_+w,E=this.values[d],k=this.values[p],T=this.values[g],z=this.values[_],R=this.values[v],C=this.values[m],A=this.values[y],H=this.values[f],o=0,i>E&&(o|=1),i>k&&(o|=2),i>T&&(o|=8),i>z&&(o|=4),i>R&&(o|=16),i>C&&(o|=32),i>A&&(o|=128),i>H&&(o|=64),n=THREE.edgeTable[o],c=.5,1&n&&(c=(i-E)/(k-E),S[0]=this.points[d].clone().lerp(this.points[p],c)),2&n&&(c=(i-k)/(z-k),S[1]=this.points[p].clone().lerp(this.points[_],c)),4&n&&(c=(i-T)/(z-T),S[2]=this.points[g].clone().lerp(this.points[_],c)),8&n&&(c=(i-E)/(T-E),S[3]=this.points[d].clone().lerp(this.points[g],c)),16&n&&(c=(i-R)/(C-R),S[4]=this.points[v].clone().lerp(this.points[m],c)),32&n&&(c=(i-C)/(H-C),S[5]=this.points[m].clone().lerp(this.points[f],c)),64&n&&(c=(i-A)/(H-A),S[6]=this.points[y].clone().lerp(this.points[f],c)),128&n&&(c=(i-R)/(A-R),S[7]=this.points[v].clone().lerp(this.points[y],c)),256&n&&(c=(i-E)/(R-E),S[8]=this.points[d].clone().lerp(this.points[v],c)),512&n&&(c=(i-k)/(C-k),S[9]=this.points[p].clone().lerp(this.points[m],c)),1024&n&&(c=(i-z)/(H-z),S[10]=this.points[_].clone().lerp(this.points[f],c)),2048&n&&(c=(i-T)/(A-T),S[11]=this.points[g].clone().lerp(this.points[y],c)),a=0,o<<=4;-1!==THREE.triTable[o+a];)u=THREE.triTable[o+a],h=THREE.triTable[o+a+1],l=THREE.triTable[o+a+2],r.vertices.push(S[u].clone().multiplyScalar(10)),r.vertices.push(S[h].clone().multiplyScalar(10)),r.vertices.push(S[l].clone().multiplyScalar(10)),s=new THREE.Face3(M,M+1,M+2),r.faces.push(s),r.faceVertexUvs[0].push([new THREE.Vector2(0,0),new THREE.Vector2(0,1),new THREE.Vector2(1,1)]),M+=3,a+=3;P++}L++}O++}return r.mergeVertices(),r.computeFaceNormals(),r.computeVertexNormals(),r},e.prototype.random_sphere_point=function(t,e,i,n){var o,s,r,a,u,h,l;return null==t&&(t=0),null==e&&(e=0),null==i&&(i=0),null==n&&(n=1),r=Math.random(),a=Math.random(),s=2*Math.PI*r,o=Math.acos(2*a-1),u=t+n*Math.sin(o)*Math.cos(s),h=e+n*Math.sin(o)*Math.sin(s),l=i+n*Math.cos(o),[u,h,l]},e.prototype.on_mouse_down=function(){var t,e,i;if(!this.is_transitioning_out)return this.force_transition_in_complete(),null!=(e=this.tween)&&e.kill(),null!=(i=this.pos_tween)&&i.kill(),t={scalar:2,ease:Power1.easeIn},this.tween=TweenLite.to(d,1,t),t={z:0},this.pos_tween=TweenLite.to(c.user.position,1,t),this.sounds.background.fade(1,.5,600),this.sounds.top.fade(0,2,600)},e.prototype.on_mouse_up=function(){var t,e,i;if(!this.is_transitioning_out)return null!=(e=this.tween)&&e.kill(),null!=(i=this.pos_tween)&&i.kill(),t={scalar:1,ease:Elastic.easeOut},this.tween=TweenLite.to(d,2,t),t={z:this.config.path_in[1].z},this.pos_tween=TweenLite.to(c.user.position,.3,t),this.sounds.background.fade(.5,2,600),this.sounds.top.fade(2,0,600)},e}(n)},function(t,e,i){var n,o,s,r,a;for(s=i(9),o=[{id:"pos-x",url:"/img/liquidice/pos-x.jpg",type:"image"},{id:"neg-x",url:"/img/liquidice/neg-x.jpg",type:"image"},{id:"pos-y",url:"/img/liquidice/pos-y.jpg",type:"image"},{id:"neg-y",url:"/img/liquidice/neg-y.jpg",type:"image"},{id:"pos-z",url:"/img/liquidice/pos-z.jpg",type:"image"},{id:"neg-z",url:"/img/liquidice/neg-z.jpg",type:"image"},{id:"MarchingCubesData",url:"/js/liquidice/MarchingCubesData.js",type:"js"},{id:"FresnelShader",url:"/js/liquidice/FresnelShader.js",type:"js"},{id:"background",url:"/sound/liquidice/background.mp3",type:"sound"},{id:"top",url:"/sound/liquidice/top.mp3",type:"sound"}],r=0,a=o.length;a>r;r++)n=o[r],n.url=s.base_path+n.url;t.exports=o},function(t,e,i){t.exports={fog_enabled:!0,transition_debug:!1,camera_fov:80,path_in:[{x:0,y:0,z:300},{x:0,y:0,z:80}],path_in_lookat:{x:0,y:0,z:0},path_out:[{x:0,y:.5714285714285836,z:80.57142857142856},{x:0,y:-17.714285714285722,z:53.14285714285714},{x:-20,y:-90.85714285714286,z:-38.28571428571429}],path_out_lookat:[{x:0,y:0,z:0},{x:0,y:-100,z:0}],camera_in_duration:15,camera_out_duration:2.8,fog_in_duration:15,fog_out_duration:3,fog_in_start:.1,fog_in_end:.001,fog_out_start:.001,fog_out_end:.01,audio_pos_z_in:-8,audio_pos_z_out:8,num_blobs:30,max_blobs:50,speed:.15,scalar:1}},function(t,e,i){t.exports=i(90),t.exports.color=i(91)},function(t,e,i){var n,o,s,r=function(t,e){return function(){return t.apply(e,arguments)}};o=i(26),s=i(3),t.exports=n=function(){function t(t){this.el=t,this.mouseup=r(this.mouseup,this),this.mousedown=r(this.mousedown,this),this.mousemove=r(this.mousemove,this),o(this)}return t.prototype.mouse_x=0,t.prototype.mouse_y=0,t.prototype.mouse_last_x=0,t.prototype.mouse_last_y=0,t.prototype.normal_x=0,t.prototype.normal_y=0,t.prototype.normal_center_x=0,t.prototype.normal_center_y=0,t.prototype.clicked_x=0,t.prototype.clicked_y=0,t.prototype.is_down=!1,t.prototype.is_dragging=!1,t.prototype.bind=function(){return this.el.on("mousedown",this.mousedown),this.el.on("mouseup",this.mouseup),this.el.on("mousemove",this.mousemove)},t.prototype.unbind=function(){return this.el.off("mousedown",this.mousedown),this.el.off("mouseup",this.mouseup),this.el.off("click",this.click)},t.prototype.mousemove=function(t){var e;return this.mouse_last_x=this.mouse_x,this.mouse_last_y=this.mouse_y,e=this._get_event_position(t),this.mouse_x=e.x,this.mouse_y=e.y,this.normal_x=this.mouse_x/s.width,this.normal_y=this.mouse_y/s.height,this.normal_center_x=-.5+this.normal_x,this.normal_center_y=-.5+this.normal_y,this.is_dragging=this.is_down?!0:!1,this.emit("move")},t.prototype.mousedown=function(t){var e;return this.is_down=!0,e=this._get_event_position(t),this.clicked_x=e.x,this.clicked_y=e.y,this.emit("down",e)},t.prototype.mouseup=function(t){return this.is_down=!1,this.emit("up")},t.prototype.distance_to=function(t,e){return Math.sqrt((t-this.normal_x)*(t-this.normal_x)+(e-this.normal_y)*(e-this.normal_y))},t.prototype._get_event_position=function(t){var e,i;return e=t.pageX,i=t.pageY,{x:e,y:i}},t}()},function(t,e,i){var n,o,s,r=function(t,e){return function(){return t.apply(e,arguments)}};o=i(26),s=i(3),t.exports=n=function(){function t(t){this.el=t,this.keyup=r(this.keyup,this),this.keydown=r(this.keydown,this),o(this)}return t.prototype.key=0,t.prototype._enabled=!1,t.prototype.bind=function(){return this._enabled=!0,this.el.on("keydown",this.keydown),this.el.on("keyup",this.keyup)},t.prototype.unbind=function(){return this._enabled=!1},t.prototype.keydown=function(t){if(t.preventDefault(),this._enabled)switch(this.key=t.keyCode,this.key){case 32:return this.emit("key:down:space")}},t.prototype.keyup=function(t){return 32===this.key?this.emit("key:up:space"):void 0},t}()},function(t,e,i){var n,o,s,r,a,u,h,l,d=function(t,e){return function(){return t.apply(e,arguments)}};u=i(26),s=i(25),r=i(19),h=i(21),o=i(70),a=i(7),l=i(18),t.exports=n=function(){function t(t,e,i,n){this.scene=t,this.gui=e,this.assets=i,this.config=n,this.next=d(this.next,this),this.transition_out_forward=d(this.transition_out_forward,this),this.transition_out_backward=d(this.transition_out_backward,this),this.on_key_up=d(this.on_key_up,this),this.on_key_down=d(this.on_key_down,this),u(this),this.tweens=[],this.keyboard=new o($(window))}return t.prototype.has_transitioned_out=!1,t.prototype.is_transitioning=!1,t.prototype.is_transitioning_in=!1,t.prototype.is_transitioning_out=!1,t.prototype.transition_progress=0,t.prototype.is_transition_disabled=!1,t.prototype.transition_lock=!1,t.prototype.audio_pos_x=0,t.prototype.audio_pos_y=0,t.prototype.audio_pos_z=0,t.prototype.sounds=Array,t.prototype.load=function(){var t,e,i,n;for(this.loader=new s,n=this.assets,e=0,i=n.length;i>e;e++)t=n[e],this.loader.add(t.id,t.url,t.type);return this.loader.once("loaded",this.setup),this.loader.load()},t.prototype.bind=function(){return a.on("update",this.update),this.keyboard.on("key:down:space",this.on_key_down),this.keyboard.on("key:up:space",this.on_key_up),this.keyboard.bind()},t.prototype.unbind=function(){return a.off("update",this.update),this.keyboard.off("key:down:space",this.on_key_down),this.keyboard.off("key:up:space",this.on_key_up)},t.prototype.on_key_down=function(){return this.is_transitioning_in||this.is_transition_disabled?void 0:this.transition_out_forward()},t.prototype.on_key_up=function(){return this.transition_out_backward()},t.prototype.transition_in=function(){var t,e,i,n;return this.emit("transition:in:complete"),this.is_transitioning=!0,this.is_transitioning_in=!0,e=this.config.path_in[0],r.user.position.set(e.x,e.y,e.z),r.user.lookAt(new THREE.Vector3),this.ui.transition_in(),i={progress:0},t={progress:1,ease:Power2.easeOut,onStart:function(t){return function(){return t.emit("transition:in:start")}}(this),onUpdate:function(t){return function(){return e=t.path_in.spline.getPointAt(i.progress),r.user.position.copy(e),r.user.lookAt(new THREE.Vector3),t.emit("transition:in:update",i.progress)}}(this),onComplete:function(t){return function(){return t.is_transitioning=!1,t.is_transitioning_in=!1}}(this)},this.config.transition_debug&&(this.config.camera_in_duration=.1),this.camera_tween=TweenLite.to(i,this.config.camera_in_duration,t),n={progress:0},t={progress:1,onComplete:function(t){return function(){return t.ui.transition_out()}}(this)},this.ui_tween=TweenLite.to(n,this.config.camera_in_duration,t),t={audio_pos_z:0,ease:Power1.easeOut},TweenLite.to(this,this.config.camera_in_duration,t),this.config.fog_enabled?(this.scene.fog.density=this.config.fog_in_start,t={density:this.config.fog_in_end,ease:Power2.easeOut},this.config.transition_debug&&(this.config.fog_in_duration=0),this.fog_tween=TweenLite.to(this.scene.fog,this.config.fog_in_duration,t)):void 0},t.prototype.force_transition_in_complete=function(){return l.delay(2,function(t){return function(){return t.ui_tween.totalProgress(1).kill()}}(this))},t.prototype.transition_out_backward=function(){var t,e,i;if(!(this.is_transition_disabled||0===this.transition_progress||this.transition_progress>.6))return this.kill_tweens(),this.ui.show(),i={progress:this.transition_progress},e={progress:0,ease:Power3.easeOut,onUpdate:function(t){return function(){var e,n;return e=t.path_out.spline.getPointAt(i.progress),r.user.position.copy(e),e=t.path_out.spline_camera.getPointAt(i.progress),r.user.lookAt(e),n=Math.max(n,0),n=Math.min(n,1),t.audio_pos_z=l.lerp(0,t.config.audio_pos_z_out,i.progress)}}(this),onComplete:function(t){return function(){return t.is_transitioning=!1,t.is_transitioning_out=!1}}(this)},t=1+1*this.transition_progress,this.tweens.push(TweenLite.to(i,t,e)),e={opacity:0,ease:Power3.easeOut},this.tweens.push(TweenLite.to(this.ui.ui.transition_black,t,e)),this.config.fog_enabled?(e={density:this.config.fog_in_end,ease:Power2.easeInOut},this.tweens.push(TweenLite.to(this.scene.fog,t,e))):void 0},t.prototype.transition_out_forward=function(t){var e,i,n,o;if(null==t&&(t=!1),!this.is_transitioning_out&&!this.is_transition_disabled){if(this.is_transitioning)return void this.transition_out_fast();if(!this.is_transitioning)return this.is_transitioning=!0,this.is_transitioning_out=!0,this.kill_tweens(),this.ui.hide(),o=new THREE.Vector3(0,0,-1),e=new THREE.Vector3,n={progress:0},i={progress:1,ease:Power2.easeIn,onUpdate:function(t){return function(){var e;return t.transition_progress=n.progress,e=t.path_out.spline.getPointAt(n.progress),r.user.position.copy(e),e=t.path_out.spline_camera.getPointAt(n.progress),r.user.lookAt(e),t.audio_pos_z=l.lerp(0,t.config.audio_pos_z_out,n.progress)}}(this),onComplete:function(t){return function(){return t.next()}}(this)},this.tweens.push(TweenLite.to(n,this.config.camera_out_duration,i)),i={opacity:1,ease:Power2.easeIn},this.tweens.push(TweenLite.to(this.ui.ui.transition_black,this.config.camera_out_duration,i)),this.config.fog_enabled?(this.scene.fog.density=this.config.fog_out_start,i={density:this.config.fog_out_end,ease:Power2.easeInOut},this.tweens.push(TweenLite.to(this.scene.fog,this.config.fog_out_duration,i))):void 0}},t.prototype.transition_out_fast=function(){return this.ui.once("transition:out:fast:complete",function(t){return function(){return t.kill_tweens(),t.next()}}(this)),this.ui.transition_out_fast()},t.prototype.next=function(){return this.has_transitioned_out=!0,this.emit("next")},t.prototype.kill_tweens=function(){var t,e,i,n,o;for(n=this.tweens,o=[],e=0,i=n.length;i>e;e++)t=n[e],o.push(null!=t?t.kill():void 0);return o},t.prototype.enable_transition=function(){return this.is_transition_disabled=!1},t.prototype.disable_transition=function(){return this.is_transition_disabled=!0},t.prototype.destroy=function(){var t,e,i,n,o,s,r;for(c.log("destroy"),s=this.scene.children,n=0,o=s.length;o>n;n++)e=s[n],this.scene.remove(e);r=this.sounds;for(t in r)i=r[t],i.stop(),i.unload();return h.shadowMapEnabled=!1,h.shadowMapSoft=!1,this.unbind(),this.ui.destroy(),this.loader.dispose(),this.emit("destroyed")},t}()},function(t,e,i){var n,o,s,r,a,u,h,l,c=function(t,e){return function(){return t.apply(e,arguments)}};a=i(26),r=i(8),u=i(16),l=i(18),s=i(19),n=i(93),h=i(9),t.exports=o=function(){function t(t,e){var n,o,s,r,l;this.id=t,this.assets=e,this.show_about=c(this.show_about,this),a(this),this.ui={ui:".ui",dim:".dim",hitarea:".hitarea",transition_black:".transition_black",chapter:".chapter",chapter_index:".chapter_index",title:"h2",about:".about",interactions:".interactions",authors:".authors",next:".next",next_title:".next h3",next_text:".next .caps-text"},r=i(96),n=u.get(this.id),s={data:n,base_path:h.base_path},$("main").append(r(s)),this.el=$("#"+n.id),l=this.ui;for(o in l)t=l[o],this.ui[o]=this.el.find(t);this.ui.letters=this.ui.about.lettering().children(),this.ui.next_letters=this.ui.next_text.lettering().children(),this.tweens=[]}return t.prototype.is_overlay_open=!0,t.prototype.ui=Object,t.prototype._disabled=!1,t.prototype.bind=function(){return this.ui.next_title.on("click",this.show_about)},t.prototype.unbind=function(){return this.ui.next_title.off("click",this.show_about)},t.prototype.disable_ui=function(){return this._disabled=!0,this.el.addClass("disable")},t.prototype.enable_ui=function(){return this._disabled=!1,this.el.removeClass("disable")},t.prototype.transition_in=function(){var t,e;return e={ease:Power2.easeIn,z:100},TweenLite.to(this.ui.chapter,1.6,e),e={autoAlpha:1,ease:Power2.easeIn},TweenLite.to(this.ui.chapter_index,1.6,e),e={autoAlpha:1,ease:Power1.easeInOut,delay:1.6},TweenLite.to(this.ui.title,3,e),t=new n,t.animate(this.ui.letters,2e3),e={autoAlpha:1,ease:Power2.easeInOut,delay:5.7},TweenLite.to(this.ui.interactions,1.6,e),e={autoAlpha:1,ease:Power2.easeInOut,delay:5.7},TweenLite.to(this.ui.authors,1.6,e)},t.prototype.transition_out=function(){var t;return t={autoAlpha:0,ease:Power2.easeOut},TweenLite.to(this.ui.dim,1.6,t),t={autoAlpha:0,ease:Power2.easeOut,onComplete:function(e){return function(){return t={autoAlpha:1,ease:Power2.easeIn,onComplete:function(){var t;return t=new n,t.animate(e.ui.next_letters,0)}},TweenLite.to(e.ui.next,1.6,t)}}(this)},TweenLite.to(this.ui.chapter,1.6,t)},t.prototype.transition_out_fast=function(){var t;return this.ui.transition_black.removeClass("layer-0").addClass("layer-5"),t={autoAlpha:1,ease:Power2.easeOut,onComplete:function(t){return function(){return t.emit("transition:out:fast:complete")}}(this)},TweenLite.to(this.ui.transition_black,1.3,t)},t.prototype.hide=function(){var t;if(!this._disabled)return this.kill_tweens(),t={autoAlpha:0,ease:Power2.easeOut},this.tweens.push(TweenLite.to(this.ui.ui,1.6,t))},t.prototype.show=function(){var t;return this.kill_tweens(),t={autoAlpha:1,delay:1,ease:Power2.easeOut},this.tweens.push(TweenLite.to(this.ui.ui,1,t))},t.prototype.show_about=function(t){var e;return t.preventDefault(),this.is_overlay_open=!this.is_overlay_open,TweenLite.killTweensOf(this.ui.dim),TweenLite.killTweensOf(this.ui.chapter),this.is_overlay_open?(e={autoAlpha:0,ease:Power2.easeOut},TweenLite.to(this.ui.dim,.6,e),e={autoAlpha:0,ease:Power2.easeOut},TweenLite.to(this.ui.chapter,.6,e)):(e={autoAlpha:1,ease:Power2.easeOut},TweenLite.to(this.ui.dim,1.6,e),e={autoAlpha:1,delay:.5,ease:Power2.easeOut},TweenLite.to(this.ui.chapter,1.6,e))},t.prototype.kill_tweens=function(){var t,e,i,n,o;for(n=this.tweens,o=[],e=0,i=n.length;i>e;e++)t=n[e],o.push(null!=t?t.kill():void 0);return o},t.prototype.destroy=function(){return this.unbind,this.el.remove()},t}()},function(t,e,i){var n,o;n=new THREE.DirectionalLight(16777215,1),n.position.set(0,100,10),o=new THREE.PointLight(16777215,1,1e3),o.position.set(0,-150,0),e.lights=[o,n]},function(t,e,i){e.vertex=function(){var t;return t=["uniform float amplitude;","attribute vec3 customColor;","attribute vec3 displacement;","varying vec3 vNormal;","varying vec3 vColor;","void main() {","vNormal = normal;","vColor = customColor;","vec3 newPosition = position + amplitude * displacement;","gl_Position = projectionMatrix * modelViewMatrix * vec4( newPosition, 1.0 );","}"],t.join("\n")},e.fragment=function(){var t;return t=["varying vec3 vNormal;","varying vec3 vColor;",THREE.ShaderChunk.fog_pars_fragment,"void main() {","const float ambient = 0.005;","vec3 light = vec3( 1.0 );","light = normalize( light );","float directional = max( dot( vNormal, light ), 0.0 );","gl_FragColor = vec4( ( directional + ambient ) * vColor, 1.0 );","gl_FragColor.xyz = sqrt( gl_FragColor.xyz );",THREE.ShaderChunk.fog_fragment,"}"],t.join("\n")}},function(t,e,i){var n,o;n=new THREE.AmbientLight(11645361),o=new THREE.DirectionalLight(16777215,.7),o.position.x=30,o.position.y=30,o.position.z=30,o.shadowCameraNear=25,o.castShadow=!0,e.ambient=n,e.directional=o},function(t,e,i){var n,o,s,r,a,u=function(t,e){return function(){return t.apply(e,arguments)}},h={}.hasOwnProperty,l=function(t,e){function i(){this.constructor=t}for(var n in e)h.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};r=i(72),a=i(18),s=i(99),o=i(100),t.exports=r=function(t){function e(t,i,o){var s,r;this.id=t,this.gui=i,this.assets=o,this.on_navlink_click=u(this.on_navlink_click,this),this.on_mouse_out=u(this.on_mouse_out,this),this.on_mouse_over=u(this.on_mouse_over,this),e.__super__.constructor.call(this,this.id,this.assets),this.ui.sequences=this.el.find("[data-sequence]"),this.ui.nav_geometry=this.el.find("nav.geometry"), +this.ui.titles=this.el.find(".titles"),this.sequences={},s=this.ui.sequences.length,r=300,this.ui.sequences.each(function(e){return function(i,o){var s,r;return s=$(o),t=s.data("id"),r=a.get_asset(""+t+"_sequence",e.assets),e.sequences[t]=new n(s,r)}}(this))}return l(e,t),e.prototype.curent_id="octahedron",e.prototype.transition_in=function(){var t,i;return e.__super__.transition_in.call(this),t=9.5,i=[1,.7,.3,.7,1],this.ui.sequences.each(function(e){return function(e,n){var o,s;return o=$(n),s={autoAlpha:1,ease:Power2.easeIn,delay:t+i[e]},TweenLite.to(o.parent(),1.5,s)}}(this)),a.delay(t,function(t){return function(){return t.bind()}}(this))},e.prototype.bind=function(){return e.__super__.bind.call(this),this.ui.sequences.on("mouseover",this.on_mouse_over),this.ui.sequences.on("mouseleave",this.on_mouse_out),this.ui.sequences.on("click",this.on_navlink_click)},e.prototype.unbind=function(){return e.__super__.unbind.call(this),this.ui.sequences.off("mouseover",this.on_mouse_over),this.ui.sequences.off("mouseleave",this.on_mouse_out),this.ui.sequences.off("click",this.on_navlink_click)},e.prototype.on_mouse_over=function(t){var e,i;return e=$(t.currentTarget),i=e.data("id"),this.sequences[i].play()},e.prototype.on_mouse_out=function(){var t,e;return t=$(event.currentTarget),e=t.data("id"),this.sequences[e].stop()},e.prototype.on_navlink_click=function(t){var e,i;return t.preventDefault(),e=$(t.currentTarget),i=e.data("id"),this.curent_id!==i?(this.curent_id=i,this.ui.nav_geometry.find("a").removeClass("active"),this.ui.nav_geometry.find('a[data-id="'+i+'"]').addClass("active"),this.disable_ui(),this.emit("change:geometry",i)):void 0},e.prototype.show_title=function(t){var e;return TweenLite.set(this.ui.titles.find(".title"),{autoAlpha:0}),TweenLite.set(this.ui.titles.find('[data-id="'+t+'"]'),{autoAlpha:1}),e={ease:Power2.easeIn,autoAlpha:1},TweenLite.to(this.ui.titles,1.6,e),e={ease:Power2.easeIn,autoAlpha:0},TweenLite.to(this.ui.next_text,1.6,e)},e.prototype.hide_title=function(){var t;return this.enable_ui(),t={ease:Power2.easeIn,autoAlpha:0},TweenLite.to(this.ui.titles,1.6,t),t={ease:Power2.easeIn,autoAlpha:1},TweenLite.to(this.ui.next_text,1.6,t)},e.prototype.destroy=function(){var t,i,n;n=this.sequences;for(t in n)i=n[t],i.destroy();return e.__super__.destroy.call(this)},e}(r),n=function(){function t(t,e){this.el=t,this.repeat_for_hover=u(this.repeat_for_hover,this),this.player=new s(this.el[0]),this.player.on("setup_complete",function(t){return function(){return t.mode=new o.LinearMode(t.player.data),t.player.set_mode(t.mode),t.mode.frame=0,t.mode._update()}}(this)),this.player.noload(e.data,e.images)}return t.prototype.play=function(){return this.mode.play(1,this.mode.total_frames()),this.mode.on("complete",this.repeat_for_hover)},t.prototype.stop=function(){return this.mode.off("complete",this.repeat_for_hover)},t.prototype.repeat_for_hover=function(){return this.mode.play(1,this.mode.total_frames())},t.prototype.destroy=function(){return this.mode=null,this.player.destroy()},t}()},function(t,e,i){var n,o;n=function(){function t(){}var e,i;return e=1.61803399,i=Array,t.prototype.presets={IcosahedronGeometry:{scale_ratio:1+e},TetrahedronGeometry:{scale_ratio:2},OctahedronGeometry:{scale_ratio:2}},t.prototype.type=null,t.prototype.radius=null,t.prototype.iterations=null,t.prototype.scale_ratio=null,t.prototype.generate=function(t,e,n,o,s){var r,a,u,h,l,c,d,p,_,f,m,g;for(this.geometry_class=null!=t?t:"IcosahedronGeometry",this.radius=null!=e?e:20,this.iterations=null!=n?n:1,this.scale_ratio=null!=o?o:2.61803399,this.detail=null!=s?s:0,l=1,r="BoxGeometry"===this.geometry_class?new THREE[this.geometry_class](this.radius,this.radius,this.radius):new THREE[this.geometry_class](this.radius,this.detail),u=[{vertices:[],center:new THREE.Vector3}],i=[],m=r.vertices,p=0,f=m.length;f>p;p++)d=m[p],i.push(d.clone().normalize()),u[0].vertices.push(d.clone());for(h=1-1/this.scale_ratio,a=_=0,g=this.iterations;g>=0?g>_:_>g;a=g>=0?++_:--_)l/=this.scale_ratio,e=this.radius*l,c=this._generate_data(u,e,h,a+1),u=c;return r.dispose(),u},t.prototype._generate_data=function(t,e,n,o){var s,r,a,u,h,l,c,d,p,_,f,m,g,y,v,b,w,x,E;for(c=[],g=0,b=t.length;b>g;g++)for(l=t[g],E=l.vertices,a=y=0,w=E.length;w>y;a=++y){for(d=E[a],p=[],s=l.center.clone().lerp(d.clone(),n),u=v=0,x=i.length;x>v;u=++v)h=i[u],_=s.x+e*i[u].x,f=s.y+e*i[u].y,m=s.z+e*i[u].z,p.push(new THREE.Vector3(_,f,m));r={vertices:p,center:s},c.push(r)}return c},t.prototype.logarithmic_scale=function(){return this.radius/Math.pow(this.scale_ratio,this.iterations)},t}(),o=function(){function t(){}var e;return t.prototype.size=null,t.prototype.iterations=null,t.prototype.generate=function(t,e,i,n){var o,s,r,a,u,h,l,c,d,p,_,f,m;for(this.size=null!=t?t:20,this.iterations=null!=e?e:2,this.grid=null!=i?i:3,this.holes=null!=n?n:[4,10,12,13,14,16,22],r=1/this.grid,s=this.size*r,h=[new THREE.Vector3],a=c=0,m=this.iterations;m>=0?m>c:c>m;a=m>=0?++c:--c){for(l=[],d=0,_=h.length;_>d;d++)u=h[d],l=l.concat(this._sponge(u,s,this.grid,this.holes));s*=r,h=l}for(o=this.size/2-this.logarithmic_scale()/2,p=0,f=h.length;f>p;p++)u=h[p],u.x-=o,u.y-=o,u.z-=o;return h},t.prototype._sponge=function(t,i,n,o){var s,r,a,u,h,l,c,d,p;for(r=0,h=[],a=c=0;n>=0?n>c:c>n;a=n>=0?++c:--c)for(l=d=0;n>=0?n>d:d>n;l=n>=0?++d:--d)for(s=p=0;n>=0?n>p:p>n;s=n>=0?++p:--p)u=new THREE.Vector3,u.x=t.x+l*i,u.y=t.y+a*i,u.z=t.z+s*i,e(r,o)||h.push(u),r++;return h},e=function(t,e){var i,n,o,s;for(n=!1,o=0,s=e.length;s>o;o++)if(i=e[o],i===t){n=!0;break}return n},t.prototype.logarithmic_scale=function(){return this.size/Math.pow(this.grid,this.iterations)},t}(),e.SierpinskiPolyhedron=n,e.SierpinskiSponge=o},function(t,e,i){var n,o,s=function(t,e){return function(){return t.apply(e,arguments)}};t.exports=o=function(){function t(){this._on_chunk_complete=s(this._on_chunk_complete,this)}return t.prototype.chunk_size=10,t.prototype.count=0,t.prototype.total=0,t.prototype.progress=0,t.prototype.geometries=[],t.prototype.build=function(t,e,i,o,s){var r,a,u,h,l,c;for(this.geometry_class=t,this.data=e,this.size=i,this.detail=o,this.callback=s,this._reset(),a=[];this.data.length>0;)a.push(this.data.splice(0,this.chunk_size));for(this.total=a.length,c=[],u=h=0,l=a.length;l>h;u=++h)r=a[u],c.push(new n(this.geometry_class,r,this.size,this.detail,this._on_chunk_complete));return c},t.prototype._on_chunk_complete=function(t){var e,i,n,o,s;if(this.count++,this.progress=this.count/this.total,this.geometries.push(t),this.count===this.total){for(i=new THREE.Geometry,s=this.geometries,n=0,o=s.length;o>n;n++)e=s[n],i.merge(e);return this.callback(i),this._reset()}},t.prototype._reset=function(){return this.count=0,this.total=0,this.progress=0,this.geometries=[]},t}(),n=function(){function t(t,e,i,n,o){this.geometry_class=t,this.data=e,this.size=i,this.detail=n,this.callback=o,this._build=s(this._build,this),this.progress=0,this.time_total=0,this.total=this.data.length,this.geometry=new THREE.Geometry,this._build()}return t.prototype._build=function(){var t,e,i,n,o,s;for(e="BoxGeometry"===this.geometry_class?new THREE[this.geometry_class](this.size,this.size,this.size):new THREE[this.geometry_class](this.size,this.detail),s=this.data[this.progress].vertices,t=n=0,o=s.length;o>n;t=++n)i=s[t],e.vertices[t].x=i.x,e.vertices[t].y=i.y,e.vertices[t].z=i.z;return this.geometry.merge(e),this.progress++,this.progress===this.total?this.callback(this.geometry):window.setTimeout(this._build,10)},t}()},function(t,e,i){var n,o;n=new THREE.AmbientLight(16777215),o=new THREE.DirectionalLight(16777215,.6),t.exports=[n,o]},function(t,e,i){e.vertex=function(){var t;return t=["attribute float alpha;","attribute float size;","varying float vAlpha;","void main() {","vAlpha = alpha;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","gl_PointSize = size * ( 100.0 / length( mvPosition.xyz ) );","gl_Position = projectionMatrix * mvPosition;","}"],t.join("\n")},e.fragment=function(){var t;return t=["uniform vec3 color;","varying float vAlpha;","uniform sampler2D texture;",THREE.ShaderChunk.fog_pars_fragment,"void main() {","gl_FragColor = vec4( color, vAlpha );","gl_FragColor = gl_FragColor * texture2D( texture, gl_PointCoord );",THREE.ShaderChunk.fog_fragment,"}"],t.join("\n")}},function(t,e,i){var n,o,s,r,a,u,h,l,c,d,p,_,f,m,g=function(t,e){return function(){return t.apply(e,arguments)}};d=i(26),h=i(19),m=i(18),_=i(9),c=i(8),r=i(94),l=i(55),p=i(16),a=i(93),s=i(99),o=i(100),f=i(95),t.exports=u=function(){function t(t,e,i){this.scene=t,this.gui=e,this.assets=i,this.on_social_click=g(this.on_social_click,this),this.ui={dim:".dim",hitarea:".hitarea",transition_black:".transition_black",hires:"h1 a",preface:"h2",paragraphs:".paragraphs dd, .paragraphs dt",next:".next",social:".social",social_links:".social a"},d(this),this.tweens=[],this.render()}return t.prototype.render=function(){var t,e,o,s,r,a;e=p.get("epilogue"),r=i(97),$("main").append(r({data:e})),this.el=$("#"+e.id),a=this.ui;for(s in a)o=a[s],this.ui[s]=this.el.find(o);return this.ui.letters=this.ui.paragraphs.lettering().children(),this.ui.next_letters=this.ui.next.lettering().children(),this.ui.dim.remove(),t=m.get_asset("hires_sequence",this.assets),this.ui.sequence=new n(this.ui.hires,t),this.bind()},t.prototype.bind=function(){return this.ui.social_links.on("click",this.on_social_click)},t.prototype.unbind=function(){return this.ui.social_links.off("click",this.on_social_click)},t.prototype.on_social_click=function(t){var e,i;switch(t.preventDefault(),e=$(t.currentTarget),i=e.data("share")){case"facebook":return f.facebook(_.share_url,c.get("share_text"));case"twitter":return f.twitter(_.share_url,c.get("share_text"));case"google":return f.plus(_.share_url)}},t.prototype.transition_in=function(){var t,e;return e={delay:l.ui_delay+10,autoAlpha:1,ease:Power4.easeIn},TweenLite.to(this.ui.preface,1.2,e),m.delay(l.ui_delay+14,function(t){return function(){return t.ui.sequence.play()}}(this)),t=l.ui_delay+15,m.delay(t,function(t){return function(){var e;return e=new a,e.animate(t.ui.letters,4e3)}}(this)),t=l.ui_delay+21,e={delay:t,autoAlpha:1,ease:Power2.easeIn},TweenLite.to(this.ui.social,1,e)},t.prototype.transition_out=function(){var t;return this.kill_tweens(),t={autoAlpha:0,ease:Power2.easeOut},this.tweens.push(TweenLite.to(this.el,1.6,t))},t.prototype.transition_out_fast=function(){var t;return this.ui.transition_black.removeClass("layer-0").addClass("layer-5"),t={autoAlpha:1,ease:Power2.easeOut,onComplete:function(t){return function(){return t.emit("transition:out:fast:complete")}}(this)},TweenLite.to(this.ui.transition_black,1.3,t)},t.prototype.kill_tweens=function(){var t,e,i,n,o;for(n=this.tweens,o=[],e=0,i=n.length;i>e;e++)t=n[e],o.push(null!=t?t.kill():void 0);return o},t.prototype.destroy=function(){var t;return this.unbind(),null!=(t=this.sequence)&&t.destroy(),this.el.remove()},t}(),n=function(){function t(t,e){this.el=t,this.player=new s(this.el[0]),this.player.on("setup_complete",function(t){return function(){return t.mode=new o.LinearMode(t.player.data),t.player.set_mode(t.mode)}}(this)),this.player.noload(e.data,e.images)}return t.prototype.play=function(){return this.mode.once("complete",function(t){return function(){return t.mode.frame=t.mode.total_frames(),t.mode._update()}}(this)),this.mode.play(5,this.mode.total_frames())},t.prototype.destroy=function(){return this.mode=null,this.player.destroy()},t}()},function(t,e,i){var n,o,s,r;n=new THREE.AmbientLight(4276545),o=new THREE.DirectionalLight(16777215,1),o.position.x=100,o.position.y=100,o.position.z=100,o.shadowCameraNear=25,o.castShadow=!0,s=new THREE.PointLight(16777215,1,1e3),s.position.set(50,50,50),r=new THREE.PointLight(16777215,1,1e3),r.position.set(-50,50,50),s.intensity=.1,r.intensity=.1,e.directional=o,e.point1=s,e.point2=r,e.all=[n,o,s,r]},function(t,e,i){var n,o,s=function(t,e){return function(){return t.apply(e,arguments)}};o=i(26),t.exports=n=function(){function t(t){this.app=t,this.start=s(this.start,this),this.play=s(this.play,this),this.stop=s(this.stop,this),o(this),window.sound=this,c.log("x"),this.cc=window.cc=new CoffeeCollider,setTimeout(this.start,750)}return t.prototype.playing=!0,t.prototype.rec=null,t.prototype.tape=function(){},t.prototype.stop=function(){return cc.reset(),this.playing=!1},t.prototype.play=function(){return console.warn("asd")},t.prototype.start=function(){return this.emit("started"),this.cc.on("sin",function(){return console.dir(arguments[0])})},t.prototype.background_atmos=function(t){return cc.run("(->\n\n noise = PinkNoise.ar(0.2)\n\n noise = Mix Array.fill 10, (i)->\n Resonz.ar(noise, i * 55 + 220, 0.05)\n\n noise = (noise * 0.2 + noise * Decay.kr(Dust.kr(0.5), 10))\n\n noise = RHPF.ar( noise, LFNoise0.kr(0.5).range(220, 55), rq:0.001)\n\n CombL.ar(noise, delaytime:1, decaytime:25).dup() * Line.kr( 0, 0.4, dur: "+t+")\n\n).play()",!0)},t.prototype.clickable_distortion=function(){return cc.run("(->\n freq = MouseY.kr(55 / 2, 55, 'exponential')\n freq1 = freq * MouseX.kr(2, 0.5, lag:2.5)\n freq2 = freq * MouseX.kr(0.5, 2, lag:2.5)\n feedback = MouseButton.kr(0, 0.5.pi(), lag:5)\n SinOscFB.ar([freq1, freq2], feedback, mul:0.25)\n).play()",!0)},t.prototype.bass_sequence=function(){return cc.run("\nsynth = SynthDef (freq)->\n\n s = SinOscFB.ar( freq ) * Line.kr(1, 0, dur:0.5, doneAction:2)\n s = s.dup()\n Out.ar(0, s) * 0.5\n\n.add()\n\np = Pseq( [ 55,0,0,0 ], Infinity )\n\nTask ->\n 0.wait()\n p.do syncblock (freq)->\n # freq = (60 - 24 + i).midicps()\n\n Synth(synth, freq:freq)\n\n [0.5].choose().wait()\n.start()\n\np = Pseq( [ 55,0,0,0,55*1.25 ], Infinity )\n\nTask ->\n 0.2.wait()\n p.do syncblock (freq)->\n # freq = (60 - 24 + i).midicps()\n\n Synth(synth, freq:freq)\n\n [0.5].choose().wait()\n.start()\n",!0)},t.prototype.percolation=function(t,e,i){return null==t&&(t=60),null==e&&(e=7),null==i&&(i=40),cc.run("d = "+t+" # number of percolators\nc = "+e+" # number of comb delays\na = "+i+" # number of allpass delays\n(->\n # sine percolation sound :\n s = Mix.ar Array.fill d, ->\n Resonz.ar(Dust.ar(2 / d, 50), 200 + 30000.rand(), 0.003)\n\n # reverb predelay time :\n z = DelayN.ar(s, 0.000498)\n\n # 7 length modulated comb delays in parallel :\n y = Mix.ar CombL.ar(z, 0.1, LFNoise1.kr(Array.fill(c, (->1.rand())), 0.04, 0.05), 15)\n\n # chain of 4 allpass delays on each of two channels (8 total) :\n a.do ->\n y = AllpassN.ar(y, 0.050, [0.050.rand(), 0.050.rand()], 1)\n\n # add original sound to reverb and play it :\n s + 0.2 * y\n).play()",!0)},t.prototype.klank=function(t,e){return cc.run("(->\n n = 5 # number of simultaneous instruments\n p = 15 # number of partials per instrument\n\n # filter bank specification :\n z = $([\n Array.fill(p, (-> 80 + 10000.linrand() )) # frequencies\n Array.fill(p, (-> 1.rand2() )) # amplitudes\n Array.fill(p, (-> 0.2 + 8.rand() )) # ring times\n ])\n\n p = Pan2.ar(Klank.ar(z, Dust.ar(0.07, 0.25)), SinOsc(1))\n\n 40.do ->\n p = AllpassN.ar(p, 0.050, [0.050.rand(), 0.050.rand()], 1)\n\n p\n).play()\n",!0)},t.prototype.glass=function(){return cc.run("d = 60 # number of percolators\nc = 7 # number of comb delays\na = 40 # number of allpass delays\n\nd = 1 # number of percolators\nc = 1 # number of comb delays\na = 1 # number of allpass delays\n\n(->\n # sine percolation sound :\n s = Mix.ar Array.fill d, ->\n Resonz.ar( Dust.ar(2 + d.rand(), 50), 200 + 30000.rand(), 0.003 )\n\n # reverb predelay time :\n z = DelayN.ar(s, 0.000498)\n\n # 7 length modulated comb delays in parallel :\n y = Mix.ar CombL.ar(z, 0.1, LFNoise1.kr(Array.fill(c, (->1.rand())), 0.04, 0.05), 15)\n\n # chain of 4 allpass delays on each of two channels (8 total) :\n a.do ->\n y = AllpassN.ar(y, 0.050, [0.050.rand(), 0.050.rand()], 1)\n\n # add original sound to reverb and play it :\n s + 0.2 * y\n).play()",!0)},t.prototype.listen_messages=function(){return cc.run('\nMessage.on "noise", (value)->\n console.log "noise is" + value.data\n',!0)},t.prototype.send_messages=function(){return cc.run("\nfreq = MouseY.kr( 10, 100, 'linear' )\n\np = Pseq( [ 10, 20, 30 ], 1 )\n\nTask ->\n p.do syncblock ( value )->\n\n # console.log freq\n\n Message.send \"sin\", ( value * freq ).exprange( 0, 1)\n\n 0.5.wait()\n.start()\n",!0)},t}()},function(t,e,i){var n,o,s,r,a,u,h,l;u=i(26),r=i(19),l=i(18),n=i(94),a=i(61),h=i(16),o=i(93),t.exports=s=function(){function t(t,e,i){this.scene=t,this.gui=e,this.assets=i,this.ui={dim:".dim",hitarea:".hitarea",hires:"h1",preface:"h2",paragraphs:".paragraphs p",next:".next"},u(this),this.tweens=[],this.render()}return t.prototype.render=function(){var t,e,o,s,r,u,l,c,d,p,_;t=h.get("home"),u=i(98),$("main").append(u({data:t})),this.el=$("#"+t.id),p=this.ui;for(s in p)o=p[s],this.ui[s]=this.el.find(o);for(this.ui.letters=this.ui.paragraphs.lettering().children(),this.ui.next_letters=this.ui.next.lettering().children(),this.ui.dim.remove(),this.container=new THREE.Object3D,this.scene.add(this.container),this.container.position.fromArray(a.title_position),l=new n,this.title_meshes=l.create_multichar({text:"VOID",size:490,curve_segments:10}),_=this.title_meshes,e=c=0,d=_.length;d>c;e=++c)r=_[e],this.container.add(r);return this.paragraph_meshes=[]},t.prototype.update=function(){return this.container.lookAt(r.user.position)},t.prototype.transition_in=function(){var t,e,i,n,s,r,u,h,c,d,p,_,f;for(n={autoAlpha:1,ease:Power2.easeIn,delay:2},TweenLite.to(this.ui.hires,4,n),n={autoAlpha:1,ease:Power4.easeIn,delay:.5},TweenLite.to(this.ui.preface,1.2,n),d=new TimelineLite,f=this.title_meshes,e=p=0,_=f.length;_>p;e=++p)i=f[e],h=a.title_letter_in_position[e],s={x:h[0],y:h[1],z:h[2],ease:Power3.easeOut},c=a.title_letter_in_rotation[e],r={x:c[0],y:c[1],z:c[2],ease:Power3.easeOut},u={opacity:1,delay:l.random(0,1),ease:Power2.easeOut},d.to(i.position,20,s,1.8),d.to(i.rotation,20,r,1.8),d.to(i.material,5,u,2.3);return d.play(),t=new o,t.animate(this.ui.letters,4e3),n={autoAlpha:1,ease:Power2.easeIn,delay:3,onComplete:function(e){return function(){return t=new o,t.exclude=[11,12,13,14,15,16,17,18,19,20],t.animate(e.ui.next_letters,0)}}(this)},TweenLite.to(this.ui.next,1.6,n)},t.prototype.transition_out=function(){var t,e,i,n,o,s,r,a,u,h,c,d,p,_,f;for(this.kill_tweens(),TweenLite.killTweensOf(this.el),e={autoAlpha:0,ease:Power2.easeOut},this.tweens.push(TweenLite.to(this.el,1.6,e)),u=new TimelineLite,f=this.title_meshes,p=0,_=f.length;_>p;p++)t=f[p],o=200,h=t.position.x+l.random(-o,o),c=t.position.y+l.random(-o,o),d=t.position.z+l.random(2*-o,2*o),o=Math.PI/2,s=l.random(-o,o),r=l.random(-o,o),a=l.random(-o,o),i={delay:4,x:h,y:c,z:d,ease:Power1.easeInOut},n={delay:4,x:s,y:r,z:a,ease:Power1.easeInOut},u.to(t.position,20,i,0),u.to(t.rotation,20,n,0);return u.play(),this.tweens.push(u)},t.prototype.transition_out_backward=function(){var t,e,i,n,o,s,r,u,h,l,c;for(this.kill_tweens(),i={autoAlpha:1,ease:Power2.easeOut,delay:2},this.tweens.push(TweenLite.to(this.el,1.6,i)),u=new TimelineLite,c=this.title_meshes,t=h=0,l=c.length;l>h;t=++h)e=c[t],s=a.title_letter_in_position[t],n={x:s[0],y:s[1],z:s[2],ease:Power3.easeOut},r=a.title_letter_in_rotation[t],o={x:r[0],y:r[1],z:r[2],ease:Power3.easeOut},u.to(e.position,20,n,1.8),u.to(e.rotation,20,o,1.8);return u.play(),this.tweens.push(u)},t.prototype.kill_tweens=function(){var t,e,i,n,o;for(n=this.tweens,o=[],e=0,i=n.length;i>e;e++)t=n[e],o.push(null!=t?t.kill():void 0);return o},t.prototype.destroy=function(){return this.el.remove()},t}()},function(t,e,i){var n;n=new THREE.AmbientLight(11645361),t.exports=[n]},function(t,e,i){var n,o,s,r;n=new THREE.PointLight(16711680),n.position.set(10,0,0),o=new THREE.PointLight(52224),o.position.set(0,10,0),s=new THREE.PointLight(255),s.position.set(0,0,10),r=new THREE.PointLight(3355443),r.position.set(-10,-10,-10),e.lights=[n,o,s,r]},function(t,e,i){var n,o,s,r=function(t,e){return function(){return t.apply(e,arguments)}};s=i(26),o=i(19).user,t.exports=n=function(){function t(t,e,i,n,o){this.el=t,this.shape=null!=e?e:"box",this.size_x=null!=i?i:10,this.size_y=null!=n?n:10,this.size_z=null!=o?o:10,this.on_click=r(this.on_click,this),this.on_mouse_move=r(this.on_mouse_move,this),s(this),"box"===this.shape&&this.box(),"sphere"===this.shape&&this.sphere(),"plane"===this.shape&&this.plane()}return t.prototype.over=!1,t.prototype.mouse_x=0,t.prototype.mouse_y=0,t.prototype.enabled=!0,t.prototype.visible=!1,t.prototype.box=function(){var t;return t=new THREE.BoxGeometry(this.size_x,this.size_y,this.size_z),this.mesh=new THREE.Mesh(t,this.material()),this.mesh.visible=this.visible},t.prototype.sphere=function(){var t;return t=new THREE.SphereGeometry(this.size_x,8,8),this.mesh=new THREE.Mesh(t,this.material()),this.mesh.visible=this.visible},t.prototype.plane=function(){var t;return t=new THREE.PlaneGeometry(this.size_x,this.size_y,1,1),this.mesh=new THREE.Mesh(t,this.material()),this.mesh.visible=this.visible},t.prototype.material=function(){var t;return t={color:65280,wireframe:!0,wireframeLinewidth:5},new THREE.MeshBasicMaterial(t)},t.prototype.bind=function(){return this.el.on("click",this.on_click),this.el.on("mousemove",this.on_mouse_move)},t.prototype.unbind=function(){return this.el.off("click",this.on_click),this.el.off("mousemove",this.on_mouse_move)},t.prototype.on_mouse_move=function(t){var e,i,n,s,r;return this.mouse_x=t.clientX,this.mouse_y=t.clientY,i=this.mouse_x/window.innerWidth*2-1,n=2*-(this.mouse_y/window.innerHeight)+1,r=new THREE.Vector3(i,n,.5),r.unproject(o),s=new THREE.Raycaster(o.position,r.sub(o.position).normalize()),e=s.intersectObject(this.mesh),e.length>0?this.on_over():this.on_out()},t.prototype.on_over=function(){return this.enabled&&!this.over?($("body").css("cursor","pointer"),this.over=!0,this.emit("over")):void 0},t.prototype.on_out=function(){return this.enabled&&this.over?(this.over=!1,$("body").css("cursor",""),this.emit("out")):void 0},t.prototype.on_click=function(t){return t.preventDefault(),this.over?this.emit("click"):void 0},t.prototype.reset=function(){return this.enabled=!0},t}()},function(t,e,i){var n,o,s,r=function(t,e){return function(){return t.apply(e,arguments)}};o=i(19).user,s=i(18),t.exports=n=function(){function t(t,e,i,n,o,s,a){var u,h,l,c,d,p,_,f;for(this.id=t,this.scene=e,this.points=i,this.lookat=n,this.color=o,this.gui=null!=s?s:null,null==a&&(a=100),this.update_camera=r(this.update_camera,this),this.update_path=r(this.update_path,this),this.gui&&(h=this.gui.addFolder(this.id),h.add(this,"export_data"),h.add(this,"camera_position",0,1).onChange(function(t){return function(){return t.update_camera()}}(this)),h.open()),this.gui&&(this.lookat_marker=new THREE.Mesh(new THREE.SphereGeometry(2,8,8),new THREE.MeshBasicMaterial({color:16711680})),this.lookat_marker.position.set(this.lookat.x,this.lookat.y,this.lookat.z),this.lookat_marker.visible=this.debug,this.scene.add(this.lookat_marker),u=h.addFolder("lookat"),u.add(this.lookat_marker.position,"x",-a,a),u.add(this.lookat_marker.position,"y",-a,a),u.add(this.lookat_marker.position,"z",-a,a),u.open()),this.markers=[],f=this.points,l=p=0,_=f.length;_>p;l=++p)d=f[l],this.gui&&(u=h.addFolder("point_"+l),u.add(d,"x",-a,a).onChange(function(t){return function(){return t.update_path()}}(this)),u.add(d,"y",-a,a).onChange(function(t){return function(){return t.update_path()}}(this)),u.add(d,"z",-a,a).onChange(function(t){return function(){return t.update_path()}}(this)),u.open()),c=new THREE.Mesh(new THREE.SphereGeometry(1,8,8),new THREE.MeshBasicMaterial({color:this.color})),c.visible=this.debug,this.markers.push(c),this.scene.add(c);this.update_path()}return t.prototype.path_curve=null,t.prototype.camera_position=.1,t.prototype.debug=!1,t.prototype.update_path=function(){var t,e,i,n,o,r,a,u,h,l,c;for(o=[],c=this.points,e=a=0,h=c.length;h>a;e=++a)i=c[e],this.markers[e].position.set(i.x,i.y,i.z),o.push(new THREE.Vector3(i.x,i.y,i.z));for(this.scene.remove(this.path_curve),r=s.spline(o),n=r.getPoints(50),t=new THREE.Geometry,u=0,l=n.length;l>u;u++)i=n[u],t.vertices.push(i.clone());return this.path_curve=new THREE.Line(t,new THREE.LineBasicMaterial(16777215*Math.random())),this.path_curve.visible=this.debug,this.scene.add(this.path_curve),this.spline=s.spline(n)},t.prototype.update_camera=function(){var t;return t=this.spline.getPointAt(this.camera_position),o.position.copy(t),o.lookAt(this.lookat_marker.position)},t.prototype.export_data=function(){var t,e,i,n,o,s,r;for(i={},i[this.id]=[],r=this.points,e=o=0,s=r.length;s>o;e=++o)n=r[e],t={x:n.x,y:n.y,z:n.z},i[this.id].push(t);return i[this.id+"_lookat"]={x:this.lookat_marker.position.x,y:this.lookat_marker.position.y,z:this.lookat_marker.position.z},c.log(JSON.stringify(i,void 0,4))},t}()},function(t,e,i){var n,o,s,r=function(t,e){return function(){return t.apply(e,arguments)}};o=i(19).user,s=i(18),t.exports=n=function(){function t(t,e,i,n,o,s,a){var u,h,l,c,d,p,_,f,m,g,y,v;for(this.id=t,this.scene=e,this.points=i,this.lookat_points=n,this.color=o,this.gui=null!=s?s:null,null==a&&(a=100),this.update_camera=r(this.update_camera,this),this.update_path=r(this.update_path,this),d=1,this.gui&&(h=this.gui.addFolder(this.id),h.add(this,"export_data"),h.add(this,"camera_position",0,1).onChange(function(t){return function(){return t.update_camera()}}(this)),h.add(this,"lookat_position",0,1).onChange(function(t){return function(){return t.update_camera()}}(this)),h.open()),this.gui&&(this.lookat_marker=new THREE.Mesh(new THREE.SphereGeometry(d,8,8),new THREE.MeshBasicMaterial({color:16711680})),this.lookat_marker.visible=!1,this.scene.add(this.lookat_marker),u=h.addFolder("lookat"),u.add(this.lookat_marker.position,"x",-a,a),u.add(this.lookat_marker.position,"y",-a,a),u.add(this.lookat_marker.position,"z",-a,a),u.open()),this.markers=[],y=this.points,l=_=0,m=y.length;m>_;l=++_)p=y[l],this.gui&&(u=h.addFolder("point_"+l),u.add(p,"x",-a,a).onChange(function(t){return function(){return t.update_path()}}(this)),u.add(p,"y",-a,a).onChange(function(t){return function(){return t.update_path()}}(this)),u.add(p,"z",-a,a).onChange(function(t){return function(){return t.update_path()}}(this)),u.open()),c=new THREE.Mesh(new THREE.SphereGeometry(d,8,8),new THREE.MeshBasicMaterial({color:this.color})),c.visible=this.debug,this.markers.push(c),this.scene.add(c);for(this.lookat_markers=[],v=this.lookat_points,l=f=0,g=v.length;g>f;l=++f)p=v[l],this.gui&&(u=h.addFolder("lookat_point_"+l),u.add(p,"x",-a,a).onChange(function(t){return function(){return t.update_path()}}(this)),u.add(p,"y",-a,a).onChange(function(t){return function(){return t.update_path()}}(this)),u.add(p,"z",-a,a).onChange(function(t){return function(){return t.update_path()}}(this)),u.open()),c=new THREE.Mesh(new THREE.SphereGeometry(d,8,8),new THREE.MeshBasicMaterial({color:this.color})),c.visible=this.debug,this.lookat_markers.push(c),this.scene.add(c);this.update_path()}return t.prototype.path_curve=null,t.prototype.camera_position=.1,t.prototype.lookat_position=.1,t.prototype.debug=!1,t.prototype.update_path=function(){var t,e,i,n,o,r,a,u,h,l,c,d,p,_,f,m;for(o=[],f=this.points,e=a=0,c=f.length;c>a;e=++a)i=f[e],this.markers[e].position.set(i.x,i.y,i.z),o.push(new THREE.Vector3(i.x,i.y,i.z));for(this.scene.remove(this.path_curve),r=s.spline(o),n=r.getPoints(50),t=new THREE.Geometry,u=0,d=n.length;d>u;u++)i=n[u],t.vertices.push(i.clone());for(this.path_curve=new THREE.Line(t,new THREE.LineBasicMaterial(16777215*Math.random())),this.path_curve.visible=this.debug,this.scene.add(this.path_curve),this.spline=s.spline(n),o=[],m=this.lookat_points,e=h=0,p=m.length;p>h;e=++h)i=m[e],this.lookat_markers[e].position.set(i.x,i.y,i.z),o.push(new THREE.Vector3(i.x,i.y,i.z));for(this.scene.remove(this.path_camera_curve),r=s.spline(o),n=r.getPoints(50),t=new THREE.Geometry,l=0,_=n.length;_>l;l++)i=n[l],t.vertices.push(i.clone());return this.path_camera_curve=new THREE.Line(t,new THREE.LineBasicMaterial(16777215*Math.random())),this.path_camera_curve.visible=this.debug,this.scene.add(this.path_camera_curve),this.spline_camera=s.spline(n),this.update_camera()},t.prototype.update_camera=function(){var t;return t=this.spline.getPointAt(this.camera_position),o.position.copy(t),t=this.spline_camera.getPointAt(this.lookat_position),this.gui?(this.lookat_marker.position.copy(t),o.lookAt(this.lookat_marker.position)):void 0},t.prototype.export_data=function(){var t,e,i,n,o,s,r;for(i={},i[this.id]=[],r=this.points,e=o=0,s=r.length;s>o;e=++o)n=r[e],t={x:n.x,y:n.y,z:n.z},i[this.id].push(t);return i[this.id+"_lookat"]={x:this.lookat_marker.position.x,y:this.lookat_marker.position.y,z:this.lookat_marker.position.z},c.log(JSON.stringify(i,void 0,4))},t}()},function(t,e,i){var n=t.exports=n||{};n.gui=n.gui||{},n.utils=n.utils||{},n.controllers=n.controllers||{},n.dom=n.dom||{},n.color=n.color||{},n.utils.css=function(){return{load:function(t,e){e=e||document;var i=e.createElement("link");i.type="text/css",i.rel="stylesheet",i.href=t,e.getElementsByTagName("head")[0].appendChild(i)},inject:function(t,e){e=e||document;var i=document.createElement("style");i.type="text/css",i.innerHTML=t,e.getElementsByTagName("head")[0].appendChild(i)}}}(),n.utils.common=function(){var t=Array.prototype.forEach,e=Array.prototype.slice;return{BREAK:{},extend:function(t){return this.each(e.call(arguments,1),function(e){for(var i in e)this.isUndefined(e[i])||(t[i]=e[i])},this),t},defaults:function(t){return this.each(e.call(arguments,1),function(e){for(var i in e)this.isUndefined(t[i])&&(t[i]=e[i])},this),t},compose:function(){var t=e.call(arguments);return function(){for(var i=e.call(arguments),n=t.length-1;n>=0;n--)i=[t[n].apply(this,i)];return i[0]}},each:function(e,i,n){if(t&&e.forEach===t)e.forEach(i,n);else if(e.length===e.length+0){for(var o=0,s=e.length;s>o;o++)if(o in e&&i.call(n,e[o],o)===this.BREAK)return}else for(var o in e)if(i.call(n,e[o],o)===this.BREAK)return},defer:function(t){setTimeout(t,0)},toArray:function(t){return t.toArray?t.toArray():e.call(t)},isUndefined:function(t){return void 0===t},isNull:function(t){return null===t},isNaN:function(t){return t!==t},isArray:Array.isArray||function(t){return t.constructor===Array},isObject:function(t){return t===Object(t)},isNumber:function(t){return t===t+0},isString:function(t){return t===t+""},isBoolean:function(t){return t===!1||t===!0},isFunction:function(t){return"[object Function]"===Object.prototype.toString.call(t)}}}(),n.controllers.Controller=function(t){var e=function(t,e){this.initialValue=t[e],this.domElement=document.createElement("div"),this.object=t,this.property=e,this.__onChange=void 0,this.__onFinishChange=void 0};return t.extend(e.prototype,{onChange:function(t){return this.__onChange=t,this},onFinishChange:function(t){return this.__onFinishChange=t,this},setValue:function(t){return this.object[this.property]=t,this.__onChange&&this.__onChange.call(this,t),this.updateDisplay(),this},getValue:function(){return this.object[this.property]},updateDisplay:function(){return this},isModified:function(){return this.initialValue!==this.getValue()}}),e}(n.utils.common),n.dom.dom=function(t){function e(e){if("0"===e||t.isUndefined(e))return 0;var i=e.match(o);return t.isNull(i)?0:parseFloat(i[1])}var i={HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},n={};t.each(i,function(e,i){t.each(e,function(t){n[t]=i})});var o=/(\d+(\.\d+)?)px/,s={makeSelectable:function(t,e){void 0!==t&&void 0!==t.style&&(t.onselectstart=e?function(){return!1}:function(){},t.style.MozUserSelect=e?"auto":"none",t.style.KhtmlUserSelect=e?"auto":"none",t.unselectable=e?"on":"off")},makeFullscreen:function(e,i,n){t.isUndefined(i)&&(i=!0),t.isUndefined(n)&&(n=!0),e.style.position="absolute",i&&(e.style.left=0,e.style.right=0),n&&(e.style.top=0,e.style.bottom=0)},fakeEvent:function(e,i,o,s){o=o||{};var r=n[i];if(!r)throw new Error("Event type "+i+" not supported.");var a=document.createEvent(r);switch(r){case"MouseEvents": +var u=o.x||o.clientX||0,h=o.y||o.clientY||0;a.initMouseEvent(i,o.bubbles||!1,o.cancelable||!0,window,o.clickCount||1,0,0,u,h,!1,!1,!1,!1,0,null);break;case"KeyboardEvents":var l=a.initKeyboardEvent||a.initKeyEvent;t.defaults(o,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0}),l(i,o.bubbles||!1,o.cancelable,window,o.ctrlKey,o.altKey,o.shiftKey,o.metaKey,o.keyCode,o.charCode);break;default:a.initEvent(i,o.bubbles||!1,o.cancelable||!0)}t.defaults(a,s),e.dispatchEvent(a)},bind:function(t,e,i,n){return n=n||!1,t.addEventListener?t.addEventListener(e,i,n):t.attachEvent&&t.attachEvent("on"+e,i),s},unbind:function(t,e,i,n){return n=n||!1,t.removeEventListener?t.removeEventListener(e,i,n):t.detachEvent&&t.detachEvent("on"+e,i),s},addClass:function(t,e){if(void 0===t.className)t.className=e;else if(t.className!==e){var i=t.className.split(/ +/);-1==i.indexOf(e)&&(i.push(e),t.className=i.join(" ").replace(/^\s+/,"").replace(/\s+$/,""))}return s},removeClass:function(t,e){if(e)if(void 0===t.className);else if(t.className===e)t.removeAttribute("class");else{var i=t.className.split(/ +/),n=i.indexOf(e);-1!=n&&(i.splice(n,1),t.className=i.join(" "))}else t.className=void 0;return s},hasClass:function(t,e){return new RegExp("(?:^|\\s+)"+e+"(?:\\s+|$)").test(t.className)||!1},getWidth:function(t){var i=getComputedStyle(t);return e(i["border-left-width"])+e(i["border-right-width"])+e(i["padding-left"])+e(i["padding-right"])+e(i.width)},getHeight:function(t){var i=getComputedStyle(t);return e(i["border-top-width"])+e(i["border-bottom-width"])+e(i["padding-top"])+e(i["padding-bottom"])+e(i.height)},getOffset:function(t){var e={left:0,top:0};if(t.offsetParent)do e.left+=t.offsetLeft,e.top+=t.offsetTop;while(t=t.offsetParent);return e},isActive:function(t){return t===document.activeElement&&(t.type||t.href)}};return s}(n.utils.common),n.controllers.OptionController=function(t,e,i){var n=function(t,o,s){n.superclass.call(this,t,o);var r=this;if(this.__select=document.createElement("select"),i.isArray(s)){var a={};i.each(s,function(t){a[t]=t}),s=a}i.each(s,function(t,e){var i=document.createElement("option");i.innerHTML=e,i.setAttribute("value",t),r.__select.appendChild(i)}),this.updateDisplay(),e.bind(this.__select,"change",function(){var t=this.options[this.selectedIndex].value;r.setValue(t)}),this.domElement.appendChild(this.__select)};return n.superclass=t,i.extend(n.prototype,t.prototype,{setValue:function(t){var e=n.superclass.prototype.setValue.call(this,t);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),e},updateDisplay:function(){return this.__select.value=this.getValue(),n.superclass.prototype.updateDisplay.call(this)}}),n}(n.controllers.Controller,n.dom.dom,n.utils.common),n.controllers.NumberController=function(t,e){function i(t){return t=t.toString(),t.indexOf(".")>-1?t.length-t.indexOf(".")-1:0}var n=function(t,o,s){n.superclass.call(this,t,o),s=s||{},this.__min=s.min,this.__max=s.max,this.__step=s.step,this.__impliedStep=e.isUndefined(this.__step)?0==this.initialValue?1:Math.pow(10,Math.floor(Math.log(this.initialValue)/Math.LN10))/10:this.__step,this.__precision=i(this.__impliedStep)};return n.superclass=t,e.extend(n.prototype,t.prototype,{setValue:function(t){return void 0!==this.__min&&tthis.__max&&(t=this.__max),void 0!==this.__step&&t%this.__step!=0&&(t=Math.round(t/this.__step)*this.__step),n.superclass.prototype.setValue.call(this,t)},min:function(t){return this.__min=t,this},max:function(t){return this.__max=t,this},step:function(t){return this.__step=t,this}}),n}(n.controllers.Controller,n.utils.common),n.controllers.NumberControllerBox=function(t,e,i){function n(t,e){var i=Math.pow(10,e);return Math.round(t*i)/i}var o=function(t,n,s){function r(){var t=parseFloat(d.__input.value);i.isNaN(t)||d.setValue(t)}function a(){r(),d.__onFinishChange&&d.__onFinishChange.call(d,d.getValue())}function u(t){e.bind(window,"mousemove",h),e.bind(window,"mouseup",l),c=t.clientY}function h(t){var e=c-t.clientY;d.setValue(d.getValue()+e*d.__impliedStep),c=t.clientY}function l(){e.unbind(window,"mousemove",h),e.unbind(window,"mouseup",l)}this.__truncationSuspended=!1,o.superclass.call(this,t,n,s);var c,d=this;this.__input=document.createElement("input"),this.__input.setAttribute("type","text"),e.bind(this.__input,"change",r),e.bind(this.__input,"blur",a),e.bind(this.__input,"mousedown",u),e.bind(this.__input,"keydown",function(t){13===t.keyCode&&(d.__truncationSuspended=!0,this.blur(),d.__truncationSuspended=!1)}),this.updateDisplay(),this.domElement.appendChild(this.__input)};return o.superclass=t,i.extend(o.prototype,t.prototype,{updateDisplay:function(){return this.__input.value=this.__truncationSuspended?this.getValue():n(this.getValue(),this.__precision),o.superclass.prototype.updateDisplay.call(this)}}),o}(n.controllers.NumberController,n.dom.dom,n.utils.common),n.controllers.NumberControllerSlider=function(t,e,i,n,o){function s(t,e,i,n,o){return n+(o-n)*((t-e)/(i-e))}var r=function(t,i,n,o,a){function u(t){e.bind(window,"mousemove",h),e.bind(window,"mouseup",l),h(t)}function h(t){t.preventDefault();var i=e.getOffset(c.__background),n=e.getWidth(c.__background);return c.setValue(s(t.clientX,i.left,i.left+n,c.__min,c.__max)),!1}function l(){e.unbind(window,"mousemove",h),e.unbind(window,"mouseup",l),c.__onFinishChange&&c.__onFinishChange.call(c,c.getValue())}r.superclass.call(this,t,i,{min:n,max:o,step:a});var c=this;this.__background=document.createElement("div"),this.__foreground=document.createElement("div"),e.bind(this.__background,"mousedown",u),e.addClass(this.__background,"slider"),e.addClass(this.__foreground,"slider-fg"),this.updateDisplay(),this.__background.appendChild(this.__foreground),this.domElement.appendChild(this.__background)};return r.superclass=t,r.useDefaultStyles=function(){i.inject(o)},n.extend(r.prototype,t.prototype,{updateDisplay:function(){var t=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*t+"%",r.superclass.prototype.updateDisplay.call(this)}}),r}(n.controllers.NumberController,n.dom.dom,n.utils.css,n.utils.common,".slider {\n box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);\n height: 1em;\n border-radius: 1em;\n background-color: #eee;\n padding: 0 0.5em;\n overflow: hidden;\n}\n\n.slider-fg {\n padding: 1px 0 2px 0;\n background-color: #aaa;\n height: 1em;\n margin-left: -0.5em;\n padding-right: 0.5em;\n border-radius: 1em 0 0 1em;\n}\n\n.slider-fg:after {\n display: inline-block;\n border-radius: 1em;\n background-color: #fff;\n border: 1px solid #aaa;\n content: '';\n float: right;\n margin-right: -1em;\n margin-top: -1px;\n height: 0.9em;\n width: 0.9em;\n}"),n.controllers.FunctionController=function(t,e,i){var n=function(t,i,o){n.superclass.call(this,t,i);var s=this;this.__button=document.createElement("div"),this.__button.innerHTML=void 0===o?"Fire":o,e.bind(this.__button,"click",function(t){return t.preventDefault(),s.fire(),!1}),e.addClass(this.__button,"button"),this.domElement.appendChild(this.__button)};return n.superclass=t,i.extend(n.prototype,t.prototype,{fire:function(){this.__onChange&&this.__onChange.call(this),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.getValue().call(this.object)}}),n}(n.controllers.Controller,n.dom.dom,n.utils.common),n.controllers.BooleanController=function(t,e,i){var n=function(t,i){function o(){s.setValue(!s.__prev)}n.superclass.call(this,t,i);var s=this;this.__prev=this.getValue(),this.__checkbox=document.createElement("input"),this.__checkbox.setAttribute("type","checkbox"),e.bind(this.__checkbox,"change",o,!1),this.domElement.appendChild(this.__checkbox),this.updateDisplay()};return n.superclass=t,i.extend(n.prototype,t.prototype,{setValue:function(t){var e=n.superclass.prototype.setValue.call(this,t);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.__prev=this.getValue(),e},updateDisplay:function(){return this.getValue()===!0?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0):this.__checkbox.checked=!1,n.superclass.prototype.updateDisplay.call(this)}}),n}(n.controllers.Controller,n.dom.dom,n.utils.common),n.color.toString=function(t){return function(e){if(1==e.a||t.isUndefined(e.a)){for(var i=e.hex.toString(16);i.length<6;)i="0"+i;return"#"+i}return"rgba("+Math.round(e.r)+","+Math.round(e.g)+","+Math.round(e.b)+","+e.a+")"}}(n.utils.common),n.color.interpret=function(t,e){var i,n,o=function(){n=!1;var t=arguments.length>1?e.toArray(arguments):arguments[0];return e.each(s,function(o){return o.litmus(t)?(e.each(o.conversions,function(o,s){return i=o.read(t),n===!1&&i!==!1?(n=i,i.conversionName=s,i.conversion=o,e.BREAK):void 0}),e.BREAK):void 0}),n},s=[{litmus:e.isString,conversions:{THREE_CHAR_HEX:{read:function(t){var e=t.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null===e?!1:{space:"HEX",hex:parseInt("0x"+e[1].toString()+e[1].toString()+e[2].toString()+e[2].toString()+e[3].toString()+e[3].toString())}},write:t},SIX_CHAR_HEX:{read:function(t){var e=t.match(/^#([A-F0-9]{6})$/i);return null===e?!1:{space:"HEX",hex:parseInt("0x"+e[1].toString())}},write:t},CSS_RGB:{read:function(t){var e=t.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null===e?!1:{space:"RGB",r:parseFloat(e[1]),g:parseFloat(e[2]),b:parseFloat(e[3])}},write:t},CSS_RGBA:{read:function(t){var e=t.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\,\s*(.+)\s*\)/);return null===e?!1:{space:"RGB",r:parseFloat(e[1]),g:parseFloat(e[2]),b:parseFloat(e[3]),a:parseFloat(e[4])}},write:t}}},{litmus:e.isNumber,conversions:{HEX:{read:function(t){return{space:"HEX",hex:t,conversionName:"HEX"}},write:function(t){return t.hex}}}},{litmus:e.isArray,conversions:{RGB_ARRAY:{read:function(t){return 3!=t.length?!1:{space:"RGB",r:t[0],g:t[1],b:t[2]}},write:function(t){return[t.r,t.g,t.b]}},RGBA_ARRAY:{read:function(t){return 4!=t.length?!1:{space:"RGB",r:t[0],g:t[1],b:t[2],a:t[3]}},write:function(t){return[t.r,t.g,t.b,t.a]}}}},{litmus:e.isObject,conversions:{RGBA_OBJ:{read:function(t){return e.isNumber(t.r)&&e.isNumber(t.g)&&e.isNumber(t.b)&&e.isNumber(t.a)?{space:"RGB",r:t.r,g:t.g,b:t.b,a:t.a}:!1},write:function(t){return{r:t.r,g:t.g,b:t.b,a:t.a}}},RGB_OBJ:{read:function(t){return e.isNumber(t.r)&&e.isNumber(t.g)&&e.isNumber(t.b)?{space:"RGB",r:t.r,g:t.g,b:t.b}:!1},write:function(t){return{r:t.r,g:t.g,b:t.b}}},HSVA_OBJ:{read:function(t){return e.isNumber(t.h)&&e.isNumber(t.s)&&e.isNumber(t.v)&&e.isNumber(t.a)?{space:"HSV",h:t.h,s:t.s,v:t.v,a:t.a}:!1},write:function(t){return{h:t.h,s:t.s,v:t.v,a:t.a}}},HSV_OBJ:{read:function(t){return e.isNumber(t.h)&&e.isNumber(t.s)&&e.isNumber(t.v)?{space:"HSV",h:t.h,s:t.s,v:t.v}:!1},write:function(t){return{h:t.h,s:t.s,v:t.v}}}}}];return o}(n.color.toString,n.utils.common),n.GUI=n.gui.GUI=function(t,e,i,n,o,s,r,a,u,h,l,c,d,p,_){function f(t,e,i,s){if(void 0===e[i])throw new Error("Object "+e+' has no property "'+i+'"');var r;if(s.color)r=new l(e,i);else{var a=[e,i].concat(s.factoryArgs);r=n.apply(t,a)}s.before instanceof o&&(s.before=s.before.__li),y(t,r),p.addClass(r.domElement,"c");var u=document.createElement("span");p.addClass(u,"property-name"),u.innerHTML=r.property;var h=document.createElement("div");h.appendChild(u),h.appendChild(r.domElement);var c=m(t,h,s.before);return p.addClass(c,j.CLASS_CONTROLLER_ROW),p.addClass(c,typeof r.getValue()),g(t,c,r),t.__controllers.push(r),r}function m(t,e,i){var n=document.createElement("li");return e&&n.appendChild(e),i?t.__ul.insertBefore(n,params.before):t.__ul.appendChild(n),t.onResize(),n}function g(t,e,i){if(i.__li=e,i.__gui=t,_.extend(i,{options:function(e){return arguments.length>1?(i.remove(),f(t,i.object,i.property,{before:i.__li.nextElementSibling,factoryArgs:[_.toArray(arguments)]})):_.isArray(e)||_.isObject(e)?(i.remove(),f(t,i.object,i.property,{before:i.__li.nextElementSibling,factoryArgs:[e]})):void 0},name:function(t){return i.__li.firstElementChild.firstElementChild.innerHTML=t,i},listen:function(){return i.__gui.listen(i),i},remove:function(){return i.__gui.remove(i),i}}),i instanceof u){var n=new a(i.object,i.property,{min:i.__min,max:i.__max,step:i.__step});_.each(["updateDisplay","onChange","onFinishChange"],function(t){var e=i[t],o=n[t];i[t]=n[t]=function(){var t=Array.prototype.slice.call(arguments);return e.apply(i,t),o.apply(n,t)}}),p.addClass(e,"has-slider"),i.domElement.insertBefore(n.domElement,i.domElement.firstElementChild)}else if(i instanceof a){var o=function(e){return _.isNumber(i.__min)&&_.isNumber(i.__max)?(i.remove(),f(t,i.object,i.property,{before:i.__li.nextElementSibling,factoryArgs:[i.__min,i.__max,i.__step]})):e};i.min=_.compose(o,i.min),i.max=_.compose(o,i.max)}else i instanceof s?(p.bind(e,"click",function(){p.fakeEvent(i.__checkbox,"click")}),p.bind(i.__checkbox,"click",function(t){t.stopPropagation()})):i instanceof r?(p.bind(e,"click",function(){p.fakeEvent(i.__button,"click")}),p.bind(e,"mouseover",function(){p.addClass(i.__button,"hover")}),p.bind(e,"mouseout",function(){p.removeClass(i.__button,"hover")})):i instanceof l&&(p.addClass(e,"color"),i.updateDisplay=_.compose(function(t){return e.style.borderLeftColor=i.__color.toString(),t},i.updateDisplay),i.updateDisplay());i.setValue=_.compose(function(e){return t.getRoot().__preset_select&&i.isModified()&&z(t.getRoot(),!0),e},i.setValue)}function y(t,e){var i=t.getRoot(),n=i.__rememberedObjects.indexOf(e.object);if(-1!=n){var o=i.__rememberedObjectIndecesToControllers[n];if(void 0===o&&(o={},i.__rememberedObjectIndecesToControllers[n]=o),o[e.property]=e,i.load&&i.load.remembered){var s,r=i.load.remembered;if(r[t.preset])s=r[t.preset];else{if(!r[P])return;s=r[P]}if(s[n]&&void 0!==s[n][e.property]){var a=s[n][e.property];e.initialValue=a,e.setValue(a)}}}}function v(t,e){return document.location.href+"."+e}function b(t){function e(){h.style.display=t.useLocalStorage?"block":"none"}var i=t.__save_row=document.createElement("li");p.addClass(t.domElement,"has-save"),t.__ul.insertBefore(i,t.__ul.firstChild),p.addClass(i,"save-row");var n=document.createElement("span");n.innerHTML=" ",p.addClass(n,"button gears");var o=document.createElement("span");o.innerHTML="Save",p.addClass(o,"button"),p.addClass(o,"save");var s=document.createElement("span");s.innerHTML="New",p.addClass(s,"button"),p.addClass(s,"save-as");var r=document.createElement("span");r.innerHTML="Revert",p.addClass(r,"button"),p.addClass(r,"revert");var a=t.__preset_select=document.createElement("select");if(t.load&&t.load.remembered?_.each(t.load.remembered,function(e,i){k(t,i,i==t.preset)}):k(t,P,!1),p.bind(a,"change",function(){for(var e=0;e0&&(t.preset=this.preset,t.remembered||(t.remembered={}),t.remembered[this.preset]=E(this)),t.folders={},_.each(this.__folders,function(e,i){t.folders[i]=e.getSaveObject()}),t},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=E(this),z(this,!1)},saveAs:function(t){this.load.remembered||(this.load.remembered={},this.load.remembered[P]=E(this,!0)),this.load.remembered[t]=E(this),this.preset=t,k(this,t,!0)},revert:function(t){_.each(this.__controllers,function(e){this.getRoot().load.remembered?y(t||this.getRoot(),e):e.setValue(e.initialValue)},this),_.each(this.__folders,function(t){t.revert(t)}),t||z(this.getRoot(),!1)},listen:function(t){var e=0==this.__listening.length;this.__listening.push(t),e&&R(this.__listening)}}),j}(n.utils.css,'
\n\n Here\'s the new load parameter for your GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n \n
\n \n
\n\n
',".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity 0.1s linear;-o-transition:opacity 0.1s linear;-moz-transition:opacity 0.1s linear;transition:opacity 0.1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity 0.1s linear;-o-transition:opacity 0.1s linear;-moz-transition:opacity 0.1s linear;transition:opacity 0.1s linear;border:0;position:absolute;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-x:hidden}.dg.a.has-save ul{margin-top:27px}.dg.a.has-save ul.closed{margin-top:0}.dg.a .save-row{position:fixed;top:0;z-index:1002}.dg li{-webkit-transition:height 0.1s ease-out;-o-transition:height 0.1s ease-out;-moz-transition:height 0.1s ease-out;transition:height 0.1s ease-out}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;overflow:hidden;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li > *{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:9px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2fa1d6}.dg .cr.number input[type=text]{color:#2fa1d6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2fa1d6}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n",n.controllers.factory=function(t,e,i,n,o,s,r){return function(a,u){var h=a[u];return r.isArray(arguments[2])||r.isObject(arguments[2])?new t(a,u,arguments[2]):r.isNumber(h)?r.isNumber(arguments[2])&&r.isNumber(arguments[3])?new i(a,u,arguments[2],arguments[3]):new e(a,u,{min:arguments[2],max:arguments[3]}):r.isString(h)?new n(a,u):r.isFunction(h)?new o(a,u,""):r.isBoolean(h)?new s(a,u):void 0}}(n.controllers.OptionController,n.controllers.NumberControllerBox,n.controllers.NumberControllerSlider,n.controllers.StringController=function(t,e,i){var n=function(t,i){function o(){r.setValue(r.__input.value)}function s(){r.__onFinishChange&&r.__onFinishChange.call(r,r.getValue())}n.superclass.call(this,t,i);var r=this;this.__input=document.createElement("input"),this.__input.setAttribute("type","text"),e.bind(this.__input,"keyup",o),e.bind(this.__input,"change",o),e.bind(this.__input,"blur",s),e.bind(this.__input,"keydown",function(t){13===t.keyCode&&this.blur()}),this.updateDisplay(),this.domElement.appendChild(this.__input)};return n.superclass=t,i.extend(n.prototype,t.prototype,{updateDisplay:function(){return e.isActive(this.__input)||(this.__input.value=this.getValue()),n.superclass.prototype.updateDisplay.call(this)}}),n}(n.controllers.Controller,n.dom.dom,n.utils.common),n.controllers.FunctionController,n.controllers.BooleanController,n.utils.common),n.controllers.Controller,n.controllers.BooleanController,n.controllers.FunctionController,n.controllers.NumberControllerBox,n.controllers.NumberControllerSlider,n.controllers.OptionController,n.controllers.ColorController=function(t,e,i,n,o){function s(t,e,i,n){t.style.background="",o.each(u,function(o){t.style.cssText+="background: "+o+"linear-gradient("+e+", "+i+" 0%, "+n+" 100%); "})}function r(t){t.style.background="",t.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",t.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",t.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);", +t.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",t.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"}var a=function(t,u){function h(t){p(t),e.bind(window,"mousemove",p),e.bind(window,"mouseup",l)}function l(){e.unbind(window,"mousemove",p),e.unbind(window,"mouseup",l)}function c(){var t=n(this.value);t!==!1?(f.__color.__state=t,f.setValue(f.__color.toOriginal())):this.value=f.__color.toString()}function d(){e.unbind(window,"mousemove",_),e.unbind(window,"mouseup",d)}function p(t){t.preventDefault();var i=e.getWidth(f.__saturation_field),n=e.getOffset(f.__saturation_field),o=(t.clientX-n.left+document.body.scrollLeft)/i,s=1-(t.clientY-n.top+document.body.scrollTop)/i;return s>1?s=1:0>s&&(s=0),o>1?o=1:0>o&&(o=0),f.__color.v=s,f.__color.s=o,f.setValue(f.__color.toOriginal()),!1}function _(t){t.preventDefault();var i=e.getHeight(f.__hue_field),n=e.getOffset(f.__hue_field),o=1-(t.clientY-n.top+document.body.scrollTop)/i;return o>1?o=1:0>o&&(o=0),f.__color.h=360*o,f.setValue(f.__color.toOriginal()),!1}a.superclass.call(this,t,u),this.__color=new i(this.getValue()),this.__temp=new i(0);var f=this;this.domElement=document.createElement("div"),e.makeSelectable(this.domElement,!1),this.__selector=document.createElement("div"),this.__selector.className="selector",this.__saturation_field=document.createElement("div"),this.__saturation_field.className="saturation-field",this.__field_knob=document.createElement("div"),this.__field_knob.className="field-knob",this.__field_knob_border="2px solid ",this.__hue_knob=document.createElement("div"),this.__hue_knob.className="hue-knob",this.__hue_field=document.createElement("div"),this.__hue_field.className="hue-field",this.__input=document.createElement("input"),this.__input.type="text",this.__input_textShadow="0 1px 1px ",e.bind(this.__input,"keydown",function(t){13===t.keyCode&&c.call(this)}),e.bind(this.__input,"blur",c),e.bind(this.__selector,"mousedown",function(t){e.addClass(this,"drag").bind(window,"mouseup",function(t){e.removeClass(f.__selector,"drag")})});var m=document.createElement("div");o.extend(this.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),o.extend(this.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:this.__field_knob_border+(this.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),o.extend(this.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),o.extend(this.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),o.extend(m.style,{width:"100%",height:"100%",background:"none"}),s(m,"top","rgba(0,0,0,0)","#000"),o.extend(this.__hue_field.style,{width:"15px",height:"100px",display:"inline-block",border:"1px solid #555",cursor:"ns-resize"}),r(this.__hue_field),o.extend(this.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:this.__input_textShadow+"rgba(0,0,0,0.7)"}),e.bind(this.__saturation_field,"mousedown",h),e.bind(this.__field_knob,"mousedown",h),e.bind(this.__hue_field,"mousedown",function(t){_(t),e.bind(window,"mousemove",_),e.bind(window,"mouseup",d)}),this.__saturation_field.appendChild(m),this.__selector.appendChild(this.__field_knob),this.__selector.appendChild(this.__saturation_field),this.__selector.appendChild(this.__hue_field),this.__hue_field.appendChild(this.__hue_knob),this.domElement.appendChild(this.__input),this.domElement.appendChild(this.__selector),this.updateDisplay()};a.superclass=t,o.extend(a.prototype,t.prototype,{updateDisplay:function(){var t=n(this.getValue());if(t!==!1){var e=!1;o.each(i.COMPONENTS,function(i){return o.isUndefined(t[i])||o.isUndefined(this.__color.__state[i])||t[i]===this.__color.__state[i]?void 0:(e=!0,{})},this),e&&o.extend(this.__color.__state,t)}o.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var r=this.__color.v<.5||this.__color.s>.5?255:0,a=255-r;o.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toString(),border:this.__field_knob_border+"rgb("+r+","+r+","+r+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,s(this.__saturation_field,"left","#fff",this.__temp.toString()),o.extend(this.__input.style,{backgroundColor:this.__input.value=this.__color.toString(),color:"rgb("+r+","+r+","+r+")",textShadow:this.__input_textShadow+"rgba("+a+","+a+","+a+",.7)"})}});var u=["-moz-","-o-","-webkit-","-ms-",""];return a}(n.controllers.Controller,n.dom.dom,n.color.Color=function(t,e,i,n){function o(t,e,i){Object.defineProperty(t,e,{get:function(){return"RGB"===this.__state.space?this.__state[e]:(r(this,e,i),this.__state[e])},set:function(t){"RGB"!==this.__state.space&&(r(this,e,i),this.__state.space="RGB"),this.__state[e]=t}})}function s(t,e){Object.defineProperty(t,e,{get:function(){return"HSV"===this.__state.space?this.__state[e]:(a(this),this.__state[e])},set:function(t){"HSV"!==this.__state.space&&(a(this),this.__state.space="HSV"),this.__state[e]=t}})}function r(t,i,o){if("HEX"===t.__state.space)t.__state[i]=e.component_from_hex(t.__state.hex,o);else{if("HSV"!==t.__state.space)throw"Corrupted color state";n.extend(t.__state,e.hsv_to_rgb(t.__state.h,t.__state.s,t.__state.v))}}function a(t){var i=e.rgb_to_hsv(t.r,t.g,t.b);n.extend(t.__state,{s:i.s,v:i.v}),n.isNaN(i.h)?n.isUndefined(t.__state.h)&&(t.__state.h=0):t.__state.h=i.h}var u=function(){if(this.__state=t.apply(this,arguments),this.__state===!1)throw"Failed to interpret color arguments";this.__state.a=this.__state.a||1};return u.COMPONENTS=["r","g","b","h","s","v","hex","a"],n.extend(u.prototype,{toString:function(){return i(this)},toOriginal:function(){return this.__state.conversion.write(this)}}),o(u.prototype,"r",2),o(u.prototype,"g",1),o(u.prototype,"b",0),s(u.prototype,"h"),s(u.prototype,"s"),s(u.prototype,"v"),Object.defineProperty(u.prototype,"a",{get:function(){return this.__state.a},set:function(t){this.__state.a=t}}),Object.defineProperty(u.prototype,"hex",{get:function(){return"HEX"!==!this.__state.space&&(this.__state.hex=e.rgb_to_hex(this.r,this.g,this.b)),this.__state.hex},set:function(t){this.__state.space="HEX",this.__state.hex=t}}),u}(n.color.interpret,n.color.math=function(){var t;return{hsv_to_rgb:function(t,e,i){var n=Math.floor(t/60)%6,o=t/60-Math.floor(t/60),s=i*(1-e),r=i*(1-o*e),a=i*(1-(1-o)*e),u=[[i,a,s],[r,i,s],[s,i,a],[s,r,i],[a,s,i],[i,s,r]][n];return{r:255*u[0],g:255*u[1],b:255*u[2]}},rgb_to_hsv:function(t,e,i){var n,o,s=Math.min(t,e,i),r=Math.max(t,e,i),a=r-s;return 0==r?{h:0/0,s:0,v:0}:(o=a/r,n=t==r?(e-i)/a:e==r?2+(i-t)/a:4+(t-e)/a,n/=6,0>n&&(n+=1),{h:360*n,s:o,v:r/255})},rgb_to_hex:function(t,e,i){var n=this.hex_with_component(0,2,t);return n=this.hex_with_component(n,1,e),n=this.hex_with_component(n,0,i)},component_from_hex:function(t,e){return t>>8*e&255},hex_with_component:function(e,i,n){return n<<(t=8*i)|e&~(255<=0;n--)i=[t[n].apply(this,i)];return i[0]}},each:function(e,i,n){if(t&&e.forEach===t)e.forEach(i,n);else if(e.length===e.length+0){for(var o=0,s=e.length;s>o;o++)if(o in e&&i.call(n,e[o],o)===this.BREAK)return}else for(var o in e)if(i.call(n,e[o],o)===this.BREAK)return},defer:function(t){setTimeout(t,0)},toArray:function(t){return t.toArray?t.toArray():e.call(t)},isUndefined:function(t){return void 0===t},isNull:function(t){return null===t},isNaN:function(t){return t!==t},isArray:Array.isArray||function(t){return t.constructor===Array},isObject:function(t){return t===Object(t)},isNumber:function(t){return t===t+0},isString:function(t){return t===t+""},isBoolean:function(t){return t===!1||t===!0},isFunction:function(t){return"[object Function]"===Object.prototype.toString.call(t)}}}(),n.color.toString=function(t){return function(e){if(1==e.a||t.isUndefined(e.a)){for(var i=e.hex.toString(16);i.length<6;)i="0"+i;return"#"+i}return"rgba("+Math.round(e.r)+","+Math.round(e.g)+","+Math.round(e.b)+","+e.a+")"}}(n.utils.common),n.Color=n.color.Color=function(t,e,i,n){function o(t,e,i){Object.defineProperty(t,e,{get:function(){return"RGB"===this.__state.space?this.__state[e]:(r(this,e,i),this.__state[e])},set:function(t){"RGB"!==this.__state.space&&(r(this,e,i),this.__state.space="RGB"),this.__state[e]=t}})}function s(t,e){Object.defineProperty(t,e,{get:function(){return"HSV"===this.__state.space?this.__state[e]:(a(this),this.__state[e])},set:function(t){"HSV"!==this.__state.space&&(a(this),this.__state.space="HSV"),this.__state[e]=t}})}function r(t,i,o){if("HEX"===t.__state.space)t.__state[i]=e.component_from_hex(t.__state.hex,o);else{if("HSV"!==t.__state.space)throw"Corrupted color state";n.extend(t.__state,e.hsv_to_rgb(t.__state.h,t.__state.s,t.__state.v))}}function a(t){var i=e.rgb_to_hsv(t.r,t.g,t.b);n.extend(t.__state,{s:i.s,v:i.v}),n.isNaN(i.h)?n.isUndefined(t.__state.h)&&(t.__state.h=0):t.__state.h=i.h}var u=function(){if(this.__state=t.apply(this,arguments),this.__state===!1)throw"Failed to interpret color arguments";this.__state.a=this.__state.a||1};return u.COMPONENTS=["r","g","b","h","s","v","hex","a"],n.extend(u.prototype,{toString:function(){return i(this)},toOriginal:function(){return this.__state.conversion.write(this)}}),o(u.prototype,"r",2),o(u.prototype,"g",1),o(u.prototype,"b",0),s(u.prototype,"h"),s(u.prototype,"s"),s(u.prototype,"v"),Object.defineProperty(u.prototype,"a",{get:function(){return this.__state.a},set:function(t){this.__state.a=t}}),Object.defineProperty(u.prototype,"hex",{get:function(){return"HEX"!==!this.__state.space&&(this.__state.hex=e.rgb_to_hex(this.r,this.g,this.b)),this.__state.hex},set:function(t){this.__state.space="HEX",this.__state.hex=t}}),u}(n.color.interpret=function(t,e){var i,n,o=function(){n=!1;var t=arguments.length>1?e.toArray(arguments):arguments[0];return e.each(s,function(o){return o.litmus(t)?(e.each(o.conversions,function(o,s){return i=o.read(t),n===!1&&i!==!1?(n=i,i.conversionName=s,i.conversion=o,e.BREAK):void 0}),e.BREAK):void 0}),n},s=[{litmus:e.isString,conversions:{THREE_CHAR_HEX:{read:function(t){var e=t.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null===e?!1:{space:"HEX",hex:parseInt("0x"+e[1].toString()+e[1].toString()+e[2].toString()+e[2].toString()+e[3].toString()+e[3].toString())}},write:t},SIX_CHAR_HEX:{read:function(t){var e=t.match(/^#([A-F0-9]{6})$/i);return null===e?!1:{space:"HEX",hex:parseInt("0x"+e[1].toString())}},write:t},CSS_RGB:{read:function(t){var e=t.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null===e?!1:{space:"RGB",r:parseFloat(e[1]),g:parseFloat(e[2]),b:parseFloat(e[3])}},write:t},CSS_RGBA:{read:function(t){var e=t.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\,\s*(.+)\s*\)/);return null===e?!1:{space:"RGB",r:parseFloat(e[1]),g:parseFloat(e[2]),b:parseFloat(e[3]),a:parseFloat(e[4])}},write:t}}},{litmus:e.isNumber,conversions:{HEX:{read:function(t){return{space:"HEX",hex:t,conversionName:"HEX"}},write:function(t){return t.hex}}}},{litmus:e.isArray,conversions:{RGB_ARRAY:{read:function(t){return 3!=t.length?!1:{space:"RGB",r:t[0],g:t[1],b:t[2]}},write:function(t){return[t.r,t.g,t.b]}},RGBA_ARRAY:{read:function(t){return 4!=t.length?!1:{space:"RGB",r:t[0],g:t[1],b:t[2],a:t[3]}},write:function(t){return[t.r,t.g,t.b,t.a]}}}},{litmus:e.isObject,conversions:{RGBA_OBJ:{read:function(t){return e.isNumber(t.r)&&e.isNumber(t.g)&&e.isNumber(t.b)&&e.isNumber(t.a)?{space:"RGB",r:t.r,g:t.g,b:t.b,a:t.a}:!1},write:function(t){return{r:t.r,g:t.g,b:t.b,a:t.a}}},RGB_OBJ:{read:function(t){return e.isNumber(t.r)&&e.isNumber(t.g)&&e.isNumber(t.b)?{space:"RGB",r:t.r,g:t.g,b:t.b}:!1},write:function(t){return{r:t.r,g:t.g,b:t.b}}},HSVA_OBJ:{read:function(t){return e.isNumber(t.h)&&e.isNumber(t.s)&&e.isNumber(t.v)&&e.isNumber(t.a)?{space:"HSV",h:t.h,s:t.s,v:t.v,a:t.a}:!1},write:function(t){return{h:t.h,s:t.s,v:t.v,a:t.a}}},HSV_OBJ:{read:function(t){return e.isNumber(t.h)&&e.isNumber(t.s)&&e.isNumber(t.v)?{space:"HSV",h:t.h,s:t.s,v:t.v}:!1},write:function(t){return{h:t.h,s:t.s,v:t.v}}}}}];return o}(n.color.toString,n.utils.common),n.color.math=function(){var t;return{hsv_to_rgb:function(t,e,i){var n=Math.floor(t/60)%6,o=t/60-Math.floor(t/60),s=i*(1-e),r=i*(1-o*e),a=i*(1-(1-o)*e),u=[[i,a,s],[r,i,s],[s,i,a],[s,r,i],[a,s,i],[i,s,r]][n];return{r:255*u[0],g:255*u[1],b:255*u[2]}},rgb_to_hsv:function(t,e,i){var n,o,s=Math.min(t,e,i),r=Math.max(t,e,i),a=r-s;return 0==r?{h:0/0,s:0,v:0}:(o=a/r,n=t==r?(e-i)/a:e==r?2+(i-t)/a:4+(t-e)/a,n/=6,0>n&&(n+=1),{h:360*n,s:o,v:r/255})},rgb_to_hex:function(t,e,i){var n=this.hex_with_component(0,2,t);return n=this.hex_with_component(n,1,e),n=this.hex_with_component(n,0,i)},component_from_hex:function(t,e){return t>>8*e&255},hex_with_component:function(e,i,n){return n<<(t=8*i)|e&~(255<e;e++)if(e in this&&this[e]===t)return e;return-1};o=i(18),t.exports=function(){function t(){this.exclude=[]}return t.prototype.exclude=Array,t.prototype.animate=function(t,e){var i,o,r,a,u,h;for(h=[],i=a=0,u=t.length;u>a;i=++a)o=t[i],r=new n($(o),e),h.push(s.call(this.exclude,i)>=0?r.once=!0:void 0);return h},t}(),n=function(){function t(t,e){this.el=t,this.base_delay=e,this.increment=1/this.passes,this.animate()}return t.prototype.passes=5,t.prototype.opacity=0,t.prototype.progress=0,t.prototype.once=!1,t.prototype.animate=function(){var t,e,i,n;return this.progress++,this.progress<=this.passes?(this.opacity+=this.increment,e=1===this.progress?this.base_delay+2400*Math.random():2400*Math.random(),this.el.delay(e).animate({opacity:this.opacity},500,function(t){return function(){return t.animate()}}(this))):this.once?void 0:(t=function(){n=[];for(var t=0,e=this.passes;e>=0?e>t:t>e;e>=0?t++:t--)n.push(t);return n}.apply(this),i=t[Math.ceil(o.random(2,t.length))-1],this.opacity=i*this.increment,this.progress=i,this.el.delay(e).animate({opacity:this.opacity},500,function(t){return function(){return t.animate()}}(this)))},t}()},function(t,e,i){var n,o;o=i(18),t.exports=n=function(){function t(){}return t.prototype.create=function(t){var e,i,n,s,r,a,u,h;for(s={text:"x",size:80,height:10,curve_segments:2,font:"montserrat",color:16777215},o.merge(s,t),e=new THREE.TextGeometry(s.text,{size:s.size,height:s.height,curveSegments:s.curve_segments,font:s.font}),e.computeBoundingBox(),h=e.vertices,a=0,u=h.length;u>a;a++)r=h[a],r.x+=-.5*(e.boundingBox.max.x-e.boundingBox.min.x);return i=new THREE.MeshBasicMaterial({color:s.color,transparent:!0}),n=new THREE.Mesh(e,i)},t.prototype.create_multichar=function(t){var e,i,n,s,r,a,u,h,l,c,d,p,_,f;for(l={text:"x",size:80,height:10,line_height:160,curve_segments:2,font:"montserrat",color:16777215},o.merge(l,t),s=l.text.length,u=[],h=s*l.size/2-l.size/2,n=d=0;s>=0?s>d:d>s;n=s>=0?++d:--d){for(e=l.text.charAt(n),i=new THREE.TextGeometry(e,{size:l.size,height:l.height,curveSegments:l.curve_segments,font:l.font}),i.computeBoundingBox(),f=i.vertices,p=0,_=f.length;_>p;p++)c=f[p],c.x+=-.5*(i.boundingBox.max.x-i.boundingBox.min.x),c.y+=-.5*(i.boundingBox.max.y-i.boundingBox.min.y);r=new THREE.MeshBasicMaterial({color:l.color,transparent:!0,depthTest:!1}),a=new THREE.Mesh(i,r),a.position.x=n*l.size-h,u.push(a)}return u},t.prototype.create_multiline=function(t){var e,i,n,s,r,a,u,h,l,c,d,p,_,f;for(h={text:"x",size:80,height:10,line_height:160,curve_segments:2,font:"montserrat",color:16777215},o.merge(h,t),r=h.text.split("\\n"),i=new THREE.Geometry,n=c=0,p=r.length;p>c;n=++c){for(s=r[n],e=new THREE.TextGeometry(s,{size:h.size,height:h.height,curveSegments:h.curve_segments,font:h.font}),e.computeBoundingBox(),f=e.vertices,d=0,_=f.length;_>d;d++)l=f[d],l.x+=-.5*(e.boundingBox.max.x-e.boundingBox.min.x),l.y-=n*h.line_height;i.merge(e)}return a=new THREE.MeshBasicMaterial({color:h.color,transparent:!0}),u=new THREE.Mesh(i,a)},t}()},function(t,e,i){var n,o=function(t,e){return function(){return t.apply(e,arguments)}};n=function(){function t(){this.weibo=o(this.weibo,this),this.renren=o(this.renren,this),this.twitter=o(this.twitter,this),this.facebook=o(this.facebook,this),this.tumblr=o(this.tumblr,this),this.pinterest=o(this.pinterest,this),this.plus=o(this.plus,this),this.open_window=o(this.open_window,this),this.url=window.location.href}return t.prototype.open_window=function(t,e,i){var n,o;return n=screen.availWidth-e>>1,o=screen.availHeight-i>>1,window.open(t,"","top="+o+",left="+n+",width="+e+",height="+i+",location=no,menubar=no"),!1},t.prototype.plus=function(t){return t=encodeURIComponent(t||this.url),this.open_window("https://web.archive.org/web/20150827155339/https://plus.google.com/share?url="+t,650,385),!1},t.prototype.pinterest=function(t,e,i){return t=encodeURIComponent(t||this.url),e=encodeURIComponent(e),i=encodeURIComponent(i),this.open_window("https://web.archive.org/web/20150827155339/http://www.pinterest.com/pin/create/button/?url="+t+"&media="+e+"&description="+i,735,310),!1},t.prototype.tumblr=function(t,e,i){return t=encodeURIComponent(t||this.url),e=encodeURIComponent(e),i=encodeURIComponent(i),this.open_window("https://web.archive.org/web/20150827155339/http://www.tumblr.com/share/photo?source="+e+"&caption="+i+"&click_thru="+t,450,430),!1},t.prototype.facebook=function(t,e){var i;return null==e&&(e=""),t=encodeURIComponent(t||this.url),i=encodeURIComponent(e),this.open_window("https://web.archive.org/web/20150827155339/http://www.facebook.com/share.php?u="+t+"&t="+i,600,300),!1},t.prototype.twitter=function(t,e){var i;return null==e&&(e=""),t=encodeURIComponent(t||this.url),""===e&&(e="Generic share text here!"),i=encodeURIComponent(e),this.open_window("https://web.archive.org/web/20150827155339/http://twitter.com/intent/tweet/?text="+i+"&url="+t,600,300),!1},t.prototype.renren=function(t){return t=encodeURIComponent(t||this.url),this.open_window("https://web.archive.org/web/20150827155339/http://share.renren.com/share/buttonshare.do?link="+t,600,300),!1},t.prototype.weibo=function(t){return t=encodeURIComponent(t||this.url),this.open_window("https://web.archive.org/web/20150827155339/http://service.weibo.com/share/share.php?url="+t+"&language=zh_cn",600,300),!1},t}(),t.exports=new n},function(t,e,i){var n=i(43);t.exports=function(t){var e,i=[],o=t||{};return function(o,s,r,a){if(i.push("

'+n.escape(null==(e=t.data.chapter)?"":e)+"

"+n.escape(null==(e=t.data.title)?"":e)+"

"),function(){var o=t.data.paragraphs;if("number"==typeof o.length)for(var s=0,r=o.length;r>s;s++){var a=o[s];i.push('

'+n.escape(null==(e=a)?"":e)+"

")}else{var r=0;for(var s in o){r++;var a=o[s];i.push('

'+n.escape(null==(e=a)?"":e)+"

")}}}.call(this),i.push('
    '),function(){var n=t.data.interactions;if("number"==typeof n.length)for(var o=0,s=n.length;s>o;o++){var r=n[o];i.push('

  • '+(null==(e=r.text)?"":e)+"
  • ")}else{var s=0;for(var o in n){s++;var r=n[o];i.push('

  • '+(null==(e=r.text)?"":e)+"
  • ")}}}.call(this),i.push('
'),"elements"==t.data.id){o=["hexahedron","octahedron","tetrahedron","icosahedron","dodecahedron"],s=["earth","air","fire","water","universe"],i.push('
');for(var u=0;u

"+n.escape(null==(e=a)?"":e)+"

");i.push('")}i.push('
')}.call(this,"solids"in o?o.solids:"undefined"!=typeof solids?solids:void 0,"elements"in o?o.elements:"undefined"!=typeof elements?elements:void 0,"solid"in o?o.solid:"undefined"!=typeof solid?solid:void 0,"element"in o?o.element:"undefined"!=typeof element?element:void 0),i.join("")}},function(t,e,i){var n=i(43);t.exports=function(t){var e,i=[];return i.push("

EPILOGUE

'),function(){var n=t.data.paragraphs;if("number"==typeof n.length)for(var o=0,s=n.length;s>o;o++){var r=n[o];i.push(""+(null==(e=r)?"":e)+"
")}else{var s=0;for(var o in n){s++;var r=n[o];i.push(""+(null==(e=r)?"":e)+"
")}}}.call(this),i.push('
'),i.join("")}},function(t,e,i){var n=i(43);t.exports=function(t){var e,i=[];return i.push("

PREFACE

'),function(){var n=t.data.paragraphs;if("number"==typeof n.length)for(var o=0,s=n.length;s>o;o++){var r=n[o];i.push("

"+(null==(e=r)?"":e)+"

")}else{var s=0;for(var o in n){s++;var r=n[o];i.push("

"+(null==(e=r)?"":e)+"

")}}}.call(this),i.push('
'),i.join("")}},function(t,e,i){var n,o,s,r=function(t,e){return function(){return t.apply(e,arguments)}};s=i(26),t.exports=n=function(){function t(t){this.el=t,this.update=r(this.update,this),this.set_size=r(this.set_size,this),this.set_mode=r(this.set_mode,this),this.load=r(this.load,this),this._resize=r(this._resize,this),this._update=r(this._update,this),this._setup=r(this._setup,this),s(this),this.el.style.overflow="hidden"}return t.prototype.el=null,t.prototype.current_frame=-1,t.prototype.spritesheet_index=-1,t.prototype.offset_x=0,t.prototype.offset_y=0,t.prototype.mode=null,t.prototype._create_frame=function(t,e){var i;return i=document.createElement("div"),i.className=e,i.style.position="absolute",i.style.width="100%",i.style.height="100%",t&&(i.style.backgroundImage="url("+t+")"),i.style.backgroundRepeat="no-repeat",i.style.visibility="hidden",i},t.prototype._setup=function(){var t,e,i,n,o,s,r,a;for(this.container=document.createElement("div"),this.container.style.position="absolute",this.el.appendChild(this.container),o=this.data.frame.width*this.data.frame.scale,e=this.data.frame.height*this.data.frame.scale,this.frame_width=this.data.frame.width,this.frame_height=this.data.frame.height,this.max_frames_horizontal=Math.round(this.data.width/this.data.frame.width),this.max_frames_vertical=Math.round(this.data.height/this.data.frame.height),this._frames=[],a=this._cache,i=s=0,r=a.length;r>s;i=++s)n=a[i],t=this._create_frame(n.src,"sd_frame"),this._frames.push(t),this.container.appendChild(t);return this._cache=null,this.set_size(o,e),this.emit("setup_complete",this)},t.prototype._update=function(t){var e,i,n,o,s,r,a,u,h,l,c,d,p,_,f;for(null==t&&(t=!1),n=this.mode.get_frame(),r=Math.floor(n/this.data.frames_per_spritesheet),o=r*this.data.frames_per_spritesheet,a=n-o,s=-1,h=0,c=0,l=d=0,_=this.max_frames_vertical;_>=0?_>d:d>_;l=_>=0?++d:--d)for(u=p=0,f=this.max_frames_horizontal;f>=0?f>p:p>f;u=f>=0?++p:--p)if(s++,s===a){h=u,c=l;break}return e=-(h*this.frame_width),i=-(c*this.frame_height),e+=this.offset_x,i+=this.offset_y,n!==this.current_frame||t?(null!=this._frames[this.spritesheet_index]&&(this._frames[this.spritesheet_index].style.visibility="hidden",this._frames[this.spritesheet_index].style.zIndex=0),this.current_frame=n,this.spritesheet_index=r,u=e+"px",l=i+"px",this._frames[r].style.backgroundPosition=""+u+" "+l,this._frames[r].style.visibility="visible",this._frames[r].style.zIndex=1):void 0},t.prototype._resize=function(){var t;return t=$(window),this.set_size(t.width(),t.height()),this._update(!0)},t.prototype.load=function(t,e){return this.path=t,$.ajax({url:this.path+"/"+e,complete:function(t){return function(e){return t.data=JSON.parse(e.responseText),t._load_images()}}(this),error:function(t){return function(t){}}(this)})},t.prototype.noload=function(t,e){return this.data=t,this._cache=e,this._setup()},t.prototype.set_mode=function(t){var e;return null!=(e=this.mode)&&e.off("update",this.update),this.mode=t,this.mode.on("update",this.update)},t.prototype.set_size=function(t,e){var i,n;return this.width=t,this.height=e,this.el.style.width=this.width+"px",this.el.style.height=this.height+"px",this.container.style.width=this.width+"px",this.container.style.height=this.height+"px",i=$(this.container).find(".sd_frame"),n=o.resize_spritesheet(i,this.data.frame.width,this.data.frame.height,this.width,this.height,this.max_frames_horizontal,this.max_frames_vertical),this.frame_width=n[0],this.frame_height=n[1],this.offset_x=n[2],this.offset_y=n[3],this.frame_width=Math.floor(this.frame_width),this.frame_height=Math.floor(this.frame_height)},t.prototype.update=function(){return null!=this.mode?this._update():void 0},t.prototype.enable_automatic_resize=function(){return $(window).on("resize",this._resize),this._resize()},t.prototype.disable_automatic_resize=function(){return $(window).off("resize",this._resize)},t.prototype.get_total_frames=function(){return this.data.total_frames-1},t.prototype.get_total_spritesheets=function(){return this.data.total_spritesheets-1},t.prototype.destroy=function(){return this.mode.off("update",this.update),this.mode=null,this.__init=null,this.on=null,this.off=null,this.once=null,this.emit=null,this.data=null,this.el.innerHTML=""},t}(),o={calculate_resize:function(t,e,i,n){var o,s,r,a,u,h,l;return l=i/n,o=t/e,s=e/t,o>l?(r=n,h=Math.round(r*o),u=0,a=.5*i-.5*h):(h=i,r=Math.round(h*s),u=.5*n-.5*r,a=0),{x:a,y:u,width:h,height:r}},resize:function(t,e,i,n,o,s){var r;return r=this.calculate_resize(e,i,n,o),t.css(s?{"background-size":""+r.width+"px "+r.height+"px","background-position":""+r.x+"px "+r.y+"px"}:{"margin-top":""+r.y+"px","margin-left":""+r.x+"px",width:""+r.width+"px",height:""+r.height+"px"})},resize_spritesheet:function(t,e,i,n,o,s,r){var a,u,h;return a=this.calculate_resize(e,i,n,o),u=a.width*s,h=a.height*r,t.css({"background-size":""+u+"px "+h+"px"}),[a.width,a.height,a.x,a.y]}}},function(t,e,i){var n,o=function(t,e){return function(){return t.apply(e,arguments)}};n=i(26),e.FrameMode=function(){function t(t,e){this.frames=t,this.data=e,this._update=o(this._update,this),this.get_frame=o(this.get_frame,this),n(this)}return t.prototype.id="Delay",t.prototype.frame=0,t.prototype.set_frame=function(t){this.frame=t},t.prototype.get_frame=function(){var t;return t=Math.floor(this.frame),t=Math.min(t,this.total_frames()),t=Math.max(t,0)},t.prototype.total_frames=function(){return this.frames.total_frames-1},t.prototype._update=function(){return this.emit("update")},t}(),e.LinearMode=function(){function t(t){this.data=t,this._complete=o(this._complete,this),this._update=o(this._update,this),this.get_frame=o(this.get_frame,this),n(this)}return t.prototype.id="Linear",t.prototype.frame=0,t.prototype.play=function(t,e,i){var n;return null==t&&(t=1),null==e&&(e=1),null==i&&(i=Linear.easeNone),this.stop(),this.frame=0,n={frame:e,onUpdate:this._update,onComplete:this._complete,ease:i},this.tween=TweenLite.to(this,t,n)},t.prototype.stop=function(){return TweenLite.killTweensOf(this.tween)},t.prototype.get_frame=function(){var t;return t=Math.floor(this.frame),0>t?t=0:t>this.total_frames()&&(t=this.total_frames()),t},t.prototype.total_frames=function(){return this.data.total_frames-1},t.prototype._update=function(){return this.emit("update")},t.prototype._complete=function(){return this.frame=0,this._update(),this.emit("complete")},t}(),e.RepeatMode=function(){function t(t){this.data=t,this._reverse_complete=o(this._reverse_complete,this),this._complete=o(this._complete,this), +this._update=o(this._update,this),this.get_frame=o(this.get_frame,this),this.play=o(this.play,this),n(this)}return t.prototype.id="Linear",t.prototype.frame=0,t.prototype.repeat=1,t.prototype.play=function(t,e,i){var n;return this.duration=null!=t?t:1,null==e&&(e=1),this.ease=null!=i?i:Linear.easeNone,n={frame:this.total_frames(),onUpdate:this._update,onComplete:this._complete,ease:this.ease,repeat:this.repeat},TweenMax.to(this,this.duration,n)},t.prototype.stop=function(){return TweenMax.killTweensOf(this)},t.prototype.get_frame=function(){var t;return t=Math.floor(this.frame),0>t?t=0:t>this.total_frames()&&(t=this.total_frames()),t},t.prototype.total_frames=function(){return this.data.total_frames-1},t.prototype._update=function(){return this.emit("update")},t.prototype._complete=function(){return this.emit("complete")},t.prototype._reverse_complete=function(){return this.emit("reverse_complete"),this.tween.play()},t}()}]); +} + +/* + FILE ARCHIVED ON 15:53:39 Aug 27, 2015 AND RETRIEVED FROM THE + INTERNET ARCHIVE ON 03:40:20 Jun 07, 2026. + JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. + + ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. + SECTION 108(a)(3)). +*/ +/* +playback timings (ms): + capture_cache.get: 0.357 + load_resource: 94.11 + PetaboxLoader3.resolve: 61.058 + PetaboxLoader3.datanode: 14.862 +*/ \ No newline at end of file diff --git a/web.archive.org/web/20150828053525js_/http:/void.hi-res.net/js/coffee-collider-dev.js b/web.archive.org/web/20150828053525js_/http:/void.hi-res.net/js/coffee-collider-dev.js new file mode 100644 index 000000000..82c58f1b0 --- /dev/null +++ b/web.archive.org/web/20150828053525js_/http:/void.hi-res.net/js/coffee-collider-dev.js @@ -0,0 +1,25085 @@ +var _____WB$wombat$assign$function_____=function(name){return (globalThis._wb_wombat && globalThis._wb_wombat.local_init && globalThis._wb_wombat.local_init(name))||globalThis[name];};if(!globalThis.__WB_pmw){globalThis.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{ +let window = _____WB$wombat$assign$function_____("window"); +let self = _____WB$wombat$assign$function_____("self"); +let document = _____WB$wombat$assign$function_____("document"); +let location = _____WB$wombat$assign$function_____("location"); +let top = _____WB$wombat$assign$function_____("top"); +let parent = _____WB$wombat$assign$function_____("parent"); +let frames = _____WB$wombat$assign$function_____("frames"); +let opener = _____WB$wombat$assign$function_____("opener"); +(function(global) { +"use strict"; +var _define = function(module, /*deps,*/ payload) { + if (!_define.modules) { + _define.modules = {}; + _define.payloads = {}; + } + _define.payloads[module] = payload; + _define.modules[module] = null; +}; +var _require = function(parentId, moduleName) { + moduleName = normalizeModule(parentId, moduleName); + var module = _define.modules[moduleName]; + if (!module) { + module = _define.payloads[moduleName]; + var exports = {}; + var mod = { id:moduleName, exports:exports }; + var req = function(module) { + return _require(moduleName, module); + }; + var ret = null; + if (module) { + module(req, exports, mod); + exports = ret || mod.exports; + } else { + exports = -1; + } + _define.modules[moduleName] = exports; + delete _define.payloads[moduleName]; + } + module = _define.modules[moduleName] = exports || module; + return module; +}; +var normalizeModule = function(parentId, moduleName) { + if (moduleName.charAt(0) === ".") { + var base = parentId.split("/").slice(0, -1).join("/"); + moduleName = base + "/" + moduleName; + var previous; + while (moduleName.indexOf(".") !== -1 && previous !== moduleName) { + previous = moduleName; + moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, ""); + } + } + return moduleName; +}; +if (typeof require === "function") { + global.require = require; +} +var define = _define; +define('cc/loader', function(require, exports, module) { + + var cc = require("./cc"); + + if (typeof document !== "undefined") { + var scripts = document.getElementsByTagName("script"); + if (scripts && scripts.length) { + for (var i = 0; i < scripts.length; i++) { + var m = /^(.*\/)coffee-collider(?:-dev)?\.js(\#.*)?$/.exec(scripts[i].src); + if (m) { + cc.rootPath = m[1]; + cc.coffeeColliderPath = m[0]; + cc.coffeeColliderHash = m[2]; + break; + } + } + } + cc.opmode = "client"; + cc.context = "client"; + require("./client/client"); + global.CoffeeCollider = function(opts) { + return cc.createSynthClient(opts); + }; + global.CoffeeCollider.version = cc.version; + } else if (typeof WorkerLocation !== "undefined") { + if (location.hash === "#socket") { + cc.opmode = "socket"; + cc.context = "lang"; + require("./lang/lang"); + cc.lang = cc.createSynthLang(); + } else { + cc.opmode = "worker"; + cc.context = "lang/server"; + require("./lang/lang"); + require("./server/server"); + cc.lang = cc.createSynthLang(); + cc.server = cc.createSynthServer(); + cc.lang.sendToServer = cc.server.recvFromLang.bind(cc.server); + cc.server.sendToLang = cc.lang.recvFromServer.bind(cc.lang); + cc.server.connect(); + } + } else if (typeof global.GLOBAL !== "undefined") { + cc.global.CoffeeCollider = function() { + cc.opmode = "nodejs"; + cc.context = "client/lang/server"; + require("./client/client"); + require("./lang/lang"); + require("./server/server"); + cc.client = cc.createSynthClient({nodejs:true}); + cc.lang = cc.createSynthLang(); + cc.server = cc.createSynthServer(); + cc.client.impl.sendToLang = cc.lang.recvFromClient.bind(cc.lang); + cc.client.impl.sendToLangWithTransferable = cc.lang.recvFromClient.bind(cc.lang); + cc.lang.sendToServer = cc.server.recvFromLang.bind(cc.server); + cc.server.sendToLang = cc.lang.recvFromServer.bind(cc.lang); + cc.lang.sendToClient = cc.client.impl.recvFromLang.bind(cc.client.impl); + cc.lang.sendToClientWithTransferable = cc.client.impl.recvFromLang.bind(cc.client.impl); + cc.server.connect(); + return cc.client; + }; + cc.global.SocketSynthServer = function(opts) { + cc.opmode = "socket"; + cc.context = "server"; + require("./server/server"); + cc.server = cc.createSynthServer(); + return cc.server.exports.createServer(opts); + }; + cc.global.version = cc.version; + module.exports = cc.global; + } + +}); +define('cc/cc', function(require, exports, module) { + + module.exports = { + version: "0.3.0", + global : {}, + Object : function() {}, + ugen : {specs:{}}, + unit : {specs:{}}, + deprecate: {} + }; + +}); +define('cc/client/client', function(require, exports, module) { + + var cc = require("../cc"); + var emitter = require("../common/emitter"); + var unpack = require("../common/pack").unpack; + var commands = {}; + var slice = [].slice; + + var SynthClient = (function() { + function SynthClient(opts) { + opts = opts || {}; + + this.version = cc.version; + if (opts.socket) { + this.impl = cc.createSynthClientSocketImpl(this, opts); + } else if (opts.nodejs) { + this.impl = cc.createSynthClientNodeJSImpl(this, opts); + } else { + this.impl = cc.createSynthClientWorkerImpl(this, opts); + } + this.sampleRate = this.impl.sampleRate; + this.channels = this.impl.channels; + } + + SynthClient.prototype.play = function() { + this.impl.play.apply(this.impl, arguments); + return this; + }; + SynthClient.prototype.pause = function() { + this.impl.pause.apply(this.impl, arguments); + return this; + }; + SynthClient.prototype.reset = function() { + this.impl.reset.apply(this.impl, arguments); + return this; + }; + SynthClient.prototype.execute = function() { + this.impl.execute.apply(this.impl, arguments); + return this; + }; + SynthClient.prototype.run = function() { + this.impl.run.apply(this.impl, arguments); + return this; + }; + SynthClient.prototype.compile = function() { + return this.impl.compile.apply(this.impl, arguments); + }; + SynthClient.prototype.getStream = function() { + return this.impl.getStream.apply(this.impl, arguments); + }; + SynthClient.prototype.getWebAudioComponents = function() { + return this.impl.getWebAudioComponents.apply(this.impl, arguments); + }; + SynthClient.prototype.load = function() { + this.impl.load.apply(this.impl, arguments); + return this; + }; + SynthClient.prototype.send = function() { + this.impl.send.apply(this.impl, arguments); + return this; + }; + SynthClient.prototype.isPlaying = function() { + return this.impl.isPlaying; + }; + + SynthClient.prototype.getListeners = function() { + return this.impl.getListeners.apply(this.impl, arguments); + }; + SynthClient.prototype.hasListeners = function() { + return this.impl.hasListeners.apply(this.impl, arguments); + }; + SynthClient.prototype.on = function() { + this.impl.on.apply(this.impl, arguments); + return this; + }; + SynthClient.prototype.once = function() { + this.impl.once.apply(this.impl, arguments); + return this; + }; + SynthClient.prototype.off = function() { + this.impl.off.apply(this.impl, arguments); + return this; + }; + + return SynthClient; + })(); + + var SynthClientImpl = (function() { + function SynthClientImpl(client, opts) { + emitter.mixin(this); + + this.compiler = cc.createCompiler("coffee"); + + this.isPlaying = false; + this.execId = 0; + this.execCallbacks = {}; + + this.sampleRate = 44100; + this.channels = 2; + this.api = cc.createAudioAPI(this, opts); + this.sampleRate = this.api.sampleRate; + this.channels = this.api.channels; + if (this.api.strmLength) { + this.strmLength = this.api.strmLength; + } + this.strm = new Float32Array(this.strmLength * this.channels); + this.clear = new Float32Array(this.strmLength * this.channels); + this.strmList = new Array(8); + this.strmListReadIndex = 0; + this.strmListWriteIndex = 0; + this.syncCount = 0; + this.speaker = opts.speaker !== false; + this.api.init(); + + var syncItems = new Uint8Array(20); + if (typeof window !== "undefined" && opts.mouse !== false) { + var f32_syncItems = new Float32Array(syncItems.buffer); + window.addEventListener("mousemove", function(e) { + f32_syncItems[2] = e.pageX / window.innerWidth; + f32_syncItems[3] = e.pageY / window.innerHeight; + }, true); + window.addEventListener("mousedown", function() { + f32_syncItems[4] = 1; + }, true); + window.addEventListener("mouseup", function() { + f32_syncItems[4] = 0; + }, true); + } + this.syncItems = syncItems; + this.syncItemsUInt32 = new Uint32Array(syncItems.buffer); + this.pendingExecution = []; + } + + SynthClientImpl.prototype.play = function() { + if (!this.isPlaying) { + this.isPlaying = true; + this.sendToLang(["/play"]); + if (this.api) { + this.api.play(); + } + } + }; + SynthClientImpl.prototype._played = function(syncCount) { + var strm = this.strm, i; + for (i = strm.length; i--; ) { + strm[i] = 0; + } + this.strmList.splice(0); + this.strmListReadIndex = 0; + this.strmListWriteIndex = 0; + this.syncCount = syncCount; + this.emit("play"); + }; + SynthClientImpl.prototype.pause = function() { + if (this.isPlaying) { + this.isPlaying = false; + this.sendToLang(["/pause"]); + } + }; + SynthClientImpl.prototype._paused = function() { + if (this.api) { + this.api.pause(); + } + this.emit("pause"); + }; + SynthClientImpl.prototype.reset = function() { + this.execId = 0; + this.execCallbacks = {}; + var strm = this.strm, i; + for (i = strm.length; i--; ) { + strm[i] = 0; + } + this.strmList.splice(0); + this.strmListReadIndex = 0; + this.strmListWriteIndex = 0; + this.sendToLang(["/reset"]); + this.emit("reset"); + }; + SynthClientImpl.prototype.execute = function(code) { + var opts; + var args = arguments; + + if (typeof code !== "string") { + throw new Error("cc.execute requires a code, but got: " + (typeof code)); + } + if (this.pendingExecution) { + this.pendingExecution.push(slice.apply(args)); + return; + } + + var i = 1, append, callback; + if (typeof args[i] === "boolean") { + append = args[i++]; + } else { + append = false; + } + if (typeof args[i] === "function") { + callback = args[i++]; + } else { + callback = null; + } + if (typeof args[i] === "object") { + opts = args[i++]; + } else { + opts = {}; + } + + if (!opts.lang || opts.lang !== "js") { + code = this.compiler.compile(code.trim()); + } + if (callback) { + this.execCallbacks[this.execId] = callback; + } + this.sendToLang([ + "/execute", this.execId, code, append, !!callback + ]); + this.execId += 1; + }; + SynthClientImpl.prototype.run = function() { + if (!this.isPlaying) { + this.play(); + } + this.execute.apply(this, arguments); + + // TODO: auto stop + }; + SynthClientImpl.prototype.compile = function(code) { + if (typeof code !== "string") { + throw new Error("cc.execute requires a code, but got: " + (typeof code)); + } + return this.compiler.compile(code.trim()); + }; + SynthClientImpl.prototype.getStream = function() { + var f32 = this.strm; + var strmLength = this.strmLength; + var strmLength4 = strmLength * 4; + return { + getChannelData: function(channel) { + if (channel === 0) { + return new Float32Array(f32.buffer, 0, strmLength); + } else if (channel === 1) { + return new Float32Array(f32.buffer, strmLength4); + } + throw new Error("bad channel"); + } + }; + }; + SynthClientImpl.prototype.getWebAudioComponents = function() { + if (this.api && this.api.type === "Web Audio API") { + return [ this.api.context, this.api.jsNode ]; + } + return []; + }; + + SynthClientImpl.prototype.load = function(files, callback) { + if (typeof callback !== "function") { + throw new Error("cc#load requires a callback function."); + } + var isNotArray = false; + if (!Array.isArray(files)) { + files = [ files ]; + isNotArray = true; + } + + var results = []; + var load = function(files) { + var path = files.shift(); + if (typeof path !== "string") { + if (isNotArray) { + results = results[0]; + } + return callback(results); + } + if (cc.opmode === "nodejs") { + var fs = global.require("fs"); + if (fs.existsSync(path)) { + results.push(fs.readFileSync(path, "utf-8")); + } else { + results.push(null); + } + load(files); + } else { + var xhr = cc.createXMLHttpRequest(); + xhr.open("GET", path); + xhr.onreadystatechange = function() { + if (xhr.readyState === 4) { + if (xhr.status === 200) { + results.push(xhr.response); + } else { + results.push(null); + } + load(files); + } + }; + xhr.send(); + } + }; + load(files); + }; + SynthClientImpl.prototype.send = function() { + this.sendToLang([ + "/send", slice.call(arguments) + ]); + }; + SynthClientImpl.prototype.process = function() { + var strm; + if (this.strmListReadIndex < this.strmListWriteIndex) { + strm = this.strmList[this.strmListReadIndex & 7]; + this.strmListReadIndex += 1; + this.strm.set(strm); + } else { + this.strm.set(this.clear); + } + this.syncItemsUInt32[1] = ++this.syncCount; + this.sendToLang(this.syncItems); + }; + SynthClientImpl.prototype.sendToLang = function(msg) { + if (this.lang) { + this.lang.postMessage(msg); + } + }; + SynthClientImpl.prototype.sendToLangWithTransferable = function(uint8) { + if (this.lang) { + this.lang.postMessage(uint8, [uint8.buffer]); + } + }; + SynthClientImpl.prototype.recvFromLang = function(msg) { + if (msg instanceof Float32Array) { + this.strmList[this.strmListWriteIndex & 7] = msg; + this.strmListWriteIndex += 1; + } else { + var func = commands[msg[0]]; + if (func) { + func.call(this, msg); + } else { + throw new Error("Unknown command: " + msg[0]); + } + } + }; + SynthClientImpl.prototype.readAudioFile = function(path, callback) { + var api = this.api; + if (api) { + if (!api.decodeAudioFile) { + callback("Audio decoding not supported", null); + return; + } + var xhr = cc.createXMLHttpRequest(); + xhr.open("GET", path); + xhr.responseType = "arraybuffer"; + xhr.onreadystatechange = function() { + if (xhr.readyState === 4) { + if (xhr.status === 200 && xhr.response) { + api.decodeAudioFile(xhr.response, function(err, buffer) { + callback(err, buffer); + }); + } else { + callback("error", null); + } + } + }; + xhr.send(); + } + }; + + return SynthClientImpl; + })(); + + commands["/connected"] = function(msg) { + var globalIds = msg[3]; + if (globalIds) { + globalIds.forEach(function(key) { + cc.global[key] = true; + }); + } + this.sendToLang([ + "/init", this.sampleRate, this.channels, this.strmLength + ]); + this.emit("connected"); + + var i, imax; + if (this.pendingExecution) { + var execute = this.execute; + var args = this.pendingExecution; + this.pendingExecution = null; + for (i = 0, imax = args.length; i < imax; ++i) { + execute.apply(this, args[i]); + } + } + }; + commands["/played"] = function(msg) { + var syncCount = msg[1]; + this._played(syncCount); + }; + commands["/paused"] = function(msg) { + var syncCount = msg[1]; + this._paused(syncCount); + }; + commands["/executed"] = function(msg) { + var execId = msg[1]; + var result = msg[2]; + var callback = this.execCallbacks[execId]; + if (callback) { + callback(unpack(result)); + delete this.execCallbacks[execId]; + } + }; + commands["/buffer/request"] = function(msg) { + var that = this; + var callbackId = msg[2]; + this.readAudioFile(msg[1], function(err, result) { + if (!err) { + var uint8 = new Uint8Array(16 + result.samples.length * 4); + var int16 = new Uint16Array(uint8.buffer); + var int32 = new Uint32Array(uint8.buffer); + var f32 = new Float32Array(uint8.buffer); + int16[0] = 1; + int16[1] = callbackId; + int16[3] = result.channels; + int32[2] = result.sampleRate; + int32[3] = result.frames; + f32.set(result.samples, 4); + that.sendToLangWithTransferable(uint8); + } + }); + }; + commands["/socket/sendToClient"] = function(msg) { + this.emit("message", msg[1]); + }; + commands["/send"] = function(msg) { + var args = msg[1]; + this.emit.apply(this, args); + }; + commands["/console/log"] = function(msg) { + console.log.apply(console, unpack(msg[1])); + }; + + cc.SynthClientImpl = SynthClientImpl; + cc.createSynthClient = function(opts) { + return new SynthClient(opts); + }; + cc.createSynthClientImpl = function(client, opts) { + return new SynthClientImpl(client, opts); + }; + + // TODO: moved + require("../common/browser"); + require("../common/audioapi"); + require("./compiler"); + require("./client-worker"); + require("./client-nodejs"); + require("./client-socket"); + + module.exports = { + SynthClient : SynthClient, + SynthClientImpl: SynthClientImpl + }; + +}); +define('cc/common/emitter', function(require, exports, module) { + + var Emitter = (function() { + function Emitter(context) { + this.__context = context || this; + this.__callbacks = {}; + } + Emitter.prototype.getListeners = function(event) { + return this.__callbacks[event] || (this.__callbacks[event] = []); + }; + Emitter.prototype.hasListeners = function(event) { + return this.getListeners(event).length > 0; + }; + Emitter.prototype.on = function(event, callback) { + var __callbacks = this.getListeners(event); + if (__callbacks.indexOf(callback) === -1) { + __callbacks.push(callback); + } + return this; + }; + Emitter.prototype.once = function(event, callback) { + var that = this; + function wrapper() { + that.off(event, wrapper); + callback.apply(that.__context, arguments); + } + wrapper.callback = callback; + this.on(event, wrapper); + return this; + }; + Emitter.prototype.off = function(event, callback) { + if (arguments.length === 0) { + this.__callbacks = {}; + return this; + } + var __callbacks = this.getListeners(event); + if (arguments.length === 1) { + __callbacks.splice(0); + return this; + } + var index = __callbacks.indexOf(callback); + if (index === -1) { + for (var i = 0, imax = __callbacks.length; i < imax; ++i) { + if (__callbacks[i].callback === callback) { + index = i; + break; + } + } + } + if (index !== -1) { + __callbacks.splice(index, 1); + } + return this; + }; + Emitter.prototype.emit = function(event) { + var args = Array.prototype.slice.call(arguments, 1); + var __callbacks = this.getListeners(event).slice(0); + for (var i = 0, imax = __callbacks.length; i < imax; ++i) { + __callbacks[i].apply(this.__context, args); + } + return this; + }; + return Emitter; + })(); + + var mixin = function(obj) { + ["getListeners", "hasListeners", "on", "once", "off", "emit"].forEach(function(method) { + if (!obj[method]) { + obj[method] = Emitter.prototype[method]; + } + }); + Emitter.call(obj); + return obj; + }; + + module.exports = { + Emitter: Emitter, + mixin: mixin + }; + +}); +define('cc/common/pack', function(require, exports, module) { + + var pack = (function() { + var _pack = function(data, stack) { + if (!data) { + return data; + } + if (typeof data === "function") { + return { klassName:"Function" }; + } + if (stack.indexOf(data) !== -1) { + return { klassName:"Circular" }; + } + var result; + if (typeof data === "object") { + if (data.buffer instanceof ArrayBuffer) { + return data; + } + stack.push(data); + if (Array.isArray(data)) { + result = data.filter(function(data) { + return typeof data !== "function"; + }).map(function(data) { + return _pack(data, stack); + }); + } else { + result = {}; + Object.keys(data).forEach(function(key) { + if (key.charAt(0) !== "_" && typeof data[key] !== "function") { + result[key] = _pack(data[key], stack); + } + }); + } + stack.pop(); + } else { + result = data; + } + return result; + }; + return function(data) { + return _pack(data, []); + }; + })(); + + var unpack = (function() { + var _unpack = function(data) { + if (!data) { + return data; + } + var result; + if (typeof data === "object") { + if (data.buffer instanceof ArrayBuffer) { + return data; + } + if (Array.isArray(data)) { + result = data.map(function(data) { + return _unpack(data); + }); + } else { + if (data.klassName && /^[_a-z$][_a-z0-9$]*$/i.test(data.klassName)) { + result = eval.call(null, "new (function " + data.klassName + "(){})"); + delete data.klassName; + } else { + result = {}; + } + Object.keys(data).forEach(function(key) { + result[key] = _unpack(data[key]); + }); + } + } else { + result = data; + } + return result; + }; + return function(data) { + return _unpack(data); + }; + })(); + + module.exports = { + pack : pack, + unpack: unpack + }; + +}); +define('cc/common/browser', function(require, exports, module) { + + var cc = require("../cc"); + + cc.createWebWorker = function(path) { + return new Worker(path); + }; + cc.createWebSocket = function(path) { + return new WebSocket(path); + }; + cc.createXMLHttpRequest = function() { + return new XMLHttpRequest(); + }; + + module.exports = {}; + +}); +define('cc/common/audioapi', function(require, exports, module) { + + var cc = require("../cc"); + + require("./audioapi-webaudio"); + require("./audioapi-flashfallback"); + require("./audioapi-nodeaudio"); + + cc.createAudioAPI = function(sys, opts) { + return cc.createWebAudioAPI(sys, opts) || + cc.createFlashAudioAPI(sys, opts) || + cc.createNodeAudioAPI(sys, opts); + }; + + module.exports = {}; + +}); +define('cc/common/audioapi-webaudio', function(require, exports, module) { + + var cc = require("../cc"); + + var AudioAPI; + + if (typeof document !== "undefined") { + var AudioContext = global.AudioContext || global.webkitAudioContext; + if (AudioContext) { + AudioAPI = (function() { + function WebAudioAPI(sys, opts) { + this.sys = sys; + this.context = opts.AudioContext || new AudioContext(); + this.sampleRate = this.context.sampleRate; + this.channels = 2; + this.type = "Web Audio API"; + this.delegate = !!opts.AudioContext; + this.jsNode = null; + } + WebAudioAPI.prototype.init = function() { + }; + WebAudioAPI.prototype.play = function() { + var sys = this.sys; + var strm = sys.strm; + var strmLength = sys.strmLength; + var strmLength4 = strmLength * 4; + var strmL = new Float32Array(strm.buffer, 0, strmLength); + var strmR = new Float32Array(strm.buffer, strmLength4); + var onaudioprocess, jsNode; + + jsNode = this.context.createScriptProcessor(strmLength, 2, this.channels); + + if (sys.speaker) { + if (sys.sampleRate === this.sampleRate) { + onaudioprocess = function(e) { + var outs = e.outputBuffer; + sys.process(); + outs.getChannelData(0).set(strmL); + outs.getChannelData(1).set(strmR); + }; + } + } else { + onaudioprocess = function() { + sys.process(); + }; + } + jsNode.onaudioprocess = onaudioprocess; + + if (!this.delegate) { + jsNode.connect(this.context.destination); + } + this.jsNode = jsNode; + }; + WebAudioAPI.prototype.pause = function() { + if (!this.jsNode) { + return; // TODO: throw an error + } + if (!this.delegate) { + this.jsNode.disconnect(); + } + this.jsNode.onaudioprocess = null; + this.jsNode = null; + }; + WebAudioAPI.prototype.decodeAudioFile = function(buffer, callback) { + this.context.decodeAudioData(buffer, function(buffer) { + var bufLength = buffer.length; + var numChannels = buffer.numberOfChannels; + var numSamples = bufLength * numChannels; + var samples = new Float32Array(numSamples); + var i, j, k = 0; + var channelData = new Array(numChannels); + for (j = 0; j < numChannels; ++j) { + channelData[j] = buffer.getChannelData(j); + } + for (i = 0; i < bufLength; ++i) { + for (j = 0; j < numChannels; ++j) { + samples[k++] = channelData[j][i]; + } + } + callback(null, { + sampleRate: buffer.sampleRate, + channels : buffer.numberOfChannels, + frames : buffer.length, + samples : samples + }); + }, function(err) { + callback(err); + }); + }; + return WebAudioAPI; + })(); + } + } + + cc.createWebAudioAPI = function(sys, opts) { + if (AudioAPI) { + return new AudioAPI(sys, opts); + } + }; + + module.exports = {}; + +}); +define('cc/common/audioapi-flashfallback', function(require, exports, module) { + + var cc = require("../cc"); + + var AudioAPI; + + if (typeof document !== "undefined") { + AudioAPI = (function() { + function FallbackAudioAPI(sys) { + this.sys = sys; + this.sampleRate = 44100; + this.channels = 2; + this.strmLength = Math.max(2048, sys.strmLength); + this.type = "Fallback"; + } + FallbackAudioAPI.prototype.init = function() { + }; + FallbackAudioAPI.prototype.play = function() { + if (fallback.play) { + this.play = fallback.play; + this.play(); + } + }; + FallbackAudioAPI.prototype.pause = function() { + if (fallback.pause) { + this.pause = fallback.pause; + this.pause(); + } + }; + + var fallback = {}; + window.addEventListener("load", function() { + var swfSrc = cc.rootPath + "coffee-collider-fallback.swf"; + var swfName = swfSrc + "?" + Date.now(); + var swfId = "coffee-collider-fallback"; + var div = document.createElement("div"); + div.style.display = "inline"; + div.width = 1; + div.height = 1; + /*jshint quotmark:single */ + div.innerHTML = ''; + /*jshint quotmark:double */ + document.body.appendChild(div); + + window.coffeecollider_flashfallback_init = function() { + var swf = document.getElementById(swfId); + var timerId = 0; + fallback.play = function() { + if (timerId === 0) { + var sys = this.sys; + var msec = (sys.strmLength / sys.sampleRate) * 1000; + var written = 0; + var start = Date.now(); + var out = new Array(sys.strmLength * sys.channels); + var len = out.length; + + var onaudioprocess = function() { + if (written > Date.now() - start) { + return; + } + sys.process(); + var x, _in = sys.strm; + for (var i = 0; i < len; ++i) { + x = (_in[i] * 16384 + 32768)|0; + x = Math.max(16384, Math.min(x, 49152)); + out[i] = String.fromCharCode(x); + } + swf.writeAudio(out.join("")); + written += msec; + }; + + timerId = setInterval(onaudioprocess, msec * 0.8); + swf.play(); + } + }; + fallback.pause = function() { + if (timerId !== 0) { + swf.pause(); + clearInterval(timerId); + timerId = 0; + } + }; + }; + }); + return FallbackAudioAPI; + })(); + } + + cc.createFlashAudioAPI = function(sys, opts) { + if (AudioAPI) { + return new AudioAPI(sys, opts); + } + }; + + module.exports = {}; + +}); +define('cc/common/audioapi-nodeaudio', function(require, exports, module) { + + var cc = require("../cc"); + + var AudioAPI; + + if (typeof global.GLOBAL !== "undefined") { + AudioAPI = (function() { + var Readable = global.require("stream").Readable; + var Speaker = global.require("speaker"); + if (!Readable) { + Readable = global.require("readable-stream/readable"); + } + function NodeAudioAPI(sys) { + this.sys = sys; + this.sampleRate = 44100; + this.channels = 2; + this.node = null; + this.isPlaying = false; + } + NodeAudioAPI.prototype.init = function() { + }; + NodeAudioAPI.prototype.play = function() { + var sys = this.sys; + this.isPlaying = true; + this.node = new Readable(); + this.node._read = function(n) { + var strm = sys._strm; + var strmLength = sys.strmLength; + var buf = new Buffer(n); + var x, i, j, k = 0; + n = (n >> 2) / sys.strmLength; + while (n--) { + sys._process(); + for (i = 0, j = strmLength; i < strmLength; ++i, ++j) { + x = Math.max(-32768, Math.min((strm[i] * 32768)|0, 32767)); + buf.writeInt16LE(x, k); + k += 2; + x = Math.max(-32768, Math.min((strm[j] * 32768)|0, 32767)); + buf.writeInt16LE(x, k); + k += 2; + } + } + this.push(buf); + }; + this.node.pipe(new Speaker({sampleRate:this.sampleRate})); + }; + NodeAudioAPI.prototype.pause = function() { + if (this.node) { + process.nextTick(this.node.emit.bind(this.node, "end")); + } + this.node = null; + this.isPlaying = false; + }; + return NodeAudioAPI; + })(); + } + + cc.createNodeAudioAPI = function(sys, opts) { + if (AudioAPI) { + return new AudioAPI(sys, opts); + } + }; + + module.exports = {}; + +}); +define('cc/client/compiler', function(require, exports, module) { + + var CoffeeScript = global.CoffeeScript || global.require("coffee-script"); + + var cc = require("../cc"); + var numericstring = require("../common/numericstring"); + var push = [].push; + + var TAG = 0; + var VALUE = 1; + var _ = {}; // empty location + + // utility functions + var isDot = function(token) { + return !!token && (token[TAG] === "." || token[TAG] === "@"); + }; + var isColon = function(token) { + return !!token && token[TAG] === ":"; + }; + var indexOfParamEnd = function(tokens, index) { + var bracket = 0, i, imax = tokens.length; + for (i = index; i < imax; ++i) { + switch (tokens[i][TAG]) { + case "PARAM_START": + bracket += 1; + break; + case "PARAM_END": + bracket -= 1; + if (bracket === 0) { + return i; + } + } + } + return -1; + }; + var indexOfFunctionStart = function(tokens, index) { + var i, imax = tokens.length; + for (i = index; i < imax; ++i) { + switch (tokens[i][TAG]) { + case "PARAM_START": case "->": case "=>": + return i; + case "TERMINATOR": + case "[": case "{": case "(": + case "CALL_START": case "INDEX_START": + return -1; + } + } + return -1; + }; + var formatArgument = function(op) { + return op.tokens.slice(op.begin, op.end+1).map(function(token, index) { + if (token[TAG] === "STRING" && token[VALUE].charAt(0) === "'") { + return "\"" + token[VALUE].substr(1, token[VALUE].length - 2) + "\""; + } else if (token[TAG] === "IDENTIFIER" && op.tokens[op.begin+index+1][TAG] === ":") { + return "\"" + token[VALUE] + "\""; + } + return token[VALUE]; + }).join(""); + }; + + var detectPlusMinusOperator = function(tokens) { + var i, prevTag = "", tag, imax = tokens.length; + for (i = 0; i < imax; ++i) { + tag = tokens[i][TAG]; + if (tag === "+" || tag === "-") { + switch (prevTag) { + case "IDENTIFIER": case "NUMBER": case "STRING": case "BOOL": + case "REGEX": case "NULL": case "UNDEFINED": case "]": case "}": case ")": + case "CALL_END": case "INDEX_END": + tokens[i][TAG] = "MATH"; + break; + default: + tokens[i][TAG] = "UNARY"; + } + } + prevTag = tag; + } + tokens.cc_plusminus = true; + return tokens; + }; + + var revertPlusMinusOperator = function(tokens) { + var i, val, imax = tokens.length; + for (i = 0; i < imax; ++i) { + val = tokens[i][VALUE]; + if (val === "+" || val === "-") { + tokens[i][TAG] = val; + } + } + return tokens; + }; + + var getPrevOperand = function(tokens, index) { + var bracket = 0; + var indent = 0; + var end = index; + var prev; + while (1 < index) { + switch (tokens[index][TAG]) { + case "(": case "[": case "{": + case "PARAM_START": case "CALL_START": case "INDEX_START": + bracket -= 1; + break; + case "}": case "]": case ")": + case "PARAM_END": case "CALL_END": case "INDEX_END": + bracket += 1; + break; + case "OUTDENT": + indent += 1; + break; + case "INDENT": + indent -= 1; + break; + } + switch (tokens[index - 1][TAG]) { + case "PARAM_END": case "CALL_END": case "INDEX_END": + case ".": case "@": + index -= 1; + continue; + } + switch (tokens[index][TAG]) { + case "(": case "[": case "{": case "PARAM_START": + case "IDENTIFIER": case "NUMBER": case "BOOL": case "STRING": case "REGEX": + case "UNDEFINED": case "NULL": case "@": case "THIS": case "SUPER": + case "->": case "=>": + if (bracket === 0 && indent === 0) { + while ((prev = tokens[index-1]) && prev[TAG] === "UNARY") { + index -= 1; + } + return {tokens:tokens, begin:index, end:end}; + } + break; + } + index -= 1; + } + return {tokens:tokens, begin:0, end:end}; + }; + + var getNextOperand = function(tokens, index) { + var bracket = 0; + var indent = 0; + var begin = index; + var imax = tokens.length - 2; + var tag; + + if (tokens[index] && tokens[index][TAG] === "@") { + if (tokens[index+1][TAG] !== "IDENTIFIER") { + return {tokens:tokens, begin:index, end:index}; + } + } + + while (index < imax) { + tag = tokens[index][TAG]; + + switch (tag) { + case "(": case "[": case "{": + case "PARAM_START": + bracket += 1; + break; + case "}": case "]": case ")": + case "PARAM_END": case "CALL_END": case "INDEX_END": + bracket -= 1; + break; + case "INDENT": + indent += 1; + break; + case "OUTDENT": + indent -= 1; + break; + } + + switch (tokens[index + 1][TAG]) { + case "CALL_START": case "INDEX_START": + bracket += 1; + index += 1; + continue; + case ".": case "@": case "ELSE": + index += 1; + continue; + } + + switch (tag) { + case "}": case "]": case ")": case "CALL_END": case "INDEX_END": + case "IDENTIFIER": case "NUMBER": case "BOOL": case "STRING": case "REGEX": + case "UNDEFINED": case "NULL": case "OUTDENT": + if (bracket === 0 && indent === 0) { + return {tokens:tokens, begin:begin, end:index}; + } + break; + } + index += 1; + } + return {tokens:tokens, begin:begin, end:Math.max(0,tokens.length - 2)}; + }; + + var func = {}; + var detectFunctionParameters = function(tokens) { + var stack = [ + { declared:[], args:[], local:[], outer:[] } + ]; + var scope; + var indent = 0; + var args = []; + var vars = []; + var op, token; + var i, imax = tokens.length - 1; + + stack.setVariables = func.setVariables(stack); + + for (i = 0; i < imax; ++i) { + token = tokens[i]; + stack.peek = stack[stack.length - 1]; + switch (token[TAG]) { + case "PARAM_START": + args = func.getInfoOfArguments(tokens, i); + i = args.end + 1; + vars = args.vars; + args = args.args; + /* falls through */ + case "->": case "=>": + scope = { + declared: stack.peek.declared.concat(stack.peek.local).concat(stack.peek.args), + args:vars.splice(0), local:[], outer:[], indent:indent + }; + tokens[i].cc_funcParams = { + args:args.splice(0), local:scope.local, outer:scope.outer + }; + token.cc_funcRef = tokens[i]; + stack.push(scope); + break; + case "FOR": + do { + op = getNextOperand(tokens, i+1); + func.getVariables(op).forEach(stack.setVariables); + i = op.end + 1; + } while (i < imax && tokens[i][TAG] === ","); + break; + case "INDENT": + indent += 1; + break; + case "OUTDENT": + indent -= 1; + if (stack.peek.indent === indent) { + stack.pop(); + } + break; + case "[": + op = getNextOperand(tokens, i); + func.getVariables(op).forEach(stack.setVariables); + break; + case "IDENTIFIER": + if (tokens[i+1][TAG] === "CALL_START" || /^[A-Z]/.test(token[VALUE])) { + break; + } + op = getNextOperand(tokens, i); + if ((op.begin === op.end && tokens[op.end+1][TAG] !== ":") || tokens[op.begin+1][TAG] === ".") { + func.getVariables(op).forEach(stack.setVariables); + } + } + } + tokens.cc_funcParams = { + local: stack[0].local + }; + return tokens; + }; + + func.setVariables = function(stack) { + var ignored = [ + "cc", "global", "console", "setInterval", "setTimeout", "clearInterval", "clearTimeout" + ]; + return function(name) { + var i; + if (ignored.indexOf(name) !== -1) { + return; + } + if (stack.peek.declared.indexOf(name) === -1) { // not declared yet + if (stack.peek.args.indexOf(name) === -1) { // not function parameters + if (stack.peek.local.indexOf(name) === -1) { // when a local variable (set) + stack.peek.local.push(name); + } + } + return; + } + + // when not a local variable + if (stack.peek.outer.indexOf(name) !== -1) { + return; + } + + // outer variable + stack.peek.outer.push(name); + for (i = stack.length - 2; i >= 0; i--) { + if (stack[i].local.indexOf(name) !== -1) { + return; + } + if (stack[i].outer.indexOf(name) === -1) { + stack[i].outer.push(name); + } + } + }; + }; + + func.getInfoOfArguments = function(tokens, index) { + var begin = index; + var end = indexOfParamEnd(tokens, index); + var vars = [], args = []; + var i, op; + for (i = begin + 1; i < end; ++i) { + op = getNextOperand(tokens, i); + args.push(formatArgument(op)); + vars = func.getVariables(op, vars); + i += op.end - op.begin + 1; + if (tokens[i][TAG] === "=") { + op = getNextOperand(tokens, i+1); + args.push(formatArgument(op)); + i += op.end - op.begin + 1; + } else { + args.push(null); + } + if (tokens[i][TAG] !== ",") { + i += 1; + } + } + return {vars:vars, args:args, end:end}; + }; + func.getVariables = function(op, list) { + var tokens = op.tokens, i, imax, _op; + list = list || []; + if (tokens[op.begin][TAG] === "[" && tokens[op.end][TAG] === "]") { + imax = op.end; + for (i = op.begin + 1; i < imax; ++i) { + _op = getNextOperand(tokens, i); + list = func.getVariables(_op, list); + i += _op.end - _op.begin + 1; + if (tokens[i][TAG] !== ",") { + i += 1; + } + } + } else { + if (!isDot(tokens[op.begin-1])) { + if (/^[a-z][a-zA-Z0-9_$]*$/.test(tokens[op.begin][VALUE])) { + list.push(tokens[op.begin][VALUE]); + } + } + } + return list; + }; + + var replaceNumericString = function(tokens) { + var token, str, val, i, imax = tokens.length; + for (i = 0; i < imax; ++i) { + token = tokens[i]; + if (token[TAG] === "STRING" && token[VALUE].charAt(0) === "\"") { + str = token[VALUE].substr(1, token[VALUE].length - 2); + val = numericstring.timevalue(str); + if (typeof val !== "number") { + val = numericstring.notevalue(str); + } + if (typeof val === "number") { + token[TAG] = "NUMBER"; + token[VALUE] = val.toString(); + } + } + } + return tokens; + }; + + var replaceStrictlyPrecedence = function(tokens) { + var i, token, prev, next; + for (i = tokens.length - 1; i > 0; i--) { + token = tokens[i]; + if (token[TAG] === "MATH" && (token[VALUE] !== "+" && token[VALUE] !== "-")) { + prev = getPrevOperand(tokens, i); + next = getNextOperand(tokens, i); + tokens.splice(next.end + 1, 0, [")", ")" , _]); + tokens.splice(prev.begin , 0, ["(", "(" , _]); + } + } + return tokens; + }; + + var replaceUnaryOperator = function(tokens) { + var i, token, selector, next; + for (i = tokens.length - 1; i >= 0; i--) { + token = tokens[i]; + if (token[TAG] !== "UNARY") { + continue; + } + switch (token[VALUE]) { + case "+": + selector = "__plus__"; + break; + case "-": + selector = "__minus__"; + break; + default: + continue; + } + next = getNextOperand(tokens, i); + tokens.splice( + next.end + 1, 0, + ["." , "." , _], + ["IDENTIFIER", selector, _], + ["CALL_START", "(" , _], + ["CALL_END" , ")" , _] + ); + tokens.splice(i, 1); // remove an origin operator + } + return tokens; + }; + + var replaceTextBinaryAdverb = function(code) { + return code.replace(/([+\-*\/%])(W|S|C|F|T|X|WRAP|SHORT|CLIP|FOLD|TABLE|FLAT)\1/g, function(_, selector, adverb) { + return selector + " \"#!" + adverb.charAt(0) + "\" " + selector; + }); + }; + + var replaceBinaryOperatorAdverbs = function(tokens) { + var i, t0, t1, t2; + for (i = tokens.length - 1; i >= 0; i--) { + t0 = tokens[i]; + if (t0[TAG] !== "MATH") { + continue; + } + t1 = tokens[i + 1]; + t2 = tokens[i + 2]; + if (t0[VALUE] === t2[VALUE] && /^"#![WSCFTX]"$/.test(t1[VALUE])) { + t0.adverb = t1[VALUE].charAt(3); + tokens.splice(i + 1, 2); + } + } + return tokens; + }; + + var replaceBinaryOperator = function(tokens) { + var i, token, selector, adverb, next; + for (i = tokens.length - 1; i >= 0; i--) { + token = tokens[i]; + if (token[TAG] !== "MATH") { + continue; + } + switch (token[VALUE]) { + case "+": + selector = "__add__"; + break; + case "-": + selector = "__sub__"; + break; + case "*": + selector = "__mul__"; + break; + case "/": + selector = "__div__"; + break; + case "%": + selector = "__mod__"; + break; + default: + throw new Error("Unknown MATH:" + token[VALUE]); + } + adverb = token.adverb; + next = getNextOperand(tokens, i); + tokens.splice( + i, 1, + ["." , "." , _], + ["IDENTIFIER", selector, _], + ["CALL_START", "(" , _] + ); + if (adverb) { + adverb = { + W: "WRAP", + S: "SHORT", + C: "CLIP", + F: "FOLD", + T: "TABLE", + X: "FLAT" + }[adverb]; + tokens.splice( + next.end + 3, 0, + ["," , "," , _], + ["IDENTIFIER", adverb, _], + ["CALL_END" , ")" , _] + ); + } else { + tokens.splice( + next.end + 3, 0, + ["CALL_END", ")", _] + ); + } + } + return tokens; + }; + + var replaceCompoundAssign = function(tokens) { + var i, j, token, selector, prev, next, subtokens; + for (i = tokens.length - 1; i >= 0; i--) { + token = tokens[i]; + if (token[TAG] !== "COMPOUND_ASSIGN") { + continue; + } + switch (token[VALUE]) { + case "+=": + selector = "__add__"; + break; + case "-=": + selector = "__sub__"; + break; + case "*=": + selector = "__mul__"; + break; + case "/=": + selector = "__div__"; + break; + case "%=": + selector = "__mod__"; + break; + default: + throw new Error("Unknown COMPOUND_ASSIGN:" + token[VALUE]); + } + prev = getPrevOperand(tokens, i); + next = getNextOperand(tokens, i); + + tokens.splice( + i, 1, + ["=" , "=" , _], + ["." , "." , _], + ["IDENTIFIER", selector, _], + ["CALL_START", "(" , _] + ); + tokens.splice( + next.end + 4, 0, + ["CALL_END", ")", _] + ); + subtokens = [ i + 1, 0 ]; + for (j = prev.begin; j < i; ++j) { + subtokens.push(tokens[j]); + } + tokens.splice.apply(tokens, subtokens); + } + return tokens; + }; + + var synthdef = {}; // utility functions + + var replaceSynthDefinition = function(tokens) { + var i, index, args; + + for (i = tokens.length - 1; i >= 0; i--) { + if (tokens[i][VALUE] !== "SynthDef") { + continue; + } + if (isDot(tokens[i-1])) { + continue; + } + index = i; + while (index < tokens.length) { + if (tokens[index][TAG] === "CALL_START") { + break; + } + index += 1; + } + index = indexOfFunctionStart(tokens, index+1); + if (index === -1) { + continue; + } + args = tokens[index].cc_funcRef.cc_funcParams.args; + if (args.length) { + synthdef.replaceDefaultArguments(tokens, index, args); + } + index = getNextOperand(tokens, index).end + 1; + synthdef.insertSynthDefArgumentsToAfterFunction(tokens, index, args); + } + return tokens; + }; + synthdef.replaceDefaultArguments = function(tokens, index, args) { + var i, removelen, spliceargs, imax = args.length; + removelen = indexOfParamEnd(tokens, index) - index + 1; + spliceargs = [ index, removelen ]; + + spliceargs.push(["PARAM_START", "(", _]); + for (i = 0; i < imax; i += 2) { + if (i) { + spliceargs.push([",", ",", _]); + } + spliceargs.push(["IDENTIFIER", args[i], _]); + } + spliceargs.push(["PARAM_END" , ")", _]); + + tokens.splice.apply(tokens, spliceargs); + }; + synthdef.insertSynthDefArgumentsToAfterFunction = function(tokens, index, args) { + var i, spliceargs, imax = args.length; + spliceargs = [ index, 0 ]; + spliceargs.push([",", ",", _], + ["[", "[", _]); + for (i = 0; i < imax; ++i) { + if (i) { + spliceargs.push([",", ",", _]); + } + spliceargs.push(["STRING", "'" + (args[i]||0) + "'", _]); + } + spliceargs.push(["]", "]", _]); + + tokens.splice.apply(tokens, spliceargs); + }; + + var segmented = {}; // utility functions + + var replaceSyncBlock = function(tokens) { + var i, token, index, isSyncBlock; + for (i = tokens.length - 1; i >= 0; i--) { + token = tokens[i]; + if (token[TAG] !== "IDENTIFIER") { + continue; + } + if (tokens[i+1][TAG] !== "CALL_START") { + continue; + } + switch (token[VALUE]) { + case "Task": + isSyncBlock = false; + break; + case "syncblock": + isSyncBlock = true; + break; + default: + continue; + } + index = indexOfFunctionStart(tokens, i + 2); + if (index === -1) { + continue; + } + segmented.makeSyncBlock(getNextOperand(tokens, index), isSyncBlock); + } + return tokens; + }; + + segmented.makeSyncBlock = function(op, syncblock) { + var tokens = op.tokens; + var body = tokens.splice(op.begin, op.end-op.begin+1); + var after = tokens.splice(op.begin); + var localVars, outerVars, args; + + var ref = body[0].cc_funcRef; + localVars = ref.cc_funcParams.local; + outerVars = ref.cc_funcParams.outer; + args = ref.cc_funcParams.args.filter(function(name, i) { + return !(i & 1); + }).map(function(x) { + var tokens = CoffeeScript.tokens(x); + tokens.pop(); // remove TERMINATOR + return tokens; + }); + + if (args.length) { + // remove default args + body.splice(0, indexOfParamEnd(body, 0) + 1); + } + body.splice(0, 2); // remove ->, INDENT + body.pop(); // remove OUTDENT + + var replaced = segmented.createSyncBlock(body, args, localVars, syncblock); + + for (var i = replaced.length; i--; ) { + replaced[i].cc_segmented = true; + } + push.apply(tokens, replaced); + push.apply(tokens, after); + + return op; + }; + + segmented.createSyncBlock = function(body, args, localVars, syncblock) { + var tokens = []; + if (!syncblock) { + tokens.push(["IDENTIFIER", "syncblock", _], + ["CALL_START", "(" , _]); + } + tokens.push(["->" , "->" , _], + ["INDENT" , 2 , _]); + { + segmented.insertLocalVariables(tokens, localVars); + tokens.push(["[" , "[" , _], + ["INDENT" , 2 , _]); + var numSegments = 0; + while (body.length) { + if (numSegments++) { + tokens.push(["TERMINATOR", "\n", _]); + } + segmented.beginOfSegment(tokens, args); + segmented.insertSegment(tokens, body); + segmented.endOfSegment(tokens, args); + } + tokens.push(["OUTDENT", 2 , _], + ["]" , "]", _]); + } + tokens.push(["OUTDENT" , 2 , _]); + if (!syncblock) { + tokens.push(["CALL_END", ")", _]); + } + return tokens; + }; + segmented.insertLocalVariables = function(tokens, localVars) { + if (localVars && localVars.length) { + for (var i = 0, imax = localVars.length; i < imax; i++) { + tokens.push(["IDENTIFIER", localVars[i], _], + ["=" , "=" , _]); + } + tokens.push(["UNDEFINED" , "undefined", _], + ["TERMINATOR", "\n", _]); + } + }; + segmented.beginOfSegment = function(tokens, args) { + if (args && args.length) { + tokens.push(["PARAM_START", "(", _]); + for (var i = 0, imax = args.length; i < imax; ++i) { + if (i) { + tokens.push([",", ",", _]); + } + push.apply(tokens, args[i]); + } + tokens.push(["PARAM_END" , ")", _]); + } + tokens.push(["->" , "->", _], + ["INDENT", 2 , _]); + }; + segmented.splitIdentifiers = [ "Task", "syncblock", "wait" ]; + segmented.insertSegment = function(tokens, body) { + while (body.length) { + var line = segmented.fetchLine(body); + push.apply(tokens, line); + for (var i = 0, imax = line.length; i < imax; ++i) { + var t = line[i]; + if (t[TAG] === "IDENTIFIER" && segmented.splitIdentifiers.indexOf(t[VALUE]) !== -1) { + return; + } + } + } + }; + segmented.endOfSegment = function(tokens) { + tokens.push(["OUTDENT", 2, _]); + }; + segmented.fetchLine = function(tokens) { + var depth = 0; + for (var i = 0, imax = tokens.length; i < imax; ++i) { + switch (tokens[i][TAG]) { + case "(": case "{": case "[": + case "CALL_START": case "PARAM_START": case "INDEX_START": + depth += 1; + break; + case "]": case "}": case ")": + case "CALL_END": case "PARAM_END": case "INDEX_END": + depth -= 1; + break; + case "TERMINATOR": + if (depth === 0) { + return tokens.splice(0, i + 1); + } + break; + case "INDENT": + depth += 1; + break; + case "OUTDENT": + if (depth === 0) { + return tokens.splice(0, i); + } + depth -= 1; + break; + } + } + return tokens.splice(0); + }; + + var replaceGlobalVariables = function(tokens) { + var i, token; + for (i = tokens.length - 1; i >= 0; i--) { + token = tokens[i]; + if (token[TAG] !== "IDENTIFIER") { + continue; + } + if (!/^\$[a-z][a-zA-Z0-9_]*$/.test(token[VALUE])) { + continue; + } + if (isColon(tokens[i+1])) { + continue; // { NotGlobal:"dict key is not global" } + } + if (isDot(tokens[i-1])) { + continue; // this.is.NotGlobal, @isNotGlobal + } + tokens.splice( + i, 1, + ["IDENTIFIER", "global", _], + ["." , "." , _], + ["IDENTIFIER", token[VALUE].substr(1), _] + ); + } + return tokens; + }; + + var replaceCCVariables = function(tokens) { + var i, token; + for (i = tokens.length - 1; i >= 0; i--) { + token = tokens[i]; + if (token[TAG] !== "IDENTIFIER") { + continue; + } + if (!cc.global.hasOwnProperty(token[VALUE])) { + continue; + } + if (isColon(tokens[i+1])) { + continue; + } + if (isDot(tokens[i-1])) { + continue; + } + tokens.splice( + i, 0, + ["IDENTIFIER", "cc", _], + ["." , "." , _] + ); + } + return tokens; + }; + + var wrapWholeCode = function(tokens) { + tokens.unshift(["(" , "(" , _], + ["PARAM_START", "(" , _], + ["IDENTIFIER" , "global" , _], + ["," , "," , _], + ["IDENTIFIER", "cc" , _], + ["PARAM_END" , ")" , _], + ["->" , "->" , _], + ["INDENT" , 2 , _]); + tokens.push(["OUTDENT" , 2 , _], + [")" , ")" , _], + ["." , "." , _], + ["IDENTIFIER", "call" , _], + ["CALL_START", "(" , _], + ["IDENTIFIER", "cc" , _], + ["." , "." , _], + ["IDENTIFIER", "__context__", _], + ["," , "," , _], + ["THIS" , "this" , _], + ["." , "." , _], + ["IDENTIFIER", "self" , _], + ["LOGIC" , "||" , _], + ["IDENTIFIER", "global" , _], + ["," , "," , _], + ["IDENTIFIER", "cc" , _], + ["CALL_END" , ")" , _]); + return tokens; + }; + + var getConditionedTokens = function(code) { + var tokens; + code = replaceTextBinaryAdverb(code); + tokens = CoffeeScript.tokens(code); + if (tokens.length) { + tokens = replaceNumericString(tokens); + tokens = detectFunctionParameters(tokens); + tokens = detectPlusMinusOperator(tokens); + tokens = replaceBinaryOperatorAdverbs(tokens); + } + return tokens; + }; + + var CoffeeCompiler = (function() { + function CoffeeCompiler() { + } + CoffeeCompiler.prototype.tokens = function(code) { + var tokens = getConditionedTokens(code); + if (tokens.length) { + tokens = replaceGlobalVariables(tokens); + tokens = replaceStrictlyPrecedence(tokens); + tokens = replaceUnaryOperator(tokens); + tokens = replaceBinaryOperator(tokens); + tokens = replaceCompoundAssign(tokens); + tokens = replaceSynthDefinition(tokens); + tokens = replaceSyncBlock(tokens); + tokens = replaceCCVariables(tokens); + tokens = wrapWholeCode(tokens); + } + return tokens; + }; + CoffeeCompiler.prototype.compile = function(code) { + return CoffeeScript.nodes(this.tokens(code)).compile({bare:true}).trim(); + }; + return CoffeeCompiler; + })(); + + cc.createCompiler = function() { + return new CoffeeCompiler(); + }; + + module.exports = { + CoffeeCompiler: CoffeeCompiler, + + // private methods + indexOfParamEnd : indexOfParamEnd, + indexOfFunctionStart: indexOfFunctionStart, + formatArgument : formatArgument, + getPrevOperand : getPrevOperand, + getNextOperand : getNextOperand, + detectPlusMinusOperator : detectPlusMinusOperator, + revertPlusMinusOperator : revertPlusMinusOperator, + detectFunctionParameters: detectFunctionParameters, + + replaceTextBinaryAdverb : replaceTextBinaryAdverb, + replaceBinaryOperatorAdverbs: replaceBinaryOperatorAdverbs, + replaceNumericString : replaceNumericString, + replaceStrictlyPrecedence: replaceStrictlyPrecedence, + replaceUnaryOperator : replaceUnaryOperator, + replaceBinaryOperator : replaceBinaryOperator, + replaceCompoundAssign : replaceCompoundAssign, + replaceSynthDefinition : replaceSynthDefinition, + replaceSyncBlock : replaceSyncBlock, + replaceGlobalVariables : replaceGlobalVariables, + replaceCCVariables : replaceCCVariables, + wrapWholeCode : wrapWholeCode + }; + +}); +define('cc/common/numericstring', function(require, exports, module) { + + var cc = require("../cc"); + + var timevalue = function(str) { + var result = null; + var freq; + if (str.charAt(0) === "~") { + freq = true; + str = str.substr(1); + } + do { + result = hz(str); + if (result !== null) { + break; + } + result = time(str); + if (result !== null) { + break; + } + result = hhmmss(str); + if (result !== null) { + break; + } + result = samples(str); + if (result !== null) { + break; + } + result = note(str); + if (result !== null) { + break; + } + result = beat(str); + if (result !== null) { + break; + } + result = ticks(str); + } while (false); + + if (result !== null) { + if (!freq) { + return result; + } + return result === 0 ? 0 : 1 / result; + } + return str; + }; + + var hz = function(str) { + var m = /^(\d+(?:\.\d+)?)hz$/i.exec(str); + if (m) { + return +m[1] === 0 ? 0 : 1 / +m[1]; + } + return null; + }; + var time = function(str) { + var m = /^(\d+(?:\.\d+)?)(min|sec|m|msec)s?$/i.exec(str); + if (m) { + switch (m[2]) { + case "min" : return (+m[1]) * 60; + case "sec" : return (+m[1]); + case "msec": case "m": return (+m[1]) / 1000; + } + } + return null; + }; + + var hhmmss = function(str) { + var x = 0, m = /^(?:([1-9]?[0-9]*):)?(?:([0-9]*):)?([0-9]+)(?:\.(\d{1,3}))?$/.exec(str); + if (m) { + if (m[1] !== undefined && m[2] === undefined) { + m[2] = m[1]; + m[1] = 0; + } + x += (m[1]|0) * 3600; + x += (m[2]|0) * 60; + x += (m[3]|0); + x += (((m[4]||"")+"00").substr(0, 3)|0) / 1000; + return x; + } + return null; + }; + + var samples = function(str) { + var m = /^(\d+)samples(?:\/(\d+)hz)?$/i.exec(str); + if (m) { + return m[1] / ((m[2]|0) || cc.sampleRate); + } + return null; + }; + + var calcNote = function(bpm, len, dot) { + var x = (60 / bpm) * (4 / len); + var mul = 1; + if (0 <= dot && dot <= 3) { + x *= [1, 1.5, 1.75, 1.875][dot]; + } else { + for (var i = 1; i < dot; ++i) { + mul += Math.pow(0.5, i); + } + x *= mul; + } + return x; + }; + var note = function(str) { + var m = /^bpm([1-9]\d+(?:\.\d+)?)\s*l([1-9]\d*)(\.*)$/i.exec(str); + if (m) { + return calcNote(+m[1], +m[2], m[3].length); + } + return null; + }; + + var calcBeat = function(bpm, measure, beat, ticks) { + var x = (measure * 4 + beat) * 480 + ticks; + return (60 / bpm) * (x / 480); + }; + var beat = function(str) { + var m = /^bpm([1-9]\d+(?:\.\d+)?)\s*(\d+)\.(\d+).(\d{1,3})$/i.exec(str); + if (m) { + return calcBeat(+m[1], +m[2], +m[3], +m[4]); + } + return null; + }; + + var calcTicks = function(bpm, ticks) { + return 60 / bpm * ticks / 480; + }; + var ticks = function(str) { + var m = /^bpm([1-9]\d+(?:\.\d+)?)\s*(\d+)ticks$/i.exec(str); + if (m) { + return calcTicks(+m[1], +m[2]); + } + return null; + }; + + var notevalue = function(str) { + var m = /^([A-Ga-g])([-+#b])?(\d)$/.exec(str); + if (m) { + var midi = {C:0,D:2,E:4,F:5,G:7,A:9,B:11}[m[1]] + (m[3] * 12) + 12; + var acc = m[2]; + if (acc === "-" || acc === "b") { + midi--; + } else if (acc === "+" || acc === "#") { + midi++; + } + return midi; + } + return str; + }; + + module.exports = { + hz : hz, + time : time, + hhmmss : hhmmss, + samples: samples, + note : note, + beat : beat, + ticks : ticks, + calcNote : calcNote, + calcBeat : calcBeat, + calcTicks: calcTicks, + timevalue: timevalue, + notevalue: notevalue + }; + +}); +define('cc/client/client-worker', function(require, exports, module) { + + var cc = require("../cc"); + var extend = require("../common/extend"); + + var SynthClientWorkerImpl = (function() { + function SynthClientWorkerImpl(client, opts) { + cc.opmode = "worker"; + this.strmLength = 1024; + this.bufLength = 64; + + cc.SynthClientImpl.call(this, client, opts); + + var that = this; + this.lang = cc.createWebWorker(cc.coffeeColliderPath); + this.lang.onmessage = function(e) { + that.recvFromLang(e.data); + }; + } + extend(SynthClientWorkerImpl, cc.SynthClientImpl); + + return SynthClientWorkerImpl; + })(); + + cc.createSynthClientWorkerImpl = function(client, opts) { + return new SynthClientWorkerImpl(client, opts); + }; + + module.exports = {}; + +}); +define('cc/common/extend', function(require, exports, module) { + + var extend = function(child, parent) { + for (var key in parent) { + if (parent.hasOwnProperty(key)) { + child[key] = parent[key]; + } + } + /*jshint validthis:true */ + function ctor() { + this.constructor = child; + } + /*jshint validthis:false */ + ctor.prototype = parent.prototype; + /*jshint newcap:false */ + child.prototype = new ctor(); + /*jshint newcap:true */ + return child; + }; + + module.exports = extend; + +}); +define('cc/client/client-nodejs', function(require, exports, module) { + + var cc = require("../cc"); + var extend = require("../common/extend"); + + var SynthClientNodeJSImpl = (function() { + function SynthClientNodeJSImpl(client, opts) { + cc.opmode = "nodejs"; + this.strmLength = 4096; + this.bufLength = 64; + + cc.SynthClientImpl.call(this, client, opts); + + this.api = null; + } + extend(SynthClientNodeJSImpl, cc.SynthClientImpl); + + return SynthClientNodeJSImpl; + })(); + + cc.createSynthClientNodeJSImpl = function(client, opts) { + return new SynthClientNodeJSImpl(client, opts); + }; + + module.exports = {}; + +}); +define('cc/client/client-socket', function(require, exports, module) { + + var cc = require("../cc"); + var extend = require("../common/extend"); + + var SynthClientSocketImpl = (function() { + function SynthClientSocketImpl(client, opts) { + cc.opmode = "socket"; + this.strmLength = 4096; + this.bufLength = 64; + + cc.SynthClientImpl.call(this, client, opts); + + var that = this; + this.lang = cc.createWebWorker(cc.coffeeColliderPath + "#socket"); + this.lang.onmessage = function(e) { + that.recvFromLang(e.data); + }; + + client.socket = { + open: function() { + that.sendToLang([ "/socket/open", opts.socket ]); + }, + close: function() { + that.sendToLang([ "/socket/close" ]); + }, + send: function(msg) { + that.sendToLang([ "/socket/sendToServer", msg ]); + } + }; + } + extend(SynthClientSocketImpl, cc.SynthClientImpl); + + return SynthClientSocketImpl; + })(); + + cc.createSynthClientSocketImpl = function(client, opts) { + return new SynthClientSocketImpl(client, opts); + }; + + module.exports = {}; + +}); +define('cc/lang/lang', function(require, exports, module) { + + var cc = require("./cc"); + var pack = require("../common/pack").pack; + var random = require("../common/random"); + var commands = {}; + + var SynthLang = (function() { + function SynthLang() { + this.klassName = "SynthLang"; + this.sampleRate = 0; + this.channels = 0; + this.strmLength = 0; + this.bufLength = 0; + this.rootNode = cc.createLangRootNode(); + this.taskManager = cc.createTaskManager(); + this.timelineResult = []; + this.phase = 0; + this.random = new random.Random(); + this.currentTime = 0; + this.callbacks = []; + + this.extendCommands(commands); + } + + SynthLang.prototype.sendToClient = function() { + throw "SynthLang#sendToClient: should be overridden[" + cc.opmode + "]"; + }; + SynthLang.prototype.sendToClientWithTransferable = function() { + throw "SynthLang#sendToClientWithTransferable: should be overridden[" + cc.opmode + "]"; + }; + SynthLang.prototype.recvFromClient = function(msg) { + if (msg) { + var func = commands[msg[0]]; + if (func) { + func.call(this, msg); + } + } + }; + SynthLang.prototype.sendToServer = function() { + throw "SynthLang#sendToServer: should be overridden[" + cc.opmode + "]"; + }; + SynthLang.prototype.recvFromServer = function(msg) { + if (msg instanceof Float32Array) { + this.sendToClient(msg); + } else { + var func = commands[msg[0]]; + if (func) { + func.call(this, msg); + } else { + throw new Error("Unknown command: " + msg[0]); + } + } + }; + SynthLang.prototype.pushToTimeline = function(cmd) { + this.timelineResult.push(cmd); + }; + SynthLang.prototype.play = function(msg) { + this.currentTimeIncr = (this.bufLength / this.sampleRate) * 1000; + this.taskManager.start(this.currentTimeIncr); + this.sendToServer(msg); + }; + SynthLang.prototype.pause = function(msg) { + this.sendToServer(msg); + }; + SynthLang.prototype.reset = function(msg) { + this.currentTime = 0; + cc.resetNode(); + cc.resetBuiltin(); + cc.resetMessage(); + this.taskManager.reset(); + this.sendToServer(msg); + }; + SynthLang.prototype.requestBuffer = function(path, callback) { + if (!(typeof path === "string" && typeof callback === "function")) { + return; + } + var callbackId = this.setCallback(callback); + this.sendToClient(["/buffer/request", path, callbackId]); + }; + SynthLang.prototype.process = function() { + throw "SynthLang#process: should be overridden"; + }; + SynthLang.prototype.extendCommands = function() { + }; + SynthLang.prototype.setCallback = function(callback) { + var callbackId = this.callbacks.length; + this.callbacks[callbackId] = callback; + return callbackId; + }; + SynthLang.prototype.getCallback = function(callbackId) { + var callback = this.callbacks[callbackId]; + this.callbacks[callbackId] = null; + return callback; + }; + + return SynthLang; + })(); + + + commands["/connected"] = function(msg) { + if (cc.opmode !== "nodejs") { + msg.push(Object.keys(cc.global)); + } + this.sendToClient(msg); + }; + commands["/init"] = function(msg) { + this.sampleRate = msg[1]|0; + this.channels = msg[2]|0; + this.sendToServer(msg); + }; + commands["/play"] = function(msg) { + this.play(msg); + }; + commands["/played"] = function(msg) { + this.sendToClient(msg); + }; + commands["/pause"] = function(msg) { + this.pause(msg); + }; + commands["/paused"] = function(msg) { + this.sendToClient(msg); + }; + commands["/reset"] = function(msg) { + this.reset(msg); + }; + commands["/process"] = function() { + this.process(); + }; + commands["/execute"] = function(msg) { + var execId = msg[1]; + var code = msg[2]; + var append = msg[3]; + var callback = msg[4]; + if (!append) { + this.reset(["/reset"]); + } + if (cc.global !== global) { + global.cc = cc.global; + } + global.cc.__context__ = { + version: cc.version + }; + var result = eval.call(global, code); + if (callback) { + this.sendToClient(["/executed", execId, pack(result)]); + } + }; + commands["/buffer/response"] = function(msg) { + var buffer = msg[1]; + var callbackId = msg[2]; + var callback = this.getCallback(callbackId); + if (callback) { + callback(buffer); + } + }; + commands["/send"] = function(msg) { + var args = msg[1]; + cc.global.Message.emit.apply(cc.global.Message, args); + }; + + commands["/b_get"] = function(msg) { + var callbackId = msg[1]; + var callback = this.getCallback(callbackId); + if (callback) { + callback(msg[2]); + } + }; + commands["/b_getn"] = function(msg) { + var callbackId = msg[1]; + var callback = this.callbacks[callbackId]; + if (callback) { + callback(msg.slice(2)); + this.callbacks[callbackId] = null; + } + }; + commands[1] = function(binary) { + var callbackId = (binary[3] << 8) + binary[2]; + var callback = this.getCallback(callbackId); + if (callback) { + callback(binary); + } + }; + + cc.SynthLang = SynthLang; + + cc.createSynthLang = function() { + switch (cc.opmode) { + case "worker": + return cc.createWorkerSynthLang(); + case "nodejs": + return cc.createNodeJSSynthLang(); + case "socket": + return cc.createSocketSynthLang(); + } + throw new Error("A SynthLang is not defined for: " + cc.opmode); + }; + + // TODO: moved + require("./array"); + require("./boolean"); + require("./buffer"); + require("./builtin"); + require("./bus"); + require("./date"); + require("./env"); + require("./function"); + require("./message"); + require("./mix"); + require("./node"); + require("./number"); + require("./object"); + require("./pattern"); + require("./ref"); + require("./scale"); + require("./string"); + require("./syncblock"); + require("./synthdef"); + require("./task"); + require("./ugen"); + require("./basic_ugen"); + require("../plugins/installer"); + + require("./lang-worker"); + require("./lang-nodejs"); + require("./lang-socket"); + + Object.keys(cc.ugen.specs).forEach(function(name) { + cc.ugen.register(name, cc.ugen.specs[name]); + }); + + cc.global.System = {}; + cc.global.System.currentTime = function() { + return cc.lang.currentTime; + }; + + module.exports = {}; + +}); +define('cc/lang/cc', function(require, exports, module) { + + module.exports = require("../cc"); + +}); +define('cc/common/random', function(require, exports, module) { + + var Random = (function() { + function Random(seed) { + if (typeof seed !== "number") { + seed = Date.now(); + } + seed = new Uint32Array([seed]); + seed[0] += ~(seed[0] << 15); + seed[0] ^= seed[0] >>> 10; + seed[0] += seed[0] << 3; + seed[0] ^= seed[0] >>> 6; + seed[0] += ~(seed[0] << 11); + seed[0] ^= seed[0] >>> 16; + + this.s1 = new Uint32Array([1243598713 ^ seed[0]]); + this.s2 = new Uint32Array([3093459404 ^ seed[0]]); + this.s3 = new Uint32Array([1821928721 ^ seed[0]]); + + if (this.s1[0] < 2) { + this.s1[0] = 1243598713; + } + if (this.s2[0] < 8) { + this.s2[0] = 3093459404; + } + if (this.s3[0] < 16) { + this.s3[0] = 1821928721; + } + } + + Random.prototype.trand = function() { + this.s1[0] = ((this.s1[0] & 4294967294) << 12) ^ (((this.s1[0] << 13) ^ this.s1[0]) >>> 19); + this.s2[0] = ((this.s2[0] & 4294967288) << 4) ^ (((this.s2[0] << 2) ^ this.s2[0]) >>> 25); + this.s3[0] = ((this.s3[0] & 4294967280) << 17) ^ (((this.s3[0] << 3) ^ this.s3[0]) >>> 11); + return this.s1[0] ^ this.s2[0] ^ this.s3[0]; + }; + + var _i = new Uint32Array(1); + var _f = new Float32Array(_i.buffer); + + Random.prototype.next = function() { + _i[0] = 0x3F800000 | (this.trand() >>> 9); + return _f[0] - 1; + }; + + return Random; + })(); + + module.exports = { + Random: Random + }; + +}); +define('cc/lang/array', function(require, exports, module) { + + var cc = require("./cc"); + var fn = require("./fn"); + var ops = require("../common/ops"); + var utils = require("./utils"); + var slice = [].slice; + + // common methods + fn.defineProperty(Array.prototype, "copy", function() { + return this.slice(); + }); + + fn.defineProperty(Array.prototype, "clone", fn(function(deep) { + if (deep) { + return this.map(function(x) { return x && x.clone ? x.clone(true) : x; }); + } + return this.slice(); + }).defaults(ops.COMMONS.clone).build()); + + fn.defineProperty(Array.prototype, "dup", fn(function(n, deep) { + var a = new Array(n|0); + for (var i = 0, imax = a.length; i < imax; ++i) { + a[i] = this.clone(deep); + } + return a; + }).defaults(ops.COMMONS.dup).build()); + + fn.defineProperty(Array.prototype, "value", function() { + return this; + }); + + fn.defineProperty(Array.prototype, "valueArray", function() { + return this; + }); + + fn.defineProperty(Array.prototype, "do", function(func) { + var list = this; + if (cc.instanceOfSyncBlock(func)) { + if (cc.currentSyncBlockHandler) { + cc.currentSyncBlockHandler.__sync__(func, cc.createTaskArgumentsArray(list)); + return this; + } + } + list.forEach(func); + return this; + }); + + fn.defineProperty(Array.prototype, "wait", function(logic) { + var list = this; + if (cc.currentTask) { + cc.currentTask.__wait__(cc.createTaskWaitTokenArray(list, logic)); + } + return this; + }); + + fn.defineProperty(Array.prototype, "asUGenInput", function() { + return this.map(utils.asUGenInput); + }); + + fn.defineProperty(Array.prototype, "asString", function() { + return "[ " + this.map(utils.asString).join(", ") + " ]"; + }); + + // unary operator methods + ["__plus__","__minus__"].concat(Object.keys(ops.UNARY_OPS)).forEach(function(selector) { + fn.defineProperty(Array.prototype, selector, function() { + return this.map(function(x) { + return x[selector](); + }); + }); + }); + + // binary operator methods + var foldAt = function(list, index) { + var len = list.length; + index = index % (len * 2 - 2); + if (index >= len) { + index = 2 * (len - 1) - index; + } + return list[index]; + }; + var calc_with_adverb = function(selector, a, b, adverb) { + var sort = a.length - b.length; + switch (adverb) { + case 1: + if (sort > 0) { + a.splice(b.length); + } else if (sort < 0) { + b.splice(a.length); + } + break; + case 2: + if (sort > 0) { + return a.map(function(a, i) { + return a[selector](foldAt(b, i)); + }); + } else if (sort < 0) { + return b.map(function(b, i) { + return foldAt(a, i)[selector](b); + }); + } + break; + case 3: + case 4: + var table = a.map(function(a) { + return b.map(function(b) { + return a[selector](b); + }); + }); + return (adverb === 4) ? utils.flatten(table) : table; + } + if (a.length === b.length) { + return a.map(function(a, index) { + return a[selector](b[index]); + }); + } else if (a.length > b.length) { + return a.map(function(a, index) { + return a[selector](b[index % b.length]); + }); + } else { + return b.map(function(b, index) { + return a[index % a.length][selector](b); + }); + } + }; + + cc.global.SHORT = 1; + cc.global.FOLD = 2; + cc.global.TABLE = 3; + cc.global.FLAT = 4; + + ["__add__","__sub__","__mul__","__div__","__mod__"].concat(Object.keys(ops.BINARY_OPS)).forEach(function(selector) { + var ugenSelector; + if (ops.ALIASES.hasOwnProperty(selector)) { + ugenSelector = ops.ALIASES[selector]; + } else { + ugenSelector = selector; + } + fn.defineProperty(Array.prototype, selector, function(b, adverb) { + if (Array.isArray(b)) { + return calc_with_adverb(selector, this, b, adverb); + } else if (cc.instanceOfUGen(b)) { + return this.map(function(a) { + return cc.createBinaryOpUGen(ugenSelector, a, b); + }); + } + return this.map(function(a) { + return a[selector](b); + }); + }); + }); + + // arity operators + Object.keys(ops.ARITY_OPS).forEach(function(selector) { + fn.defineProperty(Array.prototype, selector, fn(function() { + var args = slice.call(arguments); + return this.map(function(_in) { + if (_in[selector]) { + return _in[selector].apply(_in, args); + } + return _in; + }); + }).defaults(ops.ARITY_OPS[selector]).multiCall().build()); + }); + + // chord + var midichord = fn(function(name, inversion) { + return this.map(function(x) { + if (typeof x === "number") { + return x.midichord(name, inversion); + } + return x; + }); + }).defaults("name=\"\",inversion=0").multiCall().build(); + + fn.defineProperty(Array.prototype, "midichord", midichord); + fn.defineProperty(Array.prototype, "chord" , midichord); // deprecate + + var cpschord = fn(function(name, inversion) { + return this.map(function(x) { + if (typeof x === "number") { + return x.cpschord(name, inversion); + } + return x; + }); + }).defaults("name=\"\",inversion=0").multiCall().build(); + + fn.defineProperty(Array.prototype, "cpschord", cpschord); + fn.defineProperty(Array.prototype, "chordcps", cpschord); // deprecate + + var ratiochord = fn(function(name, inversion) { + return this.map(function(x) { + if (typeof x === "number") { + return x.ratiochord(name, inversion); + } + return x; + }); + }).defaults("name=\"\",inversion=0").multiCall().build(); + + fn.defineProperty(Array.prototype, "ratiochord", ratiochord); + fn.defineProperty(Array.prototype, "chordratio", ratiochord); // deprecate + + // Array methods + // utils + var cc_func = function(func) { + if (typeof func === "function") { + return func; + } + return function() { + return func; + }; + }; + var drand = function() { + return cc.lang.random.next(); + }; + var irand = function(n) { + return ((cc.lang.random.next() * n)|0); + }; + + // class methods + fn.defineProperty(Array, "series", fn(function(size, start, step) { + size |= 0; + var a = new Array(size); + var value = start; + for (var i = 0, imax = a.length; i < imax; i++) { + a[i] = value; + value += step; + } + return a; + }).defaults("size=0,start=0,step=1").build()); + + fn.defineProperty(Array, "geom", fn(function(size, start, grow) { + size |= 0; + var a = new Array(size); + var value = start; + for (var i = 0, imax = a.length; i < imax; i++) { + a[i] = value; + value *= grow; + } + return a; + }).defaults("size=0,start=1,grow=2").build()); + + fn.defineProperty(Array, "fill", fn(function(size, func) { + size |= 0; + var a = new Array(size); + func = cc_func(func); + for (var i = 0, imax = a.length; i < imax; ++i) { + a[i] = func(i); + } + return a; + }).defaults("size=0,func=0").build()); + + fn.defineProperty(Array, "fill2D", fn(function(rows, cols, func) { + rows |= 0; + cols |= 0; + func = cc_func(func); + var a, a2, row, col; + a = new Array(rows); + for (row = 0; row < rows; ++row) { + a2 = a[row] = new Array(cols); + for (col = 0; col < cols; ++col) { + a2[col] = func(row, col); + } + } + return a; + }).defaults("rows=0,cols=0,func=0").build()); + + fn.defineProperty(Array, "fillND", (function() { + var fillND = function(dimensions, func, args) { + var n, a, argIndex, i; + n = dimensions[0]; + a = []; + argIndex = args.length; + args = args.concat(0); + if (dimensions.length <= 1) { + for (i = 0; i < n; ++i) { + args[argIndex] = i; + a.push(func.apply(null, args)); + } + } else { + dimensions = dimensions.slice(1); + for (i = 0; i < n; ++i) { + args[argIndex] = i; + a.push(fillND(dimensions, func, args)); + } + } + return a; + }; + return fn(function(dimensions, func) { + return fillND(dimensions, cc_func(func), []); + }).defaults("dimensions=[],func=0").build(); + })()); + + fn.defineProperty(Array, "fib", fn(function(size, x, y) { + var a = new Array(size|0); + for (var t, i = 0, imax = a.length; i < imax; i++) { + a[i] = y; + t = y; + y = x + y; + x = t; + } + return a; + }).defaults("size=0,a=0,b=1").build()); + + fn.defineProperty(Array, "rand", fn(function(size, minVal, maxVal) { + var a = new Array(size|0); + for (var i = 0, imax = a.length; i < imax; i++) { + a[i] = minVal.rrand(maxVal); + } + return a; + }).defaults("size=0,minVal=0,maxVal=1").build()); + + fn.defineProperty(Array, "rand2", fn(function(size, val) { + var a = new Array(size|0); + for (var i = 0, imax = a.length; i < imax; i++) { + a[i] = val.rand2(); + } + return a; + }).defaults("size=0,val=1").build()); + + fn.defineProperty(Array, "linrand", fn(function(size, minVal, maxVal) { + var a = new Array(size|0); + for (var i = 0, imax = a.length; i < imax; i++) { + a[i] = minVal.linrand(maxVal); + } + return a; + }).defaults("size=0,minVal=0,maxVal=1").build()); + + fn.defineProperty(Array, "exprand", fn(function(size, minVal, maxVal) { + var a = new Array(size|0); + for (var i = 0, imax = a.length; i < imax; i++) { + a[i] = minVal.exprand(maxVal); + } + return a; + }).defaults("size=0,minVal=0.001,maxVal=1").build()); + + fn.defineProperty(Array, "interpolation", fn(function(size, start, end) { + if (size === 1) { + return [start]; + } + var a = new Array(size|0); + var step = (end - start) / (size - 1); + for (var i = 0, imax = a.length; i < imax; i++) { + a[i] = start + (i * step); + } + return a; + }).defaults("size=0,start=0,end=1").build()); + + + // instance methods + var ifold = function(index, len) { + var len2 = len * 2 - 2; + index = (index|0) % len2; + if (index < 0) { + index += len2; + } + if (len <= index) { + index = len2 - index; + } + return index; + }; + + fn.defineProperty(Array.prototype, "size", function() { + return this.length; + }); + + var minItem = function(func) { + var i, imax, val, minVal, minItem; + if (func) { + func = cc_func(func); + minItem = this[0]; + minVal = func(this[0], 0); + for (i = 1, imax = this.length; i < imax; ++i) { + val = func(this[i], i); + if (val < minVal) { + minItem = this[i]; + minVal = val; + } + } + } else { + minItem = this[0]; + for (i = 1, imax = this.length; i < imax; ++i) { + if (this[i] < minItem) { + minItem = this[i]; + } + } + } + return minItem; + }; + + fn.defineProperty(Array.prototype, "minItem" , minItem); + fn.defineProperty(Array.prototype, "minValue", minItem); + + var maxItem = function(func) { + var i, imax, val, maxVal, maxItem; + if (func) { + func = cc_func(func); + maxItem = this[0]; + maxVal = func(this[0], 0); + for (i = 1, imax = this.length; i < imax; ++i) { + val = func(this[i], i); + if (maxVal < val) { + maxItem = this[i]; + maxVal = val; + } + } + } else { + maxItem = this[0]; + for (i = 1, imax = this.length; i < imax; ++i) { + if (maxItem < this[i]) { + maxItem = this[i]; + } + } + } + return maxItem; + }; + + fn.defineProperty(Array.prototype, "maxItem" , maxItem); + fn.defineProperty(Array.prototype, "maxValue", maxItem); + + fn.defineProperty(Array.prototype, "at", fn(function(index) { + return this[index|0]; + }).multiCall().build()); + + fn.defineProperty(Array.prototype, "clipAt", fn(function(index) { + return this[Math.max(0, Math.min(index, this.length-1))|0]; + }).multiCall().build()); + + fn.defineProperty(Array.prototype, "wrapAt", fn(function(index) { + index = (index|0) % this.length; + if (index < 0) { + index += this.length; + } + return this[index]; + }).multiCall().build()); + + fn.defineProperty(Array.prototype, "foldAt", fn(function(index) { + return this[ifold(index, this.length)]; + }).multiCall().build()); + + fn.defineProperty(Array.prototype, "blendAt", fn(function(index, method) { + switch (method) { + case "clipAt": case "wrapAt": case "foldAt": + break; + default: + method = "clipAt"; + } + var i = index|0; + var x0 = this[method](i ); + var x1 = this[method](i+1); + return x0 + Math.abs(index - i) * (x1 - x0); + }).multiCall().build()); + + fn.defineProperty(Array.prototype, "put", function(index, item) { + if (Array.isArray(index)) { + index.forEach(function(index) { + this.put(index, item); + }, this); + } else { + index |= 0; + if (0 <= index && index < this.length) { + this[index] = item; + } + } + return this; + }); + + fn.defineProperty(Array.prototype, "clipPut", function(index, item) { + if (Array.isArray(index)) { + index.forEach(function(index) { + this.clipPut(index, item); + }, this); + } else { + this[Math.max(0, Math.min(index, this.length-1))|0] = item; + } + return this; + }); + + fn.defineProperty(Array.prototype, "wrapPut", function(index, item) { + if (Array.isArray(index)) { + index.forEach(function(index) { + this.wrapPut(index, item); + }, this); + } else { + index = (index|0) % this.length; + if (index < 0) { + index += this.length; + } + this[index] = item; + } + return this; + }); + + fn.defineProperty(Array.prototype, "foldPut", function(index, item) { + if (Array.isArray(index)) { + index.forEach(function(index) { + this.foldPut(index, item); + }, this); + } else { + this[ifold(index, this.length)] = item; + } + return this; + }); + + fn.defineProperty(Array.prototype, "insert", function(index, item) { + this.splice(Math.max(0, index), 0, item); + return this; + }); + + fn.defineProperty(Array.prototype, "swap", function(i, j) { + i |= 0; + j |= 0; + if (0 <= i && i < this.length && 0 <= j && j < this.length) { + var t = this[i]; + this[i] = this[j]; + this[j] = t; + } + return this; + }); + + fn.defineProperty(Array.prototype, "clipSwap", function(i, j) { + i = Math.max(0, Math.min(i, this.length-1))|0; + j = Math.max(0, Math.min(j, this.length-1))|0; + return this.swap(i, j); + }); + + fn.defineProperty(Array.prototype, "wrapSwap", function(i, j) { + i = (i|0) % this.length; + if (i < 0) { + i += this.length; + } + j = (j|0) % this.length; + if (j < 0) { + j += this.length; + } + return this.swap(i, j); + }); + + fn.defineProperty(Array.prototype, "foldSwap", function(i, j) { + i = ifold(i, this.length); + j = ifold(j, this.length); + return this.swap(i, j); + }); + + fn.defineProperty(Array.prototype, "sum", function() { + var value = 0; + for (var i = 0, imax = this.length; i < imax; ++i) { + value = value.__add__(this[i]); + } + return value; + }); + + fn.defineProperty(Array.prototype, "normalize", fn(function(min, max) { + var minItem = this.minItem(); + var maxItem = this.maxItem(); + return this.map(function(item) { + return item.linlin(minItem, maxItem, min, max); + }); + }).defaults("min=0,max=1").build()); + + fn.defineProperty(Array.prototype, "normalizeSum", function() { + var sum = this.sum(); + return this.map(function(item) { + return item / sum; + }); + }); + + fn.defineProperty(Array.prototype, "mirror", function() { + var size = this.length * 2 - 1; + if (size < 2) { + return this.slice(0); + } + var i, j, imax, a = new Array(size); + for (i = 0, imax = this.length; i < imax; ++i) { + a[i] = this[i]; + } + for (j = imax - 2, imax = size; i < imax; ++i, --j) { + a[i] = this[j]; + } + return a; + }); + + fn.defineProperty(Array.prototype, "mirror1", function() { + var size = this.length * 2 - 2; + if (size < 2) { + return this.slice(0); + } + var i, j, imax, a = new Array(size); + for (i = 0, imax = this.length; i < imax; ++i) { + a[i] = this[i]; + } + for (j = imax - 2, imax = size; i < imax; ++i, --j) { + a[i] = this[j]; + } + return a; + }); + + fn.defineProperty(Array.prototype, "mirror2", function() { + var size = this.length * 2; + if (size < 2) { + return this.slice(0); + } + var i, j, imax, a = new Array(size); + for (i = 0, imax = this.length; i < imax; ++i) { + a[i] = this[i]; + } + for (j = imax - 1, imax = size; i < imax; ++i, --j) { + a[i] = this[j]; + } + return a; + }); + + fn.defineProperty(Array.prototype, "stutter", fn(function(n) { + n = Math.max(0, n|0); + var a = new Array(this.length * n); + for (var i = 0, j = 0, imax = this.length; i < imax; ++i) { + for (var k = 0; k < n; ++k, ++j) { + a[j] = this[i]; + } + } + return a; + }).defaults("n=2").build()); + + fn.defineProperty(Array.prototype, "rotate", fn(function(n) { + n |= 0; + var a = new Array(this.length); + var size = a.length; + n %= size; + if (n < 0) { + n += size; + } + for (var i = 0, j = n; i < size; ++i) { + a[j] = this[i]; + if (++j >= size) { + j = 0; + } + } + return a; + }).defaults("n=1").build()); + + fn.defineProperty(Array.prototype, "sputter", fn(function(probability, maxlen) { + var a = [], i = 0, j = 0, size = this.length; + while (i < size && j < maxlen) { + a[j++] = this[i]; + if (drand() < probability) { + i += 1; + } + } + return a; + }).defaults("probability=0.25,maxlen=100").build()); + + fn.defineProperty(Array.prototype, "clipExtend", function(size) { + size = Math.max(0, size|0); + if (this.length < size) { + var a = new Array(size); + for (var i = 0, imax = this.length; i< imax; ++i) { + a[i] = this[i]; + } + for (var b = a[i-1]; i < size; ++i) { + a[i] = b; + } + return a; + } else { + return this.slice(0, size); + } + }); + + fn.defineProperty(Array.prototype, "wrapExtend", function(size) { + size = Math.max(0, size|0); + if (this.length < size) { + var a = new Array(size); + for (var i = 0; i < size; ++i) { + a[i] = this[i % this.length]; + } + return a; + } else { + return this.slice(0, size); + } + }); + + fn.defineProperty(Array.prototype, "foldExtend", function(size) { + size = Math.max(0, size|0); + if (this.length < size) { + var a = new Array(size); + for (var i = 0; i < size; ++i) { + a[i] = this[ifold(i, this.length)]; + } + return a; + } else { + return this.slice(0, size); + } + }); + + fn.defineProperty(Array.prototype, "resamp0", function(newSize) { + var factor = (this.length - 1) / (newSize - 1); + var a = new Array(newSize); + for (var i = 0; i < newSize; ++i) { + a[i] = this[Math.round(i * factor)]; + } + return a; + }); + + fn.defineProperty(Array.prototype, "resamp1", function(newSize) { + var factor = (this.length - 1) / (newSize - 1); + var a = new Array(newSize); + for (var i = 0; i < newSize; ++i) { + a[i] = this.blendAt(i * factor); + } + return a; + }); + + fn.defineProperty(Array.prototype, "scramble", function() { + var a = this.slice(); + var i, j, k, m, temp; + k = a.length; + for (i = 0, m = k; i < k - 1; ++i, --m) { + j = i + irand(m); + temp = a[i]; + a[i] = a[j]; + a[j] = temp; + } + return a; + }); + + fn.defineProperty(Array.prototype, "choose", function() { + return this[irand(this.length)]; + }); + + module.exports = {}; + +}); +define('cc/lang/fn', function(require, exports, module) { + + var cc = require("./cc"); + var utils = require("./utils"); + var ops = require("../common/ops"); + var slice = [].slice; + + var fn = (function() { + function Fn(func) { + this.func = func; + this.def = null; + this.multi = 0; + } + Fn.prototype.defaults = function(def) { + this.def = def; + return this; + }; + Fn.prototype.multiCall = function(num) { + this.multi = num === undefined ? Infinity : num; + return this; + }; + Fn.prototype.build = function() { + var func = this.func; + var keys = []; + var vals = []; + if (this.def) { + this.def.split(",").forEach(function(items) { + items = items.trim().split("="); + keys.push( items[0].trim()); + if (items.length === 2) { + if (items[1] === "Infinity") { + vals.push(Infinity); + } else { + vals.push(JSON.parse(items[1])); + } + } else { + vals.push(undefined); + } + }); + } + var ret = func; + var multi = this.multi; + if (multi === Infinity) { + if (this.def) { + ret = function() { + var args = slice.call(arguments); + args = resolve_args(keys, vals, slice.call(arguments)); + if (containsArray(args)) { + return utils.flop(args).map(function(items) { + return ret.apply(this, items); + }, this); + } + return func.apply(this, args); + }; + } else { + ret = function() { + var args = slice.call(arguments); + if (containsArray(args)) { + return utils.flop(args).map(function(items) { + return ret.apply(this, items); + }, this); + } + return func.apply(this, args); + }; + } + } else if (multi > 0) { + if (this.def) { + ret = function() { + var args = slice.call(arguments); + args = resolve_args(keys, vals, slice.call(arguments)); + var args0 = slice.call(args, 0, multi); + if (containsArray(args0)) { + var args1 = slice.call(args, multi); + return utils.flop(args0).map(function(items) { + return ret.apply(this, items.concat(args1)); + }, this); + } + return func.apply(this, args); + }; + } else { + ret = function() { + var args0 = slice.call(arguments, 0, multi); + + if (containsArray(args0)) { + var args1 = slice.call(arguments, multi); + return utils.flop(args0).map(function(items) { + return ret.apply(this, items.concat(args1)); + }, this); + } + return func.apply(this, arguments); + }; + } + } else if (multi < 0) { + if (this.def) { + ret = function() { + var args = slice.call(arguments); + args = resolve_args(keys, vals, slice.call(arguments)); + var args1 = slice.call(args, multi); + if (containsArray(args1)) { + var args0 = slice.call(args, 0, multi); + return utils.flop(args1).map(function(items) { + return ret.apply(this, args0.concat(items)); + }, this); + } + return func.apply(this, args); + }; + } else { + ret = function() { + var args1 = slice.call(arguments, multi); + if (containsArray(args1)) { + var args0 = slice.call(arguments, 0, multi); + return utils.flop(args1).map(function(items) { + return ret.apply(this, args0.concat(items)); + }, this); + } + return func.apply(this, arguments); + }; + } + } else if (this.def) { + ret = function() { + return func.apply(this, resolve_args(keys, vals, slice.call(arguments))); + }; + } + return ret; + }; + var containsArray = function(list) { + for (var i = 0, imax = list.length; i < imax; ++i) { + if (Array.isArray(list[i])) { + return true; + } + } + return false; + }; + var resolve_args = function(keys, vals, given) { + var dict; + var args = vals.slice(); + if (utils.isDict(given[given.length - 1])) { + dict = given.pop(); + Object.keys(dict).forEach(function(key) { + var index = keys.indexOf(key); + if (index !== -1) { + args[index] = dict[key]; + } + }); + } + for (var i = 0, imax = Math.min(given.length, args.length); i < imax; ++i) { + args[i] = given[i]; + } + if (dict && keys.length <= args.length) { + if (utils.isDict(vals[vals.length - 1])) { + args.splice(args.length-1, 1, dict); + } + } + return args; + }; + return function(func) { + return new Fn(func); + }; + })(); + + fn.defineProperty = function(object, selector, func) { + Object.defineProperty(object, selector, { + configurable: true, + enumerable : false, + writable : true, + value : func + }); + }; + + fn.defineBinaryProperty = function(object, selector, func) { + var ugenSelector; + if (ops.ALIASES.hasOwnProperty(selector)) { + ugenSelector = ops.ALIASES[selector]; + } else { + ugenSelector = selector; + } + Object.defineProperty(object, selector, { + configurable: true, + enumerable : false, + writable : true, + value : function(b) { + if (Array.isArray(b)) { + return b.map(function(b) { + return this[selector](b); + }, this); + } else if (cc.instanceOfUGen(b)) { + return cc.createBinaryOpUGen(ugenSelector, this, b); + } + return func.call(this, b); + } + }); + }; + + fn.defineArityProperty = function(object, selector, func) { + Object.defineProperty(object, selector, { + configurable: true, + enumerable : false, + writable : true, + value : function() { + var args = slice.call(arguments); + if (args.some(cc.instanceOfUGen)) { + return func.apply(cc.global.DC(0, this), args); + } + return func.apply(this, args); + } + }); + }; + + module.exports = fn; + +}); +define('cc/lang/utils', function(require, exports, module) { + + var cc = require("./cc"); + + var isDict = function(obj) { + return !!(obj && obj.constructor === Object); + }; + + var asRate = function(obj) { + if (Array.isArray(obj)) { + return obj.reduce(function(rate, obj) { + return Math.max(rate, asRate(obj)); + }, 0); + } + if (obj) { + switch (obj.rate) { + case 0: case 1: case 2: case 3: + return obj.rate; + } + } + return 0; + }; + + var asRateString = function(obj) { + switch (obj) { + case 0: return "scalar"; + case 1: return "control"; + case 2: return "audio"; + case 3: return "demand"; + } + return "unknown"; + }; + + var asNumber = function(obj) { + obj = +obj; + if (isNaN(obj)) { + obj = 0; + } + return obj; + }; + + var asString = function(obj) { + if (obj === null) { + return "null"; + } else if (obj === undefined) { + return "undefined"; + } else if (obj.asString) { + return obj.asString(); + } + return obj.toString(); + }; + + var asArray = function(obj) { + if (obj === null || obj === undefined) { + obj = []; + } else if (!Array.isArray(obj)) { + obj = [ obj ]; + } + return obj; + }; + + var asUGenInput = function(obj) { + if (obj === null || obj === undefined) { + return 0; + } else if (typeof obj.asUGenInput === "function") { + return obj.asUGenInput(); + } else if (cc.instanceOfUGen(obj)) { + return obj; + } else if (Array.isArray(obj)) { + return obj.map(asUGenInput); + } + obj = +obj; + if (isNaN(obj)) { + obj = 0; + } + return obj; + }; + + var flop = function(list) { + var maxSize = list.reduce(function(len, sublist) { + return Math.max(len, Array.isArray(sublist) ? sublist.length : 1); + }, 0); + var result = new Array(maxSize); + var length = list.length; + if (length) { + for (var i = 0; i < maxSize; ++i) { + var sublist = result[i] = new Array(length); + for (var j = 0; j < length; ++j) { + sublist[j] = Array.isArray(list[j]) ? list[j][i % list[j].length] : list[j]; + } + } + } + return result; + }; + + var flopDeep = function(list, rank) { + if (rank <= 1) { + return flop(list); + } + var maxsize = maxSizeAtDepth(list, rank); + var result = new Array(maxsize); + for (var i = 0; i < maxsize; ++i) { + result[i] = wrapAtDepth(list, rank, i); + } + return result; + }; + + var flat = (function() { + var _flat = function(that, list) { + var i, imax; + for (i = 0, imax = that.length; i < imax; ++i) { + if (Array.isArray(that[i])) { + list = _flat(that[i], list); + } else { + list.push(that[i]); + } + } + return list; + }; + return function(list) { + return _flat(list, []); + }; + })(); + + var flatten = (function() { + var _flatten = function(list, result) { + for (var i = 0, imax = list.length; i < imax; ++i) { + if (Array.isArray(list[i])) { + result = _flatten(list[i], result); + } else { + result.push(list[i]); + } + } + return result; + }; + return function(list) { + return _flatten(list, []); + }; + })(); + + var clump = function(list, groupSize) { + var result = []; + var sublist = []; + for (var i = 0, imax = list.length; i < imax; ++i) { + sublist.push(list[i]); + if (sublist.length >= groupSize) { + result.push(sublist); + sublist = []; + } + } + if (sublist.length) { + result.push(sublist); + } + return result; + }; + + var lace = function(list, length) { + var a = new Array(length); + var v, wrap = list.length; + for (var i = 0; i < length; ++i) { + v = list[i % wrap]; + a[i] = v[ ((i / wrap)|0) % v.length ]; + } + return a; + }; + + var bubble = function(list, depth, levels) { + if (depth <= 0) { + if (levels <= 1) { + return [ list ]; + } + return [ bubble(list, depth, levels-1) ]; + } + return list.map(function(list) { + return bubble(list, depth-1, levels); + }); + }; + + var unbubble = function(list, depth, levels) { + if (!Array.isArray(list)) { + return list; + } + if (depth <= 0) { + if (list.length > 1) { + return list; + } + if (levels <= 1) { + return list[0] || []; + } + return unbubble(list[0], depth, levels-1); + } + return list.map(function(list) { + return unbubble(list, depth-1, 1); + }); + }; + + var maxSizeAtDepth = function(list, rank) { + var maxsize = 0; + if (rank === 0) { + return list.length; + } + for (var i = 0, imax = list.length; i < imax; ++i) { + var sz, sublist = list[i]; + if (Array.isArray(sublist)) { + sz = maxSizeAtDepth(sublist, rank - 1); + } else { + sz = 1; + } + if (sz > maxsize) { + maxsize = sz; + } + } + return maxsize; + }; + + var wrapExtend = function(list, size) { + if (size < list.length) { + return list.slice(0, size); + } + var a = new Array(size); + for (var i = 0; i < size; ++i) { + a[i] = list[i % list.length]; + } + return a; + }; + + var wrapAtDepth = function(list, rank, index) { + if (rank === 0) { + return list[index % list.length]; + } + return list.map(function(item) { + if (Array.isArray(item)) { + return wrapAtDepth(item, rank - 1, index); + } else { + return item; + } + }); + }; + + var filledArray = function(size, value) { + var a = new Array(size); + for (var i = 0; i < size; ++i) { + a[i] = value; + } + return a; + }; + + var lang_onmessage = function(e) { + var msg = e.data; + if (msg instanceof Uint8Array) { + cc.lang.sendToServer(msg); + } else { + cc.lang.recvFromClient(msg); + } + }; + + module.exports = { + isDict : isDict, + asRate : asRate, + asRateString: asRateString, + asNumber : asNumber, + asString : asString, + asArray : asArray, + asUGenInput : asUGenInput, + flop : flop, + flopDeep: flopDeep, + flat : flat, + flatten : flatten, + clump : clump, + lace : lace, + bubble : bubble, + unbubble: unbubble, + maxSizeAtDepth: maxSizeAtDepth, + + wrapExtend : wrapExtend, + wrapAtDepth: wrapAtDepth, + filledArray: filledArray, + + lang_onmessage: lang_onmessage + }; + +}); +define('cc/common/ops', function(require, exports, module) { + + var UNARY_OPS = {}; + var UNARY_OPS_MAP = []; + "neg not isNil notNil bitNot abs asFloat asInt ceil floor frac sign squared cubed sqrt exp reciprocal midicps cpsmidi midiratio ratiomidi dbamp ampdb octcps cpsoct log log2 log10 sin cos tan asin acos atan sinh cosh tanh rand rand2 linrand bilinrand sum3rand distort softclip coin digitvalue silence thru rectWindow hanWindow welWindow triWindow ramp scurve numunaryselectors num tilde pi to_i half twice".split(" ").forEach(function(selector, i) { + UNARY_OPS[selector] = i; + UNARY_OPS_MAP[i] = selector; + }); + + var BINARY_OPS = {}; + var BINARY_OPS_MAP = []; + "+ - * / / % eq ne lt gt le ge min max bitAnd bitOr bitXor lcm gcd round roundUp trunc atan2 hypot hypotApx pow leftShift rightShift unsignedRightShift fill ring1 ring2 ring3 ring4 difsqr sumsqr sqrsum sqrdif absdif thresh amclip scaleneg clip2 excess fold2 wrap2 firstarg randrange exprandrange numbinaryselectors roundDown".split(" ").forEach(function(selector, i) { + BINARY_OPS[selector] = i; + BINARY_OPS_MAP[i] = selector; + }); + + var ARITY_OPS = { + madd : "mul=1,add=0", + range : "lo=0,hi=1", + exprange : "lo=0.01,hi=1", + curverange: "lo=0.01,hi=1,curve=-4", + unipolar : "mul=1", + bipolar : "mul=1", + clip : "lo=1,hi=1", + fold : "lo=1,hi=1", + wrap : "lo=1,hi=1", + blend : "that=0,blendFrac=0.5", + lag : "t1=0.1,t2", + lag2 : "t1=0.1,t2", + lag3 : "t1=0.1,t2", + lagud : "lagTimeU=0.1,lagTimeD=0.1", + lag2ud : "lagTimeU=0.1,lagTimeD=0.1", + lag3ud : "lagTimeU=0.1,lagTimeD=0.1", + varlag : "time=0.1,curvature=0,warp=5,start=0", + slew : "up=1,down=1", + linlin : "inMin=0,inMax=1,outMin=1,outMax=2,clip=\"minmax\"", + linexp : "inMin=0,inMax=1,outMin=1,outMax=2,clip=\"minmax\"", + explin : "inMin=0,inMax=1,outMin=1,outMax=2,clip=\"minmax\"", + expexp : "inMin=0,inMax=1,outMin=1,outMax=2,clip=\"minmax\"", + lincurve : "inMin=0,inMax=1,outMin=0,outMax=1,curve=-4,clip=\"minmax\"", + curvelin : "inMin=0,inMax=1,outMin=0,outMax=1,curve=-4,clip=\"minmax\"", + bilin : "inCenter=0.5,inMin=0,inMax=1,outCenter=0.5,outMin=0,outMax=1,clip=\"minmax\"", + rrand : "num=1", + exprand : "num=1" + }; + + var COMMONS = { + copy : "", + clone: "deep=false", + dup : "n=2,deep=false", + value: "", + valueArray: "", + "do" : "", + wait : "", + asUGenInput: "" + }; + + var ALIASES = { + __plus__ : "num", + __minus__: "neg", + __add__ : "+", + __sub__ : "-", + __mul__ : "*", + __div__ : "/", + __mod__ : "%" + }; + + module.exports = { + UNARY_OPS : UNARY_OPS, + UNARY_OPS_MAP : UNARY_OPS_MAP, + BINARY_OPS : BINARY_OPS, + BINARY_OPS_MAP: BINARY_OPS_MAP, + ARITY_OPS : ARITY_OPS, + ALIASES : ALIASES, + COMMONS : COMMONS + }; + +}); +define('cc/lang/boolean', function(require, exports, module) { + + var cc = require("./cc"); + var fn = require("./fn"); + var ops = require("../common/ops"); + var slice = [].slice; + + // common methods + fn.defineProperty(Boolean.prototype, "copy", function() { + return this; + }); + + fn.defineProperty(Boolean.prototype, "clone", fn(function() { + return this; + }).defaults(ops.COMMONS.clone).build()); + + fn.defineProperty(Boolean.prototype, "dup", fn(function(n) { + var a = new Array(n|0); + for (var i = 0, imax = a.length; i < imax; ++i) { + a[i] = this; + } + return a; + }).defaults(ops.COMMONS.dup).build()); + + fn.defineProperty(Boolean.prototype, "value", function() { + return this; + }); + + fn.defineProperty(Boolean.prototype, "valueArray", function() { + return this; + }); + + fn.defineProperty(Boolean.prototype, "do", function(func) { + if (this) { + if (cc.instanceOfSyncBlock(func)) { + if (cc.currentSyncBlockHandler) { + cc.currentSyncBlockHandler.__sync__(func, cc.createTaskArgumentsOnce(this)); + return this; + } + } + func(this, 0); + } + return this; + }); + + fn.defineProperty(Boolean.prototype, "wait", function() { + var flag = this; + if (flag && cc.currentTask) { + cc.currentTask.__wait__(cc.createTaskWaitTokenBoolean(flag)); + } + return this; + }); + + fn.defineProperty(Boolean.prototype, "asUGenInput", function() { + return this ? 1 : 0; + }); + + fn.defineProperty(Boolean.prototype, "asString", function() { + return this ? "true" : "false"; + }); + + // unary operator methods + ["__plus__","__minus__"].concat(Object.keys(ops.UNARY_OPS)).forEach(function(selector) { + fn.defineProperty(Boolean.prototype, selector, function() { + return (this ? 1 : 0)[selector](); + }); + }); + + // binary operator methods + ["__add__","__sub__","__mul__","__div__","__mod__"].concat(Object.keys(ops.BINARY_OPS)).forEach(function(selector) { + fn.defineProperty(Boolean.prototype, selector, function(b) { + return (this ? 1 : 0)[selector](b); + }); + }); + + // arity operators + Object.keys(ops.ARITY_OPS).forEach(function(selector) { + fn.defineProperty(Boolean.prototype, selector, fn(function() { + var args = slice.call(arguments); + return (0)[selector].apply(this ? 1 : 0, args); + }).defaults(ops.ARITY_OPS[selector]).multiCall().build()); + }); + + module.exports = {}; + +}); +define('cc/lang/buffer', function(require, exports, module) { + + var cc = require("./cc"); + var fn = require("./fn"); + var utils = require("./utils"); + var extend = require("../common/extend"); + var slice = [].slice; + + var Buffer = (function() { + var bufnum = 0; + function Buffer(frames, channels) { + this.klassName = "Buffer"; + + this.bufnum = bufnum++; + this.frames = frames |0; + this.channels = channels|0; + this.sampleRate = cc.lang.sampleRate; + this.path = null; + + cc.lang.pushToTimeline([ + "/b_new", this.bufnum, this.frames, this.channels + ]); + } + extend(Buffer, cc.Object); + + Buffer.prototype.free = function() { + cc.lang.pushToTimeline([ + "/b_free", this.bufnum + ]); + return this; + }; + + Buffer.prototype.zero = function() { + cc.lang.pushToTimeline([ + "/b_zero", this.bufnum + ]); + return this; + }; + + Buffer.prototype.set = function() { + var args = slice.call(arguments); + if (args.length) { + cc.lang.pushToTimeline([ + "/b_set", this.bufnum, args + ]); + } + return this; + }; + Buffer.prototype.setn = Buffer.prototype.set; + + Buffer.prototype.get = function(index, action) { + index = index|0; + if (typeof action === "function") { + var callbackId = cc.lang.setCallback(action); + cc.lang.pushToTimeline([ + "/b_get", this.bufnum, index, callbackId + ]); + } + return this; + }; + + Buffer.prototype.getn = function(index, count, action) { + index = index|0; + count = count|0; + if (typeof action === "function") { + var callbackId = cc.lang.setCallback(action); + cc.lang.pushToTimeline([ + "/b_getn", this.bufnum, index, count, callbackId + ]); + } + return this; + }; + + Buffer.prototype.normalize = function(newmax, asWaveable) { + cc.lang.pushToTimeline([ + "/b_gen", this.bufnum, "normalize", asWaveable ? 2 : 0, utils.asNumber(newmax) + ]); + return this; + }; + + Buffer.prototype.fill = function() { + cc.lang.pushToTimeline([ + "/b_fill", this.bufnum, slice.call(arguments) + ]); + return this; + }; + + Buffer.prototype.copyData = fn(function(buf, dstStartAt, srcStartAt, numSamples) { + buf = buf.bufnum|0; + cc.lang.pushToTimeline([ + "/b_gen", this.bufnum, "copy", 0, buf, dstStartAt, srcStartAt, numSamples + ]); + return this; + }).defaults("buf=0,dstStartAt=0,srcStartAt=0,numSamples=-1").build(); + + var calcFlag = function(normalize, asWavetable, clearFirst) { + return (normalize ? 1 : 0) + (asWavetable ? 2 : 0) + (clearFirst ? 4 : 0); + }; + + Buffer.prototype.sine1 = fn(function(amps, normalize, asWavetable, clearFirst) { + amps = utils.asArray(amps); + var flags = calcFlag(normalize, asWavetable, clearFirst); + cc.lang.pushToTimeline( + ["/b_gen", this.bufnum, "sine1", flags].concat(amps) + ); + return this; + }).defaults("amps=[],normalize=true,asWavetable=true,clearFirst=true").build(); + + Buffer.prototype.sine2 = fn(function(freqs, amps, normalize, asWavetable, clearFirst) { + freqs = utils.asArray(freqs); + amps = utils.asArray(amps); + var flags = calcFlag(normalize, asWavetable, clearFirst); + var len = Math.max(freqs.length, amps.length) * 2; + cc.lang.pushToTimeline( + ["/b_gen", this.bufnum, "sine2", flags].concat(utils.lace([freqs, amps], len)) + ); + return this; + }).defaults("freqs=[],amps=[],normalize=true,asWavetable=true,clearFirst=true").build(); + + Buffer.prototype.sine3 = fn(function(freqs, amps, phases, normalize, asWavetable, clearFirst) { + freqs = utils.asArray(freqs); + amps = utils.asArray(amps); + phases = utils.asArray(phases); + var flags = calcFlag(normalize, asWavetable, clearFirst); + var len = Math.max(freqs.length, amps.length, phases.length) * 3; + cc.lang.pushToTimeline( + ["/b_gen", this.bufnum, "sine3", flags].concat(utils.lace([freqs, amps, phases], len)) + ); + return this; + }).defaults("freqs=[],amps=[],phases=[],normalize=true,asWavetable=true,clearFirst=true").build(); + + Buffer.prototype.cheby = fn(function(amplitudes, normalize, asWavetable, clearFirst) { + amplitudes = utils.asArray(amplitudes); + var flags = calcFlag(normalize, asWavetable, clearFirst); + cc.lang.pushToTimeline( + ["/b_gen", this.bufnum, "cheby", flags].concat(amplitudes) + ); + return this; + }).defaults("amplitudes=[],normalize=true,asWavetable=true,clearFirst=true").build(); + + Buffer.prototype.asUGenInput = function() { + return this.bufnum; + }; + + Buffer.prototype.asString = function() { + return "Buffer(" + this.bufnum + ", " + this.frames + ", " + this.channels + ", " + this.sampleRate + ", " + this.path + ")"; + }; + + return Buffer; + })(); + + var sendBufferData = function(buffer, data) { + var uint8 = new Uint8Array(16 + data.samples.length * 4); + var int16 = new Uint16Array(uint8.buffer); + var int32 = new Uint32Array(uint8.buffer); + var f32 = new Float32Array(uint8.buffer); + int16[0] = 1; + int16[1] = buffer.bufnum; + int16[3] = data.channels; + int32[2] = data.sampleRate; + int32[3] = data.frames; + f32.set(data.samples, 4); + cc.lang.sendToServer(uint8); + }; + + cc.global.Buffer = fn(function(numFrames, numChannels, source) { + if (Array.isArray(numFrames)) { + numFrames = new Float32Array(numFrames); + } + if (numFrames instanceof Float32Array) { + source = { + sampleRate: cc.lang.sampleRate, + channels : 1, + frames : numFrames.length, + samples : numFrames + }; + numFrames = source.frames; + numChannels = source.channels; + } + var buffer = new Buffer(numFrames, numChannels); + if (source) { + sendBufferData(buffer, source); + } + return buffer; + }).defaults("numFrames=0,numChannels=1,source").build(); + + cc.global.Buffer["new"] = cc.global.Buffer; + + cc.global.Buffer.read = fn(function(path, startFrame, numFrames) { + if (typeof path !== "string") { + throw new TypeError("Buffer.Read: path should be a string."); + } + var buffer = new Buffer(); + cc.lang.requestBuffer(path, function(binary) { + var channels = (binary[7] << 8) + binary[6]; + var sampleRate = (binary[11] << 24) + (binary[10] << 16) + (binary[ 9] << 8) + binary[ 8]; + var frames = (binary[15] << 24) + (binary[14] << 16) + (binary[13] << 8) + binary[12]; + var samples = new Float32Array(binary.buffer, 16); + + var data = { + sampleRate: sampleRate, + channels : channels, + frames : frames, + samples : samples + }; + + buffer.sampleRate = data.sampleRate; + buffer.path = path; + + samples = data.samples; + startFrame = Math.max( 0, Math.min(startFrame|0, data.frames)); + numFrames = Math.max(-1, Math.min(numFrames |0, data.frames - startFrame)); + var numChannels = data.channels; + + if (startFrame === 0) { + if (numFrames !== -1) { + data.samples = new Float32Array( + samples.buffer, 16, numFrames * numChannels + ); + buffer.frames = numFrames; + data.frames = numFrames; + } + } else { + if (numFrames === -1) { + data.samples = new Float32Array( + samples.buffer, 16 + startFrame * numChannels * 4 + ); + buffer.frames = data.samples.length / numChannels; + } else { + data.samples = new Float32Array( + samples.buffer, 16 + startFrame * numChannels * 4, numFrames * numChannels + ); + buffer.frames = numFrames; + } + data.frames = buffer.frames; + } + sendBufferData(buffer, data); + }); + return buffer; + }).defaults("path,startFrame=0,numFrames=-1").build(); + + cc.instanceOfBuffer = function(obj) { + return obj instanceof Buffer; + }; + + module.exports = { + Buffer: Buffer + }; + +}); +define('cc/lang/builtin', function(require, exports, module) { + + var cc = require("./cc"); + var pack = require("../common/pack").pack; + var slice = [].slice; + + cc.global.console = {}; + + cc.global.console.log = function() { + if (cc.lang) { + cc.lang.sendToClient(["/console/log", slice.call(arguments).map(pack)]); + } + }; + + + var timerIdCache = []; + cc.global.setInterval = function(func, delay) { + var id = setInterval(func, delay); + timerIdCache.push(id); + return id; + }; + + cc.global.setTimeout = function(func, delay) { + var id = setTimeout(func, delay); + timerIdCache.push(id); + return id; + }; + + cc.global.clearInterval = function(id) { + clearInterval(id); + var index = timerIdCache.indexOf(id); + if (index !== -1) { + timerIdCache.splice(index, 1); + } + }; + + cc.global.clearTimeout = function(id) { + clearTimeout(id); + var index = timerIdCache.indexOf(id); + if (index !== -1) { + timerIdCache.splice(index, 1); + } + }; + + cc.resetBuiltin = function() { + timerIdCache.splice(0).forEach(function(timerId) { + clearInterval(timerId); + clearTimeout(timerId); + }); + }; + + module.exports = {}; + +}); +define('cc/lang/bus', function(require, exports, module) { + + var cc = require("./cc"); + var fn = require("./fn"); + var extend = require("../common/extend"); + var utils = require("./utils"); + + var bus_allocator = { + audio:2, control:0 + }; + + var Bus = (function() { + function Bus(rate, index, numChannels) { + this.rate = rate; + this.index = index; + this.numChannels = numChannels; + } + extend(Bus, cc.Object); + + Bus.prototype.asUGenInput = function() { + return this.index; + }; + + Bus.prototype.asString = function() { + return "Bus(" + utils.asRateString(this.rate) + ", " + this.index + ", " + this.numChannels + ")"; + }; + + return Bus; + })(); + + cc.global.Bus = function() { + return cc.global.Bus.control(1); + }; + + cc.global.Bus["new"] = cc.global.Bus; + + cc.global.Bus.control = fn(function(numChannels) { + var index = bus_allocator.control; + if (typeof numChannels === "number") { + if (128 < bus_allocator.control + numChannels) { + throw new Error("Bus: failed to get a control bus allocated."); + } + bus_allocator.control += numChannels; + } else { + numChannels = 0; + } + return new Bus(1, index, numChannels); + }).defaults("numChannels=1").build(); + + cc.global.Bus.audio = fn(function(numChannels) { + var index = bus_allocator.audio; + if (typeof numChannels === "number") { + if (16 < bus_allocator.audio + numChannels) { + throw new Error("Bus: failed to get an audio bus allocated."); + } + bus_allocator.audio += numChannels; + } else { + numChannels = 0; + } + return new Bus(2, index, numChannels); + }).defaults("numChannels=1").build(); + + cc.instanceOfBus = function(obj) { + return obj instanceof Bus; + }; + + cc.resetBus = function() { + bus_allocator.audio = 2; + bus_allocator.control = 0; + }; + + module.exports = { + Bus: Bus + }; + +}); +define('cc/lang/date', function(require, exports, module) { + + var cc = require("./cc"); + var fn = require("./fn"); + var ops = require("../common/ops"); + var slice = [].slice; + + // common methods + fn.defineProperty(Date.prototype, "copy", function() { + return new Date(+this); + }); + + fn.defineProperty(Date.prototype, "clone", fn(function() { + return new Date(+this); + }).defaults(ops.COMMONS.clone).build()); + + fn.defineProperty(Date.prototype, "dup", fn(function(n) { + var a = new Array(n|0); + for (var i = 0, imax = a.length; i < imax; ++i) { + a[i] = this; + } + return a; + }).defaults(ops.COMMONS.dup).build()); + + fn.defineProperty(Date.prototype, "value", function() { + return this; + }); + + fn.defineProperty(Date.prototype, "valueArray", function() { + return this; + }); + + fn.defineProperty(Date.prototype, "do", function(func) { + var flag = Date.now() > (+this); + if (flag) { + if (cc.instanceOfSyncBlock(func)) { + if (cc.currentSyncBlockHandler) { + cc.currentSyncBlockHandler.__sync__(func, cc.createTaskArgumentsOnce(this)); + return this; + } + } + func(this, 0); + } + return this; + }); + + fn.defineProperty(Date.prototype, "wait", function() { + var flag = Date.now() > (+this); + if (flag && cc.currentTask) { + cc.currentTask.__wait__(cc.createTaskWaitTokenDate(this)); + } + return this; + }); + + fn.defineProperty(Date.prototype, "asUGenInput", function() { + throw new Error("Date can't cast to a UGen."); + }); + + fn.defineProperty(Date.prototype, "asString", function() { + return this.toString(); + }); + + // unary operator methods + ["__plus__","__minus__"].concat(Object.keys(ops.UNARY_OPS)).forEach(function(selector) { + fn.defineProperty(Date.prototype, selector, function() { + return (+this)[selector](); + }); + }); + + // binary operator methods + ["__add__","__sub__","__mul__","__div__","__mod__"].concat(Object.keys(ops.BINARY_OPS)).forEach(function(selector) { + fn.defineProperty(Date.prototype, selector, function(b) { + return (+this)[selector](b); + }); + }); + + // arity operators + Object.keys(ops.ARITY_OPS).forEach(function(selector) { + fn.defineProperty(Date.prototype, selector, fn(function() { + var args = slice.call(arguments); + return (0)[selector].apply(+this, args); + }).defaults(ops.ARITY_OPS[selector]).multiCall().build()); + }); + + module.exports = {}; + +}); +define('cc/lang/env', function(require, exports, module) { + + var cc = require("./cc"); + var extend = require("../common/extend"); + var fn = require("./fn"); + var utils = require("./utils"); + + // utility functions + var shapeNames = { + step: 0, + lin : 1, linear : 1, + exp : 2, exponential: 2, + sin : 3, sine : 3, + wel : 4, welch : 4, + sqr : 6, squared : 6, + cub : 7, cubed : 7 + }; + + var shapeNumber = function(shapeName) { + if (typeof shapeName === "number") { + return 5; + } + return shapeNames[shapeName] || 0; + }; + + var curveValue = function(curve) { + if (typeof curve === "number") { + return curve; + } + return 0; + }; + + var Env = (function() { + function Env(levels, times, curve, releaseNode, loopNode, offset) { + this._levels = levels; + this._times = utils.wrapExtend(times, levels.length - 1); + this._curve = curve || "lin"; + this._releaseNode = releaseNode; + this._loopNode = loopNode; + this._offset = offset; + this._array = null; + } + extend(Env, cc.Object); + + Env.prototype.ar = fn(function(doneAction, gate, timeScale, mul, add) { + return cc.global.EnvGen(2, this, gate, mul, add, timeScale, doneAction); + }).defaults("doneAction=0,gate=1,timeScale=1,mul=1,add=0").multiCall().build(); + + Env.prototype.kr = fn(function(doneAction, gate, timeScale, mul, add) { + return cc.global.EnvGen(1, this, gate, mul, add, timeScale, doneAction); + }).defaults("doneAction=0,gate=1,timeScale=1,mul=1,add=0").multiCall().build(); + + Env.prototype.asMultichannelArray = function() { + if (!this._array) { + this._array = this.asArray(); + } + return this._array; + }; + + Env.prototype.asArray = function() { + var contents; + var levelArray = this._levels; + var timeArray = this._times; + var curvesArray = this._curve; + var size = this._times.length; + if (!Array.isArray(curvesArray)) { + curvesArray = [ curvesArray ]; + } + var releaseNode = typeof this._releaseNode === "number" ? this._releaseNode : -99; + var loopNode = typeof this._loopNode === "number" ? this._loopNode : -99; + + var wrapAt; + contents = [ + levelArray[0], size, releaseNode, loopNode + ]; + for (var i = 0; i < size; ++i) { + wrapAt = i % curvesArray.length; + contents.push( + levelArray[i+1], timeArray[i], shapeNumber(curvesArray[wrapAt]), curveValue (curvesArray[wrapAt]) + ); + } + return utils.flop(contents); + }; + + return Env; + })(); + + cc.global.Env = fn(function(levels, times, curve, releaseNode, loopNode, offset) { + if (!Array.isArray(levels)) { + levels = [ 0, 1, 0 ]; + } + if (!Array.isArray(times)) { + times = [ 1, 1 ]; + } + return new Env(levels, times, curve, releaseNode, loopNode, offset); + }).defaults("levels=0,times=0,curve=\"lin\",releaseNode,loopNode,offset=0").build(); + + cc.global.Env["new"] = cc.global.Env; + + cc.global.Env.triangle = fn(function(dur, level) { + dur = dur.__mul__(0.5); + return new Env( + [0, level, 0], + [dur, dur] + ); + }).defaults("dur=1,level=1").build(); + + cc.global.Env.sine = fn(function(dur, level) { + dur = dur.__mul__(0.5); + return new Env( + [0, level, 0], + [dur, dur], + "sine" + ); + }).defaults("dur=1,level=1").build(); + + cc.global.Env.perc = fn(function(attackTime, releaseTime, level, curve) { + return new Env( + [0, level, 0], + [attackTime, releaseTime], + curve + ); + }).defaults("attackTime=0.01,releaseTime=1,level=1,curve=-4").build(); + + cc.global.Env.linen = fn(function(attackTime, sustainTime, releaseTime, level, curve) { + return new Env( + [0, level, level, 0], + [attackTime, sustainTime, releaseTime], + curve + ); + }).defaults("attackTime=0.01,sustainTime=1,releaseTime=1,level=1,curve=\"lin\"").build(); + + cc.global.Env.xyc = function() { + throw "not implemented"; + }; + + cc.global.Env.pairs = function() { + throw "not implemented"; + }; + + cc.global.Env.cutoff = fn(function(releaseTime, level, curve) { + var curveNo = shapeNumber(curve); + var releaseLevel = curveNo === 2 ? 1e-05 : 0; + return new Env( + [level, releaseLevel], + [releaseTime], + curve, + 0 + ); + }).defaults("releaseTime=0.1,level=1,curve=\"lin\"").build(); + + cc.global.Env.dadsr = fn(function(delayTime, attackTime, decayTime, sustainLevel, releaseTime, peakLevel, curve, bias) { + return new Env( + [0, 0, peakLevel, peakLevel.__mul__(sustainLevel), 0].__add__(bias), + [delayTime, attackTime, decayTime, releaseTime], + curve, + 3 + ); + }).defaults("delayTime=0.1,attackTime=0.01,decayTime=0.3,sustainLevel=0.5,releaseTime=1,peakLevel=1,curve=-4,bias=0").build(); + + cc.global.Env.adsr = fn(function(attackTime, decayTime, sustainLevel, releaseTime, peakLevel, curve, bias) { + return new Env( + [0, peakLevel, peakLevel.__mul__(sustainLevel), 0].__add__(bias), + [attackTime, decayTime, releaseTime], + curve, + 2 + ); + }).defaults("attackTime=0.01,decayTime=0.3,sustainLevel=0.5,releaseTime=1,peakLevel=1,curve=-4,bias=0").build(); + + cc.global.Env.asr = fn(function(attackTime, sustainLevel, releaseTime, curve) { + return new Env( + [0, sustainLevel, 0], + [attackTime, releaseTime], + curve, + 1 + ); + }).defaults("attackTime=0.01,sustainLevel=1,releaseTime=1,curve=-4").build(); + + cc.global.Env.circle = function() { + throw "not implemented"; + }; + + module.exports = {}; + +}); +define('cc/lang/function', function(require, exports, module) { + + var cc = require("./cc"); + var fn = require("./fn"); + var ops = require("../common/ops"); + var utils = require("./utils"); + var slice = [].slice; + + var asNumber = function(val) { + val = val(); + if (typeof val !== "number" || isNaN(val)) { + return 0; + } + return val; + }; + + // common methods + fn.defineProperty(Function.prototype, "copy", function() { + return this; + }); + + fn.defineProperty(Function.prototype, "clone", fn(function() { + return this; + }).defaults(ops.COMMONS.clone).build()); + + fn.defineProperty(Function.prototype, "dup", fn(function(n) { + n |= 0; + var a = new Array(n); + for (var i = 0; i < n; ++i) { + a[i] = this(i); + } + return a; + }).defaults(ops.COMMONS.dup).build()); + + fn.defineProperty(Function.prototype, "value", function() { + return this.apply(null, arguments); + }); + + fn.defineProperty(Function.prototype, "valueArray", function(args) { + return this.apply(null, utils.asArray(args)); + }); + + fn.defineProperty(Function.prototype, "do", function(func) { + if (cc.instanceOfSyncBlock(func)) { + if (cc.currentSyncBlockHandler) { + cc.currentSyncBlockHandler.__sync__(func, cc.createTaskArgumentsOnce(true)); + return this; + } + } + func(this, 0); + return this; + }); + + fn.defineProperty(Function.prototype, "wait", function() { + if (cc.currentTask) { + cc.currentTask.__wait__(cc.createTaskWaitTokenFunction(this)); + } + return this; + }); + + fn.defineProperty(Function.prototype, "asUGenInput", function() { + return utils.asUGenInput(this()); + }); + + fn.defineProperty(Function.prototype, "asString", function() { + return "Function"; + }); + + // unary operator methods + ["__plus__","__minus__"].concat(Object.keys(ops.UNARY_OPS)).forEach(function(selector) { + fn.defineProperty(Function.prototype, selector, function() { + return asNumber(this)[selector](); + }); + if (/^[a-z]/.test(selector) && !cc.global.hasOwnProperty(selector)) { + cc.global[selector] = function(a) { + if (typeof a[selector] === "function") { + return a[selector](); + } + return a; + }; + } + }); + + // binary operator methods + ["__sub__","__div__","__mod__"].concat(Object.keys(ops.BINARY_OPS)).forEach(function(selector) { + fn.defineProperty(Function.prototype, selector, function(b) { + return asNumber(this)[selector](b); + }); + if (/^[a-z]/.test(selector) && !cc.global.hasOwnProperty(selector)) { + cc.global[selector] = function(a, b) { + if (typeof a[selector] === "function") { + return a[selector](b); + } + return a; + }; + } + }); + fn.defineProperty(Function.prototype, "__add__", function(b) { + return this.toString() + b; + }); + fn.defineProperty(Function.prototype, "__mul__", function(b) { + if (typeof b === "function") { + var f = this, g = b; + return function() { + return f.call(null, g.apply(null, arguments)); + }; + } + return 0; + }); + + // arity operators + Object.keys(ops.ARITY_OPS).forEach(function(selector) { + fn.defineProperty(Function.prototype, selector, fn(function() { + var args = slice.call(arguments); + return (0)[selector].apply(asNumber(this), args); + }).defaults(ops.ARITY_OPS[selector]).multiCall().build()); + if (/^[a-z]/.test(selector) && !cc.global.hasOwnProperty(selector)) { + cc.global[selector] = function(a) { + if (typeof a[selector] === "function") { + return a[selector].apply(a, slice.call(arguments, 1)); + } + return a; + }; + } + }); + + // others + fn.defineProperty(Function.prototype, "play", function() { + var func = this; + return cc.global.SynthDef( + function() { + cc.global.Out(2, 0, func()); + }, [] + ).play(); + }); + + module.exports = {}; + +}); +define('cc/lang/message', function(require, exports, module) { + + var cc = require("./cc"); + var emitter = require("../common/emitter"); + var slice = [].slice; + + cc.global.Message = { + klassName: "Message" + }; + + emitter.mixin(cc.global.Message); + + cc.global.Message.send = function() { + cc.lang.sendToClient([ + "/send", slice.call(arguments) + ]); + return cc.global.Message; + }; + + cc.resetMessage = function() { + cc.global.Message.off(); + }; + + module.exports = {}; + +}); +define('cc/lang/mix', function(require, exports, module) { + + var cc = require("./cc"); + var utils = require("./utils"); + var asRate = utils.asRate; + + var mix = function(array) { + if (!Array.isArray(array)) { + array = [array]; + } + var reduceArray = utils.clump(array, 4); + var a = reduceArray.map(function(a) { + switch (a.length) { + case 4: + return cc.createSum4(a[0], a[1], a[2], a[3]); + case 3: + return cc.createSum3(a[0], a[1], a[2]); + case 2: + return cc.createBinaryOpUGen("+", a[0], a[1]); + case 1: + return a[0]; + } + }); + switch (a.length) { + case 4: + return cc.createSum4(a[0], a[1], a[2], a[3]); + case 3: + return cc.createSum3(a[0], a[1], a[2]); + case 2: + return cc.createBinaryOpUGen("+", a[0], a[1]); + case 1: + return a[0]; + default: + return mix(a); + } + }; + + cc.global.Mix = function(array) { + return mix(array) || []; + }; + cc.global.Mix["new"] = cc.global.Mix; + + cc.global.Mix.fill = function(n, func) { + n = n|0; + var array = new Array(n); + for (var i = 0; i < n; ++i) { + array[i] = func(i); + } + return mix(array); + }; + cc.global.Mix.ar = function(array) { + if (Array.isArray(array)) { + var result = cc.global.Mix(array); + switch (asRate(result)) { + case 2: + return result; + case 1: + return result.map(function(x) { + return cc.global.K2A.ar(x); + }); + case 0: + return result.map(function(x) { + return cc.global.DC.ar(x); + }); + } + } + throw "Mix.ar: bad arguments"; + }; + cc.global.Mix.kr = function(array) { + if (Array.isArray(array)) { + var result = cc.global.Mix(array); + var rate = asRate(result); + if (rate === 2) { + result = result.map(function(x) { + if (x.rate === 2) { + return cc.global.A2K.kr(x); + } + return x; + }); + rate = asRate(result); + } + switch (rate) { + case 1: + return result; + case 0: + return result.map(function(x) { + return cc.global.DC.ar(x); + }); + } + } + throw "Mix.kr: bad arguments"; + }; + + cc.global.Mix.arFill = function(n, func) { + n = Math.max(0, n)|0; + var a = new Array(n); + for (var i = 0; i < n; ++i) { + a[i] = func(i); + } + return cc.global.Mix.ar(a); + }; + + cc.global.Mix.krFill = function(n, func) { + n = Math.max(0, n)|0; + var a = new Array(n); + for (var i = 0; i < n; ++i) { + a[i] = func(i); + } + return cc.global.Mix.kr(a); + }; + + module.exports = {}; + +}); +define('cc/lang/node', function(require, exports, module) { + + var cc = require("./cc"); + var utils = require("./utils"); + var extend = require("../common/extend"); + + var nodes = {}; + + var Node = (function() { + var nodeId = 0; + function Node() { + this.klassName = "Node"; + this.nodeId = nodeId++; + this._blocking = true; + nodes[this.nodeId] = this; + } + extend(Node, cc.Object); + + Node.prototype.play = function() { + cc.lang.pushToTimeline([ + "/n_run", this.nodeId, true + ]); + return this; + }; + + Node.prototype.pause = function() { + cc.lang.pushToTimeline([ + "/n_run", this.nodeId, false + ]); + return this; + }; + + Node.prototype.stop = function() { + cc.lang.pushToTimeline([ + "/n_free", this.nodeId + ]); + this._blocking = false; + return this; + }; + + Node.prototype.free = Node.prototype.stop; + + Node.prototype.set = function(args) { + var controls = args2controls(args, this.params); + if (controls.length) { + cc.lang.pushToTimeline([ + "/n_set", this.nodeId, controls + ]); + } + return this; + }; + + Node.prototype.release = function(releaseTime) { + releaseTime = -1 - utils.asNumber(releaseTime); + var controls = args2controls({ gate:releaseTime }, this.params); + if (controls.length) { + cc.lang.pushToTimeline([ + "/n_set", this.nodeId, controls + ]); + } + return this; + }; + + Node.prototype.performWait = function() { + return this._blocking; + }; + + Node.prototype.asString = function() { + return this.klassName + "(" + this.nodeId + ")"; + }; + + return Node; + })(); + + var Group = (function() { + function Group(target, addAction) { + Node.call(this); + this.klassName = "Group"; + if (target instanceof Node) { + cc.lang.pushToTimeline([ + "/g_new", this.nodeId, addAction, target.nodeId + ]); + } + } + extend(Group, Node); + + return Group; + })(); + + var Synth = (function() { + function Synth(target, addAction, def, args) { + Node.call(this); + this.klassName = "Synth"; + if (target instanceof Node && cc.instanceOfSynthDef(def)) { + this.params = def.specs.params; + var nodeId = this.nodeId; + var controls = args2controls(args, this.params); + cc.lang.pushToTimeline([ + "/s_new", nodeId, addAction, target.nodeId, def._defId, controls + ]); + } + } + extend(Synth, Node); + + return Synth; + })(); + + + var args2controls = function(args, params) { + var controls = []; + if (utils.isDict(args) && params) { + Object.keys(args).forEach(function(key) { + var value = args[key]; + var index = params.names.indexOf(key); + if (index === -1) { + return; + } + var length = params.length[index]; + index = params.indices[index]; + if (Array.isArray(value)) { + value.forEach(function(value, i) { + if (i < length) { + if (typeof value === "number" && !isNaN(value)) { + controls.push(index + i, value); + } + } + }); + } else if (typeof value === "number" && !isNaN(value)) { + controls.push(index, value); + } + }); + } + return controls; + }; + + var sortArgs = function(list) { + var node, def, args; + if (cc.instanceOfSynthDef(list[0])) { + node = cc.lang.rootNode; + def = list[0]; + args = list[1] || {}; + } else if (cc.instanceOfSynthDef(list[1])) { + node = list[0]; + def = list[1]; + args = list[2] || {}; + } else { + node = cc.lang.rootNode; + def = null; + args = {}; + } + return [node, def, args]; + }; + + cc.global.Group = function() { + var target, addAction = 0; + var i = 0; + if (cc.instanceOfNode(arguments[i])) { + target = arguments[i++]; + } else { + target = cc.lang.rootNode; + } + if (typeof arguments[i] === "string") { + addAction = { + addToHead:0, addToTail:1, addBefore:2, addAfter:3, replace:4 + }[arguments[i++]] || 0; + } else if (typeof arguments[i] === "number") { + if (0 <= arguments[i] && arguments[i] <= 4) { + addAction = arguments[i++]; + } + } + return new Group(target, addAction); + }; + cc.global.Group["new"] = cc.global.Group; + cc.global.Group.after = function(node) { + return new Group(node || cc.lang.rootNode, 3); + }; + cc.global.Group.before = function(node) { + return new Group(node || cc.lang.rootNode, 2); + }; + cc.global.Group.head = function(node) { + return new Group(node || cc.lang.rootNode, 0); + }; + cc.global.Group.tail = function(node) { + return new Group(node || cc.lang.rootNode, 1); + }; + cc.global.Group.replace = function(node) { + return new Group(node, 4); + }; + + cc.global.Synth = function(def) { + var args, target, addAction = 0; + var i = 1; + if (utils.isDict(arguments[i])) { + args = arguments[i++]; + } else { + args = {}; + } + if (cc.instanceOfNode(arguments[i])) { + target = arguments[i++]; + } else { + target = cc.lang.rootNode; + } + if (typeof arguments[i] === "string") { + addAction = { + addToHead:0, addToTail:1, addBefore:2, addAfter:3, replace:4 + }[arguments[i++]] || 0; + } else if (typeof arguments[i] === "number") { + if (0 <= arguments[i] && arguments[i] <= 4) { + addAction = arguments[i++]; + } + } + return new Synth(target, addAction, def, args); + }; + cc.global.Synth["new"] = cc.global.Synth; + cc.global.Synth.after = function() { + var list = sortArgs(arguments); + return new Synth(list[0], 3, list[1], list[2]); + }; + cc.global.Synth.before = function() { + var list = sortArgs(arguments); + return new Synth(list[0], 2, list[1], list[2]); + }; + cc.global.Synth.head = function() { + var list = sortArgs(arguments); + return new Synth(list[0], 0, list[1], list[2]); + }; + cc.global.Synth.tail = function() { + var list = sortArgs(arguments); + return new Synth(list[0], 1, list[1], list[2]); + }; + cc.global.Synth.replace = function(node, def, args) { + return new Synth(node, 4, def, args); + }; + + cc.createLangRootNode = function() { + return new Group(); + }; + cc.instanceOfNode = function(obj) { + return obj instanceof Node; + }; + cc.instanceOfGroup = function(obj) { + return obj instanceof Group; + }; + cc.instanceOfSynth = function(obj) { + return obj instanceof Synth; + }; + cc.getNode = function(nodeId) { + return nodes[nodeId]; + }; + cc.resetNode = function() { + nodes = {}; + }; + + module.exports = { + Node : Node, + Group: Group, + Synth: Synth, + args2controls: args2controls + }; + +}); +define('cc/lang/number', function(require, exports, module) { + + var cc = require("./cc"); + var fn = require("./fn"); + var ops = require("../common/ops"); + var utils = require("./utils"); + + var drand = function() { + return cc.lang.random.next(); + }; + + // common methods + fn.defineProperty(Number.prototype, "copy", function() { + return this; + }); + + fn.defineProperty(Number.prototype, "clone", fn(function() { + return this; + }).defaults(ops.COMMONS.clone).build()); + + fn.defineProperty(Number.prototype, "dup", fn(function(n) { + var a = new Array(n|0); + for (var i = 0, imax = a.length; i < imax; ++i) { + a[i] = this; + } + return a; + }).defaults(ops.COMMONS.dup).build()); + + fn.defineProperty(Number.prototype, "value", function() { + return this; + }); + + fn.defineProperty(Number.prototype, "valueArray", function() { + return this; + }); + + fn.defineProperty(Number.prototype, "do", function(func) { + var i, n = this; + if (cc.instanceOfSyncBlock(func)) { + if (cc.currentSyncBlockHandler) { + if (n > 0) { + cc.currentSyncBlockHandler.__sync__(func, cc.createTaskArgumentsNumber(0, n - 1, 1)); + } + return this; + } + } + for (i = 0; i < n; ++i) { + func(i, i); + } + return this; + }); + + fn.defineProperty(Number.prototype, "forBy", function(endValue, stepValue, func) { + var i = 0, x = this; + endValue = utils.asNumber(endValue ); + stepValue = utils.asNumber(stepValue); + if (cc.instanceOfSyncBlock(func)) { + if (cc.currentSyncBlockHandler) { + cc.currentSyncBlockHandler.__sync__(func, cc.createTaskArgumentsNumber(x, endValue, stepValue)); + return this; + } + } + if (stepValue < 0) { + for (i = 0; x >= endValue; i++) { + func(x, i); + x += stepValue; + } + } else if (stepValue > 0) { + for (i = 0; x <= endValue; i++) { + func(x, i); + x += stepValue; + } + } + return this; + }); + + fn.defineProperty(Number.prototype, "forSeries", function(second, last, func) { + return this.forBy(last, (utils.asNumber(second) - this), func); + }); + + fn.defineProperty(Number.prototype, "wait", function() { + var n = this; + if (n >= 0 && cc.currentTask) { + cc.currentTask.__wait__(n); + } + return this; + }); + + fn.defineProperty(Number.prototype, "asUGenInput", function() { + return this; + }); + + fn.defineProperty(Number.prototype, "asString", function() { + return this.toString(); + }); + + // unary operator methods + fn.defineProperty(Number.prototype, "__plus__", function() { + return +this; + }); + fn.defineProperty(Number.prototype, "__minus__", function() { + return -this; + }); + fn.defineProperty(Number.prototype, "neg", function() { + return -this; + }); + fn.defineProperty(Number.prototype, "not", function() { + return this === 0 ? 1 : 0; + }); + fn.defineProperty(Number.prototype, "isNil", function() { + return 0; + }); + fn.defineProperty(Number.prototype, "notNil", function() { + return 1; + }); + fn.defineProperty(Number.prototype, "bitNot", function() { + return ~this; + }); + fn.defineProperty(Number.prototype, "abs", function() { + return Math.abs(this); + }); + fn.defineProperty(Number.prototype, "asFloat", function() { + return +this; + }); + fn.defineProperty(Number.prototype, "asInt", function() { + return this|0; + }); + fn.defineProperty(Number.prototype, "ceil", function() { + return Math.ceil(this); + }); + fn.defineProperty(Number.prototype, "floor", function() { + return Math.floor(this); + }); + fn.defineProperty(Number.prototype, "frac", function() { + if (this < 0) { + return 1 + (this - (this|0)); + } + return this - (this|0); + }); + fn.defineProperty(Number.prototype, "sign", function() { + if (this === 0) { + return 0; + } else if (this > 0) { + return 1; + } + return -1; + }); + fn.defineProperty(Number.prototype, "squared", function() { + return this * this; + }); + fn.defineProperty(Number.prototype, "cubed", function() { + return this * this * this; + }); + fn.defineProperty(Number.prototype, "sqrt", function() { + return Math.sqrt(Math.abs(this)); + }); + fn.defineProperty(Number.prototype, "exp", function() { + return Math.exp(this); + }); + fn.defineProperty(Number.prototype, "reciprocal", function() { + return 1 / this; + }); + fn.defineProperty(Number.prototype, "midicps", function() { + return 440 * Math.pow(2, (this - 69) * 1/12); + }); + fn.defineProperty(Number.prototype, "cpsmidi", function() { + return Math.log(Math.abs(this) * 1/440) * Math.LOG2E * 12 + 69; + }); + fn.defineProperty(Number.prototype, "midiratio", function() { + return Math.pow(2, this * 1/12); + }); + fn.defineProperty(Number.prototype, "ratiomidi", function() { + return Math.log(Math.abs(this)) * Math.LOG2E * 12; + }); + fn.defineProperty(Number.prototype, "dbamp", function() { + return Math.pow(10, this * 0.05); + }); + fn.defineProperty(Number.prototype, "ampdb", function() { + return Math.log(Math.abs(this)) * Math.LOG10E * 20; + }); + fn.defineProperty(Number.prototype, "octcps", function() { + return 440 * Math.pow(2, this - 4.75); + }); + fn.defineProperty(Number.prototype, "cpsoct", function() { + return Math.log(Math.abs(this) * 1/440) * Math.LOG2E + 4.75; + }); + fn.defineProperty(Number.prototype, "log", function() { + return Math.log(Math.abs(this)); + }); + fn.defineProperty(Number.prototype, "log2", function() { + return Math.log(Math.abs(this)) * Math.LOG2E; + }); + fn.defineProperty(Number.prototype, "log10", function() { + return Math.log(Math.abs(this)) * Math.LOG10E; + }); + fn.defineProperty(Number.prototype, "sin", function() { + return Math.sin(this); + }); + fn.defineProperty(Number.prototype, "cos", function() { + return Math.cos(this); + }); + fn.defineProperty(Number.prototype, "tan", function() { + return Math.tan(this); + }); + fn.defineProperty(Number.prototype, "asin", function() { + return Math.asin(Math.max(-1, Math.min(this, 1))); + }); + fn.defineProperty(Number.prototype, "acos", function() { + return Math.acos(Math.max(-1, Math.min(this, 1))); + }); + fn.defineProperty(Number.prototype, "atan", function() { + return Math.atan(this); + }); + fn.defineProperty(Number.prototype, "sinh", function() { + return (Math.pow(Math.E, this) - Math.pow(Math.E, -this)) * 0.5; + }); + fn.defineProperty(Number.prototype, "cosh", function() { + return (Math.pow(Math.E, this) + Math.pow(Math.E, -this)) * 0.5; + }); + fn.defineProperty(Number.prototype, "tanh", function() { + return this.sinh() / this.cosh(); + }); + fn.defineProperty(Number.prototype, "rand", function() { + return drand() * this; + }); + fn.defineProperty(Number.prototype, "rand2", function() { + return (drand() * 2 - 1) * this; + }); + fn.defineProperty(Number.prototype, "linrand", function() { + return Math.min(drand(), drand()) * this; + }); + fn.defineProperty(Number.prototype, "bilinrand", function() { + return (drand() - drand()) * this; + }); + fn.defineProperty(Number.prototype, "sum3rand", function() { + return (drand() + drand() + drand() - 1.5) * 0.666666667 * this; + }); + fn.defineProperty(Number.prototype, "distort", function() { + return this / (1 + Math.abs(this)); + }); + fn.defineProperty(Number.prototype, "softclip", function() { + var absa = Math.abs(this); + return absa <= 0.5 ? this : (absa - 0.25) / this; + }); + fn.defineProperty(Number.prototype, "coin", function() { + return drand() < this; + }); + fn.defineProperty(Number.prototype, "digitvalue", function() { + return 0; // TODO: implements + }); + fn.defineProperty(Number.prototype, "silence", function() { + return 0; // TODO: implements + }); + fn.defineProperty(Number.prototype, "thru", function() { + return 0; // TODO: implements + }); + fn.defineProperty(Number.prototype, "rectWindow", function() { + return 0; // TODO: implements + }); + fn.defineProperty(Number.prototype, "hanWindow", function() { + return 0; // TODO: implements + }); + fn.defineProperty(Number.prototype, "welWindow", function() { + return 0; // TODO: implements + }); + fn.defineProperty(Number.prototype, "triWindow", function() { + return 0; // TODO: implements + }); + fn.defineProperty(Number.prototype, "ramp", function() { + return 0; // TODO: implements + }); + fn.defineProperty(Number.prototype, "scurve", function() { + return 0; // TODO: implements + }); + fn.defineProperty(Number.prototype, "numunaryselectors", function() { + return 0; // TODO: implements + }); + fn.defineProperty(Number.prototype, "num", function() { + return +this; + }); + fn.defineProperty(Number.prototype, "tilde", function() { + return ~this; + }); + fn.defineProperty(Number.prototype, "pi", function() { + return this * Math.PI; + }); + fn.defineProperty(Number.prototype, "to_i", function() { + return this|0; + }); + fn.defineProperty(Number.prototype, "half", function() { + return this * 0.5; + }); + fn.defineProperty(Number.prototype, "twice", function() { + return this * 2; + }); + + // binary operator methods + fn.defineBinaryProperty(Number.prototype, "__add__", function(b) { + return this + b; + }); + fn.defineBinaryProperty(Number.prototype, "__sub__", function(b) { + return this - b; + }); + fn.defineBinaryProperty(Number.prototype, "__mul__", function(b) { + return this * b; + }); + fn.defineBinaryProperty(Number.prototype, "__div__", function(b) { + if (this === 0 && b === 0) { + return 0; // avoid NaN + } + return this / b; + }); + fn.defineBinaryProperty(Number.prototype, "__mod__", function(b) { + if (b === 0) { + return 0; // avoid NaN + } + return this % b; + }); + fn.defineBinaryProperty(Number.prototype, "eq", function(b) { + return this === b ? 1 : 0; + }); + fn.defineBinaryProperty(Number.prototype, "ne", function(b) { + return this !== b ? 1 : 0; + }); + fn.defineBinaryProperty(Number.prototype, "lt", function(b) { + return this < b ? 1 : 0; + }); + fn.defineBinaryProperty(Number.prototype, "gt", function(b) { + return this > b ? 1 : 0; + }); + fn.defineBinaryProperty(Number.prototype, "le", function(b) { + return this <= b ? 1 : 0; + }); + fn.defineBinaryProperty(Number.prototype, "ge", function(b) { + return this >= b ? 1 : 0; + }); + fn.defineBinaryProperty(Number.prototype, "bitAnd", function(b) { + return this & b; + }); + fn.defineBinaryProperty(Number.prototype, "bitOr", function(b) { + return this | b; + }); + fn.defineBinaryProperty(Number.prototype, "bitXor", function(b) { + return this ^ b; + }); + fn.defineBinaryProperty(Number.prototype, "min", function(b) { + return Math.min(this, b); + }); + fn.defineBinaryProperty(Number.prototype, "max", function(b) { + return Math.max(this, b); + }); + + var gcd = function(a, b, t) { + a = a|0; b = b|0; + while (b !== 0) { + t = a % b; a = b; b = t; + } + return Math.abs(a); + }; + fn.defineBinaryProperty(Number.prototype, "lcm", function(b) { + if (this === 0 && b === 0) { + return 0; // avoid NaN + } + return Math.abs(this * b) / gcd(this, b); + }); + fn.defineBinaryProperty(Number.prototype, "gcd", function(b) { + return gcd(this, b); + }); + fn.defineBinaryProperty(Number.prototype, "round", function(b) { + if (b === 0) { + return this; // avoid NaN + } + return Math.round(this / b) * b; + }); + fn.defineBinaryProperty(Number.prototype, "roundUp", function(b) { + if (b === 0) { + return this; // avoid NaN + } + return Math.ceil(this / b) * b; + }); + fn.defineBinaryProperty(Number.prototype, "roundDown", function(b) { + if (b === 0) { + return this; // avoid NaN + } + return Math.floor(this / b) * b; + }); + fn.defineBinaryProperty(Number.prototype, "trunc", function(b) { + if (b === 0) { + return this; // avoid NaN + } + return Math.floor(this / b) * b; + }); + fn.defineBinaryProperty(Number.prototype, "atan2", function(b) { + return Math.atan2(this, b); + }); + fn.defineBinaryProperty(Number.prototype, "hypot", function(b) { + return Math.sqrt((this * this) + (b * b)); + }); + fn.defineBinaryProperty(Number.prototype, "hypotApx", function(b) { + var x = Math.abs(this), y = Math.abs(b); + var minxy = Math.min(x, y); + return x + y - (Math.sqrt(2) - 1) * minxy; + }); + fn.defineBinaryProperty(Number.prototype, "pow", function(b) { + return Math.pow(Math.abs(this), b); + }); + fn.defineBinaryProperty(Number.prototype, "leftShift", function(b) { + if (b < 0) { + return (this|0) >> (-b|0); + } + return (this|0) << (b|0); + }); + fn.defineBinaryProperty(Number.prototype, "rightShift", function(b) { + if (b < 0) { + return (this|0) << (-b|0); + } + return (this|0) >> (b|0); + }); + fn.defineBinaryProperty(Number.prototype, "unsignedRightShift", function(b) { + if (b < 0) { + return (this|0) << (-b|0); + } + return (this|0) >> (b|0); + }); + fn.defineBinaryProperty(Number.prototype, "fill", function() { + return 0; // TODO: implements + }); + fn.defineBinaryProperty(Number.prototype, "ring1", function(b) { + return this * b + this; + }); + fn.defineBinaryProperty(Number.prototype, "ring2", function(b) { + return this * b + this + b; + }); + fn.defineBinaryProperty(Number.prototype, "ring3", function(b) { + return this * this * b; + }); + fn.defineBinaryProperty(Number.prototype, "ring4", function(b) { + return this * this * b - this * b * b; + }); + fn.defineBinaryProperty(Number.prototype, "difsqr", function(b) { + return this * this - b * b; + }); + fn.defineBinaryProperty(Number.prototype, "sumsqr", function(b) { + return this * this + b * b; + }); + fn.defineBinaryProperty(Number.prototype, "sqrsum", function(b) { + return (this + b) * (this + b); + }); + fn.defineBinaryProperty(Number.prototype, "sqrdif", function(b) { + return (this - b) * (this - b); + }); + fn.defineBinaryProperty(Number.prototype, "absdif", function(b) { + return Math.abs(this - b); + }); + fn.defineBinaryProperty(Number.prototype, "thresh", function(b) { + return this < b ? 0 : this; + }); + fn.defineBinaryProperty(Number.prototype, "amclip", function(b) { + return this * 0.5 * (b + Math.abs(b)); + }); + fn.defineBinaryProperty(Number.prototype, "scaleneg", function(b) { + b = 0.5 * b + 0.5; + return (Math.abs(this) - this) * b + this; + }); + fn.defineBinaryProperty(Number.prototype, "clip2", function(b) { + return Math.max(-b, Math.min(this, b)); + }); + fn.defineBinaryProperty(Number.prototype, "excess", function(b) { + return this - Math.max(-b, Math.min(this, b)); + }); + fn.defineBinaryProperty(Number.prototype, "fold2", function(b) { + var _in = this, x, c, range, range2; + x = _in + b; + if (_in >= b) { + _in = b + b - _in; + if (_in >= -b) { + return _in; + } + } else if (_in < -b) { + _in = -b - b - _in; + if (_in < b) { + return _in; + } + } else { + return _in; + } + if (b === -b) { + return -b; + } + range = b + b; + range2 = range + range; + c = x - range2 * Math.floor(x / range2); + if (c >= range) { + c = range2 - c; + } + return c - b; + }); + fn.defineBinaryProperty(Number.prototype, "wrap2", function(b) { + var _in = this, range; + if (_in >= b) { + range = b + b; + _in -= range; + if (_in < b) { + return _in; + } + } else if (_in < -b) { + range = b + b; + _in += range; + if (_in >= -b) { + return _in; + } + } else { + return _in; + } + if (b === -b) { + return -b; + } + return _in - range * Math.floor((_in + b) / range); + }); + fn.defineBinaryProperty(Number.prototype, "firstarg", function() { + return 0; // TODO: implements + }); + fn.defineBinaryProperty(Number.prototype, "randrange", function() { + return 0; // TODO: implements + }); + fn.defineBinaryProperty(Number.prototype, "exprandrange", function() { + return 0; // TODO: implements + }); + fn.defineBinaryProperty(Number.prototype, "numbinaryselectors", function() { + return 0; // TODO: implements + }); + + // arity operator methods + fn.defineProperty(Number.prototype, "madd", fn(function(mul, add) { + return cc.createMulAdd(this, mul, add); + }).defaults(ops.ARITY_OPS.madd).build()); + + fn.defineArityProperty(Number.prototype, "range", fn(function(lo, hi) { + return this.linlin(0, 1, lo, hi); + }).defaults(ops.ARITY_OPS.range).build()); + + fn.defineArityProperty(Number.prototype, "exprange", fn(function(lo, hi) { + return this.linexp(0, 1, lo, hi); + }).defaults(ops.ARITY_OPS.exprange).build()); + + fn.defineArityProperty(Number.prototype, "curverange", fn(function(lo, hi, curve) { + return this.lincurve(0, 1, lo, hi, curve); + }).defaults(ops.ARITY_OPS.curverange).build()); + + fn.defineArityProperty(Number.prototype, "unipolar", fn(function(mul) { + return this.__mul__(mul); + }).defaults(ops.ARITY_OPS.unipolar).build()); + + fn.defineArityProperty(Number.prototype, "bipolar", fn(function(mul) { + return (this * 2 - 1).__mul__(mul); + }).defaults(ops.ARITY_OPS.bipolar).build()); + + fn.defineArityProperty(Number.prototype, "clip", fn(function(lo, hi) { + return Math.max(lo, Math.min(this, hi)); + }).defaults(ops.ARITY_OPS.clip).multiCall().build()); + + fn.defineArityProperty(Number.prototype, "fold", fn(function(lo, hi) { + var val = this, x, range1, range2; + if (hi === lo) { + return lo; + } + if (val >= hi) { + val = (hi * 2) - val; + if (val >= lo) { + return val; + } + } else if (val < lo) { + val = (lo * 2) - val; + if (val < hi) { + return val; + } + } else { + return val; + } + range1 = hi - lo; + range2 = range1 * 2; + x = val - lo; + x -= range2 * Math.floor(x / range2); + if (x >= range1) { + return range2 - x + lo; + } + return x + lo; + }).defaults(ops.ARITY_OPS.fold).multiCall().build()); + + fn.defineArityProperty(Number.prototype, "wrap", fn(function(lo, hi) { + var val = this; + if (hi === lo) { + return lo; + } + var range = (hi - lo); + if (val >= hi) { + val -= range; + if (val < hi) { + return val; + } + } else if (val < lo) { + val += range; + if (val >= lo) { + return val; + } + } else { + return val; + } + return val - range * Math.floor((val - lo) / range); + }).defaults(ops.ARITY_OPS.wrap).multiCall().build()); + + fn.defineArityProperty(Number.prototype, "blend", fn(function(that, blendFrac) { + return this + blendFrac * (that - this); + }).defaults(ops.ARITY_OPS.wrap).multiCall().build()); + + fn.defineProperty(Number.prototype, "lag", function() { + return this; + }); + + fn.defineProperty(Number.prototype, "lag2", function() { + return this; + }); + + fn.defineProperty(Number.prototype, "lag3", function() { + return this; + }); + + fn.defineProperty(Number.prototype, "lagud", function() { + return this; + }); + + fn.defineProperty(Number.prototype, "lag2ud", function() { + return this; + }); + + fn.defineProperty(Number.prototype, "lag3ud", function() { + return this; + }); + + fn.defineProperty(Number.prototype, "varlag", function() { + return this; + }); + + fn.defineProperty(Number.prototype, "slew", function() { + return this; + }); + + fn.defineArityProperty(Number.prototype, "linlin", fn(function(inMin, inMax, outMin, outMax, clip) { + switch (clip) { + case "min": + if (this <= inMin) { return outMin; } + break; + case "max": + if (this >= inMax) { return outMax; } + break; + case "minmax": + /* falls through */ + default: + if (this <= inMin) { return outMin; } + if (this >= inMax) { return outMax; } + break; + } + // (this-inMin)/(inMax-inMin) * (outMax-outMin) + outMin; + return (this.__sub__(inMin)).__div__(inMax.__sub__(inMin)).__mul__(outMax.__sub__(outMin)).__add__(outMin); + }).defaults(ops.ARITY_OPS.linlin).multiCall().build()); + + fn.defineArityProperty(Number.prototype, "linexp", fn(function(inMin, inMax, outMin, outMax, clip) { + switch (clip) { + case "min": + if (this <= inMin) { return outMin; } + break; + case "max": + if (this >= inMax) { return outMax; } + break; + case "minmax": + /* falls through */ + default: + if (this <= inMin) { return outMin; } + if (this >= inMax) { return outMax; } + break; + } + // Math.pow(outMax/outMin, (this-inMin)/(inMax-inMin)) * outMin; + return outMax.__div__(outMin).pow((this.__sub__(inMin)).__div__(inMax.__sub__(inMin))).__mul__(outMin); + }).defaults(ops.ARITY_OPS.linexp).multiCall().build()); + + fn.defineArityProperty(Number.prototype, "explin", fn(function(inMin, inMax, outMin, outMax, clip) { + switch (clip) { + case "min": + if (this <= inMin) { return outMin; } + break; + case "max": + if (this >= inMax) { return outMax; } + break; + case "minmax": + /* falls through */ + default: + if (this <= inMin) { return outMin; } + if (this >= inMax) { return outMax; } + break; + } + // (((Math.log(this/inMin)) / (Math.log(inMax/inMin))) * (outMax-outMin)) + outMin; + return (this.__div__(inMin).log().__div__(inMax.__div__(inMin).log()).__mul__(outMax.__sub__(outMin))).__add__(outMin); + }).defaults(ops.ARITY_OPS.explin).multiCall().build()); + + fn.defineArityProperty(Number.prototype, "expexp", fn(function(inMin, inMax, outMin, outMax, clip) { + switch (clip) { + case "min": + if (this <= inMin) { return outMin; } + break; + case "max": + if (this >= inMax) { return outMax; } + break; + case "minmax": + /* falls through */ + default: + if (this <= inMin) { return outMin; } + if (this >= inMax) { return outMax; } + break; + } + // Math.pow(outMax/outMin, Math.log(this/inMin) / Math.log(inMax/inMin)) * outMin; + return outMax.__div__(outMin).pow(this.__div__(inMin).log().__div__(inMax.__div__(inMin).log())).__mul__(outMin); + }).defaults(ops.ARITY_OPS.expexp).multiCall().build()); + + fn.defineArityProperty(Number.prototype, "lincurve", fn(function(inMin, inMax, outMin, outMax, curve, clip) { + switch (clip) { + case "min": + if (this <= inMin) { return outMin; } + break; + case "max": + if (this >= inMax) { return outMax; } + break; + case "minmax": + /* falls through */ + default: + if (this <= inMin) { return outMin; } + if (this >= inMax) { return outMax; } + break; + } + if (Math.abs(curve) < 0.001) { + return this.linlin(inMin, inMax, outMin, outMax, clip); + } + var grow = curve.exp(); + var a = outMax.__sub__(outMin).__div__((1).__sub__(grow)); + var b = outMin.__add__(a); + var scaled = (this.__sub__(inMin)).__div__(inMax.__sub__(inMin)); + return b.__sub__(a.__mul__(grow.pow(scaled))); + }).defaults(ops.ARITY_OPS.lincurve).multiCall().build()); + + fn.defineArityProperty(Number.prototype, "curvelin", fn(function(inMin, inMax, outMin, outMax, curve, clip) { + switch (clip) { + case "min": + if (this <= inMin) { return outMin; } + break; + case "max": + if (this >= inMax) { return outMax; } + break; + case "minmax": + /* falls through */ + default: + if (this <= inMin) { return outMin; } + if (this >= inMax) { return outMax; } + break; + } + if (Math.abs(curve) < 0.001) { + return this.linlin(inMin, inMax, outMin, outMax, clip); + } + var grow = curve.exp(); + var a = outMax.__sub__(outMin).__div__((1).__sub__(grow)); + var b = outMin.__add__(a); + var scaled = (this.__sub__(inMin)).__div__(inMax.__sub__(inMin)); + return ((b.__sub__(scaled)).__div__(a)).log().__div__(curve); + }).defaults(ops.ARITY_OPS.curvelin).multiCall().build()); + + fn.defineArityProperty(Number.prototype, "bilin", fn(function(inCenter, inMin, inMax, outCenter, outMin, outMax, clip) { + switch (clip) { + case "min": + if (this <= inMin) { return outMin; } + break; + case "max": + if (this >= inMax) { return outMax; } + break; + case "minmax": + /* falls through */ + default: + if (this <= inMin) { return outMin; } + if (this >= inMax) { return outMax; } + break; + } + if (this >= inCenter) { + return this.linlin(inCenter, inMax, outCenter, outMax); + } else { + return this.linlin(inMin, inCenter, outMin, outCenter); + } + }).defaults(ops.ARITY_OPS.bilin).multiCall().build()); + + fn.defineArityProperty(Number.prototype, "rrand", fn(function(num) { + var a = this, b = num; + return a + drand() * (b - a); + }).defaults(ops.ARITY_OPS.rrand).multiCall().build()); + + fn.defineArityProperty(Number.prototype, "exprand", fn(function(num) { + var a = this, b = num; + if (a === 0) { + return 0; + } + return a * Math.exp(Math.log(b / a) * drand()); + }).defaults(ops.ARITY_OPS.exprand).multiCall().build()); + + // chord + var chord_tensions = { + "" : [4, 7], + "major" : [4, 7], + "minor" : [3, 7], + "major7": [4, 7, 11], + "dom7" : [4, 7, 10], + "minor7": [3, 7, 10], + "aug" : [4, 8], + "dim" : [3, 6], + "dim7" : [3, 6, 9], + "1" : [], + "5" : [7], + "+5" : [4, 8], + "m+5" : [3, 8], + "sus2" : [2, 7], + "sus4" : [5, 7], + "6" : [4, 7, 9], + "m6" : [3, 7, 9], + "7sus2" : [2, 7, 10], + "7sus4" : [5, 7, 10], + "7-5" : [4, 6, 10], + "m7-5" : [3, 6, 10], + "7+5" : [4, 8, 10], + "m7+5" : [3, 8, 10], + "9" : [4, 7, 10, 14], + "m9" : [3, 7, 10, 14], + "m7+9" : [3, 7, 10, 14], + "maj9" : [4, 7, 11, 14], + "9sus4" : [5, 7, 10, 14], + "6*9" : [4, 7, 9, 14], + "m6*9" : [3, 9, 7, 14], + "7-9" : [4, 7, 10, 13], + "m7-9" : [3, 7, 10, 13], + "7-10" : [4, 7, 10, 15], + "9+5" : [10, 13], + "m9+5" : [10, 14], + "7+5-9" : [4, 8, 10, 13], + "m7+5-9": [3, 8, 10, 13], + "11" : [4, 7, 10, 14, 17], + "m11" : [3, 7, 10, 14, 17], + "maj11" : [4, 7, 11, 14, 17], + "11+" : [4, 7, 10, 14, 18], + "m11+" : [3, 7, 10, 14, 18], + "13" : [4, 7, 10, 14, 17, 21], + "m13" : [3, 7, 10, 14, 17, 21] + }; + chord_tensions.M = chord_tensions.major; + chord_tensions.m = chord_tensions.minor; + chord_tensions["7"] = chord_tensions.dom7; + chord_tensions.M7 = chord_tensions.major7; + chord_tensions.m7 = chord_tensions.minor7; + chord_tensions.augmented = chord_tensions.aug; + chord_tensions.a = chord_tensions.aug; + chord_tensions.diminished = chord_tensions.dim; + chord_tensions.i = chord_tensions.dim; + chord_tensions.diminished7 = chord_tensions.dim7; + chord_tensions.i7 = chord_tensions.dim7; + + var chord = function(num, name, inversion, length) { + var i, imax; + var tensions = chord_tensions[name] || []; + var list = [ num ]; + for (i = 0, imax = tensions.length; i < imax; ++i) { + list.push(num + tensions[i]); + } + if (inversion >= 0) { + inversion = Math.max(0, Math.min(+inversion, list.length - 1)); + while (inversion--) { + list.push( list.shift() + 12 ); + } + } else { + inversion = Math.max(0, Math.min(-inversion, list.length - 1)); + while (inversion--) { + list.unshift( list.pop() - 12 ); + } + } + if (length >= 0) { + if (length < list.length) { + list = list.slice(0, length); + } else { + length -= list.length; + for (i = 0, imax = length; i < imax; ++i) { + list.push( list[i] + 12 ); + } + } + } + return list; + }; + + fn.defineProperty(Number.prototype, "midichord", fn(function(name, inversion, length) { + return chord(this, name, inversion, length); + }).defaults("name=\"\",inversion=0,length=-1").multiCall().build()); + + fn.defineProperty(Number.prototype, "chord", fn(function(name, inversion, length) { + if (!cc.deprecate.chord) { + cc.deprecate.chord = true; + cc.global.console.log("Number#chord is now called `Number#midichord`"); + } + return chord(this, name, inversion, length); + }).defaults("name=\"\",inversion=0,length=-1").multiCall().build()); + + fn.defineProperty(Number.prototype, "cpschord", fn(function(name, inversion, length) { + var num = this; + return chord(0, name, inversion, length).map(function(midi) { + return num * Math.pow(2, midi * 1/12); + }); + }).defaults("name=\"\",inversion=0,length=-1").multiCall().build()); + + fn.defineProperty(Number.prototype, "chordcps", fn(function(name, inversion, length) { + var num = this; + if (!cc.deprecate.chordcps) { + cc.deprecate.chordcps = true; + cc.global.console.log("Number#chordcps is now called `Number#cpschord`"); + } + return chord(0, name, inversion, length).map(function(midi) { + return num * Math.pow(2, midi * 1/12); + }); + }).defaults("name=\"\",inversion=0,length=-1").multiCall().build()); + + fn.defineProperty(Number.prototype, "ratiochord", fn(function(name, inversion, length) { + var num = Math.pow(2, this * 1/12); + return chord(0, name, inversion, length).map(function(midi) { + return num * Math.pow(2, midi * 1/12); + }); + }).defaults("name=\"\",inversion=0,length=-1").multiCall().build()); + + fn.defineProperty(Number.prototype, "chordratio", fn(function(name, inversion, length) { + var num = Math.pow(2, this * 1/12); + if (!cc.deprecate.chordratio) { + cc.deprecate.chordratio = true; + cc.global.console.log("Number#chordratio is now called `Number#ratiochord`"); + } + return chord(0, name, inversion, length).map(function(midi) { + return num * Math.pow(2, midi * 1/12); + }); + }).defaults("name=\"\",inversion=0,length=-1").multiCall().build()); + + (function() { + var keys = {C:0,D:2,E:4,F:5,G:7,A:9,B:11}; + Object.keys(keys).forEach(function(key) { + var note = keys[key]; + for (var i = 0; i <= 9; ++i) { + cc.global[key + i] = note + (i+1) * 12; + } + }); + })(); + + module.exports = {}; + +}); +define('cc/lang/object', function(require, exports, module) { + + var cc = require("./cc"); + var fn = require("./fn"); + var ops = require("../common/ops"); + + fn.defineProperty(cc.Object.prototype, "clone", fn(function() { + return this; + }).defaults(ops.COMMONS.clone).build()); + + fn.defineProperty(cc.Object.prototype, "dup", fn(function(n, deep) { + var a = new Array(n|0); + for (var i = 0, imax = a.length; i < imax; ++i) { + a[i] = this.clone(deep); + } + return a; + }).defaults(ops.COMMONS.dup).build()); + + fn.defineProperty(cc.Object.prototype, "value", function() { + return this; + }); + + fn.defineProperty(cc.Object.prototype, "valueArray", function() { + return this; + }); + + fn.defineProperty(cc.Object.prototype, "do", function(func) { + if (cc.instanceOfSyncBlock(func)) { + if (cc.currentSyncBlockHandler) { + cc.currentSyncBlockHandler.__sync__(func, cc.createTaskArgumentsOnce(this)); + return this; + } + } + func(this, 0); + return this; + }); + + fn.defineProperty(cc.Object.prototype, "asUGenInput", function() { + throw new Error(this.klassName + " can't cast to a UGen."); + }); + + fn.defineProperty(cc.Object.prototype, "asString", function() { + return this.klassName; + }); + + module.exports = {}; + +}); +define('cc/lang/pattern', function(require, exports, module) { + + var cc = require("./cc"); + var fn = require("./fn"); + var extend = require("../common/extend"); + var ops = require("../common/ops"); + var utils = require("./utils"); + + var isNotNull = function(obj) { + return obj !== null && obj !== undefined; + }; + var valueOf = function(item) { + if (item instanceof Pattern) { + return item.next(); + } + return item; + }; + + var asPattern = function(item) { + if (item instanceof Pattern) { + return item; + } + return new Pseq(utils.asArray(item), 1, 0); + }; + + var Pattern = (function() { + function Pattern() { + this.klassName = "Pattern"; + this._finished = false; + } + extend(Pattern, cc.Object); + + Pattern.prototype.clone = function() { + return this; + }; + Pattern.prototype.next = function() { + return null; + }; + Pattern.prototype.nextN = function(n, inVal) { + var a = new Array(n); + for (var i = 0; i < n; ++i) { + a[i] = this.next(inVal); + } + return a; + }; + Pattern.prototype.reset = function() { + return this; + }; + Pattern.prototype.performWait = function() { + return !this._finished; + }; + Pattern.prototype.concat = function(item) { + return new Pseq([this, item.clone()], 1); + }; + + Pattern.prototype["do"] = function(func) { + if (cc.instanceOfSyncBlock(func)) { + if (cc.currentSyncBlockHandler) { + cc.currentSyncBlockHandler.__sync__(func, cc.createTaskArgumentsPattern(this)); + return this; + } + } + + var i = 0, val = true; + do { + val = this.next(); + if (isNotNull(val)) { + func.apply(null, [val, i++]); + } + } while (val); + return this; + }; + + // unary operators + ["__plus__","__minus__"].concat(Object.keys(ops.UNARY_OPS)).forEach(function(selector) { + if (/^[a-z_][a-zA-Z0-9_]*$/.test(selector)) { + Pattern.prototype[selector] = function() { + return new Puop(this, selector); + }; + } + }); + + // binary operators + ["__add__","__sub__","__mul__","__div__","__mod__"].concat(Object.keys(ops.BINARY_OPS)).forEach(function(selector) { + if (/^[a-z_][a-zA-Z0-9_]*$/.test(selector)) { + Pattern.prototype[selector] = function(b) { + return new Pbop(this, selector, b); + }; + } + }); + + return Pattern; + })(); + + var Puop = (function() { + function Puop(pattern, selector) { + if (!Number.prototype.hasOwnProperty(selector)) { + throw new TypeError("Puop: operator '" + selector + "' not supported"); + } + Pattern.call(this); + this.klassName = "Puop"; + this._pattern = pattern; + this._selector = selector; + } + extend(Puop, Pattern); + + Puop.prototype.clone = function() { + return new Puop(this._pattern.clone(), this._selector); + }; + + Puop.prototype.next = function() { + if (!this._finished) { + var val = this._pattern.next(); + if (isNotNull(val)) { + return val[this._selector].call(val); + } + this._finished = true; + } + return null; + }; + + return Puop; + })(); + + var Pbop = (function() { + function Pbop(pattern, selector, b) { + if (!Number.prototype.hasOwnProperty(selector)) { + throw new TypeError("Pbop: operator '" + selector + "' not supported"); + } + Pattern.call(this); + this.klassName = "Pbop"; + this._pattern = pattern; + this._selector = selector; + this._b = b; + } + extend(Pbop, Pattern); + + Pbop.prototype.clone = function() { + return new Pbop(this._pattern.clone(), this._selector); + }; + + Pbop.prototype.next = function() { + if (!this._finished) { + var val = this._pattern.next(); + if (isNotNull(val)) { + return val[this._selector].call(val, this._b); + } + this._finished = true; + } + return null; + }; + + return Pbop; + })(); + + var Pgeom = (function() { + function Pgeom(start, grow, length) { + Pattern.call(this); + this.klassName = "Pgeom"; + this._start = utils.asNumber(start); + this._grow = utils.asNumber(grow); + this._length = utils.asNumber(length); + this._pos = 0; + this._value = this._start; + } + extend(Pgeom, Pattern); + + Pgeom.prototype.clone = function() { + return new Pgeom(this._start, this._grow, this._length); + }; + + Pgeom.prototype.next = function() { + if (this._pos < this._length) { + var value = this._value; + this._value *= this._grow; + this._pos += 1; + return value; + } else { + this._pos = Infinity; + this._finished = true; + } + return null; + }; + + Pgeom.prototype.reset = function() { + this._pos = 0; + this._value = this._start; + this._finished = false; + return this; + }; + + return Pgeom; + })(); + + var Pseries = (function() { + function Pseries(start, step, length) { + Pattern.call(this); + this.klassName = "Pseries"; + this._start = utils.asNumber(start); + this._step = utils.asNumber(step); + this._length = utils.asNumber(length); + this._pos = 0; + this._value = this._start; + } + extend(Pseries, Pattern); + + Pseries.prototype.clone = function() { + return new Pseries(this._start, this._start, this._length); + }; + + Pseries.prototype.next = function() { + if (this._pos < this._length) { + var value = this._value; + this._value += this._step; + this._pos += 1; + return value; + } else { + this._pos = Infinity; + this._finished = true; + } + return null; + }; + + Pseries.prototype.reset = function() { + this._pos = 0; + this._value = this._start; + this._finished = false; + return this; + }; + + return Pseries; + })(); + + var Pwhite = (function() { + function Pwhite(lo, hi, length) { + Pattern.call(this); + this.klassName = "Pwhite"; + this._lo = utils.asNumber(lo); + this._hi = utils.asNumber(hi); + this._length = utils.asNumber(length); + this._pos = 0; + } + extend(Pwhite, Pattern); + + Pwhite.prototype.clone = function() { + return new Pwhite(this._lo, this._hi, this._length); + }; + + Pwhite.prototype.next = function() { + if (this._pos < this._length) { + this._pos += 1; + return Math.random() * (this._hi - this._lo) + this._lo; + } else { + this._pos = Infinity; + this._finished = true; + } + return null; + }; + + return Pwhite; + })(); + + var ListPattern = (function() { + function ListPattern(list, repeats, offset) { + Pattern.call(this); + this.klassName = "ListPattern"; + this.list = utils.asArray(list); + this.repeats = utils.asNumber(repeats); + this.offset = utils.asNumber(offset); + this._pos = 0; + this._posMax = this.repeats; + this._list = this.list; + } + extend(ListPattern, Pattern); + + ListPattern.prototype.clone = function() { + return new this.constructor(this.list, this.repeats, this.offset); + }; + + ListPattern.prototype.next = function() { + if (this._pos < this._posMax) { + var index = this._calcIndex(); + var item = this._list[index]; + var val = valueOf(item); + if (isNotNull(val)) { + if (!(item instanceof Pattern)) { + this._pos += 1; + } + return val; + } + if (item instanceof Pattern) { + item.reset(); + } + this._pos += 1; + return this.next(); + } else { + this._pos = Infinity; + this._finished = true; + } + return null; + }; + + ListPattern.prototype.reset = function() { + this._pos = 0; + this._finished = false; + var list = this.list; + for (var i = 0, imax = list.length; i < imax; ++i) { + if (list[i] instanceof Pattern) { + list[i].reset(); + } + } + return this; + }; + + return ListPattern; + })(); + + var Pser = (function() { + function Pser(list, repeats, offset) { + ListPattern.call(this, list, repeats, offset); + this.klassName = "Pser"; + } + extend(Pser, ListPattern); + + Pser.prototype._calcIndex = function() { + return (this._pos + this.offset) % this.list.length; + }; + + return Pser; + })(); + + var Pseq = (function() { + function Pseq(list, repeats, offset) { + Pser.call(this, list, repeats, offset); + this.klassName = "Pseq"; + this._posMax = this.repeats * this.list.length; + } + extend(Pseq, Pser); + + return Pseq; + })(); + + var Pshuf = (function() { + function Pshuf(list, repeats) { + Pseq.call(this, list, repeats, 0); + this.klassName = "Pshuf"; + this._list = this.list.slice().sort(shuffle); + } + extend(Pshuf, Pseq); + + var shuffle = function() { return Math.random() - 0.5; }; + + return Pshuf; + })(); + + var Prand = (function() { + function Prand(list, repeats) { + ListPattern.call(this, list, repeats, 0); + this.klassName = "Prand"; + } + extend(Prand, ListPattern); + + Prand.prototype._calcIndex = function() { + return (this.list.length * Math.random())|0; + }; + + return Prand; + })(); + + var Pn = (function() { + function Pn(pattern, repeats) { + Pattern.call(this); + this._pattern = asPattern(pattern); + this._repeats = utils.asNumber(repeats); + this._i = 0; + } + extend(Pn, Pattern); + + Pn.prototype.clone = function() { + return new Pn(this._pattern.clone(), this._repeats); + }; + + Pn.prototype.next = function() { + if (!this._finished) { + var val = this._pattern.next(); + if (isNotNull(val)) { + return val; + } + this._i += 1; + if (this._i !== this._repeats) { + this._pattern.reset(); + return this.next(); + } + this._finished = true; + } + return null; + }; + + Pn.prototype.reset = function() { + this._finished = false; + this._i = 0; + this._pattern.reset(); + return this; + }; + + return Pn; + })(); + + var Pfin = (function() { + function Pfin(count, pattern) { + Pattern.call(this); + this.klassName = "Pfin"; + this._count = utils.asNumber(count); + this._pattern = asPattern(pattern); + this._pos = 0; + } + extend(Pfin, Pattern); + + Pfin.prototype.clone = function() { + return new Pfin(this._count, this._pattern.clone()); + }; + + Pfin.prototype.next = function() { + if (this._pos < this._count) { + var val = this._pattern.next(); + if (isNotNull(val)) { + this._pos += 1; + return val; + } else { + this._pos = Infinity; + this._finished = true; + } + } + return null; + }; + + Pfin.prototype.reset = function() { + this._finished = false; + this._pos = 0; + this._pattern.reset(); + return this; + }; + + return Pfin; + })(); + + var Pstutter = (function() { + function Pstutter(n, pattern) { + Pattern.call(this); + this.klassName = "Pstutter"; + this._n = utils.asNumber(n); + this._pattern = asPattern(pattern); + this._i = n; + this._val = null; + if (this._n === 0) { + this._finished = true; + } + } + extend(Pstutter, Pattern); + + Pstutter.prototype.clone = function() { + return new Pstutter(this._n, this._p.clone()); + }; + + Pstutter.prototype.next = function() { + if (!this._finished) { + if (this._i >= this._n) { + var val = this._pattern.next(); + if (isNotNull(val)) { + this._val = val; + this._i = 1; + return val; + } else { + this._finished = true; + } + } else { + this._i += 1; + return this._val; + } + } + return null; + }; + + Pstutter.prototype.reset = function() { + this._i = this._n; + this._pattern.reset(); + if (this._n !== 0) { + this._finished = false; + } + return this; + }; + + return Pstutter; + })(); + + cc.global.Pgeom = fn(function(start, grow, length) { + return new Pgeom(start, grow, length); + }).defaults("start=0,grow=1,length=Infinity").build(); + cc.global.Pgeom["new"] = cc.global.Pgeom; + + cc.global.Pseries = fn(function(start, step, length) { + return new Pseries(start, step, length); + }).defaults("start=0,step=1,length=Infinity").build(); + cc.global.Pseries["new"] = cc.global.Pseries; + + cc.global.Pwhite = fn(function(lo, hi, length) { + return new Pwhite(lo, hi, length); + }).defaults("lo=0,hi=1,length=Infinity").build(); + cc.global.Pwhite["new"] = cc.global.Pwhite; + + cc.global.Pser = fn(function(list, repeats, offset) { + return new Pser(list, repeats, offset); + }).defaults("list=[],repeats=1,offset=0").build(); + cc.global.Pser["new"] = cc.global.Pser; + + cc.global.Pseq = fn(function(list, repeats, offset) { + return new Pseq(list, repeats, offset); + }).defaults("list,repeats=1,offset=0").build(); + cc.global.Pseq["new"] = cc.global.Pseq; + + cc.global.Pshuf = fn(function(list, repeats) { + return new Pshuf(list, repeats); + }).defaults("list=[],repeats=1").build(); + cc.global.Pshuf["new"] = cc.global.Pshuf; + + cc.global.Prand = fn(function(list, repeats) { + return new Prand(list, repeats); + }).defaults("list=[],repeats=1").build(); + cc.global.Prand["new"] = cc.global.Prand; + + cc.global.Pn = fn(function(pattern, repeats) { + return new Pn(pattern, repeats); + }).defaults("pattern=[],repeats=Infinity").build(); + cc.global.Pn["new"] = cc.global.Pn; + + cc.global.Pfin = fn(function(count, pattern) { + return new Pfin(count, pattern); + }).defaults("count=1,pattern=[]").build(); + cc.global.Pfin["new"] = cc.global.Pfin; + + cc.global.Pstutter = fn(function(n, pattern) { + return new Pstutter(n, pattern); + }).defaults("n=1,pattern=[]").build(); + cc.global.Pstutter["new"] = cc.global.Pstutter; + + module.exports = { + Pattern: Pattern, + Puop : Puop, + Pbop : Pbop, + + Pgeom : Pgeom, + Pseries: Pseries, + Pwhite : Pwhite, + + ListPattern: ListPattern, + Pser : Pser, + Pseq : Pseq, + Pshuf: Pshuf, + Prand: Prand, + + Pn : Pn, + Pfin : Pfin, + Pstutter: Pstutter + }; + +}); +define('cc/lang/ref', function(require, exports, module) { + + var cc = require("./cc"); + var utils = require("./utils"); + + var Ref = (function() { + function Ref(value) { + this.klassName = "Ref"; + this._value = value; + } + Ref.prototype.value = function() { + return this._value; + }; + Ref.prototype.asUGenInput = function() { + return this; + }; + Ref.prototype.dereference = Ref.prototype.value; + Ref.prototype.multichannelExpandRef = function(rank) { + var list = utils.asArray(this._value); + if (utils.maxSizeAtDepth(list, rank) <= 1) { + return this; + } + var reflist = utils.flopDeep(list, rank).map(function(item) { + return new Ref(item); + }); + return utils.unbubble(reflist, 0, 1); + }; + + return Ref; + })(); + + cc.global.$ = function(value) { + return new Ref(value); + }; + + cc.instanceOfRef = function(obj) { + return obj instanceof Ref; + }; + + module.exports = { + Ref: Ref + }; + +}); +define('cc/lang/scale', function(require, exports, module) { + + var cc = require("./cc"); + var fn = require("./fn"); + var extend = require("../common/extend"); + + var ratiomidi = function(list) { + return list.map(function(x) { + return Math.log(x) * Math.LOG2E * 12; + }); + }; + var range = function(to) { + var list = new Array(to); + for (var i = 0; i <= to; ++i) { + list[i] = i; + } + return list; + }; + + var Tuning = (function() { + function Tuning(tuning, octaveRatio, name) { + this.klassName = "Tuning"; + this._tuning = tuning; + this._octaveRatio = octaveRatio; + this.name = name; + } + extend(Tuning, cc.Object); + + Tuning.prototype.semitones = function() { + return this._tuning.slice(); + }; + Tuning.prototype.cents = function() { + return this._tuning.map(function(x) { + return x * 100; + }); + }; + Tuning.prototype.ratios = function() { + return this._tuning.map(function(x) { + return Math.pow(2, x * 1/12); + }); + }; + Tuning.prototype.at = fn(function(index) { + return this._tuning[index]; + }).multiCall().build(); + Tuning.prototype.wrapAt = fn(function(index) { + index = index % this._tuning.length; + if (index < 0) { + index = this._tuning.length + index; + } + return this._tuning[index]; + }).multiCall().build(); + Tuning.prototype.octaveRatio = function() { + return this._octaveRatio; + }; + Tuning.prototype.size = function() { + return this._tuning.length; + }; + Tuning.prototype.stepsPerOctave = function() { + return Math.log(this._octaveRatio) * Math.LOG2E * 12; + }; + Tuning.prototype.tuning = function() { + return this._tuning; + }; + Tuning.prototype.equals = function(that) { + return (that instanceof Tuning) && + (this._octaveRatio === that._octaveRatio) && + this._tuning.every(function(x, i) { + return x === that._tuning[i]; + }, this); + }; + Tuning.prototype.copy = function() { + return new Tuning(this._tuning.slice(0), this._octaveRatio, this.name); + }; + + return Tuning; + })(); + + var tuningInfo = { + et12: [ + ( + [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ] + ), 2, "ET12" + ], + pythagorean: [ + ratiomidi( + [ 1, 256/243, 9/8, 32/27, 81/64, 4/3, 729/512, 3/2, 128/81, 27/16, 16/9, 243/128 ] + ), 2, "Pythagorean" + ], + just: [ + ratiomidi( + [ 1, 16/15, 9/8, 6/5, 5/4, 4/3, 45/32, 3/2, 8/5, 5/3, 9/5, 15/8 ] + ), 2, "Limit Just Intonation" + ], + sept1: [ + ratiomidi( + [ 1, 16/15, 9/8, 6/5, 5/4, 4/3, 7/5, 3/2, 8/5, 5/3, 9/5, 15/8 ] + ), 2, "Septimal Tritone Just Intonation" + ], + sept2: [ + ratiomidi( + [ 1, 16/15, 9/8, 6/5, 5/4, 4/3, 7/5, 3/2, 8/5, 5/3, 7/4, 15/8 ] + ), 2, "7-Limit Just Intonation" + ], + mean4: [ + ( + [ 0, 0.755, 1.93, 3.105, 3.86, 5.035, 5.79, 6.965, 7.72, 8.895, 10.07, 10.82 ] + ), 2, "Meantone, 1/4 Syntonic Comma" + ], + mean5: [ + ( + [ 0, 0.804, 1.944, 3.084, 3.888, 5.028, 5.832, 6.972, 7.776, 8.916, 10.056, 10.86 ] + ), 2, "Meantone, 1/5 Pythagorean Comma" + ], + mean6: [ + ( + [ 0, 0.86, 1.96, 3.06, 3.92, 5.02, 5.88, 6.98, 7.84, 8.94, 10.04, 10.9 ] + ), 2, "Meantone, 1/6 Pythagorean Comma" + ], + kirnberger: [ + ratiomidi( + [ 1, 256/243, Math.sqrt(5)/2, 32/27, 5/4, 4/3, 45/32, Math.pow(5, 0.25), 128/81, Math.pow(5, 0.75)/2, 16/9, 15/8 ] + ), 2, "Kirnberger III" + ], + werckmeister: [ + ( + [ 0, 0.92, 1.93, 2.94, 3.915, 4.98, 5.9, 6.965, 7.93, 8.895, 9.96, 10.935 ] + ), 2, "Werckmeister III" + ], + vallotti: [ + ( + [ 0, 0.94135, 1.9609, 2.98045, 3.92180, 5.01955, 5.9218, 6.98045, 7.9609, 8.94135, 10, 10.90225 ] + ), 2, "Vallotti" + ], + young: [ + ( + [ 0, 0.9, 1.96, 2.94, 3.92, 4.98, 5.88, 6.98, 7.92, 8.94, 9.96, 10.9 ] + ), 2, "Young" + ], + reinhard: [ + ratiomidi( + [ 1, 14/13, 13/12, 16/13, 13/10, 18/13, 13/9, 20/13, 13/8, 22/13, 13/7, 208/105 ] + ), 2, "Mayumi Reinhard" + ], + wcHarm: [ + ratiomidi( + [ 1, 17/16, 9/8, 19/16, 5/4, 21/16, 11/8, 3/2, 13/8, 27/16, 7/4, 15/8 ] + ), 2, "Wendy Carlos Harmonic" + ], + wcSJ: [ + ratiomidi( + [ 1, 17/16, 9/8, 6/5, 5/4, 4/3, 11/8, 3/2, 13/8, 5/3, 7/4, 15/8 ] + ), 2, "Wendy Carlos Super Just" + ], + lu: [ + ratiomidi( + [ 1, 2187/2048, 9/8, 19683/16384, 81/64, 177147/131072, 729/612, 3/2, 6561/4096, 27/16, 59049/32768, 243/128 ] + ), 2, "Chinese Shi-er-lu scale" + ], + et19: [ + range(18).map(function(x) { + return x * 12 / 19; + }), 2, "ET19" + ], + et22: [ + range(22).map(function(x) { + return x * 12 / 22; + }), 2, "ET22" + ], + et24: [ + range(24).map(function(x) { + return x * 12 / 24; + }), 2, "ET24" + ], + et31: [ + range(31).map(function(x) { + return x * 12 / 31; + }), 2, "ET31" + ], + et41: [ + range(41).map(function(x) { + return x * 12 / 41; + }), 2, "ET41" + ], + et53: [ + range(53).map(function(x) { + return x * 12 / 53; + }), 2, "ET53" + ], + johnston: [ + ratiomidi( + [ 1, 25/24, 135/128, 16/15, 10/9, 9/8, 75/64, 6/5, 5/4, 81/64, 32/25, 4/3, 27/20, 45/32, 36/25, 3/2, 25/16, 8/5, 5/3, 27/16, 225/128, 16/9, 9/5, 15/8, 48/25 ] + ), 2, "Ben Johnston" + ], + partch: [ + ratiomidi( + [ 1, 81/80, 33/32, 21/20, 16/15, 12/11, 11/10, 10/9, 9/8, 8/7, 7/6, 32/27, 6/5, 11/9, 5/4, 14/11, 9/7, 21/16, 4/3, 27/20, 11/8, 7/5, 10/7, 16/11, 40/27, 3/2, 32/21, 14/9, 11/7, 8/5, 18/11, 5/3, 27/16, 12/7, 7/4, 16/9, 9/5, 20/11, 11/6, 15/8, 40/21, 64/33, 160/81 ] + ), 2, "Harry Partch" + ], + catler: [ + ratiomidi( + [ 1, 33/32, 16/15, 9/8, 8/7, 7/6, 6/5, 128/105, 16/13, 5/4, 21/16, 4/3, 11/8, 45/32, 16/11, 3/2, 8/5, 13/8, 5/3, 27/16, 7/4, 16/9, 24/13, 15/8 ] + ), 2, "Jon Catler" + ], + chalmers: [ + ratiomidi( + [ 1, 21/20, 16/15, 9/8, 7/6, 6/5, 5/4, 21/16, 4/3, 7/5, 35/24, 3/2, 63/40, 8/5, 5/3, 7/4, 9/5, 28/15, 63/32 ] + ), 2, "John Chalmers" + ], + harrison: [ + ratiomidi( + [ 1, 16/15, 10/9, 8/7, 7/6, 6/5, 5/4, 4/3, 17/12, 3/2, 8/5, 5/3, 12/7, 7/4, 9/5, 15/8 ] + ), 2, "Lou Harrison" + ], + sruti: [ + ratiomidi( + [ 1, 256/243, 16/15, 10/9, 9/8, 32/27, 6/5, 5/4, 81/64, 4/3, 27/20, 45/32, 729/512, 3/2, 128/81, 8/5, 5/3, 27/16, 16/9, 9/5, 15/8, 243/128 ] + ), 2, "Sruti" + ], + parret: [ + ratiomidi( + [1, 21/20, 35/32, 9/8, 7/6, 6/5, 5/4, 21/16, 4/3, 7/5, 35/24, 3/2, 63/40, 8/5, 5/3, 7/4, 9/5, 15/8, 63/32] + ), 2, "Wilfrid Perret" + ], + michael_harrison: [ + ratiomidi( + [1, 28/27, 135/128, 16/15, 243/224, 9/8, 8/7, 7/6, 32/27, 6/5, 135/112, 5/4, 81/64, 9/7, 21/16, 4/3, 112/81, 45/32, 64/45, 81/56, 3/2, 32/21, 14/9, 128/81, 8/5, 224/135, 5/3, 27/16, 12/7, 7/4, 16/9, 15/8, 243/128, 27/14 ] + ), 2, "Michael Harrison 24 tone 7-limit" + ], + harmonic: [ + ratiomidi( + range(24).slice(1) + ), 2, "Harmonic Series 24" + ], + bp: [ + ratiomidi(range(12).map(function(x) { + return x * 19.019550008654 / 13; + }) + ), 3, "Bohlen-Pierce" + ], + wcAlpha: [ + range(14).map(function(x) { + return x * 0.78; + }), 1.9656411970852, "Wendy Carlos Alpha" + ], + wcBeta: [ + range(18).map(function(x) { + return x * 0.638; + }), 2.0141437696805, "Wendy Carlos Beta" + ], + wcGamma: [ + range(33).map(function(x) { + return x * 0.351; + }), 1.9923898962606, "Wendy Carlos Gamma" + ] + }; + + cc.global.Tuning = fn(function(tuning, octaveRatio, name) { + if (!Array.isArray(tuning)) { + tuning = [0,1,2,3,4,5,6,7,8,9,10,11]; + } + if (typeof octaveRatio !== "number") { + octaveRatio = 2; + } + if (typeof name !== "string") { + name = "Unknown Tuning"; + } + return new Tuning(tuning, octaveRatio, name); + }).defaults("tuning,octaveRatio,name").build(); + cc.global.Tuning["new"] = cc.global.Tuning; + + var tunings = {}; + Object.keys(tuningInfo).forEach(function(key) { + var params = tuningInfo[key]; + tunings[key] = new Tuning(params[0], params[1], params[2]); + cc.global.Tuning[key] = tunings[key]; + }); + + cc.global.Tuning.at = function(key) { + var t = tunings[key]; + if (t) { + return t.copy(); + } + return tunings.et12.copy(); + }; + + cc.global.Tuning.choose = fn(function(size) { + if (typeof size !== "number") { + size = 12; + } + var candidates = []; + var keys = Object.keys(tunings); + var t; + for (var i = 0, imax = keys.length; i < imax; ++i) { + t = tunings[keys[i]]; + if (t._tuning.length === size) { + candidates.push(t); + } + } + t = candidates[(Math.random() * candidates.length)|0]; + if (t) { + return t.copy(); + } + return tunings.et12.copy(); + }).multiCall().build(); + + cc.global.Tuning.et = function(pitchesPerOctave) { + var list = new Array(pitchesPerOctave); + for (var i = 0; i < pitchesPerOctave; ++i) { + list[i] = i * (12 / pitchesPerOctave); + } + return new Tuning(list, 2, "ET" + pitchesPerOctave); + }; + + cc.global.Tuning.names = function() { + return Object.keys(tunings).sort(); + }; + + var Scale = (function() { + function Scale(degrees, pitchesPerOctave, tuning, name) { + this.klassName = "Scale"; + this._degrees = degrees; + this._pitchesPerOctave = pitchesPerOctave; + this.name = name; + this.tuning(tuning); + } + extend(Scale, cc.Object); + + Scale.prototype.tuning = function(inTuning) { + if (arguments.length === 0) { + return this._tuning; + } + if (typeof inTuning === "string") { + inTuning = tunings[inTuning]; + } + if (!(inTuning instanceof Tuning)) { + throw new TypeError("Scale: arguments[2] should be a tuning."); + } + if (this._pitchesPerOctave !== inTuning.size()) { + throw new TypeError("Scale steps per octave " + this._pitchesPerOctave + " does not match tuning size."); + } + this._tuning = inTuning; + return inTuning; + }; + Scale.prototype.semitones = function() { + return this._degrees.map(function(i) { + return this._tuning.wrapAt(i); + }, this); + }; + Scale.prototype.cents = function() { + return this.semitones().map(function(x) { + return x * 100; + }); + }; + Scale.prototype.ratios = function() { + return this.semitones().map(function(x) { + return Math.pow(2, x * 1/12); + }); + }; + Scale.prototype.size = function() { + return this._degrees.length; + }; + Scale.prototype.pitchesPerOctave = function() { + return this._pitchesPerOctave; + }; + Scale.prototype.stepsPerOctave = function() { + return Math.log(this.octaveRatio()) * Math.LOG2E * 12; + }; + Scale.prototype.at = fn(function(index) { + index = index % this._degrees.length; + if (index < 0) { + index = this._degrees.length + index; + } + return this._tuning.at(this._degrees[index]); + }).multiCall().build(); + Scale.prototype.wrapAt = fn(function(index) { + index = index % this._degrees.length; + if (index < 0) { + index = this._degrees.length + index; + } + return this._tuning.wrapAt(this._degrees[index]); + }).multiCall().build(); + Scale.prototype.degreeToFreq = fn(function(degree, rootFreq, octave) { + return degreeToRatio(this, degree, octave) * rootFreq; + }).defaults("degree=0,rootFreq=0,octave=0").multiCall().build(); + Scale.prototype.degreeToRatio = fn(function(degree, octave) { + return degreeToRatio(this, degree, octave); + }).defaults("degree=0,octave=0").multiCall().build(); + Scale.prototype.degrees = function() { + return this._degrees; + }; + Scale.prototype.octaveRatio = function() { + return this._tuning.octaveRatio(); + }; + Scale.prototype.equals = function(that) { + return (that instanceof Scale) && + this._degrees.every(function(x, i) { + return x === that._degrees[i]; + }) && this._tuning.equals(that._tuning); + }; + Scale.prototype.copy = function() { + return new Scale( + this._degrees.slice(), + this._pitchesPerOctave, + this._tuning.copy(), + this.name + ); + }; + var degreeToRatio = function(that, degree, octave) { + var ratios = that.ratios(); + var index = degree % ratios.length; + octave += (degree / that._degrees.length)|0; + if (index < 0) { + index = ratios.length + index; + octave -= Math.ceil(index / ratios.length); + } + return ratios[index] * Math.pow(that.octaveRatio(), octave); + }; + + return Scale; + })(); + + var guessPPO = function(degrees) { + var i, max = degrees[0] || 0; + for (i = degrees.length; i--; ) { + if (max < degrees[i]) { + max = degrees[i]; + } + } + var etTypes = [53,24,19,12]; + for (i = etTypes.length; i--; ) { + if (max < etTypes[i]) { + return etTypes[i]; + } + } + return 128; + }; + + var scaleInfo = { + major: [ + [ 0, 2, 4, 5, 7, 9, 11 ], 12, 0, "Major" + ], + minor: [ + [ 0, 2, 3, 5, 7, 8, 10 ], 12, 0, "Natural Minor" + ], + minorPentatonic: [ + [ 0, 3, 5, 7, 10 ], 12, 0, "Minor Pentatonic" + ], + majorPentatonic: [ + [ 0, 2, 4, 7, 9 ], 12, 0, "Major Pentatonic" + ], + ritusen: [ + [ 0, 2, 5, 7, 9 ], 12, 0, "Ritusen" + ], + egyptian: [ + [ 0, 2, 5, 7, 10 ], 12, 0, "Egyptian" + ], + kumoi: [ + [ 0, 2, 3, 7, 9 ], 12, 0, "Kumoi" + ], + hirajoshi: [ + [ 0, 2, 3, 7, 8 ], 12, 0, "Hirajoshi" + ], + iwato: [ + [ 0, 1, 5, 6, 10 ], 12, 0, "Iwato" + ], + ryukyu: [ + [ 0, 4, 5, 7, 11 ], 12, 0, "Ryukyu" + ], + chinese: [ + [ 0, 4, 6, 7, 11 ], 12, 0, "Chinese" + ], + indian: [ + [ 0, 4, 5, 7, 10 ], 12, 0, "Indian" + ], + pelog: [ + [ 0, 1, 3, 7, 8 ], 12, 0, "Pelog" + ], + prometheus: [ + [ 0, 2, 4, 6, 11 ], 12, 0, "Prometheus" + ], + scriabin: [ + [ 0, 1, 4, 7, 9 ], 12, 0, "Scriabin" + ], + gong: [ + [ 0, 2, 4, 7, 9 ], 12, 0, "Gong" + ], + shang: [ + [ 0, 2, 5, 7, 10 ], 12, 0, "Shang" + ], + jiao: [ + [ 0, 3, 5, 8, 10 ], 12, 0, "Jiao" + ], + zhi: [ + [ 0, 2, 5, 7, 9 ], 12, 0, "Zhi" + ], + yu: [ + [ 0, 3, 5, 7, 10 ], 12, 0, "Yu" + ], + whole: [ + [ 0, 2, 4, 6, 8, 10 ], 12, 0, "Whole Tone" + ], + augmented: [ + [ 0, 3, 4, 7, 8, 11 ], 12, 0, "Augmented" + ], + augmented2: [ + [ 0, 1, 4, 5, 8, 9 ], 12, 0, "Augmented 2" + ], + partch_o1: [ + [ 0, 8, 14, 20, 25, 34], 43, "partch", "Partch Otonality 1" + ], + partch_o2: [ + [ 0, 7, 13, 18, 27, 35 ], 43, "partch", "Partch Otonality 2" + ], + partch_o3: [ + [ 0, 6, 12, 21, 29, 36 ], 43, "partch", "Partch Otonality 3" + ], + partch_o4: [ + [ 0, 5, 15, 23, 30, 37 ], 43, "partch", "Partch Otonality 4" + ], + partch_o5: [ + [ 0, 10, 18, 25, 31, 38 ], 43, "partch", "Partch Otonality 5" + ], + partch_o6: [ + [ 0, 9, 16, 22, 28, 33 ], 43, "partch", "Partch Otonality 6" + ], + partch_u1: [ + [ 0, 9, 18, 23, 29, 35 ], 43, "partch", "Partch Utonality 1" + ], + partch_u2: [ + [ 0, 8, 16, 25, 30, 36 ], 43, "partch", "Partch Utonality 2" + ], + partch_u3: [ + [ 0, 7, 14, 22, 31, 37 ], 43, "partch", "Partch Utonality 3" + ], + partch_u4: [ + [ 0, 6, 13, 20, 28, 38 ], 43, "partch", "Partch Utonality 4" + ], + partch_u5: [ + [ 0, 5, 12, 18, 25, 33 ], 43, "partch", "Partch Utonality 5" + ], + partch_u6: [ + [ 0, 10, 15, 21, 27, 34 ], 43, "partch", "Partch Utonality 6" + ], + hexMajor7: [ + [ 0, 2, 4, 7, 9, 11 ], 12, 0, "Hex Major 7" + ], + hexDorian: [ + [ 0, 2, 3, 5, 7, 10 ], 12, 0, "Hex Dorian" + ], + hexPhrygian: [ + [ 0, 1, 3, 5, 8, 10 ], 12, 0, "Hex Phrygian" + ], + hexSus: [ + [ 0, 2, 5, 7, 9, 10 ], 12, 0, "Hex Sus" + ], + hexMajor6: [ + [ 0, 2, 4, 5, 7, 9 ], 12, 0, "Hex Major 6" + ], + hexAeolian: [ + [ 0, 3, 5, 7, 8, 10 ], 12, 0, "Hex Aeolian" + ], + ionian: [ + [ 0, 2, 4, 5, 7, 9, 11 ], 12, 0, "Ionian" + ], + dorian: [ + [ 0, 2, 3, 5, 7, 9, 10 ], 12, 0, "Dorian" + ], + phrygian: [ + [ 0, 1, 3, 5, 7, 8, 10 ], 12, 0, "Phrygian" + ], + lydian: [ + [ 0, 2, 4, 6, 7, 9, 11 ], 12, 0, "Lydian" + ], + mixolydian: [ + [ 0, 2, 4, 5, 7, 9, 10 ], 12, 0, "Mixolydian" + ], + aeolian: [ + [ 0, 2, 3, 5, 7, 8, 10 ], 12, 0, "Aeolian" + ], + locrian: [ + [ 0, 1, 3, 5, 6, 8, 10 ], 12, 0, "Locrian" + ], + harmonicMinor: [ + [ 0, 2, 3, 5, 7, 8, 11 ], 12, 0, "Harmonic Minor" + ], + harmonicMajor: [ + [ 0, 2, 4, 5, 7, 8, 11 ], 12, 0, "Harmonic Major" + ], + melodicMinor: [ + [ 0, 2, 3, 5, 7, 9, 11 ], 12, 0, "Melodic Minor" + ], + melodicMinorDesc: [ + [ 0, 2, 3, 5, 7, 8, 10 ], 12, 0, "Melodic Minor Descending" + ], + melodicMajor: [ + [ 0, 2, 4, 5, 7, 8, 10 ], 12, 0, "Melodic Major" + ], + bartok: [ + [ 0, 2, 4, 5, 7, 8, 10 ], 12, 0, "Bartok" + ], + hindu: [ + [ 0, 2, 4, 5, 7, 8, 10 ], 12, 0, "Hindu" + ], + todi: [ + [ 0, 1, 3, 6, 7, 8, 11 ], 12, 0, "Todi" + ], + purvi: [ + [ 0, 1, 4, 6, 7, 8, 11 ], 12, 0, "Purvi" + ], + marva: [ + [ 0, 1, 4, 6, 7, 9, 11 ], 12, 0, "Marva" + ], + bhairav: [ + [ 0, 1, 4, 5, 7, 8, 11 ], 12, 0, "Bhairav" + ], + ahirbhairav: [ + [ 0, 1, 4, 5, 7, 9, 10 ], 12, 0,"Ahirbhairav" + ], + superLocrian: [ + [ 0, 1, 3, 4, 6, 8, 10 ], 12, 0, "Super Locrian" + ], + romanianMinor: [ + [ 0, 2, 3, 6, 7, 9, 10 ], 12, 0, "Romanian Minor" + ], + hungarianMinor: [ + [ 0, 2, 3, 6, 7, 8, 11 ], 12, 0, "Hungarian Minor" + ], + neapolitanMinor: [ + [ 0, 1, 3, 5, 7, 8, 11 ], 12, 0, "Neapolitan Minor" + ], + enigmatic: [ + [ 0, 1, 4, 6, 8, 10, 11 ], 12, 0, "Enigmatic" + ], + spanish: [ + [ 0, 1, 4, 5, 7, 8, 10 ], 12, 0, "Spanish" + ], + leadingWhole: [ + [ 0, 2, 4, 6, 8, 10, 11 ], 12, 0, "Leading Whole Tone" + ], + lydianMinor: [ + [ 0, 2, 4, 6, 7, 8, 10 ], 12, 0, "Lydian Minor" + ], + neapolitanMajor: [ + [ 0, 1, 3, 5, 7, 9, 11 ], 12, 0, "Neapolitan Major" + ], + locrianMajor: [ + [ 0, 2, 4, 5, 6, 8, 10 ], 12, 0, "Locrian Major" + ], + diminished: [ + [ 0, 1, 3, 4, 6, 7, 9, 10 ], 12, 0, "Diminished" + ], + diminished2: [ + [ 0, 2, 3, 5, 6, 8, 9, 11 ], 12, 0, "Diminished 2" + ], + chromatic: [ + [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ], 12, 0, "Chromatic" + ], + chromatic24: [ + range(23), 24, 0, "Chromatic 24" + ], + ajam: [ + [ 0, 4, 8, 10, 14, 18, 22 ], 24, 0, "Ajam" + ], + jiharkah: [ + [ 0, 4, 8, 10, 14, 18, 21 ], 24, 0, "Jiharkah" + ], + shawqAfza: [ + [ 0, 4, 8, 10, 14, 16, 22 ], 24, 0, "Shawq Afza" + ], + sikah: [ + [ 0, 3, 7, 11, 14, 17, 21 ], 24, 0, "Sikah" + ], + sikahDesc: [ + [ 0 , 3 , 7, 11, 13, 17, 21 ], 24, 0, "Sikah Descending" + ], + huzam: [ + [ 0, 3, 7, 9, 15, 17, 21 ], 24, 0, "Huzam" + ], + iraq: [ + [ 0, 3, 7, 10, 13, 17, 21 ], 24, 0, "Iraq" + ], + bastanikar: [ + [ 0, 3, 7, 10, 13, 15, 21 ], 24, 0, "Bastanikar" + ], + mustar: [ + [ 0, 5, 7, 11, 13, 17, 21 ], 24, 0, "Mustar" + ], + bayati: [ + [ 0, 3, 6, 10, 14, 16, 20 ], 24, 0, "Bayati" + ], + karjighar: [ + [ 0, 3, 6, 10, 12, 18, 20 ], 24, 0, "Karjighar" + ], + husseini: [ + [ 0, 3, 6, 10, 14, 17, 21 ], 24, 0, "Husseini" + ], + nahawand: [ + [ 0, 4, 6, 10, 14, 16, 22 ], 24, 0, "Nahawand" + ], + nahawandDesc: [ + [ 0, 4, 6, 10, 14, 16, 20 ], 24, 0, "Nahawand Descending" + ], + farahfaza: [ + [ 0, 4, 6, 10, 14, 16, 20 ], 24, 0, "Farahfaza" + ], + murassah: [ + [ 0, 4, 6, 10, 12, 18, 20 ], 24, 0, "Murassah" + ], + ushaqMashri: [ + [ 0, 4, 6, 10, 14, 17, 21 ], 24, 0, "Ushaq Mashri" + ], + rast: [ + [ 0, 4, 7, 10, 14, 18, 21 ], 24, 0, "Rast" + ], + rastDesc: [ + [ 0, 4, 7, 10, 14, 18, 20 ], 24, 0, "Rast Descending" + ], + suznak: [ + [ 0, 4, 7, 10, 14, 16, 22 ], 24, 0, "Suznak" + ], + nairuz: [ + [ 0, 4, 7, 10, 14, 17, 20 ], 24, 0, "Nairuz" + ], + yakah: [ + [ 0, 4, 7, 10, 14, 18, 21 ], 24, 0, "Yakah" + ], + yakahDesc: [ + [ 0, 4, 7, 10, 14, 18, 20 ], 24, 0, "Yakah Descending" + ], + mahur: [ + [ 0, 4, 7, 10, 14, 18, 22 ], 24, 0, "Mahur" + ], + hijaz: [ + [ 0, 2, 8, 10, 14, 17, 20 ], 24, 0, "Hijaz" + ], + hijazDesc: [ + [ 0, 2, 8, 10, 14, 16, 20 ], 24, 0, "Hijaz Descending" + ], + zanjaran: [ + [ 0, 2, 8, 10, 14, 16, 22 ], 24, 0, "Zanjaran" + ], + saba: [ + [ 0, 3, 6, 8, 12, 16, 20 ], 24, 0, "Saba" + ], + zamzam: [ + [ 0, 2, 6, 8, 14, 16, 20 ], 24, 0, "Zamzam" + ], + kurd: [ + [ 0, 2, 6, 10, 14, 16, 20 ], 24, 0, "Kurd" + ], + kijazKarKurd: [ + [ 0, 2, 8, 10, 14, 16, 22 ], 24, 0, "Kijaz Kar Kurd" + ], + nawaAthar: [ + [ 0, 4, 6, 12, 14, 16, 22 ], 24, 0, "Nawa Athar" + ], + nikriz: [ + [ 0, 4, 6, 12, 14, 18, 20 ], 24, 0, "Nikriz" + ], + atharKurd: [ + [ 0, 2, 6, 12, 14, 16, 22 ], 24, 0, "Athar Kurd" + ] + }; + + cc.global.Scale = fn(function(degrees, pitchesPerOctave, tuning, name) { + if (!Array.isArray(degrees)) { + degrees = [0,2,4,5,7,9,11]; // ionian + } + if (typeof pitchesPerOctave !== "number") { + pitchesPerOctave = guessPPO(degrees); + } + if (typeof tuning === "string") { + tuning = tunings[tuning]; + } + if (!(tuning instanceof Tuning)) { + tuning = tunings.et12; + } + if (typeof name !== "string") { + name = "Unknown Scale"; + } + return new Scale(degrees, pitchesPerOctave, tuning, name); + }).defaults("degrees,pitchesPerOctave,tuning,name").build(); + cc.global.Scale["new"] = cc.global.Scale; + + var scales = {}; + Object.keys(scaleInfo).forEach(function(key) { + var params = scaleInfo[key]; + if (params[2]) { + params[2] = tunings[params[2]].copy(); + } else { + params[2] = cc.global.Tuning.et(params[1]); + } + scales[key] = new Scale(params[0], params[1], params[2], params[3]); + cc.global.Scale[key] = scales[key]; + }); + + cc.global.Scale.at = function(key, tuning) { + var s = scales[key]; + if (s) { + s = s.copy(); + } else { + s = scales.major.copy(); + } + if (tuning) { + s.tuning(tuning); + } + return s; + }; + + cc.global.Scale.choose = fn(function(size, pitchesPerOctave) { + if (typeof size !== "number") { + size = 7; + } + if (typeof pitchesPerOctave !== "number") { + pitchesPerOctave = 12; + } + var candidates = []; + var keys = Object.keys(scales); + var s; + for (var i = 0, imax = keys.length; i < imax; ++i) { + s = scales[keys[i]]; + if (s._degrees.length === size && s._pitchesPerOctave === pitchesPerOctave) { + candidates.push(s); + } + } + s = candidates[(Math.random() * candidates.length)|0]; + if (s) { + return s.copy(); + } + return scales.major.copy(); + }).multiCall().build(); + + cc.global.Scale.names = function() { + return Object.keys(scales).sort(); + }; + + module.exports = { + Scale : Scale, + Tuning: Tuning + }; + +}); +define('cc/lang/string', function(require, exports, module) { + + var cc = require("./cc"); + var fn = require("./fn"); + var utils = require("./utils"); + var ops = require("../common/ops"); + var numericstring = require("../common/numericstring"); + var timevalue = numericstring.timevalue; + var notevalue = numericstring.notevalue; + var slice = [].slice; + + var asNumber = function(val) { + val = +val; + if (isNaN(val)) { + return 0; + } + return val; + }; + + // common methods + fn.defineProperty(String.prototype, "copy", function() { + return this; + }); + + fn.defineProperty(String.prototype, "clone", fn(function() { + return this; + }).defaults(ops.COMMONS.clone).build()); + + fn.defineProperty(String.prototype, "dup", fn(function(n) { + var a = new Array(n|0); + for (var i = 0, imax = a.length; i < imax; ++i) { + a[i] = this; + } + return a; + }).defaults(ops.COMMONS.dup).build()); + + fn.defineProperty(String.prototype, "value", function() { + return this; + }); + + fn.defineProperty(String.prototype, "valueArray", function() { + return this; + }); + + fn.defineProperty(String.prototype, "do", function(func) { + if (cc.instanceOfSyncBlock(func)) { + if (cc.currentSyncBlockHandler) { + cc.currentSyncBlockHandler.__sync__(func, cc.createTaskArgumentsString(this)); + return this; + } + } + this.split("").forEach(func); + return this; + }); + + fn.defineProperty(String.prototype, "wait", function() { + return this; + }); + + fn.defineProperty(String.prototype, "asUGenInput", function() { + throw new Error("String can't cast to a UGen."); + }); + + fn.defineProperty(String.prototype, "asString", function() { + return this; + }); + + // unary operator methods + ["__plus__","__minus__"].concat(Object.keys(ops.UNARY_OPS)).forEach(function(selector) { + fn.defineProperty(String.prototype, selector, function() { + return asNumber(this)[selector](); + }); + }); + + // binary operator methods + ["__sub__"].concat(Object.keys(ops.BINARY_OPS)).forEach(function(selector) { + fn.defineProperty(String.prototype, selector, function(b) { + return asNumber(this)[selector](b); + }); + }); + fn.defineProperty(String.prototype, "__add__", function(b) { + b = b ? b.asString ? b.asString() : b.toString() : b; + return this + b; + }); + + var repeat = (function() { + var _repeat = function(s, n) { + if (n < 1) { + return ""; + } + if (n % 2) { + return _repeat(s, n - 1) + s; + } + var half = _repeat(s, n >> 1); + return half + half; + }; + return function(s, b) { + if (b === Infinity) { + throw new RangeError(); + } + return _repeat(s, b|0); + }; + })(); + + fn.defineBinaryProperty(String.prototype, "__mul__", function(b) { + if (typeof b === "number") { + return repeat(this, b); + } + return 0; + }); + fn.defineBinaryProperty(String.prototype, "__div__", function(b) { + if (typeof b === "number") { + return utils.clump(this.split(""), Math.ceil(this.length/b)).map(function(items) { + return items.join(""); + }); + } + return 0; + }); + fn.defineBinaryProperty(String.prototype, "__mod__", function(b) { + if (typeof b === "number") { + return utils.clump(this.split(""), Math.floor(b)).map(function(items) { + return items.join(""); + }); + } + return 0; + }); + + // arity operators + Object.keys(ops.ARITY_OPS).forEach(function(selector) { + fn.defineProperty(String.prototype, selector, fn(function() { + var args = slice.call(arguments); + return (0)[selector].apply(asNumber(this), args); + }).defaults(ops.ARITY_OPS[selector]).multiCall().build()); + }); + + fn.defineProperty(String.prototype, "time", function() { + var val = timevalue(this); + if (typeof val === "string") { + return 0; + } + return val; + }); + + fn.defineProperty(String.prototype, "note", function() { + var val = notevalue(this); + if (typeof val === "string") { + return 0; + } + return val; + }); + + module.exports = {}; + +}); +define('cc/lang/syncblock', function(require, exports, module) { + + var cc = require("./cc"); + + var syncblock = function(init) { + var func = function() { + syncblock_reset.call(func); + syncblock_perform.apply(func, arguments); + return func._result; + }; + + if (init && init.isSyncBlock) { + func._segments = init._segments; + } else if (typeof init === "function") { + func._segments = init(); + } else { + func._segments = []; + } + func._state = func._segments.length ? 1 : 2; + func._pc = 0; + func._paused = false; + func._child = null; + func._result = undefined; + + func.isSyncBlock = true; + func.clone = syncblock_clone; + func.reset = syncblock_reset; + func.perform = syncblock_perform; + func.performWait = syncblock_performWait; + func.performWaitState = syncblock_performWaitState; + + return func; + }; + + var syncblock_clone = function() { + return syncblock(this); + }; + + var syncblock_reset = function() { + this._state = this._segments.length ? 1 : 2; + this._pc = 0; + this._paused = false; + this._child = null; + this._result = undefined; + }; + + var syncblock_perform = function() { + var segments = this._segments; + var pc = this._pc, pcmax = segments.length; + var result; + + if (this._state === 2) { + return; + } + + if (this._child) { + this.perform.apply(this._child, arguments); + if (this._child._state === 1) { + return; + } + this._child = null; + } + + cc.currentSyncBlock = this; + this._paused = false; + while (pc < pcmax) { + result = segments[pc++].apply(null, arguments); + if (this._paused) { + break; + } + if (result && result.isSyncBlock) { + this._child = result; + break; + } + } + if (pcmax <= pc && !(this._paused)) { + this._state = 2; + this._result = result; + } + this._paused = false; + cc.currentSyncBlock = null; + this._pc = pc; + }; + + var syncblock_performWait = function() { + return this._state === 1; + }; + var syncblock_performWaitState = function() { + return this._state === 1; + }; + + cc.global.syncblock = function(init) { + return syncblock(init); + }; + cc.instanceOfSyncBlock = function(obj) { + return obj && !!obj.isSyncBlock; + }; + cc.pauseSyncBlock = function() { + if (cc.currentSyncBlock) { + cc.currentSyncBlock._paused = true; + } + }; + + module.exports = {}; + +}); +define('cc/lang/synthdef', function(require, exports, module) { + + var cc = require("./cc"); + var utils = require("./utils"); + var extend = require("../common/extend"); + var push = [].push; + + var defId = 0; + + var SynthDef = (function() { + function SynthDef(name) { + this.klassName = "SynthDef"; + this.name = name; + this._sent = false; + this._defId = defId++; + this._children = []; + this._args = []; + this.specs = {}; + } + extend(SynthDef, cc.Object); + + SynthDef.prototype.send = function() { + if (!this._sent) { + cc.lang.pushToTimeline([ + "/s_def", this._defId, this.specs + ]); + this._sent = true; + } + return this; + }; + + SynthDef.prototype.add = SynthDef.prototype.send; + + SynthDef.prototype.play = function() { + this.send(); + + var list = getSynthDefPlayArguments.apply(null, arguments); + var target = list[0]; + var args = list[1]; + var addAction = list[2]; + switch (addAction) { + case "addToHead": + return cc.global.Synth(this, args, target, 0); + case "addToTail": + return cc.global.Synth(this, args, target, 1); + case "addBefore": + return cc.global.Synth(this, args, target, 2); + case "addAfter": + return cc.global.Synth(this, args, target, 3); + default: + return cc.global.Synth(this, args, target, 0); + } + }; + + return SynthDef; + })(); + + var getSynthDefPlayArguments = function() { + var target, args, addAction; + var i = 0; + if (cc.instanceOfNode(arguments[i])) { + target = arguments[i++]; + } else { + target = cc.lang.rootNode; + } + if (utils.isDict(arguments[i])) { + args = arguments[i++]; + } + if (typeof arguments[i] === "string") { + addAction = arguments[i]; + } else { + addAction = "addToHead"; + } + if (args && arguments.length === 1) { + if (cc.instanceOfNode(args.target)) { + target = args.target; + delete args.target; + } + if (typeof args.addAction === "string") { + addAction = args.addAction; + delete args.addAction; + } + } + return [target, args, addAction]; + }; + + var build = function(that, func, args, rates, prependArgs, variants) { + try { + initBuild(that); + buildUGenGraph(that, func, args, rates, prependArgs); + finishBuild(that, variants); + that.func = func; + } finally { + cc.setSynthDef(null); + } + }; + + var initBuild = function(that) { + var children = that._children = []; + cc.setSynthDef(function(ugen) { + children.push(ugen); + }); + that._args = []; + }; + var buildUGenGraph = function(that, func, args, rates, prependArgs) { + var controls = args2controls(args, rates, prependArgs.length); + push.apply(that._args, controls); + args = prependArgs.concat(controls2args(controls)); + return func.apply(null, args); + }; + var finishBuild = function(that) { + cc.setSynthDef(null); + that.specs = asJSON(that.name, that._args, that._children); + }; + + var asNumber = function(val) { + if (val === "Infinity") { + return Infinity; + } else if (val === "-Infinity") { + return -Infinity; + } + return JSON.parse(val); + }; + + var args2controls = function(args, rates, skipArgs) { + if (args.length === 0) { + return []; + } + var keyValues = args2keyValues(args); + var keys = keyValues.keys.slice(skipArgs); + var vals = keyValues.vals.slice(skipArgs).map(asNumber); + + checkValidArgs(vals); + + return keyValueRates2args(keys, vals, rates); + }; + + var args2keyValues = function(args) { + var keys = [], vals = []; + if (args && args.length) { + for (var i = 0, imax = args.length; i < imax; i += 2) { + keys.push(args[i+0]); + vals.push(args[i+1]); + } + } + return { keys:keys, vals:vals }; + }; + + var checkNumber = function(val) { + return typeof val === "number" && !isNaN(val); + }; + + var checkValidArgs = function(vals) { + for (var i = 0, imax = vals.length; i < imax; ++i) { + var val = vals[i]; + if (val === null || val === undefined) { + continue; + } + if (checkNumber(val) || (Array.isArray(val) && val.every(checkNumber))) { + continue; + } + throw "bad arguments:" + utils.asString(val); + } + return true; + }; + + var IR = 0, TR = 1, KR = 2, AR = 3; + + var keyValueRates2args = function(keys, vals, rates) { + var args = []; + for (var i = 0, imax = keys.length; i < imax; ++i) { + var key = keys[i]; + var value = vals[i]; + var rate = rates[i]; + var keyAt01 = key.substr(0, 2); + args[i] = { index:i, name:key, value:value, lag:0 }; + if (rate === "ir" || keyAt01 === "i_") { + args[i].type = IR; + } else if (rate === "tr" || key === "trig" || keyAt01 === "t_") { + args[i].type = TR; + } else if (rate === "ar" || keyAt01 === "a_") { + args[i].type = AR; + } else { + rate = utils.asNumber(rate); + args[i].type = KR; + args[i].lag = rate; + } + } + return args; + }; + + var getValue = function(items) { + return items.value; + }; + + var controls2args = function(controls) { + var args = new Array(controls.length); + var values, lags, lagFlag, controlUGens; + var controlNames = []; + var irControlNames = controlNames[IR] = []; + var trControlNames = controlNames[TR] = []; + var arControlNames = controlNames[AR] = []; + var krControlNames = controlNames[KR] = []; + controls.forEach(function(cn) { + controlNames[cn.type].push(cn); + }); + var setToArgs = function(cn, index) { + args[cn.index] = controlUGens[index]; + }; + if (irControlNames.length) { + values = irControlNames.map(getValue); + controlUGens = cc.createControl(0).init(utils.flatten(values)); + controlUGens = reshape(values, utils.asArray(controlUGens)); + irControlNames.forEach(setToArgs); + } + if (trControlNames.length) { + values = trControlNames.map(getValue); + controlUGens = cc.createTrigControl().init(utils.flatten(values)); + controlUGens = reshape(values, utils.asArray(controlUGens)); + trControlNames.forEach(setToArgs); + } + if (arControlNames.length) { + values = arControlNames.map(getValue); + controlUGens = cc.createAudioControl().init(utils.flatten(values)); + controlUGens = reshape(values, utils.asArray(controlUGens)); + arControlNames.forEach(setToArgs); + } + if (krControlNames.length) { + values = []; lags = []; lagFlag = false; + krControlNames.forEach(function(cn) { + values.push(cn.value); + utils.asArray(cn.value).forEach(function() { lags.push(cn.lag); }); + if (cn.lag !== 0) { lagFlag = true; } + }); + if (lagFlag) { + controlUGens = cc.createLagControl().init(utils.flatten(values), lags); + } else { + controlUGens = cc.createControl(1).init(utils.flatten(values)); + } + controlUGens = reshape(values, utils.asArray(controlUGens)); + krControlNames.forEach(setToArgs); + } + return args; + }; + + var reshape = function(shape, flatten) { + var result = []; + var saved = flatten.slice(); + for (var i = 0, imax = shape.length; i < imax; ++i) { + if (Array.isArray(shape[i])) { + result.push(saved.splice(0, shape[i].length)); + } else { + result.push(saved.shift()); + } + } + return result; + }; + + var sort = function(a, b) { + return (a.type - b.type) || (a.index - b.index); + }; + + var filterUGen = function(ugen) { + return !(typeof ugen === "number" || cc.instanceOfOutputProxy(ugen)); + }; + + var getRate = function(ugen) { + return ugen.rate; + }; + + var asJSON = function(name, args, children) { + var sortedArgs = args.slice().sort(sort); + + var param = {}; + var sortedIndex = 0; + var values = param.values = []; + var names = param.names = []; + var indices = param.indices = []; + var length = param.length = []; + sortedArgs.forEach(function(cn) { + cn.sortedIndex = sortedIndex; + if (Array.isArray(cn.value)) { + push.apply(values, cn.value); + cn.length = cn.value.length; + } else { + values.push(cn.value); + cn.length = 1; + } + sortedIndex += cn.length; + }); + args.forEach(function(cn) { + names .push(cn.name); + indices.push(cn.sortedIndex); + length .push(cn.length); + }); + var consts = []; + children.forEach(function(ugen) { + ugen.inputs.forEach(function(x) { + if (typeof x === "number" && consts.indexOf(x) === -1) { + consts.push(x); + } + }); + }); + consts.sort(); + + var specialIndex = 0; + children.forEach(function(ugen) { + if (cc.instanceOfControlUGen(ugen)) { + ugen.specialIndex = specialIndex; + specialIndex += ugen.channels.length; + } + }); + + var ugenList = topoSort(children).filter(filterUGen); + var heapSize = param.values.length; + + var defList = ugenList.map(function(ugen) { + var inputs = []; + ugen.inputs.forEach(function(x) { + var index = ugenList.indexOf(cc.instanceOfOutputProxy(x) ? x.inputs[0] : x); + var subindex = (index !== -1) ? x.outputIndex : consts.indexOf(x); + inputs.push(index, subindex); + }); + var outputs = []; + if (ugen.channels) { + outputs = ugen.channels.map(getRate); + } else if (ugen.numOutputs === 1) { + outputs = [ ugen.rate ]; + } + for (var i = 0, imax = outputs.length; i < imax; ++i) { + heapSize += outputs[i] === 2 ? 64 : 1; + } + return [ ugen.klassName, ugen.rate, ugen.specialIndex|0, inputs, outputs ]; + }); + return { name:name, consts:consts, params:param, defList:defList, variants:{}, heapSize:heapSize }; + }; + + var topoSort = (function() { + var _topoSort = function(x, list, checked, stack) { + if (stack.indexOf(x) !== stack.length-1) { + throw new Error("UGen graph contains recursion."); + } + checked.push(x); + var index = list.indexOf(x); + if (index !== -1) { + list.splice(index, 1); + } + list.unshift(x); + if (x.inputs) { + x.inputs.forEach(function(x) { + stack.push(x); + _topoSort(x, list, checked, stack); + stack.pop(); + }); + } + }; + return function(list) { + var checked = []; + var stack; + list.slice().forEach(function(x) { + if (cc.instanceOfOut(x)) { + checked.push(x); + stack = [x]; + x.inputs.forEach(function(x) { + stack.push(x); + _topoSort(x, list, checked, stack); + stack.pop(); + }); + } + }); + list = list.filter(function(x) { + return checked.indexOf(x) !== -1; + }); + return list; + }; + })(); + + cc.global.SynthDef = function() { + var name, func, args, rates, prependArgs, variants; + var i = 0; + if (typeof arguments[i] === "string") { + name = arguments[i++]; + } else { + name = "synth"; + } + if (typeof arguments[i] !== "function") { + throw new Error("SynthDef requires build function"); + } + func = arguments[i++]; + + args = utils.asArray(arguments[i++]); + rates = utils.asArray(arguments[i++]); + prependArgs = utils.asArray(arguments[i++]); + variants = {}; + + var instance = new SynthDef(name, func, args, rates, prependArgs, variants); + build(instance, func, args, rates, prependArgs, variants); + return instance; + }; + cc.global.SynthDef["new"] = cc.global.SynthDef; + + cc.instanceOfSynthDef = function(obj) { + return obj instanceof SynthDef; + }; + + module.exports = { + SynthDef: SynthDef, + + build: build, + + initBuild : initBuild, + buildUGenGraph: buildUGenGraph, + finishBuild : finishBuild, + + args2keyValues : args2keyValues, + args2controls : args2controls, + checkValidArgs : checkValidArgs, + keyValueRates2args: keyValueRates2args, + + controls2args: controls2args, + + asJSON: asJSON, + + reshape : reshape, + topoSort: topoSort + }; + +}); +define('cc/lang/task', function(require, exports, module) { + + var cc = require("./cc"); + var extend = require("../common/extend"); + + var valueOf = function(obj) { + if (obj === null || obj === undefined) { + return null; + } + return obj.valueOf(); + }; + + var TaskManager = (function() { + function TaskManager() { + this.klassName = "TaskManager"; + this.tasks = []; + this.counterIncr = 0; + } + + TaskManager.prototype.start = function(counterIncr) { + this.counterIncr = Math.max(1, counterIncr); + }; + + TaskManager.prototype.stop = function() { + this.counterIncr = 0; + }; + + TaskManager.prototype.reset = function() { + this.tasks.splice(0); + }; + + TaskManager.prototype.append = function(task) { + var index = this.tasks.indexOf(task); + if (index === -1) { + this.tasks.push(task); + } + }; + + TaskManager.prototype.remove = function(task) { + var index = this.tasks.indexOf(task); + if (index !== -1) { + this.tasks.splice(index, 1); + } + }; + + TaskManager.prototype.process = function() { + var counterIncr = this.counterIncr; + if (counterIncr) { + var tasks = this.tasks; + for (var i = 0; i < tasks.length; ++i) { + tasks[i].performWait(counterIncr); + } + this.tasks = tasks.filter(function(task) { + return task._state === 1; + }); + } + }; + + return TaskManager; + })(); + + var Task = (function() { + function Task(func, iter) { + this.klassName = "Task"; + if (cc.instanceOfSyncBlock(func)) { + this._func = func; + this._state = 0; + } else { + this._func = null; + this._state = 2; + } + this._iter = iter; + this._wait = null; + this._args = valueOf(iter); + this._remain = 0; // number + } + extend(Task, cc.Object); + + Task.prototype.start = function() { + this.reset(); + if (cc.taskManager) { + cc.taskManager.append(this); + } + this._state = 1; + return this; + }; + + Task.prototype.resume = function() { + if (cc.taskManager) { + cc.taskManager.append(this); + } + this._state = 1; + return this; + }; + + Task.prototype.pause = function() { + if (cc.taskManager) { + cc.taskManager.remove(this); + } + this._state = 0; + return this; + }; + + Task.prototype.stop = function() { + if (cc.taskManager) { + cc.taskManager.remove(this); + } + this._state = 0; + return this; + }; + + Task.prototype.reset = function() { + if (this._func) { + this._func.reset(); + this._state = 0; + } else { + this._state = 2; + } + if (this._iter) { + this._iter.reset(); + } + this._wait = null; + this._args = valueOf(this._iter); + return this; + }; + + Task.prototype.wait = function() { + if (cc.currentTask && cc.currentTask !== this) { + cc.currentTask.__wait__(this); + } + return this; + }; + + Task.prototype.__sync__ = function(func, args) { + return this.__wait__(new Task(func, args)); + }; + + Task.prototype.__wait__ = function(task) { + if (this._wait) { + throw new Error("Task#append: wait already exists???"); + } + if (typeof task === "number") { + task += this._remain; + } + this._remain = 0; + this._wait = cc.createTaskWaitToken(task); + if (task instanceof Task) { + task._state = 1; + } + cc.pauseSyncBlock(); + return this; + }; + + Task.prototype.performWait = function(counterIncr) { + var _currentSyncBlockHandler = cc.currentSyncBlockHandler; + var _currentTask = cc.currentTask; + var func = this._func; + var iter = this._iter; + + cc.currentSyncBlockHandler = this; + cc.currentTask = this; + + while (true) { + if (this._wait) { + if (this._wait.performWait(counterIncr)) { + break; + } + this._remain = this._wait.remain || 0; + this._wait = null; + } + counterIncr = 0; + + func.perform.apply(func, this._args); + + if (this._wait) { + continue; + } + + if (func.performWaitState()) { + continue; + } + + if (iter) { + this._args = iter.next(); + if (iter.performWaitState()) { + func.reset(); + continue; + } + } + this._state = 2; + break; + } + + cc.currentSyncBlockHandler = _currentSyncBlockHandler; + cc.currentTask = _currentTask; + + return this._state === 1; + }; + + Task.prototype.performWaitState = function() { + return this._state === 1; + }; + + return Task; + })(); + + var TaskArguments = (function() { + function TaskArguments() { + this.klassName = "TaskArguments"; + this._args = [ 0, 0 ]; + this._state = 1; + } + + TaskArguments.prototype.next = function() { + if (this._state === 2) { + return null; + } + this._state = 2; + return this._args; + }; + + TaskArguments.prototype.reset = function() { + this._state = 1; + return this; + }; + + TaskArguments.prototype.valueOf = function() { + return this._args; + }; + + TaskArguments.prototype.performWait = function() { + return this._state === 1; + }; + + TaskArguments.prototype.performWaitState = function() { + return this._state === 1; + }; + + return TaskArguments; + })(); + + var TaskArgumentsNumber = (function() { + function TaskArgumentsNumber(start, end, step) { + TaskArguments.call(this); + this.klassName = "TaskArgumentsNumber"; + this.start = start; + this.end = end; + this.step = step; + this.index = 0; + this.reset(); + } + extend(TaskArgumentsNumber, TaskArguments); + + TaskArgumentsNumber.prototype.next = function() { + if (this._state === 2) { + return null; + } + var value = this._args[0] + this.step; + if (this.step >= 0) { + if (value <= this.end) { + this._args[0] = value; + this._args[1] = ++this.index; + } else { + this._state = 2; + } + } else { + if (value >= this.end) { + this._args[0] = value; + this._args[1] = ++this.index; + } else { + this._state = 2; + } + } + return this._state === 2 ? null : this._args; + }; + + TaskArguments.prototype.reset = function() { + this.index = 0; + this._args = [ this.start, this.index ]; + this._state = 1; + return this; + }; + + return TaskArgumentsNumber; + })(); + + var TaskArgumentsArray = (function() { + function TaskArgumentsArray(list, reversed) { + TaskArguments.call(this); + this.klassName = "TaskArgumentsArray"; + this.list = list; + this.reversed = reversed; + this.reset(); + } + extend(TaskArgumentsArray, TaskArguments); + + TaskArgumentsArray.prototype.next = function() { + if (this._state === 2) { + return null; + } + if (this.reversed) { + this.index -= 1; + if (0 <= this.index) { + this._args = [ this.list[this.index], this.index ]; + } else { + this._state = 2; + } + } else { + this.index += 1; + if (this.index < this.list.length) { + this._args = [ this.list[this.index], this.index ]; + } else { + this._state = 2; + } + } + return this._state === 2 ? null : this._args; + }; + + TaskArgumentsArray.prototype.reset = function() { + this.index = this.reversed ? Math.max(0, this.list.length - 1) : 0; + this._args = [ this.list[this.index], this.index ]; + this._state = 1; + return this; + }; + + return TaskArgumentsArray; + })(); + + var TaskArgumentsFunction = (function() { + function TaskArgumentsFunction(func) { + TaskArguments.call(this); + this.klassName = "TaskArgumentsFunction"; + this.func = func; + this.index = 0; + this.reset(); + } + extend(TaskArgumentsFunction, TaskArguments); + + TaskArgumentsFunction.prototype.next = function() { + if (this._state === 2) { + return null; + } + var value = this.func(); + if (!!value || value === 0) { + this._args[0] = value; + this._args[1] = ++this.index; + } else { + this._state = 2; + } + return this._state === 2 ? null : this._args; + }; + + TaskArgumentsFunction.prototype.reset = function() { + this._state = 1; + this.uninitialized = true; + return this; + }; + + TaskArgumentsFunction.prototype.valueOf = function() { + this.index = 0; + if (this.uninitialized) { + this.uninitialized = false; + this._args = [ this.func(), this.index ]; + } + return this._args; + }; + + return TaskArgumentsFunction; + })(); + + var TaskArgumentsPattern = (function() { + function TaskArgumentsPattern(pattern) { + TaskArguments.call(this); + this.klassName = "TaskArgumentsPattern"; + this.pattern = pattern; + this.reset(); + } + extend(TaskArgumentsPattern, TaskArguments); + + TaskArgumentsPattern.prototype.next = function() { + if (this._state === 2) { + return null; + } + var val = this.pattern.next(); + if (val !== null && val !== undefined) { + this._args = [ val, this.index++ ]; + } else { + this._state = 2; + } + return this._state === 2 ? null : this._args; + }; + + TaskArgumentsPattern.prototype.reset = function() { + this.index = 0; + this._args = [ this.pattern.reset().next(), this.index++ ]; + this._state = 1; + return this; + }; + + return TaskArgumentsPattern; + })(); + + var TaskWaitToken = (function() { + function TaskWaitToken() { + this.klassName = "TaskWaitToken"; + this._state = 1; + } + + TaskWaitToken.prototype.performWait = function() { + return this._state === 1; + }; + + TaskWaitToken.prototype.performWaitState = function() { + return this._state === 1; + }; + + return TaskWaitToken; + })(); + + var TaskWaitTokenNumber = (function() { + function TaskWaitTokenNumber(token) { + TaskWaitToken.call(this); + this.klassName = "TaskWaitTokenNumber"; + this.token = token * 1000; + } + extend(TaskWaitTokenNumber, TaskWaitToken); + + TaskWaitTokenNumber.prototype.performWait = function(counterIncr) { + if (this._state === 1) { + this.token -= counterIncr; + if (this.token <= 0) { + this._state = 2; + this.remain = this.token * 0.001; + } + } + return this._state === 1; + }; + + return TaskWaitTokenNumber; + })(); + + var TaskWaitTokenLogicAND = (function() { + function TaskWaitTokenLogicAND(token) { + TaskWaitToken.call(this); + this.klassName = "TaskWaitTokenLogicAND"; + this.token = token.map(cc.createTaskWaitToken); + } + extend(TaskWaitTokenLogicAND, TaskWaitToken); + + TaskWaitTokenLogicAND.prototype.performWait = function(counterIncr) { + if (this._state === 1) { + this.token = this.token.filter(function(token) { + return token.performWait(counterIncr); + }); + if (this.token.length === 0) { + this._state = 2; + } + } + return this._state === 1; + }; + + return TaskWaitTokenLogicAND; + })(); + + var TaskWaitTokenLogicOR = (function() { + function TaskWaitTokenLogicOR(token) { + TaskWaitToken.call(this); + this.klassName = "TaskWaitTokenLogicOR"; + this.token = token.map(cc.createTaskWaitToken); + } + extend(TaskWaitTokenLogicOR, TaskWaitToken); + + TaskWaitTokenLogicOR.prototype.performWait = function(counterIncr) { + if (this._state === 1) { + var list = this.token; + for (var i = 0, imax = list.length; i < imax; ++i) { + if (!list[i].performWait(counterIncr)) { + this._state = 2; + this.token.splice(0); + break; + } + } + } + return this._state === 1; + }; + + return TaskWaitTokenLogicOR; + })(); + + var TaskWaitTokenFunction = (function() { + function TaskWaitTokenFunction(token) { + TaskWaitToken.call(this); + this.klassName = "TaskWaitTokenFunction"; + this.token = token; + } + extend(TaskWaitTokenFunction, TaskWaitToken); + + TaskWaitTokenFunction.prototype.performWait = function() { + if (this._state === 1) { + var finished = this.token(); + if (finished) { + this._state = 2; + } + } + return this._state === 1; + }; + + return TaskWaitTokenFunction; + })(); + + var TaskWaitTokenBoolean = (function() { + function TaskWaitTokenBoolean(token) { + TaskWaitToken.call(this); + this.klassName = "TaskWaitTokenBoolean"; + this.token = token; + this._state = token ? 1 : 2; + } + extend(TaskWaitTokenBoolean, TaskWaitToken); + + return TaskWaitTokenBoolean; + })(); + + var TaskWaitTokenDate = (function() { + function TaskWaitTokenDate(token) { + TaskWaitToken.call(this); + this.klassName = "TaskWaitTokenDate"; + this.token = +token; + } + extend(TaskWaitTokenDate, TaskWaitToken); + + TaskWaitTokenDate.prototype.performWait = function() { + if (this._state === 1) { + if (Date.now() > this.token) { + this._state = 2; + } + } + return this._state === 1; + }; + + return TaskWaitTokenDate; + })(); + + cc.global.Task = function(func) { + return new Task(func); + }; + + cc.createTaskManager = function() { + cc.taskManager = new TaskManager(); + return cc.taskManager; + }; + cc.instanceOfTaskManager = function(obj) { + return obj instanceof TaskManager; + }; + cc.createTask = function(func, iter) { + return new Task(func, iter); + }; + cc.instanceOfTask = function(obj) { + return obj instanceof Task; + }; + cc.instanceOfTaskArguments = function(obj) { + return obj instanceof TaskArguments; + }; + cc.createTaskArgumentsNumber = function(start, end, step) { + return new TaskArgumentsNumber(start, end, step); + }; + cc.createTaskArgumentsArray = function(list, reversed) { + return new TaskArgumentsArray(list, !!reversed); + }; + cc.createTaskArgumentsOnce = function(item) { + return new TaskArgumentsArray([item]); + }; + cc.createTaskArgumentsPattern = function(p) { + return new TaskArgumentsPattern(p); + }; + cc.createTaskWaitToken = function(token, logic) { + if (token && typeof token.performWait === "function") { + return token; + } + switch (typeof token) { + case "number" : return new TaskWaitTokenNumber(token); + case "function": return new TaskWaitTokenFunction(token); + case "boolean" : return new TaskWaitTokenBoolean(token); + } + if (Array.isArray(token)) { + return cc.createTaskWaitTokenArray(token, logic); + } + if (token instanceof Date) { + return new TaskWaitTokenDate(token); + } + return new TaskWaitTokenBoolean(false); + }; + cc.instanceOfTaskWaitToken = function(obj) { + return obj instanceof TaskWaitToken; + }; + cc.createTaskWaitTokenNumber = function(token) { + return new TaskWaitTokenNumber(token); + }; + cc.createTaskWaitTokenArray = function(token, logic) { + if (logic === "or") { + return new TaskWaitTokenLogicOR(token); + } else { + return new TaskWaitTokenLogicAND(token); + } + }; + cc.createTaskWaitTokenFunction = function(token) { + return new TaskWaitTokenFunction(token); + }; + cc.createTaskWaitTokenBoolean = function(token) { + return new TaskWaitTokenBoolean(token); + }; + cc.createTaskWaitTokenDate = function(token) { + return new TaskWaitTokenDate(token); + }; + + module.exports = { + TaskManager : TaskManager, + Task : Task, + TaskArguments : TaskArguments, + TaskArgumentsNumber : TaskArgumentsNumber, + TaskArgumentsArray : TaskArgumentsArray, + TaskArgumentsFunction: TaskArgumentsFunction, + TaskWaitToken : TaskWaitToken, + TaskWaitTokenNumber : TaskWaitTokenNumber, + TaskWaitTokenLogicAND: TaskWaitTokenLogicAND, + TaskWaitTokenLogicOR : TaskWaitTokenLogicOR, + TaskWaitTokenFunction: TaskWaitTokenFunction, + TaskWaitTokenBoolean : TaskWaitTokenBoolean, + TaskWaitTokenDate : TaskWaitTokenDate + }; + +}); +define('cc/lang/ugen', function(require, exports, module) { + + var cc = require("./cc"); + var fn = require("./fn"); + var utils = require("./utils"); + var extend = require("../common/extend"); + var ops = require("../common/ops"); + var slice = [].slice; + + var addToSynthDef = null; + var newKlassOpts = {}; // TODO: ... + + var newArgsWithIndex = function(index) { + return function(item) { + if (Array.isArray(item)) { + return item[index % item.length]; + } + return item; + }; + }; + var rate2str = function(rate) { + return ["scalar","control","audio","demand"][rate] || "scalar"; + }; + + cc.ugen.checkNInputs = function(n) { + if (this.rate === 2) { + for (var i = 0; i < n; ++i) { + if (this.inputs[i].rate !== 2) { + var str = utils.asString(this.inputs[i]) + " " + rate2str(this.inputs[i].rate); + throw new Error("input[" + i + "] is not AUDIO rate: " + str); + } + } + } + }; + cc.ugen.checkSameRateAsFirstInput = function() { + if (this.rate !== this.inputs[0].rate) { + var str = utils.asString(this.inputs[0]) + " " + rate2str(this.inputs[0].rate); + throw new Error("first input is not " + rate2str(this.rate) + " rate: " + str); + } + }; + + var UGen = (function() { + function UGen(name, opts) { + opts = opts || {}; + this.klassName = name; + this.rate = 2; + this.signalRange = opts.signalRange || 2; + this.specialIndex = 0; + this.outputIndex = 0; + this.numInputs = 0; + this.numOutputs = 1; + this.inputs = []; + } + extend(UGen, cc.Object); + + UGen.multiNew = function() { + return this.multiNewList(slice.call(arguments)); + }; + + UGen.multiNewList = function(args) { + var Klass = this; + var size = 0, i, imax; + args = utils.asUGenInput(args); + for (i = 0, imax = args.length; i < imax; ++i) { + if (Array.isArray(args[i]) && size < args[i].length) { + size = args[i].length; + } + } + if (size === 0) { + return UGen.prototype.init.apply(new Klass(newKlassOpts.name, newKlassOpts), args); + } + var results = new Array(size); + for (i = 0; i < size; ++i) { + results[i] = this.multiNewList(args.map(newArgsWithIndex(i))); + } + return results; + }; + + UGen.prototype.init = function(rate) { + this.rate = rate; + if (addToSynthDef) { + addToSynthDef(this); + } + this.inputs = slice.call(arguments, 1); + this.numInputs = this.inputs.length; + return this; + }; + + // common methods + UGen.prototype.copy = function() { + return this; + }; + + UGen.prototype.clone = fn(function() { + return this; + }).defaults(ops.COMMONS.clone).build(); + + UGen.prototype.dup = fn(function(n) { + var a = new Array(n|0); + for (var i = 0, imax = a.length; i < imax; ++i) { + a[i] = this; + } + return a; + }).defaults(ops.COMMONS.dup).build(); + + UGen.prototype["do"] = function() { + return this; + }; + + UGen.prototype.wait = function() { + return this; + }; + + UGen.prototype.asUGenInput = function() { + return this; + }; + + UGen.prototype.asString = function() { + return this.klassName; + }; + + // unary operator methods + ["__plus__","__minus__"].concat(Object.keys(ops.UNARY_OPS)).forEach(function(selector) { + var ugenSelector; + if (ops.ALIASES.hasOwnProperty(selector)) { + ugenSelector = ops.ALIASES[selector]; + } else { + ugenSelector = selector; + } + if (/^[a-z_][a-zA-Z0-9_]*$/.test(selector)) { + UGen.prototype[selector] = function() { + return cc.createUnaryOpUGen(ugenSelector, this); + }; + } + }); + + // binay operator methods + ["__add__","__sub__","__mul__","__div__","__mod__"].concat(Object.keys(ops.BINARY_OPS)).forEach(function(selector) { + var ugenSelector; + if (ops.ALIASES.hasOwnProperty(selector)) { + ugenSelector = ops.ALIASES[selector]; + } else { + ugenSelector = selector; + } + if (/^[a-z_][a-zA-Z0-9_]*$/.test(selector)) { + fn.defineBinaryProperty(UGen.prototype, selector, function(b) { + return cc.createBinaryOpUGen(ugenSelector, this, b); + }); + } + }); + + // arity operators methods + UGen.prototype.madd = fn(function(mul, add) { + return cc.createMulAdd(this, mul, add); + }).defaults(ops.ARITY_OPS.madd).build(); + + UGen.prototype.range = fn(function(lo, hi) { + var mul, add; + if (this.signalRange === 2) { + mul = (hi.__sub__(lo)).__mul__(0.5); + add = mul.__add__(lo); + } else { + mul = hi.__sub__(lo); + add = lo; + } + return cc.createMulAdd(this, mul, add); + }).defaults(ops.ARITY_OPS.range).build(); + + UGen.prototype.exprange = fn(function(lo, hi) { + if (this.signalRange === 2) { + return this.linexp(-1, 1, lo, hi); + } else { + return this.linexp( 0, 1, lo, hi); + } + }).defaults(ops.ARITY_OPS.exprange).multiCall().build(); + + UGen.prototype.curverange = fn(function(lo, hi, curve) { + if (this.signalRange === 2) { + return this.lincurve(-1, 1, lo, hi, curve); + } else { + return this.lincurve( 0, 1, lo, hi, curve); + } + }).defaults(ops.ARITY_OPS.curverange).multiCall().build(); + + UGen.prototype.unipolar = fn(function(mul) { + return this.range(0, mul); + }).defaults(ops.ARITY_OPS.unipolar).multiCall().build(); + + UGen.prototype.bipolar = fn(function(mul) { + return this.range(mul.neg(), mul); + }).defaults(ops.ARITY_OPS.bipolar).multiCall().build(); + + UGen.prototype.clip = fn(function(lo, hi) { + return cc.global.Clip(this.rate, this, lo, hi); + }).defaults(ops.ARITY_OPS.clip).multiCall().build(); + + UGen.prototype.fold = fn(function(lo, hi) { + return cc.global.Fold(this.rate, this, lo, hi); + }).defaults(ops.ARITY_OPS.fold).multiCall().build(); + + UGen.prototype.wrap = fn(function(lo, hi) { + return cc.global.Wrap(this.rate, this, lo, hi); + }).defaults(ops.ARITY_OPS.wrap).multiCall().build(); + + UGen.prototype.blend = fn(function(that, blendFrac) { + var pan = blendFrac.linlin(0, 1, -1, 1); + if (this.rate === 2) { + return cc.global.XFade2(2, this, that, pan); + } + if (that.rate === 2) { + return cc.global.XFade2(2, that, this, pan.neg()); + } + return cc.global.LinXFade2(this.rate, this, that, pan); + }).defaults(ops.ARITY_OPS.blend).multiCall().build(); + + UGen.prototype.lag = fn(function(t1, t2) { + if (typeof t2 === "undefined") { + return cc.global.Lag(this.rate, this, t1); + } + return cc.global.LagUD(this.rate, this, t1, t2); + }).defaults(ops.ARITY_OPS.lag).multiCall().build(); + + UGen.prototype.lag2 = fn(function(t1, t2) { + if (typeof t2 === "undefined") { + return cc.global.Lag2(this.rate, this, t1); + } + return cc.global.Lag2UD(this.rate, this, t1, t2); + }).defaults(ops.ARITY_OPS.lag2).multiCall().build(); + + UGen.prototype.lag3 = fn(function(t1, t2) { + if (typeof t2 === "undefined") { + return cc.global.Lag3(this.rate, this, t1); + } + return cc.global.Lag3UD(this.rate, this, t1, t2); + }).defaults(ops.ARITY_OPS.lag3).multiCall().build(); + + UGen.prototype.lagud = fn(function(lagTimeU, lagTimeD) { + return cc.global.LagUD(this.rate, this, lagTimeU, lagTimeD); + }).defaults(ops.ARITY_OPS.lagud).multiCall().build(); + + UGen.prototype.lag2ud = fn(function(lagTimeU, lagTimeD) { + return cc.global.Lag2UD(this.rate, this, lagTimeU, lagTimeD); + }).defaults(ops.ARITY_OPS.lag2ud).multiCall().build(); + + UGen.prototype.lag3ud = fn(function(lagTimeU, lagTimeD) { + return cc.global.Lag3UD(this.rate, this, lagTimeU, lagTimeD); + }).defaults(ops.ARITY_OPS.lag3ud).multiCall().build(); + + UGen.prototype.varlag = fn(function(time, curvature, warp, start) { + return cc.global.VarLag(this.rate, this, time, curvature, warp, start); + }).defaults(ops.ARITY_OPS.varlag).multiCall().build(); + + UGen.prototype.slew = fn(function(up, down) { + return cc.global.Slew(this.rate, this, up, down); + }).defaults(ops.ARITY_OPS.slew).multiCall().build(); + + UGen.prototype.prune = function(min, max, type) { + switch (type) { + case "minmax": + return this.clip(min, max); + case "min": + return this.max(min); + case "max": + return this.min(max); + } + return this; + }; + + UGen.prototype.linlin = fn(function(inMin, inMax, outMin, outMax, clip) { + return cc.global.LinLin( + this.rate, + this.prune(inMin, inMax, clip), + inMin, inMax, outMin, outMax + ); + }).defaults(ops.ARITY_OPS.linlin).multiCall().build(); + + UGen.prototype.linexp = fn(function(inMin, inMax, outMin, outMax, clip) { + return cc.global.LinExp( + this.rate, + this.prune(inMin, inMax, clip), + inMin, inMax, outMin, outMax + ); + }).defaults(ops.ARITY_OPS.linexp).multiCall().build(); + + UGen.prototype.explin = fn(function(inMin, inMax, outMin, outMax, clip) { + return cc.global.ExpLin( + this.rate, + this.prune(inMin, inMax, clip), + inMin, inMax, outMin, outMax + ); + }).defaults(ops.ARITY_OPS.explin).multiCall().build(); + + UGen.prototype.expexp = fn(function(inMin, inMax, outMin, outMax, clip) { + return cc.global.ExpExp( + this.rate, + this.prune(inMin, inMax, clip), + inMin, inMax, outMin, outMax + ); + }).defaults(ops.ARITY_OPS.expexp).multiCall().build(); + + UGen.prototype.lincurve = fn(function(inMin, inMax, outMin, outMax, curve, clip) { + if (typeof curve === "number" && Math.abs(curve) < 0.25) { + return this.linlin(inMin, inMax, outMin, outMax, clip); + } + var grow = curve.exp(); + var a = outMax.__sub__(outMin).__div__((1).__sub__(grow)); + var b = outMin.__add__(a); + var scaled = (this.prune(inMin, inMax, clip).__sub__(inMin)).__div__(inMax.__sub__(inMin)); + return b.__sub__(a.__mul__(grow.pow(scaled))); + }).defaults(ops.ARITY_OPS.lincurve).multiCall().build(); + + UGen.prototype.curvelin = fn(function(inMin, inMax, outMin, outMax, curve, clip) { + if (typeof curve === "number" && Math.abs(curve) < 0.25) { + return this.linlin(inMin, inMax, outMin, outMax, clip); + } + var grow = curve.exp(); + var a = outMax.__sub__(outMin).__div__((1).__sub__(grow)); + var b = outMin.__add__(a); + var scaled = (this.prune(inMin, inMax, clip).__sub__(inMin)).__div__(inMax.__sub__(inMin)); + return ((b.__sub__(scaled)).__div__(a)).log().__div__(curve); + }).defaults(ops.ARITY_OPS.curvelin).multiCall().build(); + + UGen.prototype.bilin = fn(function(inCenter, inMin, inMax, outCenter, outMin, outMax, clip) { + return cc.global.Select(this.rate, this.lt(inCenter), [ + this.linlin(inCenter, inMax, outCenter, outMax, clip), + this.linlin(inMin, inCenter, outMin, outCenter, clip) + ]); + }).defaults(ops.ARITY_OPS.bilin).build(); + + UGen.prototype.rrand = fn(function() { + return 0; + }).defaults(ops.ARITY_OPS.rrand).build(); + + UGen.prototype.exprand = fn(function() { + return 0; + }).defaults(ops.ARITY_OPS.exprand).build(); + + return UGen; + })(); + + var MultiOutUGen = (function() { + function MultiOutUGen(name) { + UGen.call(this, name || "MultiOutUGen"); + this.channels = null; + } + extend(MultiOutUGen, UGen); + + MultiOutUGen.prototype.initOutputs = function(numChannels, rate) { + var channels = new Array(numChannels); + for (var i = 0; i < numChannels; ++i) { + channels[i] = new OutputProxy(rate, this, i); + } + this.channels = channels; + this.numOutputs = channels.length; + return (numChannels === 1) ? channels[0] : channels; + }; + + return MultiOutUGen; + })(); + + var OutputProxy = (function() { + function OutputProxy(rate, source, index) { + UGen.call(this, "OutputProxy"); + this.init(rate); + this.inputs = [ source ]; + this.numOutputs = 1; + this.outputIndex = index; + } + extend(OutputProxy, UGen); + + OutputProxy.prototype.clone = fn(function() { + return this; + }).defaults(ops.COMMONS.clone).build(); + + return OutputProxy; + })(); + + var Out = (function() { + function Out() { + cc.UGen.call(this, "Out"); + } + extend(Out, UGen); + + return Out; + })(); + + var init_instance = function(instance, opts) { + if (Array.isArray(instance)) { + return instance.map(function(ugen) { + return init_instance(ugen, opts); + }); + } else if (instance instanceof UGen) { + if (opts.checkInputs) { + opts.checkInputs.call(instance); + } + if (opts.init) { + return opts.init.apply(instance, instance.inputs); + } + } + return instance; + }; + + var register = function(name, spec) { + var Klass = spec.Klass || UGen; + var opts = { + checkInputs: spec.checkInputs, + signalRange: spec.signalRange || 2, + init: spec.init + }; + var ugenInterface; + if (spec.$new) { + ugenInterface = function() { + return cc.global[name]["new"].apply(null, slice.call(arguments)); + }; + cc.global[name] = ugenInterface; + } else { + ugenInterface = function(rate) { + if (typeof rate === "number") { + rate = ["ir", "kr", "ar"][rate]; + } + var func = cc.global[name][rate]; + if (func) { + return func.apply(null, slice.call(arguments, 1)); + } + return new UGen(name); + }; + cc.global[name] = ugenInterface; + cc.global[name]["new"] = ugenInterface; + } + + Object.keys(spec).forEach(function(key) { + if (key.charAt(0) === "$") { + var defaults = spec[key].defaults; + var ctor = spec[key].ctor; + ugenInterface[key.substr(1)] = fn(function() { + var args = slice.call(arguments); + newKlassOpts.name = name; + newKlassOpts.signalRange = opts.signalRange; + var instance = ctor.apply(Klass, args); + newKlassOpts = {}; + return init_instance(instance, opts); + }).defaults(defaults).build(); + } + }); + }; + + cc.createUGen = function() { + return new UGen(); + }; + cc.instanceOfUGen = function(obj) { + return obj instanceof UGen; + }; + cc.instanceOfMultiOutUGen = function(obj) { + return obj instanceof MultiOutUGen; + }; + + cc.createOutputProxy = function(rate, source, index) { + return new OutputProxy(rate, source, index); + }; + cc.instanceOfOutputProxy = function(obj) { + return obj instanceof OutputProxy; + }; + + cc.instanceOfOut = function(obj) { + return obj instanceof Out; + }; + + cc.setSynthDef = function(func) { + if (func && addToSynthDef !== null) { + throw new Error("nested Synth.def"); + } + addToSynthDef = func; + }; + + cc.UGen = UGen; + cc.MultiOutUGen = MultiOutUGen; + cc.Out = Out; + cc.ugen.register = register; + + module.exports = { + UGen : UGen, + MultiOutUGen: MultiOutUGen, + OutputProxy : OutputProxy + }; + +}); +define('cc/lang/basic_ugen', function(require, exports, module) { + + var cc = require("./cc"); + var extend = require("../common/extend"); + var ops = require("../common/ops"); + var fn = require("./fn"); + var utils = require("./utils"); + var asRate = utils.asRate; + + var Control = (function() { + function Control(rate, klassName) { + cc.MultiOutUGen.call(this, klassName || "Control"); + this.rate = rate; + this.values = null; + } + extend(Control, cc.MultiOutUGen); + + Control.prototype.init = function(values) { + cc.UGen.prototype.init.apply(this, [this.rate]); + this.values = values.slice(); + return this.initOutputs(this.values.length, this.rate); + }; + + return Control; + })(); + + var AudioControl = (function() { + function AudioControl() { + Control.call(this, 2, "AudioControl"); + } + extend(AudioControl, Control); + + return AudioControl; + })(); + + var TrigControl = (function() { + function TrigControl() { + Control.call(this, 1, "TrigControl"); + } + extend(TrigControl, Control); + + return TrigControl; + })(); + + var LagControl = (function() { + function LagControl() { + Control.call(this, 1, "LagControl"); + } + extend(LagControl, Control); + + LagControl.prototype.init = function(values, lags) { + cc.UGen.prototype.init.apply(this, [this.rate].concat(lags)); + this.values = values; + return this.initOutputs(values.length, this.rate); + }; + + return LagControl; + })(); + + var UnaryOpUGen = (function() { + function UnaryOpUGen() { + cc.UGen.call(this, "UnaryOpUGen"); + } + extend(UnaryOpUGen, cc.UGen); + + UnaryOpUGen.prototype.init = function(selector, a) { + var index = ops.UNARY_OPS[selector]; + if (typeof index === "undefined") { + throw new Error("UnaryOpUGen: unknown operator '" + selector + "'"); + } + a = utils.asUGenInput(a); + cc.UGen.prototype.init.call(this, asRate(a)); + this.selector = selector; + this.specialIndex = index; + this.inputs = [a]; + this.numInputs = 1; + return this; + }; + + return UnaryOpUGen; + })(); + + var BinaryOpUGen = (function() { + function BinaryOpUGen() { + cc.UGen.call(this, "BinaryOpUGen"); + } + extend(BinaryOpUGen, cc.UGen); + + BinaryOpUGen.prototype.init = function(selector, a, b) { + a = utils.asUGenInput(a); + b = utils.asUGenInput(b); + if (typeof a === "number" && typeof b === "number") { + switch (selector) { + case "+": return utils.asUGenInput(a + b); + case "-": return utils.asUGenInput(a - b); + case "*": return utils.asUGenInput(a * b); + case "/": return utils.asUGenInput(a / b); + case "%": return utils.asUGenInput(a % b); + } + } + + if (selector === "-" && typeof b === "number") { + selector = "+"; + b = -b; + } + if (selector === "/" && typeof b === "number") { + selector = "*"; + b = 1 / b; // TODO: div(0) ? + } + if (selector === "*") { + if (a === 0 || b === 0) { + return 0; + } else if (a === 1) { + return b; + } else if (b === 1) { + return a; + } + return optimizeMulObjects(a, b); + } + if (selector === "+") { + if (a === 0) { + return b; + } else if (b === 0) { + return a; + } else if (a instanceof BinaryOpUGen) { + if (a.selector === "*") { + return cc.createMulAdd(a.inputs[0], a.inputs[1], b); + } + } else if (a instanceof MulAdd) { + if (typeof a.inputs[2] === "number" && typeof b === "number") { + if (a.inputs[2] + b === 0) { + return cc.createBinaryOpUGen("*!", a.inputs[0], a.inputs[1]); + } else { + a.inputs[2] += b; + return a; + } + } + b = cc.createBinaryOpUGen("+", a.inputs[2], b); + a = cc.createBinaryOpUGen("*!", a.inputs[0], a.inputs[1]); + return cc.createBinaryOpUGen("+", a, b); + } + return optimizeSumObjects(a, b); + } + if (selector === "+!") { + selector = "+"; + } else if (selector === "*!") { + selector = "*"; + } + var index = ops.BINARY_OPS[selector]; + if (typeof index === "undefined") { + throw new Error("BinaryOpUGen: unknown operator '" + selector + "'"); + } + cc.UGen.prototype.init.call(this, asRate([a, b])); + this.selector = selector; + this.specialIndex = index; + this.inputs = [a, b]; + this.numInputs = 2; + return this; + }; + + return BinaryOpUGen; + })(); + + // TODO: a graph should be optimized when SynthDef building + var optimizeSumObjects = (function() { + var collect = function(obj) { + if (typeof obj === "number") { + return obj; + } + var i = obj.inputs; + if (obj instanceof BinaryOpUGen && obj.selector === "+") { + return [ collect(i[0]), collect(i[1]) ]; + } else if (obj instanceof Sum3) { + return [ collect(i[0]), collect(i[1]), collect(i[2]) ]; + } else if (obj instanceof Sum4) { + return [ collect(i[0]), collect(i[1]), collect(i[2]), collect(i[3]) ]; + } + return obj; + }; + var work = function(a) { + a = a.map(function(a) { + switch (a.length) { + case 4: return cc.createSum4(a[0], a[1], a[2], a[3]); + case 3: return cc.createSum3(a[0], a[1], a[2]); + case 2: return cc.createBinaryOpUGen("+!", a[0], a[1]); + case 1: return a[0]; + } + }); + switch (a.length) { + case 4: return cc.createSum4(a[0], a[1], a[2], a[3]); + case 3: return cc.createSum3(a[0], a[1], a[2]); + case 2: return cc.createBinaryOpUGen("+!", a[0], a[1]); + case 1: return a[0]; + default: return work(utils.clump(a, 4)); + } + }; + return function(in1, in2) { + var list = utils.flatten([ collect(in1), collect(in2) ]); + var fixnum = 0; + list = list.filter(function(ugen) { + if (typeof ugen === "number") { + fixnum += ugen; + return false; + } + return true; + }); + if (fixnum !== 0) { + list.push(fixnum); + } + list = utils.clump(list, 4); + if (list.length === 1 && list[0].length === 2) { + return cc.createBinaryOpUGen("+!", list[0][0], list[0][1]); + } + var result = work(list); + return result; + }; + })(); + + var optimizeMulObjects = (function() { + var collect = function(obj) { + if (typeof obj === "number") { return obj; } + var i = obj.inputs; + if (obj instanceof BinaryOpUGen && obj.selector === "*") { + return [ collect(i[0]), collect(i[1]) ]; + } + return obj; + }; + var work = function(a) { + a = a.map(function(a) { + if (a.length === 2) { + return cc.createBinaryOpUGen("*!", a[0], a[1]); + } else { + return a[0]; + } + }); + switch (a.length) { + case 2: + return cc.createBinaryOpUGen("*!", a[0], a[1]); + case 1: + return a[0]; + default: + return work(utils.clump(a, 2)); + } + }; + return function(in1, in2) { + var list = utils.flatten([ collect(in1), collect(in2) ]); + var fixnum = 1; + list = list.filter(function(ugen) { + if (typeof ugen === "number") { + fixnum *= ugen; + return false; + } + return true; + }); + if (fixnum !== 1) { + list.push(fixnum); + } + list = utils.clump(list, 2); + if (list.length === 1 && list[0].length === 2) { + return cc.createBinaryOpUGen("*!", list[0][0], list[0][1]); + } + return work(list); + }; + })(); + + var MulAdd = (function() { + function MulAdd() { + cc.UGen.call(this, "MulAdd"); + } + extend(MulAdd, cc.UGen); + + MulAdd.prototype.init = function(_in, mul, add) { + var t, minus, nomul, noadd, rate; + if (asRate(_in) < asRate(mul)) { + t = _in; _in = mul; mul = t; + } + _in = utils.asUGenInput(_in); + mul = utils.asUGenInput(mul); + add = utils.asUGenInput(add); + if (mul === 0) { + return add; + } + if (typeof _in === "number" && typeof mul === "number") { + _in *= mul; + mul = 1; + } + + minus = mul === -1; + nomul = mul === 1; + noadd = add === 0; + + if (nomul && noadd) { + return _in; + } + if (minus && noadd) { + return cc.createBinaryOpUGen("*", _in, -1); + } + if (noadd) { + return cc.createBinaryOpUGen("*", _in, mul); + } + if (minus) { + return cc.createBinaryOpUGen("-", add, _in); + } + if (nomul) { + return cc.createBinaryOpUGen("+", _in, add); + } + rate = asRate([_in, mul, add]); + return cc.UGen.prototype.init.apply(this, [rate, _in, mul, add]); + }; + + return MulAdd; + })(); + + var Sum3 = (function() { + function Sum3() { + cc.UGen.call(this, "Sum3"); + } + extend(Sum3, cc.UGen); + + Sum3.prototype.init = function(in0, in1, in2) { + if (in0 === 0) { + return cc.createBinaryOpUGen("+", in1, in2); + } + if (in1 === 0) { + return cc.createBinaryOpUGen("+", in0, in2); + } + if (in2 === 0) { + return cc.createBinaryOpUGen("+", in0, in1); + } + var rate = asRate([in0, in1, in2]); + var sortedArgs = [in0, in1, in2].sort(function(a, b) { + return asRate(b) - asRate(a); + }); + return cc.UGen.prototype.init.apply(this, [rate].concat(sortedArgs)); + }; + + return Sum3; + })(); + + var Sum4 = (function() { + function Sum4() { + cc.UGen.call(this, "Sum4"); + } + extend(Sum4, cc.UGen); + + Sum4.prototype.init = function(in0, in1, in2, in3) { + if (in0 === 0) { + return cc.createSum3(in1, in2, in3); + } + if (in1 === 0) { + return cc.createSum3(in0, in2, in3); + } + if (in2 === 0) { + return cc.createSum3(in0, in1, in3); + } + if (in3 === 0) { + return cc.createSum3(in0, in1, in2); + } + var rate = asRate([in0, in1, in2, in3]); + var sortedArgs = [in0, in1, in2, in3].sort(function(a, b) { + return asRate(b) - asRate(a); + }); + return cc.UGen.prototype.init.apply(this, [rate].concat(sortedArgs)); + }; + + return Sum4; + })(); + + cc.ugen.specs.Out = { + Klass: cc.Out, + $ar: { + defaults: "bus=0,channelsArray=0", + ctor: function(bus, channelsArray) { + this.multiNewList([2, bus].concat(channelsArray)); + return 0; // Out has no output + } + }, + $kr: { + defaults: "bus=0,channelsArray=0", + ctor: function(bus, channelsArray) { + this.multiNewList([1, bus].concat(channelsArray)); + return 0; // Out has no output + } + } + }; + + var ReplaceOut = (function() { + function ReplaceOut() { + cc.UGen.call(this, "ReplaceOut"); + } + extend(ReplaceOut, cc.Out); + + return ReplaceOut; + })(); + + cc.ugen.specs.ReplaceOut = { + Klass: ReplaceOut, + $ar: { + defaults: "bus=0,channelsArray=0", + ctor: function(bus, channelsArray) { + this.multiNewList([2, bus].concat(channelsArray)); + return 0; // Out has no output + } + }, + $kr: { + defaults: "bus=0,channelsArray=0", + ctor: function(bus, channelsArray) { + this.multiNewList([1, bus].concat(channelsArray)); + return 0; // Out has no output + } + } + }; + + cc.createControl = function(rate) { + return new Control(rate); + }; + cc.createAudioControl = function() { + return new AudioControl(); + }; + cc.createTrigControl = function() { + return new TrigControl(); + }; + cc.createLagControl = function() { + return new LagControl(); + }; + cc.instanceOfControlUGen = function(obj) { + return obj instanceof Control; + }; + cc.createUnaryOpUGen = fn(function(selector, a) { + return new UnaryOpUGen().init(selector, a); + }).multiCall().build(); + cc.createBinaryOpUGen = fn(function(selector, a, b) { + return new BinaryOpUGen().init(selector, a, b); + }).multiCall().build(); + cc.createMulAdd = fn(function(_in, mul, add) { + return new MulAdd().init(_in, mul, add); + }).multiCall().build(); + cc.createSum3 = fn(function(in0, in1, in2) { + return new Sum3().init(in0, in1, in2); + }).multiCall().build(); + cc.createSum4 = fn(function(in0, in1, in2, in3) { + return new Sum4().init(in0, in1, in2, in3); + }).multiCall().build(); + + module.exports = { + Control: Control, + UnaryOpUGen: UnaryOpUGen, + BinaryOpUGen: BinaryOpUGen, + MulAdd: MulAdd, + Sum3: Sum3, + Sum4: Sum4 + }; + +}); +define('cc/plugins/installer', function(require, exports, module) { + + require("./bufio"); + require("./debug"); + require("./decay"); + require("./delay"); + require("./demand"); + require("./env"); + require("./filter"); + require("./info"); + require("./inout"); + require("./line"); + require("./noise"); + require("./osc"); + require("./pan"); + require("./random"); + require("./range"); + require("./reverb"); + require("./trig"); + require("./ui"); + + module.exports = {}; + +}); +define('cc/plugins/bufio', function(require, exports, module) { + + var cc = require("../cc"); + var utils = require("./utils"); + var cubicinterp = utils.cubicinterp; + var slice = [].slice; + + var sc_loop = function(unit, index, hi, loop) { + if (index >= hi) { + if (!loop) { + unit.done = true; + return hi; + } + index -= hi; + if (index < hi) { + return index; + } + } else if (index < 0) { + if (!loop) { + unit.done = true; + return 0; + } + index += hi; + if (index >= 0) { + return index; + } + } else { + return index; + } + return index - hi * Math.floor(index/hi); + }; + + var get_indices = function(phase, hi, loop) { + var index1 = phase|0; + var index0 = index1 - 1; + var index2 = index1 + 1; + var index3 = index2 + 1; + if (index1 === 0) { + if (loop) { + index0 = hi; + } else { + index0 = index1; + } + } else if (index3 > hi) { + if (index2 > hi) { + if (loop) { + index2 = 0; + index3 = 1; + } else { + index2 = index3 = hi; + } + } else { + if (loop) { + index3 = 0; + } else { + index3 = hi; + } + } + } + return [ index0, index1, index2, index3 ]; + }; + + var get_buffer = function(unit) { + var buffer = unit.world.buffers[unit.inputs[0][0]|0]; + if (buffer) { + var samples = buffer.samples; + if (samples.length) { + unit._frames = buffer.frames; + unit._channels = buffer.channels; + unit._sampleRate = buffer.sampleRate; + unit._samples = samples; + return true; + } + } + return false; + }; + + var asArray = function(obj) { + if (Array.isArray(obj)) { + return obj; + } + return [obj]; + }; + + cc.ugen.specs.PlayBuf = { + Klass: cc.MultiOutUGen, + $ar: { + defaults: "numChannels=0,bufnum=0,rate=1,trigger=1,startPos=0,loop=0,doneAction=0", + ctor: function(numChannels, bufnum, rate, trigger, startPos, loop, doneAction) { + if (typeof numChannels !== "number") { + throw new TypeError("PlayBuf: numChannels should be an integer."); + } + return this.multiNew(2, numChannels, bufnum, rate, trigger, startPos, loop, doneAction); + } + }, + $kr: { + defaults: "numChannels=0,bufnum,rate=1,trigger=1,startPos=0,loop=0,doneAction=0", + ctor: function(numChannels, bufnum, rate, trigger, startPos, loop, doneAction) { + if (typeof numChannels !== "number") { + throw new TypeError("PlayBuf: numChannels should be an integer."); + } + return this.multiNew(1, numChannels, bufnum, rate, trigger, startPos, loop, doneAction); + } + }, + init: function(numChannels) { + this.inputs = slice.call(arguments, 1); + return this.initOutputs(numChannels, this.rate); + } + }; + + cc.unit.specs.PlayBuf = (function() { + var ctor = function() { + switch (this.numOutputs) { + case 1: this.process = next_1ch; break; + case 2: this.process = next_2ch; break; + default: this.process = next; + } + this._samples = null; + this._channels = 0; + this._frames = 0; + this._phase = this.inputs[3][0]; + this._trig = 0; + }; + + var next_1ch = function(inNumSamples) { + if (!get_buffer(this)) { + return; + } + var out = this.outputs[0]; + var phase = this._phase; + var rate = this.inputs[1][0]; + var trig = this.inputs[2][0]; + var loop = this.inputs[4][0]; + var samples = this._samples; + var frames = this._frames; + var indices, frac, a, b, c, d; + var hi = frames - 1; + + if (trig > 0 && this._trig <= 0) { + this.done = false; + phase = this.inputs[3][0]; + } + this._trig = trig; + for (var i = 0; i < inNumSamples; ++i) { + phase = sc_loop(this, phase, hi, loop); + indices = get_indices(phase, hi, loop); + frac = phase - (phase|0); + + a = samples[indices[0]]; + b = samples[indices[1]]; + c = samples[indices[2]]; + d = samples[indices[3]]; + out[i] = cubicinterp(frac, a, b, c, d); + + phase += rate; + } + if (this.done) { + this.doneAction(this.inputs[5][0]|0); + } + this._phase = phase; + }; + + var next_2ch = function(inNumSamples) { + if (!get_buffer(this)) { + return; + } + var out1 = this.outputs[0]; + var out2 = this.outputs[1]; + var phase = this._phase; + var rate = this.inputs[1][0]; + var trig = this.inputs[2][0]; + var loop = this.inputs[4][0]; + var samples = this._samples; + var frames = this._frames; + var indices, frac, a, b, c, d; + var hi = frames - 1; + + if (trig > 0 && this._trig <= 0) { + this.done = false; + phase = this.inputs[3][0]; + } + this._trig = trig; + for (var i = 0; i < inNumSamples; ++i) { + phase = sc_loop(this, phase, hi, loop); + indices = get_indices(phase, hi, loop); + frac = phase - (phase|0); + + a = samples[indices[0] * 2]; + b = samples[indices[1] * 2]; + c = samples[indices[2] * 2]; + d = samples[indices[3] * 2]; + out1[i] = cubicinterp(frac, a, b, c, d); + + a = samples[indices[0] * 2 + 1]; + b = samples[indices[1] * 2 + 1]; + c = samples[indices[2] * 2 + 1]; + d = samples[indices[3] * 2 + 1]; + out2[i] = cubicinterp(frac, a, b, c, d); + + phase += rate; + } + if (this.done) { + this.doneAction(this.inputs[5][0]|0); + } + this._phase = phase; + }; + + var next = function(inNumSamples) { + if (!get_buffer(this)) { + return; + } + var outputs = this.outputs; + var phase = this._phase; + var rate = this.inputs[1][0]; + var trig = this.inputs[2][0]; + var loop = this.inputs[4][0]; + var samples = this._samples; + var channels = this._channels; + var frames = this._frames; + var indices, frac, a, b, c, d; + + var hi = frames - 1; + if (trig > 0 && this._trig <= 0) { + this.done = false; + phase = this.inputs[3][0]; + } + this._trig = trig; + for (var i = 0; i < inNumSamples; ++i) { + phase = sc_loop(this, phase, hi, loop); + indices = get_indices(phase, hi, loop); + frac = phase - (phase|0); + for (var j = 0, jmax = outputs.length; j < jmax; ++j) { + a = samples[indices[0] * channels + j]; + b = samples[indices[1] * channels + j]; + c = samples[indices[2] * channels + j]; + d = samples[indices[3] * channels + j]; + outputs[j][i] = cubicinterp(frac, a, b, c, d); + } + phase += rate; + } + if (this.done) { + this.doneAction(this.inputs[5][0]|0); + } + this._phase = phase; + }; + + return ctor; + })(); + + cc.ugen.specs.BufRd = { + Klass: cc.MultiOutUGen, + $ar: { + defaults: "numChannels=0,bufnum=0,phase=0,loop=1,interpolation=2", + ctor: function(numChannels, bufnum, phase, loop, interpolation) { + if (typeof numChannels !== "number") { + throw new TypeError("PlayBuf: numChannels should be an integer."); + } + return this.multiNew(2, numChannels, bufnum, phase, loop, interpolation); + } + }, + $kr: { + defaults: "numChannels=0,bufnum=0,phase=0,loop=1,interpolation=2", + ctor: function(numChannels, bufnum, phase, loop, interpolation) { + if (typeof numChannels !== "number") { + throw new TypeError("PlayBuf: numChannels should be an integer."); + } + return this.multiNew(1, numChannels, bufnum, phase, loop, interpolation); + } + }, + init: function(numChannels) { + this.inputs = slice.call(arguments, 1); + return this.initOutputs(numChannels, this.rate); + } + }; + + var perform_N = function(samples, indices, mul, add) { + return samples[indices[1] * mul + add]; + }; + var perform_L = function(samples, indices, mul, add, frac) { + var b = samples[indices[1] * mul + add]; + var c = samples[indices[2] * mul + add]; + return b + frac * (c - b); + }; + var perform_C = function(samples, indices, mul, add, frac) { + var a = samples[indices[0] * mul + add]; + var b = samples[indices[1] * mul + add]; + var c = samples[indices[2] * mul + add]; + var d = samples[indices[3] * mul + add]; + return cubicinterp(frac, a, b, c, d); + }; + cc.unit.specs.BufRd = (function() { + var ctor = function() { + switch (this.numOutputs) { + case 1: + this.process = next_1ch; + break; + case 2: + this.process = next_2ch; + break; + default: + this.process = next; + } + switch (this.inputs[3][0]|0) { + case 1 : this._perform = perform_N; break; + case 4 : this._perform = perform_C; break; + default: this._perform = perform_L; break; + } + this._samples = null; + this._channels = 0; + this._frames = 0; + }; + var next_1ch = function(inNumSamples) { + if (!get_buffer(this)) { + return; + } + var out = this.outputs[0]; + var phaseIn = this.inputs[1]; + var loop = this.inputs[2][0]; + var samples = this._samples; + var frames = this._frames; + var perform = this._perform; + var phase, indices, frac; + var hi = frames - 1; + for (var i = 0; i < inNumSamples; ++i) { + phase = sc_loop(this, phaseIn[i], hi, loop); + indices = get_indices(phase, hi, loop); + frac = phase - (phase|0); + out[i] = perform(samples, indices, 1, 0, frac); + } + }; + var next_2ch = function(inNumSamples) { + if (!get_buffer(this)) { + return; + } + var out1 = this.outputs[0]; + var out2 = this.outputs[1]; + var phaseIn = this.inputs[1]; + var loop = this.inputs[2][0]; + var samples = this._samples; + var frames = this._frames; + var perform = this._perform; + var phase, indices, frac; + var hi = frames - 1; + for (var i = 0; i < inNumSamples; ++i) { + phase = sc_loop(this, phaseIn[i], hi, loop); + indices = get_indices(phase, hi, loop); + frac = phase - (phase|0); + out1[i] = perform(samples, indices, 2, 0, frac); + out2[i] = perform(samples, indices, 2, 1, frac); + } + }; + var next = function(inNumSamples) { + if (!get_buffer(this)) { + return; + } + var outputs = this.outputs; + var phaseIn = this.inputs[1]; + var loop = this.inputs[2][0]; + var samples = this._samples; + var frames = this._frames; + var perform = this._perform; + var phase, indices, frac; + var hi = frames - 1; + for (var i = 0; i < inNumSamples; ++i) { + phase = sc_loop(this, phaseIn[i], hi, loop); + indices = get_indices(phase, hi, loop); + frac = phase - (phase|0); + for (var j = 0, jmax = outputs.length; j < jmax; ++j) { + outputs[j][i] = perform(samples, indices, jmax, j, frac); + } + } + }; + return ctor; + })(); + + cc.ugen.specs.BufWr = { + $ar: { + defaults: "inputArray=[],bufnum=0,phase=0,loop=1", + ctor: function(inputArray, bufnum, phase, loop) { + return this.multiNewList([2, bufnum, phase, loop].concat(asArray(inputArray))); + } + }, + $kr: { + defaults: "inputArray=[],bufnum=0,phase=0,loop=1", + ctor: function(inputArray, bufnum, phase, loop) { + return this.multiNewList([1, bufnum, phase, loop].concat(asArray(inputArray))); + } + }, + checkNInputs: function() { + if (this.rate === 2 && this.inputs[1].rate !== 2) { + throw new Error("phase input is not audio rate"); + } + } + }; + + cc.unit.specs.BufWr = (function() { + var ctor = function() { + switch (this.numInputs - 3) { + case 1: + this.process = next_1ch; + break; + case 2: + this.process = next_2ch; + break; + default: + this.process = next; + break; + } + }; + var next_1ch = function(inNumSamples) { + if (!get_buffer(this)) { + return; + } + var phaseIn = this.inputs[1]; + var in0In = this.inputs[3]; + var loop = this.inputs[2][0]; + var loopMax = this._frames - (loop ? 0 : 1); + var samples = this._samples; + var phase; + var i; + for (i = 0; i < inNumSamples; ++i) { + phase = sc_loop(this, phaseIn[i], loopMax, loop); + samples[phase|0] = in0In[i]; + } + }; + var next_2ch = function(inNumSamples) { + if (!get_buffer(this)) { + return; + } + var phaseIn = this.inputs[1]; + var in0In = this.inputs[3]; + var in1In = this.inputs[4]; + var loop = this.inputs[2][0]; + var loopMax = this._frames - (loop ? 0 : 1); + var samples = this._samples; + var phase, index; + var i; + for (i = 0; i < inNumSamples; ++i) { + phase = sc_loop(this, phaseIn[i], loopMax, loop); + index = phase << 1; + samples[index ] = in0In[i]; + samples[index+1] = in1In[i]; + } + }; + var next = function(inNumSamples) { + if (!get_buffer(this)) { + return; + } + var phaseIn = this.inputs[1]; + var inputs = this.inputs; + var loop = this.inputs[2][0]; + var loopMax = this._frames - (loop ? 0 : 1); + var samples = this._samples; + var channels = this._channels; + var phase, index; + var i, j; + for (i = 0; i < inNumSamples; ++i) { + phase = sc_loop(this, phaseIn[i], loopMax, loop); + index = (phase|0) * channels; + for (j = 0; j < channels; ++j) { + samples[index+j] = inputs[j+3][i]; + } + } + }; + return ctor; + })(); + + cc.ugen.specs.RecordBuf = { + $ar: { + defaults: "inputArray=[],bufnum=0,offset=0,recLevel=1,preLevel=0,run=1,loop=1,trigger=1,doneAction=0", + ctor: function(inputArray, bufnum, offset, recLevel, preLevel, run, loop, trigger, doneAction) { + return this.multiNewList([ + 2, bufnum, offset, recLevel, preLevel, run, loop, trigger, doneAction + ].concat(asArray(inputArray))); + } + }, + $kr: { + defaults: "inputArray=[],bufnum=0,offset=0,recLevel=1,preLevel=0,run=1,loop=1,trigger=1,doneAction=0", + ctor: function(inputArray, bufnum, offset, recLevel, preLevel, run, loop, trigger, doneAction) { + return this.multiNewList([ + 1, bufnum, offset, recLevel, preLevel, run, loop, trigger, doneAction + ].concat(asArray(inputArray))); + } + } + }; + + cc.unit.specs.RecordBuf = (function() { + var ctor = function() { + switch (this.numInputs - 8) { + case 1: + this.process = next_1ch; + break; + case 2: + this.process = next_2ch; + break; + default: + this.process = next; + break; + } + this._writepos = this.inputs[1][0]; + this._recLevel = this.inputs[2][0]; + this._preLevel = this.inputs[3][0]; + this._prevtrig = 0; + this._preindex = 0; + }; + var recbuf_next = function(func) { + return function(inNumSamples) { + if (!get_buffer(this)) { + return; + } + var channels = this._channels; + var frames = this._frames; + var samples = this._samples; + var inputs = this.inputs; + var recLevel = this.inputs[2][0]; + var preLevel = this.inputs[3][0]; + var run = this.inputs[4][0]; + var loop = this.inputs[5][0]|0; + var trig = this.inputs[6][0]; + var writepos = this._writepos; + var recLevel_slope = (recLevel - this._recLevel) * this.rate.slopeFactor; + var preLevel_slope = (preLevel - this._preLevel) * this.rate.slopeFactor; + var prevpos, posincr; + var i; + recLevel = this._recLevel; + preLevel = this._preLevel; + prevpos = this._prevpos; + posincr = run > 0 ? +1 : -1; + if (trig > 0 && this._prevtrig) { + this.done = false; + writepos = (this.inputs[1][0] * channels)|0; + } + if (writepos < 0) { + writepos = frames - 1; + } else if (writepos >= frames) { + writepos = 0; + } + for (i = 0; i < inNumSamples; ++i) { + func(inputs, i, samples, writepos, prevpos, recLevel, preLevel, channels); + prevpos = writepos; + writepos += posincr; + if (writepos >= frames) { + if (loop) { + writepos = 0; + } else { + writepos = frames - 1; + this.done = true; + } + } else if (0 < writepos) { + if (loop) { + writepos = frames - 1; + } else { + writepos = 0; + this.done = true; + } + } + recLevel += recLevel_slope; + preLevel += preLevel_slope; + } + if (this.done) { + this.doneAction(this.inputs[7][0]|0); + } + this._prevtrig = trig; + this._writepos = writepos; + this._prevpos = prevpos; + this._recLevel = recLevel; + this._preLevel = preLevel; + }; + }; + + var next_1ch = recbuf_next(function(inputs, index, samples, writepos, prevpos, recLevel, preLevel) { + samples[writepos] = inputs[8][index] * recLevel + samples[prevpos] * preLevel; + }); + + var next_2ch = recbuf_next(function(inputs, index, samples, writepos, prevpos, recLevel, preLevel) { + samples[writepos*2 ] = inputs[8][index] * recLevel + samples[prevpos*2 ] * preLevel; + samples[writepos*2+1] = inputs[9][index] * recLevel + samples[prevpos*2+1] * preLevel; + }); + + var next = recbuf_next(function(inputs, index, samples, writepos, prevpos, recLevel, preLevel, channels) { + var j; + for (j = 0; j < channels; ++j) { + samples[writepos*channels+j] = inputs[8+j][index] + recLevel * samples[prevpos*channels+j] * preLevel; + } + }); + return ctor; + })(); + + cc.ugen.specs.BufSampleRate = { + $kr: { + defaults: "bufnum=0", + ctor: function(bufnum) { + return this.multiNew(1, bufnum); + } + }, + $ir: { + defaults: "bufnum=0", + ctor: function(bufnum) { + return this.multiNew(0, bufnum); + } + } + }; + + cc.unit.specs.BufSampleRate = (function() { + var ctor = function() { + this.process = next; + }; + var next = function() { + if (get_buffer(this)) { + this.outputs[0][0] = this._sampleRate; + } + }; + return ctor; + })(); + + cc.ugen.specs.BufRateScale = cc.ugen.specs.BufSampleRate; + + cc.unit.specs.BufRateScale = (function() { + var ctor = function() { + this.process = next; + this._sampleDur = cc.server.rates[2].sampleDur; + }; + var next = function() { + if (get_buffer(this)) { + this.outputs[0][0] = this._sampleRate * this._sampleDur; + } + }; + return ctor; + })(); + + cc.ugen.specs.BufFrames = cc.ugen.specs.BufSampleRate; + + cc.unit.specs.BufFrames = (function() { + var ctor = function() { + this.process = next; + }; + var next = function() { + if (get_buffer(this)) { + this.outputs[0][0] = this._frames; + } + }; + return ctor; + })(); + + cc.ugen.specs.BufSamples = cc.ugen.specs.BufSampleRate; + + cc.unit.specs.BufSamples = (function() { + var ctor = function() { + this.process = next; + }; + var next = function() { + if (get_buffer(this)) { + this.outputs[0][0] = this._samples.length; + } + }; + return ctor; + })(); + + cc.ugen.specs.BufDur = cc.ugen.specs.BufSampleRate; + + cc.unit.specs.BufDur = (function() { + var ctor = function() { + this.process = next; + this._sampleDur = cc.server.rates[2].sampleDur; + }; + var next = function() { + if (get_buffer(this)) { + this.outputs[0][0] = this._frames * this._sampleDur; + } + }; + return ctor; + })(); + + cc.ugen.specs.BufChannels = cc.ugen.specs.BufSampleRate; + + cc.unit.specs.BufChannels = (function() { + var ctor = function() { + this.process = next; + }; + var next = function() { + if (get_buffer(this)) { + this.outputs[0][0] = this._channels; + } + }; + return ctor; + })(); + + module.exports = {}; + +}); +define('cc/plugins/utils', function(require, exports, module) { + + var utils = require("../lang/utils"); + var twopi = 2 * Math.PI; + var kSineSize = 8192; + var kSineMask = kSineSize - 1; + var kBadValue = new Float32Array([1e20])[0]; + var gSine = new Float32Array(kSineSize + 1); + var gInvSine = new Float32Array(kSineSize + 1); + var gSineWavetable = new Float32Array(kSineSize * 2); + + (function() { + var i; + for (i = 0; i < kSineSize; ++i) { + var d = Math.sin(twopi * (i / kSineSize)); + gSine[i] = d; + gInvSine[i] = 1 / d; + } + gSine[kSineSize] = gSine[0]; + gInvSine[0] = gInvSine[kSineSize>>1] = gInvSine[kSineSize] = kBadValue; + var sz = kSineSize, sz2 = sz >> 1; + for (i = 1; i <= 8; ++i) { + gInvSine[i] = gInvSine[sz-i] = gInvSine[sz2-i] = gInvSine[sz2+i] = kBadValue; + } + })(); + (function() { + (function(signal, wavetable, inSize) { + var val1, val2; + var i, j; + for (i = j = 0; i < inSize - 1; ++i) { + val1 = signal[i]; + val2 = signal[i+1]; + wavetable[j++] = 2 * val1 - val2; + wavetable[j++] = val2 - val1; + } + val1 = signal[inSize - 1]; + val2 = signal[0]; + wavetable[j++] = 2 * val1 - val2; + wavetable[j++] = val2 - val1; + })(gSine, gSineWavetable, kSineSize); + })(); + + var cubicinterp = function(x, y0, y1, y2, y3) { + var c0 = y1; + var c1 = 0.5 * (y2 - y0); + var c2 = y0 - 2.5 * y1 + 2 * y2 - 0.5 * y3; + var c3 = 0.5 * (y3 - y0) + 1.5 * (y1 - y2); + return ((c3 * x + c2) * x + c1) * x + c0; + }; + + var sc_wrap = function(val, lo, hi) { + if (hi === lo) { + return lo; + } + var range = (hi - lo); + if (val >= hi) { + val -= range; + if (val < hi) { + return val; + } + } else if (val < lo) { + val += range; + if (val >= lo) { + return val; + } + } else { + return val; + } + return val - range * Math.floor((val - lo) / range); + }; + + var _ = { + kSineSize: kSineSize, + kSineMask: kSineMask, + kBadValue: kBadValue, + gSine : gSine, + gInvSine : gInvSine, + gSineWavetable: gSineWavetable, + + cubicinterp: cubicinterp, + sc_wrap: sc_wrap + }; + + Object.keys(utils).forEach(function(key) { + _[key] = utils[key]; + }); + + module.exports = _; + +}); +define('cc/plugins/debug', function(require, exports, module) { + + var cc = require("../cc"); + + var DebugUGen = { + $ar: { + defaults: "in=0", + ctor: function(_in) { + return this.multiNew(2, _in); + } + }, + $kr: { + defaults: "in=0", + ctor: function(_in) { + return this.multiNew(1, _in); + } + } + }; + + cc.ugen.specs.Debug = DebugUGen; + + cc.unit.specs.Debug = (function() { + var ctor = function() { + this.process = next; + }; + var next = function() { + this.outputs[0].set(this.inputs[0]); + cc.global.console.log(this.outputs[0][0]); + }; + return ctor; + })(); + + cc.ugen.specs.DebugNaN = DebugUGen; + + cc.unit.specs.DebugNaN = (function() { + var ctor = function() { + this.process = next; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var hasNaN = false; + for (var i = 0; i < inNumSamples; ++i) { + out[i] = inIn[i]; + if (isNaN(inIn[i])) { + hasNaN = true; + } + } + if (hasNaN) { + cc.global.console.log("NaN"); + } + }; + return ctor; + })(); + + module.exports = {}; + +}); +define('cc/plugins/decay', function(require, exports, module) { + + var cc = require("../cc"); + var log001 = Math.log(0.001); + + cc.ugen.specs.Integrator = { + $ar: { + defaults: "in=0,coef=1,mul=1,add=0", + ctor: function(_in, coef, mul, add) { + return this.multiNew(2, _in, coef).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,coef=1,mul=1,add=0", + ctor: function(_in, coef, mul, add) { + return this.multiNew(1, _in, coef).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.Integrator = (function() { + var ctor = function() { + this.process = next; + this._b1 = this.inputs[1][0]; + this._y1 = 0; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var nextB1 = this.inputs[1][0]; + var b1 = this._b1; + var y1 = this._y1; + var i; + if (b1 === nextB1) { + for (i = 0; i < inNumSamples; ++i) { + out[i] = y1 = (inIn[i] + b1 * y1); + } + } else { + var b1_slope = (nextB1 - b1) * this.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + out[i] = y1 = (inIn[i] + b1 * y1); + b1 += b1_slope; + } + this._b1 = nextB1; + } + this._y1 = y1; + }; + return ctor; + })(); + + cc.ugen.specs.Decay = { + $ar: { + defaults: "in=0,decayTime=1,mul=1,add=0", + ctor: function(_in, decayTime, mul, add) { + return this.multiNew(2, _in, decayTime).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,decayTime=1,mul=1,add=0", + ctor: function(_in, decayTime, mul, add) { + return this.multiNew(1, _in, decayTime).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.Decay = (function() { + var ctor = function() { + this.process = next; + this._decayTime = undefined; + this._b1 = 0; + this._y1 = 0; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var decayTime = this.inputs[1][0]; + var b1 = this._b1; + var y1 = this._y1; + var i; + if (decayTime === this._decayTime) { + for (i = 0; i < inNumSamples; ++i) { + out[i] = y1 = (inIn[i] + b1 * y1); + } + } else { + var next_b1 = decayTime === 0 ? 0 : Math.exp(log001 / (decayTime * this.rate.sampleRate)); + this._decayTime = decayTime; + var b1_slope = (next_b1 - b1) * this.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + out[i] = y1 = (inIn[i] + b1 * y1); + b1 += b1_slope; + } + this._b1 = next_b1; + } + this._y1 = y1; + }; + return ctor; + })(); + + cc.ugen.specs.Decay2 = { + $ar: { + defaults: "in=0,attackTime=0.01,decayTime=1,mul=1,add=0", + ctor: function(_in, attackTime, decayTime, mul, add) { + return this.multiNew(2, _in, attackTime, decayTime).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,attackTime=0.01,decayTime=1,mul=1,add=0", + ctor: function(_in, attackTime, decayTime, mul, add) { + return this.multiNew(1, _in, attackTime, decayTime).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.Decay2 = (function() { + var ctor = function() { + this.process = next; + this._attackTime = undefined; + this._decayTime = undefined; + this._b1a = 0; + this._b1b = 0; + this._y1a = 0; + this._y1b = 0; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var attackTime = this.inputs[1][0]; + var decayTime = this.inputs[2][0]; + var b1a = this._b1a; + var b1b = this._b1b; + var y1a = this._y1a; + var y1b = this._y1b; + var i; + if (attackTime === this._attackTime && decayTime === this._decayTime) { + for (i = 0; i < inNumSamples; ++i) { + y1a = inIn[i] + b1a * y1a; + y1b = inIn[i] + b1b * y1b; + out[i] = (y1a - y1b); + } + } else { + this._decayTime = decayTime; + this._attackTime = attackTime; + var next_b1a = decayTime === 0 ? 0 : Math.exp(log001 / (decayTime * this.rate.sampleRate)); + var next_b1b = attackTime === 0 ? 0 : Math.exp(log001 / (attackTime * this.rate.sampleRate)); + var b1a_slope = (next_b1a - b1a) * this.rate.slopeFactor; + var b1b_slope = (next_b1b - b1b) * this.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + y1a = inIn[i] + b1a * y1a; + y1b = inIn[i] + b1b * y1b; + out[i] = (y1a - y1b); + b1a += b1a_slope; + b1b += b1b_slope; + } + b1a = next_b1a; + b1b = next_b1b; + } + this._y1a = y1a; + this._y1b = y1b; + this._b1a = b1a; + this._b1b = b1b; + }; + return ctor; + })(); + + module.exports = {}; + +}); +define('cc/plugins/delay', function(require, exports, module) { + + var cc = require("../cc"); + var utils = require("./utils"); + var log001 = Math.log(0.001); + var cubicinterp = utils.cubicinterp; + + cc.ugen.specs.Delay1 = { + $ar: { + defaults: "in=0,mul=1,add=0", + ctor: function(_in, mul, add) { + return this.multiNew(2, _in).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,mul=1,add=0", + ctor: function(_in, mul, add) { + return this.multiNew(1, _in).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.Delay1 = (function() { + var ctor = function() { + if (this.bufLength === 1) { + this.process = next_1; + } else { + this.process = next; + } + this._x1 = 0; + next_1.call(this); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var x1 = this._x1; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = x1; + out[i+1] = inIn[i ]; + out[i+2] = inIn[i+1]; + out[i+3] = inIn[i+2]; + out[i+4] = inIn[i+3]; + out[i+5] = inIn[i+4]; + out[i+6] = inIn[i+5]; + out[i+7] = inIn[i+6]; + x1 = inIn[i+7]; + } + this._x1 = x1; + }; + var next_1 = function() { + this.outputs[0][0] = this._x1; + this._x1 = this.inputs[0][0]; + }; + return ctor; + })(); + + cc.ugen.specs.Delay2 = cc.ugen.specs.Delay1; + + cc.unit.specs.Delay2 = (function() { + var ctor = function() { + if (this.bufLength === 1) { + this.process = next_1; + } else { + this.process = next; + } + this._x1 = this._x2 = 0; + next_1.call(this); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var x1 = this._x1; + var x2 = this._x2; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = x1; + out[i+1] = x2; + out[i+2] = inIn[i ]; + out[i+3] = inIn[i+1]; + out[i+4] = inIn[i+2]; + out[i+5] = inIn[i+3]; + out[i+6] = inIn[i+4]; + out[i+7] = inIn[i+5]; + x1 = inIn[i+6]; + x2 = inIn[i+7]; + } + this._x1 = x1; + this._x2 = x2; + }; + var next_1 = function() { + this.outputs[0][0] = this._x1; + this._x1 = this._x2; + this._x2 = this.inputs[0][0]; + }; + return ctor; + })(); + + // util functions + var calcDelay = function(unit, delaytime, minDelay) { + return Math.max(minDelay, Math.min(delaytime * unit.rate.sampleRate, unit._fdelaylen)); + }; + var calcFeedback = function(delaytime, decaytime) { + if (delaytime === 0 || decaytime === 0) { + return 0; + } + if (decaytime > 0) { + return +Math.exp(log001 * delaytime / +decaytime); + } else { + return -Math.exp(log001 * delaytime / -decaytime); + } + }; + var perform_N = function(table, mask, phase) { + return table[phase & mask]; + }; + var perform_L = function(table, mask, phase, frac) { + var d1 = table[(phase )&mask]; + var d2 = table[(phase-1)&mask]; + return d1 + frac * (d2 - d1); + }; + var perform_C = function(table, mask, phase, frac) { + var d0 = table[(phase+1)&mask]; + var d1 = table[(phase )&mask]; + var d2 = table[(phase-1)&mask]; + var d3 = table[(phase-2)&mask]; + return cubicinterp(frac, d0, d1, d2, d3); + }; + + cc.ugen.specs.DelayN = { + $ar: { + defaults: "in=0,maxdelaytime=0.2,delaytime=0.2,mul=1,add=0", + ctor: function(_in, maxdelaytime, delaytime, mul, add) { + return this.multiNew(2, _in, maxdelaytime, delaytime).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,maxdelaytime=0.2,delaytime=0.2,mul=1,add=0", + ctor: function(_in, maxdelaytime, delaytime, mul, add) { + return this.multiNew(1, _in, maxdelaytime, delaytime).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + cc.ugen.specs.DelayL = cc.ugen.specs.DelayN; + cc.ugen.specs.DelayC = cc.ugen.specs.DelayN; + + // DelayN/DelayL/DelayC + var delay_ctor = function(unit) { + unit._maxdelaytime = unit.inputs[1][0]; + unit._delaytime = unit.inputs[2][0]; + unit._dlybuf = 0; + + var delaybufsize = Math.ceil(unit._maxdelaytime * unit.rate.sampleRate + 1); + delaybufsize = delaybufsize + unit.rate.bufLength; + delaybufsize = 1 << Math.ceil(Math.log(delaybufsize) * Math.LOG2E); + unit._fdelaylen = unit._idelaylen = delaybufsize; + + unit._dlybuf = new Float32Array(delaybufsize); + unit._mask = delaybufsize - 1; + + unit._dsamp = calcDelay(unit, unit._delaytime, 1); + unit._numoutput = 0; + unit._iwrphase = 0; + }; + var delay_next = function(unit, inNumSamples, perform) { + var out = unit.outputs[0]; + var inIn = unit.inputs[0]; + var delaytime = unit.inputs[2][0]; + var dlybuf = unit._dlybuf; + var iwrphase = unit._iwrphase; + var dsamp = unit._dsamp; + var mask = unit._mask; + var frac, irdphase; + var i; + if (delaytime === unit._delaytime) { + frac = dsamp - (dsamp|0); + for (i = 0; i < inNumSamples; ++i) { + dlybuf[iwrphase & mask] = inIn[i]; + irdphase = iwrphase - (dsamp|0); + out[i] = perform(dlybuf, mask, irdphase, frac); + iwrphase += 1; + } + } else { + var next_dsamp = calcDelay(unit, delaytime, 1); + var dsamp_slope = (next_dsamp - dsamp) * unit.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + dlybuf[iwrphase & mask] = inIn[i]; + dsamp += dsamp_slope; + frac = dsamp - (dsamp|0); + irdphase = iwrphase - (dsamp|0); + out[i] = perform(dlybuf, mask, irdphase, frac); + iwrphase += 1; + } + unit._dsamp = next_dsamp; + unit._delaytime = delaytime; + } + if (iwrphase > dlybuf.length) { + iwrphase -= dlybuf.length; + } + unit._iwrphase = iwrphase; + }; + + cc.unit.specs.DelayN = (function() { + var ctor = function() { + delay_ctor(this); + this.process = next; + }; + var next = function(inNumSamples) { + delay_next(this, inNumSamples, perform_N); + }; + return ctor; + })(); + + cc.unit.specs.DelayL = (function() { + var ctor = function() { + delay_ctor(this); + this.process = next; + }; + var next = function(inNumSamples) { + delay_next(this, inNumSamples, perform_L); + }; + return ctor; + })(); + + cc.unit.specs.DelayC = (function() { + var ctor = function() { + delay_ctor(this); + this.process = next; + }; + var next = function(inNumSamples) { + delay_next(this, inNumSamples, perform_C); + }; + return ctor; + })(); + + cc.ugen.specs.CombN = { + $ar: { + defaults: "in=0,maxdelaytime=0.2,delaytime=0.2,decaytime=1,mul=1,add=0", + ctor: function(_in, maxdelaytime, delaytime, decaytime, mul, add) { + return this.multiNew(2, _in, maxdelaytime, delaytime, decaytime).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,maxdelaytime=0.2,delaytime=0.2,decaytime=1,mul=1,add=0", + ctor: function(_in, maxdelaytime, delaytime, decaytime, mul, add) { + return this.multiNew(1, _in, maxdelaytime, delaytime, decaytime).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + cc.ugen.specs.CombL = cc.ugen.specs.CombN; + cc.ugen.specs.CombC = cc.ugen.specs.CombN; + + // CombN/CombL/CombC + var comb_ctor = function(unit) { + var delaybufsize; + unit._maxdelaytime = unit.inputs[1][0]; + unit._delaytime = unit.inputs[2][0]; + unit._decaytime = unit.inputs[3][0]; + delaybufsize = Math.ceil(unit._maxdelaytime * unit.rate.sampleRate + 1); + delaybufsize = delaybufsize + unit.rate.bufLength; + delaybufsize = 1 << Math.ceil(Math.log(delaybufsize) * Math.LOG2E); + unit._fdelaylen = unit._idelaylen = delaybufsize; + unit._dlybuf = new Float32Array(delaybufsize); + unit._mask = delaybufsize - 1; + unit._dsamp = calcDelay(unit, unit._delaytime, 1); + unit._iwrphase = 0; + unit._feedbk = calcFeedback(unit._delaytime, unit._decaytime); + }; + var comb_next = function(unit, inNumSamples, perform) { + var out = unit.outputs[0]; + var inIn = unit.inputs[0]; + var delaytime = unit.inputs[2][0]; + var decaytime = unit.inputs[3][0]; + var dlybuf = unit._dlybuf; + var iwrphase = unit._iwrphase; + var dsamp = unit._dsamp; + var feedbk = unit._feedbk; + var mask = unit._mask; + var frac = dsamp - (dsamp|0); + var irdphase, value; + var next_feedbk, feedbk_slope, next_dsamp, dsamp_slope; + var i; + if (delaytime === unit._delaytime) { + irdphase = iwrphase - (dsamp|0); + if (decaytime === unit._decaytime) { + for (i = 0; i < inNumSamples; ++i) { + value = perform(dlybuf, mask, irdphase, frac) || 0; + dlybuf[iwrphase & mask] = (inIn[i] + feedbk * value) || 0; + out[i] = value; + irdphase++; + iwrphase++; + } + } else { + next_feedbk = calcFeedback(delaytime, decaytime); + feedbk_slope = (next_feedbk - feedbk) * unit.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + value = perform(dlybuf, mask, irdphase, frac) || 0; + dlybuf[iwrphase & mask] = (inIn[i] + feedbk * value) || 0; + out[i] = value; + feedbk += feedbk_slope; + irdphase++; + iwrphase++; + } + unit._feedbk = next_feedbk; + unit._decaytime = decaytime; + } + } else { + next_dsamp = calcDelay(unit, delaytime, 1); + dsamp_slope = (next_dsamp - dsamp) * unit.rate.slopeFactor; + next_feedbk = calcFeedback(delaytime, decaytime); + feedbk_slope = (next_feedbk - feedbk) * unit.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + irdphase = iwrphase - (dsamp|0); + value = perform(dlybuf, mask, irdphase, frac) || 0; + dlybuf[iwrphase & mask] = (inIn[i] + feedbk * value) || 0; + out[i] = value; + dsamp += dsamp_slope; + feedbk += feedbk_slope; + irdphase++; + iwrphase++; + } + unit._feedbk = feedbk; + unit._dsamp = dsamp; + unit._delaytime = delaytime; + unit._decaytime = decaytime; + } + unit._iwrphase = iwrphase; + }; + + cc.unit.specs.CombN = (function() { + var ctor = function() { + comb_ctor(this); + this.process = next; + }; + var next = function(inNumSamples) { + comb_next(this, inNumSamples, perform_N); + }; + return ctor; + })(); + + cc.unit.specs.CombL = (function() { + var ctor = function() { + comb_ctor(this); + this.process = next; + }; + var next = function(inNumSamples) { + comb_next(this, inNumSamples, perform_L); + }; + return ctor; + })(); + + cc.unit.specs.CombC = (function() { + var ctor = function() { + comb_ctor(this); + this.process = next; + }; + var next = function(inNumSamples) { + comb_next(this, inNumSamples, perform_C); + }; + return ctor; + })(); + + cc.ugen.specs.AllpassN = { + $ar: { + defaults: "in=0,maxdelaytime=0.2,delaytime=0.2,decaytime=1,mul=1,add=0", + ctor: function(_in, maxdelaytime, delaytime, decaytime, mul, add) { + return this.multiNew(2, _in, maxdelaytime, delaytime, decaytime).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,maxdelaytime=0.2,delaytime=0.2,decaytime=1,mul=1,add=0", + ctor: function(_in, maxdelaytime, delaytime, decaytime, mul, add) { + return this.multiNew(1, _in, maxdelaytime, delaytime, decaytime).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + cc.ugen.specs.AllpassL = cc.ugen.specs.AllpassN; + cc.ugen.specs.AllpassC = cc.ugen.specs.AllpassN; + + // AllpassN/AllpassL/AllpassC + var allpass_ctor = comb_ctor; + var allpass_next = function(unit, inNumSamples, perform) { + var out = unit.outputs[0]; + var inIn = unit.inputs[0]; + var delaytime = unit.inputs[2][0]; + var decaytime = unit.inputs[3][0]; + var dlybuf = unit._dlybuf; + var iwrphase = unit._iwrphase; + var dsamp = unit._dsamp; + var feedbk = unit._feedbk; + var mask = unit._mask; + var irdphase, frac, value, dwr; + var next_feedbk, feedbk_slope, next_dsamp, dsamp_slope; + var i; + if (delaytime === unit._delaytime) { + irdphase = iwrphase - (dsamp|0); + frac = dsamp - (dsamp|0); + if (decaytime === unit._decaytime) { + for (i = 0; i < inNumSamples; ++i) { + value = perform(dlybuf, mask, irdphase, frac) || 0; + dwr = (value * feedbk + inIn[i]) || 0; + dlybuf[iwrphase & mask] = dwr; + out[i] = value - feedbk * dwr; + irdphase++; + iwrphase++; + } + } else { + next_feedbk = calcFeedback(delaytime, decaytime); + feedbk_slope = (next_feedbk - feedbk) * unit.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + value = perform(dlybuf, mask, irdphase, frac) || 0; + dwr = (value * feedbk + inIn[i]) || 0; + dlybuf[iwrphase & mask] = dwr; + out[i] = value - feedbk * dwr; + feedbk += feedbk_slope; + irdphase++; + iwrphase++; + } + unit._feedbk = next_feedbk; + unit._decaytime = decaytime; + } + } else { + next_dsamp = calcDelay(unit, delaytime, 1); + dsamp_slope = (next_dsamp - dsamp) * unit.rate.slopeFactor; + next_feedbk = calcFeedback(delaytime, decaytime); + feedbk_slope = (next_feedbk - feedbk) * unit.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + irdphase = iwrphase - (dsamp|0); + frac = dsamp - (dsamp|0); + value = perform(dlybuf, mask, irdphase, frac) || 0; + dwr = (value * feedbk + inIn[i]) || 0; + dlybuf[iwrphase & mask] = dwr; + out[i] = value - feedbk * dwr; + dsamp += dsamp_slope; + feedbk += feedbk_slope; + irdphase++; + iwrphase++; + } + unit._feedbk = feedbk; + unit._dsamp = dsamp; + unit._delaytime = delaytime; + unit._decaytime = decaytime; + } + unit._iwrphase = iwrphase; + }; + + cc.unit.specs.AllpassN = (function() { + var ctor = function() { + allpass_ctor(this); + this.process = next; + }; + var next = function(inNumSamples) { + allpass_next(this, inNumSamples, perform_N); + }; + return ctor; + })(); + + cc.unit.specs.AllpassL = (function() { + var ctor = function() { + allpass_ctor(this); + this.process = next; + }; + var next = function(inNumSamples) { + allpass_next(this, inNumSamples, perform_L); + }; + return ctor; + })(); + + cc.unit.specs.AllpassC = (function() { + var ctor = function() { + allpass_ctor(this); + this.process = next; + }; + var next = function(inNumSamples) { + allpass_next(this, inNumSamples, perform_C); + }; + return ctor; + })(); + + module.exports = {}; + +}); +define('cc/plugins/demand', function(require, exports, module) { + + var cc = require("../cc"); + + var isDemandInput = function(unit, index) { + var fromUnit = unit.fromUnits[index]; + return fromUnit && fromUnit.calcRate === 3; + }; + + var inputDemand = function(unit, index) { + var fromUnit = unit.fromUnits[index]; + if (fromUnit && fromUnit.calcRate === 3) { + fromUnit.process(1); + } + return unit.inputs[index][0]; + }; + + var inputDemandA = function(unit, index, offset) { + var fromUnit = unit.fromUnits[index]; + if (fromUnit) { + switch (fromUnit.calcRate) { + case 2: + return unit.inputs[index][offset-1]; + case 3: + fromUnit.process(offset); + /* fall through */ + default: + return unit.inputs[index][0]; + } + } else { + return unit.inputs[index][0]; + } + }; + + var resetDemandInput = function(unit, index) { + var fromUnit = unit.fromUnits[index]; + if (fromUnit && fromUnit.calcRate === 3) { + fromUnit.process(0); + } + }; + + cc.ugen.specs.Demand = { + Klass: cc.MultiOutUGen, + $ar: { + defaults: "trig=0,reset=0,demandUGens=[]", + ctor: function(trig, reset, demandUGens) { + return this.multiNewList([2, trig, reset].concat(demandUGens)); + } + }, + $kr: { + defaults: "trig=0,reset=0,demandUGens=[]", + ctor: function(trig, reset, demandUGens) { + return this.multiNewList([1, trig, reset].concat(demandUGens)); + } + }, + init: function() { + return this.initOutputs(this.inputs.length - 2, this.rate); + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.Demand = (function() { + var ctor = function() { + this.process = next; + this._prevtrig = 0; + this._prevreset = 0; + this._prevout = new Float32Array(this.numOutputs); + }; + var next = function(inNumSamples) { + var outputs = this.outputs; + var inputs = this.inputs; + var trigIn = inputs[0]; + var resetIn = inputs[1]; + var prevout = this._prevout; + var prevtrig = this._prevtrig; + var prevreset = this._prevreset; + var ztrig, zreset, x; + var numInputs = this.numInputs; + var j, k; + + for (var i = 0; i < inNumSamples; ++i) { + ztrig = trigIn[i]; + zreset = resetIn[i]; + if (zreset > 0 && prevreset <= 0) { + for (j = 2; j < numInputs; ++j) { + resetDemandInput(this, j); + } + } + if (ztrig > 0 && prevtrig <= 0) { + for (j = 2, k = 0; j < numInputs; ++j) { + x = inputDemandA(this, j, i + 1); + if (isNaN(x)) { + x = prevout[k]; + this.done = true; + } else { + prevout[k] = x; + } + outputs[k][i] = x; + } + } else { + for (j = 2, k = 0; j < numInputs; ++j) { + outputs[k][i] = prevout[k]; + } + } + prevtrig = ztrig; + prevreset = zreset; + } + this._prevtrig = prevtrig; + this._prevreset = prevreset; + }; + return ctor; + })(); + + cc.ugen.specs.Dgeom = { + $new: { + defaults: "start=1,grow=2,length=Infinity", + ctor: function(start, grow, length) { + return this.multiNew(3, length, start, grow); + } + } + }; + + cc.unit.specs.Dgeom = (function() { + var ctor = function() { + this.process = next; + this._grow = 0; + this._value = 0; + this.process(0); + }; + + var next = function(inNumSamples) { + var grow, x; + if (inNumSamples) { + grow = inputDemandA(this, 2, inNumSamples); + if (!isNaN(grow)) { + this._grow = grow; + } + if (this._repeats < 0) { + x = inputDemandA(this, 0, inNumSamples); + this._repeats = Math.floor(x); // Infinity|0 -> 0 + this._value = inputDemandA(this, 1, inNumSamples); + } + if (this._repeatCount >= this._repeats) { + this.outputs[0][0] = NaN; + return; + } + this.outputs[0][0] = this._value; + this._value *= this._grow; + this._repeatCount++; + } else { + this._repeats = -1; + this._repeatCount = 0; + } + }; + + return ctor; + })(); + + cc.ugen.specs.Dseries = { + $new: { + defaults: "start=1,step=1,length=Infinity", + ctor: function(start, step, length) { + return this.multiNew(3, length, start, step); + } + } + }; + + cc.unit.specs.Dseries = (function() { + var ctor = function() { + this.process = next; + this._step = 0; + this._value = 0; + this.process(0); + }; + + var next = function(inNumSamples) { + var step, x; + if (inNumSamples) { + step = inputDemandA(this, 2, inNumSamples); + if (!isNaN(step)) { + this._step = step; + } + if (this._repeats < 0) { + x = inputDemandA(this, 0, inNumSamples); + this._repeats = Math.floor(x); // Infinity|0 -> 0 + this._value = inputDemandA(this, 1, inNumSamples); + } + if (this._repeatCount >= this._repeats) { + this.outputs[0][0] = NaN; + return; + } + this.outputs[0][0] = this._value; + this._value += this._step; + this._repeatCount++; + } else { + this._repeats = -1; + this._repeatCount = 0; + } + }; + + return ctor; + })(); + + cc.ugen.specs.Dwhite = { + $new: { + defaults: "lo=0,hi=1,length=Infinity", + ctor: function(lo, hi, length) { + return this.multiNew(3, length, lo, hi); + } + } + }; + + cc.unit.specs.Dwhite = (function() { + var ctor = function() { + this.process = next; + this._lo = 0; + this._hi = 0; + this.process(0); + }; + + var next = function(inNumSamples) { + var lo, hi, x; + if (inNumSamples) { + if (this._repeats < 0) { + x = inputDemandA(this, 0, inNumSamples); + this._repeats = Math.floor(x); // Infinity|0 -> 0 + } + if (this._repeatCount >= this._repeats) { + this.outputs[0][0] = NaN; + return; + } + this._repeatCount++; + lo = inputDemandA(this, 1, inNumSamples); + hi = inputDemandA(this, 2, inNumSamples); + + if (!isNaN(lo)) { this._lo = lo; } + if (!isNaN(hi)) { this._hi = hi; } + this.outputs[0][0] = Math.random() * (this._hi - this._lo) + this._lo; + } else { + this._repeats = -1; + this._repeatCount = 0; + } + }; + + return ctor; + })(); + + cc.ugen.specs.Diwhite = { + $new: { + defaults: "lo=0,hi=127,length=Infinity", + ctor: function(lo, hi, length) { + return this.multiNew(3, length, lo, hi); + } + } + }; + + cc.unit.specs.Diwhite = (function() { + var ctor = function() { + this.process = next; + this._lo = 0; + this._hi = 0; + this.process(0); + }; + + var next = function(inNumSamples) { + var lo, hi, x; + if (inNumSamples) { + if (this._repeats < 0) { + x = inputDemandA(this, 0, inNumSamples); + this._repeats = Math.floor(x); // Infinity|0 -> 0 + } + if (this._repeatCount >= this._repeats) { + this.outputs[0][0] = NaN; + return; + } + this._repeatCount++; + lo = inputDemandA(this, 1, inNumSamples); + hi = inputDemandA(this, 2, inNumSamples); + + if (!isNaN(lo)) { this._lo = Math.floor(lo); } + if (!isNaN(hi)) { this._hi = Math.floor(hi); } + this.outputs[0][0] = Math.floor((Math.random() * (this._hi - this._lo) + this._lo)); + } else { + this._repeats = -1; + this._repeatCount = 0; + } + }; + + return ctor; + })(); + + var ListDUGen = { + $new: { + defaults: "list=[],repeats=1", + ctor: function(list, repeats) { + return this.multiNewList([3, repeats].concat(list)); + } + } + }; + + cc.ugen.specs.Dser = ListDUGen; + + cc.unit.specs.Dser = (function() { + var ctor = function() { + this.process = next; + this.process(0); + }; + + var next = function(inNumSamples) { + var out = this.outputs[0]; + var x; + if (inNumSamples) { + if (this._repeats < 0) { + x = inputDemandA(this, 0, inNumSamples); + this._repeats = isNaN(x) ? 0 : Math.floor(x + 0.5); + } + while (true) { + if (this._index >= this.numInputs) { + this._index = 1; + } + if (this._repeatCount >= this._repeats) { + out[0] = NaN; + return; + } + if (isDemandInput(this, this._index)) { + if (this._needToResetChild) { + this._needToResetChild = false; + resetDemandInput(this, this._index); + } + x = inputDemandA(this, this._index, inNumSamples); + if (isNaN(x)) { + this._index++; + this._repeatCount++; + this._needToResetChild = true; + } else { + out[0] = x; + return; + } + } else { + out[0] = this.inputs[this._index][0]; + this._index++; + this._repeatCount++; + this._needToResetChild = true; + return; + } + } + } else { + this._repeats = -1; + this._repeatCount = 0; + this._needToResetChild = true; + this._index = 1; + } + }; + + return ctor; + })(); + + cc.ugen.specs.Dseq = ListDUGen; + + cc.unit.specs.Dseq = (function() { + var ctor = function() { + this.process = next; + this.process(0); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var x, attempts; + if (inNumSamples) { + if (this._repeats < 0) { + x = inputDemandA(this, 0, inNumSamples); + this._repeats = isNaN(x) ? 0 : Math.floor(x + 0.5); + } + attempts = 0; + while (true) { + if (this._index >= this.numInputs) { + this._index = 1; + this._repeatCount++; + } + if (this._repeatCount >= this._repeats) { + out[0] = NaN; + this._index = 1; + return; + } + if (isDemandInput(this, this._index)) { + if (this._needToResetChild) { + this._needToResetChild = false; + resetDemandInput(this, this._index); + } + x = inputDemandA(this, this._index, inNumSamples); + if (isNaN(x)) { + this._index++; + this._needToResetChild = true; + } else { + out[0] = x; + return; + } + } else { + out[0] = inputDemandA(this, this._index, inNumSamples); + this._index++; + this._needToResetChild = true; + return; + } + if (attempts++ > this.numInputs) { + return; + } + } + } else { + this._repeats = -1; + this._repeatCount = 0; + this._needToResetChild = true; + this._index = 1; + } + }; + return ctor; + })(); + + cc.ugen.specs.Dshuf = ListDUGen; + + cc.unit.specs.Dshuf = (function() { + var ctor = function() { + this.process = next; + var indices = new Array(this.numInputs - 1); + for (var i = 0, imax = indices.length; i < imax; ++i) { + indices[i] = i + 1; + } + this._indices = indices.sort(scramble); + this.process(0); + }; + var scramble = function() { + return Math.random() - 0.5; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var x, attempts; + if (inNumSamples) { + if (this._repeats < 0) { + x = inputDemandA(this, 0, inNumSamples); + this._repeats = isNaN(x) ? 0 : Math.floor(x + 0.5); + } + attempts = 0; + while (true) { + if (this._index >= this.numInputs - 1) { + this._index = 0; + this._repeatCount++; + } + if (this._repeatCount >= this._repeats) { + out[0] = NaN; + this._index = 0; + return; + } + var index = this._indices[this._index]; + if (isDemandInput(this, index)) { + if (this._needToResetChild) { + this._needToResetChild = false; + resetDemandInput(this, index); + } + x = inputDemandA(this, index, inNumSamples); + if (isNaN(x)) { + this._index++; + this._needToResetChild = true; + } else { + out[0] = x; + return; + } + } else { + out[0] = inputDemandA(this, index, inNumSamples); + this._index++; + this._needToResetChild = true; + return; + } + if (attempts++ > this.numInputs) { + return; + } + } + } else { + this._repeats = -1; + this._repeatCount = 0; + this._needToResetChild = true; + this._index = 1; + } + }; + return ctor; + })(); + + cc.ugen.specs.Drand = ListDUGen; + + cc.unit.specs.Drand = (function() { + var ctor = function() { + this.process = next; + this.process(0); + }; + + var next = function(inNumSamples) { + var out = this.outputs[0]; + var x; + if (inNumSamples) { + if (this._repeats < 0) { + x = inputDemandA(this, 0, inNumSamples); + this._repeats = isNaN(x) ? 0 : Math.floor(x + 0.5); + } + while (true) { + if (this._repeatCount >= this._repeats) { + out[0] = NaN; + return; + } + if (isDemandInput(this, this._index)) { + if (this._needToResetChild) { + this._needToResetChild = false; + resetDemandInput(this, this._index); + } + x = inputDemandA(this, this._index, inNumSamples); + if (isNaN(x)) { + this._index = ((Math.random() * (this.numInputs-1))|0)+1; + this._repeatCount++; + this._needToResetChild = true; + } else { + out[0] = x; + return; + } + } else { + out[0] = this.inputs[this._index][0]; + this._index = ((Math.random() * (this.numInputs-1))|0)+1; + this._repeatCount++; + this._needToResetChild = true; + return; + } + } + } else { + this._repeats = -1; + this._repeatCount = 0; + this._needToResetChild = true; + this._index = 1; + } + }; + + return ctor; + })(); + + cc.ugen.specs.Duty = { + $ar: { + defaults: "dur=1,reset=0,level=1,doneAction=0", + ctor: function(dur, reset, level, doneAction) { + return this.multiNew(2, dur, reset, doneAction, level); + } + }, + $kr: { + defaults: "dur=1,reset=0,level=1,doneAction=0", + ctor: function(dur, reset, level, doneAction) { + return this.multiNew(1, dur, reset, doneAction, level); + } + } + }; + + var duty_dur = 0; + var duty_reset = 1; + var duty_doneAction = 2; + var duty_level = 3; + + cc.unit.specs.Duty = (function() { + var ctor = function() { + if (this.inRates[duty_reset] === 2) { + this.process = next_da; + this._prevreset = 0; + } else { + if (this.inRates[duty_reset] === 3) { + this.process = next_dd; + this._prevreset = inputDemand(this, duty_reset) * this.rate.sampleRate; + } else { + this.process = next_dk; + this._prevreset = 0; + } + } + this._count = inputDemand(this, duty_dur) * this.rate.sampleRate - 1; + this._prevout = inputDemand(this, duty_level); + this.outputs[0][0] = this._prevout; + }; + var next_da = function(inNumSamples) { + var out = this.outputs[0]; + var resetIn = this.inputs[duty_reset]; + var prevout = this._prevout; + var count = this._count; + var prevreset = this._prevreset; + var sr = this.rate.sampleRate; + var zreset, x; + for (var i = 0; i < inNumSamples; ++i) { + zreset = resetIn[i]; + if (zreset > 0 && prevreset <= 0) { + resetDemandInput(this, duty_level); + resetDemandInput(this, duty_dur); + count = 0; + } + if (count <= 0) { + count = inputDemandA(this, duty_dur, i+1) * sr + count; + if (isNaN(count)) { + this.doneAction(this.inputs[3][duty_doneAction]); + } + x = inputDemandA(this, duty_level, i + 1); + if (isNaN(x)) { + x = prevout; + this.doneAction(this.inputs[3][duty_doneAction]); + } else { + prevout = x; + } + out[i] = x; + } else { + count--; + out[i] = prevout; + } + } + this._count = count; + this._prevreset = prevreset; + this._prevout = prevout; + }; + var next_dk = function(inNumSamples) { + var out = this.outputs[0]; + var resetIn = this.inputs[duty_reset]; + var prevout = this._prevout; + var count = this._count; + var prevreset = this._prevreset; + var sr = this.rate.sampleRate; + var zreset, x; + zreset = resetIn[0]; + for (var i = 0; i < inNumSamples; ++i) { + if (zreset > 0 && prevreset <= 0) { + resetDemandInput(this, duty_level); + resetDemandInput(this, duty_dur); + count = 0; + } + if (count <= 0) { + count = inputDemandA(this, duty_dur, i+1) * sr + count; + if (isNaN(count)) { + this.doneAction(this.inputs[duty_doneAction][0]); + } + x = inputDemandA(this, duty_level, i + 1); + if (isNaN(x)) { + x = prevout; + this.doneAction(this.inputs[duty_doneAction][0]); + } else { + prevout = x; + } + out[i] = x; + } else { + count--; + out[i] = prevout; + } + } + this._count = count; + this._prevreset = prevreset; + this._prevout = prevout; + }; + var next_dd = function(inNumSamples) { + var out = this.outputs[0]; + var prevout = this._prevout; + var count = this._count; + var reset = this._prevreset; + var sr = this.rate.sampleRate; + var x; + + for (var i = 0; i < inNumSamples; ++i) { + if (reset <= 0) { + resetDemandInput(this, duty_level); + resetDemandInput(this, duty_dur); + count = 0; + reset = inputDemandA(this, duty_reset, i + 1) * sr + reset; + } else { + reset--; + } + if (count <= 0) { + count = inputDemandA(this, duty_dur, i+1) * sr + count; + if (isNaN(count)) { + this.doneAction(this.inputs[duty_doneAction][0]); + } + x = inputDemandA(this, duty_level, i + 1); + if (isNaN(x)) { + x = prevout; + this.doneAction(this.inputs[duty_doneAction][0]); + } else { + prevout = x; + } + out[i] = x; + } + out[i] = prevout; + count--; + } + this._count = count; + this._prevreset = reset; + this._prevout = prevout; + }; + return ctor; + })(); + + + cc.ugen.specs.TDuty = { + $ar: { + defaults: "dur=1,reset=0,level=1,doneAction=0,gapFirst=0", + ctor: function(dur, reset, level, doneAction, gapFirst) { + return this.multiNew(2, dur, reset, doneAction, level, gapFirst); + } + }, + $kr: { + defaults: "dur=1,reset=0,level=1,doneAction=0,gapFirst=0", + ctor: function(dur, reset, level, doneAction, gapFirst) { + return this.multiNew(1, dur, reset, doneAction, level, gapFirst); + } + } + }; + + cc.unit.specs.TDuty = (function() { + var ctor = function() { + if (this.inRates[duty_reset] === 2) { + this.process = next_da; + this._prevreset = 0; + } else { + if (this.inRates[duty_reset] === 3) { + this.process = next_dd; + this._prevreset = inputDemand(this, duty_reset) * this.rate.sampleRate; + } else { + this.process = next_dk; + this._prevreset = 0; + } + } + if (this.inputs[4][0]) { + this._count = inputDemand(this, duty_dur) * this.rate.sampleRate; + } else { + this._count = 0; + } + this.outputs[0][0] = 0; + }; + var next_da = function(inNumSamples) { + var out = this.outputs[0]; + var resetIn = this.inputs[duty_reset]; + var count = this._count; + var prevreset = this._prevreset; + var sr = this.rate.sampleRate; + var zreset, x; + for (var i = 0; i < inNumSamples; ++i) { + zreset = resetIn[i]; + if (zreset > 0 && prevreset <= 0) { + resetDemandInput(this, duty_level); + resetDemandInput(this, duty_dur); + count = 0; + } + if (count <= 0) { + count = inputDemandA(this, duty_dur, 1 + 1) * sr + count; + if (isNaN(count)) { + this.doneAction(this.inputs[duty_doneAction][0]); + } + x = inputDemandA(this, duty_level, i + 1); + if (isNaN(x)) { + x = 0; + } + out[i] = x; + } else { + out[i] = 0; + } + count--; + prevreset = zreset; + } + this._count = count; + this._prevreset = prevreset; + }; + var next_dk = function(inNumSamples) { + var out = this.outputs[0]; + var resetIn = this.inputs[duty_reset]; + var count = this._count; + var prevreset = this._prevreset; + var sr = this.rate.sampleRate; + var zreset, x; + zreset = resetIn[0]; + for (var i = 0; i < inNumSamples; ++i) { + if (zreset > 0 && prevreset <= 0) { + resetDemandInput(this, duty_level); + resetDemandInput(this, duty_dur); + count = 0; + } + if (count <= 0) { + count = inputDemandA(this, duty_dur, 1 + 1) * sr + count; + if (isNaN(count)) { + this.doneAction(this.inputs[duty_doneAction][0]); + } + x = inputDemandA(this, duty_level, i + 1); + if (isNaN(x)) { + x = 0; + } + out[i] = x; + } else { + out[i] = 0; + } + count--; + prevreset = zreset; + } + this._count = count; + this._prevreset = prevreset; + }; + var next_dd = function(inNumSamples) { + var out = this.outputs[0]; + var count = this._count; + var reset = this._prevreset; + var sr = this.rate.sampleRate; + var x; + for (var i = 0; i < inNumSamples; ++i) { + if (reset <= 0) { + resetDemandInput(this, duty_level); + resetDemandInput(this, duty_dur); + count = 0; + reset = inputDemandA(this, duty_reset, i + 1) * sr + reset; + } else { + reset--; + } + if (count <= 0) { + count = inputDemandA(this, duty_dur, 1 + 1) * sr + count; + if (isNaN(count)) { + this.doneAction(this.inputs[duty_doneAction][0]); + } + x = inputDemandA(this, duty_level, i + 1); + if (isNaN(x)) { + x = 0; + } + out[i] = x; + } else { + out[i] = 0; + } + count--; + } + this._count = count; + this._prevreset = reset; + }; + return ctor; + })(); + + module.exports = {}; + +}); +define('cc/plugins/env', function(require, exports, module) { + + var cc = require("../cc"); + + var kEnvGen_gate = 0; + var kEnvGen_levelScale = 1; + var kEnvGen_levelBias = 2; + var kEnvGen_timeScale = 3; + var kEnvGen_doneAction = 4; + var kEnvGen_initLevel = 5; + var kEnvGen_numStages = 6; + var kEnvGen_releaseNode = 7; + var kEnvGen_loopNode = 8; + var kEnvGen_nodeOffset = 9; + var shape_Step = 0; + var shape_Linear = 1; + var shape_Exponential = 2; + var shape_Sine = 3; + var shape_Welch = 4; + var shape_Curve = 5; + var shape_Squared = 6; + var shape_Cubed = 7; + var shape_Sustain = 9999; + + var convertEnv = function(env) { + return env.asMultichannelArray(); + }; + + cc.ugen.specs.EnvGen = { + $ar: { + defaults: "envelope,gate=1,levelScale=1,levelBias=0,timeScale=1,doneAction=0", + ctor: function(envelope, gate, levelScale, levelBias, timeScale, doneAction) { + envelope = convertEnv(envelope)[0]; // TODO: unbubble + return this.multiNewList([2, gate, levelScale, levelBias, timeScale, doneAction].concat(envelope)); + } + }, + $kr: { + defaults: "envelope,gate=1,levelScale=1,levelBias=0,timeScale=1,doneAction=0", + ctor: function(envelope, gate, levelScale, levelBias, timeScale, doneAction) { + envelope = convertEnv(envelope)[0]; // TODO: unbubble + return this.multiNewList([1, gate, levelScale, levelBias, timeScale, doneAction].concat(envelope)); + } + } + }; + + cc.unit.specs.EnvGen = (function() { + var ctor = function() { + if (this.calcRate === 2) { + this.process = next_ak; + } else { + this.process = next_k; + } + this._level = this.inputs[kEnvGen_initLevel][0] * this.inputs[kEnvGen_levelScale][0] + this.inputs[kEnvGen_levelBias][0]; + this._endLevel = this._level; + this._counter = 0; + this._stage = 1000000000; + this._prevGate = 0; + this._released = false; + this._releaseNode = this.inputs[kEnvGen_releaseNode][0]|0; + this._a1 = 0; + this._a2 = 0; + this._b1 = 0; + this._y1 = 0; + this._y2 = 0; + this._grow = 0; + this._shape = 0; + next_k.call(this, 1); + }; + var next_ak = function(inNumSamples) { + var out = this.outputs[0]; + var gate = this.inputs[kEnvGen_gate][0]; + var counter = this._counter; + var level = this._level; + var prevGate = this._prevGate; + var numstages, doneAction, loopNode; + var envPtr, stageOffset, endLevel, dur, shape, curve; + var w, a1, a2, b1, y0, y1, y2, grow; + var i, j = 0; + + var checkGate = true, counterOffset = 0; + if (prevGate <= 0 && gate > 0) { + this._stage = -1; + this._released = false; + this.done = false; + counter = counterOffset; + checkGate = false; + } else if (gate <= -1 && prevGate > -1 && !this._released) { + numstages = this.inputs[kEnvGen_numStages][0]|0; + dur = -gate - 1; + counter = Math.max(1, (dur * this.rate.sampleRate)|0) + counterOffset; + this._stage = numstages; + this._shape = shape_Linear; + this._endLevel = this.inputs[this.numInputs - 4][0] * this.inputs[kEnvGen_levelScale][0] + this.inputs[kEnvGen_levelBias][0]; + this._grow = (this._endLevel - level) / counter; + this._released = true; + checkGate = true; + } else if (prevGate > 0 && gate <= 0 && this._releaseNode >= 0 && !this._released) { + counter = counterOffset; + this._stage = this._releaseNode - 1; + this._released = true; + checkGate = false; + } + this._prevGate = gate; + + var remain = inNumSamples; + while (remain) { + var initSegment = false; + if (counter === 0) { + numstages = this.inputs[kEnvGen_numStages][0]|0; + if (this._stage + 1 >= numstages) { + counter = Infinity; + this._shape = 0; + level = this._endLevel; + this.done = true; + doneAction = this.inputs[kEnvGen_doneAction][0]|0; + this.doneAction(doneAction); + } else if (this._stage + 1 === this._releaseNode && !this._released) { // sustain stage + loopNode = this.inputs[kEnvGen_loopNode][0]|0; + if (loopNode >= 0 && loopNode < numstages) { + this._stage = loopNode; + initSegment = true; + } else { + counter = Infinity; + this._shape = shape_Sustain; + level = this._endLevel; + } + } else { + this._stage += 1; + initSegment = true; + } + } + + if (initSegment) { + stageOffset = (this._stage << 2) + kEnvGen_nodeOffset; + if (stageOffset + 4 > this.numInputs) { + // oops; + return; + } + + envPtr = this.inputs; + endLevel = envPtr[0+stageOffset][0] * this.inputs[kEnvGen_levelScale][0] + this.inputs[kEnvGen_levelBias][0]; // scale levels + dur = envPtr[1+stageOffset][0] * this.inputs[kEnvGen_timeScale ][0]; + shape = envPtr[2+stageOffset][0]|0; + curve = envPtr[3+stageOffset][0]; + this._endLevel = endLevel; + this._shape = shape; + + counter = Math.max(1, (dur * this.rate.sampleRate)|0); + if (counter === 1) { + this._shape = shape_Linear; + } + switch (this._shape) { + case shape_Step: + level = endLevel; + break; + case shape_Linear: + this._grow = (endLevel - level) / counter; + break; + case shape_Exponential: + if (Math.abs(level) < 1e-6) { + level = 1e-6; + } + this._grow = Math.pow(endLevel / level, 1 / counter); + break; + case shape_Sine: + w = Math.PI / counter; + this._a2 = (endLevel + level) * 0.5; + this._b1 = 2 * Math.cos(w); + this._y1 = (endLevel - level) * 0.5; + this._y2 = this._y1 * Math.sin(Math.PI * 0.5 - w); + level = this._a2 - this._y1; + break; + case shape_Welch: + w = (Math.PI * 0.5) / counter; + this._b1 = 2 * Math.cos(w); + if (endLevel >= level) { + this._a2 = level; + this._y1 = 0; + this._y2 = -Math.sin(w) * (endLevel - level); + } else { + this._a2 = endLevel; + this._y1 = level - endLevel; + this._y2 = Math.cos(w) * (level - endLevel); + } + level = this._a2 + this._y1; + break; + case shape_Curve: + if (Math.abs(curve) < 0.001) { + this._shape = shape_Linear; + this._grow = (endLevel - level) / counter; + } else { + a1 = (endLevel - level) / (1.0 - Math.exp(curve)); + this._a2 = level + a1; + this._b1 = a1; + this._grow = Math.exp(curve / counter); + } + break; + case shape_Squared: + this._y1 = Math.sqrt(level); + this._y2 = Math.sqrt(endLevel); + this._grow = (this._y2 - this._y1) / counter; + break; + case shape_Cubed: + this._y1 = Math.pow(level , 0.33333333); + this._y2 = Math.pow(endLevel, 0.33333333); + this._grow = (this._y2 - this._y1) / counter; + break; + } + } + + var nsmps = Math.min(remain, counter); + + grow = this._grow; + a2 = this._a2; + b1 = this._b1; + y1 = this._y1; + y2 = this._y2; + + switch (this._shape) { + case shape_Step: + for (i = 0; i < nsmps; ++i) { + out[j++] = level; + } + break; + case shape_Linear: + for (i = 0; i < nsmps; ++i) { + out[j++] = level; + level += grow; + } + break; + case shape_Exponential: + for (i = 0; i < nsmps; ++i) { + out[j++] = level; + level *= grow; + } + break; + case shape_Sine: + for (i = 0; i < nsmps; ++i) { + out[j++] = level; + y0 = b1 * y1 - y2; + level = a2 - y0; + y2 = y1; + y1 = y0; + } + break; + case shape_Welch: + for (i = 0; i < nsmps; ++i) { + out[j++] = level; + y0 = b1 * y1 - y2; + level = a2 + y0; + y2 = y1; + y1 = y0; + } + break; + case shape_Curve: + for (i = 0; i < nsmps; ++i) { + out[j++] = level; + b1 *= grow; + level = a2 - b1; + } + break; + case shape_Squared: + for (i = 0; i < nsmps; ++i) { + out[j++] = level; + y1 += grow; + level = y1 * y1; + } + break; + case shape_Cubed: + for (i = 0; i < nsmps; ++i) { + out[j++] = level; + y1 += grow; + level = y1 * y1 * y1; + } + break; + case shape_Sustain: + for (i = 0; i < nsmps; ++i) { + out[j++] = level; + } + break; + } + remain -= nsmps; + counter -= nsmps; + } + this._level = level; + this._counter = counter; + this._a2 = a2; + this._b1 = b1; + this._y1 = y1; + this._y2 = y2; + }; + var next_k = function() { + var out = this.outputs[0]; + var gate = this.inputs[kEnvGen_gate][0]; + var counter = this._counter; + var level = this._level; + var prevGate = this._prevGate; + var numstages, doneAction, loopNode; + var envPtr, stageOffset, endLevel, dur, shape, curve; + var w, a1, a2, b1, y0, y1, y2, grow; + + var checkGate = true, counterOffset = 0; + if (prevGate <= 0 && gate > 0) { + this._stage = -1; + this._released = false; + this.done = false; + counter = counterOffset; + checkGate = false; + } else if (gate <= -1 && prevGate > -1 && !this._released) { + numstages = this.inputs[kEnvGen_numStages][0]|0; + dur = -gate - 1; + counter = Math.max(1, (dur * this.rate.sampleRate)|0) + counterOffset; + this._stage = numstages; + this._shape = shape_Linear; + this._endLevel = this.inputs[this.numInputs - 4][0] * this.inputs[kEnvGen_levelScale][0] + this.inputs[kEnvGen_levelBias][0]; + this._grow = (this._endLevel - level) / counter; + this._released = true; + checkGate = true; + } else if (prevGate > 0 && gate <= 0 && this._releaseNode >= 0 && !this._released) { + counter = counterOffset; + this._stage = this._releaseNode - 1; + this._released = true; + checkGate = false; + } + this._prevGate = gate; + + var initSegment = false; + if (counter <= 0) { + numstages = this.inputs[kEnvGen_numStages][0]|0; + if (this._stage + 1 >= numstages) { + counter = Infinity; + this._shape = 0; + level = this._endLevel; + this.done = true; + doneAction = this.inputs[kEnvGen_doneAction][0]|0; + this.doneAction(doneAction); + } else if (this._stage + 1 === this._releaseNode && !this._released) { // sustain stage + loopNode = this.inputs[kEnvGen_loopNode][0]|0; + if (loopNode >= 0 && loopNode < numstages) { + this._stage = loopNode; + initSegment = true; + } else { + counter = Infinity; + this._shape = shape_Sustain; + level = this._endLevel; + } + } else { + this._stage += 1; + initSegment = true; + } + } + + if (initSegment) { + stageOffset = (this._stage << 2) + kEnvGen_nodeOffset; + if (stageOffset + 4 > this.numInputs) { + // oops; + return; + } + + envPtr = this.inputs; + endLevel = envPtr[0+stageOffset][0] * this.inputs[kEnvGen_levelScale][0] + this.inputs[kEnvGen_levelBias][0]; // scale levels + dur = envPtr[1+stageOffset][0] * this.inputs[kEnvGen_timeScale ][0]; + shape = envPtr[2+stageOffset][0]|0; + curve = envPtr[3+stageOffset][0]; + this._endLevel = endLevel; + this._shape = shape; + + counter = Math.max(1, (dur * this.rate.sampleRate)|0); + if (counter === 1) { + this._shape = shape_Linear; + } + switch (this._shape) { + case shape_Step: + level = endLevel; + break; + case shape_Linear: + this._grow = (endLevel - level) / counter; + break; + case shape_Exponential: + if (Math.abs(level) < 1e-6) { + level = 1e-6; + } + this._grow = Math.pow(endLevel / level, 1 / counter); + break; + case shape_Sine: + w = Math.PI / counter; + this._a2 = (endLevel + level) * 0.5; + this._b1 = 2 * Math.cos(w); + this._y1 = (endLevel - level) * 0.5; + this._y2 = this._y1 * Math.sin(Math.PI * 0.5 - w); + level = this._a2 - this._y1; + break; + case shape_Welch: + w = (Math.PI * 0.5) / counter; + this._b1 = 2 * Math.cos(w); + if (endLevel >= level) { + this._a2 = level; + this._y1 = 0; + this._y2 = -Math.sin(w) * (endLevel - level); + } else { + this._a2 = endLevel; + this._y1 = level - endLevel; + this._y2 = Math.cos(w) * (level - endLevel); + } + level = this._a2 + this._y1; + break; + case shape_Curve: + if (Math.abs(curve) < 0.001) { + this._shape = shape_Linear; + this._grow = (endLevel - level) / counter; + } else { + a1 = (endLevel - level) / (1.0 - Math.exp(curve)); + this._a2 = level + a1; + this._b1 = a1; + this._grow = Math.exp(curve / counter); + } + break; + case shape_Squared: + this._y1 = Math.sqrt(level); + this._y2 = Math.sqrt(endLevel); + this._grow = (this._y2 - this._y1) / counter; + break; + case shape_Cubed: + this._y1 = Math.pow(level , 0.33333333); + this._y2 = Math.pow(endLevel, 0.33333333); + this._grow = (this._y2 - this._y1) / counter; + break; + } + } + + grow = this._grow; + a2 = this._a2; + b1 = this._b1; + y1 = this._y1; + y2 = this._y2; + + switch (this._shape) { + case shape_Step: + break; + case shape_Linear: + level += grow; + break; + case shape_Exponential: + level *= grow; + break; + case shape_Sine: + y0 = b1 * y1 - y2; + level = a2 - y0; + y2 = y1; + y1 = y0; + break; + case shape_Welch: + y0 = b1 * y1 - y2; + level = a2 + y0; + y2 = y1; + y1 = y0; + break; + case shape_Curve: + b1 *= grow; + level = a2 - b1; + break; + case shape_Squared: + y1 += grow; + level = y1 * y1; + break; + case shape_Cubed: + y1 += grow; + level = y1 * y1 * y1; + break; + case shape_Sustain: + break; + } + out[0] = level; + this._level = level; + this._counter = counter - 1; + this._a2 = a2; + this._b1 = b1; + this._y1 = y1; + this._y2 = y2; + }; + return ctor; + })(); + + cc.ugen.specs.Linen = { + $kr: { + defaults: "gate=1,attackTime=0.01,susLevel=1,releaseTime=1,doneAction=0", + ctor: function(gate, attackTime, susLevel, releaseTime, doneAction) { + return this.multiNew(1, gate, attackTime, susLevel, releaseTime, doneAction); + } + } + }; + + cc.unit.specs.Linen = (function() { + var ctor = function() { + this.process = next; + this._level = 0; + this._stage = 4; + this._prevGate = 0; + this._slope = 0; + this._counter = 0; + this.process(1); + }; + var next = function() { + var out = this.outputs[0]; + var gate = this.inputs[0][0]; + var attackTime, susLevel, releaseTime; + var counter; + + if (this._prevGate <= 0 && gate > 0) { + this.done = false; + this._stage = 0; + attackTime = this.inputs[1][0]; + susLevel = this.inputs[2][0]; + counter = Math.max(1, (attackTime * this.rate.sampleRate)|0); + this._slope = (susLevel - this._level) / counter; + this._counter = counter; + } + switch (this._stage) { + case 0: + case 2: + out[0] = this._level; + this._level += this._slope; + if (--this._counter === 0) { + this._stage++; + } + break; + case 1: + out[0] = this._level; + if (gate <= -1) { + this._stage = 2; + releaseTime = -gate - 1; + counter = Math.max(1, (releaseTime * this.rate.sampleRate)|0); + this._slope = (-this._level) / counter; + this._counter = counter; + } else if (gate <= 0) { + this._stage = 2; + releaseTime = this.inputs[3][0]; + counter = Math.max(1, (releaseTime * this.rate.sampleRate)|0); + this._slope = (-this._level) / counter; + this._counter = counter; + } + break; + case 3: + out[0] = 0; + this.done = true; + this._stage++; + this.doneAction(this.inputs[4][0]); + break; + case 4: + out[0] = 0; + break; + } + this._prevGate = gate; + }; + return ctor; + })(); + + cc.ugen.specs.Free = { + $kr: { + defaults: "trig=0,id=0", + ctor: function(trig, id) { + return this.multiNew(1, trig, id); + } + } + }; + + cc.unit.specs.Free = (function() { + var ctor = function() { + this.process = next; + this._prevtrig = 0; + this.process(1); + }; + var next = function() { + var trig = this.inputs[0][0]; + var id, node; + if (trig > 0 && this._prevtrig <= 0) { + id = this.inputs[1][0]|0; + if (id) { // 0 is ignored + node = this.world.nodes[id]; + if (node) { + node.end(); + } + } + } + this._prevtrig = trig; + this.outputs[0][0] = trig; + }; + return ctor; + })(); + + cc.ugen.specs.FreeSelf = { + $kr: { + defaults: "in=0", + ctor: function(_in) { + return this.multiNew(1, _in); + } + } + }; + + cc.unit.specs.FreeSelf = (function() { + var ctor = function() { + this.process = next; + this._prevtrig = 0; + this.process(1); + }; + var next = function() { + var trig = this.inputs[0][0]; + if (trig > 0 && this._prevtrig <= 0) { + this.parent.end(); + } + this._prevtrig = trig; + this.outputs[0][0] = trig; + }; + return ctor; + })(); + + cc.ugen.specs.FreeSelfWhenDone = { + $kr: { + defaults: "src=0", + ctor: function(src) { + return this.multiNew(1, src); + } + } + }; + + cc.unit.specs.FreeSelfWhenDone = (function() { + var ctor = function() { + this.process = next; + this._src = this.fromUnits[0]; + this.process(1); + }; + var next = function() { + var src = this._src; + if (src && src.done) { + this.parent.end(); + this.process = clear; + } + this.outputs[0][0] = this.inputs[0][0]; + }; + var clear = function() { + this.outputs[0][0] = 0; + }; + return ctor; + })(); + + cc.ugen.specs.Pause = { + $kr: { + defaults: "gate=0,id=0", + ctor: function(gate, id) { + return this.multiNew(1, gate, id); + } + } + }; + + cc.unit.specs.Pause = (function() { + var ctor = function() { + this.process = next; + this._state = 1; + this.outputs[0][0] = this.inputs[0][0]; + }; + var next = function() { + var _in = this.inputs[0][0]; + var state = (_in === 0) ? 0 : 1; + var id, node; + if (state !== this._state) { + this._state = state; + id = this.inputs[1][0]|0; + if (id) { // 0 is ignored + node = this.world.nodes[id]; + if (node) { + node.run(state); + } + } + } + this.outputs[0][0] = _in; + }; + return ctor; + })(); + + cc.ugen.specs.PauseSelf = { + $kr: { + defaults: "in=0", + ctor: function(_in) { + return this.multiNew(1, _in); + } + } + }; + + cc.unit.specs.PauseSelf = (function() { + var ctor = function() { + this.process = next; + this._prevtrig = 0; + this.process(1); + }; + var next = function() { + var _in = this.inputs[0][0]; + if (_in > 0 && this._prevtrig <= 0) { + this.parent.run(0); + } + this._prevtrig = _in; + this.outputs[0][0] = _in; + }; + return ctor; + })(); + + cc.ugen.specs.PauseSelfWhenDone = { + $kr: { + defaults: "src=0", + ctor: function(src) { + return this.multiNew(1, src); + } + } + }; + + cc.unit.specs.PauseSelfWhenDone = (function() { + var ctor = function() { + this.process = next; + this._src = this.fromUnits[0]; + this.process(1); + }; + var next = function() { + var src = this._src; + if (src && src.done) { + this.parent.run(0); + this.process = clear; + } + this.outputs[0][0] = this.inputs[0][0]; + }; + var clear = function() { + this.outputs[0][0] = 0; + }; + return ctor; + })(); + + cc.ugen.specs.Done = { + $kr: { + defaults: "src=0", + ctor: function(src) { + return this.multiNew(1, src); + } + } + }; + + cc.unit.specs.Done = (function() { + var ctor = function() { + this.process = next; + this._src = this.fromUnits[0]; + this.process(1); + }; + var next = function() { + var src = this._src; + this.outputs[0][0] = src && src.done ? 1 : 0; + }; + return ctor; + })(); + + + + module.exports = {}; + +}); +define('cc/plugins/filter', function(require, exports, module) { + + var cc = require("../cc"); + var log001 = Math.log(0.001); + var sqrt2 = Math.sqrt(2); + + var do_next_1 = function(unit, next) { + var tmp_floops = unit.rate.filterLoops; + var tmp_framain = unit.rate.filterRemain; + unit.rate.filterLoops = 0; + unit.rate.filterRemain = 1; + next.call(unit, 1); + unit.rate.filterLoops = tmp_floops; + unit.rate.filterRemain = tmp_framain; + }; + + cc.ugen.specs.Resonz = { + $ar: { + defaults: "in=0,freq=440,bwr=1,mul=1,add=0", + ctor: function(_in, freq, bwr, mul, add) { + return this.multiNew(2, _in, freq, bwr).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,freq=440,bwr=1,mul=1,add=0", + ctor: function(_in, freq, bwr, mul, add) { + return this.multiNew(1, _in, freq, bwr).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.Resonz = (function() { + var ctor = function() { + this.process = next; + this._a0 = 0; + this._b1 = 0; + this._b2 = 0; + this._y1 = 0; + this._y2 = 0; + this._freq = undefined; + this._rq = 0; + do_next_1(this, next); + }; + var next = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var freq = this.inputs[1][0]; + var rq = this.inputs[2][0]; + var y0; + var y1 = this._y1; + var y2 = this._y2; + var a0 = this._a0; + var b1 = this._b1; + var b2 = this._b2; + var rate = this.rate; + var i, j = 0; + if (freq !== this._freq || rq !== this._rq) { + var ffreq = freq * rate.radiansPerSample; + var B = ffreq * rq; + var R = 1 - B * 0.5; + var twoR = 2 * R; + var R2 = R * R; + var cost = (twoR * Math.cos(ffreq)) / (1 + R2); + var b1_next = twoR * cost; + var b2_next = -R2; + var a0_next = (1 - R2) * 0.5; + var filterSlope = rate.filterSlope; + var a0_slope = (a0_next - a0) * filterSlope; + var b1_slope = (b1_next - b1) * filterSlope; + var b2_slope = (b2_next - b2) * filterSlope; + for (i = rate.filterLoops; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; out[j++] = a0 * (y0 - y2); + y2 = inIn[j] + b1 * y0 + b2 * y1; out[j++] = a0 * (y2 - y1); + y1 = inIn[j] + b1 * y2 + b2 * y0; out[j++] = a0 * (y1 - y0); + a0 += a0_slope; + b1 += b1_slope; + b1 += b2_slope; + } + this._freq = freq; + this._rq = rq; + this._a0 = a0_next; + this._b1 = b1_next; + this._b2 = b2_next; + } else { + for (i = rate.filterLoops; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; out[j++] = a0 * (y0 - y2); + y2 = inIn[j] + b1 * y0 + b2 * y1; out[j++] = a0 * (y2 - y1); + y1 = inIn[j] + b1 * y2 + b2 * y0; out[j++] = a0 * (y1 - y0); + } + } + for (i = rate.filterRemain; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; out[j++] = a0 * (y0 - y2); + y2 = y1; + y1 = y0; + } + this._y1 = y1; + this._y2 = y2; + }; + return ctor; + })(); + + cc.ugen.specs.OnePole = { + $ar: { + defaults: "in=0,coef=0.5,mul=1,add=0", + ctor: function(_in, coef, mul, add) { + return this.multiNew(2, _in, coef).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,coef=0.5,mul=1,add=0", + ctor: function(_in, coef, mul, add) { + return this.multiNew(1, _in, coef).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.OnePole = (function() { + var ctor = function() { + this.process = next; + this._b1 = this.inputs[1][0]; + this._y1 = 0; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var b1 = this._b1; + var y1 = this._y1; + var next_b1 = Math.max(-1, Math.min(this.inputs[1][0], 1)); + var y0, i; + if (b1 !== next_b1) { + var b1_slope = (next_b1 - b1) * this.rate.slopeFactor; + if (b1 > 0 && next_b1 >= 0) { + for (i = 0; i < inNumSamples; ++i) { + y0 = inIn[i]; out[i] = y1 = y0 + b1 * (y1 - y0); + b1 += b1_slope; + } + } else if (b1 <= 0 && next_b1 <= 0) { + for (i = 0; i < inNumSamples; ++i) { + y0 = inIn[i]; out[i] = y1 = y0 + b1 * (y1 + y0); + b1 += b1_slope; + } + } else { + for (i = 0; i < inNumSamples; ++i) { + y0 = inIn[i]; out[i] = y1 = (1 - Math.abs(b1)) * y0 + b1 * y1; + b1 += b1_slope; + } + } + this._b1 = next_b1; + } else { + if (b1 >= 0) { + for (i = 0; i < inNumSamples; ++i) { + y0 = inIn[i]; out[i] = y1 = y0 + b1 * (y1 - y0); + } + } else { + for (i = 0; i < inNumSamples; ++i) { + y0 = inIn[i]; out[i] = y1 = y0 + b1 * (y1 + y0); + } + } + } + this._y1 = y1; + }; + return ctor; + })(); + + cc.ugen.specs.OneZero = cc.ugen.specs.OnePole; + + cc.unit.specs.OneZero = (function() { + var ctor = function() { + this.process = next; + this._b1 = this.inputs[1][0]; + this._x1 = this.inputs[0][0]; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var b1 = this._b1; + var x1 = this._x1; + var next_b1 = Math.max(-1, Math.min(this.inputs[1][0], 1)); + var x0, i; + if (b1 !== next_b1) { + var b1_slope = (next_b1 - b1) * this.rate.slopeFactor; + if (b1 >= 0 && next_b1 >= 0) { + for (i = 0; i < inNumSamples; ++i) { + x0 = inIn[i]; out[i] = x0 + b1 * (x1 - x0); + x1 = x0; + b1 += b1_slope; + } + } else if (b1 <= 0 && next_b1 <= 0) { + for (i = 0; i < inNumSamples; ++i) { + x0 = inIn[i]; out[i] = x0 + b1 * (x1 + x0); + x1 = x0; + b1 += b1_slope; + } + } else { + for (i = 0; i < inNumSamples; ++i) { + x0 = inIn[i]; out[i] = (1 - Math.abs(b1)) * x0 + b1 * x1; + x1 = x0; + b1 += b1_slope; + } + } + this._b1 = next_b1; + } else { + if (b1 >= 0) { + for (i = 0; i < inNumSamples; ++i) { + x0 = inIn[i]; out[i] = x0 + b1 * (x1 - x0); + x1 = x0; + } + } else { + for (i = 0; i < inNumSamples; ++i) { + x0 = inIn[i]; out[i] = x0 + b1 * (x1 + x0); + x1 = x0; + } + } + } + this._x1 = x1; + }; + return ctor; + })(); + + cc.ugen.specs.TwoPole = { + $ar: { + defaults: "in=0,freq=440,radius=0.8,mul=1,add=0", + ctor: function(_in, freq, radius, mul, add) { + return this.multiNew(2, _in, freq, radius).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,freq=440,radius=0.8,mul=1,add=0", + ctor: function(_in, freq, radius, mul, add) { + return this.multiNew(1, _in, freq, radius).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.TwoPole = (function() { + var ctor = function() { + this.process = next; + this._b1 = 0; + this._b2 = 0; + this._y1 = 0; + this._y2 = 0; + this._freq = undefined; + this._reson = undefined; + do_next_1(this, next); + }; + var next = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var freq = this.inputs[1][0]; + var reson = Math.max(0, Math.min(this.inputs[2][0], 1)); + var y0; + var y1 = this._y1; + var y2 = this._y2; + var b1 = this._b1; + var b2 = this._b2; + var rate = this.rate; + var i, j = 0; + if (freq !== this._freq || reson !== this._reson) { + var b1_next = 2 * reson * Math.cos(freq * rate.radiansPerSample); + var b2_next = -(reson * reson); + var b1_slope = (b1_next - b1) * rate.filterSlope; + var b2_slope = (b2_next - b2) * rate.filterSlope; + for (i = rate.filterLoops; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; out[j++] = y0; + y2 = inIn[j] + b1 * y0 + b2 * y1; out[j++] = y2; + y1 = inIn[j] + b1 * y2 + b2 * y0; out[j++] = y1; + b1 += b1_slope; + b2 += b2_slope; + } + this._freq = freq; + this._reson = reson; + this._b1 = b1_next; + this._b2 = b2_next; + } else { + for (i = rate.filterLoops; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; out[j++] = y0; + y2 = inIn[j] + b1 * y0 + b2 * y1; out[j++] = y2; + y1 = inIn[j] + b1 * y2 + b2 * y0; out[j++] = y1; + } + } + for (i = rate.filterRemain; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; out[j++] = y0; + y2 = y1; + y1 = y0; + } + this._y1 = y1; + this._y2 = y2; + }; + return ctor; + })(); + + cc.ugen.specs.TwoZero = cc.ugen.specs.TwoPole; + + cc.unit.specs.TwoZero = (function() { + var ctor = function() { + this.process = next; + this._b1 = 0; + this._b2 = 0; + this._x1 = 0; + this._x2 = 0; + this._freq = undefined; + this._reson = undefined; + do_next_1(this, next); + }; + var next = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var freq = this.inputs[1][0]; + var reson = Math.max(0, Math.min(this.inputs[2][0], 1)); + var x0; + var b1 = this._b1; + var b2 = this._b2; + var x1 = this._x1; + var x2 = this._x2; + var rate = this.rate; + var i, j = 0; + if (freq !== this._freq || reson !== this._reson) { + var b1_next = -2 * reson * Math.cos(freq * rate.radiansPerSample); + var b2_next = (reson * reson); + var b1_slope = (b1_next - b1) * rate.filterSlope; + var b2_slope = (b2_next - b2) * rate.filterSlope; + for (i = rate.filterLoops; i--; ) { + x0 = inIn[j]; out[j++] = x0 + b1 * x1 + b2 * x2; + x2 = inIn[j]; out[j++] = x2 + b1 * x0 + b2 * x1; + x1 = inIn[j]; out[j++] = x1 + b1 * x2 + b2 * x0; + b1 += b1_slope; + b2 += b2_slope; + } + this._freq = freq; + this._reson = reson; + this._b1 = b1_next; + this._b2 = b2_next; + } else { + for (i = rate.filterLoops; i--; ) { + x0 = inIn[j]; out[j++] = x0 + b1 * x1 + b2 * x2; + x2 = inIn[j]; out[j++] = x2 + b1 * x0 + b2 * x1; + x1 = inIn[j]; out[j++] = x1 + b1 * x2 + b2 * x0; + } + } + for (i = rate.filterRemain; i--; ) { + x0 = inIn[j]; out[j++] = x0 + b1 * x1 + b2 * x2; + x2 = x1; + x1 = x0; + } + this._x1 = x1; + this._x2 = x2; + }; + return ctor; + })(); + + cc.ugen.specs.APF = { + $ar: { + defaults: "in=0,freq=440,radius=0.8,mul=1,add=0", + ctor: function(_in, freq, radius, mul, add) { + return this.multiNew(2, _in, freq, radius).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,freq=440,radius=0.8,mul=1,add=0", + ctor: function(_in, freq, radius, mul, add) { + return this.multiNew(1, _in, freq, radius).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.APF = (function() { + var ctor = function() { + this.process = next; + this._b1 = 0; + this._b2 = 0; + this._y1 = 0; + this._y2 = 0; + this._x1 = 0; + this._x2 = 0; + this._freq = undefined; + this._reson = undefined; + do_next_1(this, next); + }; + var next = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var freq = this.inputs[1][0]; + var reson = Math.max(0, Math.min(this.inputs[2][0], 1)); + var x0; + var y0; + var y1 = this._y1; + var y2 = this._y2; + var x1 = this._x1; + var x2 = this._x2; + var b1 = this._b1; + var b2 = this._b2; + var rate = this.rate; + var i, j = 0; + if (freq !== this._freq && reson !== this._reson) { + var b1_next = 2 * reson * Math.cos(freq * rate.radiansPerSample); + var b2_next = -(reson * reson); + var b1_slope = (b1_next - b1) * rate.filterSlope; + var b2_slope = (b2_next - b2) * rate.filterSlope; + for (i = rate.filterLoops; i--; ) { + x0 = inIn[j]; out[j++] = y0 = x0 + b1 * (y1 - x1) + b2 * (y2 - x2); + x1 = inIn[j]; out[j++] = y2 = x2 + b1 * (y0 - x0) + b2 * (y2 - x1); + x2 = inIn[j]; out[j++] = y1 = x1 + b1 * (y2 - x2) + b2 * (y2 - x0); + b1 += b1_slope; + b2 += b2_slope; + } + this._freq = freq; + this._reson = reson; + this._b1 = b1_next; + this._b2 = b2_next; + } else { + for (i = rate.filterLoops; i--; ) { + x0 = inIn[j]; out[j++] = y0 = x0 + b1 * (y1 - x1) + b2 * (y2 - x2); + x1 = inIn[j]; out[j++] = y2 = x2 + b1 * (y0 - x0) + b2 * (y2 - x1); + x2 = inIn[j]; out[j++] = y1 = x1 + b1 * (y2 - x2) + b2 * (y2 - x0); + } + } + for (i = rate.filterRemain; i--; ) { + x0 = inIn[j]; out[j++] = y0 = x0 + b1 * (y1 - x1) + b2 * (y2 - x2); + y2 = y1; + y1 = y0; + x2 = x1; + x1 = x0; + } + this._y1 = y1; + this._y2 = y2; + this._x1 = x1; + this._x2 = x2; + }; + return ctor; + })(); + + cc.ugen.specs.LPF = { + $ar: { + defaults: "in=0,freq=440,mul=1,add=0", + ctor: function(_in, freq, mul, add) { + return this.multiNew(2, _in, freq).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,freq=440,mul=1,add=0", + ctor: function(_in, freq, mul, add) { + return this.multiNew(1, _in, freq).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.LPF = (function() { + var ctor = function() { + this.process = next; + this._a0 = 0; + this._b1 = 0; + this._b2 = 0; + this._y1 = 0; + this._y2 = 0; + this._freq = undefined; + do_next_1(this, next); + }; + var next = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var freq = Math.max(0.001, this.inputs[1][0]); + var y0; + var y1 = this._y1; + var y2 = this._y2; + var a0 = this._a0; + var b1 = this._b1; + var b2 = this._b2; + var rate = this.rate; + var i, j = 0; + if (freq !== this._freq) { + var pfreq = freq * rate.radiansPerSample * 0.5; + var C = 1 / Math.tan(pfreq); + var C2 = C * C; + var sqrt2C = C * sqrt2; + var next_a0 = 1 / (1 + sqrt2C + C2); + var next_b1 = -2 * (1 - C2) * next_a0; + var next_b2 = -(1 - sqrt2C + C2) * next_a0; + var a0_slope = (next_a0 - a0) * rate.filterSlope; + var b1_slope = (next_b1 - b1) * rate.filterSlope; + var b2_slope = (next_b2 - b2) * rate.filterSlope; + for (i = rate.filterLoops; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; out[j++] = a0 * (y0 + 2 * y1 + y2); + y2 = inIn[j] + b1 * y0 + b2 * y1; out[j++] = a0 * (y2 + 2 * y0 + y1); + y1 = inIn[j] + b1 * y2 + b2 * y0; out[j++] = a0 * (y1 + 2 * y2 + y0); + a0 += a0_slope; + b1 += b1_slope; + b2 += b2_slope; + } + this._freq = freq; + this._a0 = next_a0; + this._b1 = next_b1; + this._b2 = next_b2; + } else { + for (i = rate.filterLoops; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; out[j++] = a0 * (y0 + 2 * y1 + y2); + y2 = inIn[j] + b1 * y0 + b2 * y1; out[j++] = a0 * (y2 + 2 * y0 + y1); + y1 = inIn[j] + b1 * y2 + b2 * y0; out[j++] = a0 * (y1 + 2 * y2 + y0); + } + } + for (i = rate.filterRemain; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; out[j++] = a0 * (y0 + 2 * y1 + y2); + y2 = y1; + y1 = y0; + } + this._y1 = y1; + this._y2 = y2; + }; + return ctor; + })(); + + cc.ugen.specs.HPF = cc.ugen.specs.LPF; + + cc.unit.specs.HPF = (function() { + var ctor = function() { + this.process = next; + this._a0 = 0; + this._b1 = 0; + this._b2 = 0; + this._y1 = 0; + this._y2 = 0; + this._freq = undefined; + do_next_1(this, next); + }; + var next = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var freq = this.inputs[1][0]; + var y0; + var y1 = this._y1; + var y2 = this._y2; + var a0 = this._a0; + var b1 = this._b1; + var b2 = this._b2; + var rate = this.rate; + var i, j = 0; + if (freq !== this._freq) { + var pfreq = freq * rate.radiansPerSample * 0.5; + var C = Math.tan(pfreq); + var C2 = C * C; + var sqrt2C = C * sqrt2; + var next_a0 = 1 / (1 + sqrt2C + C2); + var next_b1 = 2 * (1 - C2) * next_a0; + var next_b2 = -(1 - sqrt2C + C2) * next_a0; + var a0_slope = (next_a0 - a0) * rate.filterSlope; + var b1_slope = (next_b1 - b1) * rate.filterSlope; + var b2_slope = (next_b2 - b2) * rate.filterSlope; + for (i = rate.filterLoops; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; out[j++] = a0 * (y0 - 2 * y1 + y2); + y2 = inIn[j] + b1 * y0 + b2 * y1; out[j++] = a0 * (y2 - 2 * y0 + y1); + y1 = inIn[j] + b1 * y2 + b2 * y0; out[j++] = a0 * (y1 - 2 * y2 + y0); + a0 += a0_slope; + b1 += b1_slope; + b2 += b2_slope; + } + this._freq = freq; + this._a0 = next_a0; + this._b1 = next_b1; + this._b2 = next_b2; + } else { + for (i = rate.filterLoops; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; out[j++] = a0 * (y0 - 2 * y1 + y2); + y2 = inIn[j] + b1 * y0 + b2 * y1; out[j++] = a0 * (y2 - 2 * y0 + y1); + y1 = inIn[j] + b1 * y2 + b2 * y0; out[j++] = a0 * (y1 - 2 * y2 + y0); + } + } + for (i = rate.filterRemain; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; out[j++] = a0 * (y0 - 2 * y1 + y2); + y2 = y1; + y1 = y0; + } + this._y1 = y1; + this._y2 = y2; + }; + return ctor; + })(); + + cc.ugen.specs.BPF = { + $ar: { + defaults: "in=0,freq=440,rq=1,mul=1,add=0", + ctor: function(_in, freq, rq, mul, add) { + return this.multiNew(2, _in, freq, rq).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,freq=440,rq=1,mul=1,add=0", + ctor: function(_in, freq, rq, mul, add) { + return this.multiNew(1, _in, freq, rq).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.BPF = (function() { + var ctor = function() { + this.process = next; + this._a0 = 0; + this._b1 = 0; + this._b2 = 0; + this._y1 = 0; + this._y2 = 0; + this._freq = undefined; + this._bw = undefined; + do_next_1(this, next); + }; + var next = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var freq = this.inputs[1][0]; + var bw = this.inputs[2][0]; + var y0; + var y1 = this._y1; + var y2 = this._y2; + var a0 = this._a0; + var b1 = this._b1; + var b2 = this._b2; + var rate = this.rate; + var i, j = 0; + if (freq !== this._freq || bw !== this._bw) { + var pfreq = freq * rate.radiansPerSample; + var pbw = bw * pfreq * 0.5; + var C = pbw ? 1 / Math.tan(pbw) : 0; + var D = 2 * Math.cos(pfreq); + var next_a0 = 1 / (1 + C); + var next_b1 = C * D * next_a0; + var next_b2 = (1 - C) * next_a0; + var a0_slope = (next_a0 - a0) * rate.filterSlope; + var b1_slope = (next_b1 - b1) * rate.filterSlope; + var b2_slope = (next_b2 - b2) * rate.filterSlope; + for (i = rate.filterLoops; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; out[j++] = a0 * (y0 - y2); + y2 = inIn[j] + b1 * y0 + b2 * y1; out[j++] = a0 * (y2 - y1); + y1 = inIn[j] + b1 * y2 + b2 * y0; out[j++] = a0 * (y1 - y0); + a0 += a0_slope; + b1 += b1_slope; + b2 += b2_slope; + } + this._freq = freq; + this._bw = bw; + this._a0 = next_a0; + this._b1 = next_b1; + this._b2 = next_b2; + } else { + for (i = rate.filterLoops; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; out[j++] = a0 * (y0 - y2); + y2 = inIn[j] + b1 * y0 + b2 * y1; out[j++] = a0 * (y2 - y1); + y1 = inIn[j] + b1 * y2 + b2 * y0; out[j++] = a0 * (y1 - y0); + } + } + for (i = rate.filterRemain; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; out[j++] = a0 * (y0 - y2); + y2 = y1; + y1 = y0; + } + this._y1 = y1; + this._y2 = y2; + }; + return ctor; + })(); + + cc.ugen.specs.BRF = cc.ugen.specs.BPF; + + cc.unit.specs.BRF = (function() { + var ctor = function() { + this.process = next; + this._a0 = 0; + this._a1 = 0; + this._b2 = 0; + this._y1 = 0; + this._y2 = 0; + this._freq = undefined; + this._bw = undefined; + do_next_1(this, next); + }; + var next = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var freq = this.inputs[1][0]; + var bw = this.inputs[2][0]; + var ay; + var y0; + var y1 = this._y1; + var y2 = this._y2; + var a0 = this._a0; + var a1 = this._a1; + var b2 = this._b2; + var rate = this.rate; + var i, j = 0; + if (freq !== this._freq || bw !== this._bw) { + var pfreq = freq * rate.radiansPerSample; + var pbw = bw * pfreq * 0.5; + var C = Math.tan(pbw); + var D = 2 * Math.cos(pfreq); + var next_a0 = 1 / (1 + C); + var next_a1 = -D * next_a0; + var next_b2 = (1 - C) * next_a0; + var a0_slope = (next_a0 - a0) * rate.filterSlope; + var a1_slope = (next_a1 - a1) * rate.filterSlope; + var b2_slope = (next_b2 - b2) * rate.filterSlope; + for (i = rate.filterLoops; i--; ) { + ay = a1 * y1; y0 = inIn[j] - ay - b2 * y2; out[j++] = a0 * (y0 + y2) + ay; + ay = a1 * y0; y2 = inIn[j] - ay - b2 * y1; out[j++] = a0 * (y2 + y1) + ay; + ay = a1 * y2; y1 = inIn[j] - ay - b2 * y0; out[j++] = a0 * (y1 + y0) + ay; + a0 += a0_slope; + a1 += a1_slope; + b2 += b2_slope; + } + this._freq = freq; + this._bw = bw; + this._a0 = next_a0; + this._a1 = next_a1; + this._b2 = next_b2; + } else { + for (i = rate.filterLoops; i--; ) { + ay = a1 * y1; y0 = inIn[j] - ay - b2 * y2; out[j++] = a0 * (y0 + y2) + ay; + ay = a1 * y0; y2 = inIn[j] - ay - b2 * y1; out[j++] = a0 * (y2 + y1) + ay; + ay = a1 * y2; y1 = inIn[j] - ay - b2 * y0; out[j++] = a0 * (y1 + y0) + ay; + } + } + for (i = rate.filterRemain; i--; ) { + ay = a1 * y1; y0 = inIn[j] - ay - b2 * y2; out[j++] = a0 * (y0 + y2) + ay; + y2 = y1; + y1 = y0; + } + this._y1 = y1; + this._y2 = y2; + }; + return ctor; + })(); + + cc.ugen.specs.LeakDC = { + $ar: { + defaults: "in=0,coef=0.995,mul=1,add=0", + ctor: function(_in, coef, mul, add) { + return this.multiNew(2, _in, coef).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,coef=0.995,mul=1,add=0", + ctor: function(_in, coef, mul, add) { + return this.multiNew(1, _in, coef).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.LeakDC = (function() { + var ctor = function() { + if (this.bufLength === 1) { + this.process = next_1; + } else { + if (this.inRates[1] === 0) { + this.process = next_i; + } else { + this.process = next; + } + } + this._b1 = 0; + this._x1 = this.inputs[0][0]; + this._y1 = 0; + next_1.call(this, 1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var _in = this.inputs[0]; + var b1 = this._b1; + var b1_next = this.inputs[1][0]; + var y1 = this._y1; + var x1 = this._x1; + var x0, b1_slope; + var i; + + if (b1 === b1_next) { + for (i = 0; i < inNumSamples; ++i) { + x0 = _in[i]; + out[i] = y1 = x0 - x1 + b1 * y1; + x1 = x0; + } + } else { + b1_slope = (b1_next - b1) * this.rate.filterSlope; + for (i = 0; i < inNumSamples; ++i) { + x0 = _in[i]; + out[i] = y1 = x0 - x1 + b1 * y1; + x1 = x0; + b1 += b1_slope; + } + this._b1 = b1_next; + } + this._x1 = x1; + this._y1 = y1; + }; + var next_i = function(inNumSamples) { + var out = this.outputs[0]; + var _in = this.inputs[0]; + var b1 = this._b1; + var y1 = this._y1; + var x1 = this._x1; + var x0; + for (var i = 0; i < inNumSamples; ++i) { + x0 = _in[i]; + out[i] = y1 = x0 - x1 + b1 * y1; + x1 = x0; + } + this._x1 = x1; + this._y1 = y1; + }; + var next_1 = function() { + var b1 = this._b1 = this.inputs[1][0]; + var y1 = this._y1; + var x1 = this._x1; + var x0 = this.inputs[0][0]; + this.outputs[0][0] = y1 = x0 - x1 + b1 * y1; + x1 = x0; + this._x1 = x1; + this._y1 = y1; + }; + return ctor; + })(); + + cc.ugen.specs.RLPF = { + $ar: { + defaults: "in=0,freq=440,rq=1,mul=1,add=0", + ctor: function(_in, freq, rq, mul, add) { + return this.multiNew(2, _in, freq, rq).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,freq=440,rq=1,mul=1,add=0", + ctor: function(_in, freq, rq, mul, add) { + return this.multiNew(1, _in, freq, rq).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.RLPF = (function() { + var ctor = function() { + this.process = next; + this._a0 = 0; + this._b1 = 0; + this._b2 = 0; + this._y1 = 0; + this._y2 = 0; + this._freq = undefined; + this._reson = undefined; + do_next_1(this, next); + }; + var next = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var freq = this.inputs[1][0]; + var reson = this.inputs[2][0]; + var y0; + var y1 = this._y1; + var y2 = this._y2; + var a0 = this._a0; + var b1 = this._b1; + var b2 = this._b2; + var rate = this.rate; + var i, j = 0; + if (freq !== this._freq || reson !== this._reson) { + var qres = Math.max(0.001, reson); + var pfreq = freq * rate.radiansPerSample; + var D = Math.tan(pfreq * qres * 0.5); + var C = ((1.0-D)/(1.0+D)); + var cosf = Math.cos(pfreq); + var next_b1 = (1.0 + C) * cosf; + var next_b2 = -C; + var next_a0 = (1.0 + C - next_b1) * 0.25; + var a0_slope = (next_a0 - a0) * rate.filterSlope; + var b1_slope = (next_b1 - b1) * rate.filterSlope; + var b2_slope = (next_b2 - b2) * rate.filterSlope; + for (i = rate.filterLoops; i--; ) { + y0 = a0 * inIn[j] + b1 * y1 + b2 * y2; out[j++] = y0 + 2.0 * y1 + y2; + y2 = a0 * inIn[j] + b1 * y0 + b2 * y1; out[j++] = y2 + 2.0 * y0 + y1; + y1 = a0 * inIn[j] + b1 * y2 + b2 * y0; out[j++] = y1 + 2.0 * y2 + y0; + a0 += a0_slope; + b1 += b1_slope; + b2 += b2_slope; + } + this._freq = freq; + this._reson = reson; + this._a0 = next_a0; + this._b1 = next_b1; + this._b2 = next_b2; + } else { + for (i = rate.filterLoops; i--; ) { + y0 = a0 * inIn[j] + b1 * y1 + b2 * y2; out[j++] = y0 + 2.0 * y1 + y2; + y2 = a0 * inIn[j] + b1 * y0 + b2 * y1; out[j++] = y2 + 2.0 * y0 + y1; + y1 = a0 * inIn[j] + b1 * y2 + b2 * y0; out[j++] = y1 + 2.0 * y2 + y0; + } + } + for (i = rate.filterRemain; i--; ) { + y0 = a0 * inIn[j] + b1 * y1 + b2 * y2; + out[j++] = y0 + 2.0 * y1 + y2; + y2 = y1; y1 = y0; + } + this._y1 = y1; + this._y2 = y2; + }; + return ctor; + })(); + + cc.ugen.specs.RHPF = cc.ugen.specs.RLPF; + + cc.unit.specs.RHPF = (function() { + var ctor = function() { + this.process = next; + this._a0 = 0; + this._b1 = 0; + this._b2 = 0; + this._y1 = 0; + this._y2 = 0; + this._freq = undefined; + this._reson = undefined; + do_next_1(this, next); + }; + var next = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var freq = this.inputs[1][0]; + var reson = this.inputs[2][0]; + var y0; + var y1 = this._y1; + var y2 = this._y2; + var a0 = this._a0; + var b1 = this._b1; + var b2 = this._b2; + var rate = this.rate; + var i, j = 0; + if (freq !== this._freq || reson !== this._reson) { + var qres = Math.max(0.001, reson); + var pfreq = freq * rate.radiansPerSample; + var D = Math.tan(pfreq * qres * 0.5); + var C = ((1.0-D)/(1.0+D)); + var cosf = Math.cos(pfreq); + var next_b1 = (1.0 + C) * cosf; + var next_b2 = -C; + var next_a0 = (1.0 + C + next_b1) * 0.25; + var a0_slope = (next_a0 - a0) * rate.filterSlope; + var b1_slope = (next_b1 - b1) * rate.filterSlope; + var b2_slope = (next_b2 - b2) * rate.filterSlope; + for (i = rate.filterLoops; i--; ) { + y0 = a0 * inIn[j] + b1 * y1 + b2 * y2; out[j++] = y0 - 2.0 * y1 + y2; + y2 = a0 * inIn[j] + b1 * y0 + b2 * y1; out[j++] = y2 - 2.0 * y0 + y1; + y1 = a0 * inIn[j] + b1 * y2 + b2 * y0; out[j++] = y1 - 2.0 * y2 + y0; + a0 += a0_slope; + b1 += b1_slope; + b2 += b2_slope; + } + this._freq = freq; + this._reson = reson; + this._a0 = next_a0; + this._b1 = next_b1; + this._b2 = next_b2; + } else { + for (i = rate.filterLoops; i--; ) { + y0 = a0 * inIn[j] + b1 * y1 + b2 * y2; out[j++] = y0 - 2.0 * y1 + y2; + y2 = a0 * inIn[j] + b1 * y0 + b2 * y1; out[j++] = y2 - 2.0 * y0 + y1; + y1 = a0 * inIn[j] + b1 * y2 + b2 * y0; out[j++] = y1 - 2.0 * y2 + y0; + } + } + for (i = rate.filterRemain; i--; ) { + y0 = a0 * inIn[j] + b1 * y1 + b2 * y2; out[j++] = y0 - 2.0 * y1 + y2; + + y2 = y1; y1 = y0; + } + this._y1 = y1; + this._y2 = y2; + }; + return ctor; + })(); + + cc.ugen.specs.MidEQ = { + $ar: { + defaults: "in=0,freq=440,rq=1,db=0,mul=1,add=0", + ctor: function(_in, freq, rq, db, mul, add) { + return this.multiNew(2, _in, freq, rq, db).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,freq=440,rq=1,db=0,mul=1,add=0", + ctor: function(_in, freq, rq, db, mul, add) { + return this.multiNew(1, _in, freq, rq, db).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.MidEQ = (function() { + var ctor = function() { + this.process = next; + this._a0 = 0; + this._b1 = 0; + this._b2 = 0; + this._y1 = 0; + this._y2 = 0; + this._freq = undefined; + this._bw = undefined; + this._db = undefined; + do_next_1(this, next); + }; + var next = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var freq = this.inputs[1][0]; + var bw = this.inputs[2][0]; + var db = this.inputs[3][0]; + var y0, zin; + var y1 = this._y1; + var y2 = this._y2; + var a0 = this._a0; + var b1 = this._b1; + var b2 = this._b2; + var rate = this.rate; + var i, j = 0; + if (freq !== this._freq || bw !== this._bw || db !== this._db) { + var amp = Math.pow(10, db * 0.05) - 1; + var pfreq = freq * rate.radiansPerSample; + var pbw = bw * pfreq * 0.5; + var C = pbw ? 1 / Math.tan(pbw) : 0; + var D = 2 * Math.cos(pfreq); + var next_a0 = 1 / (1 + C); + var next_b1 = C * D * next_a0; + var next_b2 = (1 - C) * next_a0; + next_a0 *= amp; + var a0_slope = (next_a0 - a0) * rate.filterSlope; + var b1_slope = (next_b1 - b1) * rate.filterSlope; + var b2_slope = (next_b2 - b2) * rate.filterSlope; + for (i = rate.filterLoops; i--; ) { + zin = inIn[j]; y0 = zin + b1 * y1 + b2 * y2; out[j++] = zin + a0 * (y0 - y2); + zin = inIn[j]; y2 = zin + b1 * y0 + b2 * y1; out[j++] = zin + a0 * (y2 - y1); + zin = inIn[j]; y1 = zin + b1 * y2 + b2 * y0; out[j++] = zin + a0 * (y1 - y0); + a0 += a0_slope; + b1 += b1_slope; + b2 += b2_slope; + } + this._freq = freq; + this._bw = bw; + this._db = db; + this._a0 = next_a0; + this._b1 = next_b1; + this._b2 = next_b2; + } else { + for (i = rate.filterLoops; i--; ) { + zin = inIn[j]; y0 = zin + b1 * y1 + b2 * y2; out[j++] = zin + a0 * (y0 - y2); + zin = inIn[j]; y2 = zin + b1 * y0 + b2 * y1; out[j++] = zin + a0 * (y2 - y1); + zin = inIn[j]; y1 = zin + b1 * y2 + b2 * y0; out[j++] = zin + a0 * (y1 - y0); + } + } + for (i = rate.filterRemain; i--; ) { + zin = inIn[j]; + y0 = zin + b1 * y1 + b2 * y2; + out[j++] = zin + a0 * (y0 - y2); + y2 = y1; + y1 = y0; + } + this._y1 = y1; + this._y2 = y2; + }; + return ctor; + })(); + + cc.ugen.specs.LPZ1 = { + $ar: { + defaults: "in=0,mul=1,add=0", + ctor: function(_in, mul, add) { + return this.multiNew(2, _in).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,mul=1,add=0", + ctor: function(_in, mul, add) { + return this.multiNew(1, _in).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.LPZ1 = (function() { + var ctor = function() { + this.process = next; + this._x1 = this.inputs[0][0]; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var x0, x1 = this._x1; + var i, j = 0; + for (i = inNumSamples >> 3; i--; ) { + x0 = inIn[j]; out[j++] = 0.5 * (x0 + x1); + x1 = inIn[j]; out[j++] = 0.5 * (x1 + x0); + x0 = inIn[j]; out[j++] = 0.5 * (x0 + x1); + x1 = inIn[j]; out[j++] = 0.5 * (x1 + x0); + x0 = inIn[j]; out[j++] = 0.5 * (x0 + x1); + x1 = inIn[j]; out[j++] = 0.5 * (x1 + x0); + x0 = inIn[j]; out[j++] = 0.5 * (x0 + x1); + x1 = inIn[j]; out[j++] = 0.5 * (x1 + x0); + } + for (i = inNumSamples & 3; i--; ) { + x0 = inIn[j]; + out[j++] = 0.5 * (x0 + x1); + x1 = x0; + } + this._x1 = x1; + }; + return ctor; + })(); + + cc.ugen.specs.HPZ1 = cc.ugen.specs.LPZ1; + + cc.unit.specs.HPZ1 = (function() { + var ctor = function() { + this.process = next; + this._x1 = this.inputs[0][0]; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var x0, x1 = this._x1; + var i, j = 0; + for (i = inNumSamples >> 3; i--; ) { + x0 = inIn[j]; out[j++] = 0.5 * (x0 - x1); + x1 = inIn[j]; out[j++] = 0.5 * (x1 - x0); + x0 = inIn[j]; out[j++] = 0.5 * (x0 - x1); + x1 = inIn[j]; out[j++] = 0.5 * (x1 - x0); + x0 = inIn[j]; out[j++] = 0.5 * (x0 - x1); + x1 = inIn[j]; out[j++] = 0.5 * (x1 - x0); + x0 = inIn[j]; out[j++] = 0.5 * (x0 - x1); + x1 = inIn[j]; out[j++] = 0.5 * (x1 - x0); + } + for (i = inNumSamples & 3; i--; ) { + x0 = inIn[j]; + out[j++] = 0.5 * (x0 - x1); + x1 = x0; + } + this._x1 = x1; + }; + return ctor; + })(); + + cc.ugen.specs.Slope = cc.ugen.specs.LPZ1; + + cc.unit.specs.Slope = (function() { + var ctor = function() { + this.process = next; + this._x1 = this.inputs[0][0]; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var x0, x1 = this._x1; + var sr = this.rate.sampleRate; + var i, j = 0; + for (i = inNumSamples >> 3; i--; ) { + x0 = inIn[i]; out[j++] = sr * (x0 - x1); + x1 = inIn[i]; out[j++] = sr * (x1 - x0); + x0 = inIn[i]; out[j++] = sr * (x0 - x1); + x1 = inIn[i]; out[j++] = sr * (x1 - x0); + x0 = inIn[i]; out[j++] = sr * (x0 - x1); + x1 = inIn[i]; out[j++] = sr * (x1 - x0); + x0 = inIn[i]; out[j++] = sr * (x0 - x1); + x1 = inIn[i]; out[j++] = sr * (x1 - x0); + } + for (i = inNumSamples & 3; i--; ) { + x0 = inIn[j]; + out[j++] = sr * (x0 - x1); + x1 = x0; + } + this._x1 = x1; + }; + return ctor; + })(); + + cc.ugen.specs.LPZ2 = cc.ugen.specs.LPZ1; + + cc.unit.specs.LPZ2 = (function() { + var ctor = function() { + this.process = next; + this._x1 = this._x2 = this.inputs[0][0]; + do_next_1(this, next); + }; + var next = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var x0, x1 = this._x1, x2 = this._x2; + var rate = this.rate; + var i, j = 0; + for (i = rate.filterLoops; i--; ) { + x0 = inIn[j]; out[j++] = (x0 + 2 * x1 + x2) * 0.25; + x2 = inIn[j]; out[j++] = (x2 + 2 * x0 + x1) * 0.25; + x1 = inIn[j]; out[j++] = (x1 + 2 * x2 + x0) * 0.25; + } + for (i = rate.filterRemain; i--; ) { + x0 = inIn[j]; + out[j++] = (x0 + 2 * x1 + x2) * 0.25; + x2 = x1; + x1 = x0; + } + this._x1 = x1; + this._x2 = x2; + }; + return ctor; + })(); + + cc.ugen.specs.HPZ2 = cc.ugen.specs.LPZ1; + + cc.unit.specs.HPZ2 = (function() { + var ctor = function() { + this.process = next; + this._x1 = this._x2 = this.inputs[0][0]; + do_next_1(this, next); + }; + var next = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var x0, x1 = this._x1, x2 = this._x2; + var rate = this.rate; + var i, j = 0; + for (i = rate.filterLoops; i--; ) { + x0 = inIn[j]; out[j++] = (x0 - 2 * x1 + x2) * 0.25; + x2 = inIn[j]; out[j++] = (x2 - 2 * x0 + x1) * 0.25; + x1 = inIn[j]; out[j++] = (x1 - 2 * x2 + x0) * 0.25; + } + for (i = rate.filterRemain; i--; ) { + x0 = inIn[j]; + out[j++] = (x0 - 2 * x1 + x2) * 0.25; + x2 = x1; + x1 = x0; + } + this._x1 = x1; + this._x2 = x2; + }; + return ctor; + })(); + + cc.ugen.specs.BPZ2 = cc.ugen.specs.LPZ1; + + cc.unit.specs.BPZ2 = (function() { + var ctor = function() { + this.process = next; + this._x1 = this._x2 = this.inputs[0][0]; + do_next_1(this, next); + }; + var next = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var x0, x1 = this._x1, x2 = this._x2; + var rate = this.rate; + var i, j = 0; + for (i = rate.filterLoops; i--; ) { + x0 = inIn[j]; out[j++] = (x0 - x2) * 0.5; + x2 = inIn[j]; out[j++] = (x2 - x1) * 0.5; + x1 = inIn[j]; out[j++] = (x1 - x0) * 0.5; + } + for (i = rate.filterRemain; i--; ) { + x0 = inIn[j]; + out[j++] = (x0 - x2) * 0.25; + x2 = x1; + x1 = x0; + } + this._x1 = x1; + this._x2 = x2; + }; + return ctor; + })(); + + cc.ugen.specs.BRZ2 = cc.ugen.specs.LPZ1; + + cc.unit.specs.BRZ2 = (function() { + var ctor = function() { + this.process = next; + this._x1 = this._x2 = this.inputs[0][0]; + do_next_1(this, next); + }; + var next = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var x0, x1 = this._x1, x2 = this._x2; + var rate = this.rate; + var i, j = 0; + for (i = rate.filterLoops; i--; ) { + x0 = inIn[j]; out[j++] = (x0 + x2) * 0.5; + x2 = inIn[j]; out[j++] = (x2 + x1) * 0.5; + x1 = inIn[j]; out[j++] = (x1 + x0) * 0.5; + } + for (i = rate.filterRemain; i--; ) { + x0 = inIn[j]; + out[j++] = (x0 + x2) * 0.25; + x2 = x1; + x1 = x0; + } + this._x1 = x1; + this._x2 = x2; + }; + return ctor; + })(); + + cc.ugen.specs.Changed = { + $ar: { + defaults: "in=0,threshold=0", + ctor: function(_in, threshold) { + return cc.global.HPZ1.ar(_in).abs().gt(threshold); + } + }, + $kr: { + defaults: "in=0,threshold=0", + ctor: function(_in, threshold) { + return cc.global.HPZ1.kr(_in).abs().gt(threshold); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.ugen.specs.Lag = { + $ar: { + defaults: "in=0,lagTime=0.1,mul=1,add=0", + ctor: function(_in, lagTime, mul, add) { + return this.multiNew(2, _in, lagTime).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,lagTime=0.1,mul=1,add=0", + ctor: function(_in, lagTime, mul, add) { + return this.multiNew(1, _in, lagTime).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.Lag = (function() { + var ctor = function() { + if (this.rate.bufLength === 1) { + this.process = next_1; + } else { + this.process = next; + } + this._lag = undefined; + this._b1 = 0; + this._y1 = this.inputs[0][0]; + next_1.call(this, 1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var lag = this.inputs[1][0]; + var y1 = this._y1; + var b1 = this._b1; + var y0, i; + if (lag === this._lag) { + for (i = 0; i < inNumSamples; ++i) { + y0 = inIn[i]; + out[i] = y1 = y0 + b1 * (y1 - y0); + } + } else { + this._b1 = (lag === 0) ? 0 : Math.exp(log001 / (lag * this.rate.sampleRate)); + var b1_slope = (this._b1 - b1) * this.rate.slopeFactor; + this._lag = lag; + for (i = 0; i < inNumSamples; ++i) { + b1 += b1_slope; + y0 = inIn[i]; + out[i] = y1 = y0 + b1 * (y1 - y0); + } + } + this._y1 = y1; + }; + var next_1 = function() { + var out = this.outputs[0]; + var lag = this.inputs[1][0]; + var y1 = this._y1; + var b1 = this._b1; + var y0; + if (lag !== this._lag) { + this._b1 = b1 = (lag === 0) ? 0 : Math.exp(log001 / (lag * this.rate.sampleRate)); + this._lag = lag; + } + y0 = this.inputs[0][0]; + out[0] = y1 = y0 + b1 * (y1 - y0); + this._y1 = y1; + }; + return ctor; + })(); + + cc.ugen.specs.Lag2 = cc.ugen.specs.Lag; + + cc.unit.specs.Lag2 = (function() { + var ctor = function() { + if (this.inRates[1] !== 0) { + this.process = next_k; + } else { + if (this.rate.bufLength === 1) { + this.process = next_1_i; + } else { + this.process = next_i; + } + } + this._lag = NaN; + this._b1 = 0; + this._y1a = this.inputs[0][0]; + this._y1b = this.inputs[0][0]; + next_k.call(this, 1); + }; + var next_k = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var lag = this.inputs[1][0]; + var y1a = this._y1a; + var y1b = this._y1b; + var b1 = this._b1; + var y0a, b1_slope, i; + if (lag === this._lag) { + for (i = 0; i < inNumSamples; ++i) { + y0a = inIn[i]; + y1a = y0a + b1 * (y1a - y0a); + y1b = y1a + b1 * (y1b - y1a); + out[i] = y1b; + } + } else { + this._b1 = (lag === 0) ? 0 : Math.exp(log001 / (lag * this.rate.sampleRate)); + b1_slope = (this._b1 - b1) * this.rate.slopeFactor; + this._lag = lag; + for (i = 0; i < inNumSamples; ++i) { + b1 += b1_slope; + y0a = inIn[i]; + y1a = y0a + b1 * (y1a - y0a); + y1b = y1a + b1 * (y1b - y1a); + out[i] = y1b; + } + } + this._y1a = y1a; + this._y1b = y1b; + }; + var next_i = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var y1a = this._y1a; + var y1b = this._y1b; + var b1 = this._b1; + var y0a, i; + for (i = 0; i < inNumSamples; ++i) { + y0a = inIn[i]; + y1a = y0a + b1 * (y1a - y0a); + y1b = y1a + b1 * (y1b - y1a); + out[i] = y1b; + } + this._y1a = y1a; + this._y1b = y1b; + }; + var next_1_i = function() { + var out = this.outputs[0]; + var y1a = this._y1a; + var y1b = this._y1b; + var b1 = this._b1; + var y0a = this.inputs[0][0]; + y1a = y0a + b1 * (y1a - y0a); + y1b = y1a + b1 * (y1b - y1a); + out[0] = y1b; + this._y1a = y1a; + this._y1b = y1b; + }; + return ctor; + })(); + + cc.ugen.specs.Lag3 = cc.ugen.specs.Lag; + + cc.unit.specs.Lag3 = (function() { + var ctor = function() { + if (this.inRates[1] !== 0) { + this.process = next; + } else { + if (this.rate.bufLength === 1) { + this.process = next_1_i; + } else { + this.process = next; + } + } + this._lag = NaN; + this._b1 = 0; + this._y1a = this.inputs[0][0]; + this._y1b = this.inputs[0][0]; + this._y1c = this.inputs[0][0]; + next.call(this, 1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var lag = this.inputs[1][0]; + var y1a = this._y1a; + var y1b = this._y1b; + var y1c = this._y1c; + var b1 = this._b1; + var y0a, i; + if (lag === this._lag) { + for (i = 0; i < inNumSamples; ++i) { + y0a = inIn[i]; + y1a = y0a + b1 * (y1a - y0a); + y1b = y1a + b1 * (y1b - y1a); + y1c = y1b + b1 * (y1c - y1b); + out[i] = y1c; + } + } else { + this._b1 = (lag === 0) ? 0 : Math.exp(log001 / (lag * this.rate.sampleRate)); + var b1_slope = (this._b1 - b1) * this.rate.slopeFactor; + this._lag = lag; + for (i = 0; i < inNumSamples; ++i) { + b1 += b1_slope; + y0a = inIn[i]; + y1a = y0a + b1 * (y1a - y0a); + y1b = y1a + b1 * (y1b - y1a); + y1c = y1b + b1 * (y1c - y1b); + out[i] = y1c; + } + } + this._y1a = y1a; + this._y1b = y1b; + this._y1c = y1c; + }; + var next_1_i = function() { + var out = this.outputs[0]; + var y1a = this._y1a; + var y1b = this._y1b; + var y1c = this._y1c; + var b1 = this._b1; + var y0a = this.inputs[0][0]; + y1a = y0a + b1 * (y1a - y0a); + y1b = y1a + b1 * (y1b - y1a); + y1c = y1b + b1 * (y1c - y1b); + out[0] = y1c; + this._y1a = y1a; + this._y1b = y1b; + this._y1c = y1c; + }; + return ctor; + })(); + + cc.ugen.specs.Ramp = cc.ugen.specs.Lag; + + cc.unit.specs.Ramp = (function() { + var ctor = function() { + if (this.rate.bufLength === 1) { + this.process = next_1; + } else { + this.process = next; + } + this._counter = 1; + this._level = this.inputs[0][0]; + this._slope = 0; + this.outputs[0][0] = this._level; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var period = this.inputs[1][0]; + var slope = this._slope; + var level = this._level; + var counter = this._counter; + var remain = inNumSamples; + var sampleRate = this.rate.sampleRate; + var nsmps, i, j = 0; + while (remain) { + nsmps = Math.min(remain, counter); + for (i = 0; i < nsmps; ++i) { + out[j++] = level; + level += slope; + } + counter -= nsmps; + remain -= nsmps; + if (counter <= 0){ + counter = (period * sampleRate)|0; + counter = Math.max(1, counter); + slope = (inIn[j-1] - level) / counter; + } + } + this._level = level; + this._slope = slope; + this._counter = counter; + }; + var next_1 = function() { + var out = this.outputs[0]; + out[0] = this._level; + this._level += this._slope; + if (--this._counter <= 0) { + var _in = this.inputs[0][0]; + var period = this.inputs[1][0]; + var counter = (period * this.rate.sampleRate)|0; + this._counter = counter = Math.max(1, counter); + this._slope = (_in - this._level) / counter; + } + }; + return ctor; + })(); + + cc.ugen.specs.LagUD = { + $ar: { + defaults: "in=0,lagTimeU=0.1,lagTimeD=0.1,mul=1,add=0", + ctor: function(_in, lagTimeU, lagTimeD, mul, add) { + return this.multiNew(2, _in, lagTimeU, lagTimeD).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,lagTimeU=0.1,lagTimeD=0.1,mul=1,add=0", + ctor: function(_in, lagTimeU, lagTimeD, mul, add) { + return this.multiNew(1, _in, lagTimeU, lagTimeD).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.LagUD = (function() { + var ctor = function() { + this.process = next; + this._lagu = undefined; + this._lagd = undefined; + this._b1u = 0; + this._b1d = 0; + this._y1 = this.inputs[0][0]; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var lagu = this.inputs[1][0]; + var lagd = this.inputs[2][0]; + var y1 = this._y1; + var b1u = this._b1u; + var b1d = this._b1d; + var i, y0; + if ((lagu === this._lagu) && (lagd === this._lagd)) { + for (i = 0; i < inNumSamples; ++i) { + y0 = inIn[i]; + if (y0 > y1) { + out[i] = y1 = y0 + b1u * (y1 - y0); + } else { + out[i] = y1 = y0 + b1d * (y1 - y0); + } + } + } else { + this._b1u = (lagu === 0) ? 0 : Math.exp(log001 / (lagu * this.rate.sampleRate)); + var b1u_slope = (this._b1u - b1u) * this.rate.slopeFactor; + this._lagu = lagu; + this._b1d = (lagd === 0) ? 0 : Math.exp(log001 / (lagd * this.rate.sampleRate)); + var b1d_slope = (this._b1d - b1d) * this.rate.slopeFactor; + this._lagd = lagd; + for (i = 0; i < inNumSamples; ++i) { + b1u += b1u_slope; + b1d += b1d_slope; + y0 = inIn[i]; + if (y0 > y1) { + out[i] = y1 = y0 + b1u * (y1 - y0); + } else { + out[i] = y1 = y0 + b1d * (y1 - y0); + } + } + } + this._y1 = y1; + }; + return ctor; + })(); + + cc.ugen.specs.Lag2UD = cc.ugen.specs.LagUD; + + cc.unit.specs.Lag2UD = (function() { + var ctor = function() { + this.process = next; + this._lagu = 0; + this._lagd = 0; + this._b1u = 0; + this._b1d = 0; + this._y1a = this.inputs[0][0]; + this._y1b = this.inputs[0][0]; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var lagu = this.inputs[1][0]; + var lagd = this.inputs[2][0]; + var y1a = this._y1a; + var y1b = this._y1b; + var b1u = this._b1u; + var b1d = this._b1d; + var i, y0a; + if ((lagu === this._lagu) && (lagd === this._lagd)) { + for (i = 0; i < inNumSamples; ++i) { + y0a = inIn[i]; + if (y0a > y1a) { + y1a = y0a + b1u * (y1a - y0a); + } else { + y1a = y0a + b1d * (y1a - y0a); + } + if (y1a > y1b) { + y1b = y1a + b1u * (y1b - y1a); + } else { + y1b = y1a + b1d * (y1b - y1a); + } + out[i] = y1b; + } + } else { + this._b1u = (lagu === 0) ? 0 : Math.exp(log001 / (lagu * this.rate.sampleRate)); + var b1u_slope = (this._b1u - b1u) * this.rate.slopeFactor; + this._lagu = lagu; + this._b1d = (lagd === 0) ? 0 : Math.exp(log001 / (lagd * this.rate.sampleRate)); + var b1d_slope = (this._b1d - b1d) * this.rate.slopeFactor; + this._lagd = lagd; + for (i = 0; i < inNumSamples; ++i) { + b1u += b1u_slope; + b1d += b1d_slope; + y0a = inIn[i]; + if (y0a > y1a) { + y1a = y0a + b1u * (y1a - y0a); + } else { + y1a = y0a + b1d * (y1a - y0a); + } + if (y1a > y1b) { + y1b = y1a + b1u * (y1b - y1a); + } else { + y1b = y1a + b1d * (y1b - y1a); + } + out[i] = y1b; + } + } + this._y1a = y1a; + this._y1b = y1b; + }; + return ctor; + })(); + + cc.ugen.specs.Lag3UD = cc.ugen.specs.LagUD; + + cc.unit.specs.Lag3UD = (function() { + var ctor = function() { + this.process = next; + this._lagu = 0; + this._lagd = 0; + this._b1u = 0; + this._b1d = 0; + this._y1a = this.inputs[0][0]; + this._y1b = this.inputs[0][0]; + this._y1c = this.inputs[0][0]; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var lagu = this.inputs[1][0]; + var lagd = this.inputs[2][0]; + var y1a = this._y1a; + var y1b = this._y1b; + var y1c = this._y1c; + var b1u = this._b1u; + var b1d = this._b1d; + var i, y0a; + if ((lagu === this._lagu) && (lagd === this._lagd)) { + for (i = 0; i < inNumSamples; ++i) { + y0a = inIn[i]; + if (y0a > y1a) { + y1a = y0a + b1u * (y1a - y0a); + } else { + y1a = y0a + b1d * (y1a - y0a); + } + if (y1a > y1b) { + y1b = y1a + b1u * (y1b - y1a); + } else { + y1b = y1a + b1d * (y1b - y1a); + } + if (y1a > y1b) { + y1c = y1b + b1u * (y1c - y1b); + } else { + y1c = y1b + b1d * (y1c - y1b); + } + out[i] = y1c; + } + } else { + this._b1u = (lagu === 0) ? 0 : Math.exp(log001 / (lagu * this.rate.sampleRate)); + var b1u_slope = (this._b1u - b1u) * this.rate.slopeFactor; + this._lagu = lagu; + this._b1d = (lagd === 0) ? 0 : Math.exp(log001 / (lagd * this.rate.sampleRate)); + var b1d_slope = (this._b1d - b1d) * this.rate.slopeFactor; + this._lagd = lagd; + for (i = 0; i < inNumSamples; ++i) { + b1u += b1u_slope; + b1d += b1d_slope; + y0a = inIn[i]; + if (y0a > y1a) { + y1a = y0a + b1u * (y1a - y0a); + } else { + y1a = y0a + b1d * (y1a - y0a); + } + if (y1a > y1b) { + y1b = y1a + b1u * (y1b - y1a); + } else { + y1b = y1a + b1d * (y1b - y1a); + } + if (y1a > y1b) { + y1c = y1b + b1u * (y1c - y1b); + } else { + y1c = y1b + b1d * (y1c - y1b); + } + out[i] = y1c; + } + } + this._y1a = y1a; + this._y1b = y1b; + this._y1c = y1c; + }; + return ctor; + })(); + + cc.ugen.specs.VarLag = { + $ar: { + defaults: "in=0,time=0.1,curvature=0,warp=5,start=0,mul=1,add=0", + ctor: function(_in, time, curvature, warp, start, mul, add) { + return this.multiNew(2, _in, time, curvature, warp, start).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,time=0.1,curvature=0,warp=5,start=0,mul=1,add=0", + ctor: function(_in, time, curvature, warp, start, mul, add) { + return this.multiNew(1, _in, time, curvature, warp, start).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.VarLag = (function() { + var ctor = function() { + if (this.bufLength === 1) { + this.process = next_1; + } else { + this.process = next; + } + var lagTime = this.inputs[1][0]; + var counter = Math.max(1, (lagTime * this.rate.sampleRate)|0); + this._level = this.inputs[2][0]; + this._counter = counter; + this._in = this.inputs[0][0]; + this._slope = (this._in - this._level) / counter; + this._lagTime = lagTime; + this.outputs[0][0] = this._level; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var _in = this.inputs[0][0]; + var lagTime = this.inputs[1][0]; + var slope = this._slope; + var level = this._level; + var counter = this._counter; + var i, scaleFactor; + if (_in !== this._in) { + this._counter = counter = Math.max(1, (lagTime * this.rate.sampleRate)|0); + this._slope = slope = (_in - this._in) / counter; + this._in = _in; + this._lagTime = lagTime; + } else if (lagTime !== this._lagTime) { + scaleFactor = lagTime / this._lagTime; + this._counter = counter = Math.max(1, (this._counter * scaleFactor)|0); + this._slope = slope = (this._slope / scaleFactor) || 0; + this._lagTime = lagTime; + } + _in = this._in; + if (counter > 0) { + for (i = 0; i < inNumSamples; ++i) { + out[i] = level; + if (counter > 0) { + level += slope; + counter -= 1; + } else { + level = _in; + } + } + } else { + for (i = 0; i < inNumSamples; ++i) { + out[i] = level; + } + } + this._level = level; + this._slope = slope; + this._counter = counter; + }; + var next_1 = function() { + var _in = this.inputs[0][0]; + var lagTime = this.inputs[1][0]; + var counter = this._counter; + var scaleFactor; + if (_in !== this._in) { + this._counter = counter = Math.max(1, (lagTime * this.rate.sampleRate)|0); + this._slope = (_in - this._level) / counter; + this._in = _in; + this._lagTime = lagTime; + } else if (lagTime !== this._lagTime) { + if (counter !== 0) { + scaleFactor = lagTime / this._lagTime; + this._counter = counter = Math.max(1, (this._counter * scaleFactor)|0); + this._slope = this._slope / scaleFactor; + } + this._lagTime = lagTime; + } + this.outputs[0][0] = this._level; + if (this._counter > 0) { + this._level += this._slope; + this._counter -= 1; + } else { + this._level = this._in; + } + }; + return ctor; + })(); + + cc.ugen.specs.Slew = { + $ar: { + defaults: "in=0,up=1,dn=1,mul=1,add=0", + ctor: function(_in, up, dn, mul, add) { + return this.multiNew(2, _in, up, dn).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,up=1,dn=1,mul=1,add=0", + ctor: function(_in, up, dn, mul, add) { + return this.multiNew(1, _in, up, dn).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.Slew = (function() { + var ctor = function() { + this.process = next; + this._level = this.inputs[0][0]; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var sampleDur = this.rate.sampleDur; + var upf = +this.inputs[1][0] * sampleDur; + var dnf = -this.inputs[2][0] * sampleDur; + var level = this._level; + var slope; + for (var i = 0; i < inNumSamples; ++i) { + slope = inIn[i] - level; + level += Math.max(dnf, Math.min(slope, upf)); + out[i] = level; + } + this._level = level; + }; + return ctor; + })(); + + cc.ugen.specs.FOS = { + $ar: { + defaults: "in=0,a0=0,a1=0,b1=0,mul=1,add=0", + ctor: function(_in, a0, a1, b1, mul, add) { + return this.multiNew(2, _in, a0, a1, b1).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,a0=0,a1=0,b1=0,mul=1,add=0", + ctor: function(_in, a0, a1, b1, mul, add) { + return this.multiNew(1, _in, a0, a1, b1).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.FOS = (function() { + var ctor = function() { + if (this.bufLength === 1) { + this.process = next_1; + } else { + var inRates = this.inRates; + if (inRates[1] === 2 && inRates[2] === 2 && inRates[3] === 2) { + this.process = next_a; + } else { + this.process = next_k; + } + } + this._y1 = 0; + this._a0 = 0; + this._a1 = 0; + this._b1 = 0; + next_1.call(this, 1); + }; + var next_a = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var a0In = this.inputs[1]; + var a1In = this.inputs[2]; + var b1In = this.inputs[3]; + var y1 = this._y1, y0; + for (var i = 0; i < inNumSamples; ++i) { + y0 = inIn[i] + b1In[i] * y1; + out[i] = (a0In[i] * y0 + a1In[i] * y1) || 0; + y1 = y0; + } + this._y1 = y1; + }; + var next_1 = function() { + var _in = this.inputs[0][0]; + var a0 = this.inputs[1][0]; + var a1 = this.inputs[2][0]; + var b1 = this.inputs[3][0]; + var y1 = this._y1; + var y0 = _in + b1 * y1; + this.outputs[0][0] = (a0 * y0 + a1 * y1) || 0; + y1 = y0; + this._y1 = y1; + }; + var next_k = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var next_a0 = this.inputs[1][0]; + var next_a1 = this.inputs[2][0]; + var next_b1 = this.inputs[3][0]; + var filterSlope = this.rate.filterSlope; + var y0; + var y1 = this._y1; + var a0 = this._a0; + var a1 = this._a1; + var b1 = this._b1; + var a0_slope = (next_a0 - a0) * filterSlope; + var a1_slope = (next_a1 - a1) * filterSlope; + var b1_slope = (next_b1 - b1) * filterSlope; + for (var i = 0; i < inNumSamples; ++i) { + y0 = inIn[i] + b1 * y1; + out[i] = (a0 * y0 + a1 * y1) || 0; + y1 = y0; + + a0 += a0_slope; + a1 += a1_slope; + b1 += b1_slope; + } + this._y1 = y1; + this._a0 = a0; + this._a1 = a1; + this._b1 = b1; + }; + return ctor; + })(); + + cc.ugen.specs.SOS = { + $ar: { + defaults: "in=0,a0=0,a1=0,a2=0,b1=0,b2=0,mul=1,add=0", + ctor: function(_in, a0, a1, a2, b1, b2, mul, add) { + return this.multiNew(2, _in, a0, a1, a2, b1, b2).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,a0=0,a1=0,a2=0,b1=0,b2=0,mul=1,add=0", + ctor: function(_in, a0, a1, a2, b1, b2, mul, add) { + return this.multiNew(1, _in, a0, a1, a2, b1, b2).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.SOS = (function() { + var ctor = function() { + var inRates = this.inRates; + if (this.bufLength !== 1) { + if (inRates[1] === 2 && inRates[2] === 2 && inRates[3] === 2 && inRates[4] === 2 && inRates[5] === 2) { + this.process = next_a; + } else if (inRates[1] === 0 && inRates[2] === 0 && inRates[3] === 0 && inRates[4] === 0 && inRates[5] === 0) { + this.process = next_i; + } else { + this.process = next_k; + } + } else { + this.process = next_1; + } + this._y1 = 0; + this._y2 = 0; + this._a0 = this.inputs[1][0]; + this._a1 = this.inputs[2][0]; + this._a2 = this.inputs[3][0]; + this._b1 = this.inputs[4][0]; + this._b2 = this.inputs[5][0]; + next_1.call(this, 1); + }; + var next_a = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var a0In = this.inputs[1]; + var a1In = this.inputs[2]; + var a2In = this.inputs[3]; + var b1In = this.inputs[4]; + var b2In = this.inputs[5]; + var y0; + var y1 = this._y1; + var y2 = this._y2; + var rate = this.rate; + var i, j = 0; + + for (i = rate.filterLoops; i--; ) { + y0 = inIn[j] + b1In[j] * y1 + b2In[j] * y2; + out[j] = a0In[j] * y0 + a1In[j] * y1 + a2In[j] * y2; + j++; + + y2 = inIn[j] + b1In[j] * y0 + b2In[j] * y1; + out[j] = a0In[j] * y2 + a1In[j] * y0 + a2In[j] * y1; + j++; + + y1 = inIn[j] + b1In[j] * y2 + b2In[j] * y0; + out[j] = a0In[j] * y1 + a1In[j] * y2 + a2In[j] * y0; + j++; + } + for (i = rate.filterRemain; i--; ) { + y0 = inIn[j] + b1In[j] * y1 + b2In[j] * y2; + out[j] = a0In[j] * y0 + a1In[j] * y1 + a2In[j] * y2; + j++; + y2 = y1; + y1 = y0; + } + + this._y1 = y1; + this._y2 = y2; + }; + var next_k = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var next_a0 = this.inputs[1][0]; + var next_a1 = this.inputs[2][0]; + var next_a2 = this.inputs[3][0]; + var next_b1 = this.inputs[4][0]; + var next_b2 = this.inputs[5][0]; + + var y0; + var y1 = this._y1; + var y2 = this._y2; + var a0 = this._a0; + var a1 = this._a1; + var a2 = this._a2; + var b1 = this._b1; + var b2 = this._b2; + var rate = this.rate; + + var a0_slope = (next_a0 - a0) * rate.filterSlope; + var a1_slope = (next_a1 - a1) * rate.filterSlope; + var a2_slope = (next_a2 - a2) * rate.filterSlope; + var b1_slope = (next_b1 - b1) * rate.filterSlope; + var b2_slope = (next_b2 - b2) * rate.filterSlope; + + var i, j = 0; + for (i = rate.filterLoops; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; + out[j++] = a0 * y0 + a1 * y1 + a2 * y2; + + y2 = inIn[j] + b1 * y0 + b2 * y1; + out[j++] = a0 * y2 + a1 * y0 + a2 * y1; + + y1 = inIn[j] + b1 * y2 + b2 * y0; + out[j++] = a0 * y1 + a1 * y2 + a2 * y0; + + a0 += a0_slope; + a1 += a1_slope; + a2 += a2_slope; + b1 += b1_slope; + b2 += b2_slope; + } + for (i = rate.filterRemain; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; + out[j++] = a0 * y0 + a1 * y1 + a2 * y2; + y2 = y1; + y1 = y0; + } + this._a0 = a0; + this._a1 = a1; + this._a2 = a2; + this._b1 = b1; + this._b2 = b2; + this._y1 = y1; + this._y2 = y2; + }; + var next_i = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var y0; + var y1 = this._y1; + var y2 = this._y2; + var a0 = this._a0; + var a1 = this._a1; + var a2 = this._a2; + var b1 = this._b1; + var b2 = this._b2; + var rate = this.rate; + var i, j = 0; + for (i = rate.filterLoops; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; + out[j++] = a0 * y0 + a1 * y1 + a2 * y2; + + y2 = inIn[j] + b1 * y0 + b2 * y1; + out[j++] = a0 * y2 + a1 * y0 + a2 * y1; + + y1 = inIn[j] + b1 * y2 + b2 * y0; + out[j++] = a0 * y1 + a1 * y2 + a2 * y0; + } + for (i = rate.filterRemain; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; + out[j++] = a0 * y0 + a1 * y1 + a2 * y2; + y2 = y1; + y1 = y0; + } + this._y1 = y1; + this._y2 = y2; + }; + var next_1 = function() { + var _in = this.inputs[0][0]; + var a0 = this.inputs[1][0]; + var a1 = this.inputs[2][0]; + var a2 = this.inputs[3][0]; + var b1 = this.inputs[4][0]; + var b2 = this.inputs[5][0]; + + var y0; + var y1 = this._y1; + var y2 = this._y2; + + y0 = _in + b1 * y1 + b2 * y2; + this.outputs[0][0] = a0 * y0 + a1 * y1 + a2 * y2; + y2 = y1; + y1 = y0; + + this._y1 = y1; + this._y2 = y2; + }; + return ctor; + })(); + + cc.ugen.specs.Ringz = { + $ar: { + defaults: "in=0,freq=440,decaytime=1,mul=1,add=0", + ctor: function(_in, freq, decaytime, mul, add) { + return this.multiNew(2, _in, freq, decaytime).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,freq=440,decaytime=1,mul=1,add=0", + ctor: function(_in, freq, decaytime, mul, add) { + return this.multiNew(1, _in, freq, decaytime).madd(mul, add); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.Ringz = (function() { + var ctor = function() { + this.process = next; + this._b1 = 0; + this._b2 = 0; + this._y1 = 0; + this._y2 = 0; + this._freq = NaN; + this._decayTime = 0; + do_next_1(this, next); + }; + var next = function() { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var freq = this.inputs[1][0]; + var decayTime = this.inputs[2][0]; + var y0; + var y1 = this._y1; + var y2 = this._y2; + var a0 = 0.5; + var b1 = this._b1; + var b2 = this._b2; + var rate = this.rate; + var i, j = 0; + + if (freq !== this._freq || decayTime !== this._decayTime) { + var ffreq = freq * rate.radiansPerSample; + var R = decayTime === 0 ? 0 : Math.exp(log001/(decayTime * rate.sampleRate)); + var twoR = 2 * R; + var R2 = R * R; + var cost = (twoR * Math.cos(ffreq)) / (1 + R2); + var b1_next = twoR * cost; + var b2_next = -R2; + var b1_slope = (b1_next - b1) * rate.filterSlope; + var b2_slope = (b2_next - b2) * rate.filterSlope; + + for (i = rate.filterLoops; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; + out[j++] = a0 * (y0 - y2); + + y2 = inIn[j] + b1 * y0 + b2 * y1; + out[j++] = a0 * (y2 - y1); + + y1 = inIn[j] + b1 * y2 + b2 * y0; + out[j++] = a0 * (y1 - y0); + + b1 += b1_slope; + b2 += b2_slope; + } + this._freq = freq; + this._decayTime = decayTime; + this._b1 = b1_next; + this._b2 = b2_next; + } else { + for (i = rate.filterLoops; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; + out[j++] = a0 * (y0 - y2); + + y2 = inIn[j] + b1 * y0 + b2 * y1; + out[j++] = a0 * (y2 - y1); + + y1 = inIn[j] + b1 * y2 + b2 * y0; + out[j++] = a0 * (y1 - y0); + } + } + for (i = rate.filterRemain; i--; ) { + y0 = inIn[j] + b1 * y1 + b2 * y2; + out[j++] = a0 * (y0 - y2); + y2 = y1; + y1 = y0; + } + this._y1 = y1; + this._y2 = y2; + }; + return ctor; + })(); + + cc.ugen.specs.DetectSilence = { + $ar: { + defaults: "in=0,amp=0.0001,time=0.1,doneAction=0", + ctor: function(_in, amp, time, doneAction) { + return this.multiNew(2, _in, amp, time, doneAction); + } + }, + $kr: { + defaults: "in=0,amp=0.0001,time=0.1,doneAction=0", + ctor: function(_in, amp, time, doneAction) { + return this.multiNew(1, _in, amp, time, doneAction); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.DetectSilence = (function() { + var ctor = function() { + this.process = next; + this._thresh = this.inputs[1][0]; + this._endCounter = (this.rate.sampleRate * this.inputs[2][0])|0; + this._counter = -1; + }; + var next = function(inNumSamples) { + var thresh = this._thresh; + var counter = this._counter; + var val; + + var inIn = this.inputs[0]; + var out = this.outputs[0]; + for (var i = 0; i < inNumSamples; ++i) { + val = Math.abs(inIn[i]); + if (val > thresh) { + counter = 0; + out[i] = 0; + } else if (counter >= 0) { + if (++counter >= this._endCounter) { + this.doneAction(this.inputs[3][0]|0); + out[i] = 1; + } else { + out[i] = 0; + } + } else { + out[i] = 0; + } + } + this._counter = counter; + }; + return ctor; + })(); + + module.exports = {}; + +}); +define('cc/plugins/info', function(require, exports, module) { + + var cc = require("../cc"); + + var InfoUGenBase = { + $ir: { + ctor: function() { + return this.multiNew(0); + } + } + }; + + cc.ugen.specs.SampleRate = InfoUGenBase; + + cc.unit.specs.SampleRate = (function() { + var ctor = function() { + this.outputs[0][0] = cc.server.rates[2].sampleRate; + }; + return ctor; + })(); + + cc.ugen.specs.SampleDur = InfoUGenBase; + + cc.unit.specs.SampleDur = (function() { + var ctor = function() { + this.outputs[0][0] = cc.server.rates[2].sampleDur; + }; + return ctor; + })(); + + cc.ugen.specs.RadiansPerSample = InfoUGenBase; + + cc.unit.specs.RadiansPerSample = (function() { + var ctor = function() { + this.outputs[0][0] = cc.server.rates[2].radiansPerSample; + }; + return ctor; + })(); + + cc.ugen.specs.ControlRate = InfoUGenBase; + + cc.unit.specs.ControlRate = (function() { + var ctor = function() { + this.outputs[0][0] = cc.server.rates[1].sampleRate; + }; + return ctor; + })(); + + cc.ugen.specs.ControlDur = InfoUGenBase; + + cc.unit.specs.ControlDur = (function() { + var ctor = function() { + this.outputs[0][0] = cc.server.rates[2].bufDuration; + }; + return ctor; + })(); + + // TODO: + // cc.ugen.specs.SubsampleOffset = InfoUGenBase; + + // cc.ugen.specs.NumOutputBuses = InfoUGenBase; + + // cc.ugen.specs.NumAudioBuses = InfoUGenBase; + + // cc.ugen.specs.NumControlBuses = InfoUGenBase; + + // cc.ugen.specs.NumBuffers = InfoUGenBase; + + // cc.ugen.specs.NumRunningSynths = { + // $kr: { + // ctor: function() { + // return this.multiNew(1); + // } + // }, + // $ir: { + // ctor: function() { + // return this.multiNew(0); + // } + // } + // }; + + module.exports = {}; + +}); +define('cc/plugins/inout', function(require, exports, module) { + + var cc = require("../cc"); + var slice = [].slice; + + cc.ugen.specs.In = { + Klass: cc.MultiOutUGen, + $ar: { + defaults: "bus=0,numChannels=1", + ctor: function(bus, numChannels) { + return this.multiNew(2, numChannels, bus); + } + }, + $kr: { + defaults: "bus=0,numChannels=1", + ctor: function(bus, numChannels) { + return this.multiNew(1, numChannels, bus); + } + }, + init: function(numChannels) { + this.inputs = slice.call(arguments, 1); + this.numInputs = this.inputs.length; + return this.initOutputs(numChannels, this.rate); + } + }; + + cc.unit.specs.In = (function() { + var ctor = function() { + if (this.calcRate === 2) { + this.process = next_a; + this._busOffset = 0; + } else { + this.process = next_k; + this._busOffset = this.bufLength * 16; + } + }; + var next_a = function(inNumSamples) { + var out = this.outputs[0]; + var bus = this.world.bus; + var bufLength = this.bufLength; + var offset = (this.inputs[0][0] * bufLength)|0; + for (var i = 0; i < inNumSamples; ++i) { + out[i] = bus[offset + i]; + } + }; + var next_k = function() { + var value = this.world.bus[this._busOffset + (this.inputs[0][0]|0)]; + this.outputs[0][0] = value; + }; + return ctor; + })(); + + cc.ugen.specs.A2K = { + $kr: { + defaults: "in=0", + ctor: function(_in) { + if (_in.rate !== 2) { + throw new Error("first input is not audio rate"); + } + return this.multiNew(1, _in); + } + } + }; + + cc.unit.specs.A2K = (function() { + var ctor = function() { + this.process = next; + }; + var next = function() { + this.outputs[0][0] = this.inputs[0][0]; + }; + return ctor; + })(); + + cc.ugen.specs.K2A = { + $ar: { + defaults: "in=0", + ctor: function(_in) { + return this.multiNew(2, _in); + } + } + }; + + cc.unit.specs.K2A = (function() { + var ctor = function() { + this.process = next; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var value = this.inputs[0][0]; + for (var i = 0; i < inNumSamples; ++i) { + out[i] = value; + } + }; + return ctor; + })(); + + cc.ugen.specs.T2K = { + $kr: { + defaults: "in=0", + ctor: function(_in) { + if (_in.rate !== 2) { + throw new Error("first input is not audio rate"); + } + return this.multiNew(1, _in); + } + } + }; + + cc.unit.specs.T2K = (function() { + var ctor = function() { + this.process = next; + this._bufLength = cc.server.rates[2].bufLength; + this.outputs[0][0] = this.input[0][0]; + }; + var next = function() { + var inIn = this.input[0]; + var out = 0; + var val, n = this._bufLength; + for (var i = 0; i < n; ++i) { + val = inIn[i]; + if (val > out) { + out = val; + } + } + this.outputs[0][0] = out; + }; + return ctor; + })(); + + cc.ugen.specs.T2A = { + $kr: { + defaults: "in=0,offset=0", + ctor: function(_in, offset) { + if (_in.rate !== 2) { + throw new Error("first input is not audio rate"); + } + return this.multiNew(2, _in, offset); + } + } + }; + + cc.unit.specs.T2A = (function() { + var ctor = function() { + this.process = next; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var level = this.input[0][0]; + for (var i = 0; i < inNumSamples; ++i) { + out[0] = 0; + } + if (this._level <= 0 && level > 0) { + this.outputs[0][this.input[1][0]|0] = level; + } + this._level = level; + }; + return ctor; + })(); + + module.exports = {}; + +}); +define('cc/plugins/line', function(require, exports, module) { + + var cc = require("../cc"); + + cc.ugen.specs.Line = { + $ar: { + defaults: "start=0,end=1,dur=1,mul=1,add=0,doneAction=0", + ctor: function(start, end, dur, mul, add, doneAction) { + return this.multiNew(2, start, end, dur, doneAction).madd(mul, add); + } + }, + $kr: { + defaults: "start=0,end=1,dur=1,mul=1,add=0,doneAction=0", + ctor: function(start, end, dur, mul, add, doneAction) { + return this.multiNew(1, start, end, dur, doneAction).madd(mul, add); + } + } + }; + + cc.unit.specs.Line = (function() { + var ctor = function() { + this.process = next; + var start = this.inputs[0][0]; + var end = this.inputs[1][0]; + var dur = this.inputs[2][0]; + var counter = Math.round(dur * this.rate.sampleRate); + this._counter = Math.max(1, counter); + if (counter === 0) { + this._level = end; + this._slope = 0; + } else { + this._slope = (end - start) / this._counter; + this._level = start + this._slope; + } + this._endLevel = end; + this._doneAction = this.inputs[3][0]; + this.outputs[0][0] = this._level; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var level = this._level; + var counter = this._counter; + var slope = this._slope; + var i, remain = inNumSamples; + do { + var nsmps; + if (counter === 0) { + nsmps = remain; + remain = 0; + var endLevel = this._endLevel; + for (i = 0; i < nsmps; ++i) { + out[i] = endLevel; + } + } else { + nsmps = Math.min(remain, counter); + counter -= nsmps; + remain -= nsmps; + for (i = 0; i < nsmps; ++i) { + out[i] = level; + level += slope; + } + if (counter === 0) { + this.doneAction(this._doneAction); + } + } + } while (remain); + this._counter = counter; + this._level = level; + }; + + return ctor; + })(); + + cc.ugen.specs.XLine = { + $ar: { + defaults: "start=1,end=2,dur=1,mul=1,add=0,doneAction=0", + ctor: function(start, end, dur, mul, add, doneAction) { + return this.multiNew(2, start, end, dur, doneAction).madd(mul, add); + } + }, + $kr: { + defaults: "start=1,end=2,dur=1,mul=1,add=0,doneAction=0", + ctor: function(start, end, dur, mul, add, doneAction) { + return this.multiNew(1, start, end, dur, doneAction).madd(mul, add); + } + } + }; + + cc.unit.specs.XLine = (function() { + var ctor = function() { + this.process = next; + var start = this.inputs[0][0] || 0.001; + var end = this.inputs[1][0] || 0.001; + var dur = this.inputs[2][0]; + var counter = Math.round(dur * this.rate.sampleRate); + if (counter === 0) { + this._level = end; + this._counter = 0; + this._growth = 0; + } else { + this._counter = counter; + this._growth = Math.pow(end / start, 1 / counter); + this._level = start * this._growth; + } + this._endLevel = end; + this._doneAction = this.inputs[3][0]; + this.outputs[0][0] = this._level; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var level = this._level; + var counter = this._counter; + var growth = this._growth; + var i, remain = inNumSamples; + do { + var nsmps; + if (counter === 0) { + nsmps = remain; + remain = 0; + var endLevel = this._endLevel; + for (i = 0; i < nsmps; ++i) { + out[i] = endLevel; + } + } else { + nsmps = Math.min(remain, counter); + counter -= nsmps; + remain -= nsmps; + for (i = 0; i < nsmps; ++i) { + out[i] = level; + level *= growth; + } + if (counter === 0) { + this.doneAction(this._doneAction); + } + } + } while (remain); + this._counter = counter; + this._level = level; + }; + return ctor; + })(); + + module.exports = {}; + +}); +define('cc/plugins/noise', function(require, exports, module) { + + var cc = require("../cc"); + var utils = require("./utils"); + var cubicinterp = utils.cubicinterp; + + // frand: return a float from 0.0 to 0.999... + // Math.random(); + + // frand0: return a float from +1.0 to +1.999... + // Math.random() + 1; + + // frand2: return a float from -1.0 to +0.999... + // Math.random() * 2 - 1; + + // frand8: return a float from -0.125 to +0.124999... + // Math.random() * 0.25 - 0.125; + + + cc.ugen.specs.WhiteNoise = { + $ar: { + defaults: "mul=1,add=0", + ctor: function(mul, add) { + return this.multiNew(2).madd(mul, add); + } + }, + $kr: { + defaults: "mul=1,add=0", + ctor: function(mul, add) { + return this.multiNew(1).madd(mul, add); + } + } + }; + + cc.unit.specs.WhiteNoise = (function() { + var ctor = function() { + this.process = next; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + for (var i = 0; i < inNumSamples; ++i) { + out[i] = Math.random() * 2 - 1; // frand2 + } + }; + return ctor; + })(); + + cc.ugen.specs.BrownNoise = cc.ugen.specs.WhiteNoise; + + cc.unit.specs.BrownNoise = (function() { + var ctor = function() { + this.process = next; + this._level = Math.random() * 2 - 1; + this.outputs[0][0] = this._level; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var z = this._level; + for (var i = 0; i < inNumSamples; ++i) { + z += Math.random() * 0.25 - 0.125; // frand8 + if (z > 1) { + z = 2 - z; + } else if (z < -1) { + z = -2 - z; + } + out[i] = z; + } + this._level = z; + }; + return ctor; + })(); + + cc.ugen.specs.PinkNoise = cc.ugen.specs.WhiteNoise; + + cc.unit.specs.PinkNoise = (function() { + var ctor = function() { + this.process = next; + var whites = new Uint8Array(5); + for (var i = 0; i < 5; ++i) { + whites[i] = ((Math.random() * 1073741824)|0) % 25; + } + this._whites = whites; + this._key = 0; + this.process(1); + }; + var MAX_KEY = 31; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var key = this._key|0, whites = this._whites; + var last_key, sum, diff, i, j; + for (i = 0; i < inNumSamples; ++i) { + last_key = key++; + if (key > MAX_KEY) { + key = 0; + } + diff = last_key ^ key; + for (j = sum = 0; j < 5; ++j) { + if (diff & (1 << j)) { + whites[j] = ((Math.random() * 1073741824)|0) % 25; + } + sum += whites[j]; + } + out[i] = (sum * 0.01666666) - 1; + } + this._key = key; + }; + return ctor; + })(); + + cc.ugen.specs.ClipNoise = cc.ugen.specs.WhiteNoise; + + cc.unit.specs.ClipNoise = (function() { + var ctor = function() { + this.process = next; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + for (var i = 0; i < inNumSamples; ++i) { + out[i] = Math.random() < 0.5 ? -1 : +1; + } + }; + return ctor; + })(); + + cc.ugen.specs.GrayNoise = cc.ugen.specs.WhiteNoise; + + cc.unit.specs.GrayNoise = (function() { + var ctor = function() { + this.process = next; + this._counter = 0; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var counter = this._counter; + for (var i = 0; i < inNumSamples; ++i) { + // counter ^= 1L << (trand(s1,s2,s3) & 31); + // ZXP(out) = counter * 4.65661287308e-10f; + counter ^= 1 << ((Math.random() * 31)|0); + out[i] = counter * 4.65661287308e-10; + } + this._counter = counter; + }; + return ctor; + })(); + + cc.ugen.specs.Crackle = { + $ar: { + defaults: "chaosParam=1.5,mul=1,add=0", + ctor: function(chaosParam, mul, add) { + return this.multiNew(2, chaosParam).madd(mul, add); + } + }, + $kr: { + defaults: "chaosParam=1.5,mul=1,add=0", + ctor: function(chaosParam, mul, add) { + return this.multiNew(1, chaosParam).madd(mul, add); + } + } + }; + + cc.unit.specs.Crackle = (function() { + var ctor = function() { + this.process = next; + this._y1 = Math.random(); + this._y2 = 0; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var paramf = this.inputs[0][0]; + var y1 = this._y1; + var y2 = this._y2; + var y0; + for (var i = 0; i < inNumSamples; ++i) { + out[i] = y0 = Math.abs(y1 * paramf - y2 - 0.05) || 0; + y2 = y1; + y1 = y0; + } + this._y1 = y1; + this._y2 = y2; + }; + return ctor; + })(); + + cc.ugen.specs.Logistic = { + $ar: { + defaults: "chaosParam=1.5,freq=1000,init=0.5,mul=1,add=0", + ctor: function(chaosParam, freq, init, mul, add) { + return this.multiNew(2, chaosParam, freq, init).madd(mul, add); + } + }, + $kr: { + defaults: "chaosParam=1.5,freq=1000,init=0.5,mul=1,add=0", + ctor: function(chaosParam, freq, init, mul, add) { + return this.multiNew(1, chaosParam, freq, init).madd(mul, add); + } + } + }; + + cc.unit.specs.Logistic = (function() { + var ctor = function() { + this.process = next; + this._y1 = this.inputs[2][0]; + this._counter = 0; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var paramf = this.inputs[0][0]; + var freq = this.inputs[1][0]; + var y1 = this._y1; + var counter = this._counter; + var remain = inNumSamples; + var sampleRate = this.rate.sampleRate; + var nsmps, i, j = 0; + do { + if (counter <= 0) { + counter = Math.max(1, sampleRate / Math.max(0.001, freq))|0; + y1 = paramf * y1 * (1.0 - y1); // chaotic equation + } + nsmps = Math.min(counter, remain); + counter -= nsmps; + remain -= nsmps; + for (i = 0; i < nsmps; ++i) { + out[j++] = y1; + } + } while (remain); + this._y1 = y1; + this._counter = counter; + }; + return ctor; + })(); + + cc.ugen.specs.Dust = { + $ar: { + defaults: "density=0,mul=1,add=0", + ctor: function(density, mul, add) { + return this.multiNew(2, density).madd(mul, add); + } + }, + $kr: { + defaults: "density=0,mul=1,add=0", + ctor: function(density, mul, add) { + return this.multiNew(1, density).madd(mul, add); + } + } + }; + + cc.unit.specs.Dust = (function() { + var ctor = function() { + this.process = next; + this._density = 0; + this._scale = 0; + this._thresh = 0; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var density = this.inputs[0][0]; + var thresh, scale; + if (density !== this._density) { + thresh = this._thresh = density * this.rate.sampleDur; + scale = this._scale = thresh > 0 ? 1 / thresh : 0; + this._density = density; + } else { + thresh = this._thresh; + scale = this._scale; + } + for (var i = 0; i < inNumSamples; ++i) { + var z = Math.random(); + out[i] = z < thresh ? z * scale : 0; + } + }; + return ctor; + })(); + + cc.ugen.specs.Dust2 = cc.ugen.specs.Dust; + + cc.unit.specs.Dust2 = (function() { + var ctor = function() { + this.process = next; + this._density = 0; + this._scale = 0; + this._thresh = 0; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var density = this.inputs[0][0]; + var thresh, scale; + if (density !== this._density) { + thresh = this._thresh = density * this.rate.sampleDur; + scale = this._scale = thresh > 0 ? 2 / thresh : 0; + this._density = density; + } else { + thresh = this._thresh; + scale = this._scale; + } + for (var i = 0; i < inNumSamples; ++i) { + var z = Math.random(); + out[i] = z < thresh ? z * scale - 1 : 0; + } + }; + return ctor; + })(); + + cc.ugen.specs.LFNoise0 = { + $ar: { + defaults: "freq=500,mul=1,add=0", + ctor: function(freq, mul, add) { + return this.multiNew(2, freq).madd(mul, add); + } + }, + $kr: { + defaults: "freq=500,mul=1,add=0", + ctor: function(freq, mul, add) { + return this.multiNew(1, freq).madd(mul, add); + } + } + }; + + cc.unit.specs.LFNoise0 = (function() { + var ctor = function() { + this.process = next; + this._level = 0; + this._counter = 0; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var freq = this.inputs[0][0]; + var level = this._level; + var counter = this._counter; + var i, remain = inNumSamples; + var j = 0; + do { + if (counter <= 0) { + counter = Math.max(1, (this.rate.sampleRate / Math.max(freq, 0.001))|0); + level = Math.random() * 2 - 1; + } + var nsmps = Math.min(remain, counter); + remain -= nsmps; + counter -= nsmps; + for (i = 0; i < nsmps; ++i) { + out[j++] = level; + } + } while (remain); + this._counter = counter; + this._level = level; + }; + return ctor; + })(); + + cc.ugen.specs.LFNoise1 = cc.ugen.specs.LFNoise0; + + cc.unit.specs.LFNoise1 = (function() { + var ctor = function() { + this.process = next; + this._level = Math.random() * 2 - 1; + this._counter = 0; + this._slope = 0; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var freq = this.inputs[0][0]; + var level = this._level; + var slope = this._slope; + var counter = this._counter; + var i, remain = inNumSamples; + var j = 0; + do { + if (counter <= 0) { + counter = Math.max(1, (this.rate.sampleRate / Math.max(freq, 0.001))|0); + var nextLevel = Math.random() * 2 - 1; + slope = (nextLevel - level) / counter; + } + var nsmps = Math.min(remain, counter); + remain -= nsmps; + counter -= nsmps; + for (i = 0; i < nsmps; ++i) { + out[j++] = level; + level += slope; + } + } while (remain); + this._level = level; + this._slope = slope; + this._counter = counter; + }; + return ctor; + })(); + + cc.ugen.specs.LFNoise2 = cc.ugen.specs.LFNoise0; + + cc.unit.specs.LFNoise2 = (function() { + var ctor = function() { + this.process = next; + this._level = 0; + this._counter = 0; + this._slope = 0; + this._curve = 0; + this._nextValue = Math.random() * 2 - 1; + this._nextMidPt = this._nextValue * 0.5; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var freq = this.inputs[0][0]; + var level = this._level; + var slope = this._slope; + var curve = this._curve; + var counter = this._counter; + var i, remain = inNumSamples; + var j = 0; + do { + if (counter <= 0) { + var value = this._nextValue; + this._nextValue = Math.random() * 2 - 1; + level = this._nextMidPt; + this._nextMidPt = (this._nextValue + value) * 0.5; + counter = Math.max(2, (this.rate.sampleRate / Math.max(freq, 0.001))|0); + var fseglen = counter; + curve = 2 * (this._nextMidPt - level - fseglen * slope) / (fseglen * fseglen + fseglen); + } + var nsmps = Math.min(remain, counter); + remain -= nsmps; + counter -= nsmps; + for (i = 0; i < nsmps; ++i) { + out[j++] = level; + slope += curve; + level += slope; + } + } while (remain); + this._level = level; + this._slope = slope; + this._curve = curve; + this._counter = counter; + }; + return ctor; + })(); + + cc.ugen.specs.LFClipNoise = cc.ugen.specs.LFNoise0; + + cc.unit.specs.LFClipNoise = (function() { + var ctor = function() { + this.process = next; + this._counter = 0; + this._level = 0; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var freq = this.inputs[0][0]; + var level = this._level; + var counter = this._counter; + var i, remain = inNumSamples; + var j = 0; + do { + if (counter <= 0) { + counter = Math.max(1, (this.rate.sampleRate / Math.max(freq, 0.001))|0); + level = Math.random() < 0.5 ? -1 : +1; + } + var nsmps = Math.min(remain, counter); + remain -= nsmps; + counter -= nsmps; + for (i = 0; i < nsmps; ++i) { + out[j++] = level; + } + } while (remain); + this._counter = counter; + this._level = level; + }; + return ctor; + })(); + + cc.ugen.specs.LFDNoise0 = cc.ugen.specs.LFNoise0; + + cc.unit.specs.LFDNoise0 = (function() { + var ctor = function() { + if (this.inRates[0] === 2) { + this.process = next; + } else { + this.process = next_k; + } + this._level = 0; + this._phase = 0; + next.call(this, 1); + }; + + var next = function(inNumSamples) { + var out = this.outputs[0]; + var freqIn = this.inputs[0]; + var level = this._level; + var phase = this._phase; + var smpdur = this.rate.sampleDur; + for (var i = 0; i < inNumSamples; ++i) { + phase -= freqIn[i] * smpdur; + if (phase < 0) { + phase = 1 + (phase % 1); + level = Math.random() * 2 - 1; + } + out[i] = level; + } + this._level = level; + this._phase = phase; + }; + + var next_k = function(inNumSamples) { + var out = this.outputs[0]; + var freq = this.inputs[0][0]; + var level = this._level; + var phase = this._phase; + var smpdur = this.rate.sampleDur; + var dphase = smpdur * freq; + for (var i = 0; i < inNumSamples; ++i) { + phase -= dphase; + if (phase < 0) { + phase = 1 + (phase % 1); + level = Math.random() * 2 - 1; + } + out[i] = level; + } + this._level = level; + this._phase = phase; + }; + + return ctor; + })(); + + cc.ugen.specs.LFDNoise1 = cc.ugen.specs.LFNoise0; + + cc.unit.specs.LFDNoise1 = (function() { + var ctor = function() { + if (this.inRates[0] === 2) { + this.process = next; + } else { + this.process = next_k; + } + this._phase = 0; + this._prevLevel = 0; + this._nextLevel = 0; + next.call(this, 1); + }; + + var next = function(inNumSamples) { + var out = this.outputs[0]; + var freqIn = this.inputs[0]; + var prevLevel = this._prevLevel; + var nextLevel = this._nextLevel; + var phase = this._phase; + var smpdur = this.rate.sampleDur; + for (var i = 0; i < inNumSamples; ++i) { + phase -= freqIn[i] * smpdur; + if (phase < 0) { + phase = 1 + (phase % 1); + prevLevel = nextLevel; + nextLevel = Math.random() * 2 - 1; + } + out[i] = nextLevel + ( phase * (prevLevel - nextLevel) ); + } + this._prevLevel = prevLevel; + this._nextLevel = nextLevel; + this._phase = phase; + }; + + var next_k = function(inNumSamples) { + var out = this.outputs[0]; + var freq = this.inputs[0][0]; + var prevLevel = this._prevLevel; + var nextLevel = this._nextLevel; + var phase = this._phase; + var smpdur = this.rate.sampleDur; + var dphase = freq * smpdur; + for (var i = 0; i < inNumSamples; ++i) { + phase -= dphase; + if (phase < 0) { + phase = 1 + (phase % 1); + prevLevel = nextLevel; + nextLevel = Math.random() * 2 - 1; + } + out[i] = nextLevel + ( phase * (prevLevel - nextLevel) ); + } + this._prevLevel = prevLevel; + this._nextLevel = nextLevel; + this._phase = phase; + }; + + return ctor; + })(); + + cc.ugen.specs.LFDNoise3 = cc.ugen.specs.LFNoise0; + + cc.unit.specs.LFDNoise3 = (function() { + var ctor = function() { + if (this.inRates[0] === 2) { + this.process = next; + } else { + this.process = next_k; + } + this._phase = 0; + this._levelA = 0; + this._levelB = 0; + this._levelC = 0; + this._levelD = 0; + next.call(this, 1); + }; + + var next = function(inNumSamples) { + var out = this.outputs[0]; + var freqIn = this.inputs[0]; + var a = this._levelA; + var b = this._levelB; + var c = this._levelC; + var d = this._levelD; + var phase = this._phase; + var smpdur = this.rate.sampleDur; + for (var i = 0; i < inNumSamples; ++i) { + phase -= freqIn[i] * smpdur; + if (phase < 0) { + phase = 1 + (phase % 1); + a = b; + b = c; + c = d; + d = Math.random() * 2 - 1; + } + out[i] = cubicinterp(1 - phase, a, b, c, d); + } + this._levelA = a; + this._levelB = b; + this._levelC = c; + this._levelD = d; + this._phase = phase; + }; + + var next_k = function(inNumSamples) { + var out = this.outputs[0]; + var freq = this.inputs[0][0]; + var a = this._levelA; + var b = this._levelB; + var c = this._levelC; + var d = this._levelD; + var phase = this._phase; + var smpdur = this.rate.sampleDur; + var dphase = freq * smpdur; + for (var i = 0; i < inNumSamples; ++i) { + phase -= dphase; + if (phase < 0) { + phase = 1 + (phase % 1); + a = b; + b = c; + c = d; + d = Math.random() * 2 - 1; + } + out[i] = cubicinterp(1 - phase, a, b, c, d); + } + this._levelA = a; + this._levelB = b; + this._levelC = c; + this._levelD = d; + this._phase = phase; + }; + + return ctor; + })(); + + cc.ugen.specs.LFDClipNoise = cc.ugen.specs.LFNoise0; + + cc.unit.specs.LFDClipNoise = (function() { + var ctor = function() { + if (this.inRates[0] === 2) { + this.process = next; + } else { + this.process = next_k; + } + this._level = 0; + this._phase = 0; + next.call(this, 1); + }; + + var next = function(inNumSamples) { + var out = this.outputs[0]; + var freqIn = this.inputs[0]; + var level = this._level; + var phase = this._phase; + var smpdur = this.rate.sampleDur; + for (var i = 0; i < inNumSamples; ++i) { + phase -= freqIn[i] * smpdur; + if (phase < 0) { + phase = 1 + (phase % 1); + level = Math.random() < 0.5 ? -1 : +1; + } + out[i] = level; + } + this._level = level; + this._phase = phase; + }; + + var next_k = function(inNumSamples) { + var out = this.outputs[0]; + var freq = this.inputs[0][0]; + var level = this._level; + var phase = this._phase; + var smpdur = this.rate.sampleDur; + var dphase = smpdur * freq; + for (var i = 0; i < inNumSamples; ++i) { + phase -= dphase; + if (phase < 0) { + phase = 1 + (phase % 1); + level = Math.random() < 0.5 ? -1 : +1; + } + out[i] = level; + } + this._level = level; + this._phase = phase; + }; + + return ctor; + })(); + + module.exports = {}; + +}); +define('cc/plugins/osc', function(require, exports, module) { + + var cc = require("../cc"); + + var utils = require("./utils"); + + var twopi = 2 * Math.PI; + var kSineSize = utils.kSineSize; + var kSineMask = utils.kSineMask; + var kBadValue = utils.kBadValue; + var gSineWavetable = utils.gSineWavetable; + var gSine = utils.gSine; + var gInvSine = utils.gInvSine; + var log001 = Math.log(0.001); + + var osc_next_aa = function(unit, inNumSamples, calc) { + var out = unit.outputs[0]; + var freqIn = unit.inputs[unit._freqIndex]; + var phaseIn = unit.inputs[unit._phaseIndex]; + var mask = unit._mask; + var table = unit._table; + var cpstoinc = unit._cpstoinc; + var radtoinc = unit._radtoinc; + var x = unit._x, i; + for (i = 0; i < inNumSamples; ++i) { + out[i] = calc(table, mask, x + radtoinc * phaseIn[i]); + x += freqIn[i] * cpstoinc; + } + unit._x = x; + }; + var osc_next_ak = function(unit, inNumSamples, calc) { + var out = unit.outputs[0]; + var freqIn = unit.inputs[unit._freqIndex]; + var nextPhase = unit.inputs[unit._phaseIndex][0]; + var mask = unit._mask; + var table = unit._table; + var radtoinc = unit._radtoinc; + var cpstoinc = unit._cpstoinc; + var phase = unit._phase; + var x = unit._x, i; + if (nextPhase === phase) { + phase *= radtoinc; + for (i = 0; i < inNumSamples; ++i) { + out[i] = calc(table, mask, x + phase); + x += freqIn[i] * cpstoinc; + } + } else { + var phase_slope = (nextPhase - phase) * unit.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + out[i] = calc(table, mask, x + radtoinc * phase); + phase += phase_slope; + x += freqIn[i] * cpstoinc; + } + unit._phase = nextPhase; + } + unit._x = x; + }; + var osc_next_ai = function(unit, inNumSamples, calc) { + var out = unit.outputs[0]; + var freqIn = unit.inputs[unit._freqIndex]; + var phase = unit._phase * unit._radtoinc; + var mask = unit._mask; + var table = unit._table; + var cpstoinc = unit._cpstoinc; + var x = unit._x, i; + for (i = 0; i < inNumSamples; ++i) { + out[i] = calc(table, mask, x + phase); + x += cpstoinc * freqIn[i]; + } + unit._x = x; + }; + var osc_next_ka = function(unit, inNumSamples, calc) { + var out = unit.outputs[0]; + var nextFreq = unit.inputs[unit._freqIndex][0]; + var phaseIn = unit.inputs[unit._phaseIndex]; + var mask = unit._mask; + var table = unit._table; + var radtoinc = unit._radtoinc; + var cpstoinc = unit._cpstoinc; + var freq = unit._freq; + var x = unit._x, i; + if (nextFreq === freq) { + freq *= cpstoinc; + for (i = 0; i < inNumSamples; ++i) { + out[i] = calc(table, mask, x + radtoinc * phaseIn[i]); + x += freq; + } + } else { + var freq_slope = (nextFreq - freq) * unit.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + out[i] = calc(table, mask, x + radtoinc * phaseIn[i]); + x += freq * cpstoinc; + freq += freq_slope; + } + unit._freq = nextFreq; + } + unit._x = x; + }; + var osc_next_kk = function(unit, inNumSamples, calc) { + var out = unit.outputs[0]; + var nextFreq = unit.inputs[unit._freqIndex][0]; + var nextPhase = unit.inputs[unit._phaseIndex][0]; + var mask = unit._mask; + var table = unit._table; + var radtoinc = unit._radtoinc; + var cpstoinc = unit._cpstoinc; + var freq = unit._freq; + var phase = unit._phase; + var x = unit._x, i; + if (nextFreq === freq && nextPhase === phase) { + freq *= cpstoinc; + phase *= radtoinc; + for (i = 0; i < inNumSamples; ++i) { + out[i] = calc(table, mask, x + phase); + x += freq; + } + } else { + var freq_slope = (nextFreq - freq ) * unit.rate.slopeFactor; + var phase_slope = (nextPhase - phase) * unit.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + out[i] = calc(table, mask, x + radtoinc * phase); + x += freq * cpstoinc; + freq += freq_slope; + phase += phase_slope; + } + unit._freq = nextFreq; + unit._phase = nextPhase; + } + unit._x = x; + }; + var get_table = function(unit, shift) { + var buffer = unit.world.buffers[unit._bufnumIn[0]|0]; + if (buffer) { + var samples = buffer.samples; + if (samples.length) { + if (unit._table === samples) { + return true; + } + var length = samples.length; + var logSize = Math.log(length) / Math.log(2); + if (logSize === (logSize|0)) { + length >>= shift; + unit._radtoinc = length / twopi; + unit._cpstoinc = length * unit.rate.sampleDur; + unit._table = samples; + unit._mask = length - 1; + return true; + } + } + } + return false; + }; + + cc.ugen.specs.Osc = { + $ar: { + defaults: "bufnum=0,freq=440,phase=0,mul=1,add=0", + ctor: function(bufnum, freq, phase, mul, add) { + return this.multiNew(2, bufnum, freq, phase).madd(mul, add); + } + }, + $kr: { + defaults: "bufnum=0,freq=440,phase=0,mul=1,add=0", + ctor: function(bufnum, freq, phase, mul, add) { + return this.multiNew(1, bufnum, freq, phase).madd(mul, add); + } + } + }; + + cc.unit.specs.Osc = (function() { + var ctor = function() { + this._bufnumIn = this.inputs[0]; + this._freq = this.inputs[1][0]; + this._phase = this.inputs[2][0]; + this._freqIndex = 1; + this._phaseIndex = 2; + this._radtoinc = 0; + this._cpstoinc = 0; + this._mask = 0; + this._table = null; + this._x = 0; + switch (this.inRates[0]) { + case 2: + switch (this.inRates[1]) { + case 2 : this.process = next_aa; break; + case 1: this.process = next_ak; break; + case 0 : this.process = next_ai; break; + case 3 : this.process = next_ak; break; + } + break; + default: + switch (this.inRates[1]) { + case 2 : this.process = next_ka; break; + case 1: this.process = next_kk; break; + case 0 : this.process = next_kk; break; + case 3 : this.process = next_kk; break; + } + } + }; + var wcalc = function(table, mask, pphase) { + var index = (pphase & mask) << 1; + return table[index] + (pphase-(pphase|0)) * table[index+1]; + }; + var next_aa = function(inNumSamples) { + if (get_table(this, 1)) { + osc_next_aa(this, inNumSamples, wcalc); + } + }; + var next_ak = function(inNumSamples) { + if (get_table(this, 1)) { + osc_next_ak(this, inNumSamples, wcalc); + } + }; + var next_ai = function(inNumSamples) { + if (get_table(this, 1)) { + osc_next_ai(this, inNumSamples, wcalc); + } + }; + var next_ka = function(inNumSamples) { + if (get_table(this, 1)) { + osc_next_ka(this, inNumSamples, wcalc); + } + }; + var next_kk = function(inNumSamples) { + if (get_table(this, 1)) { + osc_next_kk(this, inNumSamples, wcalc); + } + }; + return ctor; + })(); + + cc.ugen.specs.SinOsc = { + $ar: { + defaults: "freq=440,phase=0,mul=1,add=0", + ctor: function(freq, phase, mul, add) { + return this.multiNew(2, freq, phase).madd(mul, add); + } + }, + $kr: { + defaults: "freq=440,phase=0,mul=1,add=0", + ctor: function(freq, phase, mul, add) { + return this.multiNew(1, freq, phase).madd(mul, add); + } + } + }; + + cc.unit.specs.SinOsc = (function() { + var ctor = function() { + this._freq = this.inputs[0][0]; + this._phase = this.inputs[1][0]; + this._freqIndex = 0; + this._phaseIndex = 1; + this._radtoinc = kSineSize / twopi; + this._cpstoinc = kSineSize * this.rate.sampleDur; + this._mask = kSineMask; + this._table = gSineWavetable; + this._x = 0; + switch (this.inRates[0]) { + case 2: + switch (this.inRates[1]) { + case 2 : this.process = next_aa; break; + case 1: this.process = next_ak; break; + case 0 : this.process = next_ai; break; + case 3 : this.process = next_ak; break; + } + break; + default: + switch (this.inRates[1]) { + case 2 : this.process = next_ka; break; + case 1: this.process = next_kk; break; + case 0 : this.process = next_kk; break; + case 3 : this.process = next_kk; break; + } + } + osc_next_kk(this, 1, wcalc); + }; + var wcalc = function(table, mask, pphase) { + var index = (pphase & mask) << 1; + return table[index] + (pphase-(pphase|0)) * table[index+1]; + }; + var next_aa = function(inNumSamples) { + osc_next_aa(this, inNumSamples, wcalc); + }; + var next_ak = function(inNumSamples) { + osc_next_ak(this, inNumSamples, wcalc); + }; + var next_ai = function(inNumSamples) { + osc_next_ai(this, inNumSamples, wcalc); + }; + var next_ka = function(inNumSamples) { + osc_next_ka(this, inNumSamples, wcalc); + }; + var next_kk = function(inNumSamples) { + osc_next_kk(this, inNumSamples, wcalc); + }; + return ctor; + })(); + + cc.ugen.specs.PMOsc = { + $ar: { + defaults: "carfreq=0,modfreq=0,pmindex=0,modphase=0,mul=1,add=0", + ctor: function(carfreq, modfreq, pmindex, modphase, mul, add) { + var SinOsc = cc.global.SinOsc; + return SinOsc.ar(carfreq, SinOsc.ar(modfreq, modphase, pmindex), mul, add); + } + }, + $kr: { + defaults: "carfreq=0,modfreq=0,pmindex=0,modphase=0,mul=1,add=0", + ctor: function(carfreq, modfreq, pmindex, modphase, mul, add) { + var SinOsc = cc.global.SinOsc; + return SinOsc.kr(carfreq, SinOsc.kr(modfreq, modphase, pmindex), mul, add); + } + } + }; + + cc.ugen.specs.SinOscFB = { + $ar: { + defaults: "freq=440,feedback=0,mul=1,add=0", + ctor: function(freq, feedback, mul, add) { + return this.multiNew(2, freq, feedback).madd(mul, add); + } + }, + $kr: { + defaults: "freq=440,feedback=0,mul=1,add=0", + ctor: function(freq, feedback, mul, add) { + return this.multiNew(1, freq, feedback).madd(mul, add); + } + } + }; + + cc.unit.specs.SinOscFB = (function() { + var ctor = function() { + this.process = next; + this._radtoinc = kSineSize / twopi; + this._cpstoinc = kSineSize * this.rate.sampleDur; + this._mask = kSineMask; + this._table = gSineWavetable; + this._freq = this.inputs[0][0]; + this._feedback = this.inputs[1][0] * this._radtoinc; + this._y = 0; + this._x = 0; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var nextFreq = this.inputs[0][0]; + var nextFeedback = this.inputs[1][0]; + var mask = this._mask; + var table = this._table; + var radtoinc = this._radtoinc; + var cpstoinc = this._cpstoinc; + var freq = this._freq; + var feedback = this._feedback; + var y = this._y; + var x = this._x, pphase, index, i; + if (nextFreq === freq && nextFeedback === feedback) { + freq *= cpstoinc; + feedback *= radtoinc; + for (i = 0; i < inNumSamples; ++i) { + pphase = x + feedback * y; + index = (pphase & mask) << 1; + out[i] = y = table[index] + (pphase-(pphase|0)) * table[index+1]; + x += freq; + } + } else { + var freq_slope = (nextFreq - freq ) * this.rate.slopeFactor; + var feedback_slope = (nextFeedback - feedback) * this.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + pphase = x + radtoinc * feedback * y; + index = (pphase & mask) << 1; + out[i] = y = table[index] + (pphase-(pphase|0)) * table[index+1]; + x += freq * cpstoinc; + freq += freq_slope; + feedback += feedback_slope; + } + this._freq = nextFreq; + this._feedback = nextFeedback; + } + this._y = y; + this._x = x; + }; + return ctor; + })(); + + cc.ugen.specs.OscN = { + $ar: { + defaults: "bufnum=0,freq=440,phase=0,mul=1,add=0", + ctor: function(bufnum, freq, phase, mul, add) { + return this.multiNew(2, bufnum, freq, phase).madd(mul, add); + } + }, + $kr: { + defaults: "bufnum=0,freq=440,phase=0,mul=1,add=0", + ctor: function(bufnum, freq, phase, mul, add) { + return this.multiNew(1, bufnum, freq, phase).madd(mul, add); + } + } + }; + + cc.unit.specs.OscN = (function() { + var ctor = function() { + this._bufnumIn = this.inputs[0]; + this._freq = this.inputs[1][0]; + this._phase = this.inputs[2][0]; + this._freqIndex = 1; + this._phaseIndex = 2; + this._radtoinc = 0; + this._cpstoinc = 0; + this._mask = 0; + this._table = null; + this._x = 0; + + switch (this.inRates[0]) { + case 2: + switch (this.inRates[1]) { + case 2 : this.process = next_aa; break; + case 1: this.process = next_ak; break; + case 0 : this.process = next_ai; break; + case 3 : this.process = next_ak; break; + } + break; + default: + switch (this.inRates[1]) { + case 2 : this.process = next_ka; break; + case 1: this.process = next_kk; break; + case 0 : this.process = next_kk; break; + case 3 : this.process = next_kk; break; + } + } + }; + var calc = function(table, mask, pphase) { + return table[pphase & mask]; + }; + var next_aa = function(inNumSamples) { + if (get_table(this, 0)) { + osc_next_aa(this, inNumSamples, calc); + } + }; + var next_ak = function(inNumSamples) { + if (get_table(this, 0)) { + osc_next_ak(this, inNumSamples, calc); + } + }; + var next_ai = function(inNumSamples) { + if (get_table(this, 0)) { + osc_next_ai(this, inNumSamples, calc); + } + }; + var next_ka = function(inNumSamples) { + if (get_table(this, 0)) { + osc_next_ka(this, inNumSamples, calc); + } + }; + var next_kk = function(inNumSamples) { + if (get_table(this, 0)) { + osc_next_kk(this, inNumSamples, calc); + } + }; + return ctor; + })(); + + cc.ugen.specs.FSinOsc = { + $ar: { + defaults: "freq=440,iphase=0,mul=1,add=0", + ctor: function(freq, phase, mul, add) { + return this.multiNew(2, freq, phase).madd(mul, add); + } + }, + $kr: { + defaults: "freq=440,iphase=0,mul=1,add=0", + ctor: function(freq, phase, mul, add) { + return this.multiNew(1, freq, phase).madd(mul, add); + } + } + }; + + cc.unit.specs.FSinOsc = (function() { + var ctor = function() { + this.process = next; + this._freq = this.inputs[0][0]; + var iphase = this.inputs[1][0]; + var w = this._freq * this.rate.radiansPerSample; + this._b1 = 2 * Math.cos(w); + this._y1 = Math.sin(iphase); + this._y2 = Math.sin(iphase - w); + this.outputs[0][0] = this._y1; + }; + var next = function() { + var out = this.outputs[0]; + var freq = this.inputs[0][0]; + var rate = this.rate; + var b1, y0, y1, y2, w, i, j; + if (freq !== this._freq) { + this._freq = freq; + w = freq * rate.radiansPerSample; + this._b1 = b1 = 2 * Math.cos(w); + } else { + b1 = this._b1; + } + y1 = this._y1; + y2 = this._y2; + j = 0; + for (i = rate.filterLoops; i--; ) { + out[j++] = y0 = b1 * y1 - y2; + out[j++] = y2 = b1 * y0 - y1; + out[j++] = y1 = b1 * y2 - y0; + } + for (i = rate.filterRemain; i--; ) { + out[j++] = y0 = b1 * y1 - y2; + y2 = y1; + y1 = y0; + } + this._y1 = y1; + this._y2 = y2; + }; + return ctor; + })(); + + + cc.ugen.specs.Klang = { + $ar: { + defaults: "specificationsArrayRef=0,freqscale=1,freqoffset=0", + ctor: function(specificationsArrayRef, freqscale, freqoffset) { + if (specificationsArrayRef.multichannelExpandRef) { + specificationsArrayRef = specificationsArrayRef.multichannelExpandRef(2); + } else { + specificationsArrayRef = utils.asArray(specificationsArrayRef); + } + return this.multiNewList([2, freqscale, freqoffset, specificationsArrayRef]); + } + }, + init: function() { + var ref = this.inputs.pop(); + var items, freqs, amps, phases; + var specs; + if (ref.dereference) { + items = ref.dereference(); + } else { + items = utils.asArray(items); + } + freqs = items[0] || []; + amps = items[1] || utils.filledArray(freqs.length, 1); + phases = items[2] || utils.filledArray(freqs.length, 0); + specs = utils.flat(utils.flop([ freqs, amps, phases ])); + + specs.push.apply(this.inputs, specs); + + return this; + } + }; + + cc.unit.specs.Klang = (function() { + var ctor = function() { + this.process = next; + + var rate = this.rate; + var numpartials = (this.numInputs - 2) / 3; + var numcoefs = numpartials * 3; + var coefs = new Float32Array(numcoefs); + + var inputs = this.inputs; + var freqscale = inputs[0][0] * rate.radiansPerSample; + var freqoffset = inputs[1][0] * rate.radiansPerSample; + var level, phase; + var outf = 0; + var i, j = 2, k = -1, w; + + for (i = 0; i < numpartials; ++i) { + w = inputs[j++][0] * freqscale + freqoffset; + level = inputs[j++][0]; + phase = inputs[j++][0]; + if (phase !== 0) { + outf += coefs[++k] = level * Math.sin(phase); // y1; + coefs[++k] = level * Math.sin(phase - w); // y2; + } else { + outf += coefs[++k] = 0; // y1; + coefs[++k] = level * -Math.sin(w); // y2; + } + coefs[++k] = 2 * Math.cos(w); // b1 + } + this._numpartials = numpartials; + this._coefs = coefs; + this.outputs[0][0] = outf; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var y0_0, y1_0, y2_0, b1_0; + var y0_1, y1_1, y2_1, b1_1; + var y0_2, y1_2, y2_2, b1_2; + var y0_3, y1_3, y2_3, b1_3; + var outf; + var i, j = 0; + + var rate = this.rate; + var coefs = this._coefs; + var numpartials = this._numpartials; + var n = numpartials >> 2; + + switch (numpartials & 3) { + case 3: + y1_0 = coefs[0]; y2_0 = coefs[1]; b1_0 = coefs[2]; + y1_1 = coefs[3]; y2_1 = coefs[4]; b1_1 = coefs[5]; + y1_2 = coefs[6]; y2_2 = coefs[7]; b1_2 = coefs[8]; + + for (i = rate.filterLoops; i--; ) { + outf = y0_0 = b1_0 * y1_0 - y2_0; + outf += y0_1 = b1_1 * y1_1 - y2_1; + outf += y0_2 = b1_2 * y1_2 - y2_2; + out[j++] = outf; + + outf = y2_0 = b1_0 * y0_0 - y1_0; + outf += y2_1 = b1_1 * y0_1 - y1_1; + outf += y2_2 = b1_2 * y0_2 - y1_2; + out[j++] = outf; + + outf = y1_0 = b1_0 * y2_0 - y0_0; + outf += y1_1 = b1_1 * y2_1 - y0_1; + outf += y1_2 = b1_2 * y2_2 - y0_2; + out[j++] = outf; + } + for (i = rate.filterRemain; i--; ) { + outf = y0_0 = b1_0 * y1_0 - y2_0; + outf += y0_1 = b1_1 * y1_1 - y2_1; + outf += y0_2 = b1_2 * y1_2 - y2_2; + y2_0 = y1_0; y1_0 = y0_0; + y2_1 = y1_1; y1_1 = y0_1; + y2_2 = y1_2; y1_2 = y0_2; + out[j++] = outf; + } + coefs[0] = y1_0; coefs[1] = y2_0; + coefs[3] = y1_1; coefs[4] = y2_1; + coefs[6] = y1_2; coefs[7] = y2_2; + break; + + case 2: + y1_0 = coefs[0]; y2_0 = coefs[1]; b1_0 = coefs[2]; + y1_1 = coefs[3]; y2_1 = coefs[4]; b1_1 = coefs[5]; + + for (i = rate.filterLoops; i--; ) { + outf = y0_0 = b1_0 * y1_0 - y2_0; + outf += y0_1 = b1_1 * y1_1 - y2_1; + out[j++] = outf; + + outf = y2_0 = b1_0 * y0_0 - y1_0; + outf += y2_1 = b1_1 * y0_1 - y1_1; + out[j++] = outf; + + outf = y1_0 = b1_0 * y2_0 - y0_0; + outf += y1_1 = b1_1 * y2_1 - y0_1; + out[j++] = outf; + } + for (i = rate.filterRemain; i--; ) { + outf = y0_0 = b1_0 * y1_0 - y2_0; + outf += y0_1 = b1_1 * y1_1 - y2_1; + y2_0 = y1_0; y1_0 = y0_0; + y2_1 = y1_1; y1_1 = y0_1; + out[j++] = outf; + } + coefs[0] = y1_0; coefs[1] = y2_0; + coefs[3] = y1_1; coefs[4] = y2_1; + break; + + case 1: + y1_0 = coefs[0]; y2_0 = coefs[1]; b1_0 = coefs[2]; + + for (i = rate.filterLoops; i--; ) { + outf = y0_0 = b1_0 * y1_0 - y2_0; + out[j++] = outf; + + outf = y2_0 = b1_0 * y0_0 - y1_0; + out[j++] = outf; + + outf = y1_0 = b1_0 * y2_0 - y0_0; + out[j++] = outf; + } + for (i = rate.filterRemain; i--; ) { + outf = y0_0 = b1_0 * y1_0 - y2_0; + y2_0 = y1_0; y1_0 = y0_0; + out[j++] = outf; + } + coefs[0] = y1_0; coefs[1] = y2_0; + break; + + case 0: + for (i = 0; i < inNumSamples; ++i) { + out[i] = 0; + } + break; + } + + while (n--) { + y1_0 = coefs[0]; y2_0 = coefs[ 1]; b1_0 = coefs[ 2]; + y1_1 = coefs[3]; y2_1 = coefs[ 4]; b1_1 = coefs[ 5]; + y1_2 = coefs[6]; y2_2 = coefs[ 7]; b1_2 = coefs[ 8]; + y1_3 = coefs[9]; y2_3 = coefs[10]; b1_3 = coefs[11]; + + for (i = rate.filterLoops; i--; ) { + outf = y0_0 = b1_0 * y1_0 - y2_0; + outf += y0_1 = b1_1 * y1_1 - y2_1; + outf += y0_2 = b1_2 * y1_2 - y2_2; + outf += y0_3 = b1_3 * y1_3 - y2_3; + out[j++] = outf; + + outf = y2_0 = b1_0 * y0_0 - y1_0; + outf += y2_1 = b1_1 * y0_1 - y1_1; + outf += y2_2 = b1_2 * y0_2 - y1_2; + outf += y2_3 = b1_3 * y0_3 - y1_3; + out[j++] = outf; + + outf = y1_0 = b1_0 * y2_0 - y0_0; + outf += y1_1 = b1_1 * y2_1 - y0_1; + outf += y1_2 = b1_2 * y2_2 - y0_2; + outf += y1_3 = b1_3 * y2_3 - y0_3; + out[j++] = outf; + } + for (i = rate.filterRemain; i--; ) { + outf = y0_0 = b1_0 * y1_0 - y2_0; + outf += y0_1 = b1_1 * y1_1 - y2_1; + outf += y0_2 = b1_2 * y1_2 - y2_2; + outf += y0_3 = b1_3 * y1_3 - y2_3; + y2_0 = y1_0; y1_0 = y0_0; + y2_1 = y1_1; y1_1 = y0_1; + y2_2 = y1_2; y1_2 = y0_2; + y2_3 = y1_3; y1_3 = y0_3; + out[j++] = outf; + } + coefs[0] = y1_0; coefs[ 1] = y2_0; + coefs[3] = y1_1; coefs[ 4] = y2_1; + coefs[6] = y1_2; coefs[ 7] = y2_2; + coefs[9] = y1_3; coefs[10] = y2_3; + } + }; + return ctor; + })(); + + cc.ugen.specs.Klank = { + $ar: { + defaults: "specificationsArrayRef=0,input=0,freqscale=1,freqoffset=0,decayscale=1", + ctor: function(specificationsArrayRef, input, freqscale, freqoffset, decayscale) { + if (specificationsArrayRef.multichannelExpandRef) { + specificationsArrayRef = specificationsArrayRef.multichannelExpandRef(2); + } else { + specificationsArrayRef = utils.asArray(specificationsArrayRef); + } + return this.multiNewList([2, input, freqscale, freqoffset, decayscale, specificationsArrayRef]); + } + }, + init: function() { + var ref = this.inputs.pop(); + var items, freqs, amps, times; + var specs; + if (ref.dereference) { + items = ref.dereference(); + } else { + items = utils.asArray(items); + } + freqs = items[0] || []; + amps = items[1] || utils.filledArray(freqs.length, 1); + times = items[2] || utils.filledArray(freqs.length, 1); + specs = utils.flat(utils.flop([ freqs, amps, times ])); + + specs.push.apply(this.inputs, specs); + + return this; + } + }; + + cc.unit.specs.Klank = (function() { + var ctor = function() { + this.process = next; + + var rate = this.rate; + var numpartials = (this.numInputs - 4) / 3; + var numcoefs = ((numpartials + 3) & ~3) * 5; + var coefs = new Float32Array(numcoefs + this.bufLength); + var buf = new Float32Array(coefs.buffer, numcoefs * 4); + + var inputs = this.inputs; + var freqscale = inputs[1][0] * rate.radiansPerSample; + var freqoffset = inputs[2][0] * rate.radiansPerSample; + var decayscale = inputs[3][0]; + + var level, time; + var R, twoR, R2, cost; + var sampleRate = rate.sampleRate; + + var i, j = 4, k, w; + + for (i = 0; i < numpartials; ++i) { + w = inputs[j++][0] * freqscale + freqoffset; + level = inputs[j++][0]; + time = inputs[j++][0] * decayscale; + R = time === 0 ? 0 : Math.exp(log001 / (time * sampleRate)); + twoR = 2 * R; + R2 = R * R; + cost = (twoR * Math.cos(w)) / (1 + R2); + + k = 20 * (i >> 2) + (i & 3); + coefs[k] = 0; // y1 + coefs[k+4] = 0; // y2 + coefs[k+8] = twoR * cost; // b1 + coefs[k+12] = -R2; // b2 + coefs[k+16] = level * 0.25; // a0 + } + + this._numpartials = numpartials; + this._coefs = coefs; + this._buf = buf; + this._x1 = 0; + this._x2 = 0; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var y0_0, y1_0, y2_0, a0_0, b1_0, b2_0; + var y0_1, y1_1, y2_1, a0_1, b1_1, b2_1; + var y0_2, y1_2, y2_2, a0_2, b1_2, b2_2; + var y0_3, y1_3, y2_3, a0_3, b1_3, b2_3; + var inf; + var i, j = 0; + + var rate = this.rate; + var coefs = this._coefs; + var numpartials = this._numpartials; + var buf = this._buf; + var n = numpartials >> 2; + var k = n * 20; + switch (numpartials & 3) { + case 3: + y1_0 = coefs[k+0]; y2_0 = coefs[k+4]; b1_0 = coefs[k+ 8]; b2_0 = coefs[k+12]; a0_0 = coefs[k+16]; + y1_1 = coefs[k+1]; y2_1 = coefs[k+5]; b1_1 = coefs[k+ 9]; b2_1 = coefs[k+13]; a0_1 = coefs[k+17]; + y1_2 = coefs[k+2]; y2_2 = coefs[k+6]; b1_2 = coefs[k+10]; b2_2 = coefs[k+14]; a0_2 = coefs[k+18]; + for (i = rate.filterLoops; i--; ) { + inf = inIn[j]; + y0_0 = inf + b1_0 * y1_0 + b2_0 * y2_0; + y0_1 = inf + b1_1 * y1_1 + b2_1 * y2_1; + y0_2 = inf + b1_2 * y1_2 + b2_2 * y2_2; + buf[j++] = a0_0 * y0_0 + a0_1 * y0_1 + a0_2 * y0_2; + + inf = inIn[j]; + y2_0 = inf + b1_0 * y0_0 + b2_0 * y1_0; + y2_1 = inf + b1_1 * y0_1 + b2_1 * y1_1; + y2_2 = inf + b1_2 * y0_2 + b2_2 * y1_2; + buf[j++] = a0_0 * y2_0 + a0_1 * y2_1 + a0_2 * y2_2; + + inf = inIn[j]; + y1_0 = inf + b1_0 * y2_0 + b2_0 * y0_0; + y1_1 = inf + b1_1 * y2_1 + b2_1 * y0_1; + y1_2 = inf + b1_2 * y2_2 + b2_2 * y0_2; + buf[j++] = a0_0 * y1_0 + a0_1 * y1_1 + a0_2 * y1_2; + } + for (i = rate.filterRemain; i--; ) { + inf = inIn[j]; + y0_0 = inf + b1_0 * y1_0 + b2_0 * y2_0; + y0_1 = inf + b1_1 * y1_1 + b2_1 * y2_1; + y0_2 = inf + b1_2 * y1_2 + b2_2 * y2_2; + buf[j++] = a0_0 * y0_0 + a0_1 * y0_1 + a0_2 * y0_2; + y2_0 = y1_0; y1_0 = y0_0; + y2_1 = y1_1; y1_1 = y0_1; + y2_2 = y1_2; y1_2 = y0_2; + } + coefs[k+0] = y1_0; coefs[k+4] = y2_0; + coefs[k+1] = y1_1; coefs[k+5] = y2_1; + coefs[k+2] = y1_2; coefs[k+6] = y2_2; + break; + + case 2: + y1_0 = coefs[k+0]; y2_0 = coefs[k+4]; b1_0 = coefs[k+ 8]; b2_0 = coefs[k+12]; a0_0 = coefs[k+16]; + y1_1 = coefs[k+1]; y2_1 = coefs[k+5]; b1_1 = coefs[k+ 9]; b2_1 = coefs[k+13]; a0_1 = coefs[k+17]; + for (i = rate.filterLoops; i--; ) { + inf = inIn[j]; + y0_0 = inf + b1_0 * y1_0 + b2_0 * y2_0; + y0_1 = inf + b1_1 * y1_1 + b2_1 * y2_1; + buf[j++] = a0_0 * y0_0 + a0_1 * y0_1; + + inf = inIn[j]; + y2_0 = inf + b1_0 * y0_0 + b2_0 * y1_0; + y2_1 = inf + b1_1 * y0_1 + b2_1 * y1_1; + buf[j++] = a0_0 * y2_0 + a0_1 * y2_1; + + inf = inIn[j]; + y1_0 = inf + b1_0 * y2_0 + b2_0 * y0_0; + y1_1 = inf + b1_1 * y2_1 + b2_1 * y0_1; + buf[j++] = a0_0 * y1_0 + a0_1 * y1_1; + } + for (i = rate.filterRemain; i--; ) { + inf = inIn[j]; + y0_0 = inf + b1_0 * y1_0 + b2_0 * y2_0; + y0_1 = inf + b1_1 * y1_1 + b2_1 * y2_1; + buf[j++] = a0_0 * y0_0 + a0_1 * y0_1; + y2_0 = y1_0; y1_0 = y0_0; + y2_1 = y1_1; y1_1 = y0_1; + } + coefs[k+0] = y1_0; coefs[k+4] = y2_0; + coefs[k+1] = y1_1; coefs[k+5] = y2_1; + break; + + case 1: + y1_0 = coefs[k+0]; y2_0 = coefs[k+4]; b1_0 = coefs[k+ 8]; b2_0 = coefs[k+12]; a0_0 = coefs[k+16]; + for (i = rate.filterLoops; i--; ) { + inf = inIn[j]; + y0_0 = inf + b1_0 * y1_0 + b2_0 * y2_0; + buf[j++] = a0_0 * y0_0; + + inf = inIn[j]; + y2_0 = inf + b1_0 * y0_0 + b2_0 * y1_0; + buf[j++] = a0_0 * y2_0; + + inf = inIn[j]; + y1_0 = inf + b1_0 * y2_0 + b2_0 * y0_0; + buf[j++] = a0_0 * y1_0; + } + for (i = rate.filterRemain; i--; ) { + inf = inIn[j]; + y0_0 = inf + b1_0 * y1_0 + b2_0 * y2_0; + buf[j++] = a0_0 * y0_0; + y2_0 = y1_0; y1_0 = y0_0; + } + coefs[k+0] = y1_0; coefs[k+4] = y2_0; + break; + + case 0: + for (i = 0; i < inNumSamples; ++i) { + buf[i] = 0; + } + break; + } + + j = k = 0; + while (n--) { + y1_0 = coefs[k+0]; y2_0 = coefs[k+4]; b1_0 = coefs[k+ 8]; b2_0 = coefs[k+12]; a0_0 = coefs[k+16]; + y1_1 = coefs[k+1]; y2_1 = coefs[k+5]; b1_1 = coefs[k+ 9]; b2_1 = coefs[k+13]; a0_1 = coefs[k+17]; + y1_2 = coefs[k+2]; y2_2 = coefs[k+6]; b1_2 = coefs[k+10]; b2_2 = coefs[k+14]; a0_2 = coefs[k+18]; + y1_3 = coefs[k+3]; y2_3 = coefs[k+7]; b1_3 = coefs[k+11]; b2_3 = coefs[k+15]; a0_3 = coefs[k+19]; + for (i = rate.filterLoops; i--; ) { + inf = inIn[j]; + y0_0 = inf + b1_0 * y1_0 + b2_0 * y2_0; + y0_1 = inf + b1_1 * y1_1 + b2_1 * y2_1; + y0_2 = inf + b1_2 * y1_2 + b2_2 * y2_2; + y0_3 = inf + b1_3 * y1_3 + b2_3 * y2_3; + buf[j++] = a0_0 * y0_0 + a0_1 * y0_1 + a0_2 * y0_2 + a0_3 * y0_3; + + inf = inIn[j]; + y2_0 = inf + b1_0 * y0_0 + b2_0 * y1_0; + y2_1 = inf + b1_1 * y0_1 + b2_1 * y1_1; + y2_2 = inf + b1_2 * y0_2 + b2_2 * y1_2; + y2_3 = inf + b1_3 * y0_3 + b2_3 * y1_3; + buf[j++] = a0_0 * y2_0 + a0_1 * y2_1 + a0_2 * y2_2 + a0_3 * y2_3; + + inf = inIn[j]; + y1_0 = inf + b1_0 * y2_0 + b2_0 * y0_0; + y1_1 = inf + b1_1 * y2_1 + b2_1 * y0_1; + y1_2 = inf + b1_2 * y2_2 + b2_2 * y0_2; + y1_3 = inf + b1_3 * y2_3 + b2_3 * y0_3; + buf[j++] = a0_0 * y1_0 + a0_1 * y1_1 + a0_2 * y1_2 + a0_3 * y1_3; + } + for (i = rate.filterRemain; i--; ) { + inf = inIn[j]; + y0_0 = inf + b1_0 * y1_0 + b2_0 * y2_0; + y0_1 = inf + b1_1 * y1_1 + b2_1 * y2_1; + y0_2 = inf + b1_2 * y1_2 + b2_2 * y2_2; + y0_3 = inf + b1_3 * y1_3 + b2_3 * y2_3; + buf[j++] = a0_0 * y0_0 + a0_1 * y0_1 + a0_2 * y0_2 + a0_3 * y0_3; + y2_0 = y1_0; y1_0 = y0_0; + y2_1 = y1_1; y1_1 = y0_1; + y2_2 = y1_2; y1_2 = y0_2; + y2_3 = y1_3; y1_3 = y0_3; + } + coefs[k+0] = y1_0; coefs[k+4] = y2_0; + coefs[k+1] = y1_1; coefs[k+5] = y2_1; + coefs[k+2] = y1_2; coefs[k+6] = y2_2; + coefs[k+3] = y1_3; coefs[k+7] = y2_3; + k += 20; + } + + var x0; + var x1 = this._x1; + var x2 = this._x2; + + j = 0; + for (i = rate.filterLoops; i--;) { + x0 = buf[j]; + out[j++] = x0 - x2; + x2 = buf[j]; + out[j++] = x2 - x1; + x1 = buf[j]; + out[j++] = x1 - x0; + } + for (i = rate.filterRemain; i--;) { + x0 = buf[j]; + out[j++] = x0 - x2; + x2 = x1; + x1 = x0; + } + + this._x1 = x1; + this._x2 = x2; + }; + return ctor; + })(); + + cc.ugen.specs.DynKlank = { + $ar: { + defaults: "specificationsArrayRef=0,input=0,freqscale=1,freqoffset=0,decayscale=1", + ctor: function(specificationsArrayRef, input, freqscale, freqoffset, decayscale) { + if (specificationsArrayRef.multichannelExpandRef) { + specificationsArrayRef = specificationsArrayRef.multichannelExpandRef(2); + } else { + specificationsArrayRef = utils.asArray(specificationsArrayRef); + } + return this.multiNewList([2, input, freqscale, freqoffset, decayscale, specificationsArrayRef]); + } + }, + init: function() { + var input = this.inputs[0]; + var freqscale = this.inputs[1]; + var freqoffset = this.inputs[2]; + var decayscale = this.inputs[3]; + var ref = this.inputs[4]; + var items, freqs, decays, amps; + if (ref.dereference) { + items = ref.dereference(); + } else { + items = utils.asArray(items); + } + freqs = items[0] || [ 440 ]; + decays = items[2] || [ 1.0 ]; + amps = items[1] || [ 1.0 ]; + freqs = freqs.madd(freqscale, freqoffset); + decays = decays.madd(decayscale, 0); + + return cc.global.Ringz(this.rate, input, freqs, decays, amps).sum(); + } + }; + + cc.ugen.specs.DynKlang = { + $ar: { + defaults: "specificationsArrayRef=0,freqscale=1,freqoffset=0", + ctor: function(specificationsArrayRef, freqscale, freqoffset) { + if (specificationsArrayRef.multichannelExpandRef) { + specificationsArrayRef = specificationsArrayRef.multichannelExpandRef(2); + } else { + specificationsArrayRef = utils.asArray(specificationsArrayRef); + } + return this.multiNewList([2, freqscale, freqoffset, specificationsArrayRef]); + } + }, + init: function() { + var freqscale = this.inputs[0]; + var freqoffset = this.inputs[1]; + var ref = this.inputs[2]; + var items, freqs, phases, amps; + if (ref.dereference) { + items = ref.dereference(); + } else { + items = utils.asArray(items); + } + freqs = items[0] || [ 440 ]; + phases = items[2] || [ 0.0 ]; + amps = items[1] || [ 1.0 ]; + freqs = freqs.madd(freqscale, freqoffset); + + return cc.global.SinOsc(this.rate, freqs, phases, amps).sum(); + } + }; + + cc.ugen.specs.LFSaw = { + $ar: { + defaults: "freq=440,iphase=0,mul=1,add=0", + ctor: function(freq, iphase, mul, add) { + return this.multiNew(2, freq, iphase).madd(mul, add); + } + }, + $kr: { + defaults: "freq=440,iphase=0,mul=1,add=0", + ctor: function(freq, iphase, mul, add) { + return this.multiNew(1, freq, iphase).madd(mul, add); + } + } + }; + + cc.unit.specs.LFSaw = (function() { + var ctor = function() { + this.process = next; + this._cpstoinc = 2 * this.rate.sampleDur; + this._phase = this.inputs[1][0]; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var freq = this.inputs[0][0] * this._cpstoinc; + var phase = this._phase; + var i; + if (freq >= 0) { + for (i = 0; i < inNumSamples; ++i) { + out[i] = phase; + phase += freq; + if (phase >= 1) { + phase -= 2; + } + } + } else { + for (i = 0; i < inNumSamples; ++i) { + out[i] = phase; + phase += freq; + if (phase <= -1) { + phase += 2; + } + } + } + this._phase = phase; + }; + return ctor; + })(); + + cc.ugen.specs.LFPar = cc.ugen.specs.LFSaw; + + cc.unit.specs.LFPar = (function() { + var ctor = function() { + this.process = next; + this._cpstoinc = 4 * this.rate.sampleDur; + this._phase = this.inputs[1][0]; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var freq = this.inputs[0][0] * this._cpstoinc; + var phase = this._phase; + var z, y; + for (var i = 0; i < inNumSamples; ++i) { + if (phase < 1) { + z = phase; + y = 1 - z * z; + } else if (phase < 3) { + z = phase - 2; + y = z * z - 1; + } else { + phase -= 4; + z = phase; + y = 1 - z * z; + } + out[i] = y; + phase += freq; + } + this._phase = phase; + }; + return ctor; + })(); + + cc.ugen.specs.LFCub = cc.ugen.specs.LFSaw; + + cc.unit.specs.LFCub = (function() { + var ctor = function() { + this.process = next; + this._cpstoinc = 2 * this.rate.sampleDur; + this._phase = this.inputs[1][0] + 0.5; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var freq = this.inputs[0][0] * this._cpstoinc; + var phase = this._phase; + var z; + for (var i = 0; i < inNumSamples; ++i) { + if (phase < 1) { + z = phase; + } else if (phase < 2) { + z = 2 - phase; + } else { + phase -= 2; + z = phase; + } + out[i] = z * z * (6 - 4 * z) - 1; + phase += freq; + } + this._phase = phase; + }; + return ctor; + })(); + + cc.ugen.specs.LFTri = cc.ugen.specs.LFSaw; + + cc.unit.specs.LFTri = (function() { + var ctor = function() { + this.process = next; + this._cpstoinc = 4 * this.rate.sampleDur; + this._phase = this.inputs[1][0]; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var freq = this.inputs[0][0] * this._cpstoinc; + var phase = this._phase; + for (var i = 0; i < inNumSamples; ++i) { + out[i] = phase > 1 ? 2 - phase : phase; + phase += freq; + if (phase >= 3) { + phase -= 4; + } + } + this._phase = phase; + }; + return ctor; + })(); + + cc.ugen.specs.LFPulse = { + $ar: { + defaults: "freq=440,iphase=0,width=0.5,mul=1,add=0", + ctor: function(freq, iphase, width, mul, add) { + return this.multiNew(2, freq, iphase, width).madd(mul, add); + } + }, + $kr: { + defaults: "freq=440,iphase=0,width=0.5,mul=1,add=0", + ctor: function(freq, iphase, width, mul, add) { + return this.multiNew(1, freq, iphase, width).madd(mul, add); + } + } + }; + + cc.unit.specs.LFPulse = (function() { + var ctor = function() { + this.process = next; + this._cpstoinc = this.rate.sampleDur; + this._phase = this.inputs[1][0]; + this._duty = this.inputs[2][0]; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var freq = this.inputs[0][0] * this._cpstoinc; + var nextDuty = this.inputs[2][0]; + var duty = this._duty; + var phase = this._phase; + var z; + for (var i = 0; i < inNumSamples; ++i) { + if (phase > 1) { + phase -= 1; + duty = nextDuty; + z = duty < 0.5 ? 1 : 0; + } else { + z = phase < duty ? 1 : 0; + } + out[i] = z; + phase += freq; + } + this._duty = duty; + this._phase = phase; + }; + return ctor; + })(); + + cc.ugen.specs.Blip = { + $ar: { + defaults: "freq=440,numharm=200,mul=1,add=0", + ctor: function(freq, numharm, mul, add) { + return this.multiNew(2, freq, numharm).madd(mul, add); + } + } + }; + + cc.unit.specs.Blip = (function() { + var ctor = function() { + this.process = next; + this._freq = this.inputs[0][0]; + this._numharm = this.inputs[1][0]|0; + this._cpstoinc = kSineSize * this.rate.sampleDur * 0.5; + var N = this._numharm; + var maxN = Math.max(1, (this.rate.sampleRate * 0.5 / this._freq)|0); + this._N = Math.max(1, Math.min(N, maxN)); + this._mask = kSineMask; + this._scale = 0.5 / this._N; + this._phase = 0; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var freq = this.inputs[0][0]; + var numharm = this.inputs[1][0]|0; + var phase = this._phase; + var mask = this._mask; + var numtbl = gSine, dentbl = gInvSine; + var N, N2, maxN, prevN, prevN2, scale, prevScale, crossfade; + var tblIndex, t0, t1, pfrac, denom, rphase, numer, n1, n2; + var i, xfade, xfade_slope; + if (numharm !== this._numharm || freq !== this._freq) { + N = numharm; + maxN = Math.max(1, (this.rate.sampleRate * 0.5 / this._freq)|0); + if (maxN < N) { + N = maxN; + freq = this._cpstoinc * Math.max(this._freq, freq); + } else { + if (N < 1) { + N = 1; + } + freq = this._cpstoinc * freq; + } + crossfade = (N !== this._N); + prevN = this._N; + prevScale = this._scale; + this._N = Math.max(1, Math.min(N, maxN)); + this._scale = scale = 0.5 / N; + } else { + N = this._N; + freq = this._cpstoinc * freq; + scale = this._scale; + crossfade = false; + } + N2 = 2 * N + 1; + if (crossfade) { + prevN2 = 2 * prevN + 1; + xfade_slope = this.rate.slopeFactor; + xfade = 0; + for (i = 0; i < inNumSamples; ++i) { + tblIndex = phase & mask; + t0 = dentbl[tblIndex]; + t1 = dentbl[tblIndex+1]; + if (t0 === kBadValue || t1 === kBadValue) { + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + pfrac = phase - (phase|0); + denom = t0 + (t1 - t0) * pfrac; + if (Math.abs(denom) < 0.0005) { + out[i] = 1; + } else { + rphase = phase * prevN2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + n1 = (numer / denom - 1) * prevScale; + + rphase = phase * N2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + n2 = (numer / denom - 1) * scale; + + out[i] = n1 + xfade * (n2 - n1); + } + } else { + pfrac = phase - (phase|0); + denom = t0 + (t1 - t0) * pfrac; + + rphase = phase * prevN2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + n1 = (numer * denom - 1) * prevScale; + + rphase = phase * N2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + n2 = (numer * denom - 1) * scale; + + out[i] = n1 + xfade * (n2 - n1); + } + phase += freq; + xfade += xfade_slope; + } + } else { + // hmm, if freq is above sr/4 then revert to sine table osc ? + // why bother, it isn't a common choice for a fundamental. + for (i = 0; i < inNumSamples; ++i) { + tblIndex = phase & mask; + t0 = dentbl[tblIndex]; + t1 = dentbl[tblIndex+1]; + if (t0 === kBadValue || t1 === kBadValue) { + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + pfrac = phase - (phase|0); + denom = t0 + (t1 - t0) * pfrac; + if (Math.abs(denom) < 0.0005) { + out[i] = 1; + } else { + rphase = phase * N2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + out[i] = (numer / denom - 1) * scale; + } + } else { + pfrac = phase - (phase|0); + denom = t0 + (t1 - t0) * pfrac; + rphase = phase * N2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + out[i] = (numer * denom - 1) * scale; + } + phase += freq; + } + } + if (phase >= 65536) { + phase -= 65536; + } + this._phase = phase; + this._freq = this.inputs[0][0]; + this._numharm = numharm; + }; + return ctor; + })(); + + cc.ugen.specs.Saw = { + $ar: { + defaults: "freq=440,mul=1,add=0", + ctor: function(freq, mul, add) { + return this.multiNew(2, freq).madd(mul, add); + } + } + }; + + cc.unit.specs.Saw = (function() { + var ctor = function() { + this.process = next; + this._freq = this.inputs[0][0]; + this._cpstoinc = kSineSize * this.rate.sampleDur * 0.5; + this._N = Math.max(1, (this.rate.sampleRate * 0.5 / this._freq)|0); + this._mask = kSineMask; + this._scale = 0.5 / this._N; + this._phase = 0; + this._y1 = -0.46; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var freq = this.inputs[0][0]; + var phase = this._phase; + var y1 = this._y1; + var mask = this._mask; + var numtbl = gSine, dentbl = gInvSine; + var N, N2, prevN, prevN2, scale, prevScale, crossfade; + var tblIndex, t0, t1, pfrac, denom, rphase, numer, n1, n2; + var i, xfade, xfade_slope; + if (freq !== this._freq) { + N = Math.max(1, (this.rate.sampleRate * 0.5 / freq)|0); + if (N !== this._N) { + freq = this._cpstoinc * Math.max(this._freq, freq); + crossfade = true; + } else { + freq = this._cpstoinc * freq; + crossfade = false; + } + prevN = this._N; + prevScale = this._scale; + this._N = N; + this._scale = scale = 0.5 / N; + } else { + N = this._N; + freq = this._cpstoinc * freq; + scale = this._scale; + crossfade = false; + } + N2 = 2 * N + 1; + if (crossfade) { + prevN2 = 2 * prevN + 1; + xfade_slope = this.rate.slopeFactor; + xfade = 0; + for (i = 0; i < inNumSamples; ++i) { + tblIndex = phase & mask; + t0 = dentbl[tblIndex]; + t1 = dentbl[tblIndex+1]; + if (t0 === kBadValue || t1 === kBadValue) { + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + pfrac = phase - (phase|0); + denom = t0 + (t1 - t0) * pfrac; + if (Math.abs(denom) < 0.0005) { + out[i] = y1 = 1 + 0.999 * y1; + } else { + rphase = phase * prevN2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + n1 = (numer / denom - 1) * prevScale; + + rphase = phase * N2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + n2 = (numer / denom - 1) * scale; + + out[i] = y1 = n1 + xfade * (n2 - n1) + 0.999 * y1; + } + } else { + pfrac = phase - (phase|0); + denom = t0 + (t1 - t0) * pfrac; + + rphase = phase * prevN2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + n1 = (numer * denom - 1) * prevScale; + + rphase = phase * N2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + n2 = (numer * denom - 1) * scale; + + out[i] = y1 = n1 + xfade * (n2 - n1) + 0.999 * y1; + } + phase += freq; + xfade += xfade_slope; + } + } else { + // hmm, if freq is above sr/4 then revert to sine table osc ? + // why bother, it isn't a common choice for a fundamental. + for (i = 0; i < inNumSamples; ++i) { + tblIndex = phase & mask; + t0 = dentbl[tblIndex]; + t1 = dentbl[tblIndex+1]; + if (t0 === kBadValue || t1 === kBadValue) { + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + pfrac = phase - (phase|0); + denom = t0 + (t1 - t0) * pfrac; + if (Math.abs(denom) < 0.0005) { + out[i] = y1 = 1 + 0.999 * y1; + } else { + rphase = phase * N2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + out[i] = y1 = (numer / denom - 1) * scale + 0.999 * y1; + } + } else { + pfrac = phase - (phase|0); + denom = t0 + (t1 - t0) * pfrac; + rphase = phase * N2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + out[i] = y1 = (numer * denom - 1) * scale + 0.999 * y1; + } + phase += freq; + } + } + if (phase >= 65536) { phase -= 65536; } + this._y1 = y1; + this._phase = phase; + this._freq = this.inputs[0][0]; + }; + return ctor; + })(); + + cc.ugen.specs.Pulse = { + $ar: { + defaults: "freq=440,width=0.5,mul=1,add=0", + ctor: function(freq, width, mul, add) { + return this.multiNew(2, freq, width).madd(mul, add); + } + } + }; + + cc.unit.specs.Pulse = (function() { + var ctor = function() { + this.process = next; + this._freq = this.inputs[0][0]; + this._cpstoinc = kSineSize * this.rate.sampleDur * 0.5; + this._N = Math.max(1, (this.rate.sampleRate * 0.5 / this._freq)|0); + this._mask = kSineMask; + this._scale = 0.5 / this._N; + this._phase = 0; + this._duty = 0; + this._y1 = 0; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var freq = this.inputs[0][0]; + var duty = this._duty; + var phase = this._phase; + var y1 = this._y1; + var mask = this._mask; + var numtbl = gSine, dentbl = gInvSine; + var N, N2, prevN, prevN2, scale, prevScale, crossfade; + var tblIndex, t0, t1, pfrac, denom, rphase, numer, n1, n2; + var phase2, nextDuty, duty_slope, rscale, pul1, pul2; + var i, xfade, xfade_slope; + if (freq !== this._freq) { + N = Math.max(1, (this.rate.sampleRate * 0.5 / freq)|0); + if (N !== this._N) { + freq = this._cpstoinc * Math.max(this._freq, freq); + crossfade = true; + } else { + freq = this._cpstoinc * freq; + crossfade = false; + } + prevN = this._N; + prevScale = this._scale; + this._N = N; + this._scale = scale = 0.5 / N; + } else { + N = this._N; + freq = this._cpstoinc * freq; + scale = this._scale; + crossfade = false; + } + N2 = 2 * N + 1; + + nextDuty = this.inputs[1][0]; + duty_slope = (nextDuty - duty) * this.rate.slopeFactor; + rscale = 1 / scale + 1; + if (crossfade) { + prevN2 = 2 * prevN + 1; + xfade_slope = this.rate.slopeFactor; + xfade = 0; + for (i = 0; i < inNumSamples; ++i) { + tblIndex = phase & mask; + t0 = dentbl[tblIndex]; + t1 = dentbl[tblIndex+1]; + if (t0 === kBadValue || t1 === kBadValue) { + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + pfrac = phase - (phase|0); + denom = t0 + (t1 - t0) * pfrac; + if (Math.abs(denom) < 0.0005) { + pul1 = 1; + } else { + rphase = phase * prevN2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + n1 = (numer / denom - 1) * prevScale; + + rphase = phase * N2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + n2 = (numer / denom - 1) * scale; + + pul1 = n1 + xfade * (n2 - n1); + } + } else { + pfrac = phase - (phase|0); + denom = t0 + (t1 - t0) * pfrac; + + rphase = phase * prevN2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + n1 = (numer * denom - 1) * prevScale; + + rphase = phase * N2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + n2 = (numer * denom - 1) * scale; + + pul1 = n1 + xfade * (n2 - n1); + } + + phase2 = phase + (duty * kSineSize * 0.5); + tblIndex = phase2 & mask; + t0 = dentbl[tblIndex]; + t1 = dentbl[tblIndex+1]; + if (t0 === kBadValue || t1 === kBadValue) { + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + pfrac = phase2 - (phase2|0); + denom = t0 + (t1 - t0) * pfrac; + if (Math.abs(denom) < 0.0005) { + pul2 = 1; + } else { + rphase = phase2 * prevN2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + n1 = (numer / denom - 1) * prevScale; + + rphase = phase2 * N2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + n2 = (numer / denom - 1) * scale; + + pul2 = n1 + xfade * (n2 - n1); + } + } else { + pfrac = phase2 - (phase2|0); + denom = t0 + (t1 - t0) * pfrac; + + rphase = phase2 * prevN2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + n1 = (numer * denom - 1) * prevScale; + + rphase = phase2 * N2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + n2 = (numer * denom - 1) * scale; + + pul2 = n1 + xfade * (n2 - n1); + } + out[i] = y1 = pul1 - pul2 + 0.999 * y1; + phase += freq; + duty += duty_slope; + xfade += xfade_slope; + } + } else { + for (i = 0; i < inNumSamples; ++i) { + tblIndex = phase & mask; + t0 = dentbl[tblIndex]; + t1 = dentbl[tblIndex+1]; + if (t0 === kBadValue || t1 === kBadValue) { + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + pfrac = phase - (phase|0); + denom = t0 + (t1 - t0) * pfrac; + if (Math.abs(denom) < 0.0005) { + pul1 = rscale; + } else { + rphase = phase * N2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + pul1 = numer / denom; + } + } else { + pfrac = phase - (phase|0); + denom = t0 + (t1 - t0) * pfrac; + rphase = phase * N2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + pul1 = numer * denom; + } + + phase2 = phase + (duty * kSineSize * 0.5); + tblIndex = phase2 & mask; + t0 = dentbl[tblIndex]; + t1 = dentbl[tblIndex+1]; + if (t0 === kBadValue || t1 === kBadValue) { + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + pfrac = phase2 - (phase2|0); + denom = t0 + (t1 - t0) * pfrac; + if (Math.abs(denom) < 0.0005) { + pul2 = rscale; + } else { + rphase = phase2 * N2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + pul2 = numer / denom; + } + } else { + pfrac = phase2 - (phase2|0); + denom = t0 + (t1 - t0) * pfrac; + rphase = phase2 * N2; + pfrac = rphase - (rphase|0); + tblIndex = rphase & mask; + t0 = numtbl[tblIndex]; + t1 = numtbl[tblIndex+1]; + numer = t0 + (t1 - t0) * pfrac; + pul2 = numer * denom; + } + out[i] = y1 = (pul1 - pul2) * scale + 0.999 * y1; + phase += freq; + duty += duty_slope; + } + } + if (phase >= 65536) { phase -= 65536; } + this._y1 = y1; + this._phase = phase; + this._freq = this.inputs[0][0]; + this._duty = nextDuty; + }; + return ctor; + })(); + + cc.ugen.specs.Impulse = { + $ar: { + defaults: "freq=440,phase=0,mul=1,add=0", + ctor: function(freq, phase, mul, add) { + return this.multiNew(2, freq, phase).madd(mul, add); + } + }, + $kr: { + defaults: "freq=440,phase=0,mul=1,add=0", + ctor: function(freq, phase, mul, add) { + return this.multiNew(1, freq, phase).madd(mul, add); + } + } + }; + + cc.unit.specs.Impulse = (function() { + var ctor = function() { + this._phase = this.inputs[1][0]; + if (this.inRates[0] === 2) { + this.process = next_a; + if (this.inRates[1] !== 0) { + this._phase = 1; + } + } else { + this.process = next_k; + if (this.inRates[1] !== 0) { + this._phase = 1; + } + } + this._phaseOffset = 0; + this._cpstoinc = this.rate.sampleDur; + if (this._phase === 0) { + this._phase = 1; + } + }; + var next_a = function(inNumSamples) { + var out = this.outputs[0]; + var freqIn = this.inputs[0]; + var phaseOffset = this.inputs[1][0]; + var cpstoinc = this._cpstoinc; + var phase = this._phase; + var prevPhaseOffset = this._phaseOffset; + var phase_slope = (phaseOffset - prevPhaseOffset) * this.rate.slopeFactor; + phase += prevPhaseOffset; + for (var i = 0; i < inNumSamples; ++i) { + phase += phase_slope; + if (phase >= 1) { + phase -= 1; + out[i] = 1; + } else { + out[i] = 0; + } + phase += freqIn[i] * cpstoinc; + } + this._phase = phase - phaseOffset; + this._phaseOffset = phaseOffset; + }; + var next_k = function(inNumSamples) { + var out = this.outputs[0]; + var freq = this.inputs[0][0] * this._cpstoinc; + var phaseOffset = this.inputs[1][0]; + var phase = this._phase; + var prevPhaseOffset = this._phaseOffset; + var phase_slope = (phaseOffset - prevPhaseOffset) * this.rate.slopeFactor; + phase += prevPhaseOffset; + for (var i = 0; i < inNumSamples; ++i) { + phase += phase_slope; + if (phase >= 1) { + phase -= 1; + out[i] = 1; + } else { + out[i] = 0; + } + phase += freq; + } + this._phase = phase - phaseOffset; + this._phaseOffset = phaseOffset; + }; + return ctor; + })(); + + cc.ugen.specs.TrigImpulse = { + $ar: { + defaults: "trig=0,freq=440,phase=0,mul=1,add=0", + ctor: function(trig, freq, phase, mul, add) { + return this.multiNew(2, trig, freq, phase).madd(mul, add); + } + }, + $kr: { + defaults: "trig=0,freq=440,phase=0,mul=1,add=0", + ctor: function(trig, freq, phase, mul, add) { + return this.multiNew(1, trig, freq, phase).madd(mul, add); + } + } + }; + + cc.unit.specs.TrigImpulse = (function() { + var ctor = function() { + this._phase = this.inputs[2][0]; + if (this.inRates[1] === 2) { + this.process = next_ka; + if (this.inRates[2] !== 0) { + this._phase = 1; + } + } else { + this.process = next_kk; + if (this.inRates[2] !== 0) { + this._phase = 1; + } + } + this._phaseOffset = 0; + this._cpstoinc = this.rate.sampleDur; + if (this._phase === 0) { + this._phase = 1; + } + this._prevTrig = this.inputs[0][0]; + }; + var next_ka = function(inNumSamples) { + var out = this.outputs[0]; + var trig = this.inputs[0]; + var freqIn = this.inputs[1]; + var phaseOffset = this.inputs[2][0]; + var cpstoinc = this._cpstoinc; + var phase = this._phase; + var prevPhaseOffset = this._phaseOffset; + var phase_slope = (phaseOffset - prevPhaseOffset) * this.rate.slopeFactor; + var prevTrig = this._prevTrig; + if (trig > 0 && prevTrig <= 0) { + phase = phaseOffset; + if (this.inRates[2] !== 0) { + phase = 1; + } + if (phase === 0) { + phase = 1; + } + } + phase += prevPhaseOffset; + for (var i = 0; i < inNumSamples; ++i) { + phase += phase_slope; + if (phase >= 1) { + phase -= 1; + out[i] = 1; + } else { + out[i] = 0; + } + phase += freqIn[i] * cpstoinc; + } + this._phase = phase - phaseOffset; + this._phaseOffset = phaseOffset; + this._prevTrig = trig; + }; + var next_kk = function(inNumSamples) { + var out = this.outputs[0]; + var trig = this.inputs[0][0]; + var freq = this.inputs[1][0] * this._cpstoinc; + var phaseOffset = this.inputs[2][0]; + var phase = this._phase; + var prevPhaseOffset = this._phaseOffset; + var phase_slope = (phaseOffset - prevPhaseOffset) * this.rate.slopeFactor; + var prevTrig = this._prevTrig; + if (trig > 0 && prevTrig <= 0) { + phase = phaseOffset; + if (this.inRates[2] !== 0) { + phase = 1; + } + if (phase === 0) { + phase = 1; + } + } + phase += prevPhaseOffset; + for (var i = 0; i < inNumSamples; ++i) { + phase += phase_slope; + if (phase >= 1) { + phase -= 1; + out[i] = 1; + } else { + out[i] = 0; + } + phase += freq; + } + this._phase = phase - phaseOffset; + this._phaseOffset = phaseOffset; + this._prevTrig = trig; + }; + return ctor; + })(); + + cc.ugen.specs.SyncSaw = { + $ar: { + defaults: "syncFreq=440,sawFreq=440,mul=1,add=0", + ctor: function(syncFreq, sawFreq, mul, add) { + return this.multiNew(2, syncFreq, sawFreq).madd(mul, add); + } + }, + $kr: { + defaults: "syncFreq=440,sawFreq=440,mul=1,add=0", + ctor: function(syncFreq, sawFreq, mul, add) { + return this.multiNew(1, syncFreq, sawFreq).madd(mul, add); + } + } + }; + + cc.unit.specs.SyncSaw = (function() { + var ctor = function() { + if (this.inRates[0] === 2) { + if (this.inRates[1] === 2) { + this.process = next_aa; + } else { + this.process = next_ak; + } + } else { + if (this.inRates[1] === 2) { + this.process = next_ka; + } else { + this.process = next_kk; + } + } + this._freqMul = 2 * this.rate.sampleDur; + this._phase1 = 0; + this._phase2 = 0; + next_kk.call(this, 1); + }; + var next_aa = function(inNumSamples) { + var out = this.outputs[0]; + var freq1In = this.inputs[0]; + var freq2In = this.inputs[1]; + var freqMul = this._freqMul; + var phase1 = this._phase1; + var phase2 = this._phase2; + var freq1x, freq2x, z; + for (var i = 0; i < inNumSamples; ++i) { + freq1x = freq1In[i] * freqMul; + freq2x = freq2In[i] * freqMul; + z = phase2; + phase2 += freq2x; + if (phase2 >= 1) { + phase2 -= 2; + } + phase1 += freq1x; + if (phase1 >= 1) { + phase1 -= 2; + phase2 = (phase1 + 1) * freq2x / freq1x - 1; + } + out[i] = z; + } + this._phase1 = phase1; + this._phase2 = phase2; + }; + var next_ak = function(inNumSamples) { + var out = this.outputs[0]; + var freq1In = this.inputs[0]; + var freq2In = this.inputs[1]; + var freqMul = this._freqMul; + var phase1 = this._phase1; + var phase2 = this._phase2; + var freq1x, freq2x, z; + freq2x = freq2In[0] * freqMul; + for (var i = 0; i < inNumSamples; ++i) { + freq1x = freq1In[i] * freqMul; + z = phase2; + phase2 += freq2x; + if (phase2 >= 1) { + phase2 -= 2; + } + phase1 += freq1x; + if (phase1 >= 1) { + phase1 -= 2; + phase2 = (phase1 + 1) * freq2x / freq1x - 1; + } + out[i] = z; + } + this._phase1 = phase1; + this._phase2 = phase2; + }; + var next_ka = function(inNumSamples) { + var out = this.outputs[0]; + var freq1In = this.inputs[0]; + var freq2In = this.inputs[1]; + var freqMul = this._freqMul; + var phase1 = this._phase1; + var phase2 = this._phase2; + var freq1x, freq2x, z; + freq1x = freq1In[0] * freqMul; + for (var i = 0; i < inNumSamples; ++i) { + freq2x = freq2In[i] * freqMul; + z = phase2; + phase2 += freq2x; + if (phase2 >= 1) { + phase2 -= 2; + } + phase1 += freq1x; + if (phase1 >= 1) { + phase1 -= 2; + phase2 = (phase1 + 1) * freq2x / freq1x - 1; + } + out[i] = z; + } + this._phase1 = phase1; + this._phase2 = phase2; + }; + var next_kk = function(inNumSamples) { + var out = this.outputs[0]; + var freq1x = this.inputs[0][0] * this._freqMul; + var freq2x = this.inputs[1][0] * this._freqMul; + var phase1 = this._phase1; + var phase2 = this._phase2; + var z; + for (var i = 0; i < inNumSamples; ++i) { + z = phase2; + phase2 += freq2x; + if (phase2 >= 1) { + phase2 -= 2; + } + phase1 += freq1x; + if (phase1 >= 1) { + phase1 -= 2; + phase2 = (phase1 + 1) * freq2x / freq1x - 1; + } + out[i] = z; + } + this._phase1 = phase1; + this._phase2 = phase2; + }; + return ctor; + })(); + + cc.ugen.specs.Select = { + $ar: { + defaults: "which=0,array=[]", + ctor: function(which, array) { + return this.multiNewList([2, which].concat(array)); + } + }, + $kr: { + defaults: "which=0,array=[]", + ctor: function(which, array) { + return this.multiNewList([1, which].concat(array)); + } + }, + checkInputs: function() { + if (this.rate === 2) { + var inputs = this.inputs; + for (var i = 1, imax = inputs.length; i < imax; ++i) { + if (inputs[i].rate !== 2) { + throw new Error("input was not audio rate:" + inputs[i].toString()); + } + } + } + } + }; + + cc.unit.specs.Select = (function() { + var ctor = function() { + if (this.bufLength === 1) { + this.process = next_1; + } else if (this.inRates[0] === 2) { + this.process = next_a; + } else { + this.process = next_k; + } + this._maxIndex = this.inputs.length - 1; + next_1.call(this); + }; + var next_a = function(inNumSamples) { + var out = this.outputs[0]; + var inputs = this.inputs; + var whichIn = inputs[0]; + var maxIndex = this._maxIndex; + var index; + for (var i = 0; i < inNumSamples; ++i) { + index = Math.max(1, Math.min((whichIn[i]|0) + 1, maxIndex)); + out[i] = inputs[index][i]; + } + }; + var next_k = function() { + var index = Math.max(1, Math.min((this.inputs[0][0]|0) + 1, this._maxIndex)); + this.outputs[0].set(this.inputs[index]); + }; + var next_1 = function() { + var index = Math.max(1, Math.min((this.inputs[0][0]|0) + 1, this._maxIndex)); + this.outputs[0][0] = this.inputs[index][0]; + }; + return ctor; + })(); + + cc.ugen.specs.DC = { + $ir: { + defaults: "in=0", + ctor: function(_in) { + return this.multiNew(0, _in); + } + }, + $kr: { + defaults: "in=0", + ctor: function(_in) { + return this.multiNew(1, _in); + } + }, + $ar: { + defaults: "in=0", + ctor: function(_in) { + return this.multiNew(2, _in); + } + } + }; + + cc.unit.specs.DC = (function() { + var ctor = function() { + var out = this.outputs[0]; + var val = this.inputs[0][0]; + for (var i = out.length; i--; ) { + out[i] = val; + } + }; + return ctor; + })(); + + cc.ugen.specs.Silent = { + $ir: { + ctor: function() { + return cc.global.DC.ir(0); + } + }, + $kr: { + ctor: function() { + return cc.global.DC.kr(0); + } + }, + $ar: { + ctor: function() { + return cc.global.DC.ar(0); + } + } + }; + + module.exports = {}; + +}); +define('cc/plugins/pan', function(require, exports, module) { + + var cc = require("../cc"); + var gSine = require("./utils").gSine; + var slice = [].slice; + + cc.ugen.specs.Pan2 = { + Klass: cc.MultiOutUGen, + $ar: { + defaults: "in=0,pos=0,level=1", + ctor: function(_in, pos, level) { + return this.multiNew(2, _in, pos, level); + } + }, + $kr: { + defaults: "in=0,pos=0,level=1", + ctor: function(_in, pos, level) { + return this.multiNew(1, _in, pos, level); + } + }, + init: function() { + this.inputs = slice.call(arguments); + this.channels = [ + cc.createOutputProxy(this.rate, this, 0), + cc.createOutputProxy(this.rate, this, 1) + ]; + this.numOutputs = 2; + return this.channels; + }, + checkInputs: function() { + return cc.ugen.checkNInputs.call(this, 1); + } + }; + + cc.unit.specs.Pan2 = (function() { + var ctor = function() { + if (this.inRates[1] === 2) { + this.process = next_a; + } else { + this.process = next_k; + } + this._pos = this.inputs[1][0]; + this._level = this.inputs[2][0]; + var ipos = (1024 * this._pos + 1024 + 0.5)|0; + ipos = Math.max(0, Math.min(ipos, 2048)); + this._leftAmp = this._level * gSine[2048 - ipos]; + this._rightAmp = this._level * gSine[ipos]; + next_a.call(this, 1); + }; + var next_a = function(inNumSamples) { + var leftOut = this.outputs[0]; + var rightOut = this.outputs[1]; + var inIn = this.inputs[0]; + var posIn = this.inputs[1]; + var nextLevel = this.inputs[2][0]; + var level = this._level; + var i, _in, ipos, leftAmp, rightAmp; + if (level !== nextLevel) { + var level_slope = (nextLevel - level) * this.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + ipos = (1024 * posIn[i] + 1024 + 0.5)|0; + ipos = Math.max(0, Math.min(ipos, 2048)); + leftAmp = level * gSine[2048 - ipos]; + rightAmp = level * gSine[ipos]; + _in = inIn[i]; + leftOut[i] = _in * leftAmp; + rightOut[i] = _in * rightAmp; + level += level_slope; + } + this._level = nextLevel; + } else { + for (i = 0; i < inNumSamples; ++i) { + ipos = (1024 * posIn[i] + 1024 + 0.5)|0; + ipos = Math.max(0, Math.min(ipos, 2048)); + leftAmp = level * gSine[2048 - ipos]; + rightAmp = level * gSine[ipos]; + _in = inIn[i]; + leftOut[i] = _in * leftAmp; + rightOut[i] = _in * rightAmp; + } + } + }; + var next_k = function(inNumSamples) { + var leftOut = this.outputs[0]; + var rightOut = this.outputs[1]; + var inIn = this.inputs[0]; + var nextPos = this.inputs[1][0]; + var nextLevel = this.inputs[2][0]; + var leftAmp = this._leftAmp; + var rightAmp = this._rightAmp; + var i, _in; + if (this._pos !== nextPos || this._level !== nextLevel) { + var ipos = (1024 * nextPos + 1024 + 0.5)|0; + ipos = Math.max(0, Math.min(ipos, 2048)); + var nextLeftAmp = nextLevel * gSine[2048 - ipos]; + var nextRightAmp = nextLevel * gSine[ipos]; + var slopeFactor = this.rate.slopeFactor; + var leftAmp_slope = (nextLeftAmp - leftAmp ) * slopeFactor; + var rightAmp_slope = (nextRightAmp - rightAmp) * slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + _in = inIn[i]; + leftOut[i] = _in * leftAmp; + rightOut[i] = _in * rightAmp; + leftAmp += leftAmp_slope; + rightAmp += rightAmp_slope; + } + this._pos = nextPos; + this._level = nextLevel; + this._leftAmp = nextLeftAmp; + this._rightAmp = nextRightAmp; + } else { + for (i = 0; i < inNumSamples; ++i) { + _in = inIn[i]; + leftOut[i] = _in * leftAmp; + rightOut[i] = _in * rightAmp; + } + } + }; + return ctor; + })(); + + cc.ugen.specs.XFade2 = { + $ar: { + defaults: "inA=0,inB=0,pan=0,level=1", + ctor: function(inA, inB, pan, level) { + return this.multiNew(2, inA, inB, pan, level); + } + }, + $kr: { + defaults: "inA=0,inB=0,pan=0,level=1", + ctor: function(inA, inB, pan, level) { + return this.multiNew(1, inA, inB, pan, level); + } + }, + checkInputs: function() { + return cc.ugen.checkNInputs.call(this, 2); + } + }; + + cc.unit.specs.XFade2 = (function() { + var ctor = function() { + if (this.inRates[2] === 2) { + this.process = next_a; + } else { + this.process = next_k; + } + this._pos = this.inputs[2][0]; + this._level = this.inputs[3][0]; + var ipos = (1024 * this._pos + 1024 + 0.5)|0; + ipos = Math.max(0, Math.min(ipos, 2048)); + this._leftAmp = this._level * gSine[2048 - ipos]; + this._rightAmp = this._level * gSine[ipos]; + next_k.call(this, 1); + }; + var next_a = function(inNumSamples) { + var out = this.outputs[0]; + var leftIn = this.inputs[0]; + var rightIn = this.inputs[1]; + var posIn = this.inputs[2]; + var nextLevel = this.inputs[3][0]; + var leftAmp = this._leftAmp; + var rightAmp = this._rightAmp; + var level = this._level; + var i, ipos; + if (level !== nextLevel) { + var level_slope = (nextLevel - this._level) * this.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + ipos = (1024 * posIn[i] + 1024 + 0.5)|0; + ipos = Math.max(0, Math.min(ipos, 2048)); + leftAmp = level * gSine[2048 - ipos]; + rightAmp = level * gSine[ipos]; + out[i] = leftIn[i] * leftAmp + rightIn[i] * rightAmp; + level += level_slope; + } + this._level = nextLevel; + } else { + for (i = 0; i < inNumSamples; ++i) { + ipos = (1024 * posIn[i] + 1024 + 0.5)|0; + ipos = Math.max(0, Math.min(ipos, 2048)); + leftAmp = level * gSine[2048 - ipos]; + rightAmp = level * gSine[ipos]; + out[i] = leftIn[i] * leftAmp + rightIn[i] * rightAmp; + } + } + }; + var next_k = function(inNumSamples) { + var out = this.outputs[0]; + var leftIn = this.inputs[0]; + var rightIn = this.inputs[1]; + var nextPos = this.inputs[2][0]; + var nextLevel = this.inputs[3][0]; + var leftAmp = this._leftAmp; + var rightAmp = this._rightAmp; + var i; + if (this._pos !== nextPos || this._level !== nextLevel) { + var ipos = (1024 * nextPos + 1024 + 0.5)|0; + ipos = Math.max(0, Math.min(ipos, 2048)); + var nextLeftAmp = nextLevel * gSine[2048 - ipos]; + var nextRightAmp = nextLevel * gSine[ipos]; + var slopeFactor = this.rate.slopeFactor; + var leftAmp_slope = (nextLeftAmp - leftAmp ) * slopeFactor; + var rightAmp_slope = (nextRightAmp - rightAmp) * slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + out[i] = leftIn[i] * leftAmp + rightIn[i] * rightAmp; + leftAmp += leftAmp_slope; + rightAmp += rightAmp_slope; + } + this._pos = nextPos; + this._level = nextLevel; + this._leftAmp = nextLeftAmp; + this._rightAmp = nextRightAmp; + } else { + for (i = 0; i < inNumSamples; ++i) { + out[i] = leftIn[i] * leftAmp + rightIn[i] * rightAmp; + } + } + }; + return ctor; + })(); + + cc.ugen.specs.LinXFade2 = { + $ar: { + defaults: "inA=0,inB=0,pan=0,level=1", + ctor: function(inA, inB, pan, level) { + return this.multiNew(2, inA, inB, pan).__mul__(level); + } + }, + $kr: { + defaults: "inA=0,inB=0,pan=0,level=1", + ctor: function(inA, inB, pan, level) { + return this.multiNew(1, inA, inB, pan).__mul__(level); + } + }, + checkInputs: function() { + return cc.ugen.checkNInputs.call(this, 2); + } + }; + + cc.unit.specs.LinXFade2 = (function() { + var ctor = function() { + if (this.inRates[2] === 2) { + this.process = next_a; + } else { + this.process = next_k; + } + this._pos = Math.max(-1, Math.min(this.inputs[2][0], 1)); + this._amp = this._pos * 0.5 + 0.5; + next_a.call(this, 1); + }; + var next_a = function(inNumSamples) { + var out = this.outputs[0]; + var leftIn = this.inputs[0]; + var rightIn = this.inputs[1]; + var posIn = this.inputs[2]; + var pos, amp; + for (var i = 0; i < inNumSamples; ++i) { + pos = Math.max(-1, Math.min(posIn[i], 1)); + amp = pos * 0.5 + 0.5; + out[i] = leftIn[i] + amp * (rightIn[i] - leftIn[i]); + } + }; + var next_k = function(inNumSamples) { + var out = this.outputs[0]; + var leftIn = this.inputs[0]; + var rightIn = this.inputs[1]; + var nextPos = this.inputs[2][0]; + var amp = this._amp; + var i, pos; + if (this._pos !== nextPos) { + pos = Math.max(-1, Math.min(nextPos, 1)); + var nextAmp = pos * 0.5 + 0.5; + var amp_slope = (nextAmp - amp) * this.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + out[i] = leftIn[i] + amp * (rightIn[i] - leftIn[i]); + amp += amp_slope; + } + this._pos = nextPos; + this._amp = nextAmp; + } else { + for (i = 0; i < inNumSamples; ++i) { + out[i] = leftIn[i] + amp * (rightIn[i] - leftIn[i]); + } + } + }; + return ctor; + })(); + + module.exports = {}; + +}); +define('cc/plugins/random', function(require, exports, module) { + + var cc = require("../cc"); + + cc.ugen.specs.Rand = { + $new: { + defaults: "lo=0,hi=1", + ctor: function(lo, hi) { + return this.multiNew(0, lo, hi); + } + } + }; + + cc.unit.specs.Rand = (function() { + var ctor = function() { + var lo = this.inputs[0][0]; + var hi = this.inputs[1][0]; + var range = hi - lo; + this.outputs[0][0] = Math.random() * range + lo; + }; + return ctor; + })(); + + cc.ugen.specs.IRand = { + $new: { + defaults: "lo=0,hi=127", + ctor: function(lo, hi) { + return this.multiNew(0, lo, hi); + } + } + }; + + cc.unit.specs.IRand = (function() { + var ctor = function() { + var lo = this.inputs[0][0]; + var hi = this.inputs[1][0]; + var range = hi - lo; + this.outputs[0][0] = (Math.random() * range + lo)|0; + }; + return ctor; + })(); + + cc.ugen.specs.TRand = { + $ar: { + defaults: "lo=0,hi=1,trig=1", + ctor: function(lo, hi, trig) { + return this.multiNew(2, lo, hi, trig); + } + }, + $kr: { + defaults: "lo=0,hi=1,trig=1", + ctor: function(lo, hi, trig) { + return this.multiNew(1, lo, hi, trig); + } + } + }; + + cc.unit.specs.TRand = (function() { + var ctor = function() { + if (this.calcRate === 2) { + this.process = next_a; + } else { + this.process = next_k; + } + var lo = this.inputs[0][0]; + var hi = this.inputs[1][0]; + var range = hi - lo; + this.outputs[0][0] = this._value = Math.random() * range + lo; + this._trig = this.inputs[2][0]; + }; + var next_k = function() { + var out = this.outputs[0]; + var trig = this.inputs[2][0]; + if (trig > 0 && this._trig <= 0) { + var lo = this.inputs[0][0]; + var hi = this.inputs[1][0]; + var range = hi - lo; + out[0] = this._value = Math.random() * range + lo; + } else { + out[0] = this._value; + } + this._trig = trig; + }; + var next_a = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[2]; + var value = this._value; + var prev = this._trig; + var next; + for (var i = 0; i < inNumSamples; ++i) { + next = trigIn[i]; + if (next > 0 && prev <= 0) { + var lo = this.inputs[0][0]; + var hi = this.inputs[1][0]; + var range = hi - lo; + out[i] = value = Math.random() * range + lo; + } else { + out[i] = value; + } + prev = next; + } + this._trig = next; + this._value = value; + }; + return ctor; + })(); + + cc.ugen.specs.TIRand = { + $ar: { + defaults: "lo=0,hi=127,trig=1", + ctor: function(lo, hi, trig) { + return this.multiNew(2, lo, hi, trig); + } + }, + $kr: { + defaults: "lo=0,hi=127,trig=1", + ctor: function(lo, hi, trig) { + return this.multiNew(1, lo, hi, trig); + } + } + }; + + cc.unit.specs.TIRand = (function() { + var ctor = function() { + if (this.calcRate === 2) { + this.process = next_a; + } else { + this.process = next_k; + } + var lo = this.inputs[0][0]|0; + var hi = this.inputs[1][0]|0; + var range = hi - lo; + this.outputs[0][0] = this._value = (Math.random() * range + lo)|0; + this._trig = this.inputs[2][0]; + }; + var next_k = function() { + var out = this.outputs[0]; + var trig = this.inputs[2][0]; + if (trig > 0 && this._trig <= 0) { + var lo = this.inputs[0][0]|0; + var hi = this.inputs[1][0]|0; + var range = hi - lo; + out[0] = this._value = (Math.random() * range + lo)|0; + } else { + out[0] = this._value; + } + this._trig = trig; + }; + var next_a = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[2]; + var value = this._value; + var prev = this._trig; + var next; + for (var i = 0; i < inNumSamples; ++i) { + next = trigIn[i]; + if (next > 0 && prev <= 0) { + var lo = this.inputs[0][0]|0; + var hi = this.inputs[1][0]|0; + var range = hi - lo; + out[i] = value = (Math.random() * range + lo)|0; + } else { + out[i] = value; + } + prev = next; + } + this._trig = next; + this._value = value; + }; + return ctor; + })(); + + cc.ugen.specs.LinRand = { + $new: { + defaults: "lo=0,hi=1,minmax=0", + ctor: function(lo, hi, minmax) { + return this.multiNew(0, lo, hi, minmax); + } + } + }; + + cc.unit.specs.LinRand = (function() { + var ctor = function() { + var lo = this.inputs[0][0]; + var hi = this.inputs[1][0]; + var n = this.inputs[2][0]|0; + var range = hi - lo; + var a = Math.random(); + var b = Math.random(); + if (n <= 0) { + this.outputs[0][0] = Math.min(a, b) * range + lo; + } else { + this.outputs[0][0] = Math.max(a, b) * range + lo; + } + }; + return ctor; + })(); + + cc.ugen.specs.NRand = { + $new: { + defaults: "lo=0,hi=1,n=0", + ctor: function(lo, hi, n) { + return this.multiNew(0, lo, hi, n); + } + } + }; + + cc.unit.specs.NRand = (function() { + var ctor = function() { + var lo = this.inputs[0][0]; + var hi = this.inputs[1][0]; + var n = this.inputs[2][0]|0; + if (n) { + var range = hi - lo; + var sum = 0; + for (var i = 0; i < n; ++i) { + sum += Math.random(); + } + this.outputs[0][0] = (sum/n) * range + lo; + } + }; + return ctor; + })(); + + cc.ugen.specs.ExpRand = { + $new: { + defaults: "lo=0.01,hi=1", + ctor: function(lo, hi) { + return this.multiNew(0, lo, hi); + } + } + }; + + cc.unit.specs.ExpRand = (function() { + var ctor = function() { + var lo = this.inputs[0][0] || 0.01; + var hi = this.inputs[1][0]; + var ratio = hi / lo; + this.outputs[0][0] = Math.pow(ratio, Math.random()) * lo; + }; + return ctor; + })(); + + cc.ugen.specs.TExpRand = { + $ar: { + defaults: "lo=0.01,hi=1,trig=1", + ctor: function(lo, hi, trig) { + return this.multiNew(2, lo, hi, trig); + } + }, + $kr: { + defaults: "lo=0.01,hi=1,trig=1", + ctor: function(lo, hi, trig) { + return this.multiNew(1, lo, hi, trig); + } + } + }; + + cc.unit.specs.TExpRand = (function() { + var ctor = function() { + if (this.calcRate === 2) { + this.process = next_a; + } else { + this.process = next_k; + } + var lo = this.inputs[0][0] || 0.01; + var hi = this.inputs[1][0]; + var ratio = hi / lo; + this.outputs[0][0] = this._value = Math.pow(ratio, Math.random()) * lo; + this._trig = this.inputs[2][0]; + }; + var next_k = function() { + var out = this.outputs[0]; + var trig = this.inputs[2][0]; + if (trig > 0 && this._trig <= 0) { + var lo = this.inputs[0][0] || 0.01; + var hi = this.inputs[1][0]; + var ratio = hi / lo; + out[0] = this._value = Math.pow(ratio, Math.random()) * lo; + } else { + out[0] = this._value; + } + this._trig = trig; + }; + var next_a = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[2]; + var value = this._value; + var prev = this._trig; + var next; + for (var i = 0; i < inNumSamples; ++i) { + next = trigIn[i]; + if (next > 0 && prev <= 0) { + var lo = this.inputs[0][0] || 0.01; + var hi = this.inputs[1][0]; + var ratio = hi / lo; + out[i] = value = Math.pow(ratio, Math.random()) * lo; + } else { + out[i] = value; + } + prev = next; + } + this._trig = next; + this._value = value; + }; + return ctor; + })(); + + cc.ugen.specs.CoinGate = { + $ar: { + defaults: "prob=0,in=0", + ctor: function(prob, _in) { + return this.multiNew(2, prob, _in); + } + }, + $kr: { + defaults: "prob=0,in=0", + ctor: function(prob, _in) { + return this.multiNew(1, prob, _in); + } + } + }; + + cc.unit.specs.CoinGate = (function() { + var ctor = function() { + if (this.calcRate === 2) { + this.process = next; + } else { + this.process = next_k; + } + this._trig = this.inputs[1][0]; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[1]; + var prevTrig = this._trig; + var prob = this.inputs[0][0]; + var curTrig, level; + for (var i = 0; i < inNumSamples; ++i) { + curTrig = trigIn[i]; + level = 0; + if (prevTrig <= 0 && curTrig > 0) { + if (Math.random() < prob) { + level = curTrig; + } + } + prevTrig = curTrig; + out[i] = level; + } + this._trig = prevTrig; + }; + var next_k = function() { + var trig = this.inputs[1][0]; + var level = 0; + if (trig > 0 && this._trig <= 0) { + if (Math.random() < this.inputs[0][0]) { + level = trig; + } + } + this.outputs[0][0] = level; + this._trig = trig; + }; + return ctor; + })(); + + module.exports = {}; + +}); +define('cc/plugins/range', function(require, exports, module) { + + var cc = require("../cc"); + + cc.ugen.specs.InRange = { + $ar: { + defaults: "in,lo=0,hi=1", + ctor: function(_in, lo, hi) { + return this.multiNew(2, _in, lo, hi); + } + }, + $kr: { + defaults: "in,lo=0,hi=1", + ctor: function(_in, lo, hi) { + return this.multiNew(1, _in, lo, hi); + } + }, + $ir: { + defaults: "in,lo=0,hi=1", + ctor: function(_in, lo, hi) { + return this.multiNew(0, _in, lo, hi); + } + } + }; + + cc.unit.specs.InRange = (function() { + var ctor = function() { + this.process = next; + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var loIn = this.inputs[1]; + var hiIn = this.inputs[2]; + for (var i = 0; i < inNumSamples; ++i) { + var _in = inIn[i]; + out[i] = (loIn[i] <= _in && _in <= hiIn[i]) ? 1 : 0; + } + }; + return ctor; + })(); + + cc.ugen.specs.Clip = cc.ugen.specs.InRange; + + cc.unit.specs.Clip = (function() { + var ctor = function() { + if (this.inRates[1] === 2 && this.inRates[2] === 2) { + this.process = next_aa; + } else { + this.process = next_kk; + } + this._lo = this.inputs[1][0]; + this._hi = this.inputs[2][0]; + this.process(1); + }; + var next_aa = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var loIn = this.inputs[1]; + var hiIn = this.inputs[2]; + for (var i = 0; i < inNumSamples; ++i) { + out[i] = Math.max(loIn[i], Math.min(inIn[i], hiIn[i])); + } + }; + var next_kk = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var next_lo = this.inputs[1][0]; + var next_hi = this.inputs[2][0]; + var lo = this._lo; + var hi = this._hi; + var i; + if (next_lo === lo && next_hi === hi) { + for (i = 0; i < inNumSamples; ++i) { + out[i] = Math.max(lo, Math.min(inIn[i], hi)); + } + } else { + var lo_slope = (next_lo - lo) * this.rate.slopeFactor; + var hi_slope = (next_hi - hi) * this.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + lo += lo_slope; + hi += hi_slope; + out[i] = Math.max(lo, Math.min(inIn[i], hi)); + } + this._lo = next_lo; + this._hi = next_hi; + } + }; + return ctor; + })(); + + cc.ugen.specs.Fold = cc.ugen.specs.InRange; + + cc.unit.specs.Fold = (function() { + var fold = function(val, lo, hi) { + var x, range1, range2; + if (hi === lo) { + return lo; + } + if (val >= hi) { + val = (hi * 2) - val; + if (val >= lo) { + return val; + } + } else if (val < lo) { + val = (lo * 2) - val; + if (val < hi) { + return val; + } + } else { + return val; + } + range1 = hi - lo; + range2 = range1 * 2; + x = val - lo; + x -= range2 * Math.floor(x / range2); + if (x >= range1) { + return range2 - x + lo; + } + return x + lo; + }; + var ctor = function() { + if (this.inRates[1] === 2 && this.inRates[2] === 2) { + this.process = next_aa; + } else { + this.process = next_kk; + } + this._lo = this.inputs[1][0]; + this._hi = this.inputs[2][0]; + this.process(1); + }; + var next_aa = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var loIn = this.inputs[1]; + var hiIn = this.inputs[2]; + for (var i = 0; i < inNumSamples; ++i) { + out[i] = Math.max(loIn[i], Math.min(inIn[i], hiIn[i])); + } + }; + var next_kk = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var next_lo = this.inputs[1][0]; + var next_hi = this.inputs[2][0]; + var lo = this._lo; + var hi = this._hi; + var i; + if (next_lo === lo && next_hi === hi) { + for (i = 0; i < inNumSamples; ++i) { + out[i] = fold(inIn[i], lo, hi); + } + } else { + var lo_slope = (next_lo - lo) * this.rate.slopeFactor; + var hi_slope = (next_hi - hi) * this.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + lo += lo_slope; + hi += hi_slope; + out[i] = fold(inIn[i], lo, hi); + } + this._lo = next_lo; + this._hi = next_hi; + } + }; + return ctor; + })(); + + cc.ugen.specs.Wrap = cc.ugen.specs.InRange; + + cc.unit.specs.Wrap = (function() { + var wrap = function(val, lo, hi) { + if (hi === lo) { + return lo; + } + var range = (hi - lo); + if (val >= hi) { + val -= range; + if (val < hi) { + return val; + } + } else if (val < lo) { + val += range; + if (val >= lo) { + return val; + } + } else { + return val; + } + return val - range * Math.floor((val - lo) / range); + }; + var ctor = function() { + if (this.inRates[1] === 2 && this.inRates[2] === 2) { + this.process = next_aa; + } else { + this.process = next_kk; + } + this._lo = this.inputs[1][0]; + this._hi = this.inputs[2][0]; + this.process(1); + }; + var next_aa = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var loIn = this.inputs[1]; + var hiIn = this.inputs[2]; + for (var i = 0; i < inNumSamples; ++i) { + out[i] = Math.max(loIn[i], Math.min(inIn[i], hiIn[i])); + } + }; + var next_kk = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var next_lo = this.inputs[1][0]; + var next_hi = this.inputs[2][0]; + var lo = this._lo; + var hi = this._hi; + var i; + if (next_lo === lo && next_hi === hi) { + for (i = 0; i < inNumSamples; ++i) { + out[i] = wrap(inIn[i], lo, hi); + } + } else { + var lo_slope = (next_lo - lo) * this.rate.slopeFactor; + var hi_slope = (next_hi - hi) * this.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + lo += lo_slope; + hi += hi_slope; + out[i] = wrap(inIn[i], lo, hi); + } + this._lo = next_lo; + this._hi = next_hi; + } + }; + return ctor; + })(); + + cc.ugen.specs.LinLin = { + $ar: { + defaults: "in=0,srclo=0,srchi=1,dstlo=1,dsthi=2", + ctor: function(_in, srclo, srchi, dstlo, dsthi) { + return this.multiNew(2, _in, srclo, srchi, dstlo, dsthi); + } + }, + $kr: { + defaults: "in=0,srclo=0,srchi=1,dstlo=1,dsthi=2", + ctor: function(_in, srclo, srchi, dstlo, dsthi) { + return this.multiNew(1, _in, srclo, srchi, dstlo, dsthi); + } + + }, + $ir: { + defaults: "in=0,srclo=0,srchi=1,dstlo=1,dsthi=2", + ctor: function(_in, srclo, srchi, dstlo, dsthi) { + return this.multiNew(0, _in, srclo, srchi, dstlo, dsthi); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.LinLin = (function() { + var ctor = function() { + if (this.calcRate === 2) { + this.process = next; + } else { + this.process = next_1; + } + this._srclo = 0; + this._srchi = 0; + this._dstlo = 0; + this._dsthi = 0; + this._scale = 1; + this._offset = 0; + next_1.call(this, 1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var next_srclo = this.inputs[1][0]; + var next_srchi = this.inputs[2][0]; + var next_dstlo = this.inputs[3][0]; + var next_dsthi = this.inputs[4][0]; + var srclo = this._srclo; + var srchi = this._srchi; + var dstlo = this._dstlo; + var dsthi = this._dsthi; + var scale = this._scale; + var offset = this._offset; + var i; + if (srclo !== next_srclo || srchi !== next_srchi || + dstlo !== next_dstlo || dsthi !== next_dsthi) { + var next_scale = ((next_dsthi - next_dstlo) / (next_srchi - next_srclo)) || 0; + var next_offset = next_dstlo - (next_scale * next_srclo); + var scale_slope = (next_scale - scale ) * this.rate.slopeFactor; + var offset_slope = (next_offset - offset) * this.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + out[i] = inIn[i] * scale + offset; + scale += scale_slope; + offset += offset_slope; + } + this._srclo = next_srclo; + this._srchi = next_srchi; + this._dstlo = next_dstlo; + this._dsthi = next_dsthi; + this._scale = next_scale; + this._offset = next_offset; + } else { + for (i = 0; i < inNumSamples; ++i) { + out[i] = inIn[i] * scale + offset; + } + } + }; + var next_1 = function() { + var _in = this.inputs[0][0]; + var srclo = this.inputs[1][0]; + var srchi = this.inputs[2][0]; + var dstlo = this.inputs[3][0]; + var dsthi = this.inputs[4][0]; + if (this._srclo !== srclo || this._srchi !== srchi || + this._dstlo !== dstlo || this._dsthi !== dsthi) { + this._srclo = srclo; + this._srchi = srchi; + this._dstlo = dstlo; + this._dsthi = dsthi; + this._scale = ((dsthi - dstlo) / (srchi - srclo)) || 0; + this._offset = dstlo - (this._scale * srclo); + } + this.outputs[0][0] = _in * this._scale + this._offset; + }; + return ctor; + })(); + + + cc.ugen.specs.LinExp = cc.ugen.specs.LinLin; + + cc.unit.specs.LinExp = (function() { + var ctor = function() { + if (this.calcRate === 2) { + this.process = next; + } else { + this.process = next_1; + } + this._srclo = 0; + this._srchi = 0; + this._dstlo = 0; + this._dsthi = 0; + this._x = 0; + this._y = 0; + next_1.call(this, 1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var next_srclo = this.inputs[1][0]; + var next_srchi = this.inputs[2][0]; + var next_dstlo = this.inputs[3][0] || 0.001; + var next_dsthi = this.inputs[4][0] || 0.001; + var srclo = this._srclo; + var srchi = this._srchi; + var dstlo = this._dstlo; + var dsthi = this._dsthi; + var x = this._x; + var y = this._y; + var i; + if (srclo !== next_srclo || srchi !== next_srchi || + dstlo !== next_dstlo || dsthi !== next_dsthi) { + var next_x = dsthi / dstlo; + var next_y = (srchi - srclo) || 0.001; + var x_slope = (next_x - x) * this.rate.slopeFactor; + var y_slope = (next_y - y) * this.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + out[i] = Math.pow(x, (inIn[i] - srclo) / y) * dstlo; + x += x_slope; + y += y_slope; + } + this._srclo = next_srclo; + this._srchi = next_srchi; + this._dstlo = next_dstlo; + this._dsthi = next_dsthi; + this._x = next_x; + this._y = next_y; + } else { + for (i = 0; i < inNumSamples; ++i) { + out[i] = Math.pow(x, (inIn[i] - srclo) / y) * dstlo; + } + } + }; + var next_1 = function() { + var _in = this.inputs[0][0]; + var srclo = this.inputs[1][0]; + var srchi = this.inputs[2][0]; + var dstlo = this.inputs[3][0] || 0.001; + var dsthi = this.inputs[4][0] || 0.001; + if (this._srclo !== srclo || this._srchi !== srchi || + this._dstlo !== dstlo || this._dsthi !== dsthi) { + this._srclo = srclo; + this._srchi = srchi; + this._dstlo = dstlo; + this._dsthi = dsthi; + this._x = dsthi / dstlo; + this._y = (srchi - srclo) || 0.001; + } + this.outputs[0][0] = Math.pow(this._x, (_in - srclo) / this._y) * dstlo; + }; + return ctor; + })(); + + + cc.ugen.specs.ExpLin = cc.ugen.specs.LinLin; + + cc.unit.specs.ExpLin = (function() { + var ctor = function() { + if (this.calcRate === 2) { + this.process = next; + } else { + this.process = next_1; + } + this._srclo = 0; + this._srchi = 0; + this._dstlo = 0; + this._dsthi = 0; + this._x = 0; + next_1.call(this, 1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var next_srclo = this.inputs[1][0] || 0.001; + var next_srchi = this.inputs[2][0] || 0.001; + var next_dstlo = this.inputs[3][0]; + var next_dsthi = this.inputs[4][0]; + var srclo = this._srclo; + var srchi = this._srchi; + var dstlo = this._dstlo; + var dsthi = this._dsthi; + var x = this._x; + var i, _in; + if (srclo !== next_srclo || srchi !== next_srchi || + dstlo !== next_dstlo || dsthi !== next_dsthi) { + var next_x = Math.log(Math.abs(srchi / srclo)); + var x_slope = (next_x - x) * this.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + _in = inIn[i] || 0.001; + out[i] = Math.log(Math.abs(_in / srclo)) / x * (dsthi - dstlo) + dstlo; + x += x_slope; + } + this._srclo = next_srclo; + this._srchi = next_srchi; + this._dstlo = next_dstlo; + this._dsthi = next_dsthi; + this._x = next_x; + } else { + for (i = 0; i < inNumSamples; ++i) { + _in = inIn[i] || 0.001; + out[i] = Math.log(Math.abs(_in / srclo)) / x * (dsthi - dstlo) + dstlo; + } + } + }; + var next_1 = function() { + var _in = this.inputs[0][0] || 0.001; + var srclo = this.inputs[1][0] || 0.001; + var srchi = this.inputs[2][0] || 0.001; + var dstlo = this.inputs[3][0]; + var dsthi = this.inputs[4][0]; + if (this._srclo !== srclo || this._srchi !== srchi || + this._dstlo !== dstlo || this._dsthi !== dsthi) { + this._srclo = srclo; + this._srchi = srchi; + this._dstlo = dstlo; + this._dsthi = dsthi; + this._x = Math.log(Math.abs(srchi / srclo)); + } + this.outputs[0][0] = Math.log(Math.abs(_in / srclo)) / this._x * (dsthi - dstlo) + dstlo; + }; + return ctor; + })(); + + + cc.ugen.specs.ExpExp = cc.ugen.specs.LinLin; + + cc.unit.specs.ExpExp = (function() { + var ctor = function() { + if (this.calcRate === 2) { + this.process = next; + } else { + this.process = next_1; + } + this._srclo = 0; + this._srchi = 0; + this._dstlo = 0; + this._dsthi = 0; + this._x = 0; + this._y = 0; + next_1.call(this, 1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var next_srclo = this.inputs[1][0] || 0.001; + var next_srchi = this.inputs[2][0] || 0.001; + var next_dstlo = this.inputs[3][0] || 0.001; + var next_dsthi = this.inputs[4][0] || 0.001; + var srclo = this._srclo; + var srchi = this._srchi; + var dstlo = this._dstlo; + var dsthi = this._dsthi; + var x = this._x; + var y = this._y; + var i, _in; + if (srclo !== next_srclo || srchi !== next_srchi || + dstlo !== next_dstlo || dsthi !== next_dsthi) { + var next_x = dsthi / dstlo; + var next_y = Math.log(Math.abs(srchi / srclo)); + var x_slope = (next_x - x) * this.rate.slopeFactor; + var y_slope = (next_y - y) * this.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + _in = inIn[i] || 0.001; + out[i] = Math.pow(x, Math.log(Math.abs(_in / srclo)) / y) * dstlo; + x += x_slope; + y += y_slope; + } + this._srclo = next_srclo; + this._srchi = next_srchi; + this._dstlo = next_dstlo; + this._dsthi = next_dsthi; + this._x = next_x; + this._y = next_y; + } else { + for (i = 0; i < inNumSamples; ++i) { + _in = inIn[i] || 0.001; + out[i] = Math.pow(x, Math.log(Math.abs(_in / srclo)) / y) * dstlo; + } + } + }; + var next_1 = function() { + var _in = this.inputs[0][0] || 0.001; + var srclo = this.inputs[1][0] || 0.001; + var srchi = this.inputs[2][0] || 0.001; + var dstlo = this.inputs[3][0] || 0.001; + var dsthi = this.inputs[4][0] || 0.001; + if (this._srclo !== srclo || this._srchi !== srchi || + this._dstlo !== dstlo || this._dsthi !== dsthi) { + this._srclo = srclo; + this._srchi = srchi; + this._dstlo = dstlo; + this._dsthi = dsthi; + this._x = dsthi / dstlo; + this._y = Math.log(Math.abs(srchi / srclo)); + } + this.outputs[0][0] = Math.pow(this._x, Math.log(Math.abs(_in / srclo)) / this._y) * dstlo; + }; + return ctor; + })(); + + module.exports = {}; + +}); +define('cc/plugins/reverb', function(require, exports, module) { + + var cc = require("../cc"); + + cc.ugen.specs.FreeVerb = { + checkInputs: cc.ugen.checkSameRateAsFirstInput, + $ar: { + defaults: "in=0,mix=0.33,room=0.5,damp=0.5,mul=1,add=0", + ctor: function(_in, mix, room, damp, mul, add) { + return this.multiNew(2, _in, mix, room, damp).madd(mul, add); + } + }, + $kr: { + defaults: "in=0,mix=0.33,room=0.5,damp=0.5,mul=1,add=0", + ctor: function(_in, mix, room, damp, mul, add) { + return this.multiNew(1, _in, mix, room, damp).madd(mul, add); + } + } + }; + + cc.unit.specs.FreeVerb = (function() { + var ctor = function() { + this.process = next; + + this._iota0 = 0; + this._iota1 = 0; + this._iota2 = 0; + this._iota3 = 0; + this._iota4 = 0; + this._iota5 = 0; + this._iota6 = 0; + this._iota7 = 0; + this._iota8 = 0; + this._iota9 = 0; + this._iota10 = 0; + this._iota11 = 0; + + this._R0_0 = 0; + this._R1_0 = 0; + this._R2_0 = 0; + this._R3_0 = 0; + this._R4_0 = 0; + this._R5_0 = 0; + this._R6_0 = 0; + this._R7_0 = 0; + this._R8_0 = 0; + this._R9_0 = 0; + this._R10_0 = 0; + this._R11_0 = 0; + this._R12_0 = 0; + this._R13_0 = 0; + this._R14_0 = 0; + this._R15_0 = 0; + this._R16_0 = 0; + this._R17_0 = 0; + this._R18_0 = 0; + this._R19_0 = 0; + + this._R0_1 = 0; + this._R1_1 = 0; + this._R2_1 = 0; + this._R3_1 = 0; + + this._dline0 = new Float32Array(225); + this._dline1 = new Float32Array(341); + this._dline2 = new Float32Array(441); + this._dline3 = new Float32Array(556); + this._dline4 = new Float32Array(1617); + this._dline5 = new Float32Array(1557); + this._dline6 = new Float32Array(1491); + this._dline7 = new Float32Array(1422); + this._dline8 = new Float32Array(1277); + this._dline9 = new Float32Array(1116); + this._dline10 = new Float32Array(1188); + this._dline11 = new Float32Array(1356); + + this.process(1); + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var ftemp0 = Math.max(0, Math.min(this.inputs[1][0], 1)); // mix + var ftemp1 = 1 - ftemp0; + + var room = Math.max(0, Math.min(this.inputs[2][0], 1)); // room + var ftemp5 = 0.7 + (0.28 * room); + + var damp = Math.max(0, Math.min(this.inputs[3][0], 1)); // damp + var ftemp6 = 0.4 * damp; + var ftemp7 = 1 - ftemp6; + + var iota0 = this._iota0; + var iota1 = this._iota1; + var iota2 = this._iota2; + var iota3 = this._iota3; + var iota4 = this._iota4; + var iota5 = this._iota5; + var iota6 = this._iota6; + var iota7 = this._iota7; + var iota8 = this._iota8; + var iota9 = this._iota9; + var iota10 = this._iota10; + var iota11 = this._iota11; + + var R0_1 = this._R0_1; + var R1_1 = this._R1_1; + var R2_1 = this._R2_1; + var R3_1 = this._R3_1; + + var R0_0 = this._R0_0; + var R1_0 = this._R1_0; + var R2_0 = this._R2_0; + var R3_0 = this._R3_0; + var R4_0 = this._R4_0; + var R5_0 = this._R5_0; + var R6_0 = this._R6_0; + var R7_0 = this._R7_0; + var R8_0 = this._R8_0; + var R9_0 = this._R9_0; + var R10_0 = this._R10_0; + var R11_0 = this._R11_0; + var R12_0 = this._R12_0; + var R13_0 = this._R13_0; + var R14_0 = this._R14_0; + var R15_0 = this._R15_0; + var R16_0 = this._R16_0; + var R17_0 = this._R17_0; + var R18_0 = this._R18_0; + var R19_0 = this._R19_0; + + var dline0 = this._dline0; + var dline1 = this._dline1; + var dline2 = this._dline2; + var dline3 = this._dline3; + var dline4 = this._dline4; + var dline5 = this._dline5; + var dline6 = this._dline6; + var dline7 = this._dline7; + var dline8 = this._dline8; + var dline9 = this._dline9; + var dline10 = this._dline10; + var dline11 = this._dline11; + + for (var i = 0; i < inNumSamples; ++i) { + var ftemp2 = inIn[i]; + var ftemp4 = 1.500000e-2 * ftemp2; + if (++iota0 === 225) { + iota0 = 0; + } + var T0 = dline0[iota0]; + if (++iota1 === 341) { + iota1 = 0; + } + var T1 = dline1[iota1]; + if (++iota2 === 441) { + iota2 = 0; + } + var T2 = dline2[iota2]; + if (++iota3 === 556) { + iota3 = 0; + } + var T3 = dline3[iota3]; + if (++iota4 === 1617) { + iota4 = 0; + } + var T4 = dline4[iota4]; + R5_0 = (ftemp7 * R4_0) + (ftemp6 * R5_0); + dline4[iota4] = ftemp4 + (ftemp5 * R5_0); + R4_0 = T4; + if (++iota5 === 1557) { + iota5 = 0; + } + var T5 = dline5[iota5]; + R7_0 = (ftemp7 * R6_0) + (ftemp6 * R7_0); + dline5[iota5] = ftemp4 + (ftemp5 * R7_0); + R6_0 = T5; + if (++iota6 === 1491) { + iota6 = 0; + } + var T6 = dline6[iota6]; + R9_0 = (ftemp7 * R8_0) + (ftemp6 * R9_0); + dline6[iota6] = ftemp4 + (ftemp5 * R9_0); + R8_0 = T6; + if (++iota7 === 1422) { + iota7 = 0; + } + var T7 = dline7[iota7]; + R11_0 = (ftemp7 * R10_0) + (ftemp6 * R11_0); + dline7[iota7] = ftemp4 + (ftemp5 * R11_0); + R10_0 = T7; + if (++iota8 === 1277) { + iota8 = 0; + } + var T8 = dline8[iota8]; + R13_0 = (ftemp7 * R12_0) + (ftemp6 * R13_0); + dline8[iota8] = ftemp4 + (ftemp5 * R13_0); + R12_0 = T8; + if (++iota9 === 1116) { + iota9 = 0; + } + var T9 = dline9[iota9]; + R15_0 = (ftemp7 * R14_0) + (ftemp6 * R15_0); + dline9[iota9] = ftemp4 + (ftemp5 * R15_0); + R14_0 = T9; + if (++iota10 === 1188) { + iota10 = 0; + } + var T10 = dline10[iota10]; + R17_0 = (ftemp7 * R16_0) + (ftemp6 * R17_0); + dline10[iota10] = ftemp4 + (ftemp5 * R17_0); + R16_0 = T10; + if (++iota11 === 1356) { + iota11 = 0; + } + var T11 = dline11[iota11]; + R19_0 = (ftemp7 * R18_0) + (ftemp6 * R19_0); + dline11[iota11] = ftemp4 + (ftemp5 * R19_0); + R18_0 = T11; + var ftemp8 = R16_0 + R18_0; + dline3[iota3] = (((0.5 * R3_0) + R4_0) + (R6_0 + R8_0)) + ((R10_0 + R12_0) + (R14_0 + ftemp8)); + R3_0 = T3; + R3_1 = R3_0 - (((R4_0 + R6_0) + (R8_0 + R10_0)) + ((R12_0 + R14_0) + ftemp8)); + dline2[iota2] = (0.5 * R2_0) + R3_1; + R2_0 = T2; + R2_1 = (R2_0 - R3_1); + dline1[iota1] = (0.5 * R1_0) + R2_1; + R1_0 = T1; + R1_1 = (R1_0 - R2_1); + dline0[iota0] = (0.5 * R0_0) + R1_1; + R0_0 = T0; + R0_1 = R0_0 - R1_1; + out[i] = (ftemp1 * ftemp2) + (ftemp0 * R0_1); + } + + this._iota0 = iota0; + this._iota1 = iota1; + this._iota2 = iota2; + this._iota3 = iota3; + this._iota4 = iota4; + this._iota5 = iota5; + this._iota6 = iota6; + this._iota7 = iota7; + this._iota8 = iota8; + this._iota9 = iota9; + this._iota10 = iota10; + this._iota11 = iota11; + + this._R0_1 = R0_1; + this._R1_1 = R1_1; + this._R2_1 = R2_1; + this._R3_1 = R3_1; + + this._R0_0 = R0_0; + this._R1_0 = R1_0; + this._R2_0 = R2_0; + this._R3_0 = R3_0; + this._R4_0 = R4_0; + this._R5_0 = R5_0; + this._R6_0 = R6_0; + this._R7_0 = R7_0; + this._R8_0 = R8_0; + this._R9_0 = R9_0; + this._R10_0 = R10_0; + this._R11_0 = R11_0; + this._R12_0 = R12_0; + this._R13_0 = R13_0; + this._R14_0 = R14_0; + this._R15_0 = R15_0; + this._R16_0 = R16_0; + this._R17_0 = R17_0; + this._R18_0 = R18_0; + this._R19_0 = R19_0; + }; + return ctor; + })(); + + module.exports = {}; + +}); +define('cc/plugins/trig', function(require, exports, module) { + + var cc = require("../cc"); + var sc_wrap = require("./utils").sc_wrap; + + cc.ugen.specs.Trig = { + $ar: { + defaults: "in=0,dur=0.1", + ctor: function(_in, dur) { + return this.multiNew(2, _in, dur); + } + }, + $kr: { + defaults: "in=0,dur=0.1", + ctor: function(_in, dur) { + return this.multiNew(1, _in, dur); + } + }, + signalRange: 1 + }; + + cc.unit.specs.Trig = (function() { + var ctor = function() { + if (this.calcRate === 2 && this.inRates[0] !== 2) { + this.process = next_k; + } else { + this.process = next; + } + this._counter = 0; + this._trig = 0; + this._level = 0; + this.outputs[0][0] = 0; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[0]; + var dur = this.inputs[1][0]; + var sr = this.rate.sampleRate; + var trig = this._trig; + var level = this._level; + var counter = this._counter; + var curTrig, zout; + for (var i = 0; i < inNumSamples; ++i) { + curTrig = trigIn[i]; + if (counter > 0) { + zout = --counter ? level : 0; + } else { + if (curTrig > 0 && trig <= 0) { + counter = Math.max(1, (dur * sr + 0.5)|0); + zout = level = curTrig; + } else { + zout = 0; + } + } + out[i] = zout; + trig = curTrig; + } + this._trig = trig; + this._counter = counter; + this._level = level; + }; + var next_k = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[0]; + var dur = this.inputs[1][0]; + var sr = this.rate.sampleRate; + var trig = this._trig; + var level = this._level; + var counter = this._counter; + var curTrig, zout; + curTrig = trigIn[0]; + for (var i = 0; i < inNumSamples; ++i) { + if (counter > 0) { + zout = --counter ? level : 0; + } else { + if (curTrig > 0 && trig <= 0) { + counter = Math.max(1, (dur * sr + 0.5)|0); + zout = level = curTrig; + } else { + zout = 0; + } + } + out[i] = zout; + trig = curTrig; + } + this._trig = curTrig; + this._counter = counter; + this._level = level; + }; + return ctor; + })(); + + cc.ugen.specs.Trig1 = cc.ugen.specs.Trig; + + cc.unit.specs.Trig1 = (function() { + var ctor = function() { + if (this.calcRate === 2 && this.inRates[0] !== 2) { + this.process = next_k; + } else { + this.process = next; + } + this._counter = 0; + this._trig = 0; + this.outputs[0][0] = 0; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[0]; + var dur = this.inputs[1][0]; + var sr = this.rate.sampleRate; + var trig = this._trig; + var counter = this._counter; + var curTrig, zout; + for (var i = 0; i < inNumSamples; ++i) { + curTrig = trigIn[i]; + if (counter > 0) { + zout = --counter ? 1 : 0; + } else { + if (curTrig > 0 && trig <= 0) { + counter = Math.max(1, (dur * sr + 0.5)|0); + zout = 1; + } else { + zout = 0; + } + } + out[i] = zout; + trig = curTrig; + } + this._trig = trig; + this._counter = counter; + }; + var next_k = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[0]; + var dur = this.inputs[1][0]; + var sr = this.rate.sampleRate; + var trig = this._trig; + var counter = this._counter; + var curTrig, zout; + curTrig = trigIn[0]; + for (var i = 0; i < inNumSamples; ++i) { + if (counter > 0) { + zout = --counter ? 1 : 0; + } else { + if (curTrig > 0 && trig <= 0) { + counter = Math.max(1, (dur * sr + 0.5)|0); + zout = 1; + } else { + zout = 0; + } + } + out[i] = zout; + trig = curTrig; + } + this._trig = trig; + this._counter = counter; + }; + return ctor; + })(); + + cc.ugen.specs.Latch = { + $ar: { + defaults: "in=0,trig=0", + ctor: function(_in, trig) { + return this.multiNew(2, _in, trig); + } + }, + $kr: { + defaults: "in=0,trig=0", + ctor: function(_in, trig) { + return this.multiNew(1, _in, trig); + } + } + }; + + cc.unit.specs.Latch = (function() { + var ctor = function() { + if (this.inRates[1] === 2) { + this.process = next_aa; + } else { + this.process = next_ak; + } + this._trig = 0; + this._level = 0; + this.outputs[0][0] = this.inputs[1][0] > 0 ? this.inputs[0][0] : 0; + }; + var next_aa = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var trigIn = this.inputs[1]; + var trig = this._trig; + var level = this._level; + var curTrig; + for (var i = 0; i < inNumSamples; ++i) { + curTrig = trigIn[i]; + if (trig <= 0 && curTrig > 0) { + level = inIn[i]; + } + out[i] = level; + trig = curTrig; + } + this._trig = trig; + this._level = level; + }; + var next_ak = function(inNumSamples) { + var out = this.outputs[0]; + var level = this._level; + var trig = this.inputs[0][1]; + if (this._trig <= 0 && trig > 0) { + level = this.inputs[0][0]; + } + for (var i = 0; i < inNumSamples; ++i) { + out[i] = level; + } + this._trig = trig; + this._level = level; + }; + return ctor; + })(); + + cc.ugen.specs.Gate = cc.ugen.specs.Latch; + + cc.unit.specs.Gate = (function() { + var ctor = function() { + if (this.inRates[1] === 2) { + this.process = next_aa; + } else { + this.process = next_ak; + } + this._level = 0; + this.outputs[0][0] = 0; + }; + var next_aa = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var trigIn = this.inputs[1]; + var level = this._level; + var curTrig; + for (var i = 0; i < inNumSamples; ++i) { + curTrig = trigIn[i]; + if (curTrig > 0) { + level = inIn[i]; + } + out[i] = level; + } + this._level = level; + }; + var next_ak = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var trig = this.inputs[1][0]; + var level = this._level; + var i; + if (trig > 0) { + for (i = 0; i < inNumSamples; ++i) { + out[i] = level = inIn[i]; + } + this._level = level; + } else { + for (i = 0; i < inNumSamples; ++i) { + out[i] = level; + } + } + }; + return ctor; + })(); + + cc.ugen.specs.PulseCount = { + $ar: { + defaults: "trig=0,reset=0", + ctor: function(trig, reset) { + return this.multiNew(2, trig, reset); + } + }, + $kr: { + defaults: "trig=0,reset=0", + ctor: function(trig, reset) { + return this.multiNew(1, trig, reset); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.PulseCount = (function() { + var ctor = function() { + if (this.inRates[1] === 2) { + this.process = next_a; + } else { + this.process = next; + } + this._prevtrig = 0; + this._prevreset = 0; + this._level = 0; + this.outputs[0][0] = 0; + }; + var next_a = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[0]; + var resetIn = this.inputs[1]; + var prevtrig = this._prevtrig; + var prevreset = this._prevreset; + var level = this._level; + var curtrig, curreset; + for (var i = 0; i < inNumSamples; ++i) { + curtrig = trigIn[i]; + curreset = resetIn[i]; + if (prevreset <= 0 && curreset > 0) { + level = 0; + } else if (prevtrig <= 0 && curtrig > 0) { + level += 1; + } + out[i] = level; + prevtrig = curtrig; + prevreset = curreset; + } + this._level = level; + this._prevtrig = prevtrig; + this._prevreset = prevreset; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[0]; + var resetIn = this.inputs[1]; + var prevtrig = this._prevtrig; + var prevreset = this._prevreset; + var level = this._level; + var curtrig, curreset; + + curtrig = trigIn[0]; + curreset = resetIn[0]; + if (prevreset <= 0 && curreset > 0) { + level = 0; + } else if (prevtrig <= 0 && curtrig > 0) { + level += 1; + } + out[0] = level; + prevtrig = curtrig; + prevreset = curreset; + + for (var i = 1; i < inNumSamples; ++i) { + curtrig = trigIn[i]; + curreset = resetIn[i]; + if (prevreset <= 0 && curreset > 0) { + level = 0; + } else if (prevtrig <= 0 && curtrig > 0) { + level += 1; + } + out[i] = level; + prevtrig = curtrig; + prevreset = curreset; + } + this._level = level; + this._prevtrig = prevtrig; + this._prevreset = prevreset; + }; + return ctor; + })(); + + cc.ugen.specs.Peak = { + $ar: { + defaults: "in=0,trig=0", + ctor: function(_in, trig) { + return this.multiNew(2, _in, trig); + } + }, + $kr: { + defaults: "in=0,trig=0", + ctor: function(_in, trig) { + return this.multiNew(1, _in, trig); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.Peak = (function() { + var ctor = function() { + if (this.inRates[1] === 2) { + this.process = next_a; + } else { + this.process = next_k; + } + this._prevtrig = 0; + this.outputs[0][0] = this._level = this.inputs[0][0]; + }; + var next_a = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var trigIn = this.inputs[1]; + var prevtrig = this._prevtrig; + var level = this._level; + var curtrig, inlevel; + for (var i = 0; i < inNumSamples; ++i) { + curtrig = trigIn[i]; + inlevel = Math.abs(inIn[i]); + out[i] = level = Math.max(inlevel, level); + if (prevtrig <= 0 && curtrig > 0) { + level = inlevel; + } + prevtrig = curtrig; + } + this._prevtrig = prevtrig; + this._level = level; + }; + var next_k = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var trigIn = this.inputs[1]; + var prevtrig = this._prevtrig; + var level = this._level; + var curtrig, inlevel; + + curtrig = trigIn[0]; + inlevel = Math.abs(inIn[0]); + out[0] = level = Math.max(inlevel, level); + if (prevtrig <= 0 && curtrig > 0) { + level = inlevel; + } + prevtrig = curtrig; + + for (var i = 1; i < inNumSamples; ++i) { + curtrig = trigIn[i]; + inlevel = Math.abs(inIn[i]); + out[i] = level = Math.max(inlevel, level); + if (prevtrig <= 0 && curtrig > 0) { + level = inlevel; + } + prevtrig = curtrig; + } + this._prevtrig = prevtrig; + this._level = level; + }; + return ctor; + })(); + + cc.ugen.specs.RunningMin = cc.ugen.specs.Peak; + + cc.unit.specs.RunningMin = (function() { + var ctor = function() { + if (this.inRates[1] === 2) { + this.process = next_a; + } else { + this.process = next_k; + } + this._prevtrig = 0; + this.outputs[0][0] = this._level = this.inputs[0][0]; + }; + var next_a = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var trigIn = this.inputs[1]; + var prevtrig = this._prevtrig; + var level = this._level; + var curtrig, inlevel; + for (var i = 0; i < inNumSamples; ++i) { + curtrig = trigIn[i]; + inlevel = inIn[i]; + if (inlevel < level) { + level = inlevel; + } + out[i] = level; + if (prevtrig <= 0 && curtrig > 0) { + level = inlevel; + } + prevtrig = curtrig; + } + this._prevtrig = prevtrig; + this._level = level; + }; + var next_k = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var trigIn = this.inputs[1]; + var prevtrig = this._prevtrig; + var level = this._level; + var curtrig, inlevel; + + curtrig = trigIn[0]; + inlevel = inIn[0]; + if (inlevel < level) { + level = inlevel; + } + out[0] = level; + if (prevtrig <= 0 && curtrig > 0) { + level = inlevel; + } + prevtrig = curtrig; + + for (var i = 1; i < inNumSamples; ++i) { + curtrig = trigIn[i]; + inlevel = inIn[i]; + if (inlevel < level) { + level = inlevel; + } + out[i] = level; + if (prevtrig <= 0 && curtrig > 0) { + level = inlevel; + } + prevtrig = curtrig; + } + this._prevtrig = prevtrig; + this._level = level; + }; + return ctor; + })(); + + cc.ugen.specs.RunningMax = cc.ugen.specs.Peak; + + cc.unit.specs.RunningMax = (function() { + var ctor = function() { + if (this.inRates[1] === 2) { + this.process = next_a; + } else { + this.process = next_k; + } + this._prevtrig = 0; + this.outputs[0][0] = this._level = this.inputs[0][0]; + }; + var next_a = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var trigIn = this.inputs[1]; + var prevtrig = this._prevtrig; + var level = this._level; + var curtrig, inlevel; + for (var i = 0; i < inNumSamples; ++i) { + curtrig = trigIn[i]; + inlevel = inIn[i]; + if (inlevel > level) { + level = inlevel; + } + out[i] = level; + if (prevtrig <= 0 && curtrig > 0) { + level = inlevel; + } + prevtrig = curtrig; + } + this._prevtrig = prevtrig; + this._level = level; + }; + var next_k = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var trigIn = this.inputs[1]; + var prevtrig = this._prevtrig; + var level = this._level; + var curtrig, inlevel; + + curtrig = trigIn[0]; + inlevel = inIn[0]; + if (inlevel > level) { + level = inlevel; + } + out[0] = level; + if (prevtrig <= 0 && curtrig > 0) { + level = inlevel; + } + prevtrig = curtrig; + + for (var i = 1; i < inNumSamples; ++i) { + curtrig = trigIn[i]; + inlevel = inIn[i]; + if (inlevel > level) { + level = inlevel; + } + out[i] = level; + if (prevtrig <= 0 && curtrig > 0) { + level = inlevel; + } + prevtrig = curtrig; + } + this._prevtrig = prevtrig; + this._level = level; + }; + return ctor; + })(); + + cc.ugen.specs.Stepper = { + $ar: { + defaults: "trig=0,reset=0,min=0,max=7,step=1,resetval", + ctor: function(trig, reset, min, max, step, resetval) { + if (typeof resetval === "undefined") { + resetval = min; + } + return this.multiNew(2, trig, reset, min, max, step, resetval); + } + }, + $kr: { + defaults: "trig=0,reset=0,min=0,max=7,step=1,resetval", + ctor: function(trig, reset, min, max, step, resetval) { + if (typeof resetval === "undefined") { + resetval = min; + } + return this.multiNew(1, trig, reset, min, max, step, resetval); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.Stepper = (function() { + var ctor = function() { + if (this.inRates[1] === 2) { + this.process = next_a; + } else { + this.process = next_k; + } + this._prevtrig = 0; + this._prevreset = 0; + this._level = this.inputs[5][0]; + this.outputs[0][0] = 0; + }; + var next_a = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[0]; + var resetIn = this.inputs[1]; + var zmin = this.inputs[2][0]; + var zmax = this.inputs[3][0]; + var step = this.inputs[4][0]; + var resetval = this.inputs[5][0]; + var prevtrig = this._prevtrig; + var prevreset = this._prevreset; + var level = this._level; + var curtrig, curreset; + for (var i = 0; i < inNumSamples; ++i) { + curtrig = trigIn[i]; + curreset = resetIn[i]; + if (prevreset <= 0 && curreset > 0) { + level = sc_wrap(resetval, zmin, zmax); + } else if (prevtrig <= 0 && curtrig > 0) { + level = sc_wrap(level + step, zmin, zmax); + } + out[i] = level; + prevtrig = curtrig; + prevreset = curreset; + } + this._level = level; + this._prevtrig = prevtrig; + this._prevreset = prevreset; + }; + var next_k = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[0]; + var resetIn = this.inputs[1]; + var zmin = this.inputs[2][0]; + var zmax = this.inputs[3][0]; + var step = this.inputs[4][0]; + var resetval = this.inputs[5][0]; + var prevtrig = this._prevtrig; + var prevreset = this._prevreset; + var level = this._level; + var curtrig, curreset; + + curtrig = trigIn[0]; + curreset = resetIn[0]; + if (prevreset <= 0 && curreset > 0) { + level = sc_wrap(resetval, zmin, zmax); + } else if (prevtrig <= 0 && curtrig > 0) { + level = sc_wrap(level + step, zmin, zmax); + } + out[0] = level; + prevtrig = curtrig; + prevreset = curreset; + + for (var i = 1; i < inNumSamples; ++i) { + curtrig = trigIn[i]; + if (prevtrig <= 0 && curtrig > 0) { + level = sc_wrap(level + step, zmin, zmax); + } + out[i] = level; + prevtrig = curtrig; + prevreset = curreset; + } + this._level = level; + this._prevtrig = prevtrig; + this._prevreset = prevreset; + }; + return ctor; + })(); + + cc.ugen.specs.PulseDivider = { + $ar: { + defaults: "trig=0,div=2,start=0", + ctor: function(trig, div, start) { + return this.multiNew(2, trig, div, start); + } + }, + $kr: { + defaults: "trig=0,div=2,start=0", + ctor: function(trig, div, start) { + return this.multiNew(1, trig, div, start); + } + } + }; + + cc.unit.specs.PulseDivider = (function() { + var ctor = function() { + this.process = next; + this._prevtrig = 0; + this._level = 0; + this._counter = Math.floor(this.inputs[2][0] + 0.5); + this.outputs[0][0] = 0; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[0]; + var div = this.inputs[1][0]|0; + var prevtrig = this._prevtrig; + var counter = this._counter; + var z, curtrig; + for (var i = 0; i < inNumSamples; ++i) { + curtrig = trigIn[i]; + if (prevtrig <= 0 && curtrig > 0) { + counter++; + if (counter >= div) { + counter = 0; + z = 1; + } else { + z = 0; + } + } else { + z = 0; + } + out[i] = z; + prevtrig = curtrig; + } + this._counter = counter; + this._prevtrig = prevtrig; + }; + return ctor; + })(); + + cc.ugen.specs.SetResetFF = cc.ugen.specs.PulseCount; + + cc.unit.specs.SetResetFF = (function() { + var ctor = function() { + if (this.inRates[1] === 2) { + this.process = next_a; + } else { + this.process = next; + } + this._prevtrig = 0; + this._prevreset = 0; + this._level = 0; + this.outputs[0][0] = 0; + }; + var next_a = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[0]; + var resetIn = this.inputs[1]; + var prevtrig = this._prevtrig; + var prevreset = this._prevreset; + var level = this._level; + var curtrig, curreset; + for (var i = 0; i < inNumSamples; ++i) { + curtrig = trigIn[i]; + curreset = resetIn[i]; + if (prevreset <= 0 && curreset > 0) { + level = 0; + } else if (prevtrig <= 0 && curtrig > 0) { + level = 1; + } + out[i] = level; + prevtrig = curtrig; + prevreset = curreset; + } + this._level = level; + this._prevtrig = prevtrig; + this._prevreset = prevreset; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[0]; + var resetIn = this.inputs[1]; + var prevtrig = this._prevtrig; + var prevreset = this._prevreset; + var level = this._level; + var curtrig, curreset; + + curtrig = trigIn[0]; + curreset = resetIn[0]; + if (prevreset <= 0 && curreset > 0) { + level = 0; + } else if (prevtrig <= 0 && curtrig > 0) { + level = 1; + } + out[0] = level; + prevtrig = curtrig; + prevreset = curreset; + + for (var i = 1; i < inNumSamples; ++i) { + curtrig = trigIn[i]; + if (prevtrig <= 0 && curtrig > 0) { + level = 1; + } + out[i] = level; + prevtrig = curtrig; + } + this._level = level; + this._prevtrig = prevtrig; + this._prevreset = prevreset; + }; + + return ctor; + })(); + + cc.ugen.specs.ToggleFF = { + $ar: { + defaults: "trig=0", + ctor: function(trig) { + return this.multiNew(2, trig); + } + }, + $kr: { + defaults: "trig=0", + ctor: function(trig) { + return this.multiNew(1, trig); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.ToggleFF = (function() { + var ctor = function() { + this.process = next; + this._prevtrig = 0; + this._level = 0; + this.outputs[0][0] = 0; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[0]; + var prevtrig = this._prevtrig; + var level = this._level; + var curtrig; + for (var i = 0; i < inNumSamples; ++i) { + curtrig = trigIn[i]; + if (prevtrig <= 0 && curtrig > 0) { + level = 1 - level; + } + out[i] = level; + prevtrig = curtrig; + } + this._prevtrig = prevtrig; + this._level = level; + }; + return ctor; + })(); + + cc.ugen.specs.ZeroCrossing = { + $ar: { + defaults: "in=0", + ctor: function(_in) { + return this.multiNew(2, _in); + } + }, + $kr: { + defaults: "in=0", + ctor: function(_in) { + return this.multiNew(1, _in); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.ZeroCrossing = (function() { + var ctor = function() { + this.process = next; + this._prevfrac = 0; + this._previn = this.inputs[0][0]; + this._counter = 0; + this.outputs[0][0] = this._level = 0; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var previn = this._previn; + var prevfrac = this._prevfrac; + var level = this._level; + var counter = this._counter; + var sampleRate = this.rate.sampleRate; + var curin, frac; + for (var i = 0; i < inNumSamples; ++i) { + counter++; + curin = inIn[i]; + if (counter > 4 && previn <= 0 && curin > 0) { + frac = -previn / (curin - previn); + level = sampleRate / (frac + counter - prevfrac); + prevfrac = frac; + counter = 0; + } + out[i] = level; + previn = curin; + } + this._previn = previn; + this._prevfrac = prevfrac; + this._level = level; + this._counter = counter; + }; + return ctor; + })(); + + cc.ugen.specs.Timer = cc.ugen.specs.ZeroCrossing; + + cc.unit.specs.Timer = (function() { + var ctor = function() { + this.process = next; + this._prevfrac = 0; + this._previn = this.inputs[0][0]; + this._counter = 0; + this.outputs[0][0] = this._level = 0; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var previn = this._previn; + var prevfrac = this._prevfrac; + var level = this._level; + var counter = this._counter; + var sampleDur = this.rate.sampleDur; + var curin, frac; + for (var i = 0; i < inNumSamples; ++i) { + counter++; + curin = inIn[i]; + if (previn <= 0 && curin > 0) { + frac = -previn / (curin - previn); + level = sampleDur * (frac + counter - prevfrac); + prevfrac = frac; + counter = 0; + } + out[i] = level; + previn = curin; + } + this._previn = previn; + this._prevfrac = prevfrac; + this._level = level; + this._counter = counter; + }; + return ctor; + })(); + + cc.ugen.specs.Sweep = { + $ar: { + defaults: "trig=0,rate=1", + ctor: function(trig, rate) { + return this.multiNew(2, trig, rate); + } + }, + $kr: { + defaults: "trig=0,rate=1", + ctor: function(trig, rate) { + return this.multiNew(1, trig, rate); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.Sweep = (function() { + var ctor = function() { + this.process = next; + this._prevtrig = this.inputs[0][0]; + this._level = 0; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[0]; + var rate = this.inputs[1][0] * this.rate.sampleDur; + var prevtrig = this._prevtrig; + var level = this._level; + var curtrig, frac; + for (var i = 0; i < inNumSamples; ++i) { + curtrig = trigIn[i]; + if (prevtrig <= 0 && curtrig > 0) { + frac = -prevtrig / (curtrig - prevtrig); + level = frac * rate; + } else { + level += rate; + } + out[i] = level; + prevtrig = curtrig; + } + this._prevtrig = prevtrig; + this._level = level; + }; + return ctor; + })(); + + cc.ugen.specs.Phasor = { + $ar: { + defaults: "trig=0,rate=1,start=0,end=1,resetPos=0", + ctor: function(trig, rate, start, end, resetPos) { + return this.multiNew(2, trig, rate, start, end, resetPos); + } + }, + $kr: { + defaults: "trig=0,rate=1,start=0,end=1,resetPos=0", + ctor: function(trig, rate, start, end, resetPos) { + return this.multiNew(1, trig, rate, start, end, resetPos); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.Phasor = (function() { + var ctor = function() { + this.process = next; + this._prevtrig = this.inputs[0][0]; + this.outputs[0][0] = this._level = this.inputs[2][0]; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var trigIn = this.inputs[0]; + var rate = this.inputs[1][0]; + var start = this.inputs[2][0]; + var end = this.inputs[3][0]; + var resetPos = this.inputs[4][0]; + var prevtrig = this._prevtrig; + var level = this._level; + var curtrig, frac; + for (var i = 0; i < inNumSamples; ++i) { + curtrig = trigIn[i]; + if (prevtrig <= 0 && curtrig > 0) { + frac = 1 - prevtrig / (curtrig - prevtrig); + level = resetPos + frac * rate; + } + out[i] = level; + level += rate; + level = sc_wrap(level, start, end); + prevtrig = curtrig; + } + this._prevtrig = prevtrig; + this._level = level; + }; + return ctor; + })(); + + cc.ugen.specs.PeakFollower = { + $ar: { + defaults: "in=0,decay=0.999", + ctor: function(_in, decay) { + return this.multiNew(2, _in, decay); + } + }, + $kr: { + defaults: "in=0,decay=0.999", + ctor: function(_in, decay) { + return this.multiNew(1, _in, decay); + } + }, + checkInputs: cc.ugen.checkSameRateAsFirstInput + }; + + cc.unit.specs.PeakFollower = (function() { + var ctor = function() { + this.process = next; + this._decay = this.inputs[1][0]; + this.outputs[0][0] = this._level = this.inputs[0][0]; + }; + var next = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var decay = this.inputs[1][0]; + var level = this._level; + var i, inlevel; + if (decay === this._decay) { + for (i = 0; i < inNumSamples; ++i) { + inlevel = Math.abs(inIn[i]); + if (inlevel >= level) { + level = inlevel; + } else { + level = inlevel + decay * (level - inlevel); + } + out[i] = level; + } + } else { + var decay_slope = (decay - this._decay) * this.rate.slopeFactor; + for (i = 0; i < inNumSamples; ++i) { + inlevel = Math.abs(inIn[i]); + if (inlevel >= level) { + level = inlevel; + } else { + level = (1 - Math.abs(decay)) * inlevel + decay * level; + decay += decay_slope; + } + out[i] = level; + } + } + this._level = level; + this._decay = decay; + }; + return ctor; + })(); + + module.exports = {}; + +}); +define('cc/plugins/ui', function(require, exports, module) { + + var cc = require("../cc"); + var log001 = Math.log(0.001); + + var MouseXY = { + $kr: { + defaults: "minval=0,maxval=1,warp=0,lag=0.2", + ctor: function(minval, maxval, warp, lag) { + if (warp === "exponential" ) { + warp = 1; + } else if (warp === "linear") { + warp = 0; + } + return this.multiNew(1, minval, maxval, warp, lag); + } + } + }; + + cc.ugen.specs.MouseX = MouseXY; + + cc.unit.specs.MouseX = (function() { + var ctor = function() { + this.process = next; + this._y1 = 0; + this._b1 = 0; + this._lag = 0; + this.process(1); + }; + var next = function() { + var minval = this.inputs[0][0] || 0.01; + var maxval = this.inputs[1][0]; + var warp = this.inputs[2][0]; + var lag = this.inputs[3][0]; + var y1 = this._y1; + var b1 = this._b1; + if (lag !== this._lag) { + this._b1 = lag === 0 ? 0 : Math.exp(log001 / (lag * this.rate.sampleRate)); + this._lag = lag; + } + var y0 = this.world.f32_syncItems[2]; + if (warp === 0) { + y0 = (maxval - minval) * y0 + minval; + } else { + y0 = Math.pow(maxval / minval, y0) * minval; + if (isNaN(y0)) { y0 = 0; } + } + this.outputs[0][0] = y1 = y0 + b1 * (y1 - y0); + this._y1 = y1; + }; + return ctor; + })(); + + cc.ugen.specs.MouseY = MouseXY; + + cc.unit.specs.MouseY = (function() { + var ctor = function() { + this.process = next; + this._y1 = 0; + this._b1 = 0; + this._lag = 0; + this.process(1); + }; + var next = function() { + var minval = this.inputs[0][0] || 0.01; + var maxval = this.inputs[1][0]; + var warp = this.inputs[2][0]; + var lag = this.inputs[3][0]; + var y1 = this._y1; + var b1 = this._b1; + if (lag !== this._lag) { + this._b1 = lag === 0 ? 0 : Math.exp(log001 / (lag * this.rate.sampleRate)); + this._lag = lag; + } + var y0 = this.world.f32_syncItems[3]; + if (warp === 0) { + y0 = (maxval - minval) * y0 + minval; + } else { + y0 = Math.pow(maxval / minval, y0) * minval; + if (isNaN(y0)) { y0 = 0; } + } + this.outputs[0][0] = y1 = y0 + b1 * (y1 - y0); + this._y1 = y1; + }; + return ctor; + })(); + + cc.ugen.specs.MouseButton = { + $kr: { + defaults: "minval=0,maxval=1,lag=0.2", + ctor: function(minval, maxval, lag) { + return this.multiNew(1, minval, maxval, lag); + } + } + }; + + cc.unit.specs.MouseButton = (function() { + var ctor = function() { + this.process = next; + this._y1 = 0; + this._b1 = 0; + this._lag = 0; + this.process(1); + }; + var next = function() { + var minval = this.inputs[0][0]; + var maxval = this.inputs[1][0]; + var lag = this.inputs[2][0]; + var y1 = this._y1; + var b1 = this._b1; + if (lag !== this._lag) { + this._b1 = lag === 0 ? 0 : Math.exp(log001 / (lag * this.rate.sampleRate)); + this._lag = lag; + } + var y0 = this.world.f32_syncItems[4] ? maxval : minval; + this.outputs[0][0] = y1 = y0 + b1 * (y1 - y0); + this._y1 = y1; + }; + return ctor; + })(); + + module.exports = {}; + +}); +define('cc/lang/lang-worker', function(require, exports, module) { + + var cc = require("./cc"); + var extend = require("../common/extend"); + var onmessage = require("./utils").lang_onmessage; + + var WorkerSynthLang = (function() { + function WorkerSynthLang() { + cc.opmode = "worker"; + + cc.SynthLang.call(this); + this.sampleRate = 44100; + this.channels = 2; + this.strmLength = 1024; + this.bufLength = 64; + } + extend(WorkerSynthLang, cc.SynthLang); + + WorkerSynthLang.prototype.sendToClient = function(msg) { + postMessage(msg); + }; + WorkerSynthLang.prototype.sendToClientWithTransferable = function(uint8) { + postMessage(uint8, [uint8.buffer]); + }; + WorkerSynthLang.prototype.process = function() { + this.currentTime += this.currentTimeIncr; + this.taskManager.process(); + var timelineResult = this.timelineResult.splice(0); + this.sendToServer(["/processed", timelineResult]); + }; + + return WorkerSynthLang; + })(); + + cc.createWorkerSynthLang = function() { + var lang = new WorkerSynthLang(); + global.onmessage = onmessage; + return lang; + }; + + module.exports = {}; + +}); +define('cc/lang/lang-nodejs', function(require, exports, module) { + + var cc = require("./cc"); + var extend = require("../common/extend"); + + var NodeJSSynthLang = (function() { + function NodeJSSynthLang() { + cc.opmode = "nodejs"; + + cc.SynthLang.call(this); + + this.sampleRate = 44100; + this.channels = 2; + this.strmLength = 4096; + this.bufLength = 64; + } + extend(NodeJSSynthLang, cc.SynthLang); + + NodeJSSynthLang.prototype.process = function() { + this.currentTime += this.currentTimeIncr; + this.taskManager.process(); + var timelineResult = this.timelineResult.splice(0); + this.sendToServer(["/processed", timelineResult]); + }; + + return NodeJSSynthLang; + })(); + + cc.createNodeJSSynthLang = function() { + var lang = new NodeJSSynthLang(); + return lang; + }; + + module.exports = {}; + +}); +define('cc/lang/lang-socket', function(require, exports, module) { + + var cc = require("./cc"); + var extend = require("../common/extend"); + var onmessage = require("./utils").lang_onmessage; + + var SocketSynthLang = (function() { + require("../common/browser"); + + function SocketSynthLang() { + cc.opmode = "nodejs"; + + cc.SynthLang.call(this); + + this.sampleRate = 44100; + this.channels = 2; + this.strmLength = 4096; + this.bufLength = 64; + this.socketPath = null; + } + extend(SocketSynthLang, cc.SynthLang); + + SocketSynthLang.prototype.sendToClient = function(msg) { + postMessage(msg); + }; + SocketSynthLang.prototype.sendToClientWithTransferable = function(uint8) { + postMessage(uint8, [uint8.buffer]); + }; + SocketSynthLang.prototype.sendToServer = function() { + }; + SocketSynthLang.prototype.process = function() { + this.taskManager.process(); + var timelineResult = this.timelineResult.splice(0); + this.sendToServer(["/processed", timelineResult]); + }; + + SocketSynthLang.prototype.openSocket = function() { + var that = this; + var socket = this.socket = cc.createWebSocket(this.socketPath); + var pendings = []; + socket.binaryType = "arraybuffer"; + socket.onopen = function() { + pendings.forEach(function(msg) { + socket.send(msg); + }); + pendings = []; + }; + socket.onmessage = function(e) { + // receive a message from the socket-server + var msg = e.data; + if (typeof msg !== "string") { + that.sendToClient(new Float32Array(msg)); + return; + } + that.recvFromServer(JSON.parse(msg)); + }; + socket.onclose = function() { + }; + socket.onerror = function() { + }; + this.sendToServer = function(msg) { + if (msg instanceof Uint8Array) { + if (socket.readyState === WebSocket.OPEN) { + socket.send(msg.buffer); + } + } else { + if (socket.readyState === WebSocket.OPEN) { + socket.send(JSON.stringify(msg)); + } else { + pendings.push(JSON.stringify(msg)); + } + } + }; + }; + SocketSynthLang.prototype.closeSocket = function() { + this.socket.close(); + this.socket = null; + }; + + SocketSynthLang.prototype.process = function() { + var taskManager = this.taskManager; + var n = this.strmLength / this.bufLength; + var timelineResult = []; + var currentTimeIncr = this.currentTimeIncr; + while (n--) { + this.currentTime += currentTimeIncr; + taskManager.process(); + timelineResult = timelineResult.concat( + this.timelineResult.splice(0), 0 + ); + } + this.sendToServer(["/processed", timelineResult]); + }; + + SocketSynthLang.prototype.extendCommands = function(commands) { + commands["/socket/open"] = function(msg) { + this.socketPath = msg[1]; + this.openSocket(); + }; + commands["/socket/close"] = function() { + this.closeSocket(); + }; + commands["/socket/sendToServer"] = function(msg) { + // receive a message from the lang-interface + this.sendToServer(msg); + }; + commands["/socket/sendToClient"] = function(msg) { + // receive a message from the lang-interface + this.sendToClient(msg); + }; + }; + + return SocketSynthLang; + })(); + + cc.createSocketSynthLang = function() { + var lang = new SocketSynthLang(); + global.onmessage = onmessage; + cc.opmode = "socket"; + return lang; + }; + + module.exports = {}; + +}); +define('cc/server/server', function(require, exports, module) { + + var cc = require("./cc"); + var commands = {}; + + var SynthServer = (function() { + function SynthServer() { + this.sampleRate = 0; + this.channels = 0; + this.strmLength = 0; + this.bufLength = 0; + this.world = null; + this.rates = null; + this.strm = null; + this.timer = cc.createTimer(); + this.initialized = false; + this.syncCount = 0; + this.sysSyncCount = 0; + } + + SynthServer.prototype.sendToLang = function() { + throw "SynthServer#sendToLang: should be overridden"; + }; + SynthServer.prototype.recvFromLang = function(msg, userId) { + userId = userId|0; + if (msg instanceof Uint8Array) { + this.world.doBinayCommand(msg, userId); + } else { + var func = commands[msg[0]]; + if (func) { + func.call(this, msg, userId); + } else { + throw new Error("Unknown command: " + msg[0]); + } + } + }; + SynthServer.prototype.connect = function() { + throw "SynthServer#connect: should be overridden"; + }; + SynthServer.prototype.init = function(msg) { + if (!this.initialized) { + this.initialized = true; + if (msg) { + this.sampleRate = msg[1]|0; + this.channels = msg[2]|0; + this.strmLength = msg[3]|0; + } + this.strm = new Float32Array(this.strmLength * this.channels); + + var busLength = this.bufLength * 16 + 128; + var bufLength = this.bufLength; + var bufLength4 = this.bufLength << 2; + + this.busLength = busLength; + this.busClear = new Float32Array(busLength); + this.busOut = new Float32Array(busLength); + this.busOutLen = this.bufLength << 1; + this.busOutL = new Float32Array(this.busOut.buffer, 0 , bufLength); + this.busOutR = new Float32Array(this.busOut.buffer, bufLength4, bufLength); + if (!this.world) { + this.world = cc.createWorld(0); + } + this.rates = []; + this.rates[2 ] = cc.createRate(this.sampleRate, this.bufLength); + this.rates[1] = cc.createRate(this.sampleRate / this.bufLength, 1); + this.rates[0 ] = this.rates[1]; + this.rates[3 ] = this.rates[1]; + } + }; + SynthServer.prototype.play = function(msg, userId) { + userId = userId|0; + this.world.run(true, userId); + if (!this.timer.isRunning()) { + var that = this; + this.timer.start(function() { that.process(); }, 10); + } + this.sendToLang([ + "/played", this.syncCount + ]); + }; + SynthServer.prototype.pause = function(msg, userId) { + userId = userId|0; + this.world.run(false, userId); + if (this.timer.isRunning()) { + if (!this.world.isRunning()) { + this.timer.stop(); + } + } + this.sendToLang([ + "/paused", this.syncCount + ]); + }; + SynthServer.prototype.reset = function(msg, userId) { + userId = userId|0; + this.world.reset(userId); + }; + SynthServer.prototype.pushToTimeline = function(msg, userId) { + userId = userId|0; + var timeline = msg[1]; + if (timeline.length) { + this.world.pushToTimeline(timeline, userId); + } + }; + SynthServer.prototype.process = function() { + throw "SynthServer#process: should be overridden"; + }; + + return SynthServer; + })(); + + + commands["/init"] = function(msg, userId) { + this.init(msg, userId); + }; + commands["/play"] = function(msg, userId) { + this.play(msg, userId); + }; + commands["/pause"] = function(msg, userId) { + this.pause(msg, userId); + }; + commands["/reset"] = function(msg, userId) { + this.reset(msg, userId); + }; + commands["/processed"] = function(msg, userId) { + this.pushToTimeline(msg, userId); + }; + commands["/socket/sendToServer"] = function(msg, userId) { + // receive a message from the lang-interface via the lang + if (this.exports) { + msg = msg[1]; + msg.userId = userId; + this.exports.emit("message", msg); + } + }; + + cc.SynthServer = SynthServer; + + // TODO: moved + require("../common/timer"); + require("./rate"); + require("./unit"); + require("./buffer"); + require("./node"); + require("./world"); + require("./server-worker"); + require("./server-nodejs"); + require("./server-socket"); + require("./basic_unit"); + require("../plugins/installer"); + + cc.createSynthServer = function() { + switch (cc.opmode) { + case "worker": + return cc.createWorkerSynthServer(); + case "nodejs": + return cc.createNodeJSSynthServer(); + case "socket": + return cc.createSocketSynthServer(); + } + throw new Error("A SynthServer is not defined for: " + cc.opmode); + }; + + module.exports = {}; + +}); +define('cc/server/cc', function(require, exports, module) { + + var _cc = require("../cc"); + + if (!_cc.UGen) { + _cc.UGen = Object; + } + + module.exports = _cc; + +}); +define('cc/common/timer', function(require, exports, module) { + + var cc = require("../cc"); + + var NativeTimer = (function() { + function NativeTimer() { + this._timerId = 0; + } + NativeTimer.prototype.start = function(callback, interval) { + if (this._timerId) { + clearInterval(this._timerId); + } + this._timerId = setInterval(callback, interval); + }; + NativeTimer.prototype.stop = function() { + if (this._timerId) { + clearInterval(this._timerId); + } + this._timerId = 0; + }; + NativeTimer.prototype.isRunning = function() { + return !!this._timerId; + }; + return NativeTimer; + })(); + + cc.createTimer = function() { + return new NativeTimer(); + }; + + module.exports = { + NativeTimer: NativeTimer + }; + +}); +define('cc/server/rate', function(require, exports, module) { + + var cc = require("./cc"); + + var Rate = (function() { + var twopi = 2 * Math.PI; + function Rate(sampleRate, bufLength) { + this.sampleRate = sampleRate; + this.sampleDur = 1 / sampleRate; + this.radiansPerSample = twopi / sampleRate; + this.bufLength = bufLength; + this.bufDuration = bufLength / sampleRate; + this.bufRate = 1 / this.bufDuration; + this.slopeFactor = 1 / bufLength; + this.filterLoops = (bufLength / 3)|0; + this.filterRemain = (bufLength % 3)|0; + if (this.filterLoops === 0) { + this.filterSlope = 0; + } else { + this.filterSlope = 1 / this.filterLoops; + } + } + return Rate; + })(); + + cc.createRate = function(sampleRate, bufLength) { + return new Rate(sampleRate, bufLength); + }; + + module.exports = {}; + +}); +define('cc/server/unit', function(require, exports, module) { + + var cc = require("../cc"); + + var Unit = (function() { + function Unit(parent, specs) { + this.parent = parent; + this.world = parent.world; + this.specs = specs; + this.name = specs[0]; + this.calcRate = specs[1]; + this.specialIndex = specs[2]; + this.numInputs = specs[3].length >> 1; + this.numOutputs = specs[4].length; + this.inputs = new Array(this.numInputs); + this.inRates = new Array(this.numInputs); + this.fromUnits = new Array(this.numInputs); + this.outRates = specs[4]; + this.rate = cc.server.rates[this.calcRate]; + var bufLength = this.rate.bufLength; + + var BYTES_PER_ELEMENT = Float32Array.BYTES_PER_ELEMENT; + + var heap = new Float32Array( + parent.heap.buffer, + parent.heapIndex * BYTES_PER_ELEMENT, + bufLength * this.numOutputs + ); + parent.heapIndex += bufLength * this.numOutputs; + + var outputs = new Array(this.numOutputs); + for (var i = 0, imax = outputs.length; i < imax; ++i) { + outputs[i] = new Float32Array( + heap.buffer, + heap.byteOffset + (bufLength * i * BYTES_PER_ELEMENT), + bufLength + ); + } + this.heap = heap; + this.outputs = outputs; + this.bufLength = bufLength; + this.done = false; + } + Unit.prototype.init = function() { + var ctor = cc.unit.specs[this.name]; + if (typeof ctor === "function") { + ctor.call(this); + } else { + throw new Error(this.name + "'s ctor is not found."); + } + return this; + }; + Unit.prototype.doneAction = function(action) { + this.parent.doneAction(action); + }; + return Unit; + })(); + + cc.createUnit = function(parent, specs) { + return new Unit(parent, specs); + }; + + module.exports = { + Unit : Unit + }; + +}); +define('cc/server/buffer', function(require, exports, module) { + + var cc = require("./cc"); + + var Buffer = (function() { + function Buffer(world, bufnum, frames, channels) { + this.world = world; + this.bufnum = bufnum; + this.frames = frames; + this.channels = channels; + this.sampleRate = cc.server.sampleRate; + this.samples = new Float32Array(frames * channels); + } + Buffer.prototype.bind = function(sampleRate, channels, frames, samples) { + this.sampleRate = sampleRate; + this.channels = channels; + this.frames = frames; + this.samples = samples; + }; + Buffer.prototype.zero = function() { + var i, samples = this.samples; + for (i = samples.length; i--; ) { + samples[i] = 0; + } + }; + Buffer.prototype.fill = function(params) { + var n = (params.length / 3)|0; + var samples = this.samples; + var startAt, length, value; + var i, j, k = 0; + for (i = 0; i < n; i++) { + startAt = params[k++]; + length = params[k++]; + value = params[k++]; + for (j = 0; j < length; ++j) { + if (startAt + j >= samples.length) { + break; + } + samples[startAt + j] = value; + } + } + }; + Buffer.prototype.set = function(params) { + var samples = this.samples; + var samples_length = samples.length; + var index, value, values; + var i, imax = params.length; + var j, jmax; + for (i = 0; i < imax; i += 2) { + index = params[i]; + if (typeof index !== "number" || index < 0 || samples_length <= index) { + continue; + } + index |= 0; + value = params[i+1]; + if (typeof value === "number") { + samples[index] = value || 0; // remove NaN + } else if (Array.isArray(value)) { + values = value; + for (j = 0, jmax = values.length; j < jmax; ++j) { + if (samples_length <= index + j) { + break; + } + value = values[j]; + if (typeof value === "number") { + samples[index + j] = value || 0; // remove NaN + } + } + } + } + }; + Buffer.prototype.get = function(index, callbackId) { + var samples = this.samples; + var msg = [ "/b_get", callbackId, samples[index] || 0 ]; + cc.server.sendToLang(msg); // TODO: userId + }; + Buffer.prototype.getn = function(index, count, callbackId) { + var samples = this.samples; + var msg = new Array(count + 2); + msg[0] = "/b_getn"; + msg[1] = callbackId; + for (var i = 0; i < count; ++i) { + msg[i + 2] = samples[i + index] || 0; + } + cc.server.sendToLang(msg); // TODO: userId + }; + Buffer.prototype.gen = function(cmd, flags, params) { + var func = gen_func[cmd]; + if (func) { + func(this, flags, params); + } + }; + return Buffer; + })(); + + var gen_func = {}; + + gen_func.copy = function(buf, flags, params) { + var bufnum = params[0]; + var dstStartAt = params[1]; + var srcStartAt = params[2]; + var numSamples = params[3]; + var target = buf.world.buffers[bufnum]; + if (target) { + var samples; + if (numSamples > 0) { + samples = target.samples.slice(srcStartAt, srcStartAt + numSamples); + } else { + samples = target.samples.slice(srcStartAt); + } + buf.samples.set(samples, dstStartAt); + } + }; + + gen_func.normalize = function(buf, flags, params) { + var samples = buf.samples; + var wavetable = flags & 2; + if (wavetable) { + normalize_wsamples(samples.length, samples, params[0]); + } else { + normalize_samples(samples.length, samples, params[0]); + } + }; + + gen_func.sine1 = function(buf, flags, params) { + var samples = buf.samples; + var normalize = flags & 1; + var wavetable = flags & 2; + var clear = flags & 4; + var len = samples.length; + var i, imax; + if (clear) { + for (i = samples.length; i--; ) { + samples[i] = 0; + } + } + if (wavetable) { + for (i = 0, imax = params.length; i < imax; ++i) { + add_wpartial(len, samples, i+1, params[i], 0); + } + } else { + for (i = 0, imax = params.length; i < imax; ++i) { + add_partial(len, samples, i+1, params[i], 0); + } + } + if (normalize) { + if (wavetable) { + normalize_wsamples(samples.length, samples, 1); + } else { + normalize_samples(samples.length, samples, 1); + } + } + }; + + gen_func.sine2 = function(buf, flags, params) { + var samples = buf.samples; + var normalize = flags & 1; + var wavetable = flags & 2; + var clear = flags & 4; + var len = samples.length; + var i, imax; + if (clear) { + for (i = samples.length; i--; ) { + samples[i] = 0; + } + } + if (wavetable) { + for (i = 0, imax = params.length; i < imax; i += 2) { + add_wpartial(len, samples, params[i], params[i+1], 0); + } + } else { + for (i = 0, imax = params.length; i < imax; i += 2) { + add_partial(len, samples, params[i], params[i+1], 0); + } + } + if (normalize) { + if (wavetable) { + normalize_wsamples(samples.length, samples, 1); + } else { + normalize_samples(samples.length, samples, 1); + } + } + }; + + gen_func.sine3 = function(buf, flags, params) { + var samples = buf.samples; + var normalize = flags & 1; + var wavetable = flags & 2; + var clear = flags & 4; + var len = samples.length; + var i, imax; + if (clear) { + for (i = samples.length; i--; ) { + samples[i] = 0; + } + } + if (wavetable) { + for (i = 0, imax = params.length; i < imax; i += 3) { + add_wpartial(len, samples, params[i], params[i+1], params[i+2]); + } + } else { + for (i = 0, imax = params.length; i < imax; i += 3) { + add_partial(len, samples, params[i], params[i+1], params[i+2]); + } + } + if (normalize) { + if (wavetable) { + normalize_wsamples(samples.length, samples, 1); + } else { + normalize_samples(samples.length, samples, 1); + } + } + }; + + gen_func.cheby = function(buf, flags, params) { + var samples = buf.samples; + var normalize = flags & 1; + var wavetable = flags & 2; + var clear = flags & 4; + var len = samples.length; + var i, imax; + if (clear) { + for (i = samples.length; i--; ) { + samples[i] = 0; + } + } + if (wavetable) { + for (i = 0, imax = params.length; i < imax; ++i) { + add_wchebyshev(len, samples, i+1, params[i]); + } + } else { + for (i = 0, imax = params.length; i < imax; ++i) { + add_chebyshev(len, samples, i+1, params[i]); + } + } + if (normalize) { + if (wavetable) { + normalize_wsamples(samples.length, samples, 1); + } else { + normalize_samples(samples.length, samples, 1); + } + } + }; + + var add_wpartial = function(size, data, partial, amp, phase) { + if (amp === 0) { + return; + } + var size2 = size >> 1; + var w = (partial * 2.0 * Math.PI) / size2; + var cur = amp * Math.sin(phase); + var next; + phase += w; + for (var i = 0; i < size; i += 2) { + next = amp * Math.sin(phase); + data[i] += 2 * cur - next; + data[i+1] += next - cur; + cur = next; + phase += w; + } + }; + var add_partial = function(size, data, partial, amp, phase) { + if (amp === 0) { + return; + } + var w = (partial * 2.0 * Math.PI) / size; + for (var i = 0; i < size; ++i) { + data[i] += amp * Math.sin(phase); + phase += w; + } + }; + var add_wchebyshev = function(size, data, partial, amp) { + if (amp === 0) { + return; + } + var size2 = size >> 1; + var w = 2 / size2; + var phase = -1; + var offset = -amp * Math.cos(partial * Math.PI * 0.5); + var cur = amp * Math.cos(partial * Math.acos(phase)) - offset; + var next; + phase += w; + for (var i = 0; i < size; i += 2) { + next = amp * Math.cos(partial * Math.acos(phase)) - offset; + data[i] += 2 * cur - next; + data[i+1] += next - cur; + cur = next; + phase += w; + } + }; + var add_chebyshev = function(size, data, partial, amp) { + if (amp === 0) { + return; + } + var w = 2 / size; + var phase = -1; + var offset = -amp * Math.cos(partial * Math.PI * 0.5); + for (var i = 0; i < size; ++i) { + data[i] += amp * Math.cos(partial * Math.acos(phase)) - offset; + phase += w; + } + }; + + var normalize_samples = function(size, data, peak) { + var maxamp, absamp, ampfac, i; + for (i = maxamp = 0; i < size; ++i) { + absamp = Math.abs(data[i]); + if (absamp > maxamp) { maxamp = absamp; } + } + if (maxamp !== 0 && maxamp !== peak) { + ampfac = peak / maxamp; + for (i = 0; i < size; ++i) { + data[i] *= ampfac; + } + } + }; + + var normalize_wsamples = function(size, data, peak) { + var maxamp, absamp, ampfac, i; + for (i = maxamp = 0; i < size; i += 2) { + absamp = Math.abs(data[i] + data[i+1]); + if (absamp > maxamp) { maxamp = absamp; } + } + if (maxamp !== 0 && maxamp !== peak) { + ampfac = peak / maxamp; + for (i = 0; i < size; ++i) { + data[i] *= ampfac; + } + } + }; + + cc.createServerBuffer = function(world, bufnum, frames, channels) { + return new Buffer(world, bufnum, frames, channels); + }; + + module.exports = { + Buffer: Buffer, + add_partial : add_partial, + add_wpartial : add_wpartial, + add_chebyshev : add_chebyshev, + add_wchebyshev: add_wchebyshev, + normalize_samples : normalize_samples, + normalize_wsamples: normalize_wsamples + }; + +}); +define('cc/server/node', function(require, exports, module) { + + var cc = require("./cc"); + var extend = require("../common/extend"); + + var graphFunc = []; + var doneAction = []; + + var Node = (function() { + function Node(world, nodeId) { + this.world = world; + this.nodeId = nodeId|0; + this.next = null; + this.prev = null; + this.parent = null; + this.running = true; + } + + Node.prototype.run = function(inRun) { + this.running = !!inRun; + }; + + Node.prototype.end = function() { + if (this.nodeId !== 0) { + if (this.prev) { + this.prev.next = this.next; + } + if (this.next) { + this.next.prev = this.prev; + } + + if( this.parent ) { + if (this.parent.head === this) { + this.parent.head = this.next; + } + if (this.parent.tail === this) { + this.parent.tail = this.prev; + } + + } + this.prev = null; + this.next = null; + this.parent = null; + this.world.nodes[this.nodeId] = null; + } + this.running = false; + }; + + Node.prototype.doneAction = function(action) { + var func = doneAction[action]; + if (func) { + func(this); + } + }; + + return Node; + })(); + + var Group = (function() { + function Group(world, nodeId, target, addAction) { + Node.call(this, world, nodeId); + this.head = null; + this.tail = null; + if (target) { + graphFunc[addAction](this, target); + } + } + extend(Group, Node); + + Group.prototype.endAll = function() { + var next, node = this.head; + while (node) { + next = node.next; + node.end(); + node = next; + } + this.end(); + }; + + Group.prototype.endDeep = function() { + var next, node = this.head; + while (node) { + next = node.next; + if (node instanceof Group) { + node.endDeep(); + } else { + node.end(); + } + node = next; + } + this.end(); + }; + + Group.prototype.process = function(inNumSamples) { + if (this.head && this.running) { + this.head.process(inNumSamples); + } + if (this.next) { + this.next.process(inNumSamples); + } + }; + + return Group; + })(); + + var Synth = (function() { + function Synth(world, nodeId, target, addAction, defId, controls) { + Node.call(this, world, nodeId); + var specs = world.defs[defId]; + if (specs) { + this.build(specs, controls); + } + if (target) { + graphFunc[addAction](this, target); + } + } + extend(Synth, Node); + + Synth.prototype.build = function(specs, controls) { + var list, fixNumList, unitList = []; + var world = this.world; + var heap = new Float32Array(specs.heapSize); + var unit, inputs, inRates, fromUnits, inSpec; + var i, imax, j, jmax, k, u, x1, x2; + + this.specs = specs; + this.params = specs.params; + + this.heap = heap; + this.heapIndex = this.params.values.length; + heap.set(this.params.values); + + this.controls = heap; + this.set(controls); + + list = specs.consts; + fixNumList = new Array(list.length); + for (i = 0, imax = list.length; i < imax; ++i) { + fixNumList[i] = world.getFixNum(list[i]); + } + + list = specs.defList; + for (i = 0, imax = list.length; i < imax; ++i) { + unit = cc.createUnit(this, list[i]); + inputs = unit.inputs; + inRates = unit.inRates; + fromUnits = unit.fromUnits; + inSpec = unit.specs[3]; + for (j = k = 0, jmax = inputs.length; j < jmax; ++j) { + x1 = inSpec[k++]; + x2 = inSpec[k++]; + if (x1 === -1) { + inputs[j] = fixNumList[x2].outputs[0]; + inRates[j] = 0; + } else { + u = unitList[x1]; + inputs[j] = u.outputs[x2]; + inRates[j] = u.outRates[x2]; + fromUnits[j] = u; + } + } + unit.init(); + if (unit.process && unit.rate !== 3) { + unitList.push(unit); + } + } + this.unitList = unitList; + + return this; + }; + + Synth.prototype.set = function(params) { + var controls = this.controls; + for (var i = 0, imax = params.length; i < imax; i += 2) { + controls[params[i]] = params[i + 1]; + } + }; + + Synth.prototype.process = function(inNumSamples) { + if (this.running) { + var unitList = this.unitList; + for (var i = 0, imax = unitList.length; i < imax; ++i) { + var unit = unitList[i]; + unit.process(unit.rate.bufLength); + } + } + if (this.next) { + this.next.process(inNumSamples); + } + }; + + return Synth; + })(); + + graphFunc[0] = function(child, addThisOne) { + if (child.nodeId !== 0 && addThisOne instanceof Group) { + child.prev = null; + child.next = addThisOne.head; + if (addThisOne.head) { + addThisOne.head.prev = child; + addThisOne.head = child; + } else { + addThisOne.head = addThisOne.tail = child; + } + child.parent = addThisOne; + } + }; + graphFunc[1] = function(child, addThisOne) { + if (child.nodeId !== 0 && addThisOne instanceof Group) { + child.prev = addThisOne.tail; + child.next = null; + if (addThisOne.tail) { + addThisOne.tail.next = child; + addThisOne.tail = child; + } else { + addThisOne.head = addThisOne.tail = child; + } + child.parent = addThisOne; + } + }; + graphFunc[2] = function(node, beforeThisOne) { + if (node.nodeId !== 0 && beforeThisOne.parent) { + node.parent = beforeThisOne.parent; + node.prev = beforeThisOne.prev; + node.next = beforeThisOne; + + if (beforeThisOne.prev) { + beforeThisOne.prev.next = node; + } else { + node.parent.head = node; + } + beforeThisOne.prev = node; + } + }; + graphFunc[3] = function(node, afterThisOne) { + if (node.nodeId !== 0 && afterThisOne.parent) { + node.parent = afterThisOne.parent; + node.prev = afterThisOne; + node.next = afterThisOne.next; + + if (afterThisOne.next) { + afterThisOne.next.prev = node; + } else { + node.parent.tail = node; + } + afterThisOne.next = node; + } + }; + graphFunc[4] = function(node, replaceThisOne) { + if (node.node !== 0 && replaceThisOne.parent) { + var parent = node.parent = replaceThisOne.parent; + node.prev = replaceThisOne.prev; + node.next = replaceThisOne.next; + + if (node instanceof Group) { + node.head = replaceThisOne.head; + node.tail = replaceThisOne.tail; + } + + if (replaceThisOne.prev) { + replaceThisOne.prev.next = node; + } + if (replaceThisOne.next) { + replaceThisOne.next.prev = node; + } + if (parent.head === replaceThisOne) { + parent.head = node; + } + if (parent.tail === replaceThisOne) { + parent.tail = node; + } + } + }; + + // do nothing when the UGen is finished + doneAction[0] = null; + + // pause the enclosing synth, but do not free it + doneAction[1] = function(node) { + node.running = false; + }; + + // free the enclosing synth + doneAction[2] = function(node) { + node.end(); + }; + + // free both this synth and the preceding node + doneAction[3] = function(node) { + if (node.prev) { + node.prev.end(); + } + node.end(); + }; + + // free both this synth and the following node + doneAction[4] = function(node) { + if (node.next) { + node.next.end(); + } + node.end(); + }; + + // free this synth; if the preceding node is a group then do g_freeAll on it, else free it + doneAction[5] = function(node) { + var prev = node.prev; + if (prev instanceof Group) { + prev.endAll(); + } else if (prev) { + prev.end(); + } + node.end(); + }; + + // free this synth; if the following node is a group then do g_freeAll on it, else free it + doneAction[6] = function(node) { + var next = node.next; + node.end(); + if (next instanceof Group) { + next.endAll(); + } else if (next) { + next.end(); + } + }; + + // free this synth and all preceding nodes in this group + doneAction[7] = function(node) { + var prev; + while (node) { + prev = node.prev; + node.end(); + node = prev; + } + }; + + // free this synth and all following nodes in this group + doneAction[8] = function(node) { + var next; + while (node) { + next = node.next; + node.end(); + node = next; + } + }; + + // free this synth and pause the preceding node + doneAction[9] = function(node) { + if (node.prev) { + node.prev.running = false; + } + node.end(); + }; + + // free this synth and pause the following node + doneAction[10] = function(node) { + if (node.next) { + node.next.running = false; + } + node.end(); + }; + + // free this synth and if the preceding node is a group then do g_deepFree on it, else free it + doneAction[11] = function(node) { + var prev = node.prev; + if (prev instanceof Group) { + prev.endDeep(); + } else if (prev) { + prev.end(); + } + node.end(); + }; + + // free this synth and if the following node is a group then do g_deepFree on it, else free it + doneAction[12] = function(node) { + var next = node.next; + if (next instanceof Group) { + next.endDeep(); + } else if (next) { + next.end(); + } + node.end(); + }; + + // free this synth and all other nodes in this group (before and after) + doneAction[13] = function(node) { + var next; + node = node.parent.head; + while (node) { + next = node.next; + node.end(); + node = next; + } + }; + + // free the enclosing group and all nodes within it (including this synth) + doneAction[14] = function(node) { + node.parent.endDeep(); + }; + + + cc.createServerRootNode = function(world) { + return new Group(world, 0, 0, 0); + }; + + cc.createServerGroup = function(world, nodeId, target, addAction) { + return new Group(world, nodeId, target, addAction); + }; + + cc.createServerSynth = function(world, nodeId, target, addAction, defId, controls) { + return new Synth(world, nodeId, target, addAction, defId, controls); + }; + + module.exports = { + Node : Node, + Group: Group, + Synth: Synth, + graphFunc: graphFunc + }; + +}); +define('cc/server/world', function(require, exports, module) { + + var cc = require("./cc"); + var push = [].push; + + var commands = {}; + + var World = (function() { + function World(userId) { + this.userId = userId|0; + this.bus = new Float32Array(cc.server.busClear); + this.busClear = cc.server.busClear; + + this.busIndex = 0; + this.busAmp = 0.8; + this.timeline = []; + this.timelineIndex = 0; + this.rootNode = cc.createServerRootNode(this); + this.nodes = { 0:this.rootNode }; + this.fixNums = {}; + this.defs = {}; + this.buffers = []; + this.bufSrc = {}; + this.syncItems = new Uint8Array(20); + this.i16_syncItems = new Int16Array(this.syncItems.buffer); + this.f32_syncItems = new Float32Array(this.syncItems.buffer); + } + World.prototype.run = function(flag) { + this.rootNode.run(flag); + this.bus.set(this.busClear); + this.timeline = []; + }; + World.prototype.reset = function() { + this.bus.set(this.busClear); + this.timeline = []; + this.rootNode = cc.createServerRootNode(this); + this.nodes = { 0:this.rootNode }; + this.fixNums = {}; + this.defs = {}; + this.buffers = {}; + this.bufSrc = {}; + }; + World.prototype.isRunning = function() { + return this.rootNode.running; + }; + World.prototype.pushToTimeline = function(timeline) { + push.apply(this.timeline, timeline); + }; + World.prototype.doBinayCommand = function(binary) { + var func = commands[(binary[1] << 8) + binary[0]]; + if (func) { + func(this, binary); + } + }; + World.prototype.getFixNum = function(value) { + var fixNums = this.fixNums; + return fixNums[value] || (fixNums[value] = { + outputs: [ new Float32Array([value]) ] + }); + }; + World.prototype.process = function(bufLength) { + var timeline = this.timeline; + var args, func; + + while ((args = timeline.shift())) { + func = commands[args[0]]; + if (func) { + func(this, args); + } + } + + this.bus.set(this.busClear); + this.rootNode.process(bufLength, this); + }; + + return World; + })(); + + commands["/n_run"] = function(world, args) { + var nodeId = args[1]|0; + var flag = !!args[2]; + var target = world.nodes[nodeId]; + if (target) { + target.run(flag); + } + }; + commands["/n_free"] = function(world, args) { + var nodeId = args[1]|0; + var target = world.nodes[nodeId]; + if (target) { + target.doneAction(2); + } + }; + commands["/n_set"] = function(world, args) { + var nodeId = args[1]|0; + var controls = args[2]; + var target = world.nodes[nodeId]; + if (target) { + target.set(controls); + } + }; + commands["/g_new"] = function(world, args) { + var nodeId = args[1]|0; + var addAction = args[2]|0; + var targetNodeId = args[3]|0; + var target = world.nodes[targetNodeId]; + if (target) { + world.nodes[nodeId] = cc.createServerGroup(world, nodeId, target, addAction); + } + }; + commands["/s_def"] = function(world, args) { + var defId = args[1]|0; + var specs = args[2]; + world.defs[defId] = specs; + }; + commands["/s_new"] = function(world, args) { + var nodeId = args[1]|0; + var addAction = args[2]|0; + var targetNodeId = args[3]|0; + var defId = args[4]|0; + var controls = args[5]; + var target = world.nodes[targetNodeId]; + if (target) { + world.nodes[nodeId] = cc.createServerSynth(world, nodeId, target, addAction, defId, controls); + } + }; + commands["/b_new"] = function(world, args) { + var bufnum = args[1]|0; + var frames = args[2]|0; + var channels = args[3]|0; + world.buffers[bufnum] = cc.createServerBuffer(world, bufnum, frames, channels); + }; + commands["/b_free"] = function(world, args) { + var bufnum = args[1]|0; + world.buffers[bufnum] = null; + }; + commands["/b_zero"] = function(world, args) { + var bufnum = args[1]|0; + var buffer = world.buffers[bufnum]; + if (buffer) { + buffer.zero(); + } + }; + commands["/b_set"] = function(world, args) { + var bufnum = args[1]|0; + var params = args[2]; + var buffer = world.buffers[bufnum]; + if (buffer) { + buffer.set(params); + } + }; + commands["/b_get"] = function(world, args) { + var bufnum = args[1]|0; + var index = args[2]|0; + var callbackId = args[3]|0; + var buffer = world.buffers[bufnum]; + if (buffer) { + buffer.get(index, callbackId); + } + }; + commands["/b_getn"] = function(world, args) { + var bufnum = args[1]|0; + var index = args[2]|0; + var count = args[3]|0; + var callbackId = args[4]|0; + var buffer = world.buffers[bufnum]; + if (buffer) { + buffer.getn(index, count, callbackId); + } + }; + commands["/b_fill"] = function(world, args) { + var bufnum = args[1]|0; + var params = args[2]; + var buffer = world.buffers[bufnum]; + if (buffer) { + buffer.fill(params); + } + }; + commands["/b_gen"] = function(world, args) { + var bufnum = args[1]|0; + var cmd = args[2]; + var flag = args[3]|0; + var params = args.slice(4); + var buffer = world.buffers[bufnum]; + if (buffer) { + buffer.gen(cmd, flag, params); + } + }; + + commands[0] = function(world, binary) { + world.syncItems.set(binary); + var server = cc.server; + var syncCount = new Uint32Array(binary.buffer)[1]; + if (server.sysSyncCount < syncCount) { + server.sysSyncCount = syncCount; + } + }; + commands[1] = function(world, binary) { + var bufnum = (binary[3] << 8) + binary[2]; + var channels = (binary[7] << 8) + binary[6]; + var sampleRate = (binary[11] << 24) + (binary[10] << 16) + (binary[ 9] << 8) + binary[ 8]; + var frames = (binary[15] << 24) + (binary[14] << 16) + (binary[13] << 8) + binary[12]; + var samples = new Float32Array(binary.buffer, 16); + var buffer = world.buffers[bufnum]; + if (buffer) { + buffer.bind(sampleRate, channels, frames, samples); + } + }; + + cc.createWorld = function(userId) { + return new World(userId); + }; + + module.exports = { + World : World, + commands: commands + }; + +}); +define('cc/server/server-worker', function(require, exports, module) { + + var cc = require("./cc"); + var extend = require("../common/extend"); + + var WorkerSynthServer = (function() { + function WorkerSynthServer() { + cc.SynthServer.call(this); + + this.sampleRate = 44100; + this.channels = 2; + this.strmLength = 1024; + this.bufLength = 64; + } + extend(WorkerSynthServer, cc.SynthServer); + + WorkerSynthServer.prototype.sendToLang = function(msg) { + postMessage(msg); + }; + WorkerSynthServer.prototype.connect = function() { + this.sendToLang([ + "/connected", this.sampleRate, this.channels + ]); + }; + WorkerSynthServer.prototype.process = function() { + if (this.sysSyncCount < this.syncCount - 4) { + return; + } + var strm = this.strm; + var world = this.world; + var strmLength = this.strmLength; + var bufLength = this.bufLength; + var busOut = this.busOut; + var busOutL = this.busOutL; + var busOutR = this.busOutR; + var lang = cc.lang; + var offsetL = 0; + var offsetR = strmLength; + for (var i = 0, imax = strmLength / bufLength; i < imax; ++i) { + lang.process(); + world.process(bufLength); + busOut.set(world.bus); + strm.set(busOutL, offsetL); + strm.set(busOutR, offsetR); + offsetL += bufLength; + offsetR += bufLength; + } + this.sendToLang(strm); + this.syncCount += 1; + }; + + return WorkerSynthServer; + })(); + + cc.createWorkerSynthServer = function() { + var server = new WorkerSynthServer(); + cc.opmode = "worker"; + return server; + }; + + module.exports = {}; + +}); +define('cc/server/server-nodejs', function(require, exports, module) { + + var cc = require("./cc"); + var extend = require("../common/extend"); + + var NodeJSSynthServer = (function() { + function NodeJSSynthServer() { + require("../common/audioapi"); + + cc.SynthServer.call(this); + + this.sampleRate = 44100; + this.channels = 2; + this.strmLength = 4096; + this.bufLength = 64; + } + extend(NodeJSSynthServer, cc.SynthServer); + + NodeJSSynthServer.prototype.init = function() { + if (!this.initialized) { + cc.SynthServer.prototype.init.call(this); + this.api = cc.createAudioAPI(this); + } + }; + NodeJSSynthServer.prototype.connect = function() { + this.sendToLang([ + "/connected", this.sampleRate, this.channels + ]); + }; + NodeJSSynthServer.prototype.play = function(msg, userId) { + userId = userId|0; + this.world.run(true, userId); + if (this.api) { + this._strm = new Float32Array(this.strmLength * this.channels); + this.strmList = new Array(8); + this.strmListReadIndex = 0; + this.strmListWriteIndex = 0; + var strmList = this.strmList; + for (var i = strmList.length; i--; ) { + strmList[i] = new Float32Array(this._strm); + } + if (!this.api.isPlaying) { + this.api.play(); + } + } + if (!this.timer.isRunning()) { + var that = this; + setTimeout(function() { + that.timer.start(function() { that.process(); }, 10); + }, 50); // TODO: ??? + } + }; + NodeJSSynthServer.prototype.pause = function(msg, userId) { + userId = userId|0; + this.world.run(false, userId); + if (this.api) { + if (this.api.isPlaying) { + if (!this.world.isRunning()) { + this.api.pause(); + } + } + } + if (this.timer.isRunning()) { + if (!this.world.isRunning()) { + this.timer.stop(); + } + } + }; + NodeJSSynthServer.prototype.process = function() { + if (this.sysSyncCount < this.syncCount - 4) { + return; + } + var strm = this.strm; + var world = this.world; + var strmLength = this.strmLength; + var bufLength = this.bufLength; + var busOut = this.busOut; + var busOutL = this.busOutL; + var busOutR = this.busOutR; + var lang = cc.lang; + var offsetL = 0; + var offsetR = strmLength; + for (var i = 0, imax = strmLength / bufLength; i < imax; ++i) { + lang.process(); + world.process(bufLength); + busOut.set(world.bus); + strm.set(busOutL, offsetL); + strm.set(busOutR, offsetR); + offsetL += bufLength; + offsetR += bufLength; + } + this.sendToLang(strm); + this.syncCount += 1; + if (this.api) { + this.strmList[this.strmListWriteIndex & 7] = new Float32Array(strm); + this.strmListWriteIndex += 1; + } + }; + NodeJSSynthServer.prototype._process = function() { + var strm = this.strmList[this.strmListReadIndex & 7]; + if (strm) { + this.strmListReadIndex += 1; + this._strm.set(strm); + } + this.sysSyncCount += 1; + }; + + return NodeJSSynthServer; + })(); + + cc.NodeJSSynthServer = NodeJSSynthServer; + cc.createNodeJSSynthServer = function() { + var server = new NodeJSSynthServer(); + cc.opmode = "nodejs"; + return server; + }; + + module.exports = {}; + +}); +define('cc/server/server-socket', function(require, exports, module) { + + var cc = require("./cc"); + var extend = require("../common/extend"); + var emitter = require("../common/emitter"); + + var WorldManager = (function() { + function WorldManager() { + this.map = {}; + this.list = []; + this.server = null; + this.process = process0; + } + + WorldManager.prototype.append = function(userId) { + if (!this.map[userId]) { + var world = cc.createWorld(userId); + this.map[userId] = world; + this.list.push(world); + if (this.list.length === 1) { + this.process = process1; + } else { + this.process = processN; + } + } + return this.map[userId]; + }; + WorldManager.prototype.remove = function(userId) { + var world = this.map[userId]; + if (world) { + this.list.splice(this.list.indexOf(world), 1); + delete this.map[userId]; + if (this.list.length === 1) { + this.process = process1; + } else if (this.list.length === 0) { + this.process = process0; + } + } + }; + WorldManager.prototype.run = function(flag, userId) { + var world = this.map[userId]; + if (world) { + world.run(flag); + } + }; + WorldManager.prototype.reset = function(userId) { + var world = this.map[userId]; + if (world) { + world.reset(); + } + }; + WorldManager.prototype.isRunning = function() { + return this.list.some(function(world) { + return world.isRunning(); + }); + }; + WorldManager.prototype.pushToTimeline = function(timeline, userId) { + var world = this.map[userId]; + if (world) { + world.pushToTimeline(timeline); + } + }; + WorldManager.prototype.doBinayCommand = function(binary, userId) { + var world = this.map[userId]; + if (world) { + world.doBinayCommand(binary); + } + }; + + var process0 = function() { + cc.server.busOut.set(cc.server.busClear); + }; + var process1 = function(bufLength) { + this.list[0].process(bufLength); + cc.server.busOut.set(this.list[0].bus); + }; + var processN = function(bufLength) { + var list = this.list; + var busOut = cc.server.busOut; + var busOutLen = cc.server.busOutLen; + var world; + busOut.set(cc.server.busClear); + for (var i = 0, imax = list.length; i < imax; ++i) { + world = list[i]; + world.process(bufLength); + var inBus = world.bus; + var inAmp = world.busAmp; + for (var j = busOutLen; j--; ) { + busOut[j] += inBus[j] * inAmp; + } + } + }; + + return WorldManager; + })(); + + var SocketSynthServer = (function() { + var WebSocketServer; + if (global.require) { + WebSocketServer = global.require("ws").Server; + } + function SocketSynthServer() { + cc.NodeJSSynthServer.call(this); + this.sampleRate = 44100; + this.channels = 2; + this.strmLength = 4096; + this.bufLength = 64; + this.world = new WorldManager(); + this.list = []; + this.map = {}; + this.exports = null; // bind after + } + extend(SocketSynthServer, cc.NodeJSSynthServer); + + SocketSynthServer.prototype._init = function(opts) { + var that = this; + var _userId = 0; + var exports = this.exports; + if (typeof opts.speaker !== "undefined") { + if (opts.speaker) { + this.api = cc.createAudioAPI(this); + } + delete opts.speaker; + } + this.socket = new WebSocketServer(opts); + this.socket.on("connection", function(ws) { + var userId = _userId++; + that.list.push(ws); + that.map[userId] = ws; + that.world.append(userId); + ws.on("message", function(msg) { + // receive a message from the lang + if (typeof msg !== "string") { + msg = new Uint8Array(msg); + } else { + msg = JSON.parse(msg); + } + that.recvFromLang(msg, userId); + }); + ws.on("close", function() { + if (that.map[userId]) { + that.pause([], userId); + that.world.remove(userId); + that.list.splice(that.list.indexOf(ws), 1); + delete that.map[userId]; + } + exports.emit("close", userId); + }); + ws.on("error", function(e) { + exports.emit("error", userId, e); + }); + that.sendToLang([ + "/connected", that.sampleRate, that.channels + ], userId); + exports.emit("open", userId); + }); + this.init(); + }; + SocketSynthServer.prototype.connect = function() { + }; + SocketSynthServer.prototype.sendToLang = function(msg, userId) { + if (msg instanceof Float32Array) { + this.list.forEach(function(ws) { + if (ws.readyState === 1) { + ws.send(msg.buffer, {binary:true, mask:false}); + } + }); + } else { + msg = JSON.stringify(msg); + if (userId === undefined) { + this.list.forEach(function(ws) { + if (ws.readyState === 1) { + ws.send(msg); + } + }); + } else { + var ws = this.map[userId]; + if (ws && ws.readyState === 1) { + ws.send(msg); + } + } + } + }; + SocketSynthServer.prototype.process = function() { + if (this.sysSyncCount < this.syncCount - 4) { + return; + } + var strm = this.strm; + var world = this.world; + var strmLength = this.strmLength; + var bufLength = this.bufLength; + var busOutL = this.busOutL; + var busOutR = this.busOutR; + var offsetL = 0; + var offsetR = strmLength; + for (var i = 0, imax = strmLength / bufLength; i < imax; ++i) { + world.process(bufLength); + strm.set(busOutL, offsetL); + strm.set(busOutR, offsetR); + offsetL += bufLength; + offsetR += bufLength; + } + this.sendToLang(strm); + this.sendToLang(["/process"]); + this.syncCount += 1; + + if (this.api) { + this.strmList[this.strmListWriteIndex] = new Float32Array(strm); + this.strmListWriteIndex = (this.strmListWriteIndex + 1) & 7; + } + }; + + return SocketSynthServer; + })(); + + var SocketSynthServerExports = (function() { + var singleton = null; + function SocketSynthServerExports(server, opts) { + if (singleton) { + return singleton; + } + emitter.mixin(this); + this.server = server; + this.server.exports = this; + this.server._init(opts||{}); + singleton = this; + } + SocketSynthServerExports.prototype.send = function(msg, userId) { + this.server.sendToLang([ + "/socket/sendToClient", msg + ], userId); + return this; + }; + return SocketSynthServerExports; + })(); + + cc.createSocketSynthServer = function() { + var server = new SocketSynthServer(); + server.exports = { + createServer: function(opts) { + return new SocketSynthServerExports(server, opts); + } + }; + cc.opmode = "socket"; + return server; + }; + + module.exports = { + WorldManager: WorldManager + }; + +}); + +define('cc/server/basic_unit', function(require, exports, module) { + + var cc = require("../cc"); + var ops = require("../common/ops"); + var log001 = Math.log(0.001); + + var calcDemandInput = function(unit, index, offset) { + var fromUnit = unit.fromUnits[index]; + if (fromUnit) { + switch (fromUnit.calcRate) { + case 2: + return unit.inputs[index][offset-1]; + case 3: + fromUnit.process(offset); + break; + } + } + return unit.inputs[index][0]; + }; + + var resetDemandInput = function(unit, index) { + var fromUnit = unit.fromUnits[index]; + if (fromUnit && fromUnit.calcRate === 3) { + fromUnit.process(0); + } + }; + + var uopFunc = {}; + + cc.unit.specs.UnaryOpUGen = (function() { + var ctor = function() { + var func = uopFunc[ops.UNARY_OPS_MAP[this.specialIndex]]; + var process; + if (func) { + if (this.calcRate === 3) { + this.process = func.d; + } else { + switch (this.inRates[0]) { + case 2 : process = func.a; break; + case 1: process = func.k; break; + } + this.process = process; + if (this.process) { + this.process(1); + } else { + this.outputs[0][0] = func(this.inputs[0][0]); + } + } + } else { + var opName = ops.UNARY_OPS_MAP[this.specialIndex] || "unknown"; + throw new Error("UnaryOpUGen[" + opName + "] is not defined."); + } + }; + + return ctor; + })(); + + var unary_k = function(func) { + return function() { + this.outputs[0][0] = func(this.inputs[0][0]); + }; + }; + var unary_a = function(func) { + return function(inNumSamples) { + var out = this.outputs[0]; + var a = this.inputs[0]; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = func(a[i ]); out[i+1] = func(a[i+1]); + out[i+2] = func(a[i+2]); out[i+3] = func(a[i+3]); + out[i+4] = func(a[i+4]); out[i+5] = func(a[i+5]); + out[i+6] = func(a[i+6]); out[i+7] = func(a[i+7]); + } + }; + }; + var unary_d = function(func) { + return function(inNumSamples) { + if (inNumSamples) { + var x = calcDemandInput(this, 0, inNumSamples); + this.outputs[0][0] = isNaN(x) ? NaN : func(x); + } else { + resetDemandInput(this, 0); + } + }; + }; + + uopFunc.neg = function(a) { + return -a; + }; + uopFunc.not = function(a) { + return a === 0 ? 1 : 0; + }; + uopFunc.abs = function(a) { + return Math.abs(a); + }; + uopFunc.ceil = function(a) { + return Math.ceil(a); + }; + uopFunc.floor = function(a) { + return Math.floor(a); + }; + uopFunc.frac = function(a) { + if (a < 0) { + return 1 + (a - (a|0)); + } + return a - (a|0); + }; + uopFunc.sign = function(a) { + if (a === 0) { + return 0; + } else if (a > 0) { + return 1; + } + return -1; + }; + uopFunc.squared = function(a) { + return a * a; + }; + uopFunc.cubed = function(a) { + return a * a * a; + }; + uopFunc.sqrt = function(a) { + return Math.sqrt(Math.abs(a)); + }; + uopFunc.exp = function(a) { + return Math.exp(a); + }; + uopFunc.reciprocal = function(a) { + return 1 / a; + }; + uopFunc.midicps = function(a) { + return 440 * Math.pow(2, (a - 69) * 1/12); + }; + uopFunc.cpsmidi = function(a) { + return Math.log(Math.abs(a) * 1/440) * Math.LOG2E * 12 + 69; + }; + uopFunc.midiratio = function(a) { + return Math.pow(2, a * 1/12); + }; + uopFunc.ratiomidi = function(a) { + return Math.log(Math.abs(a)) * Math.LOG2E * 12; + }; + uopFunc.dbamp = function(a) { + return Math.pow(10, a * 0.05); + }; + uopFunc.ampdb = function(a) { + return Math.log(Math.abs(a)) * Math.LOG10E * 20; + }; + uopFunc.octcps = function(a) { + return 440 * Math.pow(2, a - 4.75); + }; + uopFunc.cpsoct = function(a) { + return Math.log(Math.abs(a) * 1/440) * Math.LOG2E + 4.75; + }; + uopFunc.log = function(a) { + return Math.log(Math.abs(a)); + }; + uopFunc.log2 = function(a) { + return Math.log(Math.abs(a)) * Math.LOG2E; + }; + uopFunc.log10 = function(a) { + return Math.log(Math.abs(a)) * Math.LOG10E; + }; + uopFunc.sin = function(a) { + return Math.sin(a); + }; + uopFunc.cos = function(a) { + return Math.cos(a); + }; + uopFunc.tan = function(a) { + return Math.tan(a); + }; + uopFunc.asin = function(a) { + return Math.asin(Math.max(-1, Math.min(a, 1))); + }; + uopFunc.acos = function(a) { + return Math.acos(Math.max(-1, Math.min(a, 1))); + }; + uopFunc.atan = function(a) { + return Math.atan(a); + }; + uopFunc.sinh = function(a) { + return (Math.pow(Math.E, a) - Math.pow(Math.E, -a)) * 0.5; + }; + uopFunc.cosh = function(a) { + return (Math.pow(Math.E, a) + Math.pow(Math.E, -a)) * 0.5; + }; + uopFunc.tanh = function(a) { + var sinh = (Math.pow(Math.E, a) - Math.pow(Math.E, -a)) * 0.5; + var cosh = (Math.pow(Math.E, a) + Math.pow(Math.E, -a)) * 0.5; + return sinh / cosh; + }; + uopFunc.rand = function(a) { + return Math.random() * a; + }; + uopFunc.rand2 = function(a) { + return (Math.random() * 2 - 1) * a; + }; + uopFunc.linrand = function(a) { + return Math.min(Math.random(), Math.random()) * a; + }; + uopFunc.bilinrand = function(a) { + return (Math.random() - Math.random()) * a; + }; + uopFunc.sum3rand = function(a) { + return (Math.random() + Math.random() + Math.random() - 1.5) * 0.666666667 * a; + }; + uopFunc.distort = function(a) { + return a / (1 + Math.abs(a)); + }; + uopFunc.softclip = function(a) { + var absa = Math.abs(a); + return absa <= 0.5 ? a : (absa - 0.25) / a; + }; + uopFunc.coin = function(a) { + return Math.random() < a ? 1 : 0; + }; + uopFunc.num = function(a) { + return +a; + }; + uopFunc.tilde = function(a) { + return ~a; + }; + uopFunc.pi = function(a) { + return Math.PI * a; + }; + uopFunc.to_i = function(a) { + return a|0; + }; + uopFunc.half = function(a) { + return a * 0.5; + }; + uopFunc.twice = function(a) { + return a * 2; + }; + + Object.keys(uopFunc).forEach(function(key) { + var func = uopFunc[key]; + func.a = unary_a(func); + func.k = unary_k(func); + func.d = unary_d(func); + }); + + var bopFunc = {}; + + cc.unit.specs.BinaryOpUGen = (function() { + var ctor = function() { + var func = bopFunc[ops.BINARY_OPS_MAP[this.specialIndex]]; + var process; + if (func) { + if (this.calcRate === 3) { + this.process = func.dd; + } else { + switch (this.inRates[0]) { + case 2: + switch (this.inRates[1]) { + case 2 : process = func.aa; break; + case 1: process = func.ak; break; + case 0 : process = func.ai; break; + } + break; + case 1: + switch (this.inRates[1]) { + case 2 : process = func.ka; break; + case 1: process = func.kk; break; + case 0 : process = func.ki; break; + } + break; + case 0: + switch (this.inRates[1]) { + case 2 : process = func.ia; break; + case 1: process = func.ik; break; + case 0 : process = null ; break; + } + break; + } + this.process = process; + this._a = this.inputs[0][0]; + this._b = this.inputs[1][0]; + if (this.process) { + this.process(1); + } else { + this.outputs[0][0] = func(this.inputs[0][0], this.inputs[1][0]); + } + } + } else { + var opName = ops.BINARY_OPS_MAP[this.specialIndex] || "unknown"; + throw new Error("BinaryOpUGen[" + opName + "] is not defined."); + } + }; + + return ctor; + })(); + + var binary_aa = function(func) { + return function(inNumSamples) { + var out = this.outputs[0]; + var aIn = this.inputs[0], bIn = this.inputs[1]; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = func(aIn[i ], bIn[i ]); out[i+1] = func(aIn[i+1], bIn[i+1]); + out[i+2] = func(aIn[i+2], bIn[i+2]); out[i+3] = func(aIn[i+3], bIn[i+3]); + out[i+4] = func(aIn[i+4], bIn[i+4]); out[i+5] = func(aIn[i+5], bIn[i+5]); + out[i+6] = func(aIn[i+6], bIn[i+6]); out[i+7] = func(aIn[i+7], bIn[i+7]); + } + }; + }; + var binary_ak = function(func) { + return function(inNumSamples) { + var out = this.outputs[0]; + var aIn = this.inputs[0], b = this._b; + var nextB = this.inputs[1][0]; + var b_slope = (nextB - this._b) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = func(aIn[i ], b); b += b_slope; + out[i+1] = func(aIn[i+1], b); b += b_slope; + out[i+2] = func(aIn[i+2], b); b += b_slope; + out[i+3] = func(aIn[i+3], b); b += b_slope; + out[i+4] = func(aIn[i+4], b); b += b_slope; + out[i+5] = func(aIn[i+5], b); b += b_slope; + out[i+6] = func(aIn[i+6], b); b += b_slope; + out[i+7] = func(aIn[i+7], b); b += b_slope; + } + this._b = nextB; + }; + }; + var binary_ai = function(func) { + return function(inNumSamples) { + var out = this.outputs[0]; + var aIn = this.inputs[0], b = this._b; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = func(aIn[i ], b); + out[i+1] = func(aIn[i+1], b); + out[i+2] = func(aIn[i+2], b); + out[i+3] = func(aIn[i+3], b); + out[i+4] = func(aIn[i+4], b); + out[i+5] = func(aIn[i+5], b); + out[i+6] = func(aIn[i+6], b); + out[i+7] = func(aIn[i+7], b); + } + }; + }; + var binary_ka = function(func) { + return function(inNumSamples) { + var out = this.outputs[0]; + var a = this._a, bIn = this.inputs[1]; + var nextA = this.inputs[0][0]; + var a_slope = (nextA - this._a) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = func(a, bIn[i ]); a += a_slope; + out[i+1] = func(a, bIn[i+1]); a += a_slope; + out[i+2] = func(a, bIn[i+2]); a += a_slope; + out[i+3] = func(a, bIn[i+3]); a += a_slope; + out[i+4] = func(a, bIn[i+4]); a += a_slope; + out[i+5] = func(a, bIn[i+5]); a += a_slope; + out[i+6] = func(a, bIn[i+6]); a += a_slope; + out[i+7] = func(a, bIn[i+7]); a += a_slope; + } + this._a = nextA; + }; + }; + var binary_kk = function(func) { + return function() { + this.outputs[0][0] = func(this.inputs[0][0], this.inputs[1][0]); + }; + }; + var binary_ki = function(func) { + return function() { + this.outputs[0][0] = func(this.inputs[0][0], this._b); + }; + }; + var binary_ia = function(func) { + return function(inNumSamples) { + var out = this.outputs[0]; + var a = this._a, bIn = this.inputs[1]; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = func(a, bIn[i ]); + out[i+1] = func(a, bIn[i+1]); + out[i+2] = func(a, bIn[i+2]); + out[i+3] = func(a, bIn[i+3]); + out[i+4] = func(a, bIn[i+4]); + out[i+5] = func(a, bIn[i+5]); + out[i+6] = func(a, bIn[i+6]); + out[i+7] = func(a, bIn[i+7]); + } + }; + }; + var binary_ik = function(func) { + return function() { + this.outputs[0][0] = func(this._a, this.inputs[1][0]); + }; + }; + + var binary_dd = function(func) { + return function(inNumSamples) { + if (inNumSamples) { + var a = calcDemandInput(this, 0, inNumSamples); + var b = calcDemandInput(this, 1, inNumSamples); + this.outputs[0][0] = isNaN(a) || isNaN(b) ? NaN : func(a, b); + } else { + resetDemandInput(this, 0); + resetDemandInput(this, 1); + } + }; + }; + + bopFunc["+"] = function(a, b) { + return a + b; + }; + bopFunc["+"].aa = function(inNumSamples) { + var out = this.outputs[0]; + var aIn = this.inputs[0], bIn = this.inputs[1]; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = aIn[i ] + bIn[i ]; + out[i+1] = aIn[i+1] + bIn[i+1]; + out[i+2] = aIn[i+2] + bIn[i+2]; + out[i+3] = aIn[i+3] + bIn[i+3]; + out[i+4] = aIn[i+4] + bIn[i+4]; + out[i+5] = aIn[i+5] + bIn[i+5]; + out[i+6] = aIn[i+6] + bIn[i+6]; + out[i+7] = aIn[i+7] + bIn[i+7]; + } + }; + bopFunc["+"].ak = function(inNumSamples) { + var out = this.outputs[0]; + var aIn = this.inputs[0], b = this._b; + var nextB = this.inputs[1][0]; + var b_slope = (nextB - this._b) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = aIn[i ] + b; b += b_slope; + out[i+1] = aIn[i+1] + b; b += b_slope; + out[i+2] = aIn[i+2] + b; b += b_slope; + out[i+3] = aIn[i+3] + b; b += b_slope; + out[i+4] = aIn[i+4] + b; b += b_slope; + out[i+5] = aIn[i+5] + b; b += b_slope; + out[i+6] = aIn[i+6] + b; b += b_slope; + out[i+7] = aIn[i+7] + b; b += b_slope; + } + this._b = nextB; + }; + bopFunc["+"].ai = function(inNumSamples) { + var out = this.outputs[0]; + var aIn = this.inputs[0], b = this._b; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = aIn[i ] + b; + out[i+1] = aIn[i+1] + b; + out[i+2] = aIn[i+2] + b; + out[i+3] = aIn[i+3] + b; + out[i+4] = aIn[i+4] + b; + out[i+5] = aIn[i+5] + b; + out[i+6] = aIn[i+6] + b; + out[i+7] = aIn[i+7] + b; + } + }; + bopFunc["+"].ka = function(inNumSamples) { + var out = this.outputs[0]; + var a = this._a, bIn = this.inputs[1]; + var nextA = this.inputs[0][0]; + var a_slope = (nextA - this._a) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = a + bIn[i ]; a += a_slope; + out[i+1] = a + bIn[i+1]; a += a_slope; + out[i+2] = a + bIn[i+2]; a += a_slope; + out[i+3] = a + bIn[i+3]; a += a_slope; + out[i+4] = a + bIn[i+4]; a += a_slope; + out[i+5] = a + bIn[i+5]; a += a_slope; + out[i+6] = a + bIn[i+6]; a += a_slope; + out[i+7] = a + bIn[i+7]; a += a_slope; + } + this._a = nextA; + }; + bopFunc["+"].kk = function() { + this.outputs[0][0] = this.inputs[0][0] + this.inputs[1][0]; + }; + bopFunc["+"].ki = function() { + this.outputs[0][0] = this.inputs[0][0] + this._b; + }; + bopFunc["+"].ia = function(inNumSamples) { + var out = this.outputs[0]; + var a = this._a, bIn = this.inputs[1]; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = a + bIn[i ]; + out[i+1] = a + bIn[i+1]; + out[i+2] = a + bIn[i+2]; + out[i+3] = a + bIn[i+3]; + out[i+4] = a + bIn[i+4]; + out[i+5] = a + bIn[i+5]; + out[i+6] = a + bIn[i+6]; + out[i+7] = a + bIn[i+7]; + } + }; + bopFunc["+"].ik = function() { + this.outputs[0][0] = this._a + this.inputs[1][0]; + }; + + bopFunc["-"] = function(a, b) { + return a - b; + }; + bopFunc["-"].aa = function(inNumSamples) { + var out = this.outputs[0]; + var aIn = this.inputs[0], bIn = this.inputs[1]; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = aIn[i ] - bIn[i ]; + out[i+1] = aIn[i+1] - bIn[i+1]; + out[i+2] = aIn[i+2] - bIn[i+2]; + out[i+3] = aIn[i+3] - bIn[i+3]; + out[i+4] = aIn[i+4] - bIn[i+4]; + out[i+5] = aIn[i+5] - bIn[i+5]; + out[i+6] = aIn[i+6] - bIn[i+6]; + out[i+7] = aIn[i+7] - bIn[i+7]; + } + }; + bopFunc["-"].ak = function(inNumSamples) { + var out = this.outputs[0]; + var aIn = this.inputs[0], b = this._b; + var nextB = this.inputs[1][0]; + var b_slope = (nextB - this._b) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = aIn[i ] - b; b += b_slope; + out[i+1] = aIn[i+1] - b; b += b_slope; + out[i+2] = aIn[i+2] - b; b += b_slope; + out[i+3] = aIn[i+3] - b; b += b_slope; + out[i+4] = aIn[i+4] - b; b += b_slope; + out[i+5] = aIn[i+5] - b; b += b_slope; + out[i+6] = aIn[i+6] - b; b += b_slope; + out[i+7] = aIn[i+7] - b; b += b_slope; + } + this._b = nextB; + }; + bopFunc["-"].ai = function(inNumSamples) { + var out = this.outputs[0]; + var aIn = this.inputs[0], b = this._b; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = aIn[i ] - b; + out[i+1] = aIn[i+1] - b; + out[i+2] = aIn[i+2] - b; + out[i+3] = aIn[i+3] - b; + out[i+4] = aIn[i+4] - b; + out[i+5] = aIn[i+5] - b; + out[i+6] = aIn[i+6] - b; + out[i+7] = aIn[i+7] - b; + } + }; + bopFunc["-"].ka = function(inNumSamples) { + var out = this.outputs[0]; + var a = this._a, bIn = this.inputs[1]; + var nextA = this.inputs[0][0]; + var a_slope = (nextA - this._a) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = a - bIn[i ]; a += a_slope; + out[i+1] = a - bIn[i+1]; a += a_slope; + out[i+2] = a - bIn[i+2]; a += a_slope; + out[i+3] = a - bIn[i+3]; a += a_slope; + out[i+4] = a - bIn[i+4]; a += a_slope; + out[i+5] = a - bIn[i+5]; a += a_slope; + out[i+6] = a - bIn[i+6]; a += a_slope; + out[i+7] = a - bIn[i+7]; a += a_slope; + } + this._a = nextA; + }; + bopFunc["-"].kk = function() { + this.outputs[0][0] = this.inputs[0][0] - this.inputs[1][0]; + }; + bopFunc["-"].ki = function() { + this.outputs[0][0] = this.inputs[0][0] - this._b; + }; + bopFunc["-"].ia = function(inNumSamples) { + var out = this.outputs[0]; + var a = this._a, bIn = this.inputs[1]; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = a - bIn[i ]; + out[i+1] = a - bIn[i+1]; + out[i+2] = a - bIn[i+2]; + out[i+3] = a - bIn[i+3]; + out[i+4] = a - bIn[i+4]; + out[i+5] = a - bIn[i+5]; + out[i+6] = a - bIn[i+6]; + out[i+7] = a - bIn[i+7]; + } + }; + bopFunc["-"].ik = function() { + this.outputs[0][0] = this._a - this.inputs[1][0]; + }; + + bopFunc["*"] = function(a, b) { + return a * b; + }; + bopFunc["*"].aa = function(inNumSamples) { + var out = this.outputs[0]; + var aIn = this.inputs[0], bIn = this.inputs[1]; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = aIn[i ] * bIn[i ]; + out[i+1] = aIn[i+1] * bIn[i+1]; + out[i+2] = aIn[i+2] * bIn[i+2]; + out[i+3] = aIn[i+3] * bIn[i+3]; + out[i+4] = aIn[i+4] * bIn[i+4]; + out[i+5] = aIn[i+5] * bIn[i+5]; + out[i+6] = aIn[i+6] * bIn[i+6]; + out[i+7] = aIn[i+7] * bIn[i+7]; + } + }; + bopFunc["*"].ak = function(inNumSamples) { + var out = this.outputs[0]; + var aIn = this.inputs[0], b = this._b; + var nextB = this.inputs[1][0]; + var b_slope = (nextB - this._b) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = aIn[i ] * b; b += b_slope; + out[i+1] = aIn[i+1] * b; b += b_slope; + out[i+2] = aIn[i+2] * b; b += b_slope; + out[i+3] = aIn[i+3] * b; b += b_slope; + out[i+4] = aIn[i+4] * b; b += b_slope; + out[i+5] = aIn[i+5] * b; b += b_slope; + out[i+6] = aIn[i+6] * b; b += b_slope; + out[i+7] = aIn[i+7] * b; b += b_slope; + } + this._b = nextB; + }; + bopFunc["*"].ai = function(inNumSamples) { + var out = this.outputs[0]; + var aIn = this.inputs[0], b = this._b; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = aIn[i ] * b; + out[i+1] = aIn[i+1] * b; + out[i+2] = aIn[i+2] * b; + out[i+3] = aIn[i+3] * b; + out[i+4] = aIn[i+4] * b; + out[i+5] = aIn[i+5] * b; + out[i+6] = aIn[i+6] * b; + out[i+7] = aIn[i+7] * b; + } + }; + bopFunc["*"].ka = function(inNumSamples) { + var out = this.outputs[0]; + var a = this._a, bIn = this.inputs[1]; + var nextA = this.inputs[0][0]; + var a_slope = (nextA - this._a) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = a * bIn[i ]; a += a_slope; + out[i+1] = a * bIn[i+1]; a += a_slope; + out[i+2] = a * bIn[i+2]; a += a_slope; + out[i+3] = a * bIn[i+3]; a += a_slope; + out[i+4] = a * bIn[i+4]; a += a_slope; + out[i+5] = a * bIn[i+5]; a += a_slope; + out[i+6] = a * bIn[i+6]; a += a_slope; + out[i+7] = a * bIn[i+7]; a += a_slope; + } + this._a = nextA; + }; + bopFunc["*"].kk = function() { + this.outputs[0][0] = this.inputs[0][0] * this.inputs[1][0]; + }; + bopFunc["*"].ki = function() { + this.outputs[0][0] = this.inputs[0][0] * this._b; + }; + bopFunc["*"].ia = function(inNumSamples) { + var out = this.outputs[0]; + var a = this._a, bIn = this.inputs[1]; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = a * bIn[i ]; + out[i+1] = a * bIn[i+1]; + out[i+2] = a * bIn[i+2]; + out[i+3] = a * bIn[i+3]; + out[i+4] = a * bIn[i+4]; + out[i+5] = a * bIn[i+5]; + out[i+6] = a * bIn[i+6]; + out[i+7] = a * bIn[i+7]; + } + }; + bopFunc["*"].ik = function() { + this.outputs[0][0] = this._a * this.inputs[1][0]; + }; + + bopFunc["/"] = function(a, b) { + return b === 0 ? 0 : a / b; + }; + bopFunc["%"] = function(a, b) { + return b === 0 ? 0 : a % b; + }; + + bopFunc.eq = function(a, b) { + return a === b ? 1 : 0; + }; + bopFunc.ne = function(a, b) { + return a !== b ? 1 : 0; + }; + bopFunc.lt = function(a, b) { + return a < b ? 1 : 0; + }; + bopFunc.gt = function(a, b) { + return a > b ? 1 : 0; + }; + bopFunc.le = function(a, b) { + return a <= b ? 1 : 0; + }; + bopFunc.ge = function(a, b) { + return a >= b ? 1 : 0; + }; + bopFunc.bitAnd = function(a, b) { + return a & b; + }; + bopFunc.bitOr = function(a, b) { + return a | b; + }; + bopFunc.bitXor = function(a, b) { + return a ^ b; + }; + bopFunc.min = function(a, b) { + return Math.min(a, b); + }; + bopFunc.max = function(a, b) { + return Math.max(a, b); + }; + var gcd = function(a, b, t) { + a = a|0; b = b|0; + while (b !== 0) { + t = a % b; a = b; b = t; + } + return Math.abs(a); + }; + bopFunc.lcm = function(a, b) { + if (a === 0 && b === 0) { + return 0; + } + return Math.abs(a * b) / gcd(a, b); + }; + bopFunc.gcd = function(a, b) { + return gcd(a, b); + }; + bopFunc.round = function(a, b) { + return b === 0 ? a : Math.round(a / b) * b; + }; + bopFunc.roundUp = function(a, b) { + return b === 0 ? a : Math.ceil(a / b) * b; + }; + bopFunc.roundDown = function(a, b) { + return b === 0 ? a : Math.floor(a / b) * b; + }; + bopFunc.trunc = function(a, b) { + return b === 0 ? a : Math.floor(a / b) * b; + }; + bopFunc.atan2 = function(a, b) { + return Math.atan2(a, b); + }; + bopFunc.hypot = function(a, b) { + return Math.sqrt((a * a) + (b * b)); + }; + bopFunc.hypotApx = function(a, b) { + var x = Math.abs(a), y = Math.abs(b); + var minxy = Math.min(x, y); + return x + y - (Math.sqrt(2) - 1) * minxy; + }; + bopFunc.pow = function(a, b) { + return Math.pow(Math.abs(a), b); + }; + bopFunc.leftShift = function(a, b) { + if (b < 0) { + return (a|0) >> (-b|0); + } + return (a|0) << (b|0); + }; + bopFunc.rightShift = function(a, b) { + if (b < 0) { + return (a|0) << (-b|0); + } + return (a|0) >> (b|0); + }; + bopFunc.unsignedRightShift = function(a, b) { + if (b < 0) { + return (a|0) << (-b|0); + } + return (a|0) >> (b|0); + }; + bopFunc.ring1 = function(a, b) { + return a * b + a; + }; + bopFunc.ring2 = function(a, b) { + return a * b + a + b; + }; + bopFunc.ring3 = function(a, b) { + return a * a * b; + }; + bopFunc.ring4 = function(a, b) { + return a * a * b - a * b * b; + }; + bopFunc.difsqr = function(a, b) { + return a * a - b * b; + }; + bopFunc.sumsqr = function(a, b) { + return a * a + b * b; + }; + bopFunc.sqrsum = function(a, b) { + return (a + b) * (a + b); + }; + bopFunc.sqrdif = function(a, b) { + return (a - b) * (a - b); + }; + bopFunc.absdif = function(a, b) { + return Math.abs(a - b); + }; + bopFunc.thresh = function(a, b) { + return a < b ? 0 : a; + }; + bopFunc.amclip = function(a, b) { + return a * 0.5 * (b + Math.abs(b)); + }; + bopFunc.scaleneg = function(a, b) { + b = 0.5 * b + 0.5; + return (Math.abs(a) - a) * b + a; + }; + bopFunc.clip2 = function(a, b) { + return Math.max(-b, Math.min(a, b)); + }; + bopFunc.excess = function(a, b) { + return a - Math.max(-b, Math.min(a, b)); + }; + bopFunc.fold2 = function(val, hi) { + var x, range1, range2; + if (hi === 0) { + return 0; + } + range1 = hi + hi; + if (val >= hi) { + val = range1 - val; + if (val >= -hi) { + return val; + } + } else if (val < -hi) { + val = -range1 - val; + if (val < hi) { + return val; + } + } else { + return val; + } + + range2 = range1 + range1; + x = val + hi; + x -= range2 * Math.floor(x / range2); + if (x >= range1) { + return range2 - x - hi; + } + return x - hi; + }; + bopFunc.wrap2 = function(val, hi) { + if (hi === 0) { + return 0; + } + var range = hi * 2; + if (val >= hi) { + val -= range; + if (val < hi) { + return val; + } + } else if (val < -hi) { + val += range; + if (val >= -hi) { + return val; + } + } else { + return val; + } + return val - range * Math.floor((val + hi) / range); + }; + + + Object.keys(bopFunc).forEach(function(key) { + var func = bopFunc[key]; + if (!func.aa) { + func.aa = binary_aa(func); + } + if (!func.ak) { + func.ak = binary_ak(func); + } + if (!func.ai) { + func.ai = binary_ai(func); + } + if (!func.ka) { + func.ka = binary_ka(func); + } + if (!func.kk) { + func.kk = binary_kk(func); + } + if (!func.ki) { + func.ki = binary_ki(func); + } + if (!func.ia) { + func.ia = binary_ia(func); + } + if (!func.ik) { + func.ik = binary_ik(func); + } + func.dd = binary_dd(func); + }); + + cc.unit.specs.Control = (function() { + var ctor = function() { + if (this.numOutputs === 1) { + this.process = next_1; + } else { + this.process = next_k; + } + this.process(1); + }; + var next_1 = function() { + this.outputs[0][0] = this.parent.controls[this.specialIndex]; + }; + var next_k = function() { + var controls = this.parent.controls; + var outputs = this.outputs; + var numChannels = outputs.length; + for (var i = 0, j = this.specialIndex; i < numChannels; ++i, ++j) { + outputs[i][0] = controls[j]; + } + }; + return ctor; + })(); + + cc.unit.specs.LagControl = (function() { + var ctor = function() { + if (this.numOutputs === 1) { + this.process = next_1; + } else { + this.process = next_k; + } + var numChannels = this.numOutputs; + var y1 = this._y1 = new Float32Array(numChannels); + var b1 = this._b1 = new Float32Array(numChannels); + var controls = this.parent.controls; + var inputs = this.inputs; + var sampleRate = this.rate.sampleRate; + var lag; + for (var i = 0; i < numChannels; ++i) { + y1[i] = controls[i]; + lag = inputs[i][0]; + b1[i] = lag === 0 ? 0 : Math.exp(log001 / (lag * sampleRate)); + } + this.process(1); + }; + var next_1 = function() { + var y1 = this._y1; + var b1 = this._b1; + var z = this.parent.controls[this.specialIndex]; + var x = z + b1[0] * (y1[0] - z); + this.outputs[0][0] = y1[0] = x; + }; + var next_k = function() { + var controls = this.parent.controls; + var outputs = this.outputs; + var numChannels = this.outputs.length; + var y1 = this._y1; + var b1 = this._b1; + var z, x, i, j; + for (i = 0, j = this.specialIndex; i < numChannels; ++i, ++j) { + z = controls[j]; + x = z + b1[i] * (y1[i] - z); + outputs[i][0] = y1[i] = x; + } + }; + return ctor; + })(); + + cc.unit.specs.TrigControl = (function() { + var ctor = function() { + if (this.numOutputs === 1) { + this.process = next_1; + } else { + this.process = next_k; + } + this.process(1); + }; + var next_1 = function() { + var controls = this.parent.controls; + var specialIndex = this.specialIndex; + this.outputs[0][0] = controls[specialIndex]; + controls[specialIndex] = 0; + }; + var next_k = function() { + var controls = this.parent.controls; + var outputs = this.outputs; + var numChannels = outputs.length; + for (var i = 0, j = this.specialIndex; i < numChannels; ++i, ++j) { + outputs[i][0] = controls[j]; + controls[j] = 0; + } + }; + return ctor; + })(); + + cc.unit.specs.Out = (function() { + var ctor = function() { + if (this.calcRate === 2) { + this.process = next_a; + this._busOffset = 0; + } else { + this.process = next_k; + this._busOffset = this.bufLength * 16; + } + }; + var next_a = function(inNumSamples) { + var inputs = this.inputs; + var bus = this.world.bus; + var bufLength = this.bufLength; + var offset, _in; + var fbusChannel = (inputs[0][0]|0) - 1; + for (var i = 1, imax = inputs.length; i < imax; ++i) { + offset = (fbusChannel + i) * bufLength; + _in = inputs[i]; + for (var j = 0; j < inNumSamples; j++) { + bus[offset + j] += _in[j]; + } + } + }; + var next_k = function() { + var inputs = this.inputs; + var bus = this.world.bus; + var offset = this._busOffset + (inputs[0][0]|0) - 1; + for (var i = 1, imax = inputs.length; i < imax; ++i) { + bus[offset + i] += inputs[i][0]; + } + }; + return ctor; + })(); + + cc.unit.specs.ReplaceOut = (function() { + var ctor = function() { + if (this.calcRate === 2) { + this.process = next_a; + this._busOffset = 0; + } else { + this.process = next_k; + this._busOffset = this.bufLength * 16; + } + }; + var next_a = function(inNumSamples) { + var inputs = this.inputs; + var bus = this.world.bus; + var bufLength = this.bufLength; + var offset, _in; + var fbusChannel = (inputs[0][0]|0) - 1; + for (var i = 1, imax = inputs.length; i < imax; ++i) { + offset = (fbusChannel + i) * bufLength; + _in = inputs[i]; + for (var j = 0; j < inNumSamples; j++) { + bus[offset + j] = _in[j]; + } + } + }; + var next_k = function() { + var inputs = this.inputs; + var bus = this.world.bus; + var offset = this._busOffset + (inputs[0][0]|0) - 1; + for (var i = 1, imax = inputs.length; i < imax; ++i) { + bus[offset + i] = inputs[i][0]; + } + }; + return ctor; + })(); + + cc.unit.specs.MulAdd = (function() { + var ctor = function() { + if (this.calcRate === 3) { + this.process = next[3]; + } else { + var rates = this.inRates; + this.process = next[rates[0]][rates[1]][rates[2]]; + this._in = this.inputs[0][0]; + this._mul = this.inputs[1][0]; + this._add = this.inputs[2][0]; + if (this.process) { + this.process(1); + } else { + this.outputs[0][0] = this._in * this._mul + this._add; + } + } + }; + + var next = {}; + next[2] = {}; + next[2][2] = {}; + next[2][1] = {}; + next[2][0] = {}; + next[1] = {}; + next[1][2] = {}; + next[1][1] = {}; + next[1][0] = {}; + next[0] = {}; + next[0][2] = {}; + next[0][1] = {}; + next[0][0] = {}; + + next[2][2][2] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var mulIn = this.inputs[1]; + var addIn = this.inputs[2]; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn[i ] * mulIn[i ] + addIn[i ]; + out[i+1] = inIn[i+1] * mulIn[i+1] + addIn[i+1]; + out[i+2] = inIn[i+2] * mulIn[i+2] + addIn[i+2]; + out[i+3] = inIn[i+3] * mulIn[i+3] + addIn[i+3]; + out[i+4] = inIn[i+4] * mulIn[i+4] + addIn[i+4]; + out[i+5] = inIn[i+5] * mulIn[i+5] + addIn[i+5]; + out[i+6] = inIn[i+6] * mulIn[i+6] + addIn[i+6]; + out[i+7] = inIn[i+7] * mulIn[i+7] + addIn[i+7]; + } + }; + next[2][2][1] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var mulIn = this.inputs[1]; + var add = this._add; + var nextAdd = this.inputs[2][0]; + var add_slope = (nextAdd - add) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn[i ] * mulIn[i ] + add; add += add_slope; + out[i+1] = inIn[i+1] * mulIn[i+1] + add; add += add_slope; + out[i+2] = inIn[i+2] * mulIn[i+2] + add; add += add_slope; + out[i+3] = inIn[i+3] * mulIn[i+3] + add; add += add_slope; + out[i+4] = inIn[i+4] * mulIn[i+4] + add; add += add_slope; + out[i+5] = inIn[i+5] * mulIn[i+5] + add; add += add_slope; + out[i+6] = inIn[i+6] * mulIn[i+6] + add; add += add_slope; + out[i+7] = inIn[i+7] * mulIn[i+7] + add; add += add_slope; + } + this._add = nextAdd; + }; + next[2][2][0] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var mulIn = this.inputs[1]; + var add = this._add; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn[i ] * mulIn[i ] + add; + out[i+1] = inIn[i+1] * mulIn[i+1] + add; + out[i+2] = inIn[i+2] * mulIn[i+2] + add; + out[i+3] = inIn[i+3] * mulIn[i+3] + add; + out[i+4] = inIn[i+4] * mulIn[i+4] + add; + out[i+5] = inIn[i+5] * mulIn[i+5] + add; + out[i+6] = inIn[i+6] * mulIn[i+6] + add; + out[i+7] = inIn[i+7] * mulIn[i+7] + add; + } + }; + next[2][1][2] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var mul = this._mul; + var addIn = this.inputs[2]; + var nextMul = this.inputs[1][0]; + var mul_slope = (nextMul - mul) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn[i ] * mul + addIn[i ]; mul += mul_slope; + out[i+1] = inIn[i+1] * mul + addIn[i+1]; mul += mul_slope; + out[i+2] = inIn[i+2] * mul + addIn[i+2]; mul += mul_slope; + out[i+3] = inIn[i+3] * mul + addIn[i+3]; mul += mul_slope; + out[i+4] = inIn[i+4] * mul + addIn[i+4]; mul += mul_slope; + out[i+5] = inIn[i+5] * mul + addIn[i+5]; mul += mul_slope; + out[i+6] = inIn[i+6] * mul + addIn[i+6]; mul += mul_slope; + out[i+7] = inIn[i+7] * mul + addIn[i+7]; mul += mul_slope; + } + this._mul = nextMul; + }; + next[2][1][1] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var mul = this._mul; + var add = this._add; + var nextMul = this.inputs[1][0]; + var mul_slope = (nextMul - mul) * this.rate.slopeFactor; + var nextAdd = this.inputs[2][0]; + var add_slope = (nextAdd - add) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn[i ] * mul + add; mul += mul_slope; add += add_slope; + out[i+1] = inIn[i+1] * mul + add; mul += mul_slope; add += add_slope; + out[i+2] = inIn[i+2] * mul + add; mul += mul_slope; add += add_slope; + out[i+3] = inIn[i+3] * mul + add; mul += mul_slope; add += add_slope; + out[i+4] = inIn[i+4] * mul + add; mul += mul_slope; add += add_slope; + out[i+5] = inIn[i+5] * mul + add; mul += mul_slope; add += add_slope; + out[i+6] = inIn[i+6] * mul + add; mul += mul_slope; add += add_slope; + out[i+7] = inIn[i+7] * mul + add; mul += mul_slope; add += add_slope; + } + this._mul = nextMul; + this._add = nextAdd; + }; + next[2][1][0] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var mul = this._mul; + var add = this._add; + var nextMul = this.inputs[1][0]; + var mul_slope = (nextMul - mul) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn[i ] * mul + add; mul += mul_slope; + out[i+1] = inIn[i+1] * mul + add; mul += mul_slope; + out[i+2] = inIn[i+2] * mul + add; mul += mul_slope; + out[i+3] = inIn[i+3] * mul + add; mul += mul_slope; + out[i+4] = inIn[i+4] * mul + add; mul += mul_slope; + out[i+5] = inIn[i+5] * mul + add; mul += mul_slope; + out[i+6] = inIn[i+6] * mul + add; mul += mul_slope; + out[i+7] = inIn[i+7] * mul + add; mul += mul_slope; + } + this._mul = nextMul; + }; + next[2][0][2] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var mul = this._mul; + var addIn = this.inputs[2]; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn[i ] * mul + addIn[i ]; + out[i+1] = inIn[i+1] * mul + addIn[i+1]; + out[i+2] = inIn[i+2] * mul + addIn[i+2]; + out[i+3] = inIn[i+3] * mul + addIn[i+3]; + out[i+4] = inIn[i+4] * mul + addIn[i+4]; + out[i+5] = inIn[i+5] * mul + addIn[i+5]; + out[i+6] = inIn[i+6] * mul + addIn[i+6]; + out[i+7] = inIn[i+7] * mul + addIn[i+7]; + } + }; + next[2][0][1] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var mul = this._mul; + var add = this._add; + var nextAdd = this.inputs[2][0]; + var add_slope = (nextAdd - add) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn[i ] * mul + add; add += add_slope; + out[i+1] = inIn[i+1] * mul + add; add += add_slope; + out[i+2] = inIn[i+2] * mul + add; add += add_slope; + out[i+3] = inIn[i+3] * mul + add; add += add_slope; + out[i+4] = inIn[i+4] * mul + add; add += add_slope; + out[i+5] = inIn[i+5] * mul + add; add += add_slope; + out[i+6] = inIn[i+6] * mul + add; add += add_slope; + out[i+7] = inIn[i+7] * mul + add; add += add_slope; + } + this._add = nextAdd; + }; + next[2][0][0] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn = this.inputs[0]; + var mul = this._mul; + var add = this._add; + var nextMul = this.inputs[1][0]; + var mul_slope = (nextMul - mul) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn[i ] * mul + add; mul += mul_slope; + out[i+1] = inIn[i+1] * mul + add; mul += mul_slope; + out[i+2] = inIn[i+2] * mul + add; mul += mul_slope; + out[i+3] = inIn[i+3] * mul + add; mul += mul_slope; + out[i+4] = inIn[i+4] * mul + add; mul += mul_slope; + out[i+5] = inIn[i+5] * mul + add; mul += mul_slope; + out[i+6] = inIn[i+6] * mul + add; mul += mul_slope; + out[i+7] = inIn[i+7] * mul + add; mul += mul_slope; + } + this._mul = nextMul; + }; + next[1][1][2] = function(inNumSamples) { + var out = this.outputs[0]; + var _in = this._in; + var mul = this._mul; + var addIn = this.inputs[2]; + var nextIn = this.inputs[0][0]; + var in_slope = (nextIn - _in) * this.rate.slopeFactor; + var nextMul = this.inputs[1][0]; + var mul_slope = (nextMul - mul) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = _in * mul + addIn[i ]; _in += in_slope; mul += mul_slope; + out[i+1] = _in * mul + addIn[i+1]; _in += in_slope; mul += mul_slope; + out[i+2] = _in * mul + addIn[i+2]; _in += in_slope; mul += mul_slope; + out[i+3] = _in * mul + addIn[i+3]; _in += in_slope; mul += mul_slope; + out[i+4] = _in * mul + addIn[i+4]; _in += in_slope; mul += mul_slope; + out[i+5] = _in * mul + addIn[i+5]; _in += in_slope; mul += mul_slope; + out[i+6] = _in * mul + addIn[i+6]; _in += in_slope; mul += mul_slope; + out[i+7] = _in * mul + addIn[i+7]; _in += in_slope; mul += mul_slope; + } + this._in = nextIn; + this._mul = nextMul; + }; + next[1][1][1] = function() { + this.outputs[0][0] = this.inputs[0][0] * this.inputs[1][0] + this.inputs[2][0]; + }; + next[1][1][0] = function() { + this.outputs[0][0] = this.inputs[0][0] * this.inputs[1][0] + this._add; + }; + next[1][0][2] = function(inNumSamples) { + var out = this.outputs[0]; + var _in = this._in; + var mul = this._mul; + var addIn = this.inputs[2]; + var nextIn = this.inputs[0][0]; + var in_slope = (nextIn - _in) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = _in * mul + addIn[i ]; _in += in_slope; + out[i+1] = _in * mul + addIn[i+1]; _in += in_slope; + out[i+2] = _in * mul + addIn[i+2]; _in += in_slope; + out[i+3] = _in * mul + addIn[i+3]; _in += in_slope; + out[i+4] = _in * mul + addIn[i+4]; _in += in_slope; + out[i+5] = _in * mul + addIn[i+5]; _in += in_slope; + out[i+6] = _in * mul + addIn[i+6]; _in += in_slope; + out[i+7] = _in * mul + addIn[i+7]; _in += in_slope; + } + this._in = nextIn; + }; + next[1][0][1] = function() { + this.outputs[0][0] = this.inputs[0][0] * this._mul + this.inputs[2][0]; + }; + next[1][0][0] = function() { + this.outputs[0][0] = this.inputs[0][0] * this._mul + this._add; + }; + next[3] = function(inNumSamples) { + if (inNumSamples) { + var a = calcDemandInput(this, 0, inNumSamples); + var b = calcDemandInput(this, 1, inNumSamples); + var c = calcDemandInput(this, 2, inNumSamples); + this.outputs[0][0] = isNaN(a) || isNaN(b) || isNaN(c) ? NaN : (a * b) + c; + } else { + resetDemandInput(this, 0); + resetDemandInput(this, 1); + resetDemandInput(this, 2); + } + }; + + return ctor; + })(); + + cc.unit.specs.Sum3 = (function() { + var ctor = function() { + if (this.calcRate === 3) { + this.process = next[3]; + } else { + var rates = this.inRates; + this.process = next[rates[0]][rates[1]][rates[2]]; + this._in0 = this.inputs[0][0]; + this._in1 = this.inputs[1][0]; + this._in2 = this.inputs[2][0]; + if (this.process) { + this.process(1); + } else { + this.outputs[0][0] = this._in0 + this._in1 + this._in2; + } + } + }; + + var next = {}; + next[2] = {}; + next[2][2] = {}; + next[2][1] = {}; + next[2][0] = {}; + next[1] = {}; + next[1][1] = {}; + next[1][0] = {}; + next[0] = {}; + next[0][0] = {}; + + next[2][2][2] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn0 = this.inputs[0]; + var inIn1 = this.inputs[1]; + var inIn2 = this.inputs[2]; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn0[i ] + inIn1[i ] + inIn2[i ]; + out[i+1] = inIn0[i+1] + inIn1[i+1] + inIn2[i+1]; + out[i+2] = inIn0[i+2] + inIn1[i+2] + inIn2[i+2]; + out[i+3] = inIn0[i+3] + inIn1[i+3] + inIn2[i+3]; + out[i+4] = inIn0[i+4] + inIn1[i+4] + inIn2[i+4]; + out[i+5] = inIn0[i+5] + inIn1[i+5] + inIn2[i+5]; + out[i+6] = inIn0[i+6] + inIn1[i+6] + inIn2[i+6]; + out[i+7] = inIn0[i+7] + inIn1[i+7] + inIn2[i+7]; + } + }; + next[2][2][1] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn0 = this.inputs[0]; + var inIn1 = this.inputs[1]; + var in2 = this._in2; + var nextIn2 = this.inputs[2][0]; + var in2_slope = (nextIn2 - in2) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn0[i ] + inIn1[i ] + in2; in2 += in2_slope; + out[i+1] = inIn0[i+1] + inIn1[i+1] + in2; in2 += in2_slope; + out[i+2] = inIn0[i+2] + inIn1[i+2] + in2; in2 += in2_slope; + out[i+3] = inIn0[i+3] + inIn1[i+3] + in2; in2 += in2_slope; + out[i+4] = inIn0[i+4] + inIn1[i+4] + in2; in2 += in2_slope; + out[i+5] = inIn0[i+5] + inIn1[i+5] + in2; in2 += in2_slope; + out[i+6] = inIn0[i+6] + inIn1[i+6] + in2; in2 += in2_slope; + out[i+7] = inIn0[i+7] + inIn1[i+7] + in2; in2 += in2_slope; + } + this._in2 = nextIn2; + }; + next[2][2][0] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn0 = this.inputs[0]; + var inIn1 = this.inputs[1]; + var in2 = this._in2; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn0[i ] + inIn1[i ] + in2; + out[i+1] = inIn0[i+1] + inIn1[i+1] + in2; + out[i+2] = inIn0[i+2] + inIn1[i+2] + in2; + out[i+3] = inIn0[i+3] + inIn1[i+3] + in2; + out[i+4] = inIn0[i+4] + inIn1[i+4] + in2; + out[i+5] = inIn0[i+5] + inIn1[i+5] + in2; + out[i+6] = inIn0[i+6] + inIn1[i+6] + in2; + out[i+7] = inIn0[i+7] + inIn1[i+7] + in2; + } + }; + next[2][1][1] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn0 = this.inputs[0]; + var in12 = this._in1 + this._in2; + var nextIn12 = this.inputs[1][0] + this.inputs[2][0]; + var in12_slope = (nextIn12 - in12) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn0[i ] + in12; in12 += in12_slope; + out[i+1] = inIn0[i+1] + in12; in12 += in12_slope; + out[i+2] = inIn0[i+2] + in12; in12 += in12_slope; + out[i+3] = inIn0[i+3] + in12; in12 += in12_slope; + out[i+4] = inIn0[i+4] + in12; in12 += in12_slope; + out[i+5] = inIn0[i+5] + in12; in12 += in12_slope; + out[i+6] = inIn0[i+6] + in12; in12 += in12_slope; + out[i+7] = inIn0[i+7] + in12; in12 += in12_slope; + } + this._in1 = this.inputs[1][0]; + this._in2 = this.inputs[2][0]; + }; + next[2][1][0] = next[2][1][1]; + next[2][0][0] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn0 = this.inputs[0]; + var in12 = this._in1 + this._in2; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn0[i ] + in12; + out[i+1] = inIn0[i+1] + in12; + out[i+2] = inIn0[i+2] + in12; + out[i+3] = inIn0[i+3] + in12; + out[i+4] = inIn0[i+4] + in12; + out[i+5] = inIn0[i+5] + in12; + out[i+6] = inIn0[i+6] + in12; + out[i+7] = inIn0[i+7] + in12; + } + }; + next[1][1][1] = function() { + this.outputs[0][0] = this.inputs[0][0] + this.inputs[1][0] + this.inputs[2][0]; + }; + next[1][1][0] = next[1][1][1]; + next[1][0][0] = next[1][1][1]; + + next[3] = function(inNumSamples) { + if (inNumSamples) { + var a = calcDemandInput(this, 0, inNumSamples); + var b = calcDemandInput(this, 1, inNumSamples); + var c = calcDemandInput(this, 2, inNumSamples); + this.outputs[0][0] = isNaN(a) || isNaN(b) || isNaN(c) ? NaN : (a + b + c); + } else { + resetDemandInput(this, 0); + resetDemandInput(this, 1); + resetDemandInput(this, 2); + } + }; + + return ctor; + })(); + + cc.unit.specs.Sum4 = (function() { + var ctor = function() { + if (this.calcRate === 3) { + this.process = next[3]; + } else { + var rates = this.inRates; + this.process = next[rates[0]][rates[1]][rates[2]][rates[3]]; + this._in0 = this.inputs[0][0]; + this._in1 = this.inputs[1][0]; + this._in2 = this.inputs[2][0]; + this._in3 = this.inputs[3][0]; + if (this.process) { + this.process(1); + } else { + this.outputs[0][0] = this._in0 + this._in1 + this._in2 + this._in3; + } + } + }; + + var next = {}; + next[2] = {}; + next[2][2] = {}; + next[2][2][2] = {}; + next[2][2][1] = {}; + next[2][2][0] = {}; + next[2][1] = {}; + next[2][1][1] = {}; + next[2][1][0] = {}; + next[2][0] = {}; + next[2][0][0] = {}; + next[1] = {}; + next[1][1] = {}; + next[1][1][1] = {}; + next[1][1][0] = {}; + next[1][0] = {}; + next[1][0][0] = {}; + next[0] = {}; + next[0][0] = {}; + next[0][0][0] = {}; + + next[2][2][2][2] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn0 = this.inputs[0]; + var inIn1 = this.inputs[1]; + var inIn2 = this.inputs[2]; + var inIn3 = this.inputs[3]; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn0[i ] + inIn1[i ] + inIn2[i ] + inIn3[i ]; + out[i+1] = inIn0[i+1] + inIn1[i+1] + inIn2[i+1] + inIn3[i+1]; + out[i+2] = inIn0[i+2] + inIn1[i+2] + inIn2[i+2] + inIn3[i+2]; + out[i+3] = inIn0[i+3] + inIn1[i+3] + inIn2[i+3] + inIn3[i+3]; + out[i+4] = inIn0[i+4] + inIn1[i+4] + inIn2[i+4] + inIn3[i+4]; + out[i+5] = inIn0[i+5] + inIn1[i+5] + inIn2[i+5] + inIn3[i+5]; + out[i+6] = inIn0[i+6] + inIn1[i+6] + inIn2[i+6] + inIn3[i+6]; + out[i+7] = inIn0[i+7] + inIn1[i+7] + inIn2[i+7] + inIn3[i+7]; + } + }; + next[2][2][2][1] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn0 = this.inputs[0]; + var inIn1 = this.inputs[1]; + var inIn2 = this.inputs[2]; + var in3 = this._in3; + var nextIn3 = this.inputs[3][0]; + var in3_slope = (nextIn3 - in3) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn0[i ] + inIn1[i ] + inIn2[i ] + in3; in3 += in3_slope; + out[i+1] = inIn0[i+1] + inIn1[i+1] + inIn2[i+1] + in3; in3 += in3_slope; + out[i+2] = inIn0[i+2] + inIn1[i+2] + inIn2[i+2] + in3; in3 += in3_slope; + out[i+3] = inIn0[i+3] + inIn1[i+3] + inIn2[i+3] + in3; in3 += in3_slope; + out[i+4] = inIn0[i+4] + inIn1[i+4] + inIn2[i+4] + in3; in3 += in3_slope; + out[i+5] = inIn0[i+5] + inIn1[i+5] + inIn2[i+5] + in3; in3 += in3_slope; + out[i+6] = inIn0[i+6] + inIn1[i+6] + inIn2[i+6] + in3; in3 += in3_slope; + out[i+7] = inIn0[i+7] + inIn1[i+7] + inIn2[i+7] + in3; in3 += in3_slope; + } + this._in3 = nextIn3; + }; + next[2][2][2][0] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn0 = this.inputs[0]; + var inIn1 = this.inputs[1]; + var inIn2 = this.inputs[2]; + var in3 = this._in3; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn0[i ] + inIn1[i ] + inIn2[i ] + in3; + out[i+1] = inIn0[i+1] + inIn1[i+1] + inIn2[i+1] + in3; + out[i+2] = inIn0[i+2] + inIn1[i+2] + inIn2[i+2] + in3; + out[i+3] = inIn0[i+3] + inIn1[i+3] + inIn2[i+3] + in3; + out[i+4] = inIn0[i+4] + inIn1[i+4] + inIn2[i+4] + in3; + out[i+5] = inIn0[i+5] + inIn1[i+5] + inIn2[i+5] + in3; + out[i+6] = inIn0[i+6] + inIn1[i+6] + inIn2[i+6] + in3; + out[i+7] = inIn0[i+7] + inIn1[i+7] + inIn2[i+7] + in3; + } + }; + next[2][2][1][1] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn0 = this.inputs[0]; + var inIn1 = this.inputs[1]; + var in23 = this._in2 + this._in3; + var nextIn23 = this.inputs[2][0] + this.inputs[3][0]; + var in23_slope = (nextIn23 - in23) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn0[i ] + inIn1[i ] + in23; in23 += in23_slope; + out[i+1] = inIn0[i+1] + inIn1[i+1] + in23; in23 += in23_slope; + out[i+2] = inIn0[i+2] + inIn1[i+2] + in23; in23 += in23_slope; + out[i+3] = inIn0[i+3] + inIn1[i+3] + in23; in23 += in23_slope; + out[i+4] = inIn0[i+4] + inIn1[i+4] + in23; in23 += in23_slope; + out[i+5] = inIn0[i+5] + inIn1[i+5] + in23; in23 += in23_slope; + out[i+6] = inIn0[i+6] + inIn1[i+6] + in23; in23 += in23_slope; + out[i+7] = inIn0[i+7] + inIn1[i+7] + in23; in23 += in23_slope; + } + this._in2 = this.inputs[2][0]; + this._in3 = this.inputs[2][0]; + }; + next[2][2][1][0] = next[2][2][1][1]; + next[2][2][0][0] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn0 = this.inputs[0]; + var inIn1 = this.inputs[1]; + var in23 = this._in2 + this._in3; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn0[i ] + inIn1[i ] + in23; + out[i+1] = inIn0[i+1] + inIn1[i+1] + in23; + out[i+2] = inIn0[i+2] + inIn1[i+2] + in23; + out[i+3] = inIn0[i+3] + inIn1[i+3] + in23; + out[i+4] = inIn0[i+4] + inIn1[i+4] + in23; + out[i+5] = inIn0[i+5] + inIn1[i+5] + in23; + out[i+6] = inIn0[i+6] + inIn1[i+6] + in23; + out[i+7] = inIn0[i+7] + inIn1[i+7] + in23; + } + }; + next[2][1][1][1] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn0 = this.inputs[0]; + var in123 = this._in1 + this._in2 + this._in3; + var nextIn123 = this.inputs[1][0] + this.inputs[2][0] + this.inputs[3][0]; + var in123_slope = (nextIn123 - in123) * this.rate.slopeFactor; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn0[i ] + in123; in123 += in123_slope; + out[i+1] = inIn0[i+1] + in123; in123 += in123_slope; + out[i+2] = inIn0[i+2] + in123; in123 += in123_slope; + out[i+3] = inIn0[i+3] + in123; in123 += in123_slope; + out[i+4] = inIn0[i+4] + in123; in123 += in123_slope; + out[i+5] = inIn0[i+5] + in123; in123 += in123_slope; + out[i+6] = inIn0[i+6] + in123; in123 += in123_slope; + out[i+7] = inIn0[i+7] + in123; in123 += in123_slope; + } + this._in1 = this.inputs[1][0]; + this._in2 = this.inputs[2][0]; + this._in3 = this.inputs[3][0]; + }; + next[2][1][1][0] = next[2][1][1][1]; + next[2][1][0][0] = next[2][1][1][1]; + next[2][0][0][0] = function(inNumSamples) { + var out = this.outputs[0]; + var inIn0 = this.inputs[0]; + var in123 = this._in1 + this._in2 + this._in3; + for (var i = 0; i < inNumSamples; i += 8) { + out[i ] = inIn0[i ] + in123; + out[i+1] = inIn0[i+1] + in123; + out[i+2] = inIn0[i+2] + in123; + out[i+3] = inIn0[i+3] + in123; + out[i+4] = inIn0[i+4] + in123; + out[i+5] = inIn0[i+5] + in123; + out[i+6] = inIn0[i+6] + in123; + out[i+7] = inIn0[i+7] + in123; + } + }; + next[1][1][1][1] = function() { + this.outputs[0][0] = this.inputs[0][0] + this.inputs[1][0] + this.inputs[2][0] + this.inputs[3][0]; + }; + next[1][1][1][0] = next[1][1][1][1]; + next[1][1][0][0] = next[1][1][1][1]; + next[1][0][0][0] = next[1][1][1][1]; + + next[3] = function(inNumSamples) { + if (inNumSamples) { + var a = calcDemandInput(this, 0, inNumSamples); + var b = calcDemandInput(this, 1, inNumSamples); + var c = calcDemandInput(this, 2, inNumSamples); + var d = calcDemandInput(this, 3, inNumSamples); + this.outputs[0][0] = isNaN(a) || isNaN(b) || isNaN(c) || isNaN(d) ? NaN : (a + b + c + d); + } else { + resetDemandInput(this, 0); + resetDemandInput(this, 1); + resetDemandInput(this, 2); + resetDemandInput(this, 3); + } + }; + + return ctor; + })(); + + module.exports = { + uopFunc: uopFunc, + unary_a: unary_a, + unary_k: unary_k, + unary_d: unary_d, + bopFunc: bopFunc, + binary_aa: binary_aa, + binary_ak: binary_ak, + binary_ai: binary_ai, + binary_ka: binary_ka, + binary_kk: binary_kk, + binary_ki: binary_ki, + binary_ia: binary_ia, + binary_ik: binary_ik, + binary_dd: binary_dd + }; + +}); +var exports = _require("cc/cc", "cc/loader"); +if (typeof module !== "undefined") { + module.exports = exports; +} +})(this.self||global); + +} + +/* + FILE ARCHIVED ON 16:01:15 Aug 27, 2015 AND RETRIEVED FROM THE + INTERNET ARCHIVE ON 03:40:13 Jun 07, 2026. + JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. + + ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. + SECTION 108(a)(3)). +*/ +/* +playback timings (ms): + capture_cache.get: 8.43 + load_resource: 80.515 + PetaboxLoader3.resolve: 37.0 + PetaboxLoader3.datanode: 11.677 +*/ \ No newline at end of file diff --git a/web.archive.org/web/20150828053525js_/http:/void.hi-res.net/js/cs.js b/web.archive.org/web/20150828053525js_/http:/void.hi-res.net/js/cs.js new file mode 100644 index 000000000..7552d8194 --- /dev/null +++ b/web.archive.org/web/20150828053525js_/http:/void.hi-res.net/js/cs.js @@ -0,0 +1,38 @@ +var _____WB$wombat$assign$function_____=function(name){return (globalThis._wb_wombat && globalThis._wb_wombat.local_init && globalThis._wb_wombat.local_init(name))||globalThis[name];};if(!globalThis.__WB_pmw){globalThis.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{ +let window = _____WB$wombat$assign$function_____("window"); +let self = _____WB$wombat$assign$function_____("self"); +let document = _____WB$wombat$assign$function_____("document"); +let location = _____WB$wombat$assign$function_____("location"); +let top = _____WB$wombat$assign$function_____("top"); +let parent = _____WB$wombat$assign$function_____("parent"); +let frames = _____WB$wombat$assign$function_____("frames"); +let opener = _____WB$wombat$assign$function_____("opener"); +/** + * CoffeeScript Compiler v1.6.3 + * http://coffeescript.org + * + * Copyright 2011, Jeremy Ashkenas + * Released under the MIT License + */ +!function(root){var CoffeeScript=function(){function require(e){return require[e]}return require["./helpers"]=function(){var e={},t={exports:e};return function(){var t,n,i,s,r,o;e.starts=function(e,t,n){return t===e.substr(n,t.length)},e.ends=function(e,t,n){var i;return i=t.length,t===e.substr(e.length-i-(n||0),i)},e.repeat=r=function(e,t){var n;for(n="";t>0;)1&t&&(n+=e),t>>>=1,e+=e;return n},e.compact=function(e){var t,n,i,s;for(s=[],n=0,i=e.length;i>n;n++)t=e[n],t&&s.push(t);return s},e.count=function(e,t){var n,i;if(n=i=0,!t.length)return 1/0;for(;i=1+e.indexOf(t,i);)n++;return n},e.merge=function(e,t){return n(n({},e),t)},n=e.extend=function(e,t){var n,i;for(n in t)i=t[n],e[n]=i;return e},e.flatten=i=function(e){var t,n,s,r;for(n=[],s=0,r=e.length;r>s;s++)t=e[s],t instanceof Array?n=n.concat(i(t)):n.push(t);return n},e.del=function(e,t){var n;return n=e[t],delete e[t],n},e.last=s=function(e,t){return e[e.length-(t||0)-1]},e.some=null!=(o=Array.prototype.some)?o:function(e){var t,n,i;for(n=0,i=this.length;i>n;n++)if(t=this[n],e(t))return!0;return!1},e.invertLiterate=function(e){var t,n,i;return i=!0,n=function(){var n,s,r,o;for(r=e.split("\n"),o=[],n=0,s=r.length;s>n;n++)t=r[n],i&&/^([ ]{4}|[ ]{0,3}\t)/.test(t)?o.push(t):(i=/^\s*$/.test(t))?o.push(t):o.push("# "+t);return o}(),n.join("\n")},t=function(e,t){return t?{first_line:e.first_line,first_column:e.first_column,last_line:t.last_line,last_column:t.last_column}:e},e.addLocationDataFn=function(e,n){return function(i){return"object"==typeof i&&i.updateLocationDataIfMissing&&i.updateLocationDataIfMissing(t(e,n)),i}},e.locationDataToString=function(e){var t;return"2"in e&&"first_line"in e[2]?t=e[2]:"first_line"in e&&(t=e),t?""+(t.first_line+1)+":"+(t.first_column+1)+"-"+(""+(t.last_line+1)+":"+(t.last_column+1)):"No location data"},e.baseFileName=function(e,t,n){var i,s;return null==t&&(t=!1),null==n&&(n=!1),s=n?/\\|\//:/\//,i=e.split(s),e=i[i.length-1],t?(i=e.split("."),i.pop(),"coffee"===i[i.length-1]&&i.length>1&&i.pop(),i.join(".")):e},e.isCoffee=function(e){return/\.((lit)?coffee|coffee\.md)$/.test(e)},e.isLiterate=function(e){return/\.(litcoffee|coffee\.md)$/.test(e)},e.throwSyntaxError=function(e,t){var n;throw null==t.last_line&&(t.last_line=t.first_line),null==t.last_column&&(t.last_column=t.first_column),n=new SyntaxError(e),n.location=t,n},e.prettyErrorMessage=function(e,t,n,i){var s,o,a,c,h,l,u,p,d,f,m;return e.location?(m=e.location,h=m.first_line,c=m.first_column,u=m.last_line,l=m.last_column,s=n.split("\n")[h],f=c,a=h===u?l+1:s.length,p=r(" ",f)+r("^",a-f),i&&(o=function(e){return""+e+""},s=s.slice(0,f)+o(s.slice(f,a))+s.slice(a),p=o(p)),d=""+t+":"+(h+1)+":"+(c+1)+": error: "+e.message+"\n"+s+"\n"+p):e.stack||""+e}}.call(this),t.exports}(),require["./rewriter"]=function(){var e={},t={exports:e};return function(){var t,n,i,s,r,o,a,c,h,l,u,p,d,f,m,b,k,g,y=[].indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(t in this&&this[t]===e)return t;return-1},v=[].slice;for(d=function(e,t){var n;return n=[e,t],n.generated=!0,n},e.Rewriter=function(){function e(){}return e.prototype.rewrite=function(e){return this.tokens=e,this.removeLeadingNewlines(),this.removeMidExpressionNewlines(),this.closeOpenCalls(),this.closeOpenIndexes(),this.addImplicitIndentation(),this.tagPostfixConditionals(),this.addImplicitBracesAndParens(),this.addLocationDataToGeneratedTokens(),this.tokens},e.prototype.scanTokens=function(e){var t,n,i;for(i=this.tokens,t=0;n=i[t];)t+=e.call(this,n,t,i);return!0},e.prototype.detectEnd=function(e,t,n){var r,o,a,c,h;for(a=this.tokens,r=0;o=a[e];){if(0===r&&t.call(this,o,e))return n.call(this,o,e);if(!o||0>r)return n.call(this,o,e-1);c=o[0],y.call(s,c)>=0?r+=1:(h=o[0],y.call(i,h)>=0&&(r-=1)),e+=1}return e-1},e.prototype.removeLeadingNewlines=function(){var e,t,n,i,s;for(s=this.tokens,e=n=0,i=s.length;i>n&&(t=s[e][0],"TERMINATOR"===t);e=++n);return e?this.tokens.splice(0,e):void 0},e.prototype.removeMidExpressionNewlines=function(){return this.scanTokens(function(e,t,i){var s;return"TERMINATOR"===e[0]&&(s=this.tag(t+1),y.call(n,s)>=0)?(i.splice(t,1),0):1})},e.prototype.closeOpenCalls=function(){var e,t;return t=function(e,t){var n;return")"===(n=e[0])||"CALL_END"===n||"OUTDENT"===e[0]&&")"===this.tag(t-1)},e=function(e,t){return this.tokens["OUTDENT"===e[0]?t-1:t][0]="CALL_END"},this.scanTokens(function(n,i){return"CALL_START"===n[0]&&this.detectEnd(i+1,t,e),1})},e.prototype.closeOpenIndexes=function(){var e,t;return t=function(e){var t;return"]"===(t=e[0])||"INDEX_END"===t},e=function(e){return e[0]="INDEX_END"},this.scanTokens(function(n,i){return"INDEX_START"===n[0]&&this.detectEnd(i+1,t,e),1})},e.prototype.matchTags=function(){var e,t,n,i,s,r,o;for(t=arguments[0],i=2<=arguments.length?v.call(arguments,1):[],e=0,n=s=0,r=i.length;r>=0?r>s:s>r;n=r>=0?++s:--s){for(;"HERECOMMENT"===this.tag(t+n+e);)e+=2;if(null!=i[n]&&("string"==typeof i[n]&&(i[n]=[i[n]]),o=this.tag(t+n+e),y.call(i[n],o)<0))return!1}return!0},e.prototype.looksObjectish=function(e){return this.matchTags(e,"@",null,":")||this.matchTags(e,null,":")},e.prototype.findTagsBackwards=function(e,t){var n,r,o,a,c,h,u;for(n=[];e>=0&&(n.length||(a=this.tag(e),y.call(t,a)<0&&(c=this.tag(e),y.call(s,c)<0||this.tokens[e].generated)&&(h=this.tag(e),y.call(l,h)<0)));)r=this.tag(e),y.call(i,r)>=0&&n.push(this.tag(e)),o=this.tag(e),y.call(s,o)>=0&&n.length&&n.pop(),e-=1;return u=this.tag(e),y.call(t,u)>=0},e.prototype.addImplicitBracesAndParens=function(){var e;return e=[],this.scanTokens(function(t,n,h){var u,p,f,m,b,k,g,v,w,T,C,F,L,N,x,E,D,S,R,A,I,_,$,O,j,M;if(A=t[0],T=(n>0?h[n-1]:[])[0],v=(n"!==T&&"->"!==T&&"["!==T&&"("!==T&&","!==T&&"{"!==T&&"TRY"!==T&&"ELSE"!==T&&"="!==T)for(;b();)u();return k()&&e.pop(),e.push([A,n]),f(1)}if(y.call(s,A)>=0)return e.push([A,n]),f(1);if(y.call(i,A)>=0){for(;m();)b()?u():g()?p():e.pop();e.pop()}if((y.call(a,A)>=0&&t.spaced&&!t.stringEnd||"?"===A&&n>0&&!h[n-1].spaced)&&(y.call(r,v)>=0||y.call(c,v)>=0&&!(null!=(I=h[n+1])?I.spaced:void 0)&&!(null!=(_=h[n+1])?_.newLine:void 0)))return"?"===A&&(A=t[0]="FUNC_EXIST"),D(n+1),f(2);if(y.call(a,A)>=0&&this.matchTags(n+1,"INDENT",null,":")&&!this.findTagsBackwards(n,["CLASS","EXTENDS","IF","CATCH","SWITCH","LEADING_WHEN","FOR","WHILE","UNTIL"]))return D(n+1),e.push(["INDENT",n+2]),f(3);if(":"===A){for(C="@"===this.tag(n-2)?n-2:n-1;"HERECOMMENT"===this.tag(C-2);)C-=2;return R=0===C||($=this.tag(C-1),y.call(l,$)>=0)||h[C-1].newLine,x()&&(O=x(),N=O[0],L=O[1],("{"===N||"INDENT"===N&&"{"===this.tag(L-1))&&(R||","===this.tag(C-1)||"{"===this.tag(C-1)))?f(1):(S(C,!!R),f(2))}if("OUTDENT"===T&&b()&&("."===A||"?."===A||"::"===A||"?::"===A))return u(),f(1);if(g()&&y.call(l,A)>=0&&(x()[2].sameLine=!1),y.call(o,A)>=0)for(;m();)if(j=x(),N=j[0],L=j[1],M=j[2],F=M.sameLine,R=M.startsLine,b()&&","!==T)u();else if(g()&&F&&!R)p();else{if(!g()||"TERMINATOR"!==A||","===T||R&&this.looksObjectish(n+1))break;p()}if(","===A&&!this.looksObjectish(n+1)&&g()&&("TERMINATOR"!==v||!this.looksObjectish(n+2)))for(w="OUTDENT"===v?1:0;g();)p(n+w);return f(1)})},e.prototype.addLocationDataToGeneratedTokens=function(){return this.scanTokens(function(e,t,n){var i,s,r,o,a,c;return e[2]?1:e.generated||e.explicit?("{"===e[0]&&(r=null!=(a=n[t+1])?a[2]:void 0)?(s=r.first_line,i=r.first_column):(o=null!=(c=n[t-1])?c[2]:void 0)?(s=o.last_line,i=o.last_column):s=i=0,e[2]={first_line:s,first_column:i,last_line:s,last_column:i},1):1})},e.prototype.addImplicitIndentation=function(){var e,t,n,i,s;return s=n=i=null,t=function(e){var t,n;return";"!==e[1]&&(t=e[0],y.call(u,t)>=0)&&!("ELSE"===e[0]&&"THEN"!==s)&&!!("CATCH"!==(n=e[0])&&"FINALLY"!==n||"->"!==s&&"=>"!==s)},e=function(e,t){return this.tokens.splice(","===this.tag(t-1)?t-1:t,0,i)},this.scanTokens(function(r,o,a){var c,h,l,u,d;if(h=r[0],"TERMINATOR"===h&&"THEN"===this.tag(o+1))return a.splice(o,1),0;if("ELSE"===h&&"OUTDENT"!==this.tag(o-1))return a.splice.apply(a,[o,0].concat(v.call(this.indentation()))),2;if("CATCH"===h)for(c=l=1;2>=l;c=++l)if("OUTDENT"===(u=this.tag(o+c))||"TERMINATOR"===u||"FINALLY"===u)return a.splice.apply(a,[o+c,0].concat(v.call(this.indentation()))),2+c;return y.call(p,h)>=0&&"INDENT"!==this.tag(o+1)&&("ELSE"!==h||"IF"!==this.tag(o+1))?(s=h,d=this.indentation(!0),n=d[0],i=d[1],"THEN"===s&&(n.fromThen=!0),a.splice(o+1,0,n),this.detectEnd(o+2,t,e),"THEN"===h&&a.splice(o,1),1):1})},e.prototype.tagPostfixConditionals=function(){var e,t,n;return n=null,t=function(e,t){var n,i;return i=e[0],n=this.tokens[t-1][0],"TERMINATOR"===i||"INDENT"===i&&y.call(p,n)<0},e=function(e){return"INDENT"!==e[0]||e.generated&&!e.fromThen?n[0]="POST_"+n[0]:void 0},this.scanTokens(function(i,s){return"IF"!==i[0]?1:(n=i,this.detectEnd(s+1,t,e),1)})},e.prototype.indentation=function(e){var t,n;return null==e&&(e=!1),t=["INDENT",2],n=["OUTDENT",2],e&&(t.generated=n.generated=!0),e||(t.explicit=n.explicit=!0),[t,n]},e.prototype.generate=d,e.prototype.tag=function(e){var t;return null!=(t=this.tokens[e])?t[0]:void 0},e}(),t=[["(",")"],["[","]"],["{","}"],["INDENT","OUTDENT"],["CALL_START","CALL_END"],["PARAM_START","PARAM_END"],["INDEX_START","INDEX_END"]],e.INVERSES=h={},s=[],i=[],b=0,k=t.length;k>b;b++)g=t[b],f=g[0],m=g[1],s.push(h[m]=f),i.push(h[f]=m);n=["CATCH","WHEN","ELSE","FINALLY"].concat(i),a=["IDENTIFIER","SUPER",")","CALL_END","]","INDEX_END","@","THIS"],r=["IDENTIFIER","NUMBER","STRING","JS","REGEX","NEW","PARAM_START","CLASS","IF","TRY","SWITCH","THIS","BOOL","NULL","UNDEFINED","UNARY","SUPER","THROW","@","->","=>","[","(","{","--","++"],c=["+","-"],o=["POST_IF","FOR","WHILE","UNTIL","WHEN","BY","LOOP","TERMINATOR"],p=["ELSE","->","=>","TRY","FINALLY","THEN"],u=["TERMINATOR","CATCH","FINALLY","ELSE","OUTDENT","LEADING_WHEN"],l=["TERMINATOR","INDENT","OUTDENT"]}.call(this),t.exports}(),require["./lexer"]=function(){var e={},t={exports:e};return function(){var t,n,i,s,r,o,a,c,h,l,u,p,d,f,m,b,k,g,y,v,w,T,C,F,L,N,x,E,D,S,R,A,I,_,$,O,j,M,B,V,P,U,q,H,G,W,X,Y,K,z,J,Z,Q,et=[].indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(t in this&&this[t]===e)return t;return-1};Z=require("./rewriter"),O=Z.Rewriter,g=Z.INVERSES,Q=require("./helpers"),H=Q.count,z=Q.starts,q=Q.compact,X=Q.last,K=Q.repeat,G=Q.invertLiterate,Y=Q.locationDataToString,J=Q.throwSyntaxError,e.Lexer=L=function(){function e(){}return e.prototype.tokenize=function(e,t){var n,i,s,r;for(null==t&&(t={}),this.literate=t.literate,this.indent=0,this.indebt=0,this.outdebt=0,this.indents=[],this.ends=[],this.tokens=[],this.chunkLine=t.line||0,this.chunkColumn=t.column||0,e=this.clean(e),i=0;this.chunk=e.slice(i);)n=this.identifierToken()||this.commentToken()||this.whitespaceToken()||this.lineToken()||this.heredocToken()||this.stringToken()||this.numberToken()||this.regexToken()||this.jsToken()||this.literalToken(),r=this.getLineAndColumnFromChunk(n),this.chunkLine=r[0],this.chunkColumn=r[1],i+=n;return this.closeIndentation(),(s=this.ends.pop())&&this.error("missing "+s),t.rewrite===!1?this.tokens:(new O).rewrite(this.tokens)},e.prototype.clean=function(e){return e.charCodeAt(0)===t&&(e=e.slice(1)),e=e.replace(/\r/g,"").replace(V,""),U.test(e)&&(e="\n"+e,this.chunkLine--),this.literate&&(e=G(e)),e},e.prototype.identifierToken=function(){var e,t,n,i,s,c,h,l,u,p,d,f,m,k;return(h=b.exec(this.chunk))?(c=h[0],i=h[1],e=h[2],s=i.length,l=void 0,"own"===i&&"FOR"===this.tag()?(this.token("OWN",i),i.length):(n=e||(u=X(this.tokens))&&("."===(f=u[0])||"?."===f||"::"===f||"?::"===f||!u.spaced&&"@"===u[0]),p="IDENTIFIER",!n&&(et.call(w,i)>=0||et.call(a,i)>=0)&&(p=i.toUpperCase(),"WHEN"===p&&(m=this.tag(),et.call(T,m)>=0)?p="LEADING_WHEN":"FOR"===p?this.seenFor=!0:"UNLESS"===p?p="IF":et.call(P,p)>=0?p="UNARY":et.call(_,p)>=0&&("INSTANCEOF"!==p&&this.seenFor?(p="FOR"+p,this.seenFor=!1):(p="RELATION","!"===this.value()&&(l=this.tokens.pop(),i="!"+i)))),et.call(v,i)>=0&&(n?(p="IDENTIFIER",i=new String(i),i.reserved=!0):et.call($,i)>=0&&this.error('reserved word "'+i+'"')),n||(et.call(r,i)>=0&&(i=o[i]),p=function(){switch(i){case"!":return"UNARY";case"==":case"!=":return"COMPARE";case"&&":case"||":return"LOGIC";case"true":case"false":return"BOOL";case"break":case"continue":return"STATEMENT";default:return p}}()),d=this.token(p,i,0,s),l&&(k=[l[2].first_line,l[2].first_column],d[2].first_line=k[0],d[2].first_column=k[1]),e&&(t=c.lastIndexOf(":"),this.token(":",":",t,e.length)),c.length)):0},e.prototype.numberToken=function(){var e,t,n,i,s;return(n=R.exec(this.chunk))?(i=n[0],/^0[BOX]/.test(i)?this.error("radix prefix '"+i+"' must be lowercase"):/E/.test(i)&&!/^0x/.test(i)?this.error("exponential notation '"+i+"' must be indicated with a lowercase 'e'"):/^0\d*[89]/.test(i)?this.error("decimal literal '"+i+"' must not be prefixed with '0'"):/^0\d+/.test(i)&&this.error("octal literal '"+i+"' must be prefixed with '0o'"),t=i.length,(s=/^0o([0-7]+)/.exec(i))&&(i="0x"+parseInt(s[1],8).toString(16)),(e=/^0b([01]+)/.exec(i))&&(i="0x"+parseInt(e[1],2).toString(16)),this.token("NUMBER",i,0,t),t):0},e.prototype.stringToken=function(){var e,t,n;switch(this.chunk.charAt(0)){case"'":if(!(e=M.exec(this.chunk)))return 0;n=e[0],this.token("STRING",n.replace(x,"\\\n"),0,n.length);break;case'"':if(!(n=this.balancedString(this.chunk,'"')))return 0;0=0)?0:(n=I.exec(this.chunk))?(o=n,n=o[0],s=o[1],e=o[2],"/*"===s.slice(0,2)&&this.error("regular expressions cannot begin with `*`"),"//"===s&&(s="/(?:)/"),this.token("REGEX",""+s+e,0,n.length),n.length):0)},e.prototype.heregexToken=function(e){var t,n,i,s,r,o,a,c,h,l,u,p,d,f,b,k;if(s=e[0],t=e[1],n=e[2],0>t.indexOf("#{"))return a=t.replace(m,"").replace(/\//g,"\\/"),a.match(/^\*/)&&this.error("regular expressions cannot begin with `*`"),this.token("REGEX","/"+(a||"(?:)")+"/"+n,0,s.length),s.length;for(this.token("IDENTIFIER","RegExp",0,0),this.token("CALL_START","(",0,0),l=[],f=this.interpolateString(t,{regex:!0}),p=0,d=f.length;d>p;p++){if(h=f[p],c=h[0],u=h[1],"TOKENS"===c)l.push.apply(l,u);else if("NEOSTRING"===c){if(!(u=u.replace(m,"")))continue;u=u.replace(/\\/g,"\\\\"),h[0]="STRING",h[1]=this.makeString(u,'"',!0),l.push(h)}else this.error("Unexpected "+c);o=X(this.tokens),r=["+","+"],r[2]=o[2],l.push(r)}return l.pop(),"STRING"!==(null!=(b=l[0])?b[0]:void 0)&&(this.token("STRING",'""',0,0),this.token("+","+",0,0)),(k=this.tokens).push.apply(k,l),n&&(i=s.lastIndexOf(n),this.token(",",",",i,0),this.token("STRING",'"'+n+'"',i,n.length)),this.token(")",")",s.length-1,0),s.length},e.prototype.lineToken=function(){var e,t,n,i,s;if(!(n=E.exec(this.chunk)))return 0;if(t=n[0],this.seenFor=!1,s=t.length-1-t.lastIndexOf("\n"),i=this.unfinished(),s-this.indebt===this.indent)return i?this.suppressNewlines():this.newlineToken(0),t.length;if(s>this.indent){if(i)return this.indebt=s-this.indent,this.suppressNewlines(),t.length;e=s-this.indent+this.outdebt,this.token("INDENT",e,t.length-s,s),this.indents.push(e),this.ends.push("OUTDENT"),this.outdebt=this.indebt=0}else this.indebt=0,this.outdentToken(this.indent-s,i,t.length);return this.indent=s,t.length},e.prototype.outdentToken=function(e,t,n){for(var i,s;e>0;)s=this.indents.length-1,void 0===this.indents[s]?e=0:this.indents[s]===this.outdebt?(e-=this.outdebt,this.outdebt=0):this.indents[s]=0)&&this.error('reserved word "'+this.value()+"\" can't be assigned"),"||"===(a=t[1])||"&&"===a))return t[0]="COMPOUND_ASSIGN",t[1]+="=",r.length;if(";"===r)this.seenFor=!1,n="TERMINATOR";else if(et.call(N,r)>=0)n="MATH";else if(et.call(h,r)>=0)n="COMPARE";else if(et.call(l,r)>=0)n="COMPOUND_ASSIGN";else if(et.call(P,r)>=0)n="UNARY";else if(et.call(j,r)>=0)n="SHIFT";else if(et.call(F,r)>=0||"?"===r&&(null!=t?t.spaced:void 0))n="LOGIC";else if(t&&!t.spaced)if("("===r&&(c=t[0],et.call(i,c)>=0))"?"===t[0]&&(t[0]="FUNC_EXIST"),n="CALL_START";else if("["===r&&(u=t[0],et.call(k,u)>=0))switch(n="INDEX_START",t[0]){case"?":t[0]="INDEX_SOAK"}switch(r){case"(":case"{":case"[":this.ends.push(g[r]);break;case")":case"}":case"]":this.pair(r)}return this.token(n,r),r.length},e.prototype.sanitizeHeredoc=function(e,t){var n,i,s,r,o;if(s=t.indent,i=t.herecomment){if(p.test(e)&&this.error('block comment cannot contain "*/", starting'),e.indexOf("\n")<0)return e}else for(;r=d.exec(e);)n=r[1],(null===s||0<(o=n.length)&&o=1?h>c:c>h;i=h>=1?++c:--c)if(n)--n;else{switch(s=e.charAt(i)){case"\\":++n;continue;case t:if(a.pop(),!a.length)return e.slice(0,+i+1||9e9);t=a[a.length-1];continue}"}"!==t||'"'!==s&&"'"!==s?"}"===t&&"/"===s&&(r=f.exec(e.slice(i))||I.exec(e.slice(i)))?n+=r[0].length-1:"}"===t&&"{"===s?a.push(t="}"):'"'===t&&"#"===o&&"{"===s&&a.push(t="}"):a.push(t=s),o=s}return this.error("missing "+a.pop()+", starting")},e.prototype.interpolateString=function(t,n){var i,s,r,o,a,c,h,l,u,p,d,f,m,b,k,g,y,v,w,T,C,F,L,N,x,E,D,S;for(null==n&&(n={}),r=n.heredoc,y=n.regex,m=n.offsetInChunk,w=n.strOffset,u=n.lexedLength,m=m||0,w=w||0,u=u||t.length,r&&t.length>0&&"\n"===t[0]&&(t=t.slice(1),w++),F=[],b=0,o=-1;l=t.charAt(o+=1);)"\\"!==l?"#"===l&&"{"===t.charAt(o+1)&&(s=this.balancedString(t.slice(o+1),"}"))&&(o>b&&F.push(this.makeToken("NEOSTRING",t.slice(b,o),w+b)),a=s.slice(1,-1),a.length&&(E=this.getLineAndColumnFromChunk(w+o+1),p=E[0],i=E[1],f=(new e).tokenize(a,{line:p,column:i,rewrite:!1}),g=f.pop(),"TERMINATOR"===(null!=(D=f[0])?D[0]:void 0)&&(g=f.shift()),(h=f.length)&&(h>1&&(f.unshift(this.makeToken("(","(",w+o+1,0)),f.push(this.makeToken(")",")",w+o+1+a.length,0))),F.push(["TOKENS",f]))),o+=s.length,b=o+1):o+=1;if(o>b&&b1)&&this.token("(","(",m,0),o=N=0,x=F.length;x>N;o=++N)C=F[o],T=C[0],L=C[1],o&&(o&&(k=this.token("+","+")),d="TOKENS"===T?L[0]:C,k[2]={first_line:d[2].first_line,first_column:d[2].first_column,last_line:d[2].first_line,last_column:d[2].first_column}),"TOKENS"===T?(S=this.tokens).push.apply(S,L):"NEOSTRING"===T?(C[0]="STRING",C[1]=this.makeString(L,'"',r),this.tokens.push(C)):this.error("Unexpected "+T);return c&&(v=this.makeToken(")",")",m+u,0),v.stringEnd=!0,this.tokens.push(v)),F},e.prototype.pair=function(e){var t,n;return e!==(n=X(this.ends))?("OUTDENT"!==n&&this.error("unmatched "+e),this.indent-=t=X(this.indents),this.outdentToken(t,!0),this.pair(e)):this.ends.pop()},e.prototype.getLineAndColumnFromChunk=function(e){var t,n,i,s;return 0===e?[this.chunkLine,this.chunkColumn]:(s=e>=this.chunk.length?this.chunk:this.chunk.slice(0,+(e-1)+1||9e9),n=H(s,"\n"),t=this.chunkColumn,n>0?(i=s.split("\n"),t=X(i).length):t+=s.length,[this.chunkLine+n,t])},e.prototype.makeToken=function(e,t,n,i){var s,r,o,a,c;return null==n&&(n=0),null==i&&(i=t.length),r={},a=this.getLineAndColumnFromChunk(n),r.first_line=a[0],r.first_column=a[1],s=Math.max(0,i-1),c=this.getLineAndColumnFromChunk(n+s),r.last_line=c[0],r.last_column=c[1],o=[e,t,r]},e.prototype.token=function(e,t,n,i){var s;return s=this.makeToken(e,t,n,i),this.tokens.push(s),s},e.prototype.tag=function(e,t){var n;return(n=X(this.tokens,e))&&(t?n[0]=t:n[0])},e.prototype.value=function(e,t){var n;return(n=X(this.tokens,e))&&(t?n[1]=t:n[1])},e.prototype.unfinished=function(){var e;return C.test(this.chunk)||"\\"===(e=this.tag())||"."===e||"?."===e||"?::"===e||"UNARY"===e||"MATH"===e||"+"===e||"-"===e||"SHIFT"===e||"RELATION"===e||"COMPARE"===e||"LOGIC"===e||"THROW"===e||"EXTENDS"===e},e.prototype.escapeLines=function(e,t){return e.replace(x,t?"\\n":"")},e.prototype.makeString=function(e,t,n){return e?(e=e.replace(/\\([\s\S])/g,function(e,n){return"\n"===n||n===t?n:e}),e=e.replace(RegExp(""+t,"g"),"\\$&"),t+this.escapeLines(e,n)+t):t+t},e.prototype.error=function(e){return J(e,{first_line:this.chunkLine,first_column:this.chunkColumn})},e}(),w=["true","false","null","this","new","delete","typeof","in","instanceof","return","throw","break","continue","debugger","if","else","switch","for","while","do","try","catch","finally","class","extends","super"],a=["undefined","then","unless","until","loop","of","by","when"],o={and:"&&",or:"||",is:"==",isnt:"!=",not:"!",yes:"true",no:"false",on:"true",off:"false"},r=function(){var e;e=[];for(W in o)e.push(W);return e}(),a=a.concat(r),$=["case","default","function","var","void","with","const","let","enum","export","import","native","__hasProp","__extends","__slice","__bind","__indexOf","implements","interface","package","private","protected","public","static","yield"],B=["arguments","eval"],v=w.concat($).concat(B),e.RESERVED=$.concat(w).concat(a).concat(B),e.STRICT_PROSCRIBED=B,t=65279,b=/^([$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)([^\n\S]*:(?!:))?/,R=/^0b[01]+|^0o[0-7]+|^0x[\da-f]+|^\d*\.?\d+(?:e[+-]?\d+)?/i,u=/^("""|''')([\s\S]*?)(?:\n[^\n\S]*)?\1/,A=/^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?(\.|::)|\.{2,3})/,U=/^[^\n\S]+/,c=/^###([^#][\s\S]*?)(?:###[^\n\S]*|(?:###)$)|^(?:\s*#(?!##[^#]).*)+/,s=/^[-=]>/,E=/^(?:\n[^\n\S]*)+/,M=/^'[^\\']*(?:\\.[^\\']*)*'/,y=/^`[^\\`]*(?:\\.[^\\`]*)*`/,I=/^(\/(?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/)([imgy]{0,4})(?!\w)/,f=/^\/{3}([\s\S]+?)\/{3}([imgy]{0,4})(?!\w)/,m=/\s+(?:#.*)?/g,x=/\n/g,d=/\n+([^\n\S]*)/g,p=/\*\//,C=/^\s*(?:,|\??\.(?![.\d])|::)/,V=/\s+$/,l=["-=","+=","/=","*=","%=","||=","&&=","?=","<<=",">>=",">>>=","&=","^=","|="],P=["!","~","NEW","TYPEOF","DELETE","DO"],F=["&&","||","&","|","^"],j=["<<",">>",">>>"],h=["==","!=","<",">","<=",">="],N=["*","/","%"],_=["IN","OF","INSTANCEOF"],n=["TRUE","FALSE"],D=["NUMBER","REGEX","BOOL","NULL","UNDEFINED","++","--"],S=D.concat(")","}","THIS","IDENTIFIER","STRING","]"),i=["IDENTIFIER","STRING","REGEX",")","]","}","?","::","@","THIS","SUPER"],k=i.concat("NUMBER","BOOL","NULL","UNDEFINED"),T=["INDENT","OUTDENT","TERMINATOR"]}.call(this),t.exports}(),require["./parser"]=function(){var e={},t={exports:e},n=function(){function e(){this.yy={}}var t={trace:function(){},yy:{},symbols_:{error:2,Root:3,Body:4,Block:5,TERMINATOR:6,Line:7,Expression:8,Statement:9,Return:10,Comment:11,STATEMENT:12,Value:13,Invocation:14,Code:15,Operation:16,Assign:17,If:18,Try:19,While:20,For:21,Switch:22,Class:23,Throw:24,INDENT:25,OUTDENT:26,Identifier:27,IDENTIFIER:28,AlphaNumeric:29,NUMBER:30,STRING:31,Literal:32,JS:33,REGEX:34,DEBUGGER:35,UNDEFINED:36,NULL:37,BOOL:38,Assignable:39,"=":40,AssignObj:41,ObjAssignable:42,":":43,ThisProperty:44,RETURN:45,HERECOMMENT:46,PARAM_START:47,ParamList:48,PARAM_END:49,FuncGlyph:50,"->":51,"=>":52,OptComma:53,",":54,Param:55,ParamVar:56,"...":57,Array:58,Object:59,Splat:60,SimpleAssignable:61,Accessor:62,Parenthetical:63,Range:64,This:65,".":66,"?.":67,"::":68,"?::":69,Index:70,INDEX_START:71,IndexValue:72,INDEX_END:73,INDEX_SOAK:74,Slice:75,"{":76,AssignList:77,"}":78,CLASS:79,EXTENDS:80,OptFuncExist:81,Arguments:82,SUPER:83,FUNC_EXIST:84,CALL_START:85,CALL_END:86,ArgList:87,THIS:88,"@":89,"[":90,"]":91,RangeDots:92,"..":93,Arg:94,SimpleArgs:95,TRY:96,Catch:97,FINALLY:98,CATCH:99,THROW:100,"(":101,")":102,WhileSource:103,WHILE:104,WHEN:105,UNTIL:106,Loop:107,LOOP:108,ForBody:109,FOR:110,ForStart:111,ForSource:112,ForVariables:113,OWN:114,ForValue:115,FORIN:116,FOROF:117,BY:118,SWITCH:119,Whens:120,ELSE:121,When:122,LEADING_WHEN:123,IfBlock:124,IF:125,POST_IF:126,UNARY:127,"-":128,"+":129,"--":130,"++":131,"?":132,MATH:133,SHIFT:134,COMPARE:135,LOGIC:136,RELATION:137,COMPOUND_ASSIGN:138,$accept:0,$end:1},terminals_:{2:"error",6:"TERMINATOR",12:"STATEMENT",25:"INDENT",26:"OUTDENT",28:"IDENTIFIER",30:"NUMBER",31:"STRING",33:"JS",34:"REGEX",35:"DEBUGGER",36:"UNDEFINED",37:"NULL",38:"BOOL",40:"=",43:":",45:"RETURN",46:"HERECOMMENT",47:"PARAM_START",49:"PARAM_END",51:"->",52:"=>",54:",",57:"...",66:".",67:"?.",68:"::",69:"?::",71:"INDEX_START",73:"INDEX_END",74:"INDEX_SOAK",76:"{",78:"}",79:"CLASS",80:"EXTENDS",83:"SUPER",84:"FUNC_EXIST",85:"CALL_START",86:"CALL_END",88:"THIS",89:"@",90:"[",91:"]",93:"..",96:"TRY",98:"FINALLY",99:"CATCH",100:"THROW",101:"(",102:")",104:"WHILE",105:"WHEN",106:"UNTIL",108:"LOOP",110:"FOR",114:"OWN",116:"FORIN",117:"FOROF",118:"BY",119:"SWITCH",121:"ELSE",123:"LEADING_WHEN",125:"IF",126:"POST_IF",127:"UNARY",128:"-",129:"+",130:"--",131:"++",132:"?",133:"MATH",134:"SHIFT",135:"COMPARE",136:"LOGIC",137:"RELATION",138:"COMPOUND_ASSIGN"},productions_:[0,[3,0],[3,1],[3,2],[4,1],[4,3],[4,2],[7,1],[7,1],[9,1],[9,1],[9,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[5,2],[5,3],[27,1],[29,1],[29,1],[32,1],[32,1],[32,1],[32,1],[32,1],[32,1],[32,1],[17,3],[17,4],[17,5],[41,1],[41,3],[41,5],[41,1],[42,1],[42,1],[42,1],[10,2],[10,1],[11,1],[15,5],[15,2],[50,1],[50,1],[53,0],[53,1],[48,0],[48,1],[48,3],[48,4],[48,6],[55,1],[55,2],[55,3],[56,1],[56,1],[56,1],[56,1],[60,2],[61,1],[61,2],[61,2],[61,1],[39,1],[39,1],[39,1],[13,1],[13,1],[13,1],[13,1],[13,1],[62,2],[62,2],[62,2],[62,2],[62,1],[62,1],[70,3],[70,2],[72,1],[72,1],[59,4],[77,0],[77,1],[77,3],[77,4],[77,6],[23,1],[23,2],[23,3],[23,4],[23,2],[23,3],[23,4],[23,5],[14,3],[14,3],[14,1],[14,2],[81,0],[81,1],[82,2],[82,4],[65,1],[65,1],[44,2],[58,2],[58,4],[92,1],[92,1],[64,5],[75,3],[75,2],[75,2],[75,1],[87,1],[87,3],[87,4],[87,4],[87,6],[94,1],[94,1],[95,1],[95,3],[19,2],[19,3],[19,4],[19,5],[97,3],[97,3],[97,2],[24,2],[63,3],[63,5],[103,2],[103,4],[103,2],[103,4],[20,2],[20,2],[20,2],[20,1],[107,2],[107,2],[21,2],[21,2],[21,2],[109,2],[109,2],[111,2],[111,3],[115,1],[115,1],[115,1],[115,1],[113,1],[113,3],[112,2],[112,2],[112,4],[112,4],[112,4],[112,6],[112,6],[22,5],[22,7],[22,4],[22,6],[120,1],[120,2],[122,3],[122,4],[124,3],[124,5],[18,1],[18,3],[18,3],[18,3],[16,2],[16,2],[16,2],[16,2],[16,2],[16,2],[16,2],[16,2],[16,3],[16,3],[16,3],[16,3],[16,3],[16,3],[16,3],[16,3],[16,5],[16,4],[16,3]],performAction:function(e,t,n,i,s,r,o){var a=r.length-1;switch(s){case 1:return this.$=i.addLocationDataFn(o[a],o[a])(new i.Block);case 2:return this.$=r[a];case 3:return this.$=r[a-1];case 4:this.$=i.addLocationDataFn(o[a],o[a])(i.Block.wrap([r[a]]));break;case 5:this.$=i.addLocationDataFn(o[a-2],o[a])(r[a-2].push(r[a]));break;case 6:this.$=r[a-1];break;case 7:this.$=r[a];break;case 8:this.$=r[a];break;case 9:this.$=r[a];break;case 10:this.$=r[a];break;case 11:this.$=i.addLocationDataFn(o[a],o[a])(new i.Literal(r[a]));break;case 12:this.$=r[a];break;case 13:this.$=r[a];break;case 14:this.$=r[a];break;case 15:this.$=r[a];break;case 16:this.$=r[a];break;case 17:this.$=r[a];break;case 18:this.$=r[a];break;case 19:this.$=r[a];break;case 20:this.$=r[a];break;case 21:this.$=r[a];break;case 22:this.$=r[a];break;case 23:this.$=r[a];break;case 24:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Block);break;case 25:this.$=i.addLocationDataFn(o[a-2],o[a])(r[a-1]);break;case 26:this.$=i.addLocationDataFn(o[a],o[a])(new i.Literal(r[a]));break;case 27:this.$=i.addLocationDataFn(o[a],o[a])(new i.Literal(r[a]));break;case 28:this.$=i.addLocationDataFn(o[a],o[a])(new i.Literal(r[a]));break;case 29:this.$=r[a];break;case 30:this.$=i.addLocationDataFn(o[a],o[a])(new i.Literal(r[a]));break;case 31:this.$=i.addLocationDataFn(o[a],o[a])(new i.Literal(r[a]));break;case 32:this.$=i.addLocationDataFn(o[a],o[a])(new i.Literal(r[a]));break;case 33:this.$=i.addLocationDataFn(o[a],o[a])(new i.Undefined);break;case 34:this.$=i.addLocationDataFn(o[a],o[a])(new i.Null);break;case 35:this.$=i.addLocationDataFn(o[a],o[a])(new i.Bool(r[a]));break;case 36:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Assign(r[a-2],r[a]));break;case 37:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.Assign(r[a-3],r[a]));break;case 38:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Assign(r[a-4],r[a-1]));break;case 39:this.$=i.addLocationDataFn(o[a],o[a])(new i.Value(r[a]));break;case 40:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Assign(i.addLocationDataFn(o[a-2])(new i.Value(r[a-2])),r[a],"object"));break;case 41:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Assign(i.addLocationDataFn(o[a-4])(new i.Value(r[a-4])),r[a-1],"object"));break;case 42:this.$=r[a];break;case 43:this.$=r[a];break;case 44:this.$=r[a];break;case 45:this.$=r[a];break;case 46:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Return(r[a]));break;case 47:this.$=i.addLocationDataFn(o[a],o[a])(new i.Return);break;case 48:this.$=i.addLocationDataFn(o[a],o[a])(new i.Comment(r[a]));break;case 49:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Code(r[a-3],r[a],r[a-1]));break;case 50:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Code([],r[a],r[a-1])); +break;case 51:this.$=i.addLocationDataFn(o[a],o[a])("func");break;case 52:this.$=i.addLocationDataFn(o[a],o[a])("boundfunc");break;case 53:this.$=r[a];break;case 54:this.$=r[a];break;case 55:this.$=i.addLocationDataFn(o[a],o[a])([]);break;case 56:this.$=i.addLocationDataFn(o[a],o[a])([r[a]]);break;case 57:this.$=i.addLocationDataFn(o[a-2],o[a])(r[a-2].concat(r[a]));break;case 58:this.$=i.addLocationDataFn(o[a-3],o[a])(r[a-3].concat(r[a]));break;case 59:this.$=i.addLocationDataFn(o[a-5],o[a])(r[a-5].concat(r[a-2]));break;case 60:this.$=i.addLocationDataFn(o[a],o[a])(new i.Param(r[a]));break;case 61:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Param(r[a-1],null,!0));break;case 62:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Param(r[a-2],r[a]));break;case 63:this.$=r[a];break;case 64:this.$=r[a];break;case 65:this.$=r[a];break;case 66:this.$=r[a];break;case 67:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Splat(r[a-1]));break;case 68:this.$=i.addLocationDataFn(o[a],o[a])(new i.Value(r[a]));break;case 69:this.$=i.addLocationDataFn(o[a-1],o[a])(r[a-1].add(r[a]));break;case 70:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Value(r[a-1],[].concat(r[a])));break;case 71:this.$=r[a];break;case 72:this.$=r[a];break;case 73:this.$=i.addLocationDataFn(o[a],o[a])(new i.Value(r[a]));break;case 74:this.$=i.addLocationDataFn(o[a],o[a])(new i.Value(r[a]));break;case 75:this.$=r[a];break;case 76:this.$=i.addLocationDataFn(o[a],o[a])(new i.Value(r[a]));break;case 77:this.$=i.addLocationDataFn(o[a],o[a])(new i.Value(r[a]));break;case 78:this.$=i.addLocationDataFn(o[a],o[a])(new i.Value(r[a]));break;case 79:this.$=r[a];break;case 80:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Access(r[a]));break;case 81:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Access(r[a],"soak"));break;case 82:this.$=i.addLocationDataFn(o[a-1],o[a])([i.addLocationDataFn(o[a-1])(new i.Access(new i.Literal("prototype"))),i.addLocationDataFn(o[a])(new i.Access(r[a]))]);break;case 83:this.$=i.addLocationDataFn(o[a-1],o[a])([i.addLocationDataFn(o[a-1])(new i.Access(new i.Literal("prototype"),"soak")),i.addLocationDataFn(o[a])(new i.Access(r[a]))]);break;case 84:this.$=i.addLocationDataFn(o[a],o[a])(new i.Access(new i.Literal("prototype")));break;case 85:this.$=r[a];break;case 86:this.$=i.addLocationDataFn(o[a-2],o[a])(r[a-1]);break;case 87:this.$=i.addLocationDataFn(o[a-1],o[a])(i.extend(r[a],{soak:!0}));break;case 88:this.$=i.addLocationDataFn(o[a],o[a])(new i.Index(r[a]));break;case 89:this.$=i.addLocationDataFn(o[a],o[a])(new i.Slice(r[a]));break;case 90:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.Obj(r[a-2],r[a-3].generated));break;case 91:this.$=i.addLocationDataFn(o[a],o[a])([]);break;case 92:this.$=i.addLocationDataFn(o[a],o[a])([r[a]]);break;case 93:this.$=i.addLocationDataFn(o[a-2],o[a])(r[a-2].concat(r[a]));break;case 94:this.$=i.addLocationDataFn(o[a-3],o[a])(r[a-3].concat(r[a]));break;case 95:this.$=i.addLocationDataFn(o[a-5],o[a])(r[a-5].concat(r[a-2]));break;case 96:this.$=i.addLocationDataFn(o[a],o[a])(new i.Class);break;case 97:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Class(null,null,r[a]));break;case 98:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Class(null,r[a]));break;case 99:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.Class(null,r[a-1],r[a]));break;case 100:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Class(r[a]));break;case 101:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Class(r[a-1],null,r[a]));break;case 102:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.Class(r[a-2],r[a]));break;case 103:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Class(r[a-3],r[a-1],r[a]));break;case 104:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Call(r[a-2],r[a],r[a-1]));break;case 105:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Call(r[a-2],r[a],r[a-1]));break;case 106:this.$=i.addLocationDataFn(o[a],o[a])(new i.Call("super",[new i.Splat(new i.Literal("arguments"))]));break;case 107:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Call("super",r[a]));break;case 108:this.$=i.addLocationDataFn(o[a],o[a])(!1);break;case 109:this.$=i.addLocationDataFn(o[a],o[a])(!0);break;case 110:this.$=i.addLocationDataFn(o[a-1],o[a])([]);break;case 111:this.$=i.addLocationDataFn(o[a-3],o[a])(r[a-2]);break;case 112:this.$=i.addLocationDataFn(o[a],o[a])(new i.Value(new i.Literal("this")));break;case 113:this.$=i.addLocationDataFn(o[a],o[a])(new i.Value(new i.Literal("this")));break;case 114:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Value(i.addLocationDataFn(o[a-1])(new i.Literal("this")),[i.addLocationDataFn(o[a])(new i.Access(r[a]))],"this"));break;case 115:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Arr([]));break;case 116:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.Arr(r[a-2]));break;case 117:this.$=i.addLocationDataFn(o[a],o[a])("inclusive");break;case 118:this.$=i.addLocationDataFn(o[a],o[a])("exclusive");break;case 119:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Range(r[a-3],r[a-1],r[a-2]));break;case 120:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Range(r[a-2],r[a],r[a-1]));break;case 121:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Range(r[a-1],null,r[a]));break;case 122:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Range(null,r[a],r[a-1]));break;case 123:this.$=i.addLocationDataFn(o[a],o[a])(new i.Range(null,null,r[a]));break;case 124:this.$=i.addLocationDataFn(o[a],o[a])([r[a]]);break;case 125:this.$=i.addLocationDataFn(o[a-2],o[a])(r[a-2].concat(r[a]));break;case 126:this.$=i.addLocationDataFn(o[a-3],o[a])(r[a-3].concat(r[a]));break;case 127:this.$=i.addLocationDataFn(o[a-3],o[a])(r[a-2]);break;case 128:this.$=i.addLocationDataFn(o[a-5],o[a])(r[a-5].concat(r[a-2]));break;case 129:this.$=r[a];break;case 130:this.$=r[a];break;case 131:this.$=r[a];break;case 132:this.$=i.addLocationDataFn(o[a-2],o[a])([].concat(r[a-2],r[a]));break;case 133:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Try(r[a]));break;case 134:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Try(r[a-1],r[a][0],r[a][1]));break;case 135:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.Try(r[a-2],null,null,r[a]));break;case 136:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Try(r[a-3],r[a-2][0],r[a-2][1],r[a]));break;case 137:this.$=i.addLocationDataFn(o[a-2],o[a])([r[a-1],r[a]]);break;case 138:this.$=i.addLocationDataFn(o[a-2],o[a])([i.addLocationDataFn(o[a-1])(new i.Value(r[a-1])),r[a]]);break;case 139:this.$=i.addLocationDataFn(o[a-1],o[a])([null,r[a]]);break;case 140:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Throw(r[a]));break;case 141:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Parens(r[a-1]));break;case 142:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Parens(r[a-2]));break;case 143:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.While(r[a]));break;case 144:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.While(r[a-2],{guard:r[a]}));break;case 145:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.While(r[a],{invert:!0}));break;case 146:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.While(r[a-2],{invert:!0,guard:r[a]}));break;case 147:this.$=i.addLocationDataFn(o[a-1],o[a])(r[a-1].addBody(r[a]));break;case 148:this.$=i.addLocationDataFn(o[a-1],o[a])(r[a].addBody(i.addLocationDataFn(o[a-1])(i.Block.wrap([r[a-1]]))));break;case 149:this.$=i.addLocationDataFn(o[a-1],o[a])(r[a].addBody(i.addLocationDataFn(o[a-1])(i.Block.wrap([r[a-1]]))));break;case 150:this.$=i.addLocationDataFn(o[a],o[a])(r[a]);break;case 151:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.While(i.addLocationDataFn(o[a-1])(new i.Literal("true"))).addBody(r[a]));break;case 152:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.While(i.addLocationDataFn(o[a-1])(new i.Literal("true"))).addBody(i.addLocationDataFn(o[a])(i.Block.wrap([r[a]]))));break;case 153:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.For(r[a-1],r[a]));break;case 154:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.For(r[a-1],r[a]));break;case 155:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.For(r[a],r[a-1]));break;case 156:this.$=i.addLocationDataFn(o[a-1],o[a])({source:i.addLocationDataFn(o[a])(new i.Value(r[a]))});break;case 157:this.$=i.addLocationDataFn(o[a-1],o[a])(function(){return r[a].own=r[a-1].own,r[a].name=r[a-1][0],r[a].index=r[a-1][1],r[a]}());break;case 158:this.$=i.addLocationDataFn(o[a-1],o[a])(r[a]);break;case 159:this.$=i.addLocationDataFn(o[a-2],o[a])(function(){return r[a].own=!0,r[a]}());break;case 160:this.$=r[a];break;case 161:this.$=r[a];break;case 162:this.$=i.addLocationDataFn(o[a],o[a])(new i.Value(r[a]));break;case 163:this.$=i.addLocationDataFn(o[a],o[a])(new i.Value(r[a]));break;case 164:this.$=i.addLocationDataFn(o[a],o[a])([r[a]]);break;case 165:this.$=i.addLocationDataFn(o[a-2],o[a])([r[a-2],r[a]]);break;case 166:this.$=i.addLocationDataFn(o[a-1],o[a])({source:r[a]});break;case 167:this.$=i.addLocationDataFn(o[a-1],o[a])({source:r[a],object:!0});break;case 168:this.$=i.addLocationDataFn(o[a-3],o[a])({source:r[a-2],guard:r[a]});break;case 169:this.$=i.addLocationDataFn(o[a-3],o[a])({source:r[a-2],guard:r[a],object:!0});break;case 170:this.$=i.addLocationDataFn(o[a-3],o[a])({source:r[a-2],step:r[a]});break;case 171:this.$=i.addLocationDataFn(o[a-5],o[a])({source:r[a-4],guard:r[a-2],step:r[a]});break;case 172:this.$=i.addLocationDataFn(o[a-5],o[a])({source:r[a-4],step:r[a-2],guard:r[a]});break;case 173:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Switch(r[a-3],r[a-1]));break;case 174:this.$=i.addLocationDataFn(o[a-6],o[a])(new i.Switch(r[a-5],r[a-3],r[a-1]));break;case 175:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.Switch(null,r[a-1]));break;case 176:this.$=i.addLocationDataFn(o[a-5],o[a])(new i.Switch(null,r[a-3],r[a-1]));break;case 177:this.$=r[a];break;case 178:this.$=i.addLocationDataFn(o[a-1],o[a])(r[a-1].concat(r[a]));break;case 179:this.$=i.addLocationDataFn(o[a-2],o[a])([[r[a-1],r[a]]]);break;case 180:this.$=i.addLocationDataFn(o[a-3],o[a])([[r[a-2],r[a-1]]]);break;case 181:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.If(r[a-1],r[a],{type:r[a-2]}));break;case 182:this.$=i.addLocationDataFn(o[a-4],o[a])(r[a-4].addElse(new i.If(r[a-1],r[a],{type:r[a-2]})));break;case 183:this.$=r[a];break;case 184:this.$=i.addLocationDataFn(o[a-2],o[a])(r[a-2].addElse(r[a]));break;case 185:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.If(r[a],i.addLocationDataFn(o[a-2])(i.Block.wrap([r[a-2]])),{type:r[a-1],statement:!0}));break;case 186:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.If(r[a],i.addLocationDataFn(o[a-2])(i.Block.wrap([r[a-2]])),{type:r[a-1],statement:!0}));break;case 187:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Op(r[a-1],r[a]));break;case 188:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Op("-",r[a]));break;case 189:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Op("+",r[a]));break;case 190:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Op("--",r[a]));break;case 191:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Op("++",r[a]));break;case 192:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Op("--",r[a-1],null,!0));break;case 193:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Op("++",r[a-1],null,!0));break;case 194:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Existence(r[a-1]));break;case 195:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Op("+",r[a-2],r[a]));break;case 196:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Op("-",r[a-2],r[a]));break;case 197:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Op(r[a-1],r[a-2],r[a]));break;case 198:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Op(r[a-1],r[a-2],r[a]));break;case 199:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Op(r[a-1],r[a-2],r[a]));break;case 200:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Op(r[a-1],r[a-2],r[a]));break;case 201:this.$=i.addLocationDataFn(o[a-2],o[a])(function(){return"!"===r[a-1].charAt(0)?new i.Op(r[a-1].slice(1),r[a-2],r[a]).invert():new i.Op(r[a-1],r[a-2],r[a])}());break;case 202:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Assign(r[a-2],r[a],r[a-1]));break;case 203:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Assign(r[a-4],r[a-1],r[a-3]));break;case 204:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.Assign(r[a-3],r[a],r[a-2]));break;case 205:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Extends(r[a-2],r[a]))}},table:[{1:[2,1],3:1,4:2,5:3,7:4,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,5],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[3]},{1:[2,2],6:[1,74]},{6:[1,75]},{1:[2,4],6:[2,4],26:[2,4],102:[2,4]},{4:77,7:4,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,26:[1,76],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,7],6:[2,7],26:[2,7],102:[2,7],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,8],6:[2,8],26:[2,8],102:[2,8],103:90,104:[1,65],106:[1,66],109:91,110:[1,68],111:69,126:[1,89]},{1:[2,12],6:[2,12],25:[2,12],26:[2,12],49:[2,12],54:[2,12],57:[2,12],62:93,66:[1,95],67:[1,96],68:[1,97],69:[1,98],70:99,71:[1,100],73:[2,12],74:[1,101],78:[2,12],81:92,84:[1,94],85:[2,108],86:[2,12],91:[2,12],93:[2,12],102:[2,12],104:[2,12],105:[2,12],106:[2,12],110:[2,12],118:[2,12],126:[2,12],128:[2,12],129:[2,12],132:[2,12],133:[2,12],134:[2,12],135:[2,12],136:[2,12],137:[2,12]},{1:[2,13],6:[2,13],25:[2,13],26:[2,13],49:[2,13],54:[2,13],57:[2,13],62:103,66:[1,95],67:[1,96],68:[1,97],69:[1,98],70:99,71:[1,100],73:[2,13],74:[1,101],78:[2,13],81:102,84:[1,94],85:[2,108],86:[2,13],91:[2,13],93:[2,13],102:[2,13],104:[2,13],105:[2,13],106:[2,13],110:[2,13],118:[2,13],126:[2,13],128:[2,13],129:[2,13],132:[2,13],133:[2,13],134:[2,13],135:[2,13],136:[2,13],137:[2,13]},{1:[2,14],6:[2,14],25:[2,14],26:[2,14],49:[2,14],54:[2,14],57:[2,14],73:[2,14],78:[2,14],86:[2,14],91:[2,14],93:[2,14],102:[2,14],104:[2,14],105:[2,14],106:[2,14],110:[2,14],118:[2,14],126:[2,14],128:[2,14],129:[2,14],132:[2,14],133:[2,14],134:[2,14],135:[2,14],136:[2,14],137:[2,14]},{1:[2,15],6:[2,15],25:[2,15],26:[2,15],49:[2,15],54:[2,15],57:[2,15],73:[2,15],78:[2,15],86:[2,15],91:[2,15],93:[2,15],102:[2,15],104:[2,15],105:[2,15],106:[2,15],110:[2,15],118:[2,15],126:[2,15],128:[2,15],129:[2,15],132:[2,15],133:[2,15],134:[2,15],135:[2,15],136:[2,15],137:[2,15]},{1:[2,16],6:[2,16],25:[2,16],26:[2,16],49:[2,16],54:[2,16],57:[2,16],73:[2,16],78:[2,16],86:[2,16],91:[2,16],93:[2,16],102:[2,16],104:[2,16],105:[2,16],106:[2,16],110:[2,16],118:[2,16],126:[2,16],128:[2,16],129:[2,16],132:[2,16],133:[2,16],134:[2,16],135:[2,16],136:[2,16],137:[2,16]},{1:[2,17],6:[2,17],25:[2,17],26:[2,17],49:[2,17],54:[2,17],57:[2,17],73:[2,17],78:[2,17],86:[2,17],91:[2,17],93:[2,17],102:[2,17],104:[2,17],105:[2,17],106:[2,17],110:[2,17],118:[2,17],126:[2,17],128:[2,17],129:[2,17],132:[2,17],133:[2,17],134:[2,17],135:[2,17],136:[2,17],137:[2,17]},{1:[2,18],6:[2,18],25:[2,18],26:[2,18],49:[2,18],54:[2,18],57:[2,18],73:[2,18],78:[2,18],86:[2,18],91:[2,18],93:[2,18],102:[2,18],104:[2,18],105:[2,18],106:[2,18],110:[2,18],118:[2,18],126:[2,18],128:[2,18],129:[2,18],132:[2,18],133:[2,18],134:[2,18],135:[2,18],136:[2,18],137:[2,18]},{1:[2,19],6:[2,19],25:[2,19],26:[2,19],49:[2,19],54:[2,19],57:[2,19],73:[2,19],78:[2,19],86:[2,19],91:[2,19],93:[2,19],102:[2,19],104:[2,19],105:[2,19],106:[2,19],110:[2,19],118:[2,19],126:[2,19],128:[2,19],129:[2,19],132:[2,19],133:[2,19],134:[2,19],135:[2,19],136:[2,19],137:[2,19]},{1:[2,20],6:[2,20],25:[2,20],26:[2,20],49:[2,20],54:[2,20],57:[2,20],73:[2,20],78:[2,20],86:[2,20],91:[2,20],93:[2,20],102:[2,20],104:[2,20],105:[2,20],106:[2,20],110:[2,20],118:[2,20],126:[2,20],128:[2,20],129:[2,20],132:[2,20],133:[2,20],134:[2,20],135:[2,20],136:[2,20],137:[2,20]},{1:[2,21],6:[2,21],25:[2,21],26:[2,21],49:[2,21],54:[2,21],57:[2,21],73:[2,21],78:[2,21],86:[2,21],91:[2,21],93:[2,21],102:[2,21],104:[2,21],105:[2,21],106:[2,21],110:[2,21],118:[2,21],126:[2,21],128:[2,21],129:[2,21],132:[2,21],133:[2,21],134:[2,21],135:[2,21],136:[2,21],137:[2,21]},{1:[2,22],6:[2,22],25:[2,22],26:[2,22],49:[2,22],54:[2,22],57:[2,22],73:[2,22],78:[2,22],86:[2,22],91:[2,22],93:[2,22],102:[2,22],104:[2,22],105:[2,22],106:[2,22],110:[2,22],118:[2,22],126:[2,22],128:[2,22],129:[2,22],132:[2,22],133:[2,22],134:[2,22],135:[2,22],136:[2,22],137:[2,22]},{1:[2,23],6:[2,23],25:[2,23],26:[2,23],49:[2,23],54:[2,23],57:[2,23],73:[2,23],78:[2,23],86:[2,23],91:[2,23],93:[2,23],102:[2,23],104:[2,23],105:[2,23],106:[2,23],110:[2,23],118:[2,23],126:[2,23],128:[2,23],129:[2,23],132:[2,23],133:[2,23],134:[2,23],135:[2,23],136:[2,23],137:[2,23]},{1:[2,9],6:[2,9],26:[2,9],102:[2,9],104:[2,9],106:[2,9],110:[2,9],126:[2,9]},{1:[2,10],6:[2,10],26:[2,10],102:[2,10],104:[2,10],106:[2,10],110:[2,10],126:[2,10]},{1:[2,11],6:[2,11],26:[2,11],102:[2,11],104:[2,11],106:[2,11],110:[2,11],126:[2,11]},{1:[2,75],6:[2,75],25:[2,75],26:[2,75],40:[1,104],49:[2,75],54:[2,75],57:[2,75],66:[2,75],67:[2,75],68:[2,75],69:[2,75],71:[2,75],73:[2,75],74:[2,75],78:[2,75],84:[2,75],85:[2,75],86:[2,75],91:[2,75],93:[2,75],102:[2,75],104:[2,75],105:[2,75],106:[2,75],110:[2,75],118:[2,75],126:[2,75],128:[2,75],129:[2,75],132:[2,75],133:[2,75],134:[2,75],135:[2,75],136:[2,75],137:[2,75]},{1:[2,76],6:[2,76],25:[2,76],26:[2,76],49:[2,76],54:[2,76],57:[2,76],66:[2,76],67:[2,76],68:[2,76],69:[2,76],71:[2,76],73:[2,76],74:[2,76],78:[2,76],84:[2,76],85:[2,76],86:[2,76],91:[2,76],93:[2,76],102:[2,76],104:[2,76],105:[2,76],106:[2,76],110:[2,76],118:[2,76],126:[2,76],128:[2,76],129:[2,76],132:[2,76],133:[2,76],134:[2,76],135:[2,76],136:[2,76],137:[2,76]},{1:[2,77],6:[2,77],25:[2,77],26:[2,77],49:[2,77],54:[2,77],57:[2,77],66:[2,77],67:[2,77],68:[2,77],69:[2,77],71:[2,77],73:[2,77],74:[2,77],78:[2,77],84:[2,77],85:[2,77],86:[2,77],91:[2,77],93:[2,77],102:[2,77],104:[2,77],105:[2,77],106:[2,77],110:[2,77],118:[2,77],126:[2,77],128:[2,77],129:[2,77],132:[2,77],133:[2,77],134:[2,77],135:[2,77],136:[2,77],137:[2,77]},{1:[2,78],6:[2,78],25:[2,78],26:[2,78],49:[2,78],54:[2,78],57:[2,78],66:[2,78],67:[2,78],68:[2,78],69:[2,78],71:[2,78],73:[2,78],74:[2,78],78:[2,78],84:[2,78],85:[2,78],86:[2,78],91:[2,78],93:[2,78],102:[2,78],104:[2,78],105:[2,78],106:[2,78],110:[2,78],118:[2,78],126:[2,78],128:[2,78],129:[2,78],132:[2,78],133:[2,78],134:[2,78],135:[2,78],136:[2,78],137:[2,78]},{1:[2,79],6:[2,79],25:[2,79],26:[2,79],49:[2,79],54:[2,79],57:[2,79],66:[2,79],67:[2,79],68:[2,79],69:[2,79],71:[2,79],73:[2,79],74:[2,79],78:[2,79],84:[2,79],85:[2,79],86:[2,79],91:[2,79],93:[2,79],102:[2,79],104:[2,79],105:[2,79],106:[2,79],110:[2,79],118:[2,79],126:[2,79],128:[2,79],129:[2,79],132:[2,79],133:[2,79],134:[2,79],135:[2,79],136:[2,79],137:[2,79]},{1:[2,106],6:[2,106],25:[2,106],26:[2,106],49:[2,106],54:[2,106],57:[2,106],66:[2,106],67:[2,106],68:[2,106],69:[2,106],71:[2,106],73:[2,106],74:[2,106],78:[2,106],82:105,84:[2,106],85:[1,106],86:[2,106],91:[2,106],93:[2,106],102:[2,106],104:[2,106],105:[2,106],106:[2,106],110:[2,106],118:[2,106],126:[2,106],128:[2,106],129:[2,106],132:[2,106],133:[2,106],134:[2,106],135:[2,106],136:[2,106],137:[2,106]},{6:[2,55],25:[2,55],27:110,28:[1,73],44:111,48:107,49:[2,55],54:[2,55],55:108,56:109,58:112,59:113,76:[1,70],89:[1,114],90:[1,115]},{5:116,25:[1,5]},{8:117,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:119,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:120,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{13:122,14:123,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:124,44:63,58:47,59:48,61:121,63:25,64:26,65:27,76:[1,70],83:[1,28],88:[1,58],89:[1,59],90:[1,57],101:[1,56]},{13:122,14:123,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:124,44:63,58:47,59:48,61:125,63:25,64:26,65:27,76:[1,70],83:[1,28],88:[1,58],89:[1,59],90:[1,57],101:[1,56]},{1:[2,72],6:[2,72],25:[2,72],26:[2,72],40:[2,72],49:[2,72],54:[2,72],57:[2,72],66:[2,72],67:[2,72],68:[2,72],69:[2,72],71:[2,72],73:[2,72],74:[2,72],78:[2,72],80:[1,129],84:[2,72],85:[2,72],86:[2,72],91:[2,72],93:[2,72],102:[2,72],104:[2,72],105:[2,72],106:[2,72],110:[2,72],118:[2,72],126:[2,72],128:[2,72],129:[2,72],130:[1,126],131:[1,127],132:[2,72],133:[2,72],134:[2,72],135:[2,72],136:[2,72],137:[2,72],138:[1,128]},{1:[2,183],6:[2,183],25:[2,183],26:[2,183],49:[2,183],54:[2,183],57:[2,183],73:[2,183],78:[2,183],86:[2,183],91:[2,183],93:[2,183],102:[2,183],104:[2,183],105:[2,183],106:[2,183],110:[2,183],118:[2,183],121:[1,130],126:[2,183],128:[2,183],129:[2,183],132:[2,183],133:[2,183],134:[2,183],135:[2,183],136:[2,183],137:[2,183]},{5:131,25:[1,5]},{5:132,25:[1,5]},{1:[2,150],6:[2,150],25:[2,150],26:[2,150],49:[2,150],54:[2,150],57:[2,150],73:[2,150],78:[2,150],86:[2,150],91:[2,150],93:[2,150],102:[2,150],104:[2,150],105:[2,150],106:[2,150],110:[2,150],118:[2,150],126:[2,150],128:[2,150],129:[2,150],132:[2,150],133:[2,150],134:[2,150],135:[2,150],136:[2,150],137:[2,150]},{5:133,25:[1,5]},{8:134,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,135],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,96],5:136,6:[2,96],13:122,14:123,25:[1,5],26:[2,96],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:124,44:63,49:[2,96],54:[2,96],57:[2,96],58:47,59:48,61:138,63:25,64:26,65:27,73:[2,96],76:[1,70],78:[2,96],80:[1,137],83:[1,28],86:[2,96],88:[1,58],89:[1,59],90:[1,57],91:[2,96],93:[2,96],101:[1,56],102:[2,96],104:[2,96],105:[2,96],106:[2,96],110:[2,96],118:[2,96],126:[2,96],128:[2,96],129:[2,96],132:[2,96],133:[2,96],134:[2,96],135:[2,96],136:[2,96],137:[2,96]},{8:139,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,47],6:[2,47],8:140,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,26:[2,47],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],102:[2,47],103:39,104:[2,47],106:[2,47],107:40,108:[1,67],109:41,110:[2,47],111:69,119:[1,42],124:37,125:[1,64],126:[2,47],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,48],6:[2,48],25:[2,48],26:[2,48],54:[2,48],78:[2,48],102:[2,48],104:[2,48],106:[2,48],110:[2,48],126:[2,48]},{1:[2,73],6:[2,73],25:[2,73],26:[2,73],40:[2,73],49:[2,73],54:[2,73],57:[2,73],66:[2,73],67:[2,73],68:[2,73],69:[2,73],71:[2,73],73:[2,73],74:[2,73],78:[2,73],84:[2,73],85:[2,73],86:[2,73],91:[2,73],93:[2,73],102:[2,73],104:[2,73],105:[2,73],106:[2,73],110:[2,73],118:[2,73],126:[2,73],128:[2,73],129:[2,73],132:[2,73],133:[2,73],134:[2,73],135:[2,73],136:[2,73],137:[2,73]},{1:[2,74],6:[2,74],25:[2,74],26:[2,74],40:[2,74],49:[2,74],54:[2,74],57:[2,74],66:[2,74],67:[2,74],68:[2,74],69:[2,74],71:[2,74],73:[2,74],74:[2,74],78:[2,74],84:[2,74],85:[2,74],86:[2,74],91:[2,74],93:[2,74],102:[2,74],104:[2,74],105:[2,74],106:[2,74],110:[2,74],118:[2,74],126:[2,74],128:[2,74],129:[2,74],132:[2,74],133:[2,74],134:[2,74],135:[2,74],136:[2,74],137:[2,74]},{1:[2,29],6:[2,29],25:[2,29],26:[2,29],49:[2,29],54:[2,29],57:[2,29],66:[2,29],67:[2,29],68:[2,29],69:[2,29],71:[2,29],73:[2,29],74:[2,29],78:[2,29],84:[2,29],85:[2,29],86:[2,29],91:[2,29],93:[2,29],102:[2,29],104:[2,29],105:[2,29],106:[2,29],110:[2,29],118:[2,29],126:[2,29],128:[2,29],129:[2,29],132:[2,29],133:[2,29],134:[2,29],135:[2,29],136:[2,29],137:[2,29]},{1:[2,30],6:[2,30],25:[2,30],26:[2,30],49:[2,30],54:[2,30],57:[2,30],66:[2,30],67:[2,30],68:[2,30],69:[2,30],71:[2,30],73:[2,30],74:[2,30],78:[2,30],84:[2,30],85:[2,30],86:[2,30],91:[2,30],93:[2,30],102:[2,30],104:[2,30],105:[2,30],106:[2,30],110:[2,30],118:[2,30],126:[2,30],128:[2,30],129:[2,30],132:[2,30],133:[2,30],134:[2,30],135:[2,30],136:[2,30],137:[2,30]},{1:[2,31],6:[2,31],25:[2,31],26:[2,31],49:[2,31],54:[2,31],57:[2,31],66:[2,31],67:[2,31],68:[2,31],69:[2,31],71:[2,31],73:[2,31],74:[2,31],78:[2,31],84:[2,31],85:[2,31],86:[2,31],91:[2,31],93:[2,31],102:[2,31],104:[2,31],105:[2,31],106:[2,31],110:[2,31],118:[2,31],126:[2,31],128:[2,31],129:[2,31],132:[2,31],133:[2,31],134:[2,31],135:[2,31],136:[2,31],137:[2,31]},{1:[2,32],6:[2,32],25:[2,32],26:[2,32],49:[2,32],54:[2,32],57:[2,32],66:[2,32],67:[2,32],68:[2,32],69:[2,32],71:[2,32],73:[2,32],74:[2,32],78:[2,32],84:[2,32],85:[2,32],86:[2,32],91:[2,32],93:[2,32],102:[2,32],104:[2,32],105:[2,32],106:[2,32],110:[2,32],118:[2,32],126:[2,32],128:[2,32],129:[2,32],132:[2,32],133:[2,32],134:[2,32],135:[2,32],136:[2,32],137:[2,32]},{1:[2,33],6:[2,33],25:[2,33],26:[2,33],49:[2,33],54:[2,33],57:[2,33],66:[2,33],67:[2,33],68:[2,33],69:[2,33],71:[2,33],73:[2,33],74:[2,33],78:[2,33],84:[2,33],85:[2,33],86:[2,33],91:[2,33],93:[2,33],102:[2,33],104:[2,33],105:[2,33],106:[2,33],110:[2,33],118:[2,33],126:[2,33],128:[2,33],129:[2,33],132:[2,33],133:[2,33],134:[2,33],135:[2,33],136:[2,33],137:[2,33]},{1:[2,34],6:[2,34],25:[2,34],26:[2,34],49:[2,34],54:[2,34],57:[2,34],66:[2,34],67:[2,34],68:[2,34],69:[2,34],71:[2,34],73:[2,34],74:[2,34],78:[2,34],84:[2,34],85:[2,34],86:[2,34],91:[2,34],93:[2,34],102:[2,34],104:[2,34],105:[2,34],106:[2,34],110:[2,34],118:[2,34],126:[2,34],128:[2,34],129:[2,34],132:[2,34],133:[2,34],134:[2,34],135:[2,34],136:[2,34],137:[2,34]},{1:[2,35],6:[2,35],25:[2,35],26:[2,35],49:[2,35],54:[2,35],57:[2,35],66:[2,35],67:[2,35],68:[2,35],69:[2,35],71:[2,35],73:[2,35],74:[2,35],78:[2,35],84:[2,35],85:[2,35],86:[2,35],91:[2,35],93:[2,35],102:[2,35],104:[2,35],105:[2,35],106:[2,35],110:[2,35],118:[2,35],126:[2,35],128:[2,35],129:[2,35],132:[2,35],133:[2,35],134:[2,35],135:[2,35],136:[2,35],137:[2,35]},{4:141,7:4,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,142],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:143,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,147],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:148,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],87:145,88:[1,58],89:[1,59],90:[1,57],91:[1,144],94:146,96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,112],6:[2,112],25:[2,112],26:[2,112],49:[2,112],54:[2,112],57:[2,112],66:[2,112],67:[2,112],68:[2,112],69:[2,112],71:[2,112],73:[2,112],74:[2,112],78:[2,112],84:[2,112],85:[2,112],86:[2,112],91:[2,112],93:[2,112],102:[2,112],104:[2,112],105:[2,112],106:[2,112],110:[2,112],118:[2,112],126:[2,112],128:[2,112],129:[2,112],132:[2,112],133:[2,112],134:[2,112],135:[2,112],136:[2,112],137:[2,112]},{1:[2,113],6:[2,113],25:[2,113],26:[2,113],27:149,28:[1,73],49:[2,113],54:[2,113],57:[2,113],66:[2,113],67:[2,113],68:[2,113],69:[2,113],71:[2,113],73:[2,113],74:[2,113],78:[2,113],84:[2,113],85:[2,113],86:[2,113],91:[2,113],93:[2,113],102:[2,113],104:[2,113],105:[2,113],106:[2,113],110:[2,113],118:[2,113],126:[2,113],128:[2,113],129:[2,113],132:[2,113],133:[2,113],134:[2,113],135:[2,113],136:[2,113],137:[2,113]},{25:[2,51]},{25:[2,52]},{1:[2,68],6:[2,68],25:[2,68],26:[2,68],40:[2,68],49:[2,68],54:[2,68],57:[2,68],66:[2,68],67:[2,68],68:[2,68],69:[2,68],71:[2,68],73:[2,68],74:[2,68],78:[2,68],80:[2,68],84:[2,68],85:[2,68],86:[2,68],91:[2,68],93:[2,68],102:[2,68],104:[2,68],105:[2,68],106:[2,68],110:[2,68],118:[2,68],126:[2,68],128:[2,68],129:[2,68],130:[2,68],131:[2,68],132:[2,68],133:[2,68],134:[2,68],135:[2,68],136:[2,68],137:[2,68],138:[2,68]},{1:[2,71],6:[2,71],25:[2,71],26:[2,71],40:[2,71],49:[2,71],54:[2,71],57:[2,71],66:[2,71],67:[2,71],68:[2,71],69:[2,71],71:[2,71],73:[2,71],74:[2,71],78:[2,71],80:[2,71],84:[2,71],85:[2,71],86:[2,71],91:[2,71],93:[2,71],102:[2,71],104:[2,71],105:[2,71],106:[2,71],110:[2,71],118:[2,71],126:[2,71],128:[2,71],129:[2,71],130:[2,71],131:[2,71],132:[2,71],133:[2,71],134:[2,71],135:[2,71],136:[2,71],137:[2,71],138:[2,71]},{8:150,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:151,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:152,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{5:153,8:154,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,5],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{27:159,28:[1,73],44:160,58:161,59:162,64:155,76:[1,70],89:[1,114],90:[1,57],113:156,114:[1,157],115:158},{112:163,116:[1,164],117:[1,165]},{6:[2,91],11:169,25:[2,91],27:170,28:[1,73],29:171,30:[1,71],31:[1,72],41:167,42:168,44:172,46:[1,46],54:[2,91],77:166,78:[2,91],89:[1,114]},{1:[2,27],6:[2,27],25:[2,27],26:[2,27],43:[2,27],49:[2,27],54:[2,27],57:[2,27],66:[2,27],67:[2,27],68:[2,27],69:[2,27],71:[2,27],73:[2,27],74:[2,27],78:[2,27],84:[2,27],85:[2,27],86:[2,27],91:[2,27],93:[2,27],102:[2,27],104:[2,27],105:[2,27],106:[2,27],110:[2,27],118:[2,27],126:[2,27],128:[2,27],129:[2,27],132:[2,27],133:[2,27],134:[2,27],135:[2,27],136:[2,27],137:[2,27]},{1:[2,28],6:[2,28],25:[2,28],26:[2,28],43:[2,28],49:[2,28],54:[2,28],57:[2,28],66:[2,28],67:[2,28],68:[2,28],69:[2,28],71:[2,28],73:[2,28],74:[2,28],78:[2,28],84:[2,28],85:[2,28],86:[2,28],91:[2,28],93:[2,28],102:[2,28],104:[2,28],105:[2,28],106:[2,28],110:[2,28],118:[2,28],126:[2,28],128:[2,28],129:[2,28],132:[2,28],133:[2,28],134:[2,28],135:[2,28],136:[2,28],137:[2,28]},{1:[2,26],6:[2,26],25:[2,26],26:[2,26],40:[2,26],43:[2,26],49:[2,26],54:[2,26],57:[2,26],66:[2,26],67:[2,26],68:[2,26],69:[2,26],71:[2,26],73:[2,26],74:[2,26],78:[2,26],80:[2,26],84:[2,26],85:[2,26],86:[2,26],91:[2,26],93:[2,26],102:[2,26],104:[2,26],105:[2,26],106:[2,26],110:[2,26],116:[2,26],117:[2,26],118:[2,26],126:[2,26],128:[2,26],129:[2,26],130:[2,26],131:[2,26],132:[2,26],133:[2,26],134:[2,26],135:[2,26],136:[2,26],137:[2,26],138:[2,26]},{1:[2,6],6:[2,6],7:173,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,26:[2,6],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],102:[2,6],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,3]},{1:[2,24],6:[2,24],25:[2,24],26:[2,24],49:[2,24],54:[2,24],57:[2,24],73:[2,24],78:[2,24],86:[2,24],91:[2,24],93:[2,24],98:[2,24],99:[2,24],102:[2,24],104:[2,24],105:[2,24],106:[2,24],110:[2,24],118:[2,24],121:[2,24],123:[2,24],126:[2,24],128:[2,24],129:[2,24],132:[2,24],133:[2,24],134:[2,24],135:[2,24],136:[2,24],137:[2,24]},{6:[1,74],26:[1,174]},{1:[2,194],6:[2,194],25:[2,194],26:[2,194],49:[2,194],54:[2,194],57:[2,194],73:[2,194],78:[2,194],86:[2,194],91:[2,194],93:[2,194],102:[2,194],104:[2,194],105:[2,194],106:[2,194],110:[2,194],118:[2,194],126:[2,194],128:[2,194],129:[2,194],132:[2,194],133:[2,194],134:[2,194],135:[2,194],136:[2,194],137:[2,194]},{8:175,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:176,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:177,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:178,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:179,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:180,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:181,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:182,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,149],6:[2,149],25:[2,149],26:[2,149],49:[2,149],54:[2,149],57:[2,149],73:[2,149],78:[2,149],86:[2,149],91:[2,149],93:[2,149],102:[2,149],104:[2,149],105:[2,149],106:[2,149],110:[2,149],118:[2,149],126:[2,149],128:[2,149],129:[2,149],132:[2,149],133:[2,149],134:[2,149],135:[2,149],136:[2,149],137:[2,149]},{1:[2,154],6:[2,154],25:[2,154],26:[2,154],49:[2,154],54:[2,154],57:[2,154],73:[2,154],78:[2,154],86:[2,154],91:[2,154],93:[2,154],102:[2,154],104:[2,154],105:[2,154],106:[2,154],110:[2,154],118:[2,154],126:[2,154],128:[2,154],129:[2,154],132:[2,154],133:[2,154],134:[2,154],135:[2,154],136:[2,154],137:[2,154]},{8:183,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,148],6:[2,148],25:[2,148],26:[2,148],49:[2,148],54:[2,148],57:[2,148],73:[2,148],78:[2,148],86:[2,148],91:[2,148],93:[2,148],102:[2,148],104:[2,148],105:[2,148],106:[2,148],110:[2,148],118:[2,148],126:[2,148],128:[2,148],129:[2,148],132:[2,148],133:[2,148],134:[2,148],135:[2,148],136:[2,148],137:[2,148]},{1:[2,153],6:[2,153],25:[2,153],26:[2,153],49:[2,153],54:[2,153],57:[2,153],73:[2,153],78:[2,153],86:[2,153],91:[2,153],93:[2,153],102:[2,153],104:[2,153],105:[2,153],106:[2,153],110:[2,153],118:[2,153],126:[2,153],128:[2,153],129:[2,153],132:[2,153],133:[2,153],134:[2,153],135:[2,153],136:[2,153],137:[2,153]},{82:184,85:[1,106]},{1:[2,69],6:[2,69],25:[2,69],26:[2,69],40:[2,69],49:[2,69],54:[2,69],57:[2,69],66:[2,69],67:[2,69],68:[2,69],69:[2,69],71:[2,69],73:[2,69],74:[2,69],78:[2,69],80:[2,69],84:[2,69],85:[2,69],86:[2,69],91:[2,69],93:[2,69],102:[2,69],104:[2,69],105:[2,69],106:[2,69],110:[2,69],118:[2,69],126:[2,69],128:[2,69],129:[2,69],130:[2,69],131:[2,69],132:[2,69],133:[2,69],134:[2,69],135:[2,69],136:[2,69],137:[2,69],138:[2,69]},{85:[2,109]},{27:185,28:[1,73]},{27:186,28:[1,73]},{1:[2,84],6:[2,84],25:[2,84],26:[2,84],27:187,28:[1,73],40:[2,84],49:[2,84],54:[2,84],57:[2,84],66:[2,84],67:[2,84],68:[2,84],69:[2,84],71:[2,84],73:[2,84],74:[2,84],78:[2,84],80:[2,84],84:[2,84],85:[2,84],86:[2,84],91:[2,84],93:[2,84],102:[2,84],104:[2,84],105:[2,84],106:[2,84],110:[2,84],118:[2,84],126:[2,84],128:[2,84],129:[2,84],130:[2,84],131:[2,84],132:[2,84],133:[2,84],134:[2,84],135:[2,84],136:[2,84],137:[2,84],138:[2,84]},{27:188,28:[1,73]},{1:[2,85],6:[2,85],25:[2,85],26:[2,85],40:[2,85],49:[2,85],54:[2,85],57:[2,85],66:[2,85],67:[2,85],68:[2,85],69:[2,85],71:[2,85],73:[2,85],74:[2,85],78:[2,85],80:[2,85],84:[2,85],85:[2,85],86:[2,85],91:[2,85],93:[2,85],102:[2,85],104:[2,85],105:[2,85],106:[2,85],110:[2,85],118:[2,85],126:[2,85],128:[2,85],129:[2,85],130:[2,85],131:[2,85],132:[2,85],133:[2,85],134:[2,85],135:[2,85],136:[2,85],137:[2,85],138:[2,85]},{8:190,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],57:[1,194],58:47,59:48,61:36,63:25,64:26,65:27,72:189,75:191,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],92:192,93:[1,193],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{70:195,71:[1,100],74:[1,101]},{82:196,85:[1,106]},{1:[2,70],6:[2,70],25:[2,70],26:[2,70],40:[2,70],49:[2,70],54:[2,70],57:[2,70],66:[2,70],67:[2,70],68:[2,70],69:[2,70],71:[2,70],73:[2,70],74:[2,70],78:[2,70],80:[2,70],84:[2,70],85:[2,70],86:[2,70],91:[2,70],93:[2,70],102:[2,70],104:[2,70],105:[2,70],106:[2,70],110:[2,70],118:[2,70],126:[2,70],128:[2,70],129:[2,70],130:[2,70],131:[2,70],132:[2,70],133:[2,70],134:[2,70],135:[2,70],136:[2,70],137:[2,70],138:[2,70]},{6:[1,198],8:197,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,199],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,107],6:[2,107],25:[2,107],26:[2,107],49:[2,107],54:[2,107],57:[2,107],66:[2,107],67:[2,107],68:[2,107],69:[2,107],71:[2,107],73:[2,107],74:[2,107],78:[2,107],84:[2,107],85:[2,107],86:[2,107],91:[2,107],93:[2,107],102:[2,107],104:[2,107],105:[2,107],106:[2,107],110:[2,107],118:[2,107],126:[2,107],128:[2,107],129:[2,107],132:[2,107],133:[2,107],134:[2,107],135:[2,107],136:[2,107],137:[2,107]},{8:202,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,147],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:148,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],86:[1,200],87:201,88:[1,58],89:[1,59],90:[1,57],94:146,96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{6:[2,53],25:[2,53],49:[1,203],53:205,54:[1,204]},{6:[2,56],25:[2,56],26:[2,56],49:[2,56],54:[2,56]},{6:[2,60],25:[2,60],26:[2,60],40:[1,207],49:[2,60],54:[2,60],57:[1,206]},{6:[2,63],25:[2,63],26:[2,63],40:[2,63],49:[2,63],54:[2,63],57:[2,63]},{6:[2,64],25:[2,64],26:[2,64],40:[2,64],49:[2,64],54:[2,64],57:[2,64]},{6:[2,65],25:[2,65],26:[2,65],40:[2,65],49:[2,65],54:[2,65],57:[2,65]},{6:[2,66],25:[2,66],26:[2,66],40:[2,66],49:[2,66],54:[2,66],57:[2,66]},{27:149,28:[1,73]},{8:202,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,147],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:148,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],87:145,88:[1,58],89:[1,59],90:[1,57],91:[1,144],94:146,96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,50],6:[2,50],25:[2,50],26:[2,50],49:[2,50],54:[2,50],57:[2,50],73:[2,50],78:[2,50],86:[2,50],91:[2,50],93:[2,50],102:[2,50],104:[2,50],105:[2,50],106:[2,50],110:[2,50],118:[2,50],126:[2,50],128:[2,50],129:[2,50],132:[2,50],133:[2,50],134:[2,50],135:[2,50],136:[2,50],137:[2,50]},{1:[2,187],6:[2,187],25:[2,187],26:[2,187],49:[2,187],54:[2,187],57:[2,187],73:[2,187],78:[2,187],86:[2,187],91:[2,187],93:[2,187],102:[2,187],103:87,104:[2,187],105:[2,187],106:[2,187],109:88,110:[2,187],111:69,118:[2,187],126:[2,187],128:[2,187],129:[2,187],132:[1,78],133:[2,187],134:[2,187],135:[2,187],136:[2,187],137:[2,187]},{103:90,104:[1,65],106:[1,66],109:91,110:[1,68],111:69,126:[1,89]},{1:[2,188],6:[2,188],25:[2,188],26:[2,188],49:[2,188],54:[2,188],57:[2,188],73:[2,188],78:[2,188],86:[2,188],91:[2,188],93:[2,188],102:[2,188],103:87,104:[2,188],105:[2,188],106:[2,188],109:88,110:[2,188],111:69,118:[2,188],126:[2,188],128:[2,188],129:[2,188],132:[1,78],133:[2,188],134:[2,188],135:[2,188],136:[2,188],137:[2,188]},{1:[2,189],6:[2,189],25:[2,189],26:[2,189],49:[2,189],54:[2,189],57:[2,189],73:[2,189],78:[2,189],86:[2,189],91:[2,189],93:[2,189],102:[2,189],103:87,104:[2,189],105:[2,189],106:[2,189],109:88,110:[2,189],111:69,118:[2,189],126:[2,189],128:[2,189],129:[2,189],132:[1,78],133:[2,189],134:[2,189],135:[2,189],136:[2,189],137:[2,189]},{1:[2,190],6:[2,190],25:[2,190],26:[2,190],49:[2,190],54:[2,190],57:[2,190],66:[2,72],67:[2,72],68:[2,72],69:[2,72],71:[2,72],73:[2,190],74:[2,72],78:[2,190],84:[2,72],85:[2,72],86:[2,190],91:[2,190],93:[2,190],102:[2,190],104:[2,190],105:[2,190],106:[2,190],110:[2,190],118:[2,190],126:[2,190],128:[2,190],129:[2,190],132:[2,190],133:[2,190],134:[2,190],135:[2,190],136:[2,190],137:[2,190]},{62:93,66:[1,95],67:[1,96],68:[1,97],69:[1,98],70:99,71:[1,100],74:[1,101],81:92,84:[1,94],85:[2,108]},{62:103,66:[1,95],67:[1,96],68:[1,97],69:[1,98],70:99,71:[1,100],74:[1,101],81:102,84:[1,94],85:[2,108]},{66:[2,75],67:[2,75],68:[2,75],69:[2,75],71:[2,75],74:[2,75],84:[2,75],85:[2,75]},{1:[2,191],6:[2,191],25:[2,191],26:[2,191],49:[2,191],54:[2,191],57:[2,191],66:[2,72],67:[2,72],68:[2,72],69:[2,72],71:[2,72],73:[2,191],74:[2,72],78:[2,191],84:[2,72],85:[2,72],86:[2,191],91:[2,191],93:[2,191],102:[2,191],104:[2,191],105:[2,191],106:[2,191],110:[2,191],118:[2,191],126:[2,191],128:[2,191],129:[2,191],132:[2,191],133:[2,191],134:[2,191],135:[2,191],136:[2,191],137:[2,191]},{1:[2,192],6:[2,192],25:[2,192],26:[2,192],49:[2,192],54:[2,192],57:[2,192],73:[2,192],78:[2,192],86:[2,192],91:[2,192],93:[2,192],102:[2,192],104:[2,192],105:[2,192],106:[2,192],110:[2,192],118:[2,192],126:[2,192],128:[2,192],129:[2,192],132:[2,192],133:[2,192],134:[2,192],135:[2,192],136:[2,192],137:[2,192]},{1:[2,193],6:[2,193],25:[2,193],26:[2,193],49:[2,193],54:[2,193],57:[2,193],73:[2,193],78:[2,193],86:[2,193],91:[2,193],93:[2,193],102:[2,193],104:[2,193],105:[2,193],106:[2,193],110:[2,193],118:[2,193],126:[2,193],128:[2,193],129:[2,193],132:[2,193],133:[2,193],134:[2,193],135:[2,193],136:[2,193],137:[2,193]},{6:[1,210],8:208,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,209],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:211,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{5:212,25:[1,5],125:[1,213]},{1:[2,133],6:[2,133],25:[2,133],26:[2,133],49:[2,133],54:[2,133],57:[2,133],73:[2,133],78:[2,133],86:[2,133],91:[2,133],93:[2,133],97:214,98:[1,215],99:[1,216],102:[2,133],104:[2,133],105:[2,133],106:[2,133],110:[2,133],118:[2,133],126:[2,133],128:[2,133],129:[2,133],132:[2,133],133:[2,133],134:[2,133],135:[2,133],136:[2,133],137:[2,133]},{1:[2,147],6:[2,147],25:[2,147],26:[2,147],49:[2,147],54:[2,147],57:[2,147],73:[2,147],78:[2,147],86:[2,147],91:[2,147],93:[2,147],102:[2,147],104:[2,147],105:[2,147],106:[2,147],110:[2,147],118:[2,147],126:[2,147],128:[2,147],129:[2,147],132:[2,147],133:[2,147],134:[2,147],135:[2,147],136:[2,147],137:[2,147]},{1:[2,155],6:[2,155],25:[2,155],26:[2,155],49:[2,155],54:[2,155],57:[2,155],73:[2,155],78:[2,155],86:[2,155],91:[2,155],93:[2,155],102:[2,155],104:[2,155],105:[2,155],106:[2,155],110:[2,155],118:[2,155],126:[2,155],128:[2,155],129:[2,155],132:[2,155],133:[2,155],134:[2,155],135:[2,155],136:[2,155],137:[2,155]},{25:[1,217],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{120:218,122:219,123:[1,220]},{1:[2,97],6:[2,97],25:[2,97],26:[2,97],49:[2,97],54:[2,97],57:[2,97],73:[2,97],78:[2,97],86:[2,97],91:[2,97],93:[2,97],102:[2,97],104:[2,97],105:[2,97],106:[2,97],110:[2,97],118:[2,97],126:[2,97],128:[2,97],129:[2,97],132:[2,97],133:[2,97],134:[2,97],135:[2,97],136:[2,97],137:[2,97]},{8:221,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,100],5:222,6:[2,100],25:[1,5],26:[2,100],49:[2,100],54:[2,100],57:[2,100],66:[2,72],67:[2,72],68:[2,72],69:[2,72],71:[2,72],73:[2,100],74:[2,72],78:[2,100],80:[1,223],84:[2,72],85:[2,72],86:[2,100],91:[2,100],93:[2,100],102:[2,100],104:[2,100],105:[2,100],106:[2,100],110:[2,100],118:[2,100],126:[2,100],128:[2,100],129:[2,100],132:[2,100],133:[2,100],134:[2,100],135:[2,100],136:[2,100],137:[2,100]},{1:[2,140],6:[2,140],25:[2,140],26:[2,140],49:[2,140],54:[2,140],57:[2,140],73:[2,140],78:[2,140],86:[2,140],91:[2,140],93:[2,140],102:[2,140],103:87,104:[2,140],105:[2,140],106:[2,140],109:88,110:[2,140],111:69,118:[2,140],126:[2,140],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,46],6:[2,46],26:[2,46],102:[2,46],103:87,104:[2,46],106:[2,46],109:88,110:[2,46],111:69,126:[2,46],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{6:[1,74],102:[1,224]},{4:225,7:4,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{6:[2,129],25:[2,129],54:[2,129],57:[1,227],91:[2,129],92:226,93:[1,193],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,115],6:[2,115],25:[2,115],26:[2,115],40:[2,115],49:[2,115],54:[2,115],57:[2,115],66:[2,115],67:[2,115],68:[2,115],69:[2,115],71:[2,115],73:[2,115],74:[2,115],78:[2,115],84:[2,115],85:[2,115],86:[2,115],91:[2,115],93:[2,115],102:[2,115],104:[2,115],105:[2,115],106:[2,115],110:[2,115],116:[2,115],117:[2,115],118:[2,115],126:[2,115],128:[2,115],129:[2,115],132:[2,115],133:[2,115],134:[2,115],135:[2,115],136:[2,115],137:[2,115]},{6:[2,53],25:[2,53],53:228,54:[1,229],91:[2,53]},{6:[2,124],25:[2,124],26:[2,124],54:[2,124],86:[2,124],91:[2,124]},{8:202,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,147],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:148,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],87:230,88:[1,58],89:[1,59],90:[1,57],94:146,96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{6:[2,130],25:[2,130],26:[2,130],54:[2,130],86:[2,130],91:[2,130]},{1:[2,114],6:[2,114],25:[2,114],26:[2,114],40:[2,114],43:[2,114],49:[2,114],54:[2,114],57:[2,114],66:[2,114],67:[2,114],68:[2,114],69:[2,114],71:[2,114],73:[2,114],74:[2,114],78:[2,114],80:[2,114],84:[2,114],85:[2,114],86:[2,114],91:[2,114],93:[2,114],102:[2,114],104:[2,114],105:[2,114],106:[2,114],110:[2,114],116:[2,114],117:[2,114],118:[2,114],126:[2,114],128:[2,114],129:[2,114],130:[2,114],131:[2,114],132:[2,114],133:[2,114],134:[2,114],135:[2,114],136:[2,114],137:[2,114],138:[2,114]},{5:231,25:[1,5],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,143],6:[2,143],25:[2,143],26:[2,143],49:[2,143],54:[2,143],57:[2,143],73:[2,143],78:[2,143],86:[2,143],91:[2,143],93:[2,143],102:[2,143],103:87,104:[1,65],105:[1,232],106:[1,66],109:88,110:[1,68],111:69,118:[2,143],126:[2,143],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,145],6:[2,145],25:[2,145],26:[2,145],49:[2,145],54:[2,145],57:[2,145],73:[2,145],78:[2,145],86:[2,145],91:[2,145],93:[2,145],102:[2,145],103:87,104:[1,65],105:[1,233],106:[1,66],109:88,110:[1,68],111:69,118:[2,145],126:[2,145],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,151],6:[2,151],25:[2,151],26:[2,151],49:[2,151],54:[2,151],57:[2,151],73:[2,151],78:[2,151],86:[2,151],91:[2,151],93:[2,151],102:[2,151],104:[2,151],105:[2,151],106:[2,151],110:[2,151],118:[2,151],126:[2,151],128:[2,151],129:[2,151],132:[2,151],133:[2,151],134:[2,151],135:[2,151],136:[2,151],137:[2,151]},{1:[2,152],6:[2,152],25:[2,152],26:[2,152],49:[2,152],54:[2,152],57:[2,152],73:[2,152],78:[2,152],86:[2,152],91:[2,152],93:[2,152],102:[2,152],103:87,104:[1,65],105:[2,152],106:[1,66],109:88,110:[1,68],111:69,118:[2,152],126:[2,152],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,156],6:[2,156],25:[2,156],26:[2,156],49:[2,156],54:[2,156],57:[2,156],73:[2,156],78:[2,156],86:[2,156],91:[2,156],93:[2,156],102:[2,156],104:[2,156],105:[2,156],106:[2,156],110:[2,156],118:[2,156],126:[2,156],128:[2,156],129:[2,156],132:[2,156],133:[2,156],134:[2,156],135:[2,156],136:[2,156],137:[2,156]},{116:[2,158],117:[2,158]},{27:159,28:[1,73],44:160,58:161,59:162,76:[1,70],89:[1,114],90:[1,115],113:234,115:158},{54:[1,235],116:[2,164],117:[2,164]},{54:[2,160],116:[2,160],117:[2,160]},{54:[2,161],116:[2,161],117:[2,161]},{54:[2,162],116:[2,162],117:[2,162]},{54:[2,163],116:[2,163],117:[2,163]},{1:[2,157],6:[2,157],25:[2,157],26:[2,157],49:[2,157],54:[2,157],57:[2,157],73:[2,157],78:[2,157],86:[2,157],91:[2,157],93:[2,157],102:[2,157],104:[2,157],105:[2,157],106:[2,157],110:[2,157],118:[2,157],126:[2,157],128:[2,157],129:[2,157],132:[2,157],133:[2,157],134:[2,157],135:[2,157],136:[2,157],137:[2,157]},{8:236,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:237,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{6:[2,53],25:[2,53],53:238,54:[1,239],78:[2,53]},{6:[2,92],25:[2,92],26:[2,92],54:[2,92],78:[2,92]},{6:[2,39],25:[2,39],26:[2,39],43:[1,240],54:[2,39],78:[2,39]},{6:[2,42],25:[2,42],26:[2,42],54:[2,42],78:[2,42]},{6:[2,43],25:[2,43],26:[2,43],43:[2,43],54:[2,43],78:[2,43]},{6:[2,44],25:[2,44],26:[2,44],43:[2,44],54:[2,44],78:[2,44]},{6:[2,45],25:[2,45],26:[2,45],43:[2,45],54:[2,45],78:[2,45]},{1:[2,5],6:[2,5],26:[2,5],102:[2,5]},{1:[2,25],6:[2,25],25:[2,25],26:[2,25],49:[2,25],54:[2,25],57:[2,25],73:[2,25],78:[2,25],86:[2,25],91:[2,25],93:[2,25],98:[2,25],99:[2,25],102:[2,25],104:[2,25],105:[2,25],106:[2,25],110:[2,25],118:[2,25],121:[2,25],123:[2,25],126:[2,25],128:[2,25],129:[2,25],132:[2,25],133:[2,25],134:[2,25],135:[2,25],136:[2,25],137:[2,25]},{1:[2,195],6:[2,195],25:[2,195],26:[2,195],49:[2,195],54:[2,195],57:[2,195],73:[2,195],78:[2,195],86:[2,195],91:[2,195],93:[2,195],102:[2,195],103:87,104:[2,195],105:[2,195],106:[2,195],109:88,110:[2,195],111:69,118:[2,195],126:[2,195],128:[2,195],129:[2,195],132:[1,78],133:[1,81],134:[2,195],135:[2,195],136:[2,195],137:[2,195]},{1:[2,196],6:[2,196],25:[2,196],26:[2,196],49:[2,196],54:[2,196],57:[2,196],73:[2,196],78:[2,196],86:[2,196],91:[2,196],93:[2,196],102:[2,196],103:87,104:[2,196],105:[2,196],106:[2,196],109:88,110:[2,196],111:69,118:[2,196],126:[2,196],128:[2,196],129:[2,196],132:[1,78],133:[1,81],134:[2,196],135:[2,196],136:[2,196],137:[2,196]},{1:[2,197],6:[2,197],25:[2,197],26:[2,197],49:[2,197],54:[2,197],57:[2,197],73:[2,197],78:[2,197],86:[2,197],91:[2,197],93:[2,197],102:[2,197],103:87,104:[2,197],105:[2,197],106:[2,197],109:88,110:[2,197],111:69,118:[2,197],126:[2,197],128:[2,197],129:[2,197],132:[1,78],133:[2,197],134:[2,197],135:[2,197],136:[2,197],137:[2,197]},{1:[2,198],6:[2,198],25:[2,198],26:[2,198],49:[2,198],54:[2,198],57:[2,198],73:[2,198],78:[2,198],86:[2,198],91:[2,198],93:[2,198],102:[2,198],103:87,104:[2,198],105:[2,198],106:[2,198],109:88,110:[2,198],111:69,118:[2,198],126:[2,198],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[2,198],135:[2,198],136:[2,198],137:[2,198]},{1:[2,199],6:[2,199],25:[2,199],26:[2,199],49:[2,199],54:[2,199],57:[2,199],73:[2,199],78:[2,199],86:[2,199],91:[2,199],93:[2,199],102:[2,199],103:87,104:[2,199],105:[2,199],106:[2,199],109:88,110:[2,199],111:69,118:[2,199],126:[2,199],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[2,199],136:[2,199],137:[1,85]},{1:[2,200],6:[2,200],25:[2,200],26:[2,200],49:[2,200],54:[2,200],57:[2,200],73:[2,200],78:[2,200],86:[2,200],91:[2,200],93:[2,200],102:[2,200],103:87,104:[2,200],105:[2,200],106:[2,200],109:88,110:[2,200],111:69,118:[2,200],126:[2,200],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[2,200],137:[1,85]},{1:[2,201],6:[2,201],25:[2,201],26:[2,201],49:[2,201],54:[2,201],57:[2,201],73:[2,201],78:[2,201],86:[2,201],91:[2,201],93:[2,201],102:[2,201],103:87,104:[2,201],105:[2,201],106:[2,201],109:88,110:[2,201],111:69,118:[2,201],126:[2,201],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[2,201],136:[2,201],137:[2,201]},{1:[2,186],6:[2,186],25:[2,186],26:[2,186],49:[2,186],54:[2,186],57:[2,186],73:[2,186],78:[2,186],86:[2,186],91:[2,186],93:[2,186],102:[2,186],103:87,104:[1,65],105:[2,186],106:[1,66],109:88,110:[1,68],111:69,118:[2,186],126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,185],6:[2,185],25:[2,185],26:[2,185],49:[2,185],54:[2,185],57:[2,185],73:[2,185],78:[2,185],86:[2,185],91:[2,185],93:[2,185],102:[2,185],103:87,104:[1,65],105:[2,185],106:[1,66],109:88,110:[1,68],111:69,118:[2,185],126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,104],6:[2,104],25:[2,104],26:[2,104],49:[2,104],54:[2,104],57:[2,104],66:[2,104],67:[2,104],68:[2,104],69:[2,104],71:[2,104],73:[2,104],74:[2,104],78:[2,104],84:[2,104],85:[2,104],86:[2,104],91:[2,104],93:[2,104],102:[2,104],104:[2,104],105:[2,104],106:[2,104],110:[2,104],118:[2,104],126:[2,104],128:[2,104],129:[2,104],132:[2,104],133:[2,104],134:[2,104],135:[2,104],136:[2,104],137:[2,104]},{1:[2,80],6:[2,80],25:[2,80],26:[2,80],40:[2,80],49:[2,80],54:[2,80],57:[2,80],66:[2,80],67:[2,80],68:[2,80],69:[2,80],71:[2,80],73:[2,80],74:[2,80],78:[2,80],80:[2,80],84:[2,80],85:[2,80],86:[2,80],91:[2,80],93:[2,80],102:[2,80],104:[2,80],105:[2,80],106:[2,80],110:[2,80],118:[2,80],126:[2,80],128:[2,80],129:[2,80],130:[2,80],131:[2,80],132:[2,80],133:[2,80],134:[2,80],135:[2,80],136:[2,80],137:[2,80],138:[2,80]},{1:[2,81],6:[2,81],25:[2,81],26:[2,81],40:[2,81],49:[2,81],54:[2,81],57:[2,81],66:[2,81],67:[2,81],68:[2,81],69:[2,81],71:[2,81],73:[2,81],74:[2,81],78:[2,81],80:[2,81],84:[2,81],85:[2,81],86:[2,81],91:[2,81],93:[2,81],102:[2,81],104:[2,81],105:[2,81],106:[2,81],110:[2,81],118:[2,81],126:[2,81],128:[2,81],129:[2,81],130:[2,81],131:[2,81],132:[2,81],133:[2,81],134:[2,81],135:[2,81],136:[2,81],137:[2,81],138:[2,81]},{1:[2,82],6:[2,82],25:[2,82],26:[2,82],40:[2,82],49:[2,82],54:[2,82],57:[2,82],66:[2,82],67:[2,82],68:[2,82],69:[2,82],71:[2,82],73:[2,82],74:[2,82],78:[2,82],80:[2,82],84:[2,82],85:[2,82],86:[2,82],91:[2,82],93:[2,82],102:[2,82],104:[2,82],105:[2,82],106:[2,82],110:[2,82],118:[2,82],126:[2,82],128:[2,82],129:[2,82],130:[2,82],131:[2,82],132:[2,82],133:[2,82],134:[2,82],135:[2,82],136:[2,82],137:[2,82],138:[2,82]},{1:[2,83],6:[2,83],25:[2,83],26:[2,83],40:[2,83],49:[2,83],54:[2,83],57:[2,83],66:[2,83],67:[2,83],68:[2,83],69:[2,83],71:[2,83],73:[2,83],74:[2,83],78:[2,83],80:[2,83],84:[2,83],85:[2,83],86:[2,83],91:[2,83],93:[2,83],102:[2,83],104:[2,83],105:[2,83],106:[2,83],110:[2,83],118:[2,83],126:[2,83],128:[2,83],129:[2,83],130:[2,83],131:[2,83],132:[2,83],133:[2,83],134:[2,83],135:[2,83],136:[2,83],137:[2,83],138:[2,83]},{73:[1,241]},{57:[1,194],73:[2,88],92:242,93:[1,193],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{73:[2,89]},{8:243,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,73:[2,123],76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{12:[2,117],28:[2,117],30:[2,117],31:[2,117],33:[2,117],34:[2,117],35:[2,117],36:[2,117],37:[2,117],38:[2,117],45:[2,117],46:[2,117],47:[2,117],51:[2,117],52:[2,117],73:[2,117],76:[2,117],79:[2,117],83:[2,117],88:[2,117],89:[2,117],90:[2,117],96:[2,117],100:[2,117],101:[2,117],104:[2,117],106:[2,117],108:[2,117],110:[2,117],119:[2,117],125:[2,117],127:[2,117],128:[2,117],129:[2,117],130:[2,117],131:[2,117]},{12:[2,118],28:[2,118],30:[2,118],31:[2,118],33:[2,118],34:[2,118],35:[2,118],36:[2,118],37:[2,118],38:[2,118],45:[2,118],46:[2,118],47:[2,118],51:[2,118],52:[2,118],73:[2,118],76:[2,118],79:[2,118],83:[2,118],88:[2,118],89:[2,118],90:[2,118],96:[2,118],100:[2,118],101:[2,118],104:[2,118],106:[2,118],108:[2,118],110:[2,118],119:[2,118],125:[2,118],127:[2,118],128:[2,118],129:[2,118],130:[2,118],131:[2,118]},{1:[2,87],6:[2,87],25:[2,87],26:[2,87],40:[2,87],49:[2,87],54:[2,87],57:[2,87],66:[2,87],67:[2,87],68:[2,87],69:[2,87],71:[2,87],73:[2,87],74:[2,87],78:[2,87],80:[2,87],84:[2,87],85:[2,87],86:[2,87],91:[2,87],93:[2,87],102:[2,87],104:[2,87],105:[2,87],106:[2,87],110:[2,87],118:[2,87],126:[2,87],128:[2,87],129:[2,87],130:[2,87],131:[2,87],132:[2,87],133:[2,87],134:[2,87],135:[2,87],136:[2,87],137:[2,87],138:[2,87]},{1:[2,105],6:[2,105],25:[2,105],26:[2,105],49:[2,105],54:[2,105],57:[2,105],66:[2,105],67:[2,105],68:[2,105],69:[2,105],71:[2,105],73:[2,105],74:[2,105],78:[2,105],84:[2,105],85:[2,105],86:[2,105],91:[2,105],93:[2,105],102:[2,105],104:[2,105],105:[2,105],106:[2,105],110:[2,105],118:[2,105],126:[2,105],128:[2,105],129:[2,105],132:[2,105],133:[2,105],134:[2,105],135:[2,105],136:[2,105],137:[2,105]},{1:[2,36],6:[2,36],25:[2,36],26:[2,36],49:[2,36],54:[2,36],57:[2,36],73:[2,36],78:[2,36],86:[2,36],91:[2,36],93:[2,36],102:[2,36],103:87,104:[2,36],105:[2,36],106:[2,36],109:88,110:[2,36],111:69,118:[2,36],126:[2,36],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{8:244,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:245,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,110],6:[2,110],25:[2,110],26:[2,110],49:[2,110],54:[2,110],57:[2,110],66:[2,110],67:[2,110],68:[2,110],69:[2,110],71:[2,110],73:[2,110],74:[2,110],78:[2,110],84:[2,110],85:[2,110],86:[2,110],91:[2,110],93:[2,110],102:[2,110],104:[2,110],105:[2,110],106:[2,110],110:[2,110],118:[2,110],126:[2,110],128:[2,110],129:[2,110],132:[2,110],133:[2,110],134:[2,110],135:[2,110],136:[2,110],137:[2,110]},{6:[2,53],25:[2,53],53:246,54:[1,229],86:[2,53]},{6:[2,129],25:[2,129],26:[2,129],54:[2,129],57:[1,247],86:[2,129],91:[2,129],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{50:248,51:[1,60],52:[1,61]},{6:[2,54],25:[2,54],26:[2,54],27:110,28:[1,73],44:111,55:249,56:109,58:112,59:113,76:[1,70],89:[1,114],90:[1,115]},{6:[1,250],25:[1,251]},{6:[2,61],25:[2,61],26:[2,61],49:[2,61],54:[2,61]},{8:252,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,202],6:[2,202],25:[2,202],26:[2,202],49:[2,202],54:[2,202],57:[2,202],73:[2,202],78:[2,202],86:[2,202],91:[2,202],93:[2,202],102:[2,202],103:87,104:[2,202],105:[2,202],106:[2,202],109:88,110:[2,202],111:69,118:[2,202],126:[2,202],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{8:253,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:254,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,205],6:[2,205],25:[2,205],26:[2,205],49:[2,205],54:[2,205],57:[2,205],73:[2,205],78:[2,205],86:[2,205],91:[2,205],93:[2,205],102:[2,205],103:87,104:[2,205],105:[2,205],106:[2,205],109:88,110:[2,205],111:69,118:[2,205],126:[2,205],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,184],6:[2,184],25:[2,184],26:[2,184],49:[2,184],54:[2,184],57:[2,184],73:[2,184],78:[2,184],86:[2,184],91:[2,184],93:[2,184],102:[2,184],104:[2,184],105:[2,184],106:[2,184],110:[2,184],118:[2,184],126:[2,184],128:[2,184],129:[2,184],132:[2,184],133:[2,184],134:[2,184],135:[2,184],136:[2,184],137:[2,184]},{8:255,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,134],6:[2,134],25:[2,134],26:[2,134],49:[2,134],54:[2,134],57:[2,134],73:[2,134],78:[2,134],86:[2,134],91:[2,134],93:[2,134],98:[1,256],102:[2,134],104:[2,134],105:[2,134],106:[2,134],110:[2,134],118:[2,134],126:[2,134],128:[2,134],129:[2,134],132:[2,134],133:[2,134],134:[2,134],135:[2,134],136:[2,134],137:[2,134]},{5:257,25:[1,5]},{5:260,25:[1,5],27:258,28:[1,73],59:259,76:[1,70]},{120:261,122:219,123:[1,220]},{26:[1,262],121:[1,263],122:264,123:[1,220]},{26:[2,177],121:[2,177],123:[2,177]},{8:266,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],95:265,96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,98],5:267,6:[2,98],25:[1,5],26:[2,98],49:[2,98],54:[2,98],57:[2,98],73:[2,98],78:[2,98],86:[2,98],91:[2,98],93:[2,98],102:[2,98],103:87,104:[1,65],105:[2,98],106:[1,66],109:88,110:[1,68],111:69,118:[2,98],126:[2,98],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,101],6:[2,101],25:[2,101],26:[2,101],49:[2,101],54:[2,101],57:[2,101],73:[2,101],78:[2,101],86:[2,101],91:[2,101],93:[2,101],102:[2,101],104:[2,101],105:[2,101],106:[2,101],110:[2,101],118:[2,101],126:[2,101],128:[2,101],129:[2,101],132:[2,101],133:[2,101],134:[2,101],135:[2,101],136:[2,101],137:[2,101]},{8:268,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,141],6:[2,141],25:[2,141],26:[2,141],49:[2,141],54:[2,141],57:[2,141],66:[2,141],67:[2,141],68:[2,141],69:[2,141],71:[2,141],73:[2,141],74:[2,141],78:[2,141],84:[2,141],85:[2,141],86:[2,141],91:[2,141],93:[2,141],102:[2,141],104:[2,141],105:[2,141],106:[2,141],110:[2,141],118:[2,141],126:[2,141],128:[2,141],129:[2,141],132:[2,141],133:[2,141],134:[2,141],135:[2,141],136:[2,141],137:[2,141]},{6:[1,74],26:[1,269]},{8:270,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{6:[2,67],12:[2,118],25:[2,67],28:[2,118],30:[2,118],31:[2,118],33:[2,118],34:[2,118],35:[2,118],36:[2,118],37:[2,118],38:[2,118],45:[2,118],46:[2,118],47:[2,118],51:[2,118],52:[2,118],54:[2,67],76:[2,118],79:[2,118],83:[2,118],88:[2,118],89:[2,118],90:[2,118],91:[2,67],96:[2,118],100:[2,118],101:[2,118],104:[2,118],106:[2,118],108:[2,118],110:[2,118],119:[2,118],125:[2,118],127:[2,118],128:[2,118],129:[2,118],130:[2,118],131:[2,118]},{6:[1,272],25:[1,273],91:[1,271]},{6:[2,54],8:202,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[2,54],26:[2,54],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:148,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],86:[2,54],88:[1,58],89:[1,59],90:[1,57],91:[2,54],94:274,96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{6:[2,53],25:[2,53],26:[2,53],53:275,54:[1,229]},{1:[2,181],6:[2,181],25:[2,181],26:[2,181],49:[2,181],54:[2,181],57:[2,181],73:[2,181],78:[2,181],86:[2,181],91:[2,181],93:[2,181],102:[2,181],104:[2,181],105:[2,181],106:[2,181],110:[2,181],118:[2,181],121:[2,181],126:[2,181],128:[2,181],129:[2,181],132:[2,181],133:[2,181],134:[2,181],135:[2,181],136:[2,181],137:[2,181]},{8:276,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:277,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{116:[2,159],117:[2,159]},{27:159,28:[1,73],44:160,58:161,59:162,76:[1,70],89:[1,114],90:[1,115],115:278},{1:[2,166],6:[2,166],25:[2,166],26:[2,166],49:[2,166],54:[2,166],57:[2,166],73:[2,166],78:[2,166],86:[2,166],91:[2,166],93:[2,166],102:[2,166],103:87,104:[2,166],105:[1,279],106:[2,166],109:88,110:[2,166],111:69,118:[1,280],126:[2,166],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,167],6:[2,167],25:[2,167],26:[2,167],49:[2,167],54:[2,167],57:[2,167],73:[2,167],78:[2,167],86:[2,167],91:[2,167],93:[2,167],102:[2,167],103:87,104:[2,167],105:[1,281],106:[2,167],109:88,110:[2,167],111:69,118:[2,167],126:[2,167],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{6:[1,283],25:[1,284],78:[1,282]},{6:[2,54],11:169,25:[2,54],26:[2,54],27:170,28:[1,73],29:171,30:[1,71],31:[1,72],41:285,42:168,44:172,46:[1,46],78:[2,54],89:[1,114]},{8:286,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,287],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,86],6:[2,86],25:[2,86],26:[2,86],40:[2,86],49:[2,86],54:[2,86],57:[2,86],66:[2,86],67:[2,86],68:[2,86],69:[2,86],71:[2,86],73:[2,86],74:[2,86],78:[2,86],80:[2,86],84:[2,86],85:[2,86],86:[2,86],91:[2,86],93:[2,86],102:[2,86],104:[2,86],105:[2,86],106:[2,86],110:[2,86],118:[2,86],126:[2,86],128:[2,86],129:[2,86],130:[2,86],131:[2,86],132:[2,86],133:[2,86],134:[2,86],135:[2,86],136:[2,86],137:[2,86],138:[2,86]},{8:288,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,73:[2,121],76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{73:[2,122],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,37],6:[2,37],25:[2,37],26:[2,37],49:[2,37],54:[2,37],57:[2,37],73:[2,37],78:[2,37],86:[2,37],91:[2,37],93:[2,37],102:[2,37],103:87,104:[2,37],105:[2,37],106:[2,37],109:88,110:[2,37],111:69,118:[2,37],126:[2,37],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{26:[1,289],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{6:[1,272],25:[1,273],86:[1,290]},{6:[2,67],25:[2,67],26:[2,67],54:[2,67],86:[2,67],91:[2,67]},{5:291,25:[1,5]},{6:[2,57],25:[2,57],26:[2,57],49:[2,57],54:[2,57]},{27:110,28:[1,73],44:111,55:292,56:109,58:112,59:113,76:[1,70],89:[1,114],90:[1,115]},{6:[2,55],25:[2,55],26:[2,55],27:110,28:[1,73],44:111,48:293,54:[2,55],55:108,56:109,58:112,59:113,76:[1,70],89:[1,114],90:[1,115]},{6:[2,62],25:[2,62],26:[2,62],49:[2,62],54:[2,62],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{26:[1,294],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,204],6:[2,204],25:[2,204],26:[2,204],49:[2,204],54:[2,204],57:[2,204],73:[2,204],78:[2,204],86:[2,204],91:[2,204],93:[2,204],102:[2,204],103:87,104:[2,204],105:[2,204],106:[2,204],109:88,110:[2,204],111:69,118:[2,204],126:[2,204],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{5:295,25:[1,5],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{5:296,25:[1,5]},{1:[2,135],6:[2,135],25:[2,135],26:[2,135],49:[2,135],54:[2,135],57:[2,135],73:[2,135],78:[2,135],86:[2,135],91:[2,135],93:[2,135],102:[2,135],104:[2,135],105:[2,135],106:[2,135],110:[2,135],118:[2,135],126:[2,135],128:[2,135],129:[2,135],132:[2,135],133:[2,135],134:[2,135],135:[2,135],136:[2,135],137:[2,135]},{5:297,25:[1,5]},{5:298,25:[1,5]},{1:[2,139],6:[2,139],25:[2,139],26:[2,139],49:[2,139],54:[2,139],57:[2,139],73:[2,139],78:[2,139],86:[2,139],91:[2,139],93:[2,139],98:[2,139],102:[2,139],104:[2,139],105:[2,139],106:[2,139],110:[2,139],118:[2,139],126:[2,139],128:[2,139],129:[2,139],132:[2,139],133:[2,139],134:[2,139],135:[2,139],136:[2,139],137:[2,139]},{26:[1,299],121:[1,300],122:264,123:[1,220]},{1:[2,175],6:[2,175],25:[2,175],26:[2,175],49:[2,175],54:[2,175],57:[2,175],73:[2,175],78:[2,175],86:[2,175],91:[2,175],93:[2,175],102:[2,175],104:[2,175],105:[2,175],106:[2,175],110:[2,175],118:[2,175],126:[2,175],128:[2,175],129:[2,175],132:[2,175],133:[2,175],134:[2,175],135:[2,175],136:[2,175],137:[2,175]},{5:301,25:[1,5]},{26:[2,178],121:[2,178],123:[2,178]},{5:302,25:[1,5],54:[1,303]},{25:[2,131],54:[2,131],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,99],6:[2,99],25:[2,99],26:[2,99],49:[2,99],54:[2,99],57:[2,99],73:[2,99],78:[2,99],86:[2,99],91:[2,99],93:[2,99],102:[2,99],104:[2,99],105:[2,99],106:[2,99],110:[2,99],118:[2,99],126:[2,99],128:[2,99],129:[2,99],132:[2,99],133:[2,99],134:[2,99],135:[2,99],136:[2,99],137:[2,99]},{1:[2,102],5:304,6:[2,102],25:[1,5],26:[2,102],49:[2,102],54:[2,102],57:[2,102],73:[2,102],78:[2,102],86:[2,102],91:[2,102],93:[2,102],102:[2,102],103:87,104:[1,65],105:[2,102],106:[1,66],109:88,110:[1,68],111:69,118:[2,102],126:[2,102],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{102:[1,305]},{91:[1,306],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,116],6:[2,116],25:[2,116],26:[2,116],40:[2,116],49:[2,116],54:[2,116],57:[2,116],66:[2,116],67:[2,116],68:[2,116],69:[2,116],71:[2,116],73:[2,116],74:[2,116],78:[2,116],84:[2,116],85:[2,116],86:[2,116],91:[2,116],93:[2,116],102:[2,116],104:[2,116],105:[2,116],106:[2,116],110:[2,116],116:[2,116],117:[2,116],118:[2,116],126:[2,116],128:[2,116],129:[2,116],132:[2,116],133:[2,116],134:[2,116],135:[2,116],136:[2,116],137:[2,116]},{8:202,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:148,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],94:307,96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:202,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,147],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:148,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],87:308,88:[1,58],89:[1,59],90:[1,57],94:146,96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{6:[2,125],25:[2,125],26:[2,125],54:[2,125],86:[2,125],91:[2,125]},{6:[1,272],25:[1,273],26:[1,309]},{1:[2,144],6:[2,144],25:[2,144],26:[2,144],49:[2,144],54:[2,144],57:[2,144],73:[2,144],78:[2,144],86:[2,144],91:[2,144],93:[2,144],102:[2,144],103:87,104:[1,65],105:[2,144],106:[1,66],109:88,110:[1,68],111:69,118:[2,144],126:[2,144],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,146],6:[2,146],25:[2,146],26:[2,146],49:[2,146],54:[2,146],57:[2,146],73:[2,146],78:[2,146],86:[2,146],91:[2,146],93:[2,146],102:[2,146],103:87,104:[1,65],105:[2,146],106:[1,66],109:88,110:[1,68],111:69,118:[2,146],126:[2,146],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{116:[2,165],117:[2,165]},{8:310,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:311,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:312,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,90],6:[2,90],25:[2,90],26:[2,90],40:[2,90],49:[2,90],54:[2,90],57:[2,90],66:[2,90],67:[2,90],68:[2,90],69:[2,90],71:[2,90],73:[2,90],74:[2,90],78:[2,90],84:[2,90],85:[2,90],86:[2,90],91:[2,90],93:[2,90],102:[2,90],104:[2,90],105:[2,90],106:[2,90],110:[2,90],116:[2,90],117:[2,90],118:[2,90],126:[2,90],128:[2,90],129:[2,90],132:[2,90],133:[2,90],134:[2,90],135:[2,90],136:[2,90],137:[2,90]},{11:169,27:170,28:[1,73],29:171,30:[1,71],31:[1,72],41:313,42:168,44:172,46:[1,46],89:[1,114]},{6:[2,91],11:169,25:[2,91],26:[2,91],27:170,28:[1,73],29:171,30:[1,71],31:[1,72],41:167,42:168,44:172,46:[1,46],54:[2,91],77:314,89:[1,114]},{6:[2,93],25:[2,93],26:[2,93],54:[2,93],78:[2,93]},{6:[2,40],25:[2,40],26:[2,40],54:[2,40],78:[2,40],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{8:315,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{73:[2,120],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,38],6:[2,38],25:[2,38],26:[2,38],49:[2,38],54:[2,38],57:[2,38],73:[2,38],78:[2,38],86:[2,38],91:[2,38],93:[2,38],102:[2,38],104:[2,38],105:[2,38],106:[2,38],110:[2,38],118:[2,38],126:[2,38],128:[2,38],129:[2,38],132:[2,38],133:[2,38],134:[2,38],135:[2,38],136:[2,38],137:[2,38]},{1:[2,111],6:[2,111],25:[2,111],26:[2,111],49:[2,111],54:[2,111],57:[2,111],66:[2,111],67:[2,111],68:[2,111],69:[2,111],71:[2,111],73:[2,111],74:[2,111],78:[2,111],84:[2,111],85:[2,111],86:[2,111],91:[2,111],93:[2,111],102:[2,111],104:[2,111],105:[2,111],106:[2,111],110:[2,111],118:[2,111],126:[2,111],128:[2,111],129:[2,111],132:[2,111],133:[2,111],134:[2,111],135:[2,111],136:[2,111],137:[2,111]},{1:[2,49],6:[2,49],25:[2,49],26:[2,49],49:[2,49],54:[2,49],57:[2,49],73:[2,49],78:[2,49],86:[2,49],91:[2,49],93:[2,49],102:[2,49],104:[2,49],105:[2,49],106:[2,49],110:[2,49],118:[2,49],126:[2,49],128:[2,49],129:[2,49],132:[2,49],133:[2,49],134:[2,49],135:[2,49],136:[2,49],137:[2,49]},{6:[2,58],25:[2,58],26:[2,58],49:[2,58],54:[2,58]},{6:[2,53],25:[2,53],26:[2,53],53:316,54:[1,204]},{1:[2,203],6:[2,203],25:[2,203],26:[2,203],49:[2,203],54:[2,203],57:[2,203],73:[2,203],78:[2,203],86:[2,203],91:[2,203],93:[2,203],102:[2,203],104:[2,203],105:[2,203],106:[2,203],110:[2,203],118:[2,203],126:[2,203],128:[2,203],129:[2,203],132:[2,203],133:[2,203],134:[2,203],135:[2,203],136:[2,203],137:[2,203]},{1:[2,182],6:[2,182],25:[2,182],26:[2,182],49:[2,182],54:[2,182],57:[2,182],73:[2,182],78:[2,182],86:[2,182],91:[2,182],93:[2,182],102:[2,182],104:[2,182],105:[2,182],106:[2,182],110:[2,182],118:[2,182],121:[2,182],126:[2,182],128:[2,182],129:[2,182],132:[2,182],133:[2,182],134:[2,182],135:[2,182],136:[2,182],137:[2,182]},{1:[2,136],6:[2,136],25:[2,136],26:[2,136],49:[2,136],54:[2,136],57:[2,136],73:[2,136],78:[2,136],86:[2,136],91:[2,136],93:[2,136],102:[2,136],104:[2,136],105:[2,136],106:[2,136],110:[2,136],118:[2,136],126:[2,136],128:[2,136],129:[2,136],132:[2,136],133:[2,136],134:[2,136],135:[2,136],136:[2,136],137:[2,136]},{1:[2,137],6:[2,137],25:[2,137],26:[2,137],49:[2,137],54:[2,137],57:[2,137],73:[2,137],78:[2,137],86:[2,137],91:[2,137],93:[2,137],98:[2,137],102:[2,137],104:[2,137],105:[2,137],106:[2,137],110:[2,137],118:[2,137],126:[2,137],128:[2,137],129:[2,137],132:[2,137],133:[2,137],134:[2,137],135:[2,137],136:[2,137],137:[2,137]},{1:[2,138],6:[2,138],25:[2,138],26:[2,138],49:[2,138],54:[2,138],57:[2,138],73:[2,138],78:[2,138],86:[2,138],91:[2,138],93:[2,138],98:[2,138],102:[2,138],104:[2,138],105:[2,138],106:[2,138],110:[2,138],118:[2,138],126:[2,138],128:[2,138],129:[2,138],132:[2,138],133:[2,138],134:[2,138],135:[2,138],136:[2,138],137:[2,138]},{1:[2,173],6:[2,173],25:[2,173],26:[2,173],49:[2,173],54:[2,173],57:[2,173],73:[2,173],78:[2,173],86:[2,173],91:[2,173],93:[2,173],102:[2,173],104:[2,173],105:[2,173],106:[2,173],110:[2,173],118:[2,173],126:[2,173],128:[2,173],129:[2,173],132:[2,173],133:[2,173],134:[2,173],135:[2,173],136:[2,173],137:[2,173]},{5:317,25:[1,5]},{26:[1,318]},{6:[1,319],26:[2,179],121:[2,179],123:[2,179]},{8:320,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,103],6:[2,103],25:[2,103],26:[2,103],49:[2,103],54:[2,103],57:[2,103],73:[2,103],78:[2,103],86:[2,103],91:[2,103],93:[2,103],102:[2,103],104:[2,103],105:[2,103],106:[2,103],110:[2,103],118:[2,103],126:[2,103],128:[2,103],129:[2,103],132:[2,103],133:[2,103],134:[2,103],135:[2,103],136:[2,103],137:[2,103]},{1:[2,142],6:[2,142],25:[2,142],26:[2,142],49:[2,142],54:[2,142],57:[2,142],66:[2,142],67:[2,142],68:[2,142],69:[2,142],71:[2,142],73:[2,142],74:[2,142],78:[2,142],84:[2,142],85:[2,142],86:[2,142],91:[2,142],93:[2,142],102:[2,142],104:[2,142],105:[2,142],106:[2,142],110:[2,142],118:[2,142],126:[2,142],128:[2,142],129:[2,142],132:[2,142],133:[2,142],134:[2,142],135:[2,142],136:[2,142],137:[2,142]},{1:[2,119],6:[2,119],25:[2,119],26:[2,119],49:[2,119],54:[2,119],57:[2,119],66:[2,119],67:[2,119],68:[2,119],69:[2,119],71:[2,119],73:[2,119],74:[2,119],78:[2,119],84:[2,119],85:[2,119],86:[2,119],91:[2,119],93:[2,119],102:[2,119],104:[2,119],105:[2,119],106:[2,119],110:[2,119],118:[2,119],126:[2,119],128:[2,119],129:[2,119],132:[2,119],133:[2,119],134:[2,119],135:[2,119],136:[2,119],137:[2,119]},{6:[2,126],25:[2,126],26:[2,126],54:[2,126],86:[2,126],91:[2,126]},{6:[2,53],25:[2,53],26:[2,53],53:321,54:[1,229]},{6:[2,127],25:[2,127],26:[2,127],54:[2,127],86:[2,127],91:[2,127]},{1:[2,168],6:[2,168],25:[2,168],26:[2,168],49:[2,168],54:[2,168],57:[2,168],73:[2,168],78:[2,168],86:[2,168],91:[2,168],93:[2,168],102:[2,168],103:87,104:[2,168],105:[2,168],106:[2,168],109:88,110:[2,168],111:69,118:[1,322],126:[2,168],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,170],6:[2,170],25:[2,170],26:[2,170],49:[2,170],54:[2,170],57:[2,170],73:[2,170],78:[2,170],86:[2,170],91:[2,170],93:[2,170],102:[2,170],103:87,104:[2,170],105:[1,323],106:[2,170],109:88,110:[2,170],111:69,118:[2,170],126:[2,170],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,169],6:[2,169],25:[2,169],26:[2,169],49:[2,169],54:[2,169],57:[2,169],73:[2,169],78:[2,169],86:[2,169],91:[2,169],93:[2,169],102:[2,169],103:87,104:[2,169],105:[2,169],106:[2,169],109:88,110:[2,169],111:69,118:[2,169],126:[2,169],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{6:[2,94],25:[2,94],26:[2,94],54:[2,94],78:[2,94]},{6:[2,53],25:[2,53],26:[2,53],53:324,54:[1,239]},{26:[1,325],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{6:[1,250],25:[1,251],26:[1,326]},{26:[1,327]},{1:[2,176],6:[2,176],25:[2,176],26:[2,176],49:[2,176],54:[2,176],57:[2,176],73:[2,176],78:[2,176],86:[2,176],91:[2,176],93:[2,176],102:[2,176],104:[2,176],105:[2,176],106:[2,176],110:[2,176],118:[2,176],126:[2,176],128:[2,176],129:[2,176],132:[2,176],133:[2,176],134:[2,176],135:[2,176],136:[2,176],137:[2,176]},{26:[2,180],121:[2,180],123:[2,180]},{25:[2,132],54:[2,132],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{6:[1,272],25:[1,273],26:[1,328]},{8:329,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:330,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{6:[1,283],25:[1,284],26:[1,331]},{6:[2,41],25:[2,41],26:[2,41],54:[2,41],78:[2,41]},{6:[2,59],25:[2,59],26:[2,59],49:[2,59],54:[2,59]},{1:[2,174],6:[2,174],25:[2,174],26:[2,174],49:[2,174],54:[2,174],57:[2,174],73:[2,174],78:[2,174],86:[2,174],91:[2,174],93:[2,174],102:[2,174],104:[2,174],105:[2,174],106:[2,174],110:[2,174],118:[2,174],126:[2,174],128:[2,174],129:[2,174],132:[2,174],133:[2,174],134:[2,174],135:[2,174],136:[2,174],137:[2,174]},{6:[2,128],25:[2,128],26:[2,128],54:[2,128],86:[2,128],91:[2,128]},{1:[2,171],6:[2,171],25:[2,171],26:[2,171],49:[2,171],54:[2,171],57:[2,171],73:[2,171],78:[2,171],86:[2,171],91:[2,171],93:[2,171],102:[2,171],103:87,104:[2,171],105:[2,171],106:[2,171],109:88,110:[2,171],111:69,118:[2,171],126:[2,171],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,172],6:[2,172],25:[2,172],26:[2,172],49:[2,172],54:[2,172],57:[2,172],73:[2,172],78:[2,172],86:[2,172],91:[2,172],93:[2,172],102:[2,172],103:87,104:[2,172],105:[2,172],106:[2,172],109:88,110:[2,172],111:69,118:[2,172],126:[2,172],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{6:[2,95],25:[2,95],26:[2,95],54:[2,95],78:[2,95]}],defaultActions:{60:[2,51],61:[2,52],75:[2,3],94:[2,109],191:[2,89]},parseError:function(e){throw new Error(e) +},parse:function(e){function t(){var e;return e=n.lexer.lex()||1,"number"!=typeof e&&(e=n.symbols_[e]||e),e}var n=this,i=[0],s=[null],r=[],o=this.table,a="",c=0,h=0,l=0;this.lexer.setInput(e),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,"undefined"==typeof this.lexer.yylloc&&(this.lexer.yylloc={});var u=this.lexer.yylloc;r.push(u);var p=this.lexer.options&&this.lexer.options.ranges;"function"==typeof this.yy.parseError&&(this.parseError=this.yy.parseError);for(var d,f,m,b,k,g,y,v,w,T={};;){if(m=i[i.length-1],this.defaultActions[m]?b=this.defaultActions[m]:((null===d||"undefined"==typeof d)&&(d=t()),b=o[m]&&o[m][d]),"undefined"==typeof b||!b.length||!b[0]){var C="";if(!l){w=[];for(g in o[m])this.terminals_[g]&&g>2&&w.push("'"+this.terminals_[g]+"'");C=this.lexer.showPosition?"Parse error on line "+(c+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+w.join(", ")+", got '"+(this.terminals_[d]||d)+"'":"Parse error on line "+(c+1)+": Unexpected "+(1==d?"end of input":"'"+(this.terminals_[d]||d)+"'"),this.parseError(C,{text:this.lexer.match,token:this.terminals_[d]||d,line:this.lexer.yylineno,loc:u,expected:w})}}if(b[0]instanceof Array&&b.length>1)throw new Error("Parse Error: multiple actions possible at state: "+m+", token: "+d);switch(b[0]){case 1:i.push(d),s.push(this.lexer.yytext),r.push(this.lexer.yylloc),i.push(b[1]),d=null,f?(d=f,f=null):(h=this.lexer.yyleng,a=this.lexer.yytext,c=this.lexer.yylineno,u=this.lexer.yylloc,l>0&&l--);break;case 2:if(y=this.productions_[b[1]][1],T.$=s[s.length-y],T._$={first_line:r[r.length-(y||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(y||1)].first_column,last_column:r[r.length-1].last_column},p&&(T._$.range=[r[r.length-(y||1)].range[0],r[r.length-1].range[1]]),k=this.performAction.call(T,a,h,c,this.yy,b[1],s,r),"undefined"!=typeof k)return k;y&&(i=i.slice(0,2*-1*y),s=s.slice(0,-1*y),r=r.slice(0,-1*y)),i.push(this.productions_[b[1]][0]),s.push(T.$),r.push(T._$),v=o[i[i.length-2]][i[i.length-1]],i.push(v);break;case 3:return!0}}return!0}};return e.prototype=t,t.Parser=e,new e}();return"undefined"!=typeof require&&"undefined"!=typeof e&&(e.parser=n,e.Parser=n.Parser,e.parse=function(){return n.parse.apply(n,arguments)},e.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var n=require("fs").readFileSync(require("path").normalize(t[1]),"utf8");return e.parser.parse(n)},"undefined"!=typeof t&&require.main===t&&e.main(process.argv.slice(1))),t.exports}(),require["./scope"]=function(){var e={},t={exports:e};return function(){var t,n,i,s;s=require("./helpers"),n=s.extend,i=s.last,e.Scope=t=function(){function e(t,n,i){this.parent=t,this.expressions=n,this.method=i,this.variables=[{name:"arguments",type:"arguments"}],this.positions={},this.parent||(e.root=this)}return e.root=null,e.prototype.add=function(e,t,n){return this.shared&&!n?this.parent.add(e,t,n):Object.prototype.hasOwnProperty.call(this.positions,e)?this.variables[this.positions[e]].type=t:this.positions[e]=this.variables.push({name:e,type:t})-1},e.prototype.namedMethod=function(){var e;return(null!=(e=this.method)?e.name:void 0)||!this.parent?this.method:this.parent.namedMethod()},e.prototype.find=function(e){return this.check(e)?!0:(this.add(e,"var"),!1)},e.prototype.parameter=function(e){return this.shared&&this.parent.check(e,!0)?void 0:this.add(e,"param")},e.prototype.check=function(e){var t;return!!(this.type(e)||(null!=(t=this.parent)?t.check(e):void 0))},e.prototype.temporary=function(e,t){return e.length>1?"_"+e+(t>1?t-1:""):"_"+(t+parseInt(e,36)).toString(36).replace(/\d/g,"a")},e.prototype.type=function(e){var t,n,i,s;for(s=this.variables,n=0,i=s.length;i>n;n++)if(t=s[n],t.name===e)return t.type;return null},e.prototype.freeVariable=function(e,t){var n,i;for(null==t&&(t=!0),n=0;this.check(i=this.temporary(e,n));)n++;return t&&this.add(i,"var",!0),i},e.prototype.assign=function(e,t){return this.add(e,{value:t,assigned:!0},!0),this.hasAssignments=!0},e.prototype.hasDeclarations=function(){return!!this.declaredVariables().length},e.prototype.declaredVariables=function(){var e,t,n,i,s,r;for(e=[],t=[],r=this.variables,i=0,s=r.length;s>i;i++)n=r[i],"var"===n.type&&("_"===n.name.charAt(0)?t:e).push(n.name);return e.sort().concat(t.sort())},e.prototype.assignedVariables=function(){var e,t,n,i,s;for(i=this.variables,s=[],t=0,n=i.length;n>t;t++)e=i[t],e.type.assigned&&s.push(""+e.name+" = "+e.type.value);return s},e}()}.call(this),t.exports}(),require["./nodes"]=function(){var e={},t={exports:e};return function(){var t,n,i,s,r,o,a,c,h,l,u,p,d,f,m,b,k,g,y,v,w,T,C,F,L,N,x,E,D,S,R,A,I,_,$,O,j,M,B,V,P,U,q,H,G,W,X,Y,K,z,J,Z,Q,et,tt,nt,it,st,rt,ot,at,ct,ht,lt,ut,pt,dt,ft,mt,bt,kt,gt={}.hasOwnProperty,yt=function(e,t){function n(){this.constructor=e}for(var i in t)gt.call(t,i)&&(e[i]=t[i]);return n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype,e},vt=[].indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(t in this&&this[t]===e)return t;return-1},wt=[].slice;Error.stackTraceLimit=1/0,V=require("./scope").Scope,ft=require("./lexer"),$=ft.RESERVED,B=ft.STRICT_PROSCRIBED,mt=require("./helpers"),Q=mt.compact,it=mt.flatten,nt=mt.extend,at=mt.merge,et=mt.del,lt=mt.starts,tt=mt.ends,rt=mt.last,ht=mt.some,Z=mt.addLocationDataFn,ot=mt.locationDataToString,ut=mt.throwSyntaxError,e.extend=nt,e.addLocationDataFn=Z,J=function(){return!0},S=function(){return!1},G=function(){return this},D=function(){return this.negated=!this.negated,this},e.CodeFragment=l=function(){function e(e,t){var n;this.code=""+t,this.locationData=null!=e?e.locationData:void 0,this.type=(null!=e?null!=(n=e.constructor)?n.name:void 0:void 0)||"unknown"}return e.prototype.toString=function(){return""+this.code+(this.locationData?": "+ot(this.locationData):"")},e}(),st=function(e){var t;return function(){var n,i,s;for(s=[],n=0,i=e.length;i>n;n++)t=e[n],s.push(t.code);return s}().join("")},e.Base=s=function(){function e(){}return e.prototype.compile=function(e,t){return st(this.compileToFragments(e,t))},e.prototype.compileToFragments=function(e,t){var n;return e=nt({},e),t&&(e.level=t),n=this.unfoldSoak(e)||this,n.tab=e.indent,e.level!==N&&n.isStatement(e)?n.compileClosure(e):n.compileNode(e)},e.prototype.compileClosure=function(e){var t;return(t=this.jumps())&&t.error("cannot use a pure statement in an expression"),e.sharedScope=!0,c.wrap(this).compileNode(e)},e.prototype.cache=function(e,t,n){var s,r;return this.isComplex()?(s=new x(n||e.scope.freeVariable("ref")),r=new i(s,this),t?[r.compileToFragments(e,t),[this.makeCode(s.value)]]:[r,s]):(s=t?this.compileToFragments(e,t):this,[s,s])},e.prototype.cacheToCodeFragments=function(e){return[st(e[0]),st(e[1])]},e.prototype.makeReturn=function(e){var t;return t=this.unwrapAll(),e?new o(new x(""+e+".push"),[t]):new j(t)},e.prototype.contains=function(e){var t;return t=void 0,this.traverseChildren(!1,function(n){return e(n)?(t=n,!1):void 0}),t},e.prototype.lastNonComment=function(e){var t;for(t=e.length;t--;)if(!(e[t]instanceof u))return e[t];return null},e.prototype.toString=function(e,t){var n;return null==e&&(e=""),null==t&&(t=this.constructor.name),n="\n"+e+t,this.soak&&(n+="?"),this.eachChild(function(t){return n+=t.toString(e+H)}),n},e.prototype.eachChild=function(e){var t,n,i,s,r,o,a,c;if(!this.children)return this;for(a=this.children,i=0,r=a.length;r>i;i++)if(t=a[i],this[t])for(c=it([this[t]]),s=0,o=c.length;o>s;s++)if(n=c[s],e(n)===!1)return this;return this},e.prototype.traverseChildren=function(e,t){return this.eachChild(function(n){var i;return i=t(n),i!==!1?n.traverseChildren(e,t):void 0})},e.prototype.invert=function(){return new A("!",this)},e.prototype.unwrapAll=function(){var e;for(e=this;e!==(e=e.unwrap()););return e},e.prototype.children=[],e.prototype.isStatement=S,e.prototype.jumps=S,e.prototype.isComplex=J,e.prototype.isChainable=S,e.prototype.isAssignable=S,e.prototype.unwrap=G,e.prototype.unfoldSoak=S,e.prototype.assigns=S,e.prototype.updateLocationDataIfMissing=function(e){return this.locationData||(this.locationData=e),this.eachChild(function(t){return t.updateLocationDataIfMissing(e)})},e.prototype.error=function(e){return ut(e,this.locationData)},e.prototype.makeCode=function(e){return new l(this,e)},e.prototype.wrapInBraces=function(e){return[].concat(this.makeCode("("),e,this.makeCode(")"))},e.prototype.joinFragmentArrays=function(e,t){var n,i,s,r,o;for(n=[],s=r=0,o=e.length;o>r;s=++r)i=e[s],s&&n.push(this.makeCode(t)),n=n.concat(i);return n},e}(),e.Block=r=function(e){function t(e){this.expressions=Q(it(e||[]))}return yt(t,e),t.prototype.children=["expressions"],t.prototype.push=function(e){return this.expressions.push(e),this},t.prototype.pop=function(){return this.expressions.pop()},t.prototype.unshift=function(e){return this.expressions.unshift(e),this},t.prototype.unwrap=function(){return 1===this.expressions.length?this.expressions[0]:this},t.prototype.isEmpty=function(){return!this.expressions.length},t.prototype.isStatement=function(e){var t,n,i,s;for(s=this.expressions,n=0,i=s.length;i>n;n++)if(t=s[n],t.isStatement(e))return!0;return!1},t.prototype.jumps=function(e){var t,n,i,s;for(s=this.expressions,n=0,i=s.length;i>n;n++)if(t=s[n],t.jumps(e))return t},t.prototype.makeReturn=function(e){var t,n;for(n=this.expressions.length;n--;)if(t=this.expressions[n],!(t instanceof u)){this.expressions[n]=t.makeReturn(e),t instanceof j&&!t.expression&&this.expressions.splice(n,1);break}return this},t.prototype.compileToFragments=function(e,n){return null==e&&(e={}),e.scope?t.__super__.compileToFragments.call(this,e,n):this.compileRoot(e)},t.prototype.compileNode=function(e){var n,i,s,r,o,a,c,h,l;for(this.tab=e.indent,a=e.level===N,i=[],l=this.expressions,r=c=0,h=l.length;h>c;r=++c)o=l[r],o=o.unwrapAll(),o=o.unfoldSoak(e)||o,o instanceof t?i.push(o.compileNode(e)):a?(o.front=!0,s=o.compileToFragments(e),o.isStatement(e)||(s.unshift(this.makeCode(""+this.tab)),s.push(this.makeCode(";"))),i.push(s)):i.push(o.compileToFragments(e,C));return a?this.spaced?[].concat(this.joinFragmentArrays(i,"\n\n"),this.makeCode("\n")):this.joinFragmentArrays(i,"\n"):(n=i.length?this.joinFragmentArrays(i,", "):[this.makeCode("void 0")],i.length>1&&e.level>=C?this.wrapInBraces(n):n)},t.prototype.compileRoot=function(e){var t,n,i,s,r,o,a,c,h,l;for(e.indent=e.bare?"":H,e.level=N,this.spaced=!0,e.scope=new V(null,this,null),l=e.locals||[],c=0,h=l.length;h>c;c++)s=l[c],e.scope.parameter(s);return r=[],e.bare||(o=function(){var e,n,s,r;for(s=this.expressions,r=[],i=e=0,n=s.length;n>e&&(t=s[i],t.unwrap()instanceof u);i=++e)r.push(t);return r}.call(this),a=this.expressions.slice(o.length),this.expressions=o,o.length&&(r=this.compileNode(at(e,{indent:""})),r.push(this.makeCode("\n"))),this.expressions=a),n=this.compileWithDeclarations(e),e.bare?n:[].concat(r,this.makeCode("(function() {\n"),n,this.makeCode("\n}).call(this);\n"))},t.prototype.compileWithDeclarations=function(e){var t,n,i,s,r,o,a,c,h,l,p,d,f,m;for(s=[],o=[],d=this.expressions,r=l=0,p=d.length;p>l&&(i=d[r],i=i.unwrap(),i instanceof u||i instanceof x);r=++l);return e=at(e,{level:N}),r&&(a=this.expressions.splice(r,9e9),f=[this.spaced,!1],h=f[0],this.spaced=f[1],m=[this.compileNode(e),h],s=m[0],this.spaced=m[1],this.expressions=a),o=this.compileNode(e),c=e.scope,c.expressions===this&&(n=e.scope.hasDeclarations(),t=c.hasAssignments,n||t?(r&&s.push(this.makeCode("\n")),s.push(this.makeCode(""+this.tab+"var ")),n&&s.push(this.makeCode(c.declaredVariables().join(", "))),t&&(n&&s.push(this.makeCode(",\n"+(this.tab+H))),s.push(this.makeCode(c.assignedVariables().join(",\n"+(this.tab+H))))),s.push(this.makeCode(";\n"+(this.spaced?"\n":"")))):s.length&&o.length&&s.push(this.makeCode("\n"))),s.concat(o)},t.wrap=function(e){return 1===e.length&&e[0]instanceof t?e[0]:new t(e)},t}(s),e.Literal=x=function(e){function t(e){this.value=e}return yt(t,e),t.prototype.makeReturn=function(){return this.isStatement()?this:t.__super__.makeReturn.apply(this,arguments)},t.prototype.isAssignable=function(){return m.test(this.value)},t.prototype.isStatement=function(){var e;return"break"===(e=this.value)||"continue"===e||"debugger"===e},t.prototype.isComplex=S,t.prototype.assigns=function(e){return e===this.value},t.prototype.jumps=function(e){return"break"!==this.value||(null!=e?e.loop:void 0)||(null!=e?e.block:void 0)?"continue"!==this.value||(null!=e?e.loop:void 0)?void 0:this:this},t.prototype.compileNode=function(e){var t,n,i;return n="this"===this.value?(null!=(i=e.scope.method)?i.bound:void 0)?e.scope.method.context:this.value:this.value.reserved?'"'+this.value+'"':this.value,t=this.isStatement()?""+this.tab+n+";":n,[this.makeCode(t)]},t.prototype.toString=function(){return' "'+this.value+'"'},t}(s),e.Undefined=function(e){function t(){return bt=t.__super__.constructor.apply(this,arguments)}return yt(t,e),t.prototype.isAssignable=S,t.prototype.isComplex=S,t.prototype.compileNode=function(e){return[this.makeCode(e.level>=w?"(void 0)":"void 0")]},t}(s),e.Null=function(e){function t(){return kt=t.__super__.constructor.apply(this,arguments)}return yt(t,e),t.prototype.isAssignable=S,t.prototype.isComplex=S,t.prototype.compileNode=function(){return[this.makeCode("null")]},t}(s),e.Bool=function(e){function t(e){this.val=e}return yt(t,e),t.prototype.isAssignable=S,t.prototype.isComplex=S,t.prototype.compileNode=function(){return[this.makeCode(this.val)]},t}(s),e.Return=j=function(e){function t(e){e&&!e.unwrap().isUndefined&&(this.expression=e)}return yt(t,e),t.prototype.children=["expression"],t.prototype.isStatement=J,t.prototype.makeReturn=G,t.prototype.jumps=G,t.prototype.compileToFragments=function(e,n){var i,s;return i=null!=(s=this.expression)?s.makeReturn():void 0,!i||i instanceof t?t.__super__.compileToFragments.call(this,e,n):i.compileToFragments(e,n)},t.prototype.compileNode=function(e){var t;return t=[],t.push(this.makeCode(this.tab+("return"+(this.expression?" ":"")))),this.expression&&(t=t.concat(this.expression.compileToFragments(e,L))),t.push(this.makeCode(";")),t},t}(s),e.Value=K=function(e){function t(e,n,i){return!n&&e instanceof t?e:(this.base=e,this.properties=n||[],i&&(this[i]=!0),this)}return yt(t,e),t.prototype.children=["base","properties"],t.prototype.add=function(e){return this.properties=this.properties.concat(e),this},t.prototype.hasProperties=function(){return!!this.properties.length},t.prototype.isArray=function(){return!this.properties.length&&this.base instanceof n},t.prototype.isComplex=function(){return this.hasProperties()||this.base.isComplex()},t.prototype.isAssignable=function(){return this.hasProperties()||this.base.isAssignable()},t.prototype.isSimpleNumber=function(){return this.base instanceof x&&M.test(this.base.value)},t.prototype.isString=function(){return this.base instanceof x&&k.test(this.base.value)},t.prototype.isAtomic=function(){var e,t,n,i;for(i=this.properties.concat(this.base),t=0,n=i.length;n>t;t++)if(e=i[t],e.soak||e instanceof o)return!1;return!0},t.prototype.isStatement=function(e){return!this.properties.length&&this.base.isStatement(e)},t.prototype.assigns=function(e){return!this.properties.length&&this.base.assigns(e)},t.prototype.jumps=function(e){return!this.properties.length&&this.base.jumps(e)},t.prototype.isObject=function(e){return this.properties.length?!1:this.base instanceof R&&(!e||this.base.generated)},t.prototype.isSplice=function(){return rt(this.properties)instanceof P},t.prototype.unwrap=function(){return this.properties.length?this:this.base},t.prototype.cacheReference=function(e){var n,s,r,o;return r=rt(this.properties),this.properties.length<2&&!this.base.isComplex()&&!(null!=r?r.isComplex():void 0)?[this,this]:(n=new t(this.base,this.properties.slice(0,-1)),n.isComplex()&&(s=new x(e.scope.freeVariable("base")),n=new t(new _(new i(s,n)))),r?(r.isComplex()&&(o=new x(e.scope.freeVariable("name")),r=new v(new i(o,r.index)),o=new v(o)),[n.add(r),new t(s||n.base,[o||r])]):[n,s])},t.prototype.compileNode=function(e){var t,n,i,s,r;for(this.base.front=this.front,i=this.properties,t=this.base.compileToFragments(e,i.length?w:null),(this.base instanceof _||i.length)&&M.test(st(t))&&t.push(this.makeCode(".")),s=0,r=i.length;r>s;s++)n=i[s],t.push.apply(t,n.compileToFragments(e));return t},t.prototype.unfoldSoak=function(e){var n=this;return null!=this.unfoldedSoak?this.unfoldedSoak:this.unfoldedSoak=function(){var s,r,o,a,c,h,l,u,d,f;if(o=n.base.unfoldSoak(e))return(d=o.body.properties).push.apply(d,n.properties),o;for(f=n.properties,r=l=0,u=f.length;u>l;r=++l)if(a=f[r],a.soak)return a.soak=!1,s=new t(n.base,n.properties.slice(0,r)),h=new t(n.base,n.properties.slice(r)),s.isComplex()&&(c=new x(e.scope.freeVariable("ref")),s=new _(new i(c,s)),h.base=c),new g(new p(s),h,{soak:!0});return!1}()},t}(s),e.Comment=u=function(e){function t(e){this.comment=e}return yt(t,e),t.prototype.isStatement=J,t.prototype.makeReturn=G,t.prototype.compileNode=function(e,t){var n;return n="/*"+ct(this.comment,this.tab)+(vt.call(this.comment,"\n")>=0?"\n"+this.tab:"")+"*/\n",(t||e.level)===N&&(n=e.indent+n),[this.makeCode(n)]},t}(s),e.Call=o=function(e){function n(e,t,n){this.args=null!=t?t:[],this.soak=n,this.isNew=!1,this.isSuper="super"===e,this.variable=this.isSuper?null:e}return yt(n,e),n.prototype.children=["variable","args"],n.prototype.newInstance=function(){var e,t;return e=(null!=(t=this.variable)?t.base:void 0)||this.variable,e instanceof n&&!e.isNew?e.newInstance():this.isNew=!0,this},n.prototype.superReference=function(e){var n,i;return i=e.scope.namedMethod(),(null!=i?i.klass:void 0)?(n=[new t(new x("__super__"))],i["static"]&&n.push(new t(new x("constructor"))),n.push(new t(new x(i.name))),new K(new x(i.klass),n).compile(e)):(null!=i?i.ctor:void 0)?""+i.name+".__super__.constructor":this.error("cannot call super outside of an instance method.")},n.prototype.superThis=function(e){var t;return t=e.scope.method,t&&!t.klass&&t.context||"this"},n.prototype.unfoldSoak=function(e){var t,i,s,r,o,a,c,h,l;if(this.soak){if(this.variable){if(i=pt(e,this,"variable"))return i;h=new K(this.variable).cacheReference(e),s=h[0],o=h[1]}else s=new x(this.superReference(e)),o=new K(s);return o=new n(o,this.args),o.isNew=this.isNew,s=new x("typeof "+s.compile(e)+' === "function"'),new g(s,new K(o),{soak:!0})}for(t=this,r=[];;)if(t.variable instanceof n)r.push(t),t=t.variable;else{if(!(t.variable instanceof K))break;if(r.push(t),!((t=t.variable.base)instanceof n))break}for(l=r.reverse(),a=0,c=l.length;c>a;a++)t=l[a],i&&(t.variable instanceof n?t.variable=i:t.variable.base=i),i=pt(e,t,"variable");return i},n.prototype.compileNode=function(e){var t,n,i,s,r,o,a,c,h,l;if(null!=(h=this.variable)&&(h.front=this.front),s=U.compileSplattedArray(e,this.args,!0),s.length)return this.compileSplat(e,s);for(i=[],l=this.args,n=a=0,c=l.length;c>a;n=++a)t=l[n],n&&i.push(this.makeCode(", ")),i.push.apply(i,t.compileToFragments(e,C));return r=[],this.isSuper?(o=this.superReference(e)+(".call("+this.superThis(e)),i.length&&(o+=", "),r.push(this.makeCode(o))):(this.isNew&&r.push(this.makeCode("new ")),r.push.apply(r,this.variable.compileToFragments(e,w)),r.push(this.makeCode("("))),r.push.apply(r,i),r.push(this.makeCode(")")),r},n.prototype.compileSplat=function(e,t){var n,i,s,r,o,a;return this.isSuper?[].concat(this.makeCode(""+this.superReference(e)+".apply("+this.superThis(e)+", "),t,this.makeCode(")")):this.isNew?(r=this.tab+H,[].concat(this.makeCode("(function(func, args, ctor) {\n"+r+"ctor.prototype = func.prototype;\n"+r+"var child = new ctor, result = func.apply(child, args);\n"+r+"return Object(result) === result ? result : child;\n"+this.tab+"})("),this.variable.compileToFragments(e,C),this.makeCode(", "),t,this.makeCode(", function(){})"))):(n=[],i=new K(this.variable),(o=i.properties.pop())&&i.isComplex()?(a=e.scope.freeVariable("ref"),n=n.concat(this.makeCode("("+a+" = "),i.compileToFragments(e,C),this.makeCode(")"),o.compileToFragments(e))):(s=i.compileToFragments(e,w),M.test(st(s))&&(s=this.wrapInBraces(s)),o?(a=st(s),s.push.apply(s,o.compileToFragments(e))):a="null",n=n.concat(s)),n=n.concat(this.makeCode(".apply("+a+", "),t,this.makeCode(")")))},n}(s),e.Extends=d=function(e){function t(e,t){this.child=e,this.parent=t}return yt(t,e),t.prototype.children=["child","parent"],t.prototype.compileToFragments=function(e){return new o(new K(new x(dt("extends"))),[this.child,this.parent]).compileToFragments(e)},t}(s),e.Access=t=function(e){function t(e,t){this.name=e,this.name.asKey=!0,this.soak="soak"===t}return yt(t,e),t.prototype.children=["name"],t.prototype.compileToFragments=function(e){var t;return t=this.name.compileToFragments(e),m.test(st(t))?t.unshift(this.makeCode(".")):(t.unshift(this.makeCode("[")),t.push(this.makeCode("]"))),t},t.prototype.isComplex=S,t}(s),e.Index=v=function(e){function t(e){this.index=e}return yt(t,e),t.prototype.children=["index"],t.prototype.compileToFragments=function(e){return[].concat(this.makeCode("["),this.index.compileToFragments(e,L),this.makeCode("]"))},t.prototype.isComplex=function(){return this.index.isComplex()},t}(s),e.Range=O=function(e){function t(e,t,n){this.from=e,this.to=t,this.exclusive="exclusive"===n,this.equals=this.exclusive?"":"="}return yt(t,e),t.prototype.children=["from","to"],t.prototype.compileVariables=function(e){var t,n,i,s,r;return e=at(e,{top:!0}),n=this.cacheToCodeFragments(this.from.cache(e,C)),this.fromC=n[0],this.fromVar=n[1],i=this.cacheToCodeFragments(this.to.cache(e,C)),this.toC=i[0],this.toVar=i[1],(t=et(e,"step"))&&(s=this.cacheToCodeFragments(t.cache(e,C)),this.step=s[0],this.stepVar=s[1]),r=[this.fromVar.match(M),this.toVar.match(M)],this.fromNum=r[0],this.toNum=r[1],this.stepVar?this.stepNum=this.stepVar.match(M):void 0},t.prototype.compileNode=function(e){var t,n,i,s,r,o,a,c,h,l,u,p,d,f;return this.fromVar||this.compileVariables(e),e.index?(a=this.fromNum&&this.toNum,r=et(e,"index"),o=et(e,"name"),h=o&&o!==r,p=""+r+" = "+this.fromC,this.toC!==this.toVar&&(p+=", "+this.toC),this.step!==this.stepVar&&(p+=", "+this.step),d=[""+r+" <"+this.equals,""+r+" >"+this.equals],c=d[0],s=d[1],n=this.stepNum?+this.stepNum>0?""+c+" "+this.toVar:""+s+" "+this.toVar:a?(f=[+this.fromNum,+this.toNum],i=f[0],u=f[1],f,u>=i?""+c+" "+u:""+s+" "+u):(t=this.stepVar?""+this.stepVar+" > 0":""+this.fromVar+" <= "+this.toVar,""+t+" ? "+c+" "+this.toVar+" : "+s+" "+this.toVar),l=this.stepVar?""+r+" += "+this.stepVar:a?h?u>=i?"++"+r:"--"+r:u>=i?""+r+"++":""+r+"--":h?""+t+" ? ++"+r+" : --"+r:""+t+" ? "+r+"++ : "+r+"--",h&&(p=""+o+" = "+p),h&&(l=""+o+" = "+l),[this.makeCode(""+p+"; "+n+"; "+l)]):this.compileArray(e)},t.prototype.compileArray=function(e){var t,n,i,s,r,o,a,c,h,l,u,p,d;return this.fromNum&&this.toNum&&Math.abs(this.fromNum-this.toNum)<=20?(h=function(){d=[];for(var e=p=+this.fromNum,t=+this.toNum;t>=p?t>=e:e>=t;t>=p?e++:e--)d.push(e);return d}.apply(this),this.exclusive&&h.pop(),[this.makeCode("["+h.join(", ")+"]")]):(o=this.tab+H,r=e.scope.freeVariable("i"),l=e.scope.freeVariable("results"),c="\n"+o+l+" = [];",this.fromNum&&this.toNum?(e.index=r,n=st(this.compileNode(e))):(u=""+r+" = "+this.fromC+(this.toC!==this.toVar?", "+this.toC:""),i=""+this.fromVar+" <= "+this.toVar,n="var "+u+"; "+i+" ? "+r+" <"+this.equals+" "+this.toVar+" : "+r+" >"+this.equals+" "+this.toVar+"; "+i+" ? "+r+"++ : "+r+"--"),a="{ "+l+".push("+r+"); }\n"+o+"return "+l+";\n"+e.indent,s=function(e){return null!=e?e.contains(function(e){return e instanceof x&&"arguments"===e.value&&!e.asKey}):void 0},(s(this.from)||s(this.to))&&(t=", arguments"),[this.makeCode("(function() {"+c+"\n"+o+"for ("+n+")"+a+"}).apply(this"+(null!=t?t:"")+")")])},t}(s),e.Slice=P=function(e){function t(e){this.range=e,t.__super__.constructor.call(this)}return yt(t,e),t.prototype.children=["range"],t.prototype.compileNode=function(e){var t,n,i,s,r,o,a;return a=this.range,r=a.to,i=a.from,s=i&&i.compileToFragments(e,L)||[this.makeCode("0")],r&&(t=r.compileToFragments(e,L),n=st(t),(this.range.exclusive||-1!==+n)&&(o=", "+(this.range.exclusive?n:M.test(n)?""+(+n+1):(t=r.compileToFragments(e,w),"+"+st(t)+" + 1 || 9e9")))),[this.makeCode(".slice("+st(s)+(o||"")+")")]},t}(s),e.Obj=R=function(e){function t(e,t){this.generated=null!=t?t:!1,this.objects=this.properties=e||[]}return yt(t,e),t.prototype.children=["properties"],t.prototype.compileNode=function(e){var t,n,s,r,o,a,c,h,l,p,d,f,m;if(l=this.properties,!l.length)return[this.makeCode(this.front?"({})":"{}")];if(this.generated)for(p=0,f=l.length;f>p;p++)c=l[p],c instanceof K&&c.error("cannot have an implicit value in an implicit object");for(s=e.indent+=H,a=this.lastNonComment(this.properties),t=[],n=d=0,m=l.length;m>d;n=++d)h=l[n],o=n===l.length-1?"":h===a||h instanceof u?"\n":",\n",r=h instanceof u?"":s,h instanceof i&&h.variable instanceof K&&h.variable.hasProperties()&&h.variable.error("Invalid object key"),h instanceof K&&h["this"]&&(h=new i(h.properties[0].name,h,"object")),h instanceof u||(h instanceof i||(h=new i(h,h,"object")),(h.variable.base||h.variable).asKey=!0),r&&t.push(this.makeCode(r)),t.push.apply(t,h.compileToFragments(e,N)),o&&t.push(this.makeCode(o));return t.unshift(this.makeCode("{"+(l.length&&"\n"))),t.push(this.makeCode(""+(l.length&&"\n"+this.tab)+"}")),this.front?this.wrapInBraces(t):t},t.prototype.assigns=function(e){var t,n,i,s;for(s=this.properties,n=0,i=s.length;i>n;n++)if(t=s[n],t.assigns(e))return!0;return!1},t}(s),e.Arr=n=function(e){function t(e){this.objects=e||[]}return yt(t,e),t.prototype.children=["objects"],t.prototype.compileNode=function(e){var t,n,i,s,r,o,a;if(!this.objects.length)return[this.makeCode("[]")];if(e.indent+=H,t=U.compileSplattedArray(e,this.objects),t.length)return t;for(t=[],n=function(){var t,n,i,s;for(i=this.objects,s=[],t=0,n=i.length;n>t;t++)r=i[t],s.push(r.compileToFragments(e,C));return s}.call(this),s=o=0,a=n.length;a>o;s=++o)i=n[s],s&&t.push(this.makeCode(", ")),t.push.apply(t,i);return st(t).indexOf("\n")>=0?(t.unshift(this.makeCode("[\n"+e.indent)),t.push(this.makeCode("\n"+this.tab+"]"))):(t.unshift(this.makeCode("[")),t.push(this.makeCode("]"))),t},t.prototype.assigns=function(e){var t,n,i,s;for(s=this.objects,n=0,i=s.length;i>n;n++)if(t=s[n],t.assigns(e))return!0;return!1},t}(s),e.Class=a=function(e){function n(e,t,n){this.variable=e,this.parent=t,this.body=null!=n?n:new r,this.boundFuncs=[],this.body.classBody=!0}return yt(n,e),n.prototype.children=["variable","parent","body"],n.prototype.determineName=function(){var e,n;return this.variable?(e=(n=rt(this.variable.properties))?n instanceof t&&n.name.value:this.variable.base.value,vt.call(B,e)>=0&&this.variable.error("class variable name may not be "+e),e&&(e=m.test(e)&&e)):null},n.prototype.setContext=function(e){return this.body.traverseChildren(!1,function(t){return t.classBody?!1:t instanceof x&&"this"===t.value?t.value=e:t instanceof h&&(t.klass=e,t.bound)?t.context=e:void 0})},n.prototype.addBoundFunctions=function(e){var n,i,s,r,o;for(o=this.boundFuncs,s=0,r=o.length;r>s;s++)n=o[s],i=new K(new x("this"),[new t(n)]).compile(e),this.ctor.body.unshift(new x(""+i+" = "+dt("bind")+"("+i+", this)"))},n.prototype.addProperties=function(e,n,s){var r,o,a,c,l;return l=e.base.properties.slice(0),a=function(){var e;for(e=[];r=l.shift();)r instanceof i&&(o=r.variable.base,delete r.context,c=r.value,"constructor"===o.value?(this.ctor&&r.error("cannot define more than one constructor in a class"),c.bound&&r.error("cannot define a constructor as a bound function"),c instanceof h?r=this.ctor=c:(this.externalCtor=s.scope.freeVariable("class"),r=new i(new x(this.externalCtor),c))):r.variable["this"]?(c["static"]=!0,c.bound&&(c.context=n)):(r.variable=new K(new x(n),[new t(new x("prototype")),new t(o)]),c instanceof h&&c.bound&&(this.boundFuncs.push(o),c.bound=!1))),e.push(r);return e}.call(this),Q(a)},n.prototype.walkBody=function(e,t){var i=this;return this.traverseChildren(!1,function(s){var o,a,c,h,l,u,p;if(o=!0,s instanceof n)return!1;if(s instanceof r){for(p=a=s.expressions,c=l=0,u=p.length;u>l;c=++l)h=p[c],h instanceof K&&h.isObject(!0)&&(o=!1,a[c]=i.addProperties(h,e,t));s.expressions=a=it(a)}return o&&!(s instanceof n)})},n.prototype.hoistDirectivePrologue=function(){var e,t,n;for(t=0,e=this.body.expressions;(n=e[t])&&n instanceof u||n instanceof K&&n.isString();)++t;return this.directives=e.splice(0,t)},n.prototype.ensureConstructor=function(e,t){var n,s,r;return n=!this.ctor,this.ctor||(this.ctor=new h),this.ctor.ctor=this.ctor.name=e,this.ctor.klass=null,this.ctor.noReturn=!0,n?(this.parent&&(r=new x(""+e+".__super__.constructor.apply(this, arguments)")),this.externalCtor&&(r=new x(""+this.externalCtor+".apply(this, arguments)")),r&&(s=new x(t.scope.freeVariable("ref")),this.ctor.body.unshift(new i(s,r))),this.addBoundFunctions(t),r&&(this.ctor.body.push(s),this.ctor.body.makeReturn()),this.body.expressions.unshift(this.ctor)):this.addBoundFunctions(t)},n.prototype.compileNode=function(e){var t,n,s,r,o,a,l;return n=this.determineName(),o=n||"_Class",o.reserved&&(o="_"+o),r=new x(o),this.hoistDirectivePrologue(),this.setContext(o),this.walkBody(o,e),this.ensureConstructor(o,e),this.body.spaced=!0,this.ctor instanceof h||this.body.expressions.unshift(this.ctor),this.body.expressions.push(r),(l=this.body.expressions).unshift.apply(l,this.directives),t=c.wrap(this.body),this.parent&&(this.superClass=new x(e.scope.freeVariable("super",!1)),this.body.expressions.unshift(new d(r,this.superClass)),t.args.push(this.parent),a=t.variable.params||t.variable.base.params,a.push(new I(this.superClass))),s=new _(t,!0),this.variable&&(s=new i(this.variable,s)),s.compileToFragments(e)},n}(s),e.Assign=i=function(e){function n(e,t,n,i){var s,r,o;this.variable=e,this.value=t,this.context=n,this.param=i&&i.param,this.subpattern=i&&i.subpattern,o=r=this.variable.unwrapAll().value,s=vt.call(B,o)>=0,s&&"object"!==this.context&&this.variable.error('variable name may not be "'+r+'"')}return yt(n,e),n.prototype.children=["variable","value"],n.prototype.isStatement=function(e){return(null!=e?e.level:void 0)===N&&null!=this.context&&vt.call(this.context,"?")>=0},n.prototype.assigns=function(e){return this["object"===this.context?"value":"variable"].assigns(e)},n.prototype.unfoldSoak=function(e){return pt(e,this,"variable")},n.prototype.compileNode=function(e){var t,n,i,s,r,o,a,c,l,u,p;if(i=this.variable instanceof K){if(this.variable.isArray()||this.variable.isObject())return this.compilePatternMatch(e);if(this.variable.isSplice())return this.compileSplice(e);if("||="===(c=this.context)||"&&="===c||"?="===c)return this.compileConditional(e)}return n=this.variable.compileToFragments(e,C),r=st(n),this.context||(a=this.variable.unwrapAll(),a.isAssignable()||this.variable.error('"'+this.variable.compile(e)+'" cannot be assigned'),("function"==typeof a.hasProperties?a.hasProperties():void 0)||(this.param?e.scope.add(r,"var"):e.scope.find(r))),this.value instanceof h&&(s=E.exec(r))&&(s[1]&&(this.value.klass=s[1]),this.value.name=null!=(l=null!=(u=null!=(p=s[2])?p:s[3])?u:s[4])?l:s[5]),o=this.value.compileToFragments(e,C),"object"===this.context?n.concat(this.makeCode(": "),o):(t=n.concat(this.makeCode(" "+(this.context||"=")+" "),o),e.level<=C?t:this.wrapInBraces(t))},n.prototype.compilePatternMatch=function(e){var i,s,r,o,a,c,h,l,u,p,d,f,b,k,g,y,w,T,L,E,D,S,R,A,I,O,j,M;if(y=e.level===N,T=this.value,d=this.variable.base.objects,!(f=d.length))return r=T.compileToFragments(e),e.level>=F?this.wrapInBraces(r):r;if(h=this.variable.isObject(),y&&1===f&&!((p=d[0])instanceof U))return p instanceof n?(R=p,A=R.variable,c=A.base,p=R.value):c=h?p["this"]?p.properties[0].name:p:new x(0),i=m.test(c.unwrap().value||0),T=new K(T),T.properties.push(new(i?t:v)(c)),I=p.unwrap().value,vt.call($,I)>=0&&p.error("assignment to a reserved word: "+p.compile(e)),new n(p,T,null,{param:this.param}).compileToFragments(e,N);for(L=T.compileToFragments(e,C),E=st(L),s=[],g=!1,(!m.test(E)||this.variable.assigns(E))&&(s.push([this.makeCode(""+(b=e.scope.freeVariable("ref"))+" = ")].concat(wt.call(L))),L=[this.makeCode(b)],E=b),a=D=0,S=d.length;S>D;a=++D)p=d[a],c=a,h&&(p instanceof n?(O=p,j=O.variable,c=j.base,p=O.value):p.base instanceof _?(M=new K(p.unwrapAll()).cacheReference(e),p=M[0],c=M[1]):c=p["this"]?p.properties[0].name:p),!g&&p instanceof U?(u=p.name.unwrap().value,p=p.unwrap(),w=""+f+" <= "+E+".length ? "+dt("slice")+".call("+E+", "+a,(k=f-a-1)?(l=e.scope.freeVariable("i"),w+=", "+l+" = "+E+".length - "+k+") : ("+l+" = "+a+", [])"):w+=") : []",w=new x(w),g=""+l+"++"):(u=p.unwrap().value,p instanceof U&&p.error("multiple splats are disallowed in an assignment"),"number"==typeof c?(c=new x(g||c),i=!1):i=h&&m.test(c.unwrap().value||0),w=new K(new x(E),[new(i?t:v)(c)])),null!=u&&vt.call($,u)>=0&&p.error("assignment to a reserved word: "+p.compile(e)),s.push(new n(p,w,null,{param:this.param,subpattern:!0}).compileToFragments(e,C)); +return y||this.subpattern||s.push(L),o=this.joinFragmentArrays(s,", "),e.level=0&&(e.isExistentialEquals=!0),new A(this.context.slice(0,-1),t,new n(i,this.value,"=")).compileToFragments(e)},n.prototype.compileSplice=function(e){var t,n,i,s,r,o,a,c,h,l,u,p;return l=this.variable.properties.pop().range,i=l.from,a=l.to,n=l.exclusive,o=this.variable.compile(e),i?(u=this.cacheToCodeFragments(i.cache(e,F)),s=u[0],r=u[1]):s=r="0",a?(null!=i?i.isSimpleNumber():void 0)&&a.isSimpleNumber()?(a=+a.compile(e)-+r,n||(a+=1)):(a=a.compile(e,w)+" - "+r,n||(a+=" + 1")):a="9e9",p=this.value.cache(e,C),c=p[0],h=p[1],t=[].concat(this.makeCode("[].splice.apply("+o+", ["+s+", "+a+"].concat("),c,this.makeCode(")), "),h),e.level>N?this.wrapInBraces(t):t},n}(s),e.Code=h=function(e){function t(e,t,n){this.params=e||[],this.body=t||new r,this.bound="boundfunc"===n,this.bound&&(this.context="_this")}return yt(t,e),t.prototype.children=["params","body"],t.prototype.isStatement=function(){return!!this.ctor},t.prototype.jumps=S,t.prototype.compileNode=function(e){var t,s,r,o,a,c,h,l,u,p,d,f,m,b,k,y,v,T,C,F,L,N,E,D,S,R,I,_,$;for(e.scope=new V(e.scope,this.body,this),e.scope.shared=et(e,"sharedScope"),e.indent+=H,delete e.bare,delete e.isExistentialEquals,u=[],r=[],this.eachParamName(function(t){return e.scope.check(t)?void 0:e.scope.parameter(t)}),S=this.params,k=0,C=S.length;C>k;k++)if(l=S[k],l.splat){for(R=this.params,y=0,F=R.length;F>y;y++)h=R[y].name,h["this"]&&(h=h.properties[0].name),h.value&&e.scope.add(h.value,"var",!0);d=new i(new K(new n(function(){var t,n,i,s;for(i=this.params,s=[],t=0,n=i.length;n>t;t++)h=i[t],s.push(h.asReference(e));return s}.call(this))),new K(new x("arguments")));break}for(I=this.params,v=0,L=I.length;L>v;v++)l=I[v],l.isComplex()?(m=p=l.asReference(e),l.value&&(m=new A("?",p,l.value)),r.push(new i(new K(l.name),m,"=",{param:!0}))):(p=l,l.value&&(c=new x(p.name.value+" == null"),m=new i(new K(l.name),l.value,"="),r.push(new g(c,m)))),d||u.push(p);for(b=this.body.isEmpty(),d&&r.unshift(d),r.length&&(_=this.body.expressions).unshift.apply(_,r),o=T=0,N=u.length;N>T;o=++T)h=u[o],u[o]=h.compileToFragments(e),e.scope.parameter(st(u[o]));for(f=[],this.eachParamName(function(e,t){return vt.call(f,e)>=0&&t.error("multiple parameters named '"+e+"'"),f.push(e)}),b||this.noReturn||this.body.makeReturn(),this.bound&&((null!=($=e.scope.parent.method)?$.bound:void 0)?this.bound=this.context=e.scope.parent.method.context:this["static"]||e.scope.parent.assign("_this","this")),a=e.indent,s="function",this.ctor&&(s+=" "+this.name),s+="(",t=[this.makeCode(s)],o=D=0,E=u.length;E>D;o=++D)h=u[o],o&&t.push(this.makeCode(", ")),t.push.apply(t,h);return t.push(this.makeCode(") {")),this.body.isEmpty()||(t=t.concat(this.makeCode("\n"),this.body.compileWithDeclarations(e),this.makeCode("\n"+this.tab))),t.push(this.makeCode("}")),this.ctor?[this.makeCode(this.tab)].concat(wt.call(t)):this.front||e.level>=w?this.wrapInBraces(t):t},t.prototype.eachParamName=function(e){var t,n,i,s,r;for(s=this.params,r=[],n=0,i=s.length;i>n;n++)t=s[n],r.push(t.eachName(e));return r},t.prototype.traverseChildren=function(e,n){return e?t.__super__.traverseChildren.call(this,e,n):void 0},t}(s),e.Param=I=function(e){function t(e,t,n){var i;this.name=e,this.value=t,this.splat=n,i=e=this.name.unwrapAll().value,vt.call(B,i)>=0&&this.name.error('parameter name "'+e+'" is not allowed')}return yt(t,e),t.prototype.children=["name","value"],t.prototype.compileToFragments=function(e){return this.name.compileToFragments(e,C)},t.prototype.asReference=function(e){var t;return this.reference?this.reference:(t=this.name,t["this"]?(t=t.properties[0].name,t.value.reserved&&(t=new x(e.scope.freeVariable(t.value)))):t.isComplex()&&(t=new x(e.scope.freeVariable("arg"))),t=new K(t),this.splat&&(t=new U(t)),this.reference=t)},t.prototype.isComplex=function(){return this.name.isComplex()},t.prototype.eachName=function(e,t){var n,s,r,o,a,c;if(null==t&&(t=this.name),n=function(t){var n;return n=t.properties[0].name,n.value.reserved?void 0:e(n.value,n)},t instanceof x)return e(t.value,t);if(t instanceof K)return n(t);for(c=t.objects,o=0,a=c.length;a>o;o++)r=c[o],r instanceof i?this.eachName(e,r.value.unwrap()):r instanceof U?(s=r.name.unwrap(),e(s.value,s)):r instanceof K?r.isArray()||r.isObject()?this.eachName(e,r.base):r["this"]?n(r):e(r.base.value,r.base):r.error("illegal parameter "+r.compile())},t}(s),e.Splat=U=function(e){function t(e){this.name=e.compile?e:new x(e)}return yt(t,e),t.prototype.children=["name"],t.prototype.isAssignable=J,t.prototype.assigns=function(e){return this.name.assigns(e)},t.prototype.compileToFragments=function(e){return this.name.compileToFragments(e)},t.prototype.unwrap=function(){return this.name},t.compileSplattedArray=function(e,n,i){var s,r,o,a,c,h,l,u,p,d;for(l=-1;(u=n[++l])&&!(u instanceof t););if(l>=n.length)return[];if(1===n.length)return u=n[0],c=u.compileToFragments(e,C),i?c:[].concat(u.makeCode(""+dt("slice")+".call("),c,u.makeCode(")"));for(s=n.slice(l),h=p=0,d=s.length;d>p;h=++p)u=s[h],o=u.compileToFragments(e,C),s[h]=u instanceof t?[].concat(u.makeCode(""+dt("slice")+".call("),o,u.makeCode(")")):[].concat(u.makeCode("["),o,u.makeCode("]"));return 0===l?(u=n[0],a=u.joinFragmentArrays(s.slice(1),", "),s[0].concat(u.makeCode(".concat("),a,u.makeCode(")"))):(r=function(){var t,i,s,r;for(s=n.slice(0,l),r=[],t=0,i=s.length;i>t;t++)u=s[t],r.push(u.compileToFragments(e,C));return r}(),r=n[0].joinFragmentArrays(r,", "),a=n[l].joinFragmentArrays(s,", "),[].concat(n[0].makeCode("["),r,n[l].makeCode("].concat("),a,rt(n).makeCode(")")))},t}(s),e.While=z=function(e){function t(e,t){this.condition=(null!=t?t.invert:void 0)?e.invert():e,this.guard=null!=t?t.guard:void 0}return yt(t,e),t.prototype.children=["condition","guard","body"],t.prototype.isStatement=J,t.prototype.makeReturn=function(e){return e?t.__super__.makeReturn.apply(this,arguments):(this.returns=!this.jumps({loop:!0}),this)},t.prototype.addBody=function(e){return this.body=e,this},t.prototype.jumps=function(){var e,t,n,i;if(e=this.body.expressions,!e.length)return!1;for(n=0,i=e.length;i>n;n++)if(t=e[n],t.jumps({loop:!0}))return t;return!1},t.prototype.compileNode=function(e){var t,n,i,s;return e.indent+=H,s="",n=this.body,n.isEmpty()?n=this.makeCode(""):(this.returns&&(n.makeReturn(i=e.scope.freeVariable("results")),s=""+this.tab+i+" = [];\n"),this.guard&&(n.expressions.length>1?n.expressions.unshift(new g(new _(this.guard).invert(),new x("continue"))):this.guard&&(n=r.wrap([new g(this.guard,n)]))),n=[].concat(this.makeCode("\n"),n.compileToFragments(e,N),this.makeCode("\n"+this.tab))),t=[].concat(this.makeCode(s+this.tab+"while ("),this.condition.compileToFragments(e,L),this.makeCode(") {"),n,this.makeCode("}")),this.returns&&t.push(this.makeCode("\n"+this.tab+"return "+i+";")),t},t}(s),e.Op=A=function(e){function t(e,t,i,s){if("in"===e)return new y(t,i);if("do"===e)return this.generateDo(t);if("new"===e){if(t instanceof o&&!t["do"]&&!t.isNew)return t.newInstance();(t instanceof h&&t.bound||t["do"])&&(t=new _(t))}return this.operator=n[e]||e,this.first=t,this.second=i,this.flip=!!s,this}var n,s;return yt(t,e),n={"==":"===","!=":"!==",of:"in"},s={"!==":"===","===":"!=="},t.prototype.children=["first","second"],t.prototype.isSimpleNumber=S,t.prototype.isUnary=function(){return!this.second},t.prototype.isComplex=function(){var e;return!(this.isUnary()&&("+"===(e=this.operator)||"-"===e))||this.first.isComplex()},t.prototype.isChainable=function(){var e;return"<"===(e=this.operator)||">"===e||">="===e||"<="===e||"==="===e||"!=="===e},t.prototype.invert=function(){var e,n,i,r,o;if(this.isChainable()&&this.first.isChainable()){for(e=!0,n=this;n&&n.operator;)e&&(e=n.operator in s),n=n.first;if(!e)return new _(this).invert();for(n=this;n&&n.operator;)n.invert=!n.invert,n.operator=s[n.operator],n=n.first;return this}return(r=s[this.operator])?(this.operator=r,this.first.unwrap()instanceof t&&this.first.invert(),this):this.second?new _(this).invert():"!"===this.operator&&(i=this.first.unwrap())instanceof t&&("!"===(o=i.operator)||"in"===o||"instanceof"===o)?i:new t("!",this)},t.prototype.unfoldSoak=function(e){var t;return("++"===(t=this.operator)||"--"===t||"delete"===t)&&pt(e,this,"first")},t.prototype.generateDo=function(e){var t,n,s,r,a,c,l,u;for(r=[],n=e instanceof i&&(a=e.value.unwrap())instanceof h?a:e,u=n.params||[],c=0,l=u.length;l>c;c++)s=u[c],s.value?(r.push(s.value),delete s.value):r.push(s);return t=new o(e,r),t["do"]=!0,t},t.prototype.compileNode=function(e){var t,n,i,s;return n=this.isChainable()&&this.first.isChainable(),n||(this.first.front=this.front),"delete"===this.operator&&e.scope.check(this.first.unwrapAll().value)&&this.error("delete operand may not be argument or var"),("--"===(i=this.operator)||"++"===i)&&(s=this.first.unwrapAll().value,vt.call(B,s)>=0)&&this.error('cannot increment/decrement "'+this.first.unwrapAll().value+'"'),this.isUnary()?this.compileUnary(e):n?this.compileChain(e):"?"===this.operator?this.compileExistence(e):(t=[].concat(this.first.compileToFragments(e,F),this.makeCode(" "+this.operator+" "),this.second.compileToFragments(e,F)),e.level<=F?t:this.wrapInBraces(t))},t.prototype.compileChain=function(e){var t,n,i,s;return s=this.first.second.cache(e),this.first.second=s[0],i=s[1],n=this.first.compileToFragments(e,F),t=n.concat(this.makeCode(" "+(this.invert?"&&":"||")+" "),i.compileToFragments(e),this.makeCode(" "+this.operator+" "),this.second.compileToFragments(e,F)),this.wrapInBraces(t)},t.prototype.compileExistence=function(e){var t,n;return!e.isExistentialEquals&&this.first.isComplex()?(n=new x(e.scope.freeVariable("ref")),t=new _(new i(n,this.first))):(t=this.first,n=t),new g(new p(t),n,{type:"if"}).addElse(this.second).compileToFragments(e)},t.prototype.compileUnary=function(e){var n,i,s;return i=[],n=this.operator,i.push([this.makeCode(n)]),"!"===n&&this.first instanceof p?(this.first.negated=!this.first.negated,this.first.compileToFragments(e)):e.level>=w?new _(this).compileToFragments(e):(s="+"===n||"-"===n,("new"===n||"typeof"===n||"delete"===n||s&&this.first instanceof t&&this.first.operator===n)&&i.push([this.makeCode(" ")]),(s&&this.first instanceof t||"new"===n&&this.first.isStatement(e))&&(this.first=new _(this.first)),i.push(this.first.compileToFragments(e,F)),this.flip&&i.reverse(),this.joinFragmentArrays(i,""))},t.prototype.toString=function(e){return t.__super__.toString.call(this,e,this.constructor.name+" "+this.operator)},t}(s),e.In=y=function(e){function t(e,t){this.object=e,this.array=t}return yt(t,e),t.prototype.children=["object","array"],t.prototype.invert=D,t.prototype.compileNode=function(e){var t,n,i,s,r;if(this.array instanceof K&&this.array.isArray()){for(r=this.array.base.objects,i=0,s=r.length;s>i;i++)if(n=r[i],n instanceof U){t=!0;break}if(!t)return this.compileOrTest(e)}return this.compileLoopTest(e)},t.prototype.compileOrTest=function(e){var t,n,i,s,r,o,a,c,h,l,u,p;if(0===this.array.base.objects.length)return[this.makeCode(""+!!this.negated)];for(l=this.object.cache(e,F),o=l[0],r=l[1],u=this.negated?[" !== "," && "]:[" === "," || "],t=u[0],n=u[1],a=[],p=this.array.base.objects,i=c=0,h=p.length;h>c;i=++c)s=p[i],i&&a.push(this.makeCode(n)),a=a.concat(i?r:o,this.makeCode(t),s.compileToFragments(e,w));return e.level= 0"))),st(i)===st(n)?t:(t=i.concat(this.makeCode(", "),t),e.level+B)||(F=I.freeVariable("len")),a=""+w+y+" = 0, "+F+" = "+P+".length",c=""+w+y+" = "+P+".length - 1",s=""+y+" < "+F,o=""+y+" >= 0",this.step?(B?u&&(s=o,a=c):(s=""+V+" > 0 ? "+s+" : "+o,a="("+V+" > 0 ? ("+a+") : "+c+")"),b=""+y+" += "+V):b=""+(v!==y?"++"+y:""+y+"++"),p=[this.makeCode(""+a+"; "+s+"; "+w+b)])),this.returns&&(S=""+this.tab+A+" = [];\n",R="\n"+this.tab+"return "+A+";",t.makeReturn(A)),this.guard&&(t.expressions.length>1?t.expressions.unshift(new g(new _(this.guard).invert(),new x("continue"))):this.guard&&(t=r.wrap([new g(this.guard,t)]))),this.pattern&&t.expressions.unshift(new i(this.name,new x(""+P+"["+v+"]"))),l=[].concat(this.makeCode(h),this.pluckDirectCall(e,t)),E&&(U="\n"+f+E+";"),this.object&&(p=[this.makeCode(""+v+" in "+P)],this.own&&(d="\n"+f+"if (!"+dt("hasProp")+".call("+P+", "+v+")) continue;")),n=t.compileToFragments(at(e,{indent:f}),N),n&&n.length>0&&(n=[].concat(this.makeCode("\n"),n,this.makeCode("\n"))),[].concat(l,this.makeCode(""+(S||"")+this.tab+"for ("),p,this.makeCode(") {"+d+U),n,this.makeCode(""+this.tab+"}"+(R||"")))},t.prototype.pluckDirectCall=function(e,t){var n,s,r,a,c,l,u,p,d,f,m,b,k,g,y;for(s=[],f=t.expressions,c=p=0,d=f.length;d>p;c=++p)r=f[c],r=r.unwrapAll(),r instanceof o&&(u=r.variable.unwrapAll(),(u instanceof h||u instanceof K&&(null!=(m=u.base)?m.unwrapAll():void 0)instanceof h&&1===u.properties.length&&("call"===(b=null!=(k=u.properties[0].name)?k.value:void 0)||"apply"===b))&&(a=(null!=(g=u.base)?g.unwrapAll():void 0)||u,l=new x(e.scope.freeVariable("fn")),n=new K(l),u.base&&(y=[n,u],u.base=y[0],n=y[1]),t.expressions[c]=new o(n,r.args),s=s.concat(this.makeCode(this.tab),new i(l,a).compileToFragments(e,N),this.makeCode(";\n"))));return s},t}(z),e.Switch=q=function(e){function t(e,t,n){this.subject=e,this.cases=t,this.otherwise=n}return yt(t,e),t.prototype.children=["subject","cases","otherwise"],t.prototype.isStatement=J,t.prototype.jumps=function(e){var t,n,i,s,r,o,a;for(null==e&&(e={block:!0}),r=this.cases,i=0,s=r.length;s>i;i++)if(o=r[i],n=o[0],t=o[1],t.jumps(e))return t;return null!=(a=this.otherwise)?a.jumps(e):void 0},t.prototype.makeReturn=function(e){var t,n,i,s,o;for(s=this.cases,n=0,i=s.length;i>n;n++)t=s[n],t[1].makeReturn(e);return e&&(this.otherwise||(this.otherwise=new r([new x("void 0")]))),null!=(o=this.otherwise)&&o.makeReturn(e),this},t.prototype.compileNode=function(e){var t,n,i,s,r,o,a,c,h,l,u,p,d,f,m,b;for(c=e.indent+H,h=e.indent=c+H,o=[].concat(this.makeCode(this.tab+"switch ("),this.subject?this.subject.compileToFragments(e,L):this.makeCode("false"),this.makeCode(") {\n")),f=this.cases,a=l=0,p=f.length;p>l;a=++l){for(m=f[a],s=m[0],t=m[1],b=it([s]),u=0,d=b.length;d>u;u++)i=b[u],this.subject||(i=i.invert()),o=o.concat(this.makeCode(c+"case "),i.compileToFragments(e,L),this.makeCode(":\n"));if((n=t.compileToFragments(e,N)).length>0&&(o=o.concat(n,this.makeCode("\n"))),a===this.cases.length-1&&!this.otherwise)break;r=this.lastNonComment(t.expressions),r instanceof j||r instanceof x&&r.jumps()&&"debugger"!==r.value||o.push(i.makeCode(h+"break;\n"))}return this.otherwise&&this.otherwise.expressions.length&&o.push.apply(o,[this.makeCode(c+"default:\n")].concat(wt.call(this.otherwise.compileToFragments(e,N)),[this.makeCode("\n")])),o.push(this.makeCode(this.tab+"}")),o},t}(s),e.If=g=function(e){function t(e,t,n){this.body=t,null==n&&(n={}),this.condition="unless"===n.type?e.invert():e,this.elseBody=null,this.isChain=!1,this.soak=n.soak}return yt(t,e),t.prototype.children=["condition","body","elseBody"],t.prototype.bodyNode=function(){var e;return null!=(e=this.body)?e.unwrap():void 0},t.prototype.elseBodyNode=function(){var e;return null!=(e=this.elseBody)?e.unwrap():void 0},t.prototype.addElse=function(e){return this.isChain?this.elseBodyNode().addElse(e):(this.isChain=e instanceof t,this.elseBody=this.ensureBlock(e)),this},t.prototype.isStatement=function(e){var t;return(null!=e?e.level:void 0)===N||this.bodyNode().isStatement(e)||(null!=(t=this.elseBodyNode())?t.isStatement(e):void 0)},t.prototype.jumps=function(e){var t;return this.body.jumps(e)||(null!=(t=this.elseBody)?t.jumps(e):void 0)},t.prototype.compileNode=function(e){return this.isStatement(e)?this.compileStatement(e):this.compileExpression(e)},t.prototype.makeReturn=function(e){return e&&(this.elseBody||(this.elseBody=new r([new x("void 0")]))),this.body&&(this.body=new r([this.body.makeReturn(e)])),this.elseBody&&(this.elseBody=new r([this.elseBody.makeReturn(e)])),this},t.prototype.ensureBlock=function(e){return e instanceof r?e:new r([e])},t.prototype.compileStatement=function(e){var n,i,s,r,o,a,c;return s=et(e,"chainChild"),(o=et(e,"isExistentialEquals"))?new t(this.condition.invert(),this.elseBodyNode(),{type:"if"}).compileToFragments(e):(c=e.indent+H,r=this.condition.compileToFragments(e,L),i=this.ensureBlock(this.body).compileToFragments(at(e,{indent:c})),a=[].concat(this.makeCode("if ("),r,this.makeCode(") {\n"),i,this.makeCode("\n"+this.tab+"}")),s||a.unshift(this.makeCode(this.tab)),this.elseBody?(n=a.concat(this.makeCode(" else ")),this.isChain?(e.chainChild=!0,n=n.concat(this.elseBody.unwrap().compileToFragments(e,N))):n=n.concat(this.makeCode("{\n"),this.elseBody.compileToFragments(at(e,{indent:c}),N),this.makeCode("\n"+this.tab+"}")),n):a)},t.prototype.compileExpression=function(e){var t,n,i,s;return i=this.condition.compileToFragments(e,T),n=this.bodyNode().compileToFragments(e,C),t=this.elseBodyNode()?this.elseBodyNode().compileToFragments(e,C):[this.makeCode("void 0")],s=i.concat(this.makeCode(" ? "),n,this.makeCode(" : "),t),e.level>=T?this.wrapInBraces(s):s},t.prototype.unfoldSoak=function(){return this.soak&&this},t}(s),c={wrap:function(e,n,i){var s,a,c,l,u;return e.jumps()?e:(l=new h([],r.wrap([e])),s=[],a=e.contains(this.isLiteralArguments),a&&e.classBody&&a.error("Class bodies shouldn't reference arguments"),(a||e.contains(this.isLiteralThis))&&(u=new x(a?"apply":"call"),s=[new x("this")],a&&s.push(new x("arguments")),l=new K(l,[new t(u)])),l.noReturn=i,c=new o(l,s),n?r.wrap([c]):c)},isLiteralArguments:function(e){return e instanceof x&&"arguments"===e.value&&!e.asKey},isLiteralThis:function(e){return e instanceof x&&"this"===e.value&&!e.asKey||e instanceof h&&e.bound||e instanceof o&&e.isSuper}},pt=function(e,t,n){var i;if(i=t[n].unfoldSoak(e))return t[n]=i.body,i.body=new K(t),i},Y={"extends":function(){return"function(child, parent) { for (var key in parent) { if ("+dt("hasProp")+".call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }"},bind:function(){return"function(fn, me){ return function(){ return fn.apply(me, arguments); }; }"},indexOf:function(){return"[].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }"},hasProp:function(){return"{}.hasOwnProperty"},slice:function(){return"[].slice"}},N=1,L=2,C=3,T=4,F=5,w=6,H=" ",b="[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*",m=RegExp("^"+b+"$"),M=/^[+-]?\d+$/,E=RegExp("^(?:("+b+")\\.prototype(?:\\.("+b+")|\\[(\"(?:[^\\\\\"\\r\\n]|\\\\.)*\"|'(?:[^\\\\'\\r\\n]|\\\\.)*')\\]|\\[(0x[\\da-fA-F]+|\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\]))|("+b+")$"),k=/^['"]/,dt=function(e){var t;return t="__"+e,V.root.assign(t,Y[e]()),t},ct=function(e,t){return e=e.replace(/\n/g,"$&"+t),e.replace(/\s+$/,"")}}.call(this),t.exports}(),require["./sourcemap"]=function(){var e={},t={exports:e};return function(){var e,n;e=function(){function e(e){this.line=e,this.columns=[]}return e.prototype.add=function(e,t,n){var i,s;return s=t[0],i=t[1],null==n&&(n={}),this.columns[e]&&n.noReplace?void 0:this.columns[e]={line:this.line,column:e,sourceLine:s,sourceColumn:i}},e.prototype.sourceLocation=function(e){for(var t;!((t=this.columns[e])||0>=e);)e--;return t&&[t.sourceLine,t.sourceColumn]},e}(),n=function(){function t(){this.lines=[]}var n,i,s,r;return t.prototype.add=function(t,n,i){var s,r,o,a;return null==i&&(i={}),r=n[0],s=n[1],o=(a=this.lines)[r]||(a[r]=new e(r)),o.add(s,t,i)},t.prototype.sourceLocation=function(e){var t,n,i;for(n=e[0],t=e[1];!((i=this.lines[n])||0>=n);)n--;return i&&i.sourceLocation(t)},t.prototype.generate=function(e,t){var n,i,s,r,o,a,c,h,l,u,p,d,f,m,b,k;for(null==e&&(e={}),null==t&&(t=null),u=0,i=0,r=0,s=0,h=!1,n="",b=this.lines,a=p=0,f=b.length;f>p;a=++p)if(o=b[a])for(k=o.columns,d=0,m=k.length;m>d;d++)if(c=k[d]){for(;ue?1:0,a=(Math.abs(e)<<1)+o;a||!t;)n=a&r,a>>=s,a&&(n|=i),t+=this.encodeBase64(n);return t},n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t.prototype.encodeBase64=function(e){return n[e]||function(){throw new Error("Cannot Base64 encode value: "+e)}()},t}(),t.exports=n}.call(this),t.exports}(),require["./coffee-script"]=function(){var e={},t={exports:e};return function(){var t,n,i,s,r,o,a,c,h,l,u,p,d,f,m,b,k,g,y,v,w,T,C={}.hasOwnProperty;if(l=require("fs"),y=require("vm"),k=require("path"),s=require("child_process"),t=require("./lexer").Lexer,f=require("./parser").parser,u=require("./helpers"),i=require("./sourcemap"),e.VERSION="1.6.3",e.helpers=u,e.compile=r=function(e,t){var n,s,r,o,a,c,h,l,d,m,b,k;for(null==t&&(t={}),d=u.merge,t.sourceMap&&(l=new i),a=f.parse(p.tokenize(e,t)).compileToFragments(t),r=0,t.header&&(r+=1),t.shiftLine&&(r+=1),s=0,h="",b=0,k=a.length;k>b;b++)o=a[b],t.sourceMap&&(o.locationData&&l.add([o.locationData.first_line,o.locationData.first_column],[r,s],{noReplace:!0}),m=u.count(o.code,"\n"),r+=m,s=o.code.length-(m?o.code.lastIndexOf("\n"):0)),h+=o.code;return t.header&&(c="Generated by CoffeeScript "+this.VERSION,h="// "+c+"\n"+h),t.sourceMap?(n={js:h},n.sourceMap=l,n.v3SourceMap=l.generate(t,e),n):h},e.tokens=function(e,t){return p.tokenize(e,t)},e.nodes=function(e,t){return"string"==typeof e?f.parse(p.tokenize(e,t)):f.parse(e)},e.run=function(e,t){var n,i;return null==t&&(t={}),i=require.main,null==t.sourceMap&&(t.sourceMap=!0),i.filename=process.argv[1]=t.filename?l.realpathSync(t.filename):".",i.moduleCache&&(i.moduleCache={}),i.paths=require("module")._nodeModulePaths(k.dirname(l.realpathSync(t.filename||"."))),!u.isCoffee(i.filename)||require.extensions?(n=r(e,t),m(),g[i.filename]=n.sourceMap,i._compile(n.js,i.filename)):i._compile(e,i.filename)},e.eval=function(e,t){var n,i,s,o,a,c,h,l,u,p,d,f,m,b;if(null==t&&(t={}),e=e.trim()){if(i=y.Script){if(null!=t.sandbox){if(t.sandbox instanceof i.createContext().constructor)h=t.sandbox;else{h=i.createContext(),f=t.sandbox;for(o in f)C.call(f,o)&&(l=f[o],h[o]=l)}h.global=h.root=h.GLOBAL=h}else h=global;if(h.__filename=t.filename||"eval",h.__dirname=k.dirname(h.__filename),h===global&&!h.module&&!h.require){for(n=require("module"),h.module=d=new n(t.modulename||"eval"),h.require=b=function(e){return n._load(e,d,!0)},d.filename=h.__filename,m=Object.getOwnPropertyNames(require),u=0,p=m.length;p>u;u++)c=m[u],"paths"!==c&&(b[c]=require[c]);b.paths=d.paths=n._nodeModulePaths(process.cwd()),b.resolve=function(e){return n._resolveFilename(e,d)}}}a={};for(o in t)C.call(t,o)&&(l=t[o],a[o]=l);return a.bare=!0,s=r(e,a),h===global?y.runInThisContext(s):y.runInContext(s,h)}},d=function(e,t){var n,i,s;return i=l.readFileSync(t,"utf8"),s=65279===i.charCodeAt(0)?i.substring(1):i,n=r(s,{filename:t,sourceMap:!0,literate:u.isLiterate(t)}),g[t]=n.sourceMap,e._compile(n.js,t)},require.extensions){for(T=[".coffee",".litcoffee",".coffee.md"],v=0,w=T.length;w>v;v++)o=T[v],require.extensions[o]=d;n=require("module"),a=function(e){var t,i;for(i=k.basename(e).split("."),""===i[0]&&i.shift();i.shift();)if(t="."+i.join("."),n._extensions[t])return t;return".js"},n.prototype.load=function(e){var t;return this.filename=e,this.paths=n._nodeModulePaths(k.dirname(e)),t=a(e),n._extensions[t](this,e),this.loaded=!0}}s&&(c=s.fork,s.fork=function(e,t,n){var i;return null==t&&(t=[]),null==n&&(n={}),i=u.isCoffee(e)?"coffee":null,Array.isArray(t)||(t=[],n=t||{}),n.execPath||(n.execPath=i),c(e,t,n)}),p=new t,f.lexer={lex:function(){var e,t;return t=this.tokens[this.pos++],t?(e=t[0],this.yytext=t[1],this.yylloc=t[2],this.yylineno=this.yylloc.first_line):e="",e},setInput:function(e){return this.tokens=e,this.pos=0},upcomingInput:function(){return""}},f.yy=require("./nodes"),f.yy.parseError=function(e,t){var n;return n=t.token,e="unexpected "+(1===n?"end of input":n),u.throwSyntaxError(e,f.lexer.yylloc)},b=!1,g={},m=function(){var t;if(!b)return b=!0,t=require.main,Error.prepareStackTrace=function(t,n){var i,s,r,o,a;return o={},r=function(e,t,n){var i,s;return s=g[e],s&&(i=s.sourceLocation([t-1,n-1])),i?[i[0]+1,i[1]+1]:null},s=function(){var t,s,o;for(o=[],t=0,s=n.length;s>t&&(i=n[t],i.getFunction()!==e.run);t++)o.push(" at "+h(i,r));return o}(),""+t.name+": "+(null!=(a=t.message)?a:"")+"\n"+s.join("\n")+"\n"}},h=function(e,t){var n,i,s,r,o,a,c,h,l,u,p,d;return r=void 0,s="",e.isNative()?s="native":(e.isEval()?(r=e.getScriptNameOrSourceURL(),r||(s=""+e.getEvalOrigin()+", ")):r=e.getFileName(),r||(r=""),h=e.getLineNumber(),i=e.getColumnNumber(),u=t(r,h,i),s=u?""+r+":"+u[0]+":"+u[1]+", :"+h+":"+i:""+r+":"+h+":"+i),o=e.getFunctionName(),a=e.isConstructor(),c=!(e.isToplevel()||a),c?(l=e.getMethodName(),d=e.getTypeName(),o?(p=n="",d&&o.indexOf(d)&&(p=""+d+"."),l&&o.indexOf("."+l)!==o.length-l.length-1&&(n=" [as "+l+"]"),""+p+o+n+" ("+s+")"):""+d+"."+(l||"")+" ("+s+")"):a?"new "+(o||"")+" ("+s+")":o?""+o+" ("+s+")":s}}.call(this),t.exports}(),require["./browser"]=function(){var exports={},module={exports:exports};return function(){var CoffeeScript,compile,runScripts,__indexOf=[].indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(t in this&&this[t]===e)return t;return-1};CoffeeScript=require("./coffee-script"),CoffeeScript.require=require,compile=CoffeeScript.compile,CoffeeScript.eval=function(code,options){return null==options&&(options={}),null==options.bare&&(options.bare=!0),eval(compile(code,options))},CoffeeScript.run=function(e,t){return null==t&&(t={}),t.bare=!0,t.shiftLine=!0,Function(compile(e,t))()},"undefined"!=typeof window&&null!==window&&("undefined"!=typeof btoa&&null!==btoa&&"undefined"!=typeof JSON&&null!==JSON&&"undefined"!=typeof unescape&&null!==unescape&&"undefined"!=typeof encodeURIComponent&&null!==encodeURIComponent&&(compile=function(e,t){var n,i,s;return null==t&&(t={}),t.sourceMap=!0,t.inline=!0,s=CoffeeScript.compile(e,t),n=s.js,i=s.v3SourceMap,""+n+"\n//@ sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(i)))+"\n//@ sourceURL=coffeescript"}),CoffeeScript.load=function(e,t,n){var i;return null==n&&(n={}),n.sourceFiles=[e],i=window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLHTTP"):new window.XMLHttpRequest,i.open("GET",e,!0),"overrideMimeType"in i&&i.overrideMimeType("text/plain"),i.onreadystatechange=function(){var s;if(4===i.readyState){if(0!==(s=i.status)&&200!==s)throw new Error("Could not load "+e);if(CoffeeScript.run(i.responseText,n),t)return t()}},i.send(null)},runScripts=function(){var e,t,n,i,s,r,o;return o=window.document.getElementsByTagName("script"),t=["text/coffeescript","text/literate-coffeescript"],e=function(){var e,n,i,s; +for(s=[],e=0,n=o.length;n>e;e++)r=o[e],i=r.type,__indexOf.call(t,i)>=0&&s.push(r);return s}(),i=0,s=e.length,(n=function(){var s,r,o;return o=e[i++],s=null!=o?o.type:void 0,__indexOf.call(t,s)>=0?(r={literate:"text/literate-coffeescript"===s},o.src?CoffeeScript.load(o.src,n,r):(r.sourceFiles=["embedded"],CoffeeScript.run(o.innerHTML,r),n())):void 0})(),null},window.addEventListener?window.addEventListener("DOMContentLoaded",runScripts,!1):window.attachEvent("onload",runScripts))}.call(this),module.exports}(),require["./coffee-script"]}();"function"==typeof define&&define.amd?define(function(){return CoffeeScript}):root.CoffeeScript=CoffeeScript}(this); +} + +/* + FILE ARCHIVED ON 16:08:53 Aug 27, 2015 AND RETRIEVED FROM THE + INTERNET ARCHIVE ON 03:40:10 Jun 07, 2026. + JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. + + ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. + SECTION 108(a)(3)). +*/ +/* +playback timings (ms): + capture_cache.get: 0.742 + load_resource: 134.837 + PetaboxLoader3.resolve: 103.959 + PetaboxLoader3.datanode: 18.253 +*/ \ No newline at end of file diff --git a/web.archive.org/web/20150828053525js_/http:/void.hi-res.net/js/jquery-2.1.1.min.js b/web.archive.org/web/20150828053525js_/http:/void.hi-res.net/js/jquery-2.1.1.min.js new file mode 100644 index 000000000..0405de734 --- /dev/null +++ b/web.archive.org/web/20150828053525js_/http:/void.hi-res.net/js/jquery-2.1.1.min.js @@ -0,0 +1,31 @@ +var _____WB$wombat$assign$function_____=function(name){return (globalThis._wb_wombat && globalThis._wb_wombat.local_init && globalThis._wb_wombat.local_init(name))||globalThis[name];};if(!globalThis.__WB_pmw){globalThis.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{ +let window = _____WB$wombat$assign$function_____("window"); +let self = _____WB$wombat$assign$function_____("self"); +let document = _____WB$wombat$assign$function_____("document"); +let location = _____WB$wombat$assign$function_____("location"); +let top = _____WB$wombat$assign$function_____("top"); +let parent = _____WB$wombat$assign$function_____("parent"); +let frames = _____WB$wombat$assign$function_____("frames"); +let opener = _____WB$wombat$assign$function_____("opener"); +/*! jQuery v2.1.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ +!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.1",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="
",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+Math.random()}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b) +},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthx",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|&#?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*\s*$/g,ib={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(ob(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(ob(c,"script"),kb),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(hb,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function tb(a){var b=l,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||n("