Skip to content

Commit

Permalink
Adds support for AMD and CommonJS modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
alemangui committed Aug 15, 2016
1 parent 18794a9 commit 6bafb30
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions Pizzicato.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
(function(root) {
'use strict';

var AudioContext = window.AudioContext || window.webkitAudioContext;
var Pizzicato = {};
var Pz = Pizzicato;
var commonJS = typeof module === "object" && module.exports;
var amd = typeof define === "function" && define.amd;

if (commonJS)
module.exports = Pizzicato;
else if (amd)
define([], Pizzicato);
else
root.Pizzicato = root.Pz = Pizzicato;

var AudioContext = root.AudioContext || root.webkitAudioContext;

if (!AudioContext) {
console.error('No AudioContext found in this environment. Please ensure your window or global object contains a working AudioContext constructor function.');
return;
}

var Pizzicato = root.Pz = root.Pizzicato = {};
Pizzicato.context = new AudioContext();

var masterGainNode = Pizzicato.context.createGain();
Expand Down Expand Up @@ -1870,4 +1886,4 @@
});

return Pizzicato;
})(this);
})(typeof window !== "undefined" ? window : global);

0 comments on commit 6bafb30

Please sign in to comment.