{"id":15060536,"url":"https://github.com/danigb/web-audio-assembler","last_synced_at":"2025-04-10T06:11:25.276Z","repository":{"id":57151506,"uuid":"61285592","full_name":"danigb/web-audio-assembler","owner":"danigb","description":null,"archived":false,"fork":false,"pushed_at":"2016-07-21T01:04:09.000Z","size":129,"stargazers_count":10,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-03-27T00:25:11.607Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://danigb.github.io/web-audio-assembler/examples/","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/danigb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-16T10:56:05.000Z","updated_at":"2022-05-11T13:40:48.000Z","dependencies_parsed_at":"2022-09-06T16:41:00.974Z","dependency_job_id":null,"html_url":"https://github.com/danigb/web-audio-assembler","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/danigb%2Fweb-audio-assembler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Fweb-audio-assembler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Fweb-audio-assembler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Fweb-audio-assembler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danigb","download_url":"https://codeload.github.com/danigb/web-audio-assembler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248166925,"owners_count":21058481,"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":[],"created_at":"2024-09-24T23:00:09.596Z","updated_at":"2025-04-10T06:11:25.236Z","avatar_url":"https://github.com/danigb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# web-audio-assembler [![npm](https://img.shields.io/npm/v/web-audio-assembler.svg?style=flat-square)](https://www.npmjs.com/package/web-audio-assembler)\n\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) [![license](https://img.shields.io/npm/l/web-audio-assembler.svg?style=flat-square)](https://www.npmjs.com/package/web-audio-assembler)\n\n**This is not even alpha software. It's an exploration of an idea**\n\nThe aim of this project is answer the question: how to convert the highly imperative web audio api into something more compatible with a functional programming approach? In fact, the first purpose of this project is to access Web Audio API from Elm lang.\n\nThe idea it's old and popular: instead of use the API, create an object with the description of what you want and let `web-audio-assembler` to do the work.\n\nRequirements:\n\n- The node graph descriptor must be JSON serializable\n- Create Web Audio API modules delcaratively\n- Connect modules to modules or audio params\n- Update and schedule updates of those node graphs\n- Allow other software (for example, audio user interfaces) to discover properties and capabilities of node graph\n\nYou can see the [Live Examples](https://danigb.github.io/web-audio-assembler) or read the [generated API documentation](https://github.com/danigb/web-audio-assembler/blob/master/API.md)\n\n## How-to\n\n### Assemble audio nodes\n\n**Create simple nodes**\n\nUse the `assemble` function to create a function that returns a node:\n\n```js\nvar ac = new AudioContext()\nvar Assembler = require('web-audio-assembler')\n\nvar Osc = Assembler.assemble({\n  node: 'oscillator',\n  type: 'sine',\n  frequency: 400,\n  connect: '$context'\n})\nvar osc = Osc(ac)\nosc.start()\n```\n\n**Create more complex node graphs**\n\nYou can create a complex node graph by using an object. Also you can use the `connect` property to connect one node to the other:\n\n```js\nvar Synth = Assembler.assemble({\n  name: 'microsynth',\n  amp: {\n    node: 'gain',\n    connect: '$context'\n  },\n  filter: {\n    node: 'filter',\n    type: 'lowpass',\n    frequency: '500',\n    connect: 'amp'\n  },\n  osc: {\n    node: 'oscillator',\n    type: 'sine'\n    connect: 'filter'\n  }\n})\nvar synth = Synth(ac)\nsynth.osc.start(ac.currentTime)\n// or\nAssembler.start(synth, ac.currentTime) // start all startable nodes (oscillators, audio sources, envelopes)\nAssembler.stop(synth, ac.currentTime)  // stop all stoppable nodes\nAssembler.dispoase(synth) // dispose all nodes\n```\n\n### Schedule updates\n\nThere's a way to schedule updates in the node. You pass an array with update objects with the form `{ target: \u003cnode.path\u003e, time: \u003crelative time in secs\u003e, ...}`:\n\n```js\nAssembler.schedule(synth, ac.currentTime, [\n  { target: 'filter.frequency', value: 400, time: 0 },\n  { target: 'osc', trigger: 'start', time: 0 },\n  { target: 'filter.frequency', value: 400, time: 1 }\n])\n```\n\nNotice the `time` value of the update events are relative to the time passed to the `schedule` function.\n\n### TODO\n\n- Currently only Oscillator, Gain, BiquadFilter and Delay nodes are implemented.\n- Use custom nodes generators (envelopes, for example)\n- Combine node graphs\n- Describe node graphs (to generate synth UIs for example)\n- Add yours...\n\n## Run tests and examples\n\nClone this repository and run `npm install \u0026\u0026 npm test`. You can open the .html files of the `examples` directory directly (no server required).\n\n## References, links and related projects\n\n- Web Audio API, of course: https://www.w3.org/TR/webaudio/\n- clojure.spec (I'm thinking in a kind of spec of web audio)\n- A standardized framework for building and including Web Audio API instrument/effect \"patches\": https://github.com/h5bp/lazyweb-requests/issues/82\n- Flocking uses a similar approach to build synths: https://github.com/colinbdclark/flocking\n- https://github.com/charlieroberts/genish.js\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanigb%2Fweb-audio-assembler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanigb%2Fweb-audio-assembler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanigb%2Fweb-audio-assembler/lists"}