{"id":13504369,"url":"https://github.com/jaggad/crunker","last_synced_at":"2025-03-29T21:30:33.648Z","repository":{"id":20230897,"uuid":"89203822","full_name":"jaggad/crunker","owner":"jaggad","description":"Simple way to merge or concatenate audio files with the Web Audio API. ","archived":false,"fork":false,"pushed_at":"2024-03-16T05:59:55.000Z","size":3297,"stargazers_count":444,"open_issues_count":9,"forks_count":60,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-23T00:06:55.755Z","etag":null,"topics":["audiobuffer","concatenate","es2015","es6","javascript","webaudio-api"],"latest_commit_sha":null,"homepage":"https://jaggad.github.io/crunker/examples/client/","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/jaggad.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-24T06:08:49.000Z","updated_at":"2025-03-15T00:30:33.000Z","dependencies_parsed_at":"2023-10-10T17:14:14.787Z","dependency_job_id":"826bf09b-bcf1-4775-80f4-83668849cabf","html_url":"https://github.com/jaggad/crunker","commit_stats":{"total_commits":92,"total_committers":18,"mean_commits":5.111111111111111,"dds":0.6630434782608696,"last_synced_commit":"d41c2ad3ad5af43d978df8f94c3da4013e5efd83"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaggad%2Fcrunker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaggad%2Fcrunker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaggad%2Fcrunker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaggad%2Fcrunker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaggad","download_url":"https://codeload.github.com/jaggad/crunker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246249130,"owners_count":20747164,"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":["audiobuffer","concatenate","es2015","es6","javascript","webaudio-api"],"created_at":"2024-08-01T00:00:35.578Z","updated_at":"2025-03-29T21:30:33.194Z","avatar_url":"https://github.com/jaggad.png","language":"TypeScript","readme":"# Crunker\n\nSimple way to merge, concatenate, play, export and download audio files with the Web Audio API.\n\n- No dependencies\n- Tiny 2kB gzipped\n- Written in Typescript\n\n[View online demos](https://jaggad.github.io/crunker/examples/)\n\n# Installation\n\n```sh\nyarn add crunker\n```\n\n```sh\nnpm install crunker\n```\n\n# Example\n\n```javascript\nlet crunker = new Crunker();\n\ncrunker\n  .fetchAudio('/song.mp3', '/another-song.mp3')\n  .then((buffers) =\u003e {\n    // =\u003e [AudioBuffer, AudioBuffer]\n    return crunker.mergeAudio(buffers);\n  })\n  .then((merged) =\u003e {\n    // =\u003e AudioBuffer\n    return crunker.export(merged, 'audio/mp3');\n  })\n  .then((output) =\u003e {\n    // =\u003e {blob, element, url}\n    crunker.download(output.blob);\n    document.body.append(output.element);\n    console.log(output.url);\n  })\n  .catch((error) =\u003e {\n    // =\u003e Error Message\n  });\n\ncrunker.notSupported(() =\u003e {\n  // Handle no browser support\n});\n```\n\n# Condensed Example\n\n```javascript\nlet crunker = new Crunker();\n\ncrunker\n  .fetchAudio('/voice.mp3', '/background.mp3')\n  .then((buffers) =\u003e crunker.mergeAudio(buffers))\n  .then((merged) =\u003e crunker.export(merged, 'audio/mp3'))\n  .then((output) =\u003e crunker.download(output.blob))\n  .catch((error) =\u003e {\n    throw new Error(error);\n  });\n```\n\n# Input file Example\n\n```javascript\nlet crunker = new Crunker();\n\nconst onFileInputChange = async (target) =\u003e {\n  const buffers = await crunker.fetchAudio(...target.files, '/voice.mp3', '/background.mp3');\n};\n\n\u003cinput onChange={onFileInputChange(this)} type=\"file\" accept=\"audio/*\" /\u003e;\n```\n\n## Other Examples\n\n- [Beat Builder Machine](examples/client/beatBuilder.html)\n\n# [Graphic Representation of Methods](https://github.com/jackedgson/crunker/issues/16)\n\n## Merge\n\n![merge](https://user-images.githubusercontent.com/12958674/88806278-968f0680-d186-11ea-9cb5-8ef2606ffcc7.png)\n\n## Concat\n\n![concat](https://user-images.githubusercontent.com/12958674/88806297-9d1d7e00-d186-11ea-8cd2-c64cb0324845.png)\n\n# Methods\n\nFor more detailed API documentation, view the Typescript typings.\n\n## new Crunker()\n\nCreate a new instance of Crunker.\nYou may optionally provide an object with a `sampleRate` key, but it will default to the same sample rate as the internal audio context, which is appropriate for your device.\n\n## crunker.fetchAudio(songURL, anotherSongURL)\n\nFetch one or more audio files.\\\n**Returns:** an array of audio buffers in the order they were fetched.\n\n## crunker.mergeAudio(arrayOfBuffers);\n\nMerge two or more audio buffers.\\\n**Returns:** a single `AudioBuffer` object.\n\n## crunker.concatAudio(arrayOfBuffers);\n\nConcatenate two or more audio buffers in the order specified.\\\n**Returns:** a single `AudioBuffer` object.\n\n## crunker.padAudio(buffer, padStart, seconds);\n\nPad the audio with silence, at the beginning, the end, or any specified points through the audio.\\\n**Returns:** a single `AudioBuffer` object.\n\n## crunker.sliceAudio(buffer, start, end, fadeIn, fadeOut);\n\nSlice the audio to the specified range, removing any content outside the range. Optionally add a fade-in at the start and a fade-out at the end to avoid audible clicks.\n\n- **buffer:** The audio buffer to be trimmed.\n- **start:** The starting second from where the audio should begin.\n- **end:** The ending second where the audio should be trimmed.\n- **fadeIn:** (Optional) Number of seconds for the fade-in effect at the beginning. Default is `0`.\n- **fadeOut:** (Optional) Number of seconds for the fade-out effect at the end. Default is `0`.\n\n**Returns:** a single `AudioBuffer` object.\n\n## crunker.export(buffer, type);\n\nExport an audio buffers with MIME type option.\\\n**Type:** e.g. `'audio/mp3', 'audio/wav', 'audio/ogg'`.\n**IMPORTANT**: the MIME type does **not** change the actual file format. It will always be a `WAVE` file under the hood.\\\n**Returns:** an object containing the blob object, url, and an audio element object.\n\n## crunker.download(blob, filename);\n\nAutomatically download an exported audio blob with optional filename.\\\n**Filename:** String **not** containing the .mp3, .wav, or .ogg file extension.\\\n**Returns:** the `HTMLAnchorElement` element used to simulate the automatic download.\n\n## crunker.play(buffer);\n\nStarts playing the exported audio buffer in the background.\\\n**Returns:** the `HTMLAudioElement`.\n\n## crunker.notSupported(callback);\n\nExecute custom code if Web Audio API is not supported by the users browser.\\\n**Returns:** The callback function.\n\n# Properties\n\nFor more detailed API documentation, view the Typescript typings.\n\n## crunker.context\n\nAccess the [AudioContext](https://developer.mozilla.org/en-US/docs/Web/API/AudioContext) used internally by a given Crunker.\\\n**Returns:** [AudioContext](https://developer.mozilla.org/en-US/docs/Web/API/AudioContext).\n\n# License\n\nMIT\n","funding_links":[],"categories":["Utilities","HarmonyOS","TypeScript"],"sub_categories":["Windows Manager"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaggad%2Fcrunker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaggad%2Fcrunker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaggad%2Fcrunker/lists"}