Skip to content
〰️ Drag and drop and decode audio files.
JavaScript CSS HTML
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


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.

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. Audiodrop makes use of the Web Audio API to decode audio files into AudioBuffer objects.



Call AudioDrop with an options object. Required options are context, elements, and drop.


  // the web audio context (required)
  context: myAudioContext,

  // a DOM Element or an array of DOM Elements (required)
  elements: document.querySelector('#dropzone'),

  // the callback to handle each file (required)
  drop: function(buffer, file) {
    window[] = buffer;
    console.log('Added the buffer ' + + ' to the window.');

  // DOM Events

  // called when there is a file being dragged into the dropzone
  dragEnter: function(e) { },

  // called repeatedly while a file is being dragged on the dropzone
  dragOver: function(e) { },

  // called when there is a file being dragged out of the dropzone
  dragLeave: function(e) { },


A 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.


Attach the audio buffer to the window.

  context: new AudioContext(),
  elements: window.document.body,
  drop: function(buffer, file) {
    var name =\.[^/.]+$/, "");
    if( AudioDrop.isValidVariableName(name) ) {
      window[name] = buffer;
      console.log('Added the variable "' + name + '"" to the window.');
    } else {
      window[name + '-sample'] = buffer;
      console.log('Added the variable window["' + name + '-sample"] to the window.');

AudioDrop was created for Lissajous.

You can’t perform that action at this time.