{"id":15658423,"url":"https://github.com/fritzo/wavencoderjs","last_synced_at":"2025-06-30T12:35:12.066Z","repository":{"id":2257896,"uuid":"3213426","full_name":"fritzo/wavencoderjs","owner":"fritzo","description":"A fast cross-browser riff wave encoder for real-time audio synthesis in HTML5","archived":false,"fork":false,"pushed_at":"2012-02-15T22:41:49.000Z","size":108,"stargazers_count":23,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-05T16:55:14.371Z","etag":null,"topics":["html5-audio","javascript","web-worker"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fritzo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-01-18T23:09:48.000Z","updated_at":"2025-04-28T03:34:05.000Z","dependencies_parsed_at":"2022-09-02T03:50:25.757Z","dependency_job_id":null,"html_url":"https://github.com/fritzo/wavencoderjs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fritzo/wavencoderjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fritzo%2Fwavencoderjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fritzo%2Fwavencoderjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fritzo%2Fwavencoderjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fritzo%2Fwavencoderjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fritzo","download_url":"https://codeload.github.com/fritzo/wavencoderjs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fritzo%2Fwavencoderjs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262774181,"owners_count":23362266,"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":["html5-audio","javascript","web-worker"],"created_at":"2024-10-03T13:12:25.733Z","updated_at":"2025-06-30T12:35:11.942Z","avatar_url":"https://github.com/fritzo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WavEncoder #\n\nWavEncoder is a fast cross-browser riff wave encoder for real-time audio synthesis in HTML5.\nWorks in Web Workers and in the main window\n(in contrast to encoders using window.btoa).\n\nDual licensed under the [MIT](http://www.opensource.org/licenses/MIT)\nor [GPL Version 2](http://www.opensource.org/licenses/GPL-2.0) licenses.\n\n## Examples ##\n\nTo play 1 sec of noise in the main window, we can\n\n    \u003cscript type='text/javascript' src='wavencoder.js'\u003e\u003c/script\u003e\n    \u003cscript type='text/javascript'\u003e\n\n      var samples = [];\n      for (var t = 0; t \u003c 22050; ++t) {\n        samples[t] = 2 * Math.random() - 1;  // in the interval [-1,1]\n      }\n\n      var datauri = WavEncoder.encode(samples);\n      var audio = new Audio(datauri);\n\n      document.onload(function(){ audio.play(); });\n\n    \u003c/script\u003e\n\nWavEncoder objects are optimized to create many samples of the same length.\nA typical use case is to generate a set of tones, say in a web worker\n\n    includeScripts('wavencoder.js');\n    \n    var sampleRateHz = 44100;\n    var numSamples = 1 * sampleRateHz;                 // 1 sec\n    var baseFreq = 2 * Math.PI * 27.5 / sampleRateHz;  // A0\n\n    var wavEncoder = new WavEncoder(numSamples, {sampleRateHz: sampleRateHz});\n\n    var tones = [];\n    var samples = [];\n    for (var n = 0; n \u003c 88; ++n) {\n\n      var freq = baseFreq * Math.pow(2, n/12);\n      for (var t = 0; t \u003c numSamples; ++t) {\n        samples[t] = Math.sin(freq * t);\n      }\n\n      tones[n] = wavEncoder.encode(samples);\n    }\n\n    postMessage(tones);\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffritzo%2Fwavencoderjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffritzo%2Fwavencoderjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffritzo%2Fwavencoderjs/lists"}