{"id":13804237,"url":"https://github.com/audiojs/audio","last_synced_at":"2025-10-09T13:44:20.530Z","repository":{"id":52972778,"uuid":"59882536","full_name":"audiojs/audio","owner":"audiojs","description":"Class for high-level audio manipulations [NOT MAINTAINED]","archived":false,"fork":false,"pushed_at":"2024-03-15T17:44:36.000Z","size":25094,"stargazers_count":240,"open_issues_count":26,"forks_count":9,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-08-19T22:42:25.554Z","etag":null,"topics":["audio","audiojs","javascript"],"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":".github/FUNDING.yml","license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["dy","jamen","connorhartley"]}},"created_at":"2016-05-28T07:22:38.000Z","updated_at":"2025-07-02T23:32:52.000Z","dependencies_parsed_at":"2024-06-18T20:01:38.176Z","dependency_job_id":"c54df4ff-2c22-41b5-82f5-cd189c6b8fb7","html_url":"https://github.com/audiojs/audio","commit_stats":{"total_commits":271,"total_committers":4,"mean_commits":67.75,"dds":"0.21033210332103325","last_synced_commit":"95d5193e84a4f5e3cacc65261e51d39c313e27f1"},"previous_names":["jamen/node-audio"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/audiojs/audio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audiojs%2Faudio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audiojs%2Faudio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audiojs%2Faudio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audiojs%2Faudio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/audiojs","download_url":"https://codeload.github.com/audiojs/audio/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audiojs%2Faudio/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001461,"owners_count":26083102,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["audio","audiojs","javascript"],"created_at":"2024-08-04T01:00:44.266Z","updated_at":"2025-10-09T13:44:20.483Z","avatar_url":"https://github.com/audiojs.png","language":"JavaScript","readme":"# Audio [![test](https://github.com/audiojs/audio/actions/workflows/test.yml/badge.svg)](https://github.com/audiojs/audio/actions/workflows/test.yml)\n\nData structure for audio manipulations.\n\n\u003c!--\nideas:\n\t- docs\n\t- playground: editing based on settings-panel (demo)\n\t- gallery:\n\t\t- spectrum vis\n\t\t- waveform vis\n\t\t- demoscene vis\n\t\t- benchmark\n\t\t- recorder app w/ choo\n\t\t- text waveform\n\t\t- player component\n\t- downloads\n\t- size\n\t- image (just teaser/logo)\n--\u003e\n\n\u003c!--\n## Usage\n\n[![npm install audio](https://nodei.co/npm/audio.png?mini=true)](https://npmjs.org/package/audio/)\n\n```js\nconst Audio = require('audio')\n```\n--\u003e\n\n## Use-cases\n\n\u003c!--\nideas:\n- image\n  file → waveform → processed waveform → file\n- try yourself - requirebin demo with file opener and processing\n\nmvp:\n\n- stats: averages, variance\n- push data\n- delete data (splice?)\n- insert data (splice?)\n- remove Buffer, process from exports\n\n--\u003e\n\n\u003c!--\n### Load `./sample.mp3`, trim, normalize, fade in, fade out, save:\n\n```js\nlet audio = await new Audio('./sample.mp3')\n\naudio\n\t.trim()\t\t\t\t\t\t// remove silent head/tail\n\t.normalize()\t\t\t\t// make sure max amplitude is at 1\n\t.fade(.5)\t\t\t\t\t// fade in 0.5s at the beginning\n\t.fade(-3)\t\t\t\t\t// fade out 3s at the end\n\t.save('sample-edited.wav')\t// save as file\n```\n\n\n### Record 4s of mic input.\n\n```js\nnavigator.getUserMedia({audio: true}, stream =\u003e\n\tlet audio = await new Audio(stream)\n\taudio.save('my-record.wav')\n)\n```\n\n### Record and download 2 seconds of web-audio experiment\n\n```js\n//create web-audio experiment\nlet ctx = new AudioContext()\nlet osc = ctx.createOscillator()\nosc.type = 'sawtooth'\nosc.frequency.value = 440\nosc.start()\nosc.connect(ctx.destination)\n\n//record 2 seconds of web-audio experiment\nlet audio = await Audio.record(osc, 2)\naudio.save('experiment.wav')\nosc.stop()\n```\n\n### Download AudioBuffer returned from offline context\n\n```js\n//setup offline context\nlet offlineCtx = new OfflineAudioContext(2, 44100*40, 44100)\naudioNode.connect(offlineCtx)\n\n//process result of offline context\nofflineCtx.startRendering().then((audioBuffer) =\u003e {\n\tAudio(audioBuffer).save()\n})\n```\n\n\n### Montage audio\n\n```js\nlet audio = await Audio('./record.mp3')\n\n// repeat slowed down fragment\naudio.write(audio.slice(2.1, 1).scale(.9), 3.1)\n\n// delete fragment, fade out starting from 0.3s for the duration of 2.1s\naudio.remove(2.4, 2.6).fade(.3, 2.1)\n\n// insert other fragment not overwriting the existing data\naudio.insert(await Audio('./other-record.mp3'))\n\naudio.save('edited-record', 'wav')\n```\n\n### Render waveform of HTML5 `\u003caudio\u003e`\n\n```js\nimport Waveform from '@a-vis/waveform'\n\n//create waveform renderer\nlet waveform = Waveform();\n\n//get audio element\nlet audio = \u003caudio src=\"./chopin.mp3\"/\u003e\n\n//create audio holder\naudio.on('load', (err, audio) =\u003e {\n\tlet buf = audio.read(4096).getChannelData(0)\n\n\t//put left channel data to waveform renderer\n\twaveform.push(data).render()\n})\n```\n\n### Process audio with _audio-*_ modules\n\n```js\nconst Biquad = require('audio-biquad')\n\nlet lpf = new Biquad({frequency: 2000, type: 'lowpass'})\nlet audio = Audio(10).noise().process(lpf)\n```\n\n\tData handle - subaudio, for sprites etc\n\n\tLoad intro, append 1s pause, start recording. Once ended, save as file.\n\nAudio(['./intro.mp3', 1, MediaStream]).once('ready', (err, audio) =\u003e audio.save(Date() + '-recording.mp3'))\n\n\n## [API](https://github.com/audiojs/audio/blob/master/api.md)\n\n**1. [Core](#creation)**\n\n* [new Audio(src?, opts?)]()\n* [Audio.from(a, b?, c?, ..., opts?)]()\n* [Audio.load(url, opts?, cb?)]()\n* [Audio.decode(buf, opts?, cb?)]()\n* [audio.buffer]()\n* [audio.channels]()\n* [audio.duration]()\n* [audio.length]()\n* [audio.sampleRate]()\n* [audio.time(offset)]()\n* [audio.offset(time)]()\n* [Audio.gain(db)]()\n* [Audio.db(gain)]()\n* [Audio.isAudio(a)]()\n* [Audio.isEqual(a, b, ...c)]()\n* [audio.serialize(format)]()\n* [audio.save(filename, opts?)]()\n* [Audio.record(stream, opts?)]()\n* [audio.stream(dst, opts?, onend?)]()\n* [audio.clone()]()\n\n**2. [Manipulations](#manipulations)**\n\n* [audio.read(dst?, t?, dur?, opts?)]()\n* [audio.write(src|val, t?, dur?, opts?)]()\n* [audio.insert(data, t?, dur?, opts?)]()\n* [audio.slice(t?, dur?, opts?)]()\n* [audio.remove(t?, dur?, opts?)]()\n* [audio.pad(dur, opts?)]()\n* [audio.shift(amt, t?, opts?)]()\n* [audio.trim(opts?)]()\n* [audio.repeat(times, t?, dur?, opts?)]()\n* [audio.reverse(t?, dur?, opts?)]()\n* [audio.invert(t?, dur?, opts?)]()\n* [audio.gain(db, t?, dur?, opts?)]()\n* [audio.fade(t?, dur, opts?)]()\n* [audio.normalize(t?, dur?, opts?)]()\n* [audio.pan(amt, t?, dur?, opts?)]()\n* [audio.mix(audio, t?, dur?, opts?)]()\n* [audio.scale(amt, t?, opts?)]()\n* [audio.map(fn, opts?)]()\n\n**3. [Metrics](#metrics)**\n\n* [audio.statistics(t?, dur?, opts?)]()\n* [audio.bounds(t?, dur?, opts?)]()\n* [audio.spectrum(t?, dur, opts?)]()\n* [audio.cepstrum(t?, dur)]()\n* [audio.loudness(t?, dur)]()\n* [audio.memory(t?, dur, opts?)]()\n\n**4. [Playback](#playback)**\n\n* [audio.play(t?, dur?, opts?)]()\n* [audio.pause()]()\n* [audio.muted]()\n* [audio.loop]()\n* [audio.rate]()\n* [audio.volume]()\n* [audio.paused]() \u003ckbd\u003ereadonly\u003c/kbd\u003e\n* [audio.currentTime]()\n\n\n## See Also\n\n* [audiojs](https://github.com/audiojs) − open-source audio components for javascript\n* [web-audio-api](https://github.com/audiojs/web-audio-api) − web-audio-api implementation for nodejs\n\n## Related\n--\u003e\n\n\n## Alternatives\n\n* [wad](https://github.com/rserota/wad)\n* [tuna](https://github.com/Theodeus/tuna)\n* [aural](https://github.com/mjanssen/aural)\n* [pizzicato](https://github.com/alemangui/pizzicato)\n* [ciseaux](https://github.com/mohayonao/ciseaux)\n* [pjsaudio](https://github.com/corbanbrook/pjsaudio)\n* [howler](https://github.com/goldfire/howler.js)\n* [dsp.js](https://github.com/corbanbrook/dsp.js)\n* [audiolet](https://github.com/oampo/Audiolet)\n* [dynamicaudio](https://github.com/bfirsh/dynamicaudio.js)\n* [audiolib](https://github.com/jussi-kalliokoski/audiolib.js)\n* [bufaudio](https://github.com/eipark/buffaudio)\n* [crunker](https://github.com/jackedgson/crunker)\n* [sonorous](https://github.com/EkoLabs/sonorous)\n* [waud](https://github.com/waud/waud)\n* [tape.js](https://github.com/alien35/tape.js)\n\n\u003c!--\n## Credits\n\nAcknowledgement to contributors:\n\n* [Dmitry Yv](https://github.com/dy) for redesign and take on main implementation.\n* [Jamen Marz](https://github.com/jamen) for initiative and help with making decisions.\n* [Daniel Gómez Blasco](https://github.com/danigb/) for patience and work on [audio-loader](https://github.com/audiojs/audio-loader).\n* [Michael Williams](https://github.com/ahdinosaur) for audio stream insights.\n --\u003e\n\n## License\n\n[MIT](LICENSE) \u0026copy; \u003ca href=\"https://github.com/audiojs\"\u003eaudiojs\u003c/a\u003e.\n","funding_links":["https://github.com/sponsors/dy","https://github.com/sponsors/jamen","https://github.com/sponsors/connorhartley"],"categories":["Packages"],"sub_categories":["Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faudiojs%2Faudio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faudiojs%2Faudio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faudiojs%2Faudio/lists"}