{"id":24529771,"url":"https://github.com/learosema/retro-sound","last_synced_at":"2025-03-15T18:19:52.830Z","repository":{"id":208916258,"uuid":"705039462","full_name":"learosema/retro-sound","owner":"learosema","description":"8-bit style sound library based on Web Audio API","archived":false,"fork":false,"pushed_at":"2023-12-28T22:19:35.000Z","size":426,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T07:52:30.729Z","etag":null,"topics":["javascript","webaudio-api"],"latest_commit_sha":null,"homepage":"https://retro-sound.js.org","language":"TypeScript","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/learosema.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-10-14T21:21:45.000Z","updated_at":"2024-07-23T22:31:04.000Z","dependencies_parsed_at":"2023-12-22T23:28:06.084Z","dependency_job_id":null,"html_url":"https://github.com/learosema/retro-sound","commit_stats":null,"previous_names":["learosema/retro-sound"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learosema%2Fretro-sound","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learosema%2Fretro-sound/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learosema%2Fretro-sound/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learosema%2Fretro-sound/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/learosema","download_url":"https://codeload.github.com/learosema/retro-sound/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243770377,"owners_count":20345287,"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":["javascript","webaudio-api"],"created_at":"2025-01-22T07:52:37.474Z","updated_at":"2025-03-15T18:19:52.808Z","avatar_url":"https://github.com/learosema.png","language":"TypeScript","readme":"---\ntitle: Introducing retro-sound.js\nlayout: demo\n---\n\n`retro-sound.js` is Lea's new Web Audio Library for 8-bit style retro sounds, based on Web Audio API. It's an `npm install` away:\n\n```sh\nnpm install retro-sound\n```\n\nLet's have a look how it works. As it is based on Web Audio API, first thing to do is to create a new `AudioContext`.\nI also create a gain node to reduce the overall loudness a bit.\n\n```ts\nconst AC = new AudioContext();\nconst masterVolume = AC.createGain();\n\nmasterVolume.gain.setValueAtTime(0.25, 0);\nmasterVolume.connect(AC.destination);\n```\n\nMy library exports a `Sound` class which uses the Builder pattern to create sounds based on the four basic oscillators available in Web Audio API (triangle, singe, square and sawtooth). There are builder methods to add a couple of effects to the sound, like a modulator or a lowpass filter.\n\n```ts\nAC.resume();\nconst FM = new Sound(AC, 'triangle')\n  .withModulator('square', 6, 600, 'detune')\n  .withModulator('square', 12, 300, 'detune')\n  .withFilter('lowpass', 1000)\n  .toDestination(masterVolume);\n\nFM.play('A5')\n  .rampToVolumeAtTime(0, 1)\n  .waitDispose();\n```\n\nThere is also a `WhiteNoise` class. Combining it with a low-pass filter and changing it over time can create interesting effects like swooshes or percussions.\n\n```ts\nAC.resume();\n\nconst noise = new WhiteNoise(AC)\n  .withFilter('lowpass', 10000)\n  .toDestination(masterVolume);\n\nnoise.play()\n  .rampFilterFreqAtTime(1000, .25)\n  .rampToVolumeAtTime(0, .5).waitDispose();\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flearosema%2Fretro-sound","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flearosema%2Fretro-sound","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flearosema%2Fretro-sound/lists"}