{"id":13768443,"url":"https://github.com/audiojs/audio-oscillator","last_synced_at":"2025-05-10T23:31:15.572Z","repository":{"id":57186625,"uuid":"43621649","full_name":"audiojs/audio-oscillator","owner":"audiojs","description":"Generate periodic oscillation into an array/audiobuffer","archived":true,"fork":false,"pushed_at":"2020-05-25T04:08:32.000Z","size":62,"stargazers_count":27,"open_issues_count":4,"forks_count":2,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-04-26T11:21:06.653Z","etag":null,"topics":["audiojs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/audiojs.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-04T01:55:10.000Z","updated_at":"2024-01-09T10:25:20.000Z","dependencies_parsed_at":"2022-08-28T10:51:37.373Z","dependency_job_id":null,"html_url":"https://github.com/audiojs/audio-oscillator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audiojs%2Faudio-oscillator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audiojs%2Faudio-oscillator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audiojs%2Faudio-oscillator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audiojs%2Faudio-oscillator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/audiojs","download_url":"https://codeload.github.com/audiojs/audio-oscillator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253497296,"owners_count":21917683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audiojs"],"created_at":"2024-08-03T16:01:21.479Z","updated_at":"2025-05-10T23:31:14.936Z","avatar_url":"https://github.com/audiojs.png","language":"JavaScript","funding_links":[],"categories":["Sound creation"],"sub_categories":["Low frequency oscillators (\"LFOs\"):"],"readme":"# audio-oscillator [![Build Status](https://travis-ci.org/audiojs/audio-oscillator.svg?branch=master)](https://travis-ci.org/audiojs/audio-oscillator) [![unstable](https://img.shields.io/badge/stability-unstable-green.svg)](http://github.com/badges/stability-badges) [![Greenkeeper badge](https://badges.greenkeeper.io/audiojs/audio-oscillator.svg)](https://greenkeeper.io/)\n\nGenerate periodic oscillation data.\n\n## Usage\n\n[![$ npm install audio-oscillator](http://nodei.co/npm/audio-oscillator.png?mini=true)](http://npmjs.org/package/audio-oscillator)\n\n```js\nconst oscillate = require('audio-oscillator/sine')\nconst output = require('web-audio-write')()\n\n// render sine sound stream\nlet buf = new AudioBuffer({ channels: 2, sampleRate: 44100, length: 1024 })\n;(async function frame() {\n  await output(oscillate(buf, { frequency: 440 })))\n  frame()\n})()\n```\n\n\n## API\n\n### `let array = oscillate.\u003cwaveform\u003e(length|dst, frequency=440|options?)`\n\nGenerate [periodic-function](https://ghub.io/periodic-function) `waveform` samples into a `dst` float array / array of arrays / _AudioBuffer_. If `length` is provided, a new mono `array` is created. The phase of consequently generated chunks is aligned, if the same array is passed multiple times.\n\n```js\nlet oscillate = require('audio-oscillator')\n\nlet samples = new Float64Array(1024)\n\noscillate.sine(samples, 440)\n\n// output array has additional properties of the data\n// samples.phase, samples.frequency, samples.detune, samples.sampleRate\n\n// next data phase is aligned with the previous data\noscillate.sine(samples)\n```\n\n#### `options`\n\nProperty | Default | Meaning\n---|---|---\n`frequency`, `f` | `440` | Frequency of oscillations, in Hz.\n`detune` | `0` | Detune of oscillations `-100...+100`, in cents.\n`phase`, `t` | `0` | Normalized initial phase of waveform, `0..1`.\n`sampleRate`, `rate` | `44100` | Sample rate of output data.\n\n\n#### `waveform`\n\nAvailable waveforms with their additional options:\n\nType | Waveshape | Parameters\n---|---|---\n`'sin'` | ![sine](https://raw.githubusercontent.com/dfcreative/periodic-function/master/img/sine.png) |\n`'cos'` | ![cosine](https://raw.githubusercontent.com/dfcreative/periodic-function/master/img/cosine.png) |\n`'saw'` | ![sawtooth](https://raw.githubusercontent.com/dfcreative/periodic-function/master/img/sawtooth.png) | `inverse=false`\n`'tri'` | ![triangle](https://raw.githubusercontent.com/dfcreative/periodic-function/master/img/triangle.png) | `ratio=0.5`\n`'rect'` | ![square](https://raw.githubusercontent.com/dfcreative/periodic-function/master/img/square.png) | `ratio=0.5`\n`'series'` | ![fourier](https://raw.githubusercontent.com/dfcreative/periodic-function/master/img/fourier.png) | `real=[0, 1]`, `imag=[0, 0]`, `normalize=true`\n`'clausen'` | ![clausen](https://raw.githubusercontent.com/dfcreative/periodic-function/master/img/clausen.png) | `limit=10`\n`'step'` | ![step](https://raw.githubusercontent.com/dfcreative/periodic-function/master/img/step.png) | `samples=10`\n\n\n## Related\n\n* [periodic-function](https://github.com/scijs/periodic-function) − a collection of periodic functions.\n\n## License\n\n© 2017 Dmitry Yv. MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faudiojs%2Faudio-oscillator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faudiojs%2Faudio-oscillator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faudiojs%2Faudio-oscillator/lists"}