{"_id":"periodic-function","_rev":"13-5213325299e4e9595c58f4fb473995b5","name":"periodic-function","dist-tags":{"latest":"2.1.2"},"versions":{"1.0.0":{"name":"periodic-function","version":"1.0.0","keywords":["periodic","math","sine","cosine","sawtooth"],"author":{"name":"Dima Yv","email":"dfcreative@gmail.com"},"license":"MIT","_id":"periodic-function@1.0.0","maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"}],"homepage":"https://github.com/dfcreative/periodic-function#readme","bugs":{"url":"https://github.com/dfcreative/periodic-function/issues"},"dist":{"shasum":"8431a8586941b4329c098a37aff38707b4db16c4","tarball":"https://registry.npmjs.org/periodic-function/-/periodic-function-1.0.0.tgz","integrity":"sha512-rojXmRPK4rbMpABDoMl9t3wyQhhaLnegGxo7skRh/sNA5Gnm3ldPTYQAWPH3+diz5e83zTXSi6f1upOay2aShw==","signatures":[{"sig":"MEQCIBENTjXkntkFzQ8qn08EXwna+V21WQ4I0j3svRcfwpj+AiAh20T9DStkW842AAwR7WkFuwH/CQICaDKxhvRtgQu6tg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"8431a8586941b4329c098a37aff38707b4db16c4","gitHead":"2db00d814d86c643c67949d4e4e454e842816deb","scripts":{"test":"node test"},"_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"repository":{"url":"git+https://github.com/dfcreative/periodic-function.git","type":"git"},"_npmVersion":"4.6.1","description":"Collection of periodic functions","directories":{},"_nodeVersion":"8.1.2","devDependencies":{"tape":"^4.6.3","almost-equal":"^1.1.0"},"_npmOperationalInternal":{"tmp":"tmp/periodic-function-1.0.0.tgz_1498117199800_0.33835220243781805","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"periodic-function","version":"1.1.0","keywords":["periodic","math","sine","cosine","sawtooth","dsp"],"author":{"name":"Dima Yv","email":"dfcreative@gmail.com"},"license":"MIT","_id":"periodic-function@1.1.0","maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"}],"homepage":"https://github.com/dfcreative/periodic-function#readme","bugs":{"url":"https://github.com/dfcreative/periodic-function/issues"},"dist":{"shasum":"0cc9d1b2a32d6f4509871399247d347c10719e38","tarball":"https://registry.npmjs.org/periodic-function/-/periodic-function-1.1.0.tgz","integrity":"sha512-vYoyl8a7LjSnPujyhC7lntHI1DxeHiZxsVSdPMtOdJOY+u99CC1Zs7ZjWfM9cXwy4e5fhS+/Ru4h9cM3VWwKBA==","signatures":[{"sig":"MEQCIBZN+WQqPBo/TVN2JQod3iDUBd1ezunJ9fDHSsBpH/vzAiAXNHETJk1VMPTwu6ERrQNBhmM1P0PCiVFbPm38faC01g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"0cc9d1b2a32d6f4509871399247d347c10719e38","gitHead":"65685423e184fa1d0647035e69afbed991509b3f","scripts":{"test":"node test --harmony"},"_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"repository":{"url":"git+https://github.com/dfcreative/periodic-function.git","type":"git"},"_npmVersion":"4.6.1","description":"Collection of periodic functions","directories":{},"_nodeVersion":"8.1.2","devDependencies":{"tape":"^4.6.3","almost-equal":"^1.1.0"},"_npmOperationalInternal":{"tmp":"tmp/periodic-function-1.1.0.tgz_1498153352358_0.43215236184187233","host":"s3://npm-registry-packages"}},"1.1.1":{"name":"periodic-function","version":"1.1.1","keywords":["periodic","math","sine","cosine","sawtooth","dsp"],"author":{"name":"Dima Yv","email":"dfcreative@gmail.com"},"license":"MIT","_id":"periodic-function@1.1.1","maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"}],"homepage":"https://github.com/dfcreative/periodic-function#readme","bugs":{"url":"https://github.com/dfcreative/periodic-function/issues"},"dist":{"shasum":"f3f40ebe9b2645390fd0543225b337910af95128","tarball":"https://registry.npmjs.org/periodic-function/-/periodic-function-1.1.1.tgz","integrity":"sha512-iwNaVZukfPOZ9l2hDtZv8WrucpCOKn13cPy/CibbLfJsfmBkVTwnjJfFjA20rPOEveyteTNLjNxviSz5w6Q0Aw==","signatures":[{"sig":"MEUCIApHXoEjkJq8aI05fRhV/SZ1rF+jMxeEpj2pl1ewUPWvAiEAx5QPCYLyzNU5dOUVQ59+7m798AK1/GKWVE7xEVSAtGM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"f3f40ebe9b2645390fd0543225b337910af95128","gitHead":"fd8ef28e6d944f5c8d2421d443e08bc83d6a1298","scripts":{"test":"node test --harmony"},"_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"repository":{"url":"git+https://github.com/dfcreative/periodic-function.git","type":"git"},"_npmVersion":"4.6.1","description":"Collection of periodic functions","directories":{},"_nodeVersion":"8.1.2","devDependencies":{"tape":"^4.6.3","almost-equal":"^1.1.0"},"_npmOperationalInternal":{"tmp":"tmp/periodic-function-1.1.1.tgz_1498768274757_0.02057679183781147","host":"s3://npm-registry-packages"}},"1.1.2":{"name":"periodic-function","version":"1.1.2","keywords":["periodic","math","sine","cosine","sawtooth","dsp"],"author":{"name":"Dima Yv","email":"dfcreative@gmail.com"},"license":"MIT","_id":"periodic-function@1.1.2","maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"}],"homepage":"https://github.com/dfcreative/periodic-function#readme","bugs":{"url":"https://github.com/dfcreative/periodic-function/issues"},"dist":{"shasum":"5d4ed809fc53cf8c4b430071d92d07de52918bb5","tarball":"https://registry.npmjs.org/periodic-function/-/periodic-function-1.1.2.tgz","integrity":"sha512-IQC+Uxuio5/lnGZcN1iBznvFV/ngStmiX7YAttGn1S/6RfIMeSeiL/npVsFdeQIa5BUc5P92HveWMc87Xaq0vQ==","signatures":[{"sig":"MEYCIQDZt1jfO6eIXgRHbO17PcdqizCyxRhchawY+lXorXAXPAIhAIAdUmjWKgRaY+SCjO88MZAgh52iKCgG3xaOFHr9KiUl","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"5d4ed809fc53cf8c4b430071d92d07de52918bb5","gitHead":"0b0c2318ac008c9e8772b2b2687b6981b42c5db7","scripts":{"test":"node test --harmony"},"_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"repository":{"url":"git+https://github.com/dfcreative/periodic-function.git","type":"git"},"_npmVersion":"4.6.1","description":"Collection of periodic functions","directories":{},"_nodeVersion":"8.1.2","devDependencies":{"tape":"^4.6.3","almost-equal":"^1.1.0"},"_npmOperationalInternal":{"tmp":"tmp/periodic-function-1.1.2.tgz_1498768576199_0.4154905106406659","host":"s3://npm-registry-packages"}},"1.1.3":{"name":"periodic-function","version":"1.1.3","keywords":["periodic","math","sine","cosine","sawtooth","dsp"],"author":{"name":"Dima Yv","email":"dfcreative@gmail.com"},"license":"MIT","_id":"periodic-function@1.1.3","maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"}],"homepage":"https://github.com/dfcreative/periodic-function#readme","bugs":{"url":"https://github.com/dfcreative/periodic-function/issues"},"dist":{"shasum":"b8458427b7e1bff53bf20f0a9c82340ed05beb8d","tarball":"https://registry.npmjs.org/periodic-function/-/periodic-function-1.1.3.tgz","integrity":"sha512-LU84cMdV39j6c5Nt84Chq/mLO+vkmdaXWdwCswvDbxNc8kORrDkRDGYMEONQUVRDAfJoek8ZBmSWfo8yeeYfnQ==","signatures":[{"sig":"MEYCIQDNI1xnT+AvwKBVvJoh1WRPM53WRd0hIRuVCAledj1CogIhAN5YQZxzaca4PmGtEM5WYpa9oX8zylti4sRpSVMCISvN","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"b8458427b7e1bff53bf20f0a9c82340ed05beb8d","gitHead":"64705b060710a7489b81e49c918b0f8e6786accb","scripts":{"test":"node test --harmony"},"_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"repository":{"url":"git+https://github.com/dfcreative/periodic-function.git","type":"git"},"_npmVersion":"4.6.1","description":"Collection of periodic functions","directories":{},"_nodeVersion":"8.1.2","devDependencies":{"tape":"^4.6.3","almost-equal":"^1.1.0"},"_npmOperationalInternal":{"tmp":"tmp/periodic-function-1.1.3.tgz_1498778088005_0.3521595657803118","host":"s3://npm-registry-packages"}},"1.1.4":{"name":"periodic-function","version":"1.1.4","keywords":["periodic","math","sine","cosine","sawtooth","dsp"],"author":{"name":"Dima Yv","email":"dfcreative@gmail.com"},"license":"MIT","_id":"periodic-function@1.1.4","maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"}],"homepage":"https://github.com/dfcreative/periodic-function#readme","bugs":{"url":"https://github.com/dfcreative/periodic-function/issues"},"dist":{"shasum":"53bab04ecd3d2ac767aca8798d2e4bbd2b8b9433","tarball":"https://registry.npmjs.org/periodic-function/-/periodic-function-1.1.4.tgz","integrity":"sha512-1eQ9qUKLZEasfECQdK2F3ZipWJfxj3ORtahwDvX+B+ldTsJxZXxwcCjYCBOBsI7n3ccv6+kZuMoPRQMQiIbx7Q==","signatures":[{"sig":"MEQCIDw9ETRk1hla1ggYjvUghR9SB0t7nwYSWcquXiy719gnAiA6eniuWewe8gTnXLwsbb4YGv77LwEVQQ1poZpHyT0iew==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"53bab04ecd3d2ac767aca8798d2e4bbd2b8b9433","gitHead":"bdc6d433cbc8079ba6d81848e010ed47215bbf2f","scripts":{"test":"node test --harmony"},"_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"repository":{"url":"git+https://github.com/dfcreative/periodic-function.git","type":"git"},"_npmVersion":"4.6.1","description":"Collection of periodic functions","directories":{},"_nodeVersion":"8.1.2","devDependencies":{"tape":"^4.6.3","almost-equal":"^1.1.0"},"_npmOperationalInternal":{"tmp":"tmp/periodic-function-1.1.4.tgz_1498841105383_0.21825875341892242","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"periodic-function","version":"2.0.0","keywords":["periodic","waveform","sine","sawtooth","square","triangle","fourier","wavetable","dsp","audio"],"author":{"name":"Dmitry Iv","email":"dfcreative@gmail.com"},"license":"MIT","_id":"periodic-function@2.0.0","maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"homepage":"https://github.com/audiojs/periodic-function#readme","bugs":{"url":"https://github.com/audiojs/periodic-function/issues"},"dist":{"shasum":"7772aab8c110f7076a78c3d3a6d7178e583c67a7","tarball":"https://registry.npmjs.org/periodic-function/-/periodic-function-2.0.0.tgz","fileCount":20,"integrity":"sha512-26h/6E0hRU2R6Q68Ni6TJGkOHjx7/HjHo96MIKaPxYDSDhNTS2oyQolYtMnOCqfrMWJ0aCgTfjuk5sJY+wQwfg==","signatures":[{"sig":"MEQCIEj7tEg4NHuP6o+aZLKffWVa/vhcXrHj419Vi37I0sglAiBl9QssW0uY3dFTbOweZg30DKQ7B2RiDE5wzlbi086b4A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17787},"type":"module","exports":{".":"./index.js","./sine":"./sine.js","./step":"./step.js","./noise":"./noise.js","./pulse":"./pulse.js","./cosine":"./cosine.js","./square":"./square.js","./clausen":"./clausen.js","./fourier":"./fourier.js","./sawtooth":"./sawtooth.js","./triangle":"./triangle.js","./trapezoid":"./trapezoid.js","./wavetable":"./wavetable.js","./interpolate":"./interpolate.js"},"gitHead":"9bd4bb8fd1665ba5eac90648ec7716b75b45138a","scripts":{"test":"node test.js","plots":"node generate-plots.js"},"_npmUser":{"name":"dy","email":"df.creative@gmail.com"},"repository":{"url":"git+https://github.com/audiojs/periodic-function.git","type":"git"},"_npmVersion":"11.11.0","description":"Periodic waveform functions — phase normalized to [0,1]","directories":{},"_nodeVersion":"25.8.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/periodic-function_2.0.0_1774930819024_0.4164066378661857","host":"s3://npm-registry-packages-npm-production"}},"2.1.0":{"name":"periodic-function","version":"2.1.0","keywords":["periodic","waveform","sine","sawtooth","square","triangle","fourier","wavetable","dsp","audio"],"author":{"name":"Dmitry Iv","email":"dfcreative@gmail.com"},"license":"MIT","_id":"periodic-function@2.1.0","maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"homepage":"https://github.com/audiojs/periodic-function#readme","bugs":{"url":"https://github.com/audiojs/periodic-function/issues"},"dist":{"shasum":"2c942d60fe953097551aa078e858e632660b9a85","tarball":"https://registry.npmjs.org/periodic-function/-/periodic-function-2.1.0.tgz","fileCount":20,"integrity":"sha512-hUuKIlMwYIPZiao76mWRw25/nGkB6kBjgVeBdAqLFWZh0u7KaZpEyPn5VGFsId4U6Ytu5+1WQUNp+OsHdgKFBg==","signatures":[{"sig":"MEUCIQCOODM9RT4u9wwCxLyDYAL8RjwinhDF2FpSfQOAIfOMtwIgPpF5i2jB4RoRH/c8GRrhdapJ0I6aeQmtzUS2VM3AZp8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17320},"type":"module","gitHead":"5f61be23195a2242e12bc9318ef07ecea1cc6108","scripts":{"test":"node test.js","plots":"node generate-plots.js"},"_npmUser":{"name":"dy","email":"df.creative@gmail.com"},"repository":{"url":"git+https://github.com/audiojs/periodic-function.git","type":"git"},"_npmVersion":"11.11.0","description":"Periodic waveform functions — phase normalized to [0,1]","directories":{},"_nodeVersion":"25.8.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/periodic-function_2.1.0_1774959379999_0.3887385733715061","host":"s3://npm-registry-packages-npm-production"}},"2.1.1":{"name":"periodic-function","version":"2.1.1","keywords":["periodic","waveform","sine","sawtooth","square","triangle","fourier","wavetable","dsp","audio"],"author":{"name":"Dmitry Iv","email":"dfcreative@gmail.com"},"license":"MIT","_id":"periodic-function@2.1.1","maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"homepage":"https://github.com/audiojs/periodic-function#readme","bugs":{"url":"https://github.com/audiojs/periodic-function/issues"},"dist":{"shasum":"bbe74b1072774c7d2a6a69b4cd3955598e9ebc63","tarball":"https://registry.npmjs.org/periodic-function/-/periodic-function-2.1.1.tgz","fileCount":16,"integrity":"sha512-sO1ZJ09R3j8Kk/MJJVOuZgsF+PdGaI1W+pVpTlHuyP+ZJs9vrwN5Ovr8t2kLXD+4ylGd8W8rtmLz0mC5OFzPYA==","signatures":[{"sig":"MEUCIAU1acHEqH0PFd7SG4BKTJlcZm0Bsnd08R/l5jA0Da3zAiEAoGSGzbauUY7109RZB4dM7NY+Rc96ZDPjLx9l9wsLdPQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9422},"main":"index.js","type":"module","exports":{".":"./index.js","./*.js":"./*.js","./package.json":"./package.json"},"gitHead":"a8289539f9d474aba155c2cc3531969e59273f47","scripts":{"test":"node test.js","plots":"node generate-plots.js"},"_npmUser":{"name":"dy","email":"df.creative@gmail.com"},"repository":{"url":"git+https://github.com/audiojs/periodic-function.git","type":"git"},"_npmVersion":"11.12.1","description":"Periodic waveform functions — phase normalized to [0,1]","directories":{},"sideEffects":false,"_nodeVersion":"25.9.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/periodic-function_2.1.1_1783632893629_0.4501140651088793","host":"s3://npm-registry-packages-npm-production"}},"2.1.2":{"name":"periodic-function","version":"2.1.2","type":"module","description":"Periodic waveform functions — phase normalized to [0,1]","main":"index.js","exports":{".":"./index.js","./*.js":"./*.js","./package.json":"./package.json"},"sideEffects":false,"scripts":{"test":"node test.js","plots":"node generate-plots.js"},"repository":{"type":"git","url":"git+https://github.com/audiojs/periodic-function.git"},"keywords":["periodic","waveform","sine","sawtooth","square","triangle","fourier","wavetable","dsp","audio"],"author":{"name":"Dmitry Iv","email":"dfcreative@gmail.com"},"license":"MIT","funding":"https://github.com/sponsors/audiojs","gitHead":"a8289539f9d474aba155c2cc3531969e59273f47","_id":"periodic-function@2.1.2","bugs":{"url":"https://github.com/audiojs/periodic-function/issues"},"homepage":"https://github.com/audiojs/periodic-function#readme","_nodeVersion":"25.9.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-/plcq6tcduzQC4nnjDKv6g4J8wwTfGghWCKC5puj4wPQ4FcDxRmaJ0V8yIoJ1Vd1xE6tYwx0T3qO6V9zsYIyMQ==","shasum":"91992e755fd46dcb8040bf707b0044c623bbf3ea","tarball":"https://registry.npmjs.org/periodic-function/-/periodic-function-2.1.2.tgz","fileCount":16,"unpackedSize":9474,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCvMJuzWkEFz8doLEQBjZdhxpgHwJ4ze1WzzdiribxcrAIgcPULEhfbtyXCe2wERbR/0mCBELCuA78vrDjvjKAeVVs="}]},"_npmUser":{"name":"dy","email":"df.creative@gmail.com"},"directories":{},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/periodic-function_2.1.2_1783732009596_0.13745336501664962"},"_hasShrinkwrap":false}},"time":{"created":"2017-06-22T07:40:02.549Z","modified":"2026-07-11T01:06:49.802Z","1.0.0":"2017-06-22T07:40:02.549Z","1.1.0":"2017-06-22T17:42:33.259Z","1.1.1":"2017-06-29T20:31:15.764Z","1.1.2":"2017-06-29T20:36:17.124Z","1.1.3":"2017-06-29T23:14:48.911Z","1.1.4":"2017-06-30T16:45:06.322Z","2.0.0":"2026-03-31T04:20:19.175Z","2.1.0":"2026-03-31T12:16:20.151Z","2.1.1":"2026-07-09T21:34:53.782Z","2.1.2":"2026-07-11T01:06:49.718Z"},"bugs":{"url":"https://github.com/audiojs/periodic-function/issues"},"author":{"name":"Dmitry Iv","email":"dfcreative@gmail.com"},"license":"MIT","homepage":"https://github.com/audiojs/periodic-function#readme","keywords":["periodic","waveform","sine","sawtooth","square","triangle","fourier","wavetable","dsp","audio"],"repository":{"type":"git","url":"git+https://github.com/audiojs/periodic-function.git"},"description":"Periodic waveform functions — phase normalized to [0,1]","maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"readme":"# periodic-function\n\nPeriodic waveform functions. Phase `t` is normalized to `[0, 1]` — one full turn.\n\n```\nnpm install periodic-function\n```\n\n```js\nimport { sine, square, wavetable } from 'periodic-function'\n\nsine(0.25)          // 1  (peak)\nsquare(0.75)        // -1 (low)\nwavetable(null, [0, 1, 0, 0.5])  // Float32Array wavetable from Fourier coefficients\n```\n\n## API\n\nAll functions take phase `t ∈ [0, 1]` as first argument. Values outside `[0, 1]` wrap correctly.\n\n| | Function | Description |\n|:---:|---|---|\n| | **Waveforms** | |\n| <img src=\"img/sine.svg\" width=\"200\" height=\"60\" alt=\"sine\"> | `sine(t, phase=0)` | Sine wave. `phase=0.25` gives cosine. |\n| <img src=\"img/cosine.svg\" width=\"200\" height=\"60\" alt=\"cosine\"> | `cosine(t, phase=0)` | Cosine wave. Equivalent to `sine(t, 0.25)`. |\n| <img src=\"img/sawtooth.svg\" width=\"200\" height=\"60\" alt=\"sawtooth\"> | `sawtooth(t)` | Descending ramp: 1 at t=0, −1 approaching t=1. For ascending ramp use `triangle(t, 0)`. |\n| <img src=\"img/square.svg\" width=\"200\" height=\"60\" alt=\"square\"> | `square(t, duty=0.5)` | Square wave. `duty` = fraction of period spent high. |\n| <img src=\"img/triangle.svg\" width=\"200\" height=\"60\" alt=\"triangle\"> | `triangle(t, ratio=0.5)` | Triangle wave. `ratio` = peak position (0 = ascending ramp, 1 = descending ramp). |\n| <img src=\"img/trapezoid.svg\" width=\"200\" height=\"60\" alt=\"trapezoid\"> | `trapezoid(t, p1=0.25, p2=0.5, p3=0.75)` | Trapezoid wave. Rise ends at `p1`, fall starts at `p2`, fall ends at `p3`. Generalizes square and triangle. |\n| <img src=\"img/pulse.svg\" width=\"200\" height=\"60\" alt=\"pulse\"> | `pulse(t, width=0)` | Dirac-like pulse: 1 at t=0, 0 elsewhere. `width` extends the high region. |\n| <img src=\"img/clausen.svg\" width=\"200\" height=\"60\" alt=\"clausen\"> | `clausen(t, harmonics=10)` | [Clausen function](https://en.wikipedia.org/wiki/Clausen_function): Σ sin(kθ)/k². |\n| <img src=\"img/noise.svg\" width=\"200\" height=\"60\" alt=\"noise\"> | `noise(t)` | Periodic noise — repeating random buffer. |\n| | **Fourier / Wavetable** | |\n| <img src=\"img/fourier.svg\" width=\"200\" height=\"60\" alt=\"fourier\"> | `fourier(t, real, imag)` | Evaluate one sample from Fourier coefficients. `real[k]` and `imag[k]` are cosine/sine amplitudes for harmonic `k`. Index 0 is DC, 1 is fundamental. |\n| <img src=\"img/wavetable.svg\" width=\"200\" height=\"60\" alt=\"wavetable\"> | `wavetable(real, imag, {size=8192, normalize=true})` | Build a `Float32Array` wavetable from Fourier coefficients. Used for `AudioContext.createPeriodicWave`. |\n| | **Lookup** | |\n| <img src=\"img/interpolate.svg\" width=\"200\" height=\"60\" alt=\"interpolate\"> | `interpolate(t, samples)` | Linearly interpolate between samples, treating them as one period. |\n| <img src=\"img/step.svg\" width=\"200\" height=\"60\" alt=\"step\"> | `step(t, samples)` | Step lookup — nearest sample, no interpolation. |\n\n## Examples\n\n```js\n// Cosine as a phase-shifted sine\nsine(0, 0.25)     // 1  (same as cosine(0))\n\n// Square wave with 10% duty cycle\nsquare(0.05, 0.1) // 1\nsquare(0.15, 0.1) // -1\n\n// Triangle with peak at 0.25 (asymmetric)\ntriangle(0.25, 0.25) // -1  (valley, since peak is at t=0)\n\n// Trapezoid as a square with soft edges\ntrapezoid(t, 0.05, 0.5, 0.55)\n\n// Fourier series: pure sine\nfourier(0.25, null, [0, 1])  // 1\n\n// Wavetable for Web Audio API PeriodicWave\nconst real = new Float32Array(64)\nconst imag = new Float32Array(64)\nfor (let k = 1; k < 64; k += 2) imag[k] = 4 / (Math.PI * k)  // square wave\nconst table = wavetable(real, imag)  // Float32Array[8192], normalized to ±1\n```\n\n## Related\n\n- [web-audio-api](https://github.com/audiojs/web-audio-api) — uses `wavetable()` for `PeriodicWave`\n- [MDN: createPeriodicWave](https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createPeriodicWave)\n- [List of periodic functions](https://en.wikipedia.org/wiki/List_of_periodic_functions)\n\n## License\n\nMIT © Dmitry Iv\n\n<p align=center><a href=\"https://github.com/krishnized/license/\">ॐ</a></p>\n","readmeFilename":"readme.md"}