-
Notifications
You must be signed in to change notification settings - Fork 0
/
launchpad.min.js.map
1 lines (1 loc) · 12.2 KB
/
launchpad.min.js.map
1
{"version":3,"sources":["launchpad.js"],"names":["$","Observable","this","observers","prototype","on","event","callback","push","emit","args","Array","slice","call","arguments","forEach","apply","undefined","window","launchpad","Button","channel","note","midiAdapter","id","isControl","x","y","Math","floor","Object","create","constructor","turn","color","paint","defaults","paintNames","colors","extend","red","green","velocity","send","selectItem","name","from","items","item","next","done","value","orange","sysex","midiAdapterFactory","accept","reject","navigator","requestMIDIAccess","padName","then","midiAccess","input","inputs","values","output","outputs","io","MidiAdapter","Launchpad","pad","reduce","result","dictionary","key","hasOwnProperty","connect","options","Promise","bind","onmidimessage","onMidiMessageCallback","message","data","inputHandlers","applies","handle","buttonLookups","length","lookup","Pad","handleInput","filter","handler","clear","button","buttonLookup","map","controlButton","version"],"mappings":"CAAA,SAAUA,GACN,GAAIC,GAAaD,EAAEC,WAAa,WAC5BC,KAAKC,aAETF,GAAWG,UAAUC,GAAK,SAASC,EAAOC,GACd,kBAAbA,KACVL,KAAKC,UAAUG,GAASJ,KAAKC,UAAUG,QAAcE,KAAKD,IAE/DN,EAAWG,UAAUK,KAAO,SAASH,GACjC,GAAII,GAAOC,MAAMP,UAAUQ,MAAMC,KAAKC,UAAW,IAChDZ,KAAKC,UAAUG,QAAcS,QAAQ,SAASR,GAC3CA,EAASS,MAAMC,OAAWP,OAGnCQ,OAAOC,UAAYD,OAAOC,eAC5B,SAAUnB,GACP,GAAIoB,GAASpB,EAAEoB,OAAS,SAASC,EAASC,EAAMC,GAC5CvB,EAAEC,WAAWY,KAAKX,MAClBA,KAAKmB,QAAUA,EACfnB,KAAKoB,KAAOA,EACZpB,KAAKqB,YAAcA,EACnBrB,KAAKsB,GAAKtB,KAAKoB,KACVpB,KAAKuB,YAINvB,KAAKsB,IAAM,KAHXtB,KAAKwB,EAAIxB,KAAKoB,KAAO,GACrBpB,KAAKyB,EAAIC,KAAKC,MAAM3B,KA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AAYoB,KAAK,IAAK,EAAG,IAElC+C,EAAItF,UAAU2F,OAAS,WACnB,GAAIrF,GAAOC,MAAMP,UAAUQ,MAAMC,KAAKC,UACtC,OAAOyE,GACFK,OAAO,SAASI,GAAe,MAAOA,GAAaX,QAAQ3E,KAC3DuF,IAAI,SAASD,GAAe,MAAOA,GAAaP,OAAOvF,KAAMQ,IAASqE,KAAK7E,OAC/E,IAELwF,EAAItF,UAAU8F,cAAgB,SAAS1E,GACnC,MAAO,IAAIxB,GAAEoB,OAAO,IAAK,IAAMI,EAAItB,KAAKqB,eAE7CL,OAAOC,UAAYD,OAAOC,eAC5B,SAAUnB,GACPA,EAAEmG,QAAU,SACbjF,OAAOC,UAAYD,OAAOC","file":"launchpad.min.js","sourcesContent":["(function($){\n var Observable = $.Observable = function(){\n this.observers = {};\n };\n Observable.prototype.on = function(event, callback){\n if (typeof callback !== 'function') return;\n (this.observers[event] = this.observers[event] || []).push(callback);\n };\n Observable.prototype.emit = function(event){\n var args = Array.prototype.slice.call(arguments, 1);\n (this.observers[event] || []).forEach(function(callback){\n callback.apply(undefined, args);\n });\n };\n})(window.launchpad = window.launchpad || {});\n;(function($){\n var Button = $.Button = function(channel, note, midiAdapter){\n $.Observable.call(this);\n this.channel = channel;\n this.note = note;\n this.midiAdapter = midiAdapter;\n this.id = this.note;\n if (!this.isControl()) {\n this.x = this.note % 16;\n this.y = Math.floor(this.note / 16);\n } else {\n this.id -= 104;\n }\n };\n Button.prototype = Object.create($.Observable.prototype);\n Button.prototype.constructor = Button;\n Button.prototype.turn = function(color){\n this.paint($.defaults.paintNames[color]);\n };\n Button.prototype.paint = function(colors){\n colors = $.extend(colors, { 'red': 0, 'green': 0 });\n var velocity = (colors.green % 4) * 16 + (colors.red % 4);\n this.send(velocity);\n };\n Button.prototype.send = function(velocity){\n this.midiAdapter.send(this.channel, this.note, velocity);\n };\n Button.prototype.isControl = function(){\n return this.channel === 176;\n };\n})(window.launchpad = window.launchpad || {});\n;(function($, undefined){\n var defaults = $.defaults = {};\n\n function selectItem(name){\n return {\n 'from': function(items){\n var item = items.next();\n while (!item.done) {\n if (item.value.name === name) {\n return item.value;\n }\n item = items.next();\n }\n return undefined;\n }\n };\n }\n\n defaults.paintNames = {\n 'red': { 'red': 3, 'green': 0 },\n 'green': { 'red': 0, 'green': 3 },\n 'orange': { 'red': 3, 'green': 3 }\n };\n defaults.name = 'Launchpad Mini MIDI 1';\n defaults.sysex = false;\n defaults.midiAdapterFactory = function(accept, reject){\n if (!navigator.requestMIDIAccess){\n reject();\n } else {\n var padName = this.name;\n navigator.requestMIDIAccess({ sysex: this.sysex })\n .then(function(midiAccess){\n return {\n 'input': selectItem(padName).from(midiAccess.inputs.values()),\n 'output': selectItem(padName).from(midiAccess.outputs.values())\n };\n })\n .then(function(io){\n return new $.MidiAdapter(io.input, io.output);\n })\n .then(function(midiAdapter){\n return new $.Launchpad(midiAdapter);\n })\n .then(function(pad){\n accept(pad);\n })\n .catch(reject);\n }\n };\n})(window.launchpad = window.launchpad || {});\n;(function($){\n $.extend = function extend(){\n return Array.prototype.slice.call(arguments).reduce(function(result, dictionary){\n for (var key in dictionary){\n if (dictionary.hasOwnProperty(key) && !result.hasOwnProperty(key)) {\n result[key] = dictionary[key];\n }\n }\n return result;\n }, {});\n };\n})(window.launchpad = window.launchpad || {});\n;(function($){\n $.connect = function(options){\n options = $.extend(options || {}, $.defaults);\n return new Promise(options.midiAdapterFactory.bind(options));\n };\n})(window.launchpad = window.launchpad || {});\n;(function($){\n var MidiAdapter = $.MidiAdapter = function(input, output){\n $.Observable.call(this);\n this.input = input;\n this.output = output;\n\n this.input.onmidimessage = this.onMidiMessageCallback.bind(this);\n };\n MidiAdapter.prototype = Object.create($.Observable.prototype);\n MidiAdapter.prototype.constructor = MidiAdapter;\n MidiAdapter.prototype.onMidiMessageCallback = function(message){\n var channel = message.data[0];\n var note = message.data[1];\n var velocity = message.data[2];\n this.emit('input', channel, note, velocity);\n };\n MidiAdapter.prototype.send = function(channel, note, velocity){\n this.output.send([channel, note, velocity]);\n };\n})(window.launchpad = window.launchpad || {});\n;(function($){\n var inputHandlers = [\n {\n 'applies': function(channel, note, velocity){ return velocity === 127; },\n 'handle': function(pad, channel, note, velocity){\n pad.emit('press', new $.Button(channel, note, pad.midiAdapter));\n }\n },\n {\n 'applies': function(channel, note, velocity){ return velocity === 0; },\n 'handle': function(pad, channel, note, velocity){\n pad.emit('release', new $.Button(channel, note, pad.midiAdapter));\n }\n }\n ];\n\n var buttonLookups = [\n {\n 'applies': function(args){ return args.length === 1; },\n 'lookup': function(pad, args){\n return new $.Button(144, args[0], pad.midiAdapter);\n }\n },\n {\n 'applies': function(args){ return args.length === 2; },\n 'lookup': function(pad, args){\n return new $.Button(144, args[0] + 16 * args[1], pad.midiAdapter);\n }\n }\n ];\n\n var Pad = $.Launchpad = function(midiAdapter){\n $.Observable.call(this);\n this.midiAdapter = midiAdapter;\n this.midiAdapter.on('input', this.handleInput.bind(this));\n };\n Pad.prototype = Object.create($.Observable.prototype);\n Pad.prototype.constructor = Pad;\n Pad.prototype.handleInput = function(channel, note, velocity){\n inputHandlers\n .filter(function(handler){ return handler.applies(channel, note, velocity); })\n .forEach(function(handler){ handler.handle(this, channel, note, velocity); }.bind(this));\n };\n Pad.prototype.clear = function(){\n this.midiAdapter.send(176, 0, 0);\n };\n Pad.prototype.button = function(){\n var args = Array.prototype.slice.call(arguments);\n return buttonLookups\n .filter(function(buttonLookup){ return buttonLookup.applies(args); })\n .map(function(buttonLookup){ return buttonLookup.lookup(this, args); }.bind(this))\n [0];\n };\n Pad.prototype.controlButton = function(id){\n return new $.Button(176, 104 + id, this.midiAdapter);\n };\n})(window.launchpad = window.launchpad || {});\n;(function($){\n $.version = '1.0.0';\n})(window.launchpad = window.launchpad || {});\n"]}