{"id":17068421,"url":"https://github.com/kylestetz/audiodrop","last_synced_at":"2025-04-12T18:21:52.213Z","repository":{"id":29508062,"uuid":"33046252","full_name":"kylestetz/AudioDrop","owner":"kylestetz","description":":wavy_dash: Drag and drop and decode audio files.","archived":false,"fork":false,"pushed_at":"2017-02-15T16:49:35.000Z","size":14,"stargazers_count":77,"open_issues_count":1,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-26T12:37:51.292Z","etag":null,"topics":[],"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/kylestetz.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":"2015-03-28T19:00:48.000Z","updated_at":"2023-05-15T23:14:30.000Z","dependencies_parsed_at":"2022-09-09T09:41:43.494Z","dependency_job_id":null,"html_url":"https://github.com/kylestetz/AudioDrop","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/kylestetz%2FAudioDrop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kylestetz%2FAudioDrop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kylestetz%2FAudioDrop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kylestetz%2FAudioDrop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kylestetz","download_url":"https://codeload.github.com/kylestetz/AudioDrop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248610686,"owners_count":21132984,"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-10-14T11:13:26.088Z","updated_at":"2025-04-12T18:21:52.168Z","avatar_url":"https://github.com/kylestetz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AudioDrop\n\n\u003cimg src=\"https://github.com/kylestetz/AudioDrop/blob/master/audiodrop.png\" width=\"90\" height=\"75\" align=\"left\" /\u003e\n\n`AudioDrop` is a utility that enables drag-and-drop loading of Audio Buffers. Simply specify an element to be designated as a drop zone and provide a callback that determines how to handle the newly-created audio buffer.\n\n*For use with the Web Audio API*: If you're looking for a general drag-and-drop utility you may want to check out [dropzone](http://www.dropzonejs.com/). Audiodrop makes use of the [Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API) to decode audio files into [`AudioBuffer`](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer) objects.\n\n## API\n\n#### `AudioDrop(options)`\n\nCall `AudioDrop` with an options object. Required options are `context`, `elements`, and `drop`.\n\n```javascript\nAudioDrop({\n\n  // the web audio context (required)\n  context: myAudioContext,\n\n  // a DOM Element or an array of DOM Elements (required)\n  elements: document.querySelector('#dropzone'),\n\n  // the callback to handle each file (required)\n  drop: function(buffer, file) {\n    window[file.name] = buffer;\n    console.log('Added the buffer ' + file.name + ' to the window.');\n  },\n\n  // DOM Events\n\n  // called when there is a file being dragged into the dropzone\n  dragEnter: function(e) { },\n\n  // called repeatedly while a file is being dragged on the dropzone\n  dragOver: function(e) { },\n\n  // called when there is a file being dragged out of the dropzone\n  dragLeave: function(e) { },\n})\n```\n\n#### `AudioDrop.isValidVariableName(String)`\n\nA convenience function for determining whether or not a string, if turned into a variable name, would violate a reserved keyword. This is useful if you are planning to attach the variable to the `window`, as in the example below.\n\n## Examples\n\n#### Attach the audio buffer to the window.\n\n```javascript\nAudioDrop({\n  context: new AudioContext(),\n  elements: window.document.body,\n  drop: function(buffer, file) {\n    var name = file.name.replace(/\\.[^/.]+$/, \"\");\n    if( AudioDrop.isValidVariableName(name) ) {\n      window[name] = buffer;\n      console.log('Added the variable \"' + name + '\"\" to the window.');\n    } else {\n      window[name + '-sample'] = buffer;\n      console.log('Added the variable window[\"' + name + '-sample\"] to the window.');\n    }\n  }\n});\n```\n\n-----------------------\n\n`AudioDrop` was created for [`Lissajous`](https://github.com/kylestetz/lissajous).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkylestetz%2Faudiodrop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkylestetz%2Faudiodrop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkylestetz%2Faudiodrop/lists"}