diff options
Diffstat (limited to 'bundle.js')
| -rw-r--r-- | bundle.js | 46153 |
1 files changed, 46153 insertions, 0 deletions
diff --git a/bundle.js b/bundle.js new file mode 100644 index 0000000..93b74a7 --- /dev/null +++ b/bundle.js @@ -0,0 +1,46153 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // identity function for calling harmony imports with the correct context +/******/ __webpack_require__.i = function(value) { return value; }; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 77); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +var store = __webpack_require__(40)('wks') + , uid = __webpack_require__(27) + , Symbol = __webpack_require__(2).Symbol + , USE_SYMBOL = typeof Symbol == 'function'; + +var $exports = module.exports = function(name){ + return store[name] || (store[name] = + USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name)); +}; + +$exports.store = store; + +/***/ }), +/* 1 */ +/***/ (function(module, exports) { + +var core = module.exports = {version: '2.4.0'}; +if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef + +/***/ }), +/* 2 */ +/***/ (function(module, exports) { + +// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 +var global = module.exports = typeof window != 'undefined' && window.Math == Math + ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); +if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(global) {/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> + * @license MIT + */ +/* eslint-disable no-proto */ + + + +var base64 = __webpack_require__(89) +var ieee754 = __webpack_require__(135) +var isArray = __webpack_require__(64) + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Use Object implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * Due to various browser bugs, sometimes the Object implementation will be used even + * when the browser supports typed arrays. + * + * Note: + * + * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, + * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. + * + * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. + * + * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of + * incorrect length in some situations. + + * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they + * get the Object implementation, which is slower but behaves correctly. + */ +Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined + ? global.TYPED_ARRAY_SUPPORT + : typedArraySupport() + +/* + * Export kMaxLength after typed array support is determined. + */ +exports.kMaxLength = kMaxLength() + +function typedArraySupport () { + try { + var arr = new Uint8Array(1) + arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + return arr.foo() === 42 && // typed array instances can be augmented + typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` + arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` + } catch (e) { + return false + } +} + +function kMaxLength () { + return Buffer.TYPED_ARRAY_SUPPORT + ? 0x7fffffff + : 0x3fffffff +} + +function createBuffer (that, length) { + if (kMaxLength() < length) { + throw new RangeError('Invalid typed array length') + } + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = new Uint8Array(length) + that.__proto__ = Buffer.prototype + } else { + // Fallback: Return an object instance of the Buffer class + if (that === null) { + that = new Buffer(length) + } + that.length = length + } + + return that +} + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + +function Buffer (arg, encodingOrOffset, length) { + if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { + return new Buffer(arg, encodingOrOffset, length) + } + + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) + } + return allocUnsafe(this, arg) + } + return from(this, arg, encodingOrOffset, length) +} + +Buffer.poolSize = 8192 // not used by this implementation + +// TODO: Legacy, not needed anymore. Remove in next major version. +Buffer._augment = function (arr) { + arr.__proto__ = Buffer.prototype + return arr +} + +function from (that, value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } + + if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { + return fromArrayBuffer(that, value, encodingOrOffset, length) + } + + if (typeof value === 'string') { + return fromString(that, value, encodingOrOffset) + } + + return fromObject(that, value) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(null, value, encodingOrOffset, length) +} + +if (Buffer.TYPED_ARRAY_SUPPORT) { + Buffer.prototype.__proto__ = Uint8Array.prototype + Buffer.__proto__ = Uint8Array + if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) { + // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true + }) + } +} + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be a number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') + } +} + +function alloc (that, size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(that, size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(that, size).fill(fill, encoding) + : createBuffer(that, size).fill(fill) + } + return createBuffer(that, size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(null, size, fill, encoding) +} + +function allocUnsafe (that, size) { + assertSize(size) + that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < size; ++i) { + that[i] = 0 + } + } + return that +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(null, size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(null, size) +} + +function fromString (that, string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('"encoding" must be a valid string encoding') + } + + var length = byteLength(string, encoding) | 0 + that = createBuffer(that, length) + + var actual = that.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + that = that.slice(0, actual) + } + + return that +} + +function fromArrayLike (that, array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + that = createBuffer(that, length) + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that +} + +function fromArrayBuffer (that, array, byteOffset, length) { + array.byteLength // this throws if `array` is not a valid ArrayBuffer + + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('\'offset\' is out of bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('\'length\' is out of bounds') + } + + if (byteOffset === undefined && length === undefined) { + array = new Uint8Array(array) + } else if (length === undefined) { + array = new Uint8Array(array, byteOffset) + } else { + array = new Uint8Array(array, byteOffset, length) + } + + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = array + that.__proto__ = Buffer.prototype + } else { + // Fallback: Return an object instance of the Buffer class + that = fromArrayLike(that, array) + } + return that +} + +function fromObject (that, obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + that = createBuffer(that, len) + + if (that.length === 0) { + return that + } + + obj.copy(that, 0, 0, len) + return that + } + + if (obj) { + if ((typeof ArrayBuffer !== 'undefined' && + obj.buffer instanceof ArrayBuffer) || 'length' in obj) { + if (typeof obj.length !== 'number' || isnan(obj.length)) { + return createBuffer(that, 0) + } + return fromArrayLike(that, obj) + } + + if (obj.type === 'Buffer' && isArray(obj.data)) { + return fromArrayLike(that, obj.data) + } + } + + throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') +} + +function checked (length) { + // Note: cannot use `length < kMaxLength()` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= kMaxLength()) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + kMaxLength().toString(16) + ' bytes') + } + return length | 0 +} + +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) +} + +Buffer.isBuffer = function isBuffer (b) { + return !!(b != null && b._isBuffer) +} + +Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} + +Buffer.concat = function concat (list, length) { + if (!isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } + + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length + } + return buffer +} + +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && + (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string + } + + var len = string.length + if (len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + case undefined: + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) return utf8ToBytes(string).length // assume utf8 + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength + +function slowToString (encoding, start, end) { + var loweredCase = false + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect +// Buffer instances. +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i +} + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} + +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} + +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + +Buffer.prototype.toString = function toString () { + var length = this.length | 0 + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +} + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' + } + return '<Buffer ' + str + '>' +} + +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!Buffer.isBuffer(target)) { + throw new TypeError('Argument must be a Buffer') + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (isNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (Buffer.TYPED_ARRAY_SUPPORT && + typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 +} + +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +} + +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +} + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + // must be an even number of digits + var strLen = string.length + if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (isNaN(parsed)) return i + buf[offset + i] = parsed + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset | 0 + if (isFinite(length)) { + length = length | 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + // legacy write(string, encoding, offset, length) - remove in v0.13 + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res +} + +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret +} + +function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf + if (Buffer.TYPED_ARRAY_SUPPORT) { + newBuf = this.subarray(start, end) + newBuf.__proto__ = Buffer.prototype + } else { + var sliceLen = end - start + newBuf = new Buffer(sliceLen, undefined) + for (var i = 0; i < sliceLen; ++i) { + newBuf[i] = this[i + start] + } + } + + return newBuf +} + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val +} + +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} + +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} + +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} + +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} + +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +} + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} + +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + this[offset] = (value & 0xff) + return offset + 1 +} + +function objectWriteUInt16 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { + buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> + (littleEndian ? i : 1 - i) * 8 + } +} + +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 +} + +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 +} + +function objectWriteUInt32 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffffffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { + buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff + } +} + +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 +} + +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 +} + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 +} + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 +} + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 +} + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 +} + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start + var i + + if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] + } + } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { + // ascending copy from start + for (i = 0; i < len; ++i) { + target[i + targetStart] = this[i + start] + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, start + len), + targetStart + ) + } + + return len +} + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if (code < 256) { + val = code + } + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + } else if (typeof val === 'number') { + val = val & 255 + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : utf8ToBytes(new Buffer(val, encoding).toString()) + var len = bytes.length + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } + } + + return this +} + +// HELPER FUNCTIONS +// ================ + +var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = stringtrim(str).replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function stringtrim (str) { + if (str.trim) return str.trim() + return str.replace(/^\s+|\s+$/g, '') +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +function isnan (val) { + return val !== val // eslint-disable-line no-self-compare +} + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(20))) + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +var isObject = __webpack_require__(18); +module.exports = function(it){ + if(!isObject(it))throw TypeError(it + ' is not an object!'); + return it; +}; + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +// Thank's IE8 for his funny defineProperty +module.exports = !__webpack_require__(13)(function(){ + return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7; +}); + +/***/ }), +/* 6 */ +/***/ (function(module, exports) { + +var hasOwnProperty = {}.hasOwnProperty; +module.exports = function(it, key){ + return hasOwnProperty.call(it, key); +}; + +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { + +var dP = __webpack_require__(8) + , createDesc = __webpack_require__(25); +module.exports = __webpack_require__(5) ? function(object, key, value){ + return dP.f(object, key, createDesc(1, value)); +} : function(object, key, value){ + object[key] = value; + return object; +}; + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + +var anObject = __webpack_require__(4) + , IE8_DOM_DEFINE = __webpack_require__(53) + , toPrimitive = __webpack_require__(43) + , dP = Object.defineProperty; + +exports.f = __webpack_require__(5) ? Object.defineProperty : function defineProperty(O, P, Attributes){ + anObject(O); + P = toPrimitive(P, true); + anObject(Attributes); + if(IE8_DOM_DEFINE)try { + return dP(O, P, Attributes); + } catch(e){ /* empty */ } + if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!'); + if('value' in Attributes)O[P] = Attributes.value; + return O; +}; + +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { + +// to indexed object, toObject with fallback for non-array-like ES3 strings +var IObject = __webpack_require__(54) + , defined = __webpack_require__(35); +module.exports = function(it){ + return IObject(defined(it)); +}; + +/***/ }), +/* 10 */ +/***/ (function(module, exports) { + +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. + + + +/*<replacement>*/ + +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + keys.push(key); + }return keys; +}; +/*</replacement>*/ + +module.exports = Duplex; + +/*<replacement>*/ +var processNextTick = __webpack_require__(48); +/*</replacement>*/ + +/*<replacement>*/ +var util = __webpack_require__(19); +util.inherits = __webpack_require__(16); +/*</replacement>*/ + +var Readable = __webpack_require__(65); +var Writable = __webpack_require__(49); + +util.inherits(Duplex, Readable); + +var keys = objectKeys(Writable.prototype); +for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; +} + +function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) this.readable = false; + + if (options && options.writable === false) this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; + + this.once('end', onend); +} + +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) return; + + // no more data can be written. + // But allow more writes to happen in this tick. + processNextTick(onEndNT, this); +} + +function onEndNT(self) { + self.end(); +} + +function forEach(xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } +} + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + +var global = __webpack_require__(2) + , core = __webpack_require__(1) + , ctx = __webpack_require__(22) + , hide = __webpack_require__(7) + , PROTOTYPE = 'prototype'; + +var $export = function(type, name, source){ + var IS_FORCED = type & $export.F + , IS_GLOBAL = type & $export.G + , IS_STATIC = type & $export.S + , IS_PROTO = type & $export.P + , IS_BIND = type & $export.B + , IS_WRAP = type & $export.W + , exports = IS_GLOBAL ? core : core[name] || (core[name] = {}) + , expProto = exports[PROTOTYPE] + , target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE] + , key, own, out; + if(IS_GLOBAL)source = name; + for(key in source){ + // contains in native + own = !IS_FORCED && target && target[key] !== undefined; + if(own && key in exports)continue; + // export native or passed + out = own ? target[key] : source[key]; + // prevent global pollution for namespaces + exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key] + // bind timers to global for call from export context + : IS_BIND && own ? ctx(out, global) + // wrap global constructors for prevent change them in library + : IS_WRAP && target[key] == out ? (function(C){ + var F = function(a, b, c){ + if(this instanceof C){ + switch(arguments.length){ + case 0: return new C; + case 1: return new C(a); + case 2: return new C(a, b); + } return new C(a, b, c); + } return C.apply(this, arguments); + }; + F[PROTOTYPE] = C[PROTOTYPE]; + return F; + // make static versions for prototype methods + })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; + // export proto methods to core.%CONSTRUCTOR%.methods.%NAME% + if(IS_PROTO){ + (exports.virtual || (exports.virtual = {}))[key] = out; + // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME% + if(type & $export.R && expProto && !expProto[key])hide(expProto, key, out); + } + } +}; +// type bitmap +$export.F = 1; // forced +$export.G = 2; // global +$export.S = 4; // static +$export.P = 8; // proto +$export.B = 16; // bind +$export.W = 32; // wrap +$export.U = 64; // safe +$export.R = 128; // real proto method for `library` +module.exports = $export; + +/***/ }), +/* 13 */ +/***/ (function(module, exports) { + +module.exports = function(exec){ + try { + return !!exec(); + } catch(e){ + return true; + } +}; + +/***/ }), +/* 14 */ +/***/ (function(module, exports) { + +module.exports = {}; + +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + +// 19.1.2.14 / 15.2.3.14 Object.keys(O) +var $keys = __webpack_require__(58) + , enumBugKeys = __webpack_require__(37); + +module.exports = Object.keys || function keys(O){ + return $keys(O, enumBugKeys); +}; + +/***/ }), +/* 16 */ +/***/ (function(module, exports) { + +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } +} + + +/***/ }), +/* 17 */ +/***/ (function(module, exports) { + +var toString = {}.toString; + +module.exports = function(it){ + return toString.call(it).slice(8, -1); +}; + +/***/ }), +/* 18 */ +/***/ (function(module, exports) { + +module.exports = function(it){ + return typeof it === 'object' ? it !== null : typeof it === 'function'; +}; + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. + +function isArray(arg) { + if (Array.isArray) { + return Array.isArray(arg); + } + return objectToString(arg) === '[object Array]'; +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = Buffer.isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer)) + +/***/ }), +/* 20 */ +/***/ (function(module, exports) { + +var g;
+
+// This works in non-strict mode
+g = (function() {
+ return this;
+})();
+
+try {
+ // This works if eval is allowed (see CSP)
+ g = g || Function("return this")() || (1,eval)("this");
+} catch(e) {
+ // This works if the window reference is available
+ if(typeof window === "object")
+ g = window;
+}
+
+// g can still be undefined, but nothing to do about it...
+// We return undefined, instead of nothing here, so it's
+// easier to handle this case. if(!global) { ...}
+
+module.exports = g;
+ + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + +var __WEBPACK_AMD_DEFINE_RESULT__;(function(root, factory){ + + //UMD + if ( true ) { + !(__WEBPACK_AMD_DEFINE_RESULT__ = function() { + return factory(); + }.call(exports, __webpack_require__, exports, module), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if (typeof module === "object") { + module.exports = factory(); + } else { + root.Tone = factory(); + } + +}(this, function(){ + + "use strict"; + + var Tone; + //constructs the main Tone object + function Main(func){ + Tone = func(); + } + //invokes each of the modules with the main Tone object as the argument + function Module(func){ + func(Tone); + } /** + * Tone.js + * @author Yotam Mann + * @license http://opensource.org/licenses/MIT MIT License + * @copyright 2014-2018 Yotam Mann + */ + Main(function () { + + /////////////////////////////////////////////////////////////////////////// + // TONE + /////////////////////////////////////////////////////////////////////////// + /** + * @class Tone is the base class of all other classes. + * @constructor + */ + var Tone = function () { + if (!(this instanceof Tone)) { + throw new Error('constructor needs to be called with the \'new\' keyword'); + } + }; + /** + * @memberOf Tone# + * @returns {String} returns the name of the class as a string + */ + Tone.prototype.toString = function () { + for (var className in Tone) { + var isLetter = className[0].match(/^[A-Z]$/); + var sameConstructor = Tone[className] === this.constructor; + if (Tone.isFunction(Tone[className]) && isLetter && sameConstructor) { + return className; + } + } + return 'Tone'; + }; + /** + * @memberOf Tone# + * disconnect and dispose + * @returns {Tone} this + */ + Tone.prototype.dispose = function () { + return this; + }; + /////////////////////////////////////////////////////////////////////////// + // GET/SET + /////////////////////////////////////////////////////////////////////////// + /** + * Set the parameters at once. Either pass in an + * object mapping parameters to values, or to set a + * single parameter, by passing in a string and value. + * The last argument is an optional ramp time which + * will ramp any signal values to their destination value + * over the duration of the rampTime. + * @param {Object|String} params + * @param {Number=} value + * @param {Time=} rampTime + * @returns {Tone} this + * @memberOf Tone# + * @example + * //set values using an object + * filter.set({ + * "frequency" : 300, + * "type" : highpass + * }); + * @example + * filter.set("type", "highpass"); + * @example + * //ramp to the value 220 over 3 seconds. + * oscillator.set({ + * "frequency" : 220 + * }, 3); + */ + Tone.prototype.set = function (params, value, rampTime) { + if (Tone.isObject(params)) { + rampTime = value; + } else if (Tone.isString(params)) { + var tmpObj = {}; + tmpObj[params] = value; + params = tmpObj; + } + paramLoop: + for (var attr in params) { + value = params[attr]; + var parent = this; + if (attr.indexOf('.') !== -1) { + var attrSplit = attr.split('.'); + for (var i = 0; i < attrSplit.length - 1; i++) { + parent = parent[attrSplit[i]]; + if (parent instanceof Tone) { + attrSplit.splice(0, i + 1); + var innerParam = attrSplit.join('.'); + parent.set(innerParam, value); + continue paramLoop; + } + } + attr = attrSplit[attrSplit.length - 1]; + } + var param = parent[attr]; + if (Tone.isUndef(param)) { + continue; + } + if (Tone.Signal && param instanceof Tone.Signal || Tone.Param && param instanceof Tone.Param) { + if (param.value !== value) { + if (Tone.isUndef(rampTime)) { + param.value = value; + } else { + param.rampTo(value, rampTime); + } + } + } else if (param instanceof AudioParam) { + if (param.value !== value) { + param.value = value; + } + } else if (Tone.TimeBase && param instanceof Tone.TimeBase) { + parent[attr] = value; + } else if (param instanceof Tone) { + param.set(value); + } else if (param !== value) { + parent[attr] = value; + } + } + return this; + }; + /** + * Get the object's attributes. Given no arguments get + * will return all available object properties and their corresponding + * values. Pass in a single attribute to retrieve or an array + * of attributes. The attribute strings can also include a "." + * to access deeper properties. + * @memberOf Tone# + * @example + * osc.get(); + * //returns {"type" : "sine", "frequency" : 440, ...etc} + * @example + * osc.get("type"); + * //returns { "type" : "sine"} + * @example + * //use dot notation to access deep properties + * synth.get(["envelope.attack", "envelope.release"]); + * //returns {"envelope" : {"attack" : 0.2, "release" : 0.4}} + * @param {Array=|string|undefined} params the parameters to get, otherwise will return + * all available. + * @returns {Object} + */ + Tone.prototype.get = function (params) { + if (Tone.isUndef(params)) { + params = this._collectDefaults(this.constructor); + } else if (Tone.isString(params)) { + params = [params]; + } + var ret = {}; + for (var i = 0; i < params.length; i++) { + var attr = params[i]; + var parent = this; + var subRet = ret; + if (attr.indexOf('.') !== -1) { + var attrSplit = attr.split('.'); + for (var j = 0; j < attrSplit.length - 1; j++) { + var subAttr = attrSplit[j]; + subRet[subAttr] = subRet[subAttr] || {}; + subRet = subRet[subAttr]; + parent = parent[subAttr]; + } + attr = attrSplit[attrSplit.length - 1]; + } + var param = parent[attr]; + if (Tone.isObject(params[attr])) { + subRet[attr] = param.get(); + } else if (Tone.Signal && param instanceof Tone.Signal) { + subRet[attr] = param.value; + } else if (Tone.Param && param instanceof Tone.Param) { + subRet[attr] = param.value; + } else if (param instanceof AudioParam) { + subRet[attr] = param.value; + } else if (param instanceof Tone) { + subRet[attr] = param.get(); + } else if (!Tone.isFunction(param) && Tone.isDefined(param)) { + subRet[attr] = param; + } + } + return ret; + }; + /** + * collect all of the default attributes in one + * @private + * @param {Function} constr the constructor to find the defaults from + * @return {Array} all of the attributes which belong to the class + */ + Tone.prototype._collectDefaults = function (constr) { + var ret = []; + if (Tone.isDefined(constr.defaults)) { + ret = Object.keys(constr.defaults); + } + if (Tone.isDefined(constr._super)) { + var superDefs = this._collectDefaults(constr._super); + //filter out repeats + for (var i = 0; i < superDefs.length; i++) { + if (ret.indexOf(superDefs[i]) === -1) { + ret.push(superDefs[i]); + } + } + } + return ret; + }; + /////////////////////////////////////////////////////////////////////////// + // DEFAULTS + /////////////////////////////////////////////////////////////////////////// + /** + * @memberOf Tone + * @param {Array} values The arguments array + * @param {Array} keys The names of the arguments + * @param {Function|Object} constr The class constructor + * @return {Object} An object composed of the defaults between the class' defaults + * and the passed in arguments. + */ + Tone.defaults = function (values, keys, constr) { + var options = {}; + if (values.length === 1 && Tone.isObject(values[0])) { + options = values[0]; + } else { + for (var i = 0; i < keys.length; i++) { + options[keys[i]] = values[i]; + } + } + if (Tone.isDefined(constr.defaults)) { + return Tone.defaultArg(options, constr.defaults); + } else if (Tone.isObject(constr)) { + return Tone.defaultArg(options, constr); + } else { + return options; + } + }; + /** + * If the `given` parameter is undefined, use the `fallback`. + * If both `given` and `fallback` are object literals, it will + * return a deep copy which includes all of the parameters from both + * objects. If a parameter is undefined in given, it will return + * the fallback property. + * <br><br> + * WARNING: if object is self referential, it will go into an an + * infinite recursive loop. + * @memberOf Tone + * @param {*} given + * @param {*} fallback + * @return {*} + */ + Tone.defaultArg = function (given, fallback) { + if (Tone.isObject(given) && Tone.isObject(fallback)) { + var ret = {}; + //make a deep copy of the given object + for (var givenProp in given) { + ret[givenProp] = Tone.defaultArg(fallback[givenProp], given[givenProp]); + } + for (var fallbackProp in fallback) { + ret[fallbackProp] = Tone.defaultArg(given[fallbackProp], fallback[fallbackProp]); + } + return ret; + } else { + return Tone.isUndef(given) ? fallback : given; + } + }; + /////////////////////////////////////////////////////////////////////////// + // CONNECTIONS + /////////////////////////////////////////////////////////////////////////// + /** + * connect together all of the arguments in series + * @param {...AudioParam|Tone|AudioNode} nodes + * @returns {Tone} + * @memberOf Tone + * @static + */ + Tone.connectSeries = function () { + var currentUnit = arguments[0]; + for (var i = 1; i < arguments.length; i++) { + var toUnit = arguments[i]; + currentUnit.connect(toUnit); + currentUnit = toUnit; + } + return Tone; + }; + /////////////////////////////////////////////////////////////////////////// + // TYPE CHECKING + /////////////////////////////////////////////////////////////////////////// + /** + * Test if the arg is undefined + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is undefined + * @static + * @memberOf Tone + */ + Tone.isUndef = function (val) { + return typeof val === 'undefined'; + }; + /** + * Test if the arg is not undefined + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is undefined + * @static + * @memberOf Tone + */ + Tone.isDefined = function (val) { + return !Tone.isUndef(val); + }; + /** + * Test if the arg is a function + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is a function + * @static + * @memberOf Tone + */ + Tone.isFunction = function (val) { + return typeof val === 'function'; + }; + /** + * Test if the argument is a number. + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is a number + * @static + * @memberOf Tone + */ + Tone.isNumber = function (arg) { + return typeof arg === 'number'; + }; + /** + * Test if the given argument is an object literal (i.e. `{}`); + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is an object literal. + * @static + * @memberOf Tone + */ + Tone.isObject = function (arg) { + return Object.prototype.toString.call(arg) === '[object Object]' && arg.constructor === Object; + }; + /** + * Test if the argument is a boolean. + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is a boolean + * @static + * @memberOf Tone + */ + Tone.isBoolean = function (arg) { + return typeof arg === 'boolean'; + }; + /** + * Test if the argument is an Array + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is an array + * @static + * @memberOf Tone + */ + Tone.isArray = function (arg) { + return Array.isArray(arg); + }; + /** + * Test if the argument is a string. + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is a string + * @static + * @memberOf Tone + */ + Tone.isString = function (arg) { + return typeof arg === 'string'; + }; + /** + * Test if the argument is in the form of a note in scientific pitch notation. + * e.g. "C4" + * @param {*} arg the argument to test + * @returns {Boolean} true if the arg is a string + * @static + * @memberOf Tone + */ + Tone.isNote = function (arg) { + return Tone.isString(arg) && /^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(arg); + }; + /** + * An empty function. + * @static + */ + Tone.noOp = function () { + }; + /** + * Make the property not writable. Internal use only. + * @private + * @param {String} property the property to make not writable + */ + Tone.prototype._readOnly = function (property) { + if (Array.isArray(property)) { + for (var i = 0; i < property.length; i++) { + this._readOnly(property[i]); + } + } else { + Object.defineProperty(this, property, { + writable: false, + enumerable: true + }); + } + }; + /** + * Make an attribute writeable. Interal use only. + * @private + * @param {String} property the property to make writable + */ + Tone.prototype._writable = function (property) { + if (Array.isArray(property)) { + for (var i = 0; i < property.length; i++) { + this._writable(property[i]); + } + } else { + Object.defineProperty(this, property, { writable: true }); + } + }; + /** + * Possible play states. + * @enum {String} + */ + Tone.State = { + Started: 'started', + Stopped: 'stopped', + Paused: 'paused' + }; + /////////////////////////////////////////////////////////////////////////// + // CONVERSIONS + /////////////////////////////////////////////////////////////////////////// + /** + * Equal power gain scale. Good for cross-fading. + * @param {NormalRange} percent (0-1) + * @return {Number} output gain (0-1) + * @static + * @memberOf Tone + */ + Tone.equalPowerScale = function (percent) { + var piFactor = 0.5 * Math.PI; + return Math.sin(percent * piFactor); + }; + /** + * Convert decibels into gain. + * @param {Decibels} db + * @return {Number} + * @static + * @memberOf Tone + */ + Tone.dbToGain = function (db) { + return Math.pow(10, db / 20); + }; + /** + * Convert gain to decibels. + * @param {Number} gain (0-1) + * @return {Decibels} + * @static + * @memberOf Tone + */ + Tone.gainToDb = function (gain) { + return 20 * (Math.log(gain) / Math.LN10); + }; + /** + * Convert an interval (in semitones) to a frequency ratio. + * @param {Interval} interval the number of semitones above the base note + * @return {Number} the frequency ratio + * @static + * @memberOf Tone + * @example + * tone.intervalToFrequencyRatio(0); // 1 + * tone.intervalToFrequencyRatio(12); // 2 + * tone.intervalToFrequencyRatio(-12); // 0.5 + */ + Tone.intervalToFrequencyRatio = function (interval) { + return Math.pow(2, interval / 12); + }; + /////////////////////////////////////////////////////////////////////////// + // TIMING + /////////////////////////////////////////////////////////////////////////// + /** + * Return the current time of the AudioContext clock. + * @return {Number} the currentTime from the AudioContext + * @memberOf Tone# + */ + Tone.prototype.now = function () { + return Tone.context.now(); + }; + /** + * Return the current time of the AudioContext clock. + * @return {Number} the currentTime from the AudioContext + * @static + * @memberOf Tone + */ + Tone.now = function () { + return Tone.context.now(); + }; + /////////////////////////////////////////////////////////////////////////// + // INHERITANCE + /////////////////////////////////////////////////////////////////////////// + /** + * have a child inherit all of Tone's (or a parent's) prototype + * to inherit the parent's properties, make sure to call + * Parent.call(this) in the child's constructor + * + * based on closure library's inherit function + * + * @memberOf Tone + * @static + * @param {Function} child + * @param {Function=} parent (optional) parent to inherit from + * if no parent is supplied, the child + * will inherit from Tone + */ + Tone.extend = function (child, parent) { + if (Tone.isUndef(parent)) { + parent = Tone; + } + function TempConstructor() { + } + TempConstructor.prototype = parent.prototype; + child.prototype = new TempConstructor(); + /** @override */ + child.prototype.constructor = child; + child._super = parent; + }; + /////////////////////////////////////////////////////////////////////////// + // CONTEXT + /////////////////////////////////////////////////////////////////////////// + /** + * Private reference to the global AudioContext + * @type {AudioContext} + * @private + */ + var audioContext = null; + /** + * A static pointer to the audio context accessible as Tone.context. + * @type {Tone.Context} + * @name context + * @memberOf Tone + */ + Object.defineProperty(Tone, 'context', { + get: function () { + return audioContext; + }, + set: function (context) { + if (Tone.Context && context instanceof Tone.Context) { + audioContext = context; + } else { + audioContext = new Tone.Context(context); + } + //initialize the new audio context + Tone.Context.emit('init', audioContext); + } + }); + /** + * The AudioContext + * @type {Tone.Context} + * @name context + * @memberOf Tone# + * @readOnly + */ + Object.defineProperty(Tone.prototype, 'context', { + get: function () { + return Tone.context; + } + }); + /** + * Tone automatically creates a context on init, but if you are working + * with other libraries which also create an AudioContext, it can be + * useful to set your own. If you are going to set your own context, + * be sure to do it at the start of your code, before creating any objects. + * @static + * @param {AudioContext} ctx The new audio context to set + */ + Tone.setContext = function (ctx) { + Tone.context = ctx; + }; + /////////////////////////////////////////////////////////////////////////// + // ATTRIBUTES + /////////////////////////////////////////////////////////////////////////// + /** + * The number of seconds of 1 processing block (128 samples) + * @type {Number} + * @name blockTime + * @memberOf Tone + * @static + * @readOnly + */ + Object.defineProperty(Tone.prototype, 'blockTime', { + get: function () { + return 128 / this.context.sampleRate; + } + }); + /** + * The duration in seconds of one sample. + * @type {Number} + * @name sampleTime + * @memberOf Tone + * @static + * @readOnly + */ + Object.defineProperty(Tone.prototype, 'sampleTime', { + get: function () { + return 1 / this.context.sampleRate; + } + }); + /** + * Whether or not all the technologies that Tone.js relies on are supported by the current browser. + * @type {Boolean} + * @name supported + * @memberOf Tone + * @readOnly + * @static + */ + Object.defineProperty(Tone, 'supported', { + get: function () { + var hasAudioContext = window.hasOwnProperty('AudioContext') || window.hasOwnProperty('webkitAudioContext'); + var hasPromises = window.hasOwnProperty('Promise'); + var hasWorkers = window.hasOwnProperty('Worker'); + return hasAudioContext && hasPromises && hasWorkers; + } + }); + /** + * Boolean value if the audio context has been initialized. + * @type {Boolean} + * @memberOf Tone + * @static + * @name initialized + */ + Object.defineProperty(Tone, 'initialized', { + get: function () { + return audioContext !== null; + } + }); + /** + * Get the context when it becomes available + * @param {Function} resolve Callback when the context is initialized + * @return {Tone} + */ + Tone.getContext = function (resolve) { + if (Tone.initialized) { + resolve(Tone.context); + } else { + var resCallback = function () { + resolve(Tone.context); + Tone.Context.off('init', resCallback); + }; + Tone.Context.on('init', resCallback); + } + return Tone; + }; + /** + * The version number + * @type {String} + * @static + */ + Tone.version = 'r12'; + return Tone; + }); + Module(function (Tone) { + + /** + * @class Tone.Emitter gives classes which extend it + * the ability to listen for and emit events. + * Inspiration and reference from Jerome Etienne's [MicroEvent](https://github.com/jeromeetienne/microevent.js). + * MIT (c) 2011 Jerome Etienne. + * + * @extends {Tone} + */ + Tone.Emitter = function () { + Tone.call(this); + /** + * Contains all of the events. + * @private + * @type {Object} + */ + this._events = {}; + }; + Tone.extend(Tone.Emitter); + /** + * Bind a callback to a specific event. + * @param {String} event The name of the event to listen for. + * @param {Function} callback The callback to invoke when the + * event is emitted + * @return {Tone.Emitter} this + */ + Tone.Emitter.prototype.on = function (event, callback) { + //split the event + var events = event.split(/\W+/); + for (var i = 0; i < events.length; i++) { + var eventName = events[i]; + if (!this._events.hasOwnProperty(eventName)) { + this._events[eventName] = []; + } + this._events[eventName].push(callback); + } + return this; + }; + /** + * Bind a callback which is only invoked once + * @param {String} event The name of the event to listen for. + * @param {Function} callback The callback to invoke when the + * event is emitted + * @return {Tone.Emitter} this + */ + Tone.Emitter.prototype.once = function (event, callback) { + var boundCallback = function () { + //invoke the callback + callback.apply(this, arguments); + this.off(event, boundCallback); + }.bind(this); + this.on(event, boundCallback); + return this; + }; + /** + * Remove the event listener. + * @param {String} event The event to stop listening to. + * @param {Function=} callback The callback which was bound to + * the event with Tone.Emitter.on. + * If no callback is given, all callbacks + * events are removed. + * @return {Tone.Emitter} this + */ + Tone.Emitter.prototype.off = function (event, callback) { + var events = event.split(/\W+/); + for (var ev = 0; ev < events.length; ev++) { + event = events[ev]; + if (this._events.hasOwnProperty(event)) { + if (Tone.isUndef(callback)) { + this._events[event] = []; + } else { + var eventList = this._events[event]; + for (var i = 0; i < eventList.length; i++) { + if (eventList[i] === callback) { + eventList.splice(i, 1); + } + } + } + } + } + return this; + }; + /** + * Invoke all of the callbacks bound to the event + * with any arguments passed in. + * @param {String} event The name of the event. + * @param {*} args... The arguments to pass to the functions listening. + * @return {Tone.Emitter} this + */ + Tone.Emitter.prototype.emit = function (event) { + if (this._events) { + var args = Array.apply(null, arguments).slice(1); + if (this._events.hasOwnProperty(event)) { + var eventList = this._events[event].slice(0); + for (var i = 0, len = eventList.length; i < len; i++) { + eventList[i].apply(this, args); + } + } + } + return this; + }; + /** + * Add Emitter functions (on/off/emit) to the object + * @param {Object|Function} object The object or class to extend. + * @returns {Tone.Emitter} + */ + Tone.Emitter.mixin = function (object) { + var functions = [ + 'on', + 'once', + 'off', + 'emit' + ]; + object._events = {}; + for (var i = 0; i < functions.length; i++) { + var func = functions[i]; + var emitterFunc = Tone.Emitter.prototype[func]; + object[func] = emitterFunc; + } + return Tone.Emitter; + }; + /** + * Clean up + * @return {Tone.Emitter} this + */ + Tone.Emitter.prototype.dispose = function () { + Tone.prototype.dispose.call(this); + this._events = null; + return this; + }; + return Tone.Emitter; + }); + Module(function (Tone) { + + /** + * @class A Timeline class for scheduling and maintaining state + * along a timeline. All events must have a "time" property. + * Internally, events are stored in time order for fast + * retrieval. + * @extends {Tone} + * @param {Positive} [memory=Infinity] The number of previous events that are retained. + */ + Tone.Timeline = function () { + var options = Tone.defaults(arguments, ['memory'], Tone.Timeline); + Tone.call(this); + /** + * The array of scheduled timeline events + * @type {Array} + * @private + */ + this._timeline = []; + /** + * The memory of the timeline, i.e. + * how many events in the past it will retain + * @type {Positive} + */ + this.memory = options.memory; + }; + Tone.extend(Tone.Timeline); + /** + * the default parameters + * @static + * @const + */ + Tone.Timeline.defaults = { 'memory': Infinity }; + /** + * The number of items in the timeline. + * @type {Number} + * @memberOf Tone.Timeline# + * @name length + * @readOnly + */ + Object.defineProperty(Tone.Timeline.prototype, 'length', { + get: function () { + return this._timeline.length; + } + }); + /** + * Insert an event object onto the timeline. Events must have a "time" attribute. + * @param {Object} event The event object to insert into the + * timeline. + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.add = function (event) { + //the event needs to have a time attribute + if (Tone.isUndef(event.time)) { + throw new Error('Tone.Timeline: events must have a time attribute'); + } + event.time = event.time.valueOf(); + var index = this._search(event.time); + this._timeline.splice(index + 1, 0, event); + //if the length is more than the memory, remove the previous ones + if (this.length > this.memory) { + var diff = this.length - this.memory; + this._timeline.splice(0, diff); + } + return this; + }; + /** + * Remove an event from the timeline. + * @param {Object} event The event object to remove from the list. + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.remove = function (event) { + var index = this._timeline.indexOf(event); + if (index !== -1) { + this._timeline.splice(index, 1); + } + return this; + }; + /** + * Get the nearest event whose time is less than or equal to the given time. + * @param {Number} time The time to query. + * @param {String} comparator Which value in the object to compare + * @returns {Object} The event object set after that time. + */ + Tone.Timeline.prototype.get = function (time, comparator) { + comparator = Tone.defaultArg(comparator, 'time'); + var index = this._search(time, comparator); + if (index !== -1) { + return this._timeline[index]; + } else { + return null; + } + }; + /** + * Return the first event in the timeline without removing it + * @returns {Object} The first event object + */ + Tone.Timeline.prototype.peek = function () { + return this._timeline[0]; + }; + /** + * Return the first event in the timeline and remove it + * @returns {Object} The first event object + */ + Tone.Timeline.prototype.shift = function () { + return this._timeline.shift(); + }; + /** + * Get the event which is scheduled after the given time. + * @param {Number} time The time to query. + * @param {String} comparator Which value in the object to compare + * @returns {Object} The event object after the given time + */ + Tone.Timeline.prototype.getAfter = function (time, comparator) { + comparator = Tone.defaultArg(comparator, 'time'); + var index = this._search(time, comparator); + if (index + 1 < this._timeline.length) { + return this._timeline[index + 1]; + } else { + return null; + } + }; + /** + * Get the event before the event at the given time. + * @param {Number} time The time to query. + * @param {String} comparator Which value in the object to compare + * @returns {Object} The event object before the given time + */ + Tone.Timeline.prototype.getBefore = function (time, comparator) { + comparator = Tone.defaultArg(comparator, 'time'); + var len = this._timeline.length; + //if it's after the last item, return the last item + if (len > 0 && this._timeline[len - 1][comparator] < time) { + return this._timeline[len - 1]; + } + var index = this._search(time, comparator); + if (index - 1 >= 0) { + return this._timeline[index - 1]; + } else { + return null; + } + }; + /** + * Cancel events after the given time + * @param {Number} time The time to query. + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.cancel = function (after) { + if (this._timeline.length > 1) { + var index = this._search(after); + if (index >= 0) { + if (this._timeline[index].time === after) { + //get the first item with that time + for (var i = index; i >= 0; i--) { + if (this._timeline[i].time === after) { + index = i; + } else { + break; + } + } + this._timeline = this._timeline.slice(0, index); + } else { + this._timeline = this._timeline.slice(0, index + 1); + } + } else { + this._timeline = []; + } + } else if (this._timeline.length === 1) { + //the first item's time + if (this._timeline[0].time >= after) { + this._timeline = []; + } + } + return this; + }; + /** + * Cancel events before or equal to the given time. + * @param {Number} time The time to cancel before. + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.cancelBefore = function (time) { + var index = this._search(time); + if (index >= 0) { + this._timeline = this._timeline.slice(index + 1); + } + return this; + }; + /** + * Returns the previous event if there is one. null otherwise + * @param {Object} event The event to find the previous one of + * @return {Object} The event right before the given event + */ + Tone.Timeline.prototype.previousEvent = function (event) { + var index = this._timeline.indexOf(event); + if (index > 0) { + return this._timeline[index - 1]; + } else { + return null; + } + }; + /** + * Does a binary search on the timeline array and returns the + * nearest event index whose time is after or equal to the given time. + * If a time is searched before the first index in the timeline, -1 is returned. + * If the time is after the end, the index of the last item is returned. + * @param {Number} time + * @param {String} comparator Which value in the object to compare + * @return {Number} the index in the timeline array + * @private + */ + Tone.Timeline.prototype._search = function (time, comparator) { + if (this._timeline.length === 0) { + return -1; + } + comparator = Tone.defaultArg(comparator, 'time'); + var beginning = 0; + var len = this._timeline.length; + var end = len; + if (len > 0 && this._timeline[len - 1][comparator] <= time) { + return len - 1; + } + while (beginning < end) { + // calculate the midpoint for roughly equal partition + var midPoint = Math.floor(beginning + (end - beginning) / 2); + var event = this._timeline[midPoint]; + var nextEvent = this._timeline[midPoint + 1]; + if (event[comparator] === time) { + //choose the last one that has the same time + for (var i = midPoint; i < this._timeline.length; i++) { + var testEvent = this._timeline[i]; + if (testEvent[comparator] === time) { + midPoint = i; + } + } + return midPoint; + } else if (event[comparator] < time && nextEvent[comparator] > time) { + return midPoint; + } else if (event[comparator] > time) { + //search lower + end = midPoint; + } else { + //search upper + beginning = midPoint + 1; + } + } + return -1; + }; + /** + * Internal iterator. Applies extra safety checks for + * removing items from the array. + * @param {Function} callback + * @param {Number=} lowerBound + * @param {Number=} upperBound + * @private + */ + Tone.Timeline.prototype._iterate = function (callback, lowerBound, upperBound) { + lowerBound = Tone.defaultArg(lowerBound, 0); + upperBound = Tone.defaultArg(upperBound, this._timeline.length - 1); + this._timeline.slice(lowerBound, upperBound + 1).forEach(function (event) { + callback.call(this, event); + }.bind(this)); + }; + /** + * Iterate over everything in the array + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.forEach = function (callback) { + this._iterate(callback); + return this; + }; + /** + * Iterate over everything in the array at or before the given time. + * @param {Number} time The time to check if items are before + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.forEachBefore = function (time, callback) { + //iterate over the items in reverse so that removing an item doesn't break things + var upperBound = this._search(time); + if (upperBound !== -1) { + this._iterate(callback, 0, upperBound); + } + return this; + }; + /** + * Iterate over everything in the array after the given time. + * @param {Number} time The time to check if items are before + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.forEachAfter = function (time, callback) { + //iterate over the items in reverse so that removing an item doesn't break things + var lowerBound = this._search(time); + this._iterate(callback, lowerBound + 1); + return this; + }; + /** + * Iterate over everything in the array between the startTime and endTime. + * The timerange is inclusive of the startTime, but exclusive of the endTime. + * range = [startTime, endTime). + * @param {Number} startTime The time to check if items are before + * @param {Number} endTime The end of the test interval. + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.forEachBetween = function (startTime, endTime, callback) { + var lowerBound = this._search(startTime); + var upperBound = this._search(endTime); + if (lowerBound !== -1 && upperBound !== -1) { + if (this._timeline[lowerBound].time !== startTime) { + lowerBound += 1; + } + //exclusive of the end time + if (this._timeline[upperBound].time === endTime) { + upperBound -= 1; + } + this._iterate(callback, lowerBound, upperBound); + } else if (lowerBound === -1) { + this._iterate(callback, 0, upperBound); + } + return this; + }; + /** + * Iterate over everything in the array at or after the given time. Similar to + * forEachAfter, but includes the item(s) at the given time. + * @param {Number} time The time to check if items are before + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.forEachFrom = function (time, callback) { + //iterate over the items in reverse so that removing an item doesn't break things + var lowerBound = this._search(time); + //work backwards until the event time is less than time + while (lowerBound >= 0 && this._timeline[lowerBound].time >= time) { + lowerBound--; + } + this._iterate(callback, lowerBound + 1); + return this; + }; + /** + * Iterate over everything in the array at the given time + * @param {Number} time The time to check if items are before + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.Timeline} this + */ + Tone.Timeline.prototype.forEachAtTime = function (time, callback) { + //iterate over the items in reverse so that removing an item doesn't break things + var upperBound = this._search(time); + if (upperBound !== -1) { + this._iterate(function (event) { + if (event.time === time) { + callback.call(this, event); + } + }, 0, upperBound); + } + return this; + }; + /** + * Clean up. + * @return {Tone.Timeline} this + */ + Tone.Timeline.prototype.dispose = function () { + Tone.prototype.dispose.call(this); + this._timeline = null; + return this; + }; + return Tone.Timeline; + }); + Module(function (Tone) { + if (Tone.supported) { + if (!window.hasOwnProperty('OfflineAudioContext') && window.hasOwnProperty('webkitOfflineAudioContext')) { + window.OfflineAudioContext = window.webkitOfflineAudioContext; + } + //returns promise? + var context = new OfflineAudioContext(1, 1, 44100); + var ret = context.startRendering(); + if (!(ret instanceof Promise)) { + OfflineAudioContext.prototype._native_startRendering = OfflineAudioContext.prototype.startRendering; + OfflineAudioContext.prototype.startRendering = function () { + return new Promise(function (done) { + this.oncomplete = function (e) { + done(e.renderedBuffer); + }; + this._native_startRendering(); + }.bind(this)); + }; + } + } + }); + Module(function (Tone) { + if (Tone.supported) { + if (!window.hasOwnProperty('AudioContext') && window.hasOwnProperty('webkitAudioContext')) { + window.AudioContext = window.webkitAudioContext; + } + //not functionally equivalent, but only an API placeholder + if (!AudioContext.prototype.close) { + AudioContext.prototype.close = function () { + if (Tone.isFunction(this.suspend)) { + this.suspend(); + } + return Promise.resolve(); + }; + } + //not functionally equivalent + if (!AudioContext.prototype.resume) { + AudioContext.prototype.resume = function () { + return Promise.resolve(); + }; + } + //createGain + if (!AudioContext.prototype.createGain && AudioContext.prototype.createGainNode) { + AudioContext.prototype.createGain = AudioContext.prototype.createGainNode; + } + //createDelay + if (!AudioContext.prototype.createDelay && AudioContext.prototype.createDelayNode) { + AudioContext.prototype.createDelay = AudioContext.prototype.createDelayNode; + } + //test decodeAudioData returns a promise + // https://github.com/mohayonao/web-audio-api-shim/blob/master/src/AudioContext.js + // MIT License (c) 2015 @mohayonao + var decodeAudioDataPromise = false; + var offlineContext = new OfflineAudioContext(1, 1, 44100); + var audioData = new Uint32Array([ + 1179011410, + 48, + 1163280727, + 544501094, + 16, + 131073, + 44100, + 176400, + 1048580, + 1635017060, + 8, + 0, + 0, + 0, + 0 + ]).buffer; + try { + var ret = offlineContext.decodeAudioData(audioData); + if (ret instanceof Promise) { + decodeAudioDataPromise = true; + } + } catch (e) { + decodeAudioDataPromise = false; + } + if (!decodeAudioDataPromise) { + AudioContext.prototype._native_decodeAudioData = AudioContext.prototype.decodeAudioData; + AudioContext.prototype.decodeAudioData = function (audioData) { + return new Promise(function (success, error) { + this._native_decodeAudioData(audioData, success, error); + }.bind(this)); + }; + } + } + }); + Module(function (Tone) { + /** + * @class Wrapper around the native AudioContext. + * @extends {Tone.Emitter} + * @param {AudioContext=} context optionally pass in a context + */ + Tone.Context = function () { + Tone.Emitter.call(this); + var options = Tone.defaults(arguments, ['context'], Tone.Context); + if (!options.context) { + options.context = new window.AudioContext(); + if (!options.context) { + throw new Error('could not create AudioContext. Possibly too many AudioContexts running already.'); + } + } + this._context = options.context; + // extend all of the methods + for (var prop in this._context) { + this._defineProperty(this._context, prop); + } + /** + * The default latency hint + * @type {String} + * @private + */ + this._latencyHint = options.latencyHint; + /** + * An object containing all of the constants AudioBufferSourceNodes + * @type {Object} + * @private + */ + this._constants = {}; + /////////////////////////////////////////////////////////////////////// + // WORKER + /////////////////////////////////////////////////////////////////////// + /** + * The amount of time events are scheduled + * into the future + * @type {Number} + */ + this.lookAhead = options.lookAhead; + /** + * A reference to the actual computed update interval + * @type {Number} + * @private + */ + this._computedUpdateInterval = 0; + /** + * A reliable callback method + * @private + * @type {Ticker} + */ + this._ticker = new Ticker(this.emit.bind(this, 'tick'), options.clockSource, options.updateInterval); + /////////////////////////////////////////////////////////////////////// + // TIMEOUTS + /////////////////////////////////////////////////////////////////////// + /** + * All of the setTimeout events. + * @type {Tone.Timeline} + * @private + */ + this._timeouts = new Tone.Timeline(); + /** + * The timeout id counter + * @private + * @type {Number} + */ + this._timeoutIds = 0; + this.on('tick', this._timeoutLoop.bind(this)); + }; + Tone.extend(Tone.Context, Tone.Emitter); + Tone.Emitter.mixin(Tone.Context); + /** + * defaults + * @static + * @type {Object} + */ + Tone.Context.defaults = { + 'clockSource': 'worker', + 'latencyHint': 'interactive', + 'lookAhead': 0.1, + 'updateInterval': 0.03 + }; + /** + * Define a property on this Tone.Context. + * This is used to extend the native AudioContext + * @param {AudioContext} context + * @param {String} prop + * @private + */ + Tone.Context.prototype._defineProperty = function (context, prop) { + if (Tone.isUndef(this[prop])) { + Object.defineProperty(this, prop, { + get: function () { + if (typeof context[prop] === 'function') { + return context[prop].bind(context); + } else { + return context[prop]; + } + }, + set: function (val) { + context[prop] = val; + } + }); + } + }; + /** + * The current audio context time + * @return {Number} + */ + Tone.Context.prototype.now = function () { + return this._context.currentTime + this.lookAhead; + }; + /** + * Promise which is invoked when the context is running. + * Tries to resume the context if it's not started. + * @return {Promise} + */ + Tone.Context.prototype.ready = function () { + return new Promise(function (done) { + if (this._context.state === 'running') { + done(); + } else { + this._context.resume().then(function () { + done(); + }); + } + }.bind(this)); + }; + /** + * Promise which is invoked when the context is running. + * Tries to resume the context if it's not started. + * @return {Promise} + */ + Tone.Context.prototype.close = function () { + return this._context.close().then(function () { + Tone.Context.emit('close', this); + }.bind(this)); + }; + /** + * Generate a looped buffer at some constant value. + * @param {Number} val + * @return {BufferSourceNode} + */ + Tone.Context.prototype.getConstant = function (val) { + if (this._constants[val]) { + return this._constants[val]; + } else { + var buffer = this._context.createBuffer(1, 128, this._context.sampleRate); + var arr = buffer.getChannelData(0); + for (var i = 0; i < arr.length; i++) { + arr[i] = val; + } + var constant = this._context.createBufferSource(); + constant.channelCount = 1; + constant.channelCountMode = 'explicit'; + constant.buffer = buffer; + constant.loop = true; + constant.start(0); + this._constants[val] = constant; + return constant; + } + }; + /** + * The private loop which keeps track of the context scheduled timeouts + * Is invoked from the clock source + * @private + */ + Tone.Context.prototype._timeoutLoop = function () { + var now = this.now(); + while (this._timeouts && this._timeouts.length && this._timeouts.peek().time <= now) { + this._timeouts.shift().callback(); + } + }; + /** + * A setTimeout which is gaurenteed by the clock source. + * Also runs in the offline context. + * @param {Function} fn The callback to invoke + * @param {Seconds} timeout The timeout in seconds + * @returns {Number} ID to use when invoking Tone.Context.clearTimeout + */ + Tone.Context.prototype.setTimeout = function (fn, timeout) { + this._timeoutIds++; + var now = this.now(); + this._timeouts.add({ + callback: fn, + time: now + timeout, + id: this._timeoutIds + }); + return this._timeoutIds; + }; + /** + * Clears a previously scheduled timeout with Tone.context.setTimeout + * @param {Number} id The ID returned from setTimeout + * @return {Tone.Context} this + */ + Tone.Context.prototype.clearTimeout = function (id) { + this._timeouts.forEach(function (event) { + if (event.id === id) { + this.remove(event); + } + }); + return this; + }; + /** + * How often the Web Worker callback is invoked. + * This number corresponds to how responsive the scheduling + * can be. Context.updateInterval + Context.lookAhead gives you the + * total latency between scheduling an event and hearing it. + * @type {Number} + * @memberOf Tone.Context# + * @name updateInterval + */ + Object.defineProperty(Tone.Context.prototype, 'updateInterval', { + get: function () { + return this._ticker.updateInterval; + }, + set: function (interval) { + this._ticker.updateInterval = interval; + } + }); + /** + * What the source of the clock is, either "worker" (Web Worker [default]), + * "timeout" (setTimeout), or "offline" (none). + * @type {String} + * @memberOf Tone.Context# + * @name clockSource + */ + Object.defineProperty(Tone.Context.prototype, 'clockSource', { + get: function () { + return this._ticker.type; + }, + set: function (type) { + this._ticker.type = type; + } + }); + /** + * The type of playback, which affects tradeoffs between audio + * output latency and responsiveness. + * + * In addition to setting the value in seconds, the latencyHint also + * accepts the strings "interactive" (prioritizes low latency), + * "playback" (prioritizes sustained playback), "balanced" (balances + * latency and performance), and "fastest" (lowest latency, might glitch more often). + * @type {String|Seconds} + * @memberOf Tone.Context# + * @name latencyHint + * @example + * //set the lookAhead to 0.3 seconds + * Tone.context.latencyHint = 0.3; + */ + Object.defineProperty(Tone.Context.prototype, 'latencyHint', { + get: function () { + return this._latencyHint; + }, + set: function (hint) { + var lookAhead = hint; + this._latencyHint = hint; + if (Tone.isString(hint)) { + switch (hint) { + case 'interactive': + lookAhead = 0.1; + this._context.latencyHint = hint; + break; + case 'playback': + lookAhead = 0.8; + this._context.latencyHint = hint; + break; + case 'balanced': + lookAhead = 0.25; + this._context.latencyHint = hint; + break; + case 'fastest': + this._context.latencyHint = 'interactive'; + lookAhead = 0.01; + break; + } + } + this.lookAhead = lookAhead; + this.updateInterval = lookAhead / 3; + } + }); + /** + * Unlike other dispose methods, this returns a Promise + * which executes when the context is closed and disposed + * @returns {Promise} this + */ + Tone.Context.prototype.dispose = function () { + return this.close().then(function () { + Tone.Emitter.prototype.dispose.call(this); + this._ticker.dispose(); + this._ticker = null; + this._timeouts.dispose(); + this._timeouts = null; + for (var con in this._constants) { + this._constants[con].disconnect(); + } + this._constants = null; + }.bind(this)); + }; + /** + * @class A class which provides a reliable callback using either + * a Web Worker, or if that isn't supported, falls back to setTimeout. + * @private + */ + var Ticker = function (callback, type, updateInterval) { + /** + * Either "worker" or "timeout" + * @type {String} + * @private + */ + this._type = type; + /** + * The update interval of the worker + * @private + * @type {Number} + */ + this._updateInterval = updateInterval; + /** + * The callback to invoke at regular intervals + * @type {Function} + * @private + */ + this._callback = Tone.defaultArg(callback, Tone.noOp); + //create the clock source for the first time + this._createClock(); + }; + /** + * The possible ticker types + * @private + * @type {Object} + */ + Ticker.Type = { + Worker: 'worker', + Timeout: 'timeout', + Offline: 'offline' + }; + /** + * Generate a web worker + * @return {WebWorker} + * @private + */ + Ticker.prototype._createWorker = function () { + //URL Shim + window.URL = window.URL || window.webkitURL; + var blob = new Blob([//the initial timeout time + 'var timeoutTime = ' + (this._updateInterval * 1000).toFixed(1) + ';' + //onmessage callback + 'self.onmessage = function(msg){' + '\ttimeoutTime = parseInt(msg.data);' + '};' + //the tick function which posts a message + //and schedules a new tick + 'function tick(){' + '\tsetTimeout(tick, timeoutTime);' + '\tself.postMessage(\'tick\');' + '}' + //call tick initially + 'tick();']); + var blobUrl = URL.createObjectURL(blob); + var worker = new Worker(blobUrl); + worker.onmessage = this._callback.bind(this); + this._worker = worker; + }; + /** + * Create a timeout loop + * @private + */ + Ticker.prototype._createTimeout = function () { + this._timeout = setTimeout(function () { + this._createTimeout(); + this._callback(); + }.bind(this), this._updateInterval * 1000); + }; + /** + * Create the clock source. + * @private + */ + Ticker.prototype._createClock = function () { + if (this._type === Ticker.Type.Worker) { + try { + this._createWorker(); + } catch (e) { + // workers not supported, fallback to timeout + this._type = Ticker.Type.Timeout; + this._createClock(); + } + } else if (this._type === Ticker.Type.Timeout) { + this._createTimeout(); + } + }; + /** + * @memberOf Ticker# + * @type {Number} + * @name updateInterval + * @private + */ + Object.defineProperty(Ticker.prototype, 'updateInterval', { + get: function () { + return this._updateInterval; + }, + set: function (interval) { + this._updateInterval = Math.max(interval, 128 / 44100); + if (this._type === Ticker.Type.Worker) { + this._worker.postMessage(Math.max(interval * 1000, 1)); + } + } + }); + /** + * The type of the ticker, either a worker or a timeout + * @memberOf Ticker# + * @type {Number} + * @name type + * @private + */ + Object.defineProperty(Ticker.prototype, 'type', { + get: function () { + return this._type; + }, + set: function (type) { + this._disposeClock(); + this._type = type; + this._createClock(); + } + }); + /** + * Clean up the current clock source + * @private + */ + Ticker.prototype._disposeClock = function () { + if (this._timeout) { + clearTimeout(this._timeout); + this._timeout = null; + } + if (this._worker) { + this._worker.terminate(); + this._worker.onmessage = null; + this._worker = null; + } + }; + /** + * Clean up + * @private + */ + Ticker.prototype.dispose = function () { + this._disposeClock(); + this._callback = null; + }; + /** + * Shim all connect/disconnect and some deprecated methods which are still in + * some older implementations. + * @private + */ + Tone.getContext(function () { + var nativeConnect = AudioNode.prototype.connect; + var nativeDisconnect = AudioNode.prototype.disconnect; + //replace the old connect method + function toneConnect(B, outNum, inNum) { + if (B.input) { + inNum = Tone.defaultArg(inNum, 0); + if (Tone.isArray(B.input)) { + return this.connect(B.input[inNum]); + } else { + return this.connect(B.input, outNum, inNum); + } + } else { + try { + if (B instanceof AudioNode) { + nativeConnect.call(this, B, outNum, inNum); + return B; + } else { + nativeConnect.call(this, B, outNum); + return B; + } + } catch (e) { + throw new Error('error connecting to node: ' + B + '\n' + e); + } + } + } + //replace the old disconnect method + function toneDisconnect(B, outNum, inNum) { + if (B && B.input && Tone.isArray(B.input)) { + inNum = Tone.defaultArg(inNum, 0); + this.disconnect(B.input[inNum], outNum, 0); + } else if (B && B.input) { + this.disconnect(B.input, outNum, inNum); + } else { + try { + nativeDisconnect.apply(this, arguments); + } catch (e) { + throw new Error('error disconnecting node: ' + B + '\n' + e); + } + } + } + if (AudioNode.prototype.connect !== toneConnect) { + AudioNode.prototype.connect = toneConnect; + AudioNode.prototype.disconnect = toneDisconnect; + } + }); + // set the audio context initially, and if one is not already created + if (Tone.supported && !Tone.initialized) { + Tone.context = new Tone.Context(); + // log on first initialization + // allow optional silencing of this log + if (!window.TONE_SILENCE_VERSION_LOGGING) { + // eslint-disable-next-line no-console + console.log('%c * Tone.js ' + Tone.version + ' * ', 'background: #000; color: #fff'); + } + } else if (!Tone.supported) { + // eslint-disable-next-line no-console + console.warn('This browser does not support Tone.js'); + } + return Tone.Context; + }); + Module(function (Tone) { + /** + * @class Tone.AudioNode is the base class for classes which process audio. + * AudioNodes have inputs and outputs. + * @param {AudioContext=} context The audio context to use with the class + * @extends {Tone} + */ + Tone.AudioNode = function () { + Tone.call(this); + //use the default context if one is not passed in + var options = Tone.defaults(arguments, ['context'], { 'context': Tone.context }); + /** + * The AudioContext of this instance + * @private + * @type {AudioContext} + */ + this._context = options.context; + }; + Tone.extend(Tone.AudioNode); + /** + * Get the audio context belonging to this instance. + * @type {Tone.Context} + * @memberOf Tone.AudioNode# + * @name context + * @readOnly + */ + Object.defineProperty(Tone.AudioNode.prototype, 'context', { + get: function () { + return this._context; + } + }); + /** + * Create input and outputs for this object. + * @param {Number} [input=0] The number of inputs + * @param {Number} [outputs=0] The number of outputs + * @return {Tone.AudioNode} this + * @private + */ + Tone.AudioNode.prototype.createInsOuts = function (inputs, outputs) { + if (inputs === 1) { + this.input = this.context.createGain(); + } else if (inputs > 1) { + this.input = new Array(inputs); + } + if (outputs === 1) { + this.output = this.context.createGain(); + } else if (outputs > 1) { + this.output = new Array(outputs); + } + }; + /** + * channelCount is the number of channels used when up-mixing and down-mixing + * connections to any inputs to the node. The default value is 2 except for + * specific nodes where its value is specially determined. + * + * @memberof Tone.AudioNode# + * @type {Number} + * @name channelCount + * @readOnly + */ + Object.defineProperty(Tone.AudioNode.prototype, 'channelCount', { + get: function () { + return this.output.channelCount; + }, + set: function (c) { + return this.output.channelCount = c; + } + }); + /** + * channelCountMode determines how channels will be counted when up-mixing and + * down-mixing connections to any inputs to the node. + * The default value is "max". This attribute has no effect for nodes with no inputs. + * @memberof Tone.AudioNode# + * @type {String} + * @name channelCountMode + * @readOnly + */ + Object.defineProperty(Tone.AudioNode.prototype, 'channelCountMode', { + get: function () { + return this.output.channelCountMode; + }, + set: function (m) { + return this.output.channelCountMode = m; + } + }); + /** + * channelInterpretation determines how individual channels will be treated + * when up-mixing and down-mixing connections to any inputs to the node. + * The default value is "speakers". + * @memberof Tone.AudioNode# + * @type {String} + * @name channelInterpretation + * @readOnly + */ + Object.defineProperty(Tone.AudioNode.prototype, 'channelInterpretation', { + get: function () { + return this.output.channelInterpretation; + }, + set: function (i) { + return this.output.channelInterpretation = i; + } + }); + /** + * The number of inputs feeding into the AudioNode. + * For source nodes, this will be 0. + * @type {Number} + * @name numberOfInputs + * @memberof Tone.AudioNode# + * @readOnly + */ + Object.defineProperty(Tone.AudioNode.prototype, 'numberOfInputs', { + get: function () { + if (this.input) { + if (Tone.isArray(this.input)) { + return this.input.length; + } else { + return 1; + } + } else { + return 0; + } + } + }); + /** + * The number of outputs coming out of the AudioNode. + * @type {Number} + * @name numberOfOutputs + * @memberof Tone.AudioNode# + * @readOnly + */ + Object.defineProperty(Tone.AudioNode.prototype, 'numberOfOutputs', { + get: function () { + if (this.output) { + if (Tone.isArray(this.output)) { + return this.output.length; + } else { + return 1; + } + } else { + return 0; + } + } + }); + /** + * Called when an audio param connects to this node + * @private + */ + Tone.AudioNode.prototype._onConnect = function () { + }; + /** + * connect the output of a ToneNode to an AudioParam, AudioNode, or ToneNode + * @param {Tone | AudioParam | AudioNode} unit + * @param {number} [outputNum=0] optionally which output to connect from + * @param {number} [inputNum=0] optionally which input to connect to + * @returns {Tone.AudioNode} this + */ + Tone.AudioNode.prototype.connect = function (unit, outputNum, inputNum) { + if (unit._onConnect) { + unit._onConnect(this); + } + if (Tone.isArray(this.output)) { + outputNum = Tone.defaultArg(outputNum, 0); + this.output[outputNum].connect(unit, 0, inputNum); + } else { + this.output.connect(unit, outputNum, inputNum); + } + return this; + }; + /** + * disconnect the output + * @param {Number|AudioNode} output Either the output index to disconnect + * if the output is an array, or the + * node to disconnect from. + * @returns {Tone.AudioNode} this + */ + Tone.AudioNode.prototype.disconnect = function (destination, outputNum, inputNum) { + if (Tone.isArray(this.output)) { + if (Tone.isNumber(destination)) { + this.output[destination].disconnect(); + } else { + outputNum = Tone.defaultArg(outputNum, 0); + this.output[outputNum].disconnect(destination, 0, inputNum); + } + } else { + this.output.disconnect.apply(this.output, arguments); + } + }; + /** + * Connect the output of this node to the rest of the nodes in series. + * @example + * //connect a node to an effect, panVol and then to the master output + * node.chain(effect, panVol, Tone.Master); + * @param {...AudioParam|Tone|AudioNode} nodes + * @returns {Tone.AudioNode} this + * @private + */ + Tone.AudioNode.prototype.chain = function () { + var currentUnit = this; + for (var i = 0; i < arguments.length; i++) { + var toUnit = arguments[i]; + currentUnit.connect(toUnit); + currentUnit = toUnit; + } + return this; + }; + /** + * connect the output of this node to the rest of the nodes in parallel. + * @param {...AudioParam|Tone|AudioNode} nodes + * @returns {Tone.AudioNode} this + * @private + */ + Tone.AudioNode.prototype.fan = function () { + for (var i = 0; i < arguments.length; i++) { + this.connect(arguments[i]); + } + return this; + }; + if (window.AudioNode) { + //give native nodes chain and fan methods + AudioNode.prototype.chain = Tone.AudioNode.prototype.chain; + AudioNode.prototype.fan = Tone.AudioNode.prototype.fan; + } + /** + * Dispose and disconnect + * @return {Tone.AudioNode} this + */ + Tone.AudioNode.prototype.dispose = function () { + if (Tone.isDefined(this.input)) { + if (this.input instanceof AudioNode) { + this.input.disconnect(); + } + this.input = null; + } + if (Tone.isDefined(this.output)) { + if (this.output instanceof AudioNode) { + this.output.disconnect(); + } + this.output = null; + } + this._context = null; + return this; + }; + return Tone.AudioNode; + }); + Module(function (Tone) { + + /** + * @class Base class for all Signals. Used Internally. + * + * @constructor + * @extends {Tone} + */ + Tone.SignalBase = function () { + Tone.AudioNode.call(this); + }; + Tone.extend(Tone.SignalBase, Tone.AudioNode); + /** + * When signals connect to other signals or AudioParams, + * they take over the output value of that signal or AudioParam. + * For all other nodes, the behavior is the same as a default <code>connect</code>. + * + * @override + * @param {AudioParam|AudioNode|Tone.Signal|Tone} node + * @param {number} [outputNumber=0] The output number to connect from. + * @param {number} [inputNumber=0] The input number to connect to. + * @returns {Tone.SignalBase} this + */ + Tone.SignalBase.prototype.connect = function (node, outputNumber, inputNumber) { + //zero it out so that the signal can have full control + if (Tone.Signal && Tone.Signal === node.constructor || Tone.Param && Tone.Param === node.constructor) { + //cancel changes + node._param.cancelScheduledValues(0); + //reset the value + node._param.value = 0; + //mark the value as overridden + node.overridden = true; + } else if (node instanceof AudioParam) { + node.cancelScheduledValues(0); + node.value = 0; + } + Tone.AudioNode.prototype.connect.call(this, node, outputNumber, inputNumber); + return this; + }; + return Tone.SignalBase; + }); + Module(function (Tone) { + if (Tone.supported) { + //fixes safari only bug which is still present in 11 + var ua = navigator.userAgent.toLowerCase(); + var isSafari = ua.includes('safari') && !ua.includes('chrome'); + if (isSafari) { + var WaveShaperNode = function (context) { + this._internalNode = this.input = this.output = context._native_createWaveShaper(); + this._curve = null; + for (var prop in this._internalNode) { + this._defineProperty(this._internalNode, prop); + } + }; + Object.defineProperty(WaveShaperNode.prototype, 'curve', { + get: function () { + return this._curve; + }, + set: function (curve) { + this._curve = curve; + var array = new Float32Array(curve.length + 1); + array.set(curve, 1); + array[0] = curve[0]; + this._internalNode.curve = array; + } + }); + WaveShaperNode.prototype._defineProperty = function (context, prop) { + if (Tone.isUndef(this[prop])) { + Object.defineProperty(this, prop, { + get: function () { + if (typeof context[prop] === 'function') { + return context[prop].bind(context); + } else { + return context[prop]; + } + }, + set: function (val) { + context[prop] = val; + } + }); + } + }; + AudioContext.prototype._native_createWaveShaper = AudioContext.prototype.createWaveShaper; + AudioContext.prototype.createWaveShaper = function () { + return new WaveShaperNode(this); + }; + } + } + }); + Module(function (Tone) { + + /** + * @class Wraps the native Web Audio API + * [WaveShaperNode](http://webaudio.github.io/web-audio-api/#the-waveshapernode-interface). + * + * @extends {Tone.SignalBase} + * @constructor + * @param {function|Array|Number} mapping The function used to define the values. + * The mapping function should take two arguments: + * the first is the value at the current position + * and the second is the array position. + * If the argument is an array, that array will be + * set as the wave shaping function. The input + * signal is an AudioRange [-1, 1] value and the output + * signal can take on any numerical values. + * + * @param {Number} [bufferLen=1024] The length of the WaveShaperNode buffer. + * @example + * var timesTwo = new Tone.WaveShaper(function(val){ + * return val * 2; + * }, 2048); + * @example + * //a waveshaper can also be constructed with an array of values + * var invert = new Tone.WaveShaper([1, -1]); + */ + Tone.WaveShaper = function (mapping, bufferLen) { + Tone.SignalBase.call(this); + /** + * the waveshaper + * @type {WaveShaperNode} + * @private + */ + this._shaper = this.input = this.output = this.context.createWaveShaper(); + /** + * the waveshapers curve + * @type {Float32Array} + * @private + */ + this._curve = null; + if (Array.isArray(mapping)) { + this.curve = mapping; + } else if (isFinite(mapping) || Tone.isUndef(mapping)) { + this._curve = new Float32Array(Tone.defaultArg(mapping, 1024)); + } else if (Tone.isFunction(mapping)) { + this._curve = new Float32Array(Tone.defaultArg(bufferLen, 1024)); + this.setMap(mapping); + } + }; + Tone.extend(Tone.WaveShaper, Tone.SignalBase); + /** + * Uses a mapping function to set the value of the curve. + * @param {function} mapping The function used to define the values. + * The mapping function take two arguments: + * the first is the value at the current position + * which goes from -1 to 1 over the number of elements + * in the curve array. The second argument is the array position. + * @returns {Tone.WaveShaper} this + * @example + * //map the input signal from [-1, 1] to [0, 10] + * shaper.setMap(function(val, index){ + * return (val + 1) * 5; + * }) + */ + Tone.WaveShaper.prototype.setMap = function (mapping) { + var array = new Array(this._curve.length); + for (var i = 0, len = this._curve.length; i < len; i++) { + var normalized = i / (len - 1) * 2 - 1; + array[i] = mapping(normalized, i); + } + this.curve = array; + return this; + }; + /** + * The array to set as the waveshaper curve. For linear curves + * array length does not make much difference, but for complex curves + * longer arrays will provide smoother interpolation. + * @memberOf Tone.WaveShaper# + * @type {Array} + * @name curve + */ + Object.defineProperty(Tone.WaveShaper.prototype, 'curve', { + get: function () { + return this._shaper.curve; + }, + set: function (mapping) { + this._curve = new Float32Array(mapping); + this._shaper.curve = this._curve; + } + }); + /** + * Specifies what type of oversampling (if any) should be used when + * applying the shaping curve. Can either be "none", "2x" or "4x". + * @memberOf Tone.WaveShaper# + * @type {string} + * @name oversample + */ + Object.defineProperty(Tone.WaveShaper.prototype, 'oversample', { + get: function () { + return this._shaper.oversample; + }, + set: function (oversampling) { + if ([ + 'none', + '2x', + '4x' + ].includes(oversampling)) { + this._shaper.oversample = oversampling; + } else { + throw new RangeError('Tone.WaveShaper: oversampling must be either \'none\', \'2x\', or \'4x\''); + } + } + }); + /** + * Clean up. + * @returns {Tone.WaveShaper} this + */ + Tone.WaveShaper.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._shaper.disconnect(); + this._shaper = null; + this._curve = null; + return this; + }; + return Tone.WaveShaper; + }); + Module(function (Tone) { + /** + * @class Tone.TimeBase is a flexible encoding of time + * which can be evaluated to and from a string. + * @extends {Tone} + * @param {Time} val The time value as a number or string + * @param {String=} units Unit values + * @example + * Tone.TimeBase(4, "n") + * Tone.TimeBase(2, "t") + * Tone.TimeBase("2t") + * Tone.TimeBase("2t") + Tone.TimeBase("4n"); + */ + Tone.TimeBase = function (val, units) { + //allows it to be constructed with or without 'new' + if (this instanceof Tone.TimeBase) { + /** + * The value + * @type {Number|String|Tone.TimeBase} + * @private + */ + this._val = val; + /** + * The units + * @type {String?} + * @private + */ + this._units = units; + //test if the value is a string representation of a number + if (Tone.isUndef(this._units) && Tone.isString(this._val) && // eslint-disable-next-line eqeqeq + parseFloat(this._val) == this._val && this._val.charAt(0) !== '+') { + this._val = parseFloat(this._val); + this._units = this._defaultUnits; + } else if (val && val.constructor === this.constructor) { + //if they're the same type, just copy values over + this._val = val._val; + this._units = val._units; + } else if (val instanceof Tone.TimeBase) { + switch (this._defaultUnits) { + case 's': + this._val = val.toSeconds(); + break; + case 'i': + this._val = val.toTicks(); + break; + case 'hz': + this._val = val.toFrequency(); + break; + case 'midi': + this._val = val.toMidi(); + break; + default: + throw new Error('Unrecognized default units ' + this._defaultUnits); + } + } + } else { + return new Tone.TimeBase(val, units); + } + }; + Tone.extend(Tone.TimeBase); + /////////////////////////////////////////////////////////////////////////// + // ABSTRACT SYNTAX TREE PARSER + /////////////////////////////////////////////////////////////////////////// + /** + * All the primary expressions. + * @private + * @type {Object} + */ + Tone.TimeBase.prototype._expressions = { + 'n': { + regexp: /^(\d+)n(\.?)$/i, + method: function (value, dot) { + value = parseInt(value); + var scalar = dot === '.' ? 1.5 : 1; + if (value === 1) { + return this._beatsToUnits(this._getTimeSignature()) * scalar; + } else { + return this._beatsToUnits(4 / value) * scalar; + } + } + }, + 't': { + regexp: /^(\d+)t$/i, + method: function (value) { + value = parseInt(value); + return this._beatsToUnits(8 / (parseInt(value) * 3)); + } + }, + 'm': { + regexp: /^(\d+)m$/i, + method: function (value) { + return this._beatsToUnits(parseInt(value) * this._getTimeSignature()); + } + }, + 'i': { + regexp: /^(\d+)i$/i, + method: function (value) { + return this._ticksToUnits(parseInt(value)); + } + }, + 'hz': { + regexp: /^(\d+(?:\.\d+)?)hz$/i, + method: function (value) { + return this._frequencyToUnits(parseFloat(value)); + } + }, + 'tr': { + regexp: /^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/, + method: function (m, q, s) { + var total = 0; + if (m && m !== '0') { + total += this._beatsToUnits(this._getTimeSignature() * parseFloat(m)); + } + if (q && q !== '0') { + total += this._beatsToUnits(parseFloat(q)); + } + if (s && s !== '0') { + total += this._beatsToUnits(parseFloat(s) / 4); + } + return total; + } + }, + 's': { + regexp: /^(\d+(?:\.\d+)?)s$/, + method: function (value) { + return this._secondsToUnits(parseFloat(value)); + } + }, + 'samples': { + regexp: /^(\d+)samples$/, + method: function (value) { + return parseInt(value) / this.context.sampleRate; + } + }, + 'default': { + regexp: /^(\d+(?:\.\d+)?)$/, + method: function (value) { + return this._expressions[this._defaultUnits].method.call(this, value); + } + } + }; + /** + * The default units if none are given. + * @type {String} + * @private + */ + Tone.TimeBase.prototype._defaultUnits = 's'; + /////////////////////////////////////////////////////////////////////////// + // TRANSPORT FALLBACKS + /////////////////////////////////////////////////////////////////////////// + /** + * Return the bpm, or 120 if Transport is not available + * @type {Number} + * @private + */ + Tone.TimeBase.prototype._getBpm = function () { + if (Tone.Transport) { + return Tone.Transport.bpm.value; + } else { + return 120; + } + }; + /** + * Return the timeSignature or 4 if Transport is not available + * @type {Number} + * @private + */ + Tone.TimeBase.prototype._getTimeSignature = function () { + if (Tone.Transport) { + return Tone.Transport.timeSignature; + } else { + return 4; + } + }; + /** + * Return the PPQ or 192 if Transport is not available + * @type {Number} + * @private + */ + Tone.TimeBase.prototype._getPPQ = function () { + if (Tone.Transport) { + return Tone.Transport.PPQ; + } else { + return 192; + } + }; + /** + * Return the current time in whichever context is relevant + * @type {Number} + * @private + */ + Tone.TimeBase.prototype._now = function () { + return this.now(); + }; + /////////////////////////////////////////////////////////////////////////// + // UNIT CONVERSIONS + /////////////////////////////////////////////////////////////////////////// + /** + * Returns the value of a frequency in the current units + * @param {Frequency} freq + * @return {Number} + * @private + */ + Tone.TimeBase.prototype._frequencyToUnits = function (freq) { + return 1 / freq; + }; + /** + * Return the value of the beats in the current units + * @param {Number} beats + * @return {Number} + * @private + */ + Tone.TimeBase.prototype._beatsToUnits = function (beats) { + return 60 / this._getBpm() * beats; + }; + /** + * Returns the value of a second in the current units + * @param {Seconds} seconds + * @return {Number} + * @private + */ + Tone.TimeBase.prototype._secondsToUnits = function (seconds) { + return seconds; + }; + /** + * Returns the value of a tick in the current time units + * @param {Ticks} ticks + * @return {Number} + * @private + */ + Tone.TimeBase.prototype._ticksToUnits = function (ticks) { + return ticks * (this._beatsToUnits(1) / this._getPPQ()); + }; + /** + * With no arguments, return 'now' + * @return {Number} + * @private + */ + Tone.TimeBase.prototype._noArg = function () { + return this._now(); + }; + /////////////////////////////////////////////////////////////////////////// + // EXPRESSIONS + /////////////////////////////////////////////////////////////////////////// + /** + * Evaluate the time value. Returns the time + * in seconds. + * @return {Seconds} + */ + Tone.TimeBase.prototype.valueOf = function () { + if (Tone.isUndef(this._val)) { + return this._noArg(); + } else if (Tone.isString(this._val) && Tone.isUndef(this._units)) { + for (var units in this._expressions) { + if (this._expressions[units].regexp.test(this._val.trim())) { + this._units = units; + break; + } + } + } + if (Tone.isDefined(this._units)) { + var expr = this._expressions[this._units]; + var matching = this._val.toString().trim().match(expr.regexp); + if (matching) { + return expr.method.apply(this, matching.slice(1)); + } else { + return expr.method.call(this, parseFloat(this._val)); + } + } else { + return this._val; + } + }; + /** + * Return the value in seconds + * @return {Seconds} + */ + Tone.TimeBase.prototype.toSeconds = function () { + return this.valueOf(); + }; + /** + * Return the value in hertz + * @return {Frequency} + */ + Tone.TimeBase.prototype.toFrequency = function () { + return 1 / this.toSeconds(); + }; + /** + * Return the time in samples + * @return {Samples} + */ + Tone.TimeBase.prototype.toSamples = function () { + return this.toSeconds() * this.context.sampleRate; + }; + /** + * Return the time in milliseconds. + * @return {Milliseconds} + */ + Tone.TimeBase.prototype.toMilliseconds = function () { + return this.toSeconds() * 1000; + }; + /** + * Clean up + * @return {Tone.TimeBase} this + */ + Tone.TimeBase.prototype.dispose = function () { + this._val = null; + this._units = null; + }; + return Tone.TimeBase; + }); + Module(function (Tone) { + /** + * @class Tone.Frequency is a primitive type for encoding Frequency values. + * Eventually all time values are evaluated to hertz + * using the `eval` method. + * @constructor + * @extends {Tone.TimeBase} + * @param {String|Number} val The time value. + * @param {String=} units The units of the value. + * @example + * Tone.Frequency("C3") // 261 + * Tone.Frequency(38, "midi") // + * Tone.Frequency("C3").transpose(4); + */ + Tone.Frequency = function (val, units) { + if (this instanceof Tone.Frequency) { + Tone.TimeBase.call(this, val, units); + } else { + return new Tone.Frequency(val, units); + } + }; + Tone.extend(Tone.Frequency, Tone.TimeBase); + /////////////////////////////////////////////////////////////////////////// + // AUGMENT BASE EXPRESSIONS + /////////////////////////////////////////////////////////////////////////// + Tone.Frequency.prototype._expressions = Object.assign({}, Tone.TimeBase.prototype._expressions, { + 'midi': { + regexp: /^(\d+(?:\.\d+)?midi)/, + method: function (value) { + if (this._defaultUnits === 'midi') { + return value; + } else { + return Tone.Frequency.mtof(value); + } + } + }, + 'note': { + regexp: /^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i, + method: function (pitch, octave) { + var index = noteToScaleIndex[pitch.toLowerCase()]; + var noteNumber = index + (parseInt(octave) + 1) * 12; + if (this._defaultUnits === 'midi') { + return noteNumber; + } else { + return Tone.Frequency.mtof(noteNumber); + } + } + }, + 'tr': { + regexp: /^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/, + method: function (m, q, s) { + var total = 1; + if (m && m !== '0') { + total *= this._beatsToUnits(this._getTimeSignature() * parseFloat(m)); + } + if (q && q !== '0') { + total *= this._beatsToUnits(parseFloat(q)); + } + if (s && s !== '0') { + total *= this._beatsToUnits(parseFloat(s) / 4); + } + return total; + } + } + }); + /////////////////////////////////////////////////////////////////////////// + // EXPRESSIONS + /////////////////////////////////////////////////////////////////////////// + /** + * Transposes the frequency by the given number of semitones. + * @param {Interval} interval + * @return {Tone.Frequency} A new transposed frequency + * @example + * Tone.Frequency("A4").transpose(3); //"C5" + */ + Tone.Frequency.prototype.transpose = function (interval) { + return new this.constructor(this.valueOf() * Tone.intervalToFrequencyRatio(interval)); + }; + /** + * Takes an array of semitone intervals and returns + * an array of frequencies transposed by those intervals. + * @param {Array} intervals + * @return {Array<Tone.Frequency>} Returns an array of Frequencies + * @example + * Tone.Frequency("A4").harmonize([0, 3, 7]); //["A4", "C5", "E5"] + */ + Tone.Frequency.prototype.harmonize = function (intervals) { + return intervals.map(function (interval) { + return this.transpose(interval); + }.bind(this)); + }; + /////////////////////////////////////////////////////////////////////////// + // UNIT CONVERSIONS + /////////////////////////////////////////////////////////////////////////// + /** + * Return the value of the frequency as a MIDI note + * @return {MIDI} + * @example + * Tone.Frequency("C4").toMidi(); //60 + */ + Tone.Frequency.prototype.toMidi = function () { + return Tone.Frequency.ftom(this.valueOf()); + }; + /** + * Return the value of the frequency in Scientific Pitch Notation + * @return {Note} + * @example + * Tone.Frequency(69, "midi").toNote(); //"A4" + */ + Tone.Frequency.prototype.toNote = function () { + var freq = this.toFrequency(); + var log = Math.log2(freq / Tone.Frequency.A4); + var noteNumber = Math.round(12 * log) + 57; + var octave = Math.floor(noteNumber / 12); + if (octave < 0) { + noteNumber += -12 * octave; + } + var noteName = scaleIndexToNote[noteNumber % 12]; + return noteName + octave.toString(); + }; + /** + * Return the duration of one cycle in seconds. + * @return {Seconds} + */ + Tone.Frequency.prototype.toSeconds = function () { + return 1 / Tone.TimeBase.prototype.toSeconds.call(this); + }; + /** + * Return the value in Hertz + * @return {Frequency} + */ + Tone.Frequency.prototype.toFrequency = function () { + return Tone.TimeBase.prototype.toFrequency.call(this); + }; + /** + * Return the duration of one cycle in ticks + * @return {Ticks} + */ + Tone.Frequency.prototype.toTicks = function () { + var quarterTime = this._beatsToUnits(1); + var quarters = this.valueOf() / quarterTime; + return Math.floor(quarters * Tone.Transport.PPQ); + }; + /////////////////////////////////////////////////////////////////////////// + // UNIT CONVERSIONS HELPERS + /////////////////////////////////////////////////////////////////////////// + /** + * With no arguments, return 0 + * @return {Number} + * @private + */ + Tone.Frequency.prototype._noArg = function () { + return 0; + }; + /** + * Returns the value of a frequency in the current units + * @param {Frequency} freq + * @return {Number} + * @private + */ + Tone.Frequency.prototype._frequencyToUnits = function (freq) { + return freq; + }; + /** + * Returns the value of a tick in the current time units + * @param {Ticks} ticks + * @return {Number} + * @private + */ + Tone.Frequency.prototype._ticksToUnits = function (ticks) { + return 1 / (ticks * 60 / (Tone.Transport.bpm.value * Tone.Transport.PPQ)); + }; + /** + * Return the value of the beats in the current units + * @param {Number} beats + * @return {Number} + * @private + */ + Tone.Frequency.prototype._beatsToUnits = function (beats) { + return 1 / Tone.TimeBase.prototype._beatsToUnits.call(this, beats); + }; + /** + * Returns the value of a second in the current units + * @param {Seconds} seconds + * @return {Number} + * @private + */ + Tone.Frequency.prototype._secondsToUnits = function (seconds) { + return 1 / seconds; + }; + /** + * The default units if none are given. + * @private + */ + Tone.Frequency.prototype._defaultUnits = 'hz'; + /////////////////////////////////////////////////////////////////////////// + // FREQUENCY CONVERSIONS + /////////////////////////////////////////////////////////////////////////// + /** + * Note to scale index + * @type {Object} + */ + var noteToScaleIndex = { + 'cbb': -2, + 'cb': -1, + 'c': 0, + 'c#': 1, + 'cx': 2, + 'dbb': 0, + 'db': 1, + 'd': 2, + 'd#': 3, + 'dx': 4, + 'ebb': 2, + 'eb': 3, + 'e': 4, + 'e#': 5, + 'ex': 6, + 'fbb': 3, + 'fb': 4, + 'f': 5, + 'f#': 6, + 'fx': 7, + 'gbb': 5, + 'gb': 6, + 'g': 7, + 'g#': 8, + 'gx': 9, + 'abb': 7, + 'ab': 8, + 'a': 9, + 'a#': 10, + 'ax': 11, + 'bbb': 9, + 'bb': 10, + 'b': 11, + 'b#': 12, + 'bx': 13 + }; + /** + * scale index to note (sharps) + * @type {Array} + */ + var scaleIndexToNote = [ + 'C', + 'C#', + 'D', + 'D#', + 'E', + 'F', + 'F#', + 'G', + 'G#', + 'A', + 'A#', + 'B' + ]; + /** + * The [concert pitch](https://en.wikipedia.org/wiki/Concert_pitch) + * A4's values in Hertz. + * @type {Frequency} + * @static + */ + Tone.Frequency.A4 = 440; + /** + * Convert a MIDI note to frequency value. + * @param {MIDI} midi The midi number to convert. + * @return {Frequency} the corresponding frequency value + * @static + * @example + * Tone.Frequency.mtof(69); // returns 440 + */ + Tone.Frequency.mtof = function (midi) { + return Tone.Frequency.A4 * Math.pow(2, (midi - 69) / 12); + }; + /** + * Convert a frequency value to a MIDI note. + * @param {Frequency} frequency The value to frequency value to convert. + * @returns {MIDI} + * @static + * @example + * Tone.Frequency.ftom(440); // returns 69 + */ + Tone.Frequency.ftom = function (frequency) { + return 69 + Math.round(12 * Math.log2(frequency / Tone.Frequency.A4)); + }; + return Tone.Frequency; + }); + Module(function (Tone) { + /** + * @class Tone.Time is a primitive type for encoding Time values. + * Tone.Time can be constructed with or without the `new` keyword. Tone.Time can be passed + * into the parameter of any method which takes time as an argument. + * @constructor + * @extends {Tone.TimeBase} + * @param {String|Number} val The time value. + * @param {String=} units The units of the value. + * @example + * var t = Tone.Time("4n");//a quarter note + */ + Tone.Time = function (val, units) { + if (this instanceof Tone.Time) { + Tone.TimeBase.call(this, val, units); + } else { + return new Tone.Time(val, units); + } + }; + Tone.extend(Tone.Time, Tone.TimeBase); + /** + * Extend the base expressions + */ + Tone.Time.prototype._expressions = Object.assign({}, Tone.TimeBase.prototype._expressions, { + 'quantize': { + regexp: /^@(.+)/, + method: function (capture) { + if (Tone.Transport) { + var quantTo = new this.constructor(capture); + return Tone.Transport.nextSubdivision(quantTo); + } else { + return 0; + } + } + }, + 'now': { + regexp: /^\+(.+)/, + method: function (capture) { + return this._now() + new this.constructor(capture); + } + } + }); + /** + * Quantize the time by the given subdivision. Optionally add a + * percentage which will move the time value towards the ideal + * quantized value by that percentage. + * @param {Number|Time} val The subdivision to quantize to + * @param {NormalRange} [percent=1] Move the time value + * towards the quantized value by + * a percentage. + * @return {Number} this + * @example + * Tone.Time(21).quantize(2) //returns 22 + * Tone.Time(0.6).quantize("4n", 0.5) //returns 0.55 + */ + Tone.Time.prototype.quantize = function (subdiv, percent) { + percent = Tone.defaultArg(percent, 1); + var subdivision = new this.constructor(subdiv); + var value = this.valueOf(); + var multiple = Math.round(value / subdivision); + var ideal = multiple * subdivision; + var diff = ideal - value; + return value + diff * percent; + }; + /////////////////////////////////////////////////////////////////////////// + // CONVERSIONS + /////////////////////////////////////////////////////////////////////////// + /** + * Convert a Time to Notation. The notation values are will be the + * closest representation between 1m to 128th note. + * @return {Notation} + * @example + * //if the Transport is at 120bpm: + * Tone.Time(2).toNotation();//returns "1m" + */ + Tone.Time.prototype.toNotation = function () { + var time = this.toSeconds(); + var testNotations = ['1m']; + for (var power = 1; power < 8; power++) { + var subdiv = Math.pow(2, power); + testNotations.push(subdiv + 'n.'); + testNotations.push(subdiv + 'n'); + testNotations.push(subdiv + 't'); + } + testNotations.push('0'); + //find the closets notation representation + var closest = testNotations[0]; + var closestSeconds = Tone.Time(testNotations[0]).toSeconds(); + testNotations.forEach(function (notation) { + var notationSeconds = Tone.Time(notation).toSeconds(); + if (Math.abs(notationSeconds - time) < Math.abs(closestSeconds - time)) { + closest = notation; + closestSeconds = notationSeconds; + } + }); + return closest; + }; + /** + * Return the time encoded as Bars:Beats:Sixteenths. + * @return {BarsBeatsSixteenths} + */ + Tone.Time.prototype.toBarsBeatsSixteenths = function () { + var quarterTime = this._beatsToUnits(1); + var quarters = this.valueOf() / quarterTime; + var measures = Math.floor(quarters / this._getTimeSignature()); + var sixteenths = quarters % 1 * 4; + quarters = Math.floor(quarters) % this._getTimeSignature(); + sixteenths = sixteenths.toString(); + if (sixteenths.length > 3) { + // the additional parseFloat removes insignificant trailing zeroes + sixteenths = parseFloat(parseFloat(sixteenths).toFixed(3)); + } + var progress = [ + measures, + quarters, + sixteenths + ]; + return progress.join(':'); + }; + /** + * Return the time in ticks. + * @return {Ticks} + */ + Tone.Time.prototype.toTicks = function () { + var quarterTime = this._beatsToUnits(1); + var quarters = this.valueOf() / quarterTime; + return Math.round(quarters * this._getPPQ()); + }; + /** + * Return the time in seconds. + * @return {Seconds} + */ + Tone.Time.prototype.toSeconds = function () { + return this.valueOf(); + }; + /** + * Return the value as a midi note. + * @return {Midi} + */ + Tone.Time.prototype.toMidi = function () { + return Tone.Frequency.ftom(this.toFrequency()); + }; + return Tone.Time; + }); + Module(function (Tone) { + /** + * @class Tone.TransportTime is a the time along the Transport's + * timeline. It is similar to Tone.Time, but instead of evaluating + * against the AudioContext's clock, it is evaluated against + * the Transport's position. See [TransportTime wiki](https://github.com/Tonejs/Tone.js/wiki/TransportTime). + * @constructor + * @param {Time} val The time value as a number or string + * @param {String=} units Unit values + * @extends {Tone.Time} + */ + Tone.TransportTime = function (val, units) { + if (this instanceof Tone.TransportTime) { + Tone.Time.call(this, val, units); + } else { + return new Tone.TransportTime(val, units); + } + }; + Tone.extend(Tone.TransportTime, Tone.Time); + /** + * Return the current time in whichever context is relevant + * @type {Number} + * @private + */ + Tone.TransportTime.prototype._now = function () { + return Tone.Transport.seconds; + }; + return Tone.TransportTime; + }); + Module(function (Tone) { + /////////////////////////////////////////////////////////////////////////// + // TYPES + /////////////////////////////////////////////////////////////////////////// + /** + * Units which a value can take on. + * @enum {String} + */ + Tone.Type = { + /** + * Default units + * @typedef {Default} + */ + Default: 'number', + /** + * Time can be described in a number of ways. Read more [Time](https://github.com/Tonejs/Tone.js/wiki/Time). + * + * * Numbers, which will be taken literally as the time (in seconds). + * * Notation, ("4n", "8t") describes time in BPM and time signature relative values. + * * TransportTime, ("4:3:2") will also provide tempo and time signature relative times + * in the form BARS:QUARTERS:SIXTEENTHS. + * * Frequency, ("8hz") is converted to the length of the cycle in seconds. + * * Now-Relative, ("+1") prefix any of the above with "+" and it will be interpreted as + * "the current time plus whatever expression follows". + * * Expressions, ("3:0 + 2 - (1m / 7)") any of the above can also be combined + * into a mathematical expression which will be evaluated to compute the desired time. + * * No Argument, for methods which accept time, no argument will be interpreted as + * "now" (i.e. the currentTime). + * + * @typedef {Time} + */ + Time: 'time', + /** + * Frequency can be described similar to time, except ultimately the + * values are converted to frequency instead of seconds. A number + * is taken literally as the value in hertz. Additionally any of the + * Time encodings can be used. Note names in the form + * of NOTE OCTAVE (i.e. C4) are also accepted and converted to their + * frequency value. + * @typedef {Frequency} + */ + Frequency: 'frequency', + /** + * TransportTime describes a position along the Transport's timeline. It is + * similar to Time in that it uses all the same encodings, but TransportTime specifically + * pertains to the Transport's timeline, which is startable, stoppable, loopable, and seekable. + * [Read more](https://github.com/Tonejs/Tone.js/wiki/TransportTime) + * @typedef {TransportTime} + */ + TransportTime: 'transportTime', + /** + * Ticks are the basic subunit of the Transport. They are + * the smallest unit of time that the Transport supports. + * @typedef {Ticks} + */ + Ticks: 'ticks', + /** + * Normal values are within the range [0, 1]. + * @typedef {NormalRange} + */ + NormalRange: 'normalRange', + /** + * AudioRange values are between [-1, 1]. + * @typedef {AudioRange} + */ + AudioRange: 'audioRange', + /** + * Decibels are a logarithmic unit of measurement which is useful for volume + * because of the logarithmic way that we perceive loudness. 0 decibels + * means no change in volume. -10db is approximately half as loud and 10db + * is twice is loud. + * @typedef {Decibels} + */ + Decibels: 'db', + /** + * Half-step note increments, i.e. 12 is an octave above the root. and 1 is a half-step up. + * @typedef {Interval} + */ + Interval: 'interval', + /** + * Beats per minute. + * @typedef {BPM} + */ + BPM: 'bpm', + /** + * The value must be greater than or equal to 0. + * @typedef {Positive} + */ + Positive: 'positive', + /** + * Gain is the ratio between input and output of a signal. + * A gain of 0 is the same as silencing the signal. A gain of + * 1, causes no change to the incoming signal. + * @typedef {Gain} + */ + Gain: 'gain', + /** + * A cent is a hundredth of a semitone. + * @typedef {Cents} + */ + Cents: 'cents', + /** + * Angle between 0 and 360. + * @typedef {Degrees} + */ + Degrees: 'degrees', + /** + * A number representing a midi note. + * @typedef {MIDI} + */ + MIDI: 'midi', + /** + * A colon-separated representation of time in the form of + * Bars:Beats:Sixteenths. + * @typedef {BarsBeatsSixteenths} + */ + BarsBeatsSixteenths: 'barsBeatsSixteenths', + /** + * Sampling is the reduction of a continuous signal to a discrete signal. + * Audio is typically sampled 44100 times per second. + * @typedef {Samples} + */ + Samples: 'samples', + /** + * Hertz are a frequency representation defined as one cycle per second. + * @typedef {Hertz} + */ + Hertz: 'hertz', + /** + * A frequency represented by a letter name, + * accidental and octave. This system is known as + * [Scientific Pitch Notation](https://en.wikipedia.org/wiki/Scientific_pitch_notation). + * @typedef {Note} + */ + Note: 'note', + /** + * One millisecond is a thousandth of a second. + * @typedef {Milliseconds} + */ + Milliseconds: 'milliseconds', + /** + * Seconds are the time unit of the AudioContext. In the end, + * all values need to be evaluated to seconds. + * @typedef {Seconds} + */ + Seconds: 'seconds', + /** + * A string representing a duration relative to a measure. + * * "4n" = quarter note + * * "2m" = two measures + * * "8t" = eighth-note triplet + * @typedef {Notation} + */ + Notation: 'notation' + }; + /////////////////////////////////////////////////////////////////////////// + // AUGMENT TONE's PROTOTYPE + /////////////////////////////////////////////////////////////////////////// + /** + * Convert Time into seconds. + * + * Unlike the method which it overrides, this takes into account + * transporttime and musical notation. + * + * Time : 1.40 + * Notation: 4n or 1m or 2t + * Now Relative: +3n + * Math: 3n+16n or even complicated expressions ((3n*2)/6 + 1) + * + * @param {Time} time + * @return {Seconds} + */ + Tone.prototype.toSeconds = function (time) { + if (Tone.isNumber(time)) { + return time; + } else if (Tone.isUndef(time)) { + return this.now(); + } else if (Tone.isString(time)) { + return new Tone.Time(time).toSeconds(); + } else if (time instanceof Tone.TimeBase) { + return time.toSeconds(); + } + }; + /** + * Convert a frequency representation into a number. + * @param {Frequency} freq + * @return {Hertz} the frequency in hertz + */ + Tone.prototype.toFrequency = function (freq) { + if (Tone.isNumber(freq)) { + return freq; + } else if (Tone.isString(freq) || Tone.isUndef(freq)) { + return new Tone.Frequency(freq).valueOf(); + } else if (freq instanceof Tone.TimeBase) { + return freq.toFrequency(); + } + }; + /** + * Convert a time representation into ticks. + * @param {Time} time + * @return {Ticks} the time in ticks + */ + Tone.prototype.toTicks = function (time) { + if (Tone.isNumber(time) || Tone.isString(time)) { + return new Tone.TransportTime(time).toTicks(); + } else if (Tone.isUndef(time)) { + return Tone.Transport.ticks; + } else if (time instanceof Tone.TimeBase) { + return time.toTicks(); + } + }; + return Tone; + }); + Module(function (Tone) { + + /** + * @class Tone.Param wraps the native Web Audio's AudioParam to provide + * additional unit conversion functionality. It also + * serves as a base-class for classes which have a single, + * automatable parameter. + * @extends {Tone.AudioNode} + * @param {AudioParam} param The parameter to wrap. + * @param {Tone.Type} units The units of the audio param. + * @param {Boolean} convert If the param should be converted. + */ + Tone.Param = function () { + var options = Tone.defaults(arguments, [ + 'param', + 'units', + 'convert' + ], Tone.Param); + Tone.AudioNode.call(this); + /** + * The native parameter to control + * @type {AudioParam} + * @private + */ + this._param = this.input = options.param; + /** + * The units of the parameter + * @type {Tone.Type} + */ + this.units = options.units; + /** + * If the value should be converted or not + * @type {Boolean} + */ + this.convert = options.convert; + /** + * True if the signal value is being overridden by + * a connected signal. + * @readOnly + * @type {boolean} + * @private + */ + this.overridden = false; + /** + * The timeline which tracks all of the automations. + * @type {Tone.Timeline} + * @private + */ + this._events = new Tone.Timeline(1000); + if (Tone.isDefined(options.value) && this._param) { + this.value = options.value; + } + }; + Tone.extend(Tone.Param, Tone.AudioNode); + /** + * Defaults + * @type {Object} + * @const + */ + Tone.Param.defaults = { + 'units': Tone.Type.Default, + 'convert': true, + 'param': undefined + }; + /** + * The current value of the parameter. + * @memberOf Tone.Param# + * @type {Number} + * @name value + */ + Object.defineProperty(Tone.Param.prototype, 'value', { + get: function () { + var now = this.now(); + return this._toUnits(this.getValueAtTime(now)); + }, + set: function (value) { + this._initialValue = this._fromUnits(value); + this.cancelScheduledValues(this.context.currentTime); + this.setValueAtTime(value, this.context.currentTime); + } + }); + /** + * The minimum output value of the parameter + * @memberOf Tone.Param# + * @type {Number} + * @name value + */ + Object.defineProperty(Tone.Param.prototype, 'minValue', { + get: function () { + if (this.units === Tone.Type.Time || this.units === Tone.Type.Frequency || this.units === Tone.Type.NormalRange || this.units === Tone.Type.Positive || this.units === Tone.Type.BPM) { + return 0; + } else if (this.units === Tone.Type.AudioRange) { + return -1; + } else if (this.units === Tone.Type.Decibels) { + return -Infinity; + } else { + return this._param.minValue; + } + } + }); + /** + * The maximum output value of the parameter + * @memberOf Tone.Param# + * @type {Number} + * @name value + */ + Object.defineProperty(Tone.Param.prototype, 'maxValue', { + get: function () { + if (this.units === Tone.Type.NormalRange || this.units === Tone.Type.AudioRange) { + return 1; + } else { + return this._param.maxValue; + } + } + }); + /** + * Convert the given value from the type specified by Tone.Param.units + * into the destination value (such as Gain or Frequency). + * @private + * @param {*} val the value to convert + * @return {number} the number which the value should be set to + */ + Tone.Param.prototype._fromUnits = function (val) { + if ((this.convert || Tone.isUndef(this.convert)) && !this.overridden) { + switch (this.units) { + case Tone.Type.Time: + return this.toSeconds(val); + case Tone.Type.Frequency: + return this.toFrequency(val); + case Tone.Type.Decibels: + return Tone.dbToGain(val); + case Tone.Type.NormalRange: + return Math.min(Math.max(val, 0), 1); + case Tone.Type.AudioRange: + return Math.min(Math.max(val, -1), 1); + case Tone.Type.Positive: + return Math.max(val, 0); + default: + return val; + } + } else { + return val; + } + }; + /** + * Convert the parameters value into the units specified by Tone.Param.units. + * @private + * @param {number} val the value to convert + * @return {number} + */ + Tone.Param.prototype._toUnits = function (val) { + if (this.convert || Tone.isUndef(this.convert)) { + switch (this.units) { + case Tone.Type.Decibels: + return Tone.gainToDb(val); + default: + return val; + } + } else { + return val; + } + }; + /** + * the minimum output value + * @type {Number} + * @private + */ + Tone.Param.prototype._minOutput = 0.00001; + /** + * The event types + * @enum {String} + * @private + */ + Tone.Param.AutomationType = { + Linear: 'linearRampToValueAtTime', + Exponential: 'exponentialRampToValueAtTime', + Target: 'setTargetAtTime', + SetValue: 'setValueAtTime' + }; + /** + * Schedules a parameter value change at the given time. + * @param {*} value The value to set the signal. + * @param {Time} time The time when the change should occur. + * @returns {Tone.Param} this + * @example + * //set the frequency to "G4" in exactly 1 second from now. + * freq.setValueAtTime("G4", "+1"); + */ + Tone.Param.prototype.setValueAtTime = function (value, time) { + time = this.toSeconds(time); + value = this._fromUnits(value); + this._events.add({ + 'type': Tone.Param.AutomationType.SetValue, + 'value': value, + 'time': time + }); + this._param.setValueAtTime(value, time); + return this; + }; + /** + * Get the signals value at the given time. Subsequent scheduling + * may invalidate the returned value. + * @param {Time} time When to get the value + * @returns {Number} The value at the given time + */ + Tone.Param.prototype.getValueAtTime = function (time) { + time = this.toSeconds(time); + var after = this._events.getAfter(time); + var before = this._events.get(time); + var initialValue = Tone.defaultArg(this._initialValue, this._param.defaultValue); + var value = initialValue; + //if it was set by + if (before === null) { + value = initialValue; + } else if (before.type === Tone.Param.AutomationType.Target) { + var previous = this._events.getBefore(before.time); + var previousVal; + if (previous === null) { + previousVal = initialValue; + } else { + previousVal = previous.value; + } + value = this._exponentialApproach(before.time, previousVal, before.value, before.constant, time); + } else if (after === null) { + value = before.value; + } else if (after.type === Tone.Param.AutomationType.Linear) { + value = this._linearInterpolate(before.time, before.value, after.time, after.value, time); + } else if (after.type === Tone.Param.AutomationType.Exponential) { + value = this._exponentialInterpolate(before.time, before.value, after.time, after.value, time); + } else { + value = before.value; + } + return value; + }; + /** + * Creates a schedule point with the current value at the current time. + * This is useful for creating an automation anchor point in order to + * schedule changes from the current value. + * + * @param {number=} now (Optionally) pass the now value in. + * @returns {Tone.Param} this + */ + Tone.Param.prototype.setRampPoint = function (time) { + time = this.toSeconds(time); + var currentVal = this.getValueAtTime(time); + this.cancelAndHoldAtTime(time); + if (currentVal === 0) { + currentVal = this._minOutput; + } + this.setValueAtTime(this._toUnits(currentVal), time); + return this; + }; + /** + * Schedules a linear continuous change in parameter value from the + * previous scheduled parameter value to the given value. + * + * @param {number} value + * @param {Time} endTime + * @returns {Tone.Param} this + */ + Tone.Param.prototype.linearRampToValueAtTime = function (value, endTime) { + value = this._fromUnits(value); + endTime = this.toSeconds(endTime); + this._events.add({ + 'type': Tone.Param.AutomationType.Linear, + 'value': value, + 'time': endTime + }); + this._param.linearRampToValueAtTime(value, endTime); + return this; + }; + /** + * Schedules an exponential continuous change in parameter value from + * the previous scheduled parameter value to the given value. + * + * @param {number} value + * @param {Time} endTime + * @returns {Tone.Param} this + */ + Tone.Param.prototype.exponentialRampToValueAtTime = function (value, endTime) { + value = this._fromUnits(value); + value = Math.max(this._minOutput, value); + endTime = this.toSeconds(endTime); + //store the event + this._events.add({ + 'type': Tone.Param.AutomationType.Exponential, + 'time': endTime, + 'value': value + }); + this._param.exponentialRampToValueAtTime(value, endTime); + return this; + }; + /** + * Schedules an exponential continuous change in parameter value from + * the current time and current value to the given value over the + * duration of the rampTime. + * + * @param {number} value The value to ramp to. + * @param {Time} rampTime the time that it takes the + * value to ramp from it's current value + * @param {Time} [startTime=now] When the ramp should start. + * @returns {Tone.Param} this + * @example + * //exponentially ramp to the value 2 over 4 seconds. + * signal.exponentialRampTo(2, 4); + */ + Tone.Param.prototype.exponentialRampTo = function (value, rampTime, startTime) { + startTime = this.toSeconds(startTime); + this.setRampPoint(startTime); + this.exponentialRampToValueAtTime(value, startTime + this.toSeconds(rampTime)); + return this; + }; + /** + * Schedules an linear continuous change in parameter value from + * the current time and current value to the given value over the + * duration of the rampTime. + * + * @param {number} value The value to ramp to. + * @param {Time} rampTime the time that it takes the + * value to ramp from it's current value + * @param {Time} [startTime=now] When the ramp should start. + * @returns {Tone.Param} this + * @example + * //linearly ramp to the value 4 over 3 seconds. + * signal.linearRampTo(4, 3); + */ + Tone.Param.prototype.linearRampTo = function (value, rampTime, startTime) { + startTime = this.toSeconds(startTime); + this.setRampPoint(startTime); + this.linearRampToValueAtTime(value, startTime + this.toSeconds(rampTime)); + return this; + }; + /** + * Start exponentially approaching the target value at the given time. Since it + * is an exponential approach it will continue approaching after the ramp duration. The + * rampTime is the time that it takes to reach over 99% of the way towards the value. + * @param {number} value The value to ramp to. + * @param {Time} rampTime the time that it takes the + * value to ramp from it's current value + * @param {Time} [startTime=now] When the ramp should start. + * @returns {Tone.Param} this + * @example + * //exponentially ramp to the value 2 over 4 seconds. + * signal.exponentialRampTo(2, 4); + */ + Tone.Param.prototype.targetRampTo = function (value, rampTime, startTime) { + startTime = this.toSeconds(startTime); + this.setRampPoint(startTime); + this.exponentialApproachValueAtTime(value, startTime, rampTime); + return this; + }; + /** + * Start exponentially approaching the target value at the given time. Since it + * is an exponential approach it will continue approaching after the ramp duration. The + * rampTime is the time that it takes to reach over 99% of the way towards the value. This methods + * is similar to setTargetAtTime except the third argument is a time instead of a 'timeConstant' + * @param {number} value The value to ramp to. + * @param {Time} time When the ramp should start. + * @param {Time} rampTime the time that it takes the + * value to ramp from it's current value + * @returns {Tone.Param} this + * @example + * //exponentially ramp to the value 2 over 4 seconds. + * signal.exponentialRampTo(2, 4); + */ + Tone.Param.prototype.exponentialApproachValueAtTime = function (value, time, rampTime) { + var timeConstant = Math.log(this.toSeconds(rampTime) + 1) / Math.log(200); + time = this.toSeconds(time); + return this.setTargetAtTime(value, time, timeConstant); + }; + /** + * Start exponentially approaching the target value at the given time with + * a rate having the given time constant. + * @param {number} value + * @param {Time} startTime + * @param {number} timeConstant + * @returns {Tone.Param} this + */ + Tone.Param.prototype.setTargetAtTime = function (value, startTime, timeConstant) { + value = this._fromUnits(value); + // The value will never be able to approach without timeConstant > 0. + if (timeConstant <= 0) { + throw new Error('timeConstant must be greater than 0'); + } + startTime = this.toSeconds(startTime); + this._events.add({ + 'type': Tone.Param.AutomationType.Target, + 'value': value, + 'time': startTime, + 'constant': timeConstant + }); + this._param.setTargetAtTime(value, startTime, timeConstant); + return this; + }; + /** + * Sets an array of arbitrary parameter values starting at the given time + * for the given duration. + * + * @param {Array} values + * @param {Time} startTime + * @param {Time} duration + * @param {NormalRange} [scaling=1] If the values in the curve should be scaled by some value + * @returns {Tone.Param} this + */ + Tone.Param.prototype.setValueCurveAtTime = function (values, startTime, duration, scaling) { + scaling = Tone.defaultArg(scaling, 1); + duration = this.toSeconds(duration); + startTime = this.toSeconds(startTime); + this.setValueAtTime(values[0] * scaling, startTime); + var segTime = duration / (values.length - 1); + for (var i = 1; i < values.length; i++) { + this.linearRampToValueAtTime(values[i] * scaling, startTime + i * segTime); + } + return this; + }; + /** + * Cancels all scheduled parameter changes with times greater than or + * equal to startTime. + * + * @param {Time} time + * @returns {Tone.Param} this + */ + Tone.Param.prototype.cancelScheduledValues = function (time) { + time = this.toSeconds(time); + this._events.cancel(time); + this._param.cancelScheduledValues(time); + return this; + }; + /** + * This is similar to [cancelScheduledValues](#cancelScheduledValues) except + * it holds the automated value at time until the next automated event. + * @param {Time} time + * @returns {Tone.Param} this + */ + Tone.Param.prototype.cancelAndHoldAtTime = function (time) { + var valueAtTime = this.getValueAtTime(time); + //if there is an event at the given time + //and that even is not a "set" + var before = this._events.get(time); + var after = this._events.getAfter(time); + if (before && before.time === time) { + //remove everything after + if (after) { + this._events.cancel(after.time); + } else { + this._events.cancel(time + 0.000001); + } + } else if (after) { + //cancel the next event(s) + this._events.cancel(after.time); + if (!this._param.cancelAndHoldAtTime) { + this._param.cancelScheduledValues(time); + } + if (after.type === Tone.Param.AutomationType.Linear) { + if (!this._param.cancelAndHoldAtTime) { + this.linearRampToValueAtTime(valueAtTime, time); + } else { + this._events.add({ + 'type': Tone.Param.AutomationType.Linear, + 'value': valueAtTime, + 'time': time + }); + } + } else if (after.type === Tone.Param.AutomationType.Exponential) { + if (!this._param.cancelAndHoldAtTime) { + this.exponentialRampToValueAtTime(valueAtTime, time); + } else { + this._events.add({ + 'type': Tone.Param.AutomationType.Exponential, + 'value': valueAtTime, + 'time': time + }); + } + } + } + //set the value at the given time + this._events.add({ + 'type': Tone.Param.AutomationType.SetValue, + 'value': valueAtTime, + 'time': time + }); + if (this._param.cancelAndHoldAtTime) { + this._param.cancelAndHoldAtTime(time); + } else { + this._param.setValueAtTime(valueAtTime, time); + } + return this; + }; + /** + * Ramps to the given value over the duration of the rampTime. + * Automatically selects the best ramp type (exponential or linear) + * depending on the `units` of the signal + * + * @param {number} value + * @param {Time} rampTime The time that it takes the + * value to ramp from it's current value + * @param {Time} [startTime=now] When the ramp should start. + * @returns {Tone.Param} this + * @example + * //ramp to the value either linearly or exponentially + * //depending on the "units" value of the signal + * signal.rampTo(0, 10); + * @example + * //schedule it to ramp starting at a specific time + * signal.rampTo(0, 10, 5) + */ + Tone.Param.prototype.rampTo = function (value, rampTime, startTime) { + rampTime = Tone.defaultArg(rampTime, 0.1); + if (this.units === Tone.Type.Frequency || this.units === Tone.Type.BPM || this.units === Tone.Type.Decibels) { + this.exponentialRampTo(value, rampTime, startTime); + } else { + this.linearRampTo(value, rampTime, startTime); + } + return this; + }; + /////////////////////////////////////////////////////////////////////////// + // AUTOMATION CURVE CALCULATIONS + // MIT License, copyright (c) 2014 Jordan Santell + /////////////////////////////////////////////////////////////////////////// + // Calculates the the value along the curve produced by setTargetAtTime + Tone.Param.prototype._exponentialApproach = function (t0, v0, v1, timeConstant, t) { + return v1 + (v0 - v1) * Math.exp(-(t - t0) / timeConstant); + }; + // Calculates the the value along the curve produced by linearRampToValueAtTime + Tone.Param.prototype._linearInterpolate = function (t0, v0, t1, v1, t) { + return v0 + (v1 - v0) * ((t - t0) / (t1 - t0)); + }; + // Calculates the the value along the curve produced by exponentialRampToValueAtTime + Tone.Param.prototype._exponentialInterpolate = function (t0, v0, t1, v1, t) { + return v0 * Math.pow(v1 / v0, (t - t0) / (t1 - t0)); + }; + /** + * Clean up + * @returns {Tone.Param} this + */ + Tone.Param.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._param = null; + this._events = null; + return this; + }; + return Tone.Param; + }); + Module(function (Tone) { + /** + * @class Wrapper around the OfflineAudioContext + * @extends {Tone.Context} + * @param {Number} channels The number of channels to render + * @param {Number} duration The duration to render in samples + * @param {Number} sampleRate the sample rate to render at + */ + Tone.OfflineContext = function (channels, duration, sampleRate) { + /** + * The offline context + * @private + * @type {OfflineAudioContext} + */ + var offlineContext = new OfflineAudioContext(channels, duration * sampleRate, sampleRate); + //wrap the methods/members + Tone.Context.call(this, { + 'context': offlineContext, + 'clockSource': 'offline', + 'lookAhead': 0, + 'updateInterval': 128 / sampleRate + }); + /** + * A private reference to the duration + * @private + * @type {Number} + */ + this._duration = duration; + /** + * An artificial clock source + * @type {Number} + * @private + */ + this._currentTime = 0; + }; + Tone.extend(Tone.OfflineContext, Tone.Context); + /** + * Override the now method to point to the internal clock time + * @return {Number} + */ + Tone.OfflineContext.prototype.now = function () { + return this._currentTime; + }; + /** + * Render the output of the OfflineContext + * @return {Promise} + */ + Tone.OfflineContext.prototype.render = function () { + while (this._duration - this._currentTime >= 0) { + //invoke all the callbacks on that time + this.emit('tick'); + //increment the clock + this._currentTime += this.blockTime; + } + return this._context.startRendering(); + }; + /** + * Close the context + * @return {Promise} + */ + Tone.OfflineContext.prototype.close = function () { + this._context = null; + return Promise.resolve(); + }; + return Tone.OfflineContext; + }); + Module(function (Tone) { + if (Tone.supported) { + var ua = navigator.userAgent.toLowerCase(); + var isMobileSafari = ua.includes('safari') && !ua.includes('chrome') && ua.includes('mobile'); + if (isMobileSafari) { + //mobile safari has a bizarre bug with the offline context + //when a BufferSourceNode is started, it starts the offline context + // + //deferring all BufferSource starts till the last possible moment + //reduces the likelihood of this happening + Tone.OfflineContext.prototype.createBufferSource = function () { + var bufferSource = this._context.createBufferSource(); + var _native_start = bufferSource.start; + bufferSource.start = function (time) { + this.setTimeout(function () { + _native_start.call(bufferSource, time); + }.bind(this), 0); + }.bind(this); + return bufferSource; + }; + } + } + }); + Module(function (Tone) { + + /** + * @class A thin wrapper around the Native Web Audio GainNode. + * The GainNode is a basic building block of the Web Audio + * API and is useful for routing audio and adjusting gains. + * @extends {Tone} + * @param {Number=} gain The initial gain of the GainNode + * @param {Tone.Type=} units The units of the gain parameter. + */ + Tone.Gain = function () { + var options = Tone.defaults(arguments, [ + 'gain', + 'units' + ], Tone.Gain); + Tone.AudioNode.call(this); + /** + * The GainNode + * @type {GainNode} + * @private + */ + this.input = this.output = this._gainNode = this.context.createGain(); + /** + * The gain parameter of the gain node. + * @type {Gain} + * @signal + */ + this.gain = new Tone.Param({ + 'param': this._gainNode.gain, + 'units': options.units, + 'value': options.gain, + 'convert': options.convert + }); + this._readOnly('gain'); + }; + Tone.extend(Tone.Gain, Tone.AudioNode); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.Gain.defaults = { + 'gain': 1, + 'convert': true + }; + /** + * Clean up. + * @return {Tone.Gain} this + */ + Tone.Gain.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._gainNode.disconnect(); + this._gainNode = null; + this._writable('gain'); + this.gain.dispose(); + this.gain = null; + }; + return Tone.Gain; + }); + Module(function (Tone) { + if (Tone.supported && !AudioContext.prototype.createConstantSource) { + var ConstantSourceNode = function (context) { + this.context = context; + var buffer = context.createBuffer(1, 128, context.sampleRate); + var arr = buffer.getChannelData(0); + for (var i = 0; i < arr.length; i++) { + arr[i] = 1; + } + this._bufferSource = context.createBufferSource(); + this._bufferSource.channelCount = 1; + this._bufferSource.channelCountMode = 'explicit'; + this._bufferSource.buffer = buffer; + this._bufferSource.loop = true; + var gainNode = this._output = context.createGain(); + this.offset = gainNode.gain; + this._bufferSource.connect(gainNode); + }; + ConstantSourceNode.prototype.start = function (time) { + this._bufferSource.start(time); + return this; + }; + ConstantSourceNode.prototype.stop = function (time) { + this._bufferSource.stop(time); + return this; + }; + ConstantSourceNode.prototype.connect = function () { + this._output.connect.apply(this._output, arguments); + return this; + }; + ConstantSourceNode.prototype.disconnect = function () { + this._output.disconnect.apply(this._output, arguments); + return this; + }; + AudioContext.prototype.createConstantSource = function () { + return new ConstantSourceNode(this); + }; + Tone.Context.prototype.createConstantSource = function () { + return new ConstantSourceNode(this); + }; + } + }); + Module(function (Tone) { + + /** + * @class A signal is an audio-rate value. Tone.Signal is a core component of the library. + * Unlike a number, Signals can be scheduled with sample-level accuracy. Tone.Signal + * has all of the methods available to native Web Audio + * [AudioParam](http://webaudio.github.io/web-audio-api/#the-audioparam-interface) + * as well as additional conveniences. Read more about working with signals + * [here](https://github.com/Tonejs/Tone.js/wiki/Signals). + * + * @constructor + * @extends {Tone.Param} + * @param {Number|AudioParam} [value] Initial value of the signal. If an AudioParam + * is passed in, that parameter will be wrapped + * and controlled by the Signal. + * @param {string} [units=Number] unit The units the signal is in. + * @example + * var signal = new Tone.Signal(10); + */ + Tone.Signal = function () { + var options = Tone.defaults(arguments, [ + 'value', + 'units' + ], Tone.Signal); + Tone.Param.call(this, options); + /** + * When a signal is connected to another signal or audio param, + * this signal becomes a proxy for it + * @type {Array} + * @private + */ + this._proxies = []; + /** + * Indicates if the constant source was started or not + * @private + * @type {Boolean} + */ + this._sourceStarted = false; + /** + * The constant source node which generates the signal + * @type {ConstantSourceNode} + * @private + */ + this._constantSource = this.context.createConstantSource(); + this._param = this._constantSource.offset; + this.value = options.value; + /** + * The node where the constant signal value is scaled. + * @type {GainNode} + * @private + */ + this.output = this._constantSource; + /** + * The node where the value is set. + * @type {Tone.Param} + * @private + */ + this.input = this._param = this.output.offset; + }; + Tone.extend(Tone.Signal, Tone.Param); + /** + * The default values + * @type {Object} + * @static + * @const + */ + Tone.Signal.defaults = { + 'value': 0, + 'units': Tone.Type.Default, + 'convert': true + }; + /** + * When signals connect to other signals or AudioParams, + * they take over the output value of that signal or AudioParam. + * For all other nodes, the behavior is the same as a default <code>connect</code>. + * + * @override + * @param {AudioParam|AudioNode|Tone.Signal|Tone} node + * @param {number} [outputNumber=0] The output number to connect from. + * @param {number} [inputNumber=0] The input number to connect to. + * @returns {Tone.Signal} this + * @method + */ + Tone.Signal.prototype.connect = function (node) { + //this is an optimization where this node will forward automations + //to connected nodes without any signal if possible. + if (this._isParam(node) && !this._sourceStarted) { + this._proxies.push(node); + node.overridden = true; + this._applyAutomations(node); + } else { + Tone.SignalBase.prototype.connect.apply(this, arguments); + if (!this._sourceStarted) { + this._sourceStarted = true; + this._constantSource.start(0); + } + } + return this; + }; + /** + * Takes a node as an argument and returns if it is a Param or AudioParam + * @param {*} node The node to test + * @return {Boolean} + * @private + */ + Tone.Signal.prototype._isParam = function (node) { + return Tone.Param && Tone.Param === node.constructor || node instanceof AudioParam; + }; + /** + * Discard the optimization and connect all of the proxies + * @private + */ + Tone.Signal.prototype._connectProxies = function () { + if (!this._sourceStarted) { + this._sourceStarted = true; + this._constantSource.start(0); + } + this._proxies.forEach(function (proxy) { + Tone.SignalBase.prototype.connect.call(this, proxy); + if (proxy._proxies) { + proxy._connectProxies(); + } + }.bind(this)); + }; + /** + * Invoked when a node is connected to this + * @param {AudioNode} from + * @private + */ + Tone.Signal.prototype._onConnect = function (from) { + if (!this._isParam(from)) { + //connect all the proxies + this._connectProxies(); + } + }; + /** + * Apply all the current automations to the given parameter + * @param {AudioParam} param + * @private + */ + Tone.Signal.prototype._applyAutomations = function (param) { + var now = this.context.currentTime; + param.cancelScheduledValues(now); + var currentVal = this.getValueAtTime(now); + param.setValueAtTime(currentVal, now); + this._events.forEachFrom(now, function (event) { + param[event.type](event.value, event.time, event.constant); + }); + }; + /** + * Disconnect from the given node or all nodes if no param is given. + * @param {AudioNode|AudioParam} node + * @return {Tone.Signal} this + */ + Tone.Signal.prototype.disconnect = function (node) { + if (this._proxies.includes(node)) { + var index = this._proxies.indexOf(node); + this._proxies.splice(index, 1); + } else if (!node) { + //no argument, disconnect everything + this._proxies = []; + } + return Tone.SignalBase.prototype.disconnect.apply(this, arguments); + }; + /** + * Return the current signal value at the given time. + * @param {Time} time When to get the signal value + * @return {Number} + */ + Tone.Signal.prototype.getValueAtTime = function (time) { + if (this._param.getValueAtTime) { + return this._param.getValueAtTime(time); + } else { + return Tone.Param.prototype.getValueAtTime.call(this, time); + } + }; + //wrap all of the automation methods + [ + 'setValueAtTime', + 'linearRampToValueAtTime', + 'exponentialRampToValueAtTime', + 'setTargetAtTime' + ].forEach(function (method) { + var previousMethod = Tone.Signal.prototype[method]; + Tone.Signal.prototype[method] = function () { + var args = arguments; + previousMethod.apply(this, arguments); + args[0] = this._fromUnits(args[0]); + args[1] = this.toSeconds(args[1]); + //apply it to the proxies + this._proxies.forEach(function (signal) { + signal[method].apply(signal, args); + }); + }; + }); + [ + 'cancelScheduledValues', + 'cancelAndHoldAtTime' + ].forEach(function (method) { + var previousMethod = Tone.Signal.prototype[method]; + Tone.Signal.prototype[method] = function () { + var args = arguments; + previousMethod.apply(this, arguments); + args[0] = this.toSeconds(args[0]); + //apply it to the proxies + this._proxies.forEach(function (signal) { + signal[method].apply(signal, args); + }); + }; + }); + /** + * dispose and disconnect + * @returns {Tone.Signal} this + */ + Tone.Signal.prototype.dispose = function () { + Tone.Param.prototype.dispose.call(this); + this._constantSource.disconnect(); + this._constantSource = null; + this._proxies = null; + return this; + }; + return Tone.Signal; + }); + Module(function (Tone) { + + /** + * @class Pow applies an exponent to the incoming signal. The incoming signal + * must be AudioRange. + * + * @extends {Tone.SignalBase} + * @constructor + * @param {Positive} exp The exponent to apply to the incoming signal, must be at least 2. + * @example + * var pow = new Tone.Pow(2); + * var sig = new Tone.Signal(0.5).connect(pow); + * //output of pow is 0.25. + */ + Tone.Pow = function (exp) { + Tone.SignalBase.call(this); + /** + * the exponent + * @private + * @type {number} + */ + this._exp = Tone.defaultArg(exp, 1); + /** + * @type {WaveShaperNode} + * @private + */ + this._expScaler = this.input = this.output = new Tone.WaveShaper(this._expFunc(this._exp), 8192); + }; + Tone.extend(Tone.Pow, Tone.SignalBase); + /** + * The value of the exponent. + * @memberOf Tone.Pow# + * @type {number} + * @name value + */ + Object.defineProperty(Tone.Pow.prototype, 'value', { + get: function () { + return this._exp; + }, + set: function (exp) { + this._exp = exp; + this._expScaler.setMap(this._expFunc(this._exp)); + } + }); + /** + * the function which maps the waveshaper + * @param {number} exp + * @return {function} + * @private + */ + Tone.Pow.prototype._expFunc = function (exp) { + return function (val) { + return Math.pow(Math.abs(val), exp); + }; + }; + /** + * Clean up. + * @returns {Tone.Pow} this + */ + Tone.Pow.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._expScaler.dispose(); + this._expScaler = null; + return this; + }; + return Tone.Pow; + }); + Module(function (Tone) { + + /** + * @class Tone.Envelope is an [ADSR](https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope) + * envelope generator. Tone.Envelope outputs a signal which + * can be connected to an AudioParam or Tone.Signal. + * <img src="https://upload.wikimedia.org/wikipedia/commons/e/ea/ADSR_parameter.svg"> + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Time} [attack] The amount of time it takes for the envelope to go from + * 0 to it's maximum value. + * @param {Time} [decay] The period of time after the attack that it takes for the envelope + * to fall to the sustain value. + * @param {NormalRange} [sustain] The percent of the maximum value that the envelope rests at until + * the release is triggered. + * @param {Time} [release] The amount of time after the release is triggered it takes to reach 0. + * @example + * //an amplitude envelope + * var gainNode = Tone.context.createGain(); + * var env = new Tone.Envelope({ + * "attack" : 0.1, + * "decay" : 0.2, + * "sustain" : 1, + * "release" : 0.8, + * }); + * env.connect(gainNode.gain); + */ + Tone.Envelope = function () { + //get all of the defaults + var options = Tone.defaults(arguments, [ + 'attack', + 'decay', + 'sustain', + 'release' + ], Tone.Envelope); + Tone.AudioNode.call(this); + /** + * When triggerAttack is called, the attack time is the amount of + * time it takes for the envelope to reach it's maximum value. + * @type {Time} + */ + this.attack = options.attack; + /** + * After the attack portion of the envelope, the value will fall + * over the duration of the decay time to it's sustain value. + * @type {Time} + */ + this.decay = options.decay; + /** + * The sustain value is the value + * which the envelope rests at after triggerAttack is + * called, but before triggerRelease is invoked. + * @type {NormalRange} + */ + this.sustain = options.sustain; + /** + * After triggerRelease is called, the envelope's + * value will fall to it's miminum value over the + * duration of the release time. + * @type {Time} + */ + this.release = options.release; + /** + * the next time the envelope is at standby + * @type {number} + * @private + */ + this._attackCurve = 'linear'; + /** + * the next time the envelope is at standby + * @type {number} + * @private + */ + this._releaseCurve = 'exponential'; + /** + * the signal + * @type {Tone.Signal} + * @private + */ + this._sig = this.output = new Tone.Signal(0); + //set the attackCurve initially + this.attackCurve = options.attackCurve; + this.releaseCurve = options.releaseCurve; + }; + Tone.extend(Tone.Envelope, Tone.AudioNode); + /** + * the default parameters + * @static + * @const + */ + Tone.Envelope.defaults = { + 'attack': 0.01, + 'decay': 0.1, + 'sustain': 0.5, + 'release': 1, + 'attackCurve': 'linear', + 'releaseCurve': 'exponential' + }; + /** + * Read the current value of the envelope. Useful for + * syncronizing visual output to the envelope. + * @memberOf Tone.Envelope# + * @type {Number} + * @name value + * @readOnly + */ + Object.defineProperty(Tone.Envelope.prototype, 'value', { + get: function () { + return this.getValueAtTime(this.now()); + } + }); + /** + * The shape of the attack. + * Can be any of these strings: + * <ul> + * <li>linear</li> + * <li>exponential</li> + * <li>sine</li> + * <li>cosine</li> + * <li>bounce</li> + * <li>ripple</li> + * <li>step</li> + * </ul> + * Can also be an array which describes the curve. Values + * in the array are evenly subdivided and linearly + * interpolated over the duration of the attack. + * @memberOf Tone.Envelope# + * @type {String|Array} + * @name attackCurve + * @example + * env.attackCurve = "linear"; + * @example + * //can also be an array + * env.attackCurve = [0, 0.2, 0.3, 0.4, 1] + */ + Object.defineProperty(Tone.Envelope.prototype, 'attackCurve', { + get: function () { + if (Tone.isString(this._attackCurve)) { + return this._attackCurve; + } else if (Tone.isArray(this._attackCurve)) { + //look up the name in the curves array + for (var type in Tone.Envelope.Type) { + if (Tone.Envelope.Type[type].In === this._attackCurve) { + return type; + } + } + //otherwise just return the array + return this._attackCurve; + } + }, + set: function (curve) { + //check if it's a valid type + if (Tone.Envelope.Type.hasOwnProperty(curve)) { + var curveDef = Tone.Envelope.Type[curve]; + if (Tone.isObject(curveDef)) { + this._attackCurve = curveDef.In; + } else { + this._attackCurve = curveDef; + } + } else if (Tone.isArray(curve)) { + this._attackCurve = curve; + } else { + throw new Error('Tone.Envelope: invalid curve: ' + curve); + } + } + }); + /** + * The shape of the release. See the attack curve types. + * @memberOf Tone.Envelope# + * @type {String|Array} + * @name releaseCurve + * @example + * env.releaseCurve = "linear"; + */ + Object.defineProperty(Tone.Envelope.prototype, 'releaseCurve', { + get: function () { + if (Tone.isString(this._releaseCurve)) { + return this._releaseCurve; + } else if (Tone.isArray(this._releaseCurve)) { + //look up the name in the curves array + for (var type in Tone.Envelope.Type) { + if (Tone.Envelope.Type[type].Out === this._releaseCurve) { + return type; + } + } + //otherwise just return the array + return this._releaseCurve; + } + }, + set: function (curve) { + //check if it's a valid type + if (Tone.Envelope.Type.hasOwnProperty(curve)) { + var curveDef = Tone.Envelope.Type[curve]; + if (Tone.isObject(curveDef)) { + this._releaseCurve = curveDef.Out; + } else { + this._releaseCurve = curveDef; + } + } else if (Tone.isArray(curve)) { + this._releaseCurve = curve; + } else { + throw new Error('Tone.Envelope: invalid curve: ' + curve); + } + } + }); + /** + * Trigger the attack/decay portion of the ADSR envelope. + * @param {Time} [time=now] When the attack should start. + * @param {NormalRange} [velocity=1] The velocity of the envelope scales the vales. + * number between 0-1 + * @returns {Tone.Envelope} this + * @example + * //trigger the attack 0.5 seconds from now with a velocity of 0.2 + * env.triggerAttack("+0.5", 0.2); + */ + Tone.Envelope.prototype.triggerAttack = function (time, velocity) { + time = this.toSeconds(time); + var originalAttack = this.toSeconds(this.attack); + var attack = originalAttack; + var decay = this.toSeconds(this.decay); + velocity = Tone.defaultArg(velocity, 1); + //check if it's not a complete attack + var currentValue = this.getValueAtTime(time); + if (currentValue > 0) { + //subtract the current value from the attack time + var attackRate = 1 / attack; + var remainingDistance = 1 - currentValue; + //the attack is now the remaining time + attack = remainingDistance / attackRate; + } + //attack + if (this._attackCurve === 'linear') { + this._sig.linearRampTo(velocity, attack, time); + } else if (this._attackCurve === 'exponential') { + this._sig.targetRampTo(velocity, attack, time); + } else if (attack > 0) { + this._sig.cancelAndHoldAtTime(time); + var curve = this._attackCurve; + //take only a portion of the curve + if (attack < originalAttack) { + var percentComplete = 1 - attack / originalAttack; + var sliceIndex = Math.floor(percentComplete * this._attackCurve.length); + curve = this._attackCurve.slice(sliceIndex); + //the first index is the current value + curve[0] = currentValue; + } + this._sig.setValueCurveAtTime(curve, time, attack, velocity); + } + //decay + if (decay) { + this._sig.targetRampTo(velocity * this.sustain, decay, attack + time); + } + return this; + }; + /** + * Triggers the release of the envelope. + * @param {Time} [time=now] When the release portion of the envelope should start. + * @returns {Tone.Envelope} this + * @example + * //trigger release immediately + * env.triggerRelease(); + */ + Tone.Envelope.prototype.triggerRelease = function (time) { + time = this.toSeconds(time); + var currentValue = this.getValueAtTime(time); + if (currentValue > 0) { + var release = this.toSeconds(this.release); + if (this._releaseCurve === 'linear') { + this._sig.linearRampTo(0, release, time); + } else if (this._releaseCurve === 'exponential') { + this._sig.targetRampTo(0, release, time); + } else { + var curve = this._releaseCurve; + if (Tone.isArray(curve)) { + this._sig.cancelAndHoldAtTime(time); + this._sig.setValueCurveAtTime(curve, time, release, currentValue); + } + } + } + return this; + }; + /** + * Get the scheduled value at the given time. This will + * return the unconverted (raw) value. + * @param {Number} time The time in seconds. + * @return {Number} The scheduled value at the given time. + */ + Tone.Envelope.prototype.getValueAtTime = function (time) { + return this._sig.getValueAtTime(time); + }; + /** + * triggerAttackRelease is shorthand for triggerAttack, then waiting + * some duration, then triggerRelease. + * @param {Time} duration The duration of the sustain. + * @param {Time} [time=now] When the attack should be triggered. + * @param {number} [velocity=1] The velocity of the envelope. + * @returns {Tone.Envelope} this + * @example + * //trigger the attack and then the release after 0.6 seconds. + * env.triggerAttackRelease(0.6); + */ + Tone.Envelope.prototype.triggerAttackRelease = function (duration, time, velocity) { + time = this.toSeconds(time); + this.triggerAttack(time, velocity); + this.triggerRelease(time + this.toSeconds(duration)); + return this; + }; + /** + * Cancels all scheduled envelope changes after the given time. + * @param {Time} after + * @returns {Tone.Envelope} this + */ + Tone.Envelope.prototype.cancel = function (after) { + this._sig.cancelScheduledValues(after); + return this; + }; + /** + * Borrows the connect method from Tone.Signal. + * @function + * @private + */ + Tone.Envelope.prototype.connect = Tone.SignalBase.prototype.connect; + /** + * Generate some complex envelope curves. + */ + (function _createCurves() { + var curveLen = 128; + var i, k; + //cosine curve + var cosineCurve = []; + for (i = 0; i < curveLen; i++) { + cosineCurve[i] = Math.sin(i / (curveLen - 1) * (Math.PI / 2)); + } + //ripple curve + var rippleCurve = []; + var rippleCurveFreq = 6.4; + for (i = 0; i < curveLen - 1; i++) { + k = i / (curveLen - 1); + var sineWave = Math.sin(k * (Math.PI * 2) * rippleCurveFreq - Math.PI / 2) + 1; + rippleCurve[i] = sineWave / 10 + k * 0.83; + } + rippleCurve[curveLen - 1] = 1; + //stairs curve + var stairsCurve = []; + var steps = 5; + for (i = 0; i < curveLen; i++) { + stairsCurve[i] = Math.ceil(i / (curveLen - 1) * steps) / steps; + } + //in-out easing curve + var sineCurve = []; + for (i = 0; i < curveLen; i++) { + k = i / (curveLen - 1); + sineCurve[i] = 0.5 * (1 - Math.cos(Math.PI * k)); + } + //a bounce curve + var bounceCurve = []; + for (i = 0; i < curveLen; i++) { + k = i / (curveLen - 1); + var freq = Math.pow(k, 3) * 4 + 0.2; + var val = Math.cos(freq * Math.PI * 2 * k); + bounceCurve[i] = Math.abs(val * (1 - k)); + } + /** + * Invert a value curve to make it work for the release + * @private + */ + function invertCurve(curve) { + var out = new Array(curve.length); + for (var j = 0; j < curve.length; j++) { + out[j] = 1 - curve[j]; + } + return out; + } + /** + * reverse the curve + * @private + */ + function reverseCurve(curve) { + return curve.slice(0).reverse(); + } + /** + * attack and release curve arrays + * @type {Object} + * @private + */ + Tone.Envelope.Type = { + 'linear': 'linear', + 'exponential': 'exponential', + 'bounce': { + In: invertCurve(bounceCurve), + Out: bounceCurve + }, + 'cosine': { + In: cosineCurve, + Out: reverseCurve(cosineCurve) + }, + 'step': { + In: stairsCurve, + Out: invertCurve(stairsCurve) + }, + 'ripple': { + In: rippleCurve, + Out: invertCurve(rippleCurve) + }, + 'sine': { + In: sineCurve, + Out: invertCurve(sineCurve) + } + }; + }()); + /** + * Disconnect and dispose. + * @returns {Tone.Envelope} this + */ + Tone.Envelope.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._sig.dispose(); + this._sig = null; + this._attackCurve = null; + this._releaseCurve = null; + return this; + }; + return Tone.Envelope; + }); + Module(function (Tone) { + + /** + * @class Tone.AmplitudeEnvelope is a Tone.Envelope connected to a gain node. + * Unlike Tone.Envelope, which outputs the envelope's value, Tone.AmplitudeEnvelope accepts + * an audio signal as the input and will apply the envelope to the amplitude + * of the signal. Read more about ADSR Envelopes on [Wikipedia](https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope). + * + * @constructor + * @extends {Tone.Envelope} + * @param {Time|Object} [attack] The amount of time it takes for the envelope to go from + * 0 to it's maximum value. + * @param {Time} [decay] The period of time after the attack that it takes for the envelope + * to fall to the sustain value. + * @param {NormalRange} [sustain] The percent of the maximum value that the envelope rests at until + * the release is triggered. + * @param {Time} [release] The amount of time after the release is triggered it takes to reach 0. + * @example + * var ampEnv = new Tone.AmplitudeEnvelope({ + * "attack": 0.1, + * "decay": 0.2, + * "sustain": 1.0, + * "release": 0.8 + * }).toMaster(); + * //create an oscillator and connect it + * var osc = new Tone.Oscillator().connect(ampEnv).start(); + * //trigger the envelopes attack and release "8t" apart + * ampEnv.triggerAttackRelease("8t"); + */ + Tone.AmplitudeEnvelope = function () { + Tone.Envelope.apply(this, arguments); + /** + * the input node + * @type {GainNode} + * @private + */ + this.input = this.output = new Tone.Gain(); + this._sig.connect(this.output.gain); + }; + Tone.extend(Tone.AmplitudeEnvelope, Tone.Envelope); + /** + * Clean up + * @return {Tone.AmplitudeEnvelope} this + */ + Tone.AmplitudeEnvelope.prototype.dispose = function () { + Tone.Envelope.prototype.dispose.call(this); + return this; + }; + return Tone.AmplitudeEnvelope; + }); + Module(function (Tone) { + /** + * AnalyserNode.getFloatTimeDomainData polyfill + * @private + */ + if (Tone.supported) { + if (!AnalyserNode.prototype.getFloatTimeDomainData) { + //referenced https://github.com/mohayonao/get-float-time-domain-data + AnalyserNode.prototype.getFloatTimeDomainData = function (array) { + var uint8 = new Uint8Array(array.length); + this.getByteTimeDomainData(uint8); + for (var i = 0; i < uint8.length; i++) { + array[i] = (uint8[i] - 128) / 128; + } + }; + } + } + }); + Module(function (Tone) { + + /** + * @class Wrapper around the native Web Audio's + * [AnalyserNode](http://webaudio.github.io/web-audio-api/#idl-def-AnalyserNode). + * Extracts FFT or Waveform data from the incoming signal. + * @extends {Tone.AudioNode} + * @param {String=} type The return type of the analysis, either "fft", or "waveform". + * @param {Number=} size The size of the FFT. Value must be a power of + * two in the range 32 to 32768. + */ + Tone.Analyser = function () { + var options = Tone.defaults(arguments, [ + 'type', + 'size' + ], Tone.Analyser); + Tone.AudioNode.call(this); + /** + * The analyser node. + * @private + * @type {AnalyserNode} + */ + this._analyser = this.input = this.output = this.context.createAnalyser(); + /** + * The analysis type + * @type {String} + * @private + */ + this._type = options.type; + /** + * The buffer that the FFT data is written to + * @type {TypedArray} + * @private + */ + this._buffer = null; + //set the values initially + this.size = options.size; + this.type = options.type; + }; + Tone.extend(Tone.Analyser, Tone.AudioNode); + /** + * The default values. + * @type {Object} + * @const + */ + Tone.Analyser.defaults = { + 'size': 1024, + 'type': 'fft', + 'smoothing': 0.8 + }; + /** + * Possible return types of analyser.getValue() + * @enum {String} + */ + Tone.Analyser.Type = { + Waveform: 'waveform', + FFT: 'fft' + }; + /** + * Run the analysis given the current settings and return the + * result as a TypedArray. + * @returns {TypedArray} + */ + Tone.Analyser.prototype.getValue = function () { + if (this._type === Tone.Analyser.Type.FFT) { + this._analyser.getFloatFrequencyData(this._buffer); + } else if (this._type === Tone.Analyser.Type.Waveform) { + this._analyser.getFloatTimeDomainData(this._buffer); + } + return this._buffer; + }; + /** + * The size of analysis. This must be a power of two in the range 32 to 32768. + * @memberOf Tone.Analyser# + * @type {Number} + * @name size + */ + Object.defineProperty(Tone.Analyser.prototype, 'size', { + get: function () { + return this._analyser.frequencyBinCount; + }, + set: function (size) { + this._analyser.fftSize = size * 2; + this._buffer = new Float32Array(size); + } + }); + /** + * The analysis function returned by analyser.getValue(), either "fft" or "waveform". + * @memberOf Tone.Analyser# + * @type {String} + * @name type + */ + Object.defineProperty(Tone.Analyser.prototype, 'type', { + get: function () { + return this._type; + }, + set: function (type) { + if (type !== Tone.Analyser.Type.Waveform && type !== Tone.Analyser.Type.FFT) { + throw new TypeError('Tone.Analyser: invalid type: ' + type); + } + this._type = type; + } + }); + /** + * 0 represents no time averaging with the last analysis frame. + * @memberOf Tone.Analyser# + * @type {NormalRange} + * @name smoothing + */ + Object.defineProperty(Tone.Analyser.prototype, 'smoothing', { + get: function () { + return this._analyser.smoothingTimeConstant; + }, + set: function (val) { + this._analyser.smoothingTimeConstant = val; + } + }); + /** + * Clean up. + * @return {Tone.Analyser} this + */ + Tone.Analyser.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._analyser.disconnect(); + this._analyser = null; + this._buffer = null; + }; + return Tone.Analyser; + }); + Module(function (Tone) { + + /** + * @class Tone.Compressor is a thin wrapper around the Web Audio + * [DynamicsCompressorNode](http://webaudio.github.io/web-audio-api/#the-dynamicscompressornode-interface). + * Compression reduces the volume of loud sounds or amplifies quiet sounds + * by narrowing or "compressing" an audio signal's dynamic range. + * Read more on [Wikipedia](https://en.wikipedia.org/wiki/Dynamic_range_compression). + * + * @extends {Tone.AudioNode} + * @constructor + * @param {Decibels|Object} [threshold] The value above which the compression starts to be applied. + * @param {Positive} [ratio] The gain reduction ratio. + * @example + * var comp = new Tone.Compressor(-30, 3); + */ + Tone.Compressor = function () { + var options = Tone.defaults(arguments, [ + 'threshold', + 'ratio' + ], Tone.Compressor); + Tone.AudioNode.call(this); + /** + * the compressor node + * @type {DynamicsCompressorNode} + * @private + */ + this._compressor = this.input = this.output = this.context.createDynamicsCompressor(); + /** + * the threshold vaue + * @type {Decibels} + * @signal + */ + this.threshold = new Tone.Param({ + 'param': this._compressor.threshold, + 'units': Tone.Type.Decibels, + 'convert': false + }); + /** + * The attack parameter + * @type {Time} + * @signal + */ + this.attack = new Tone.Param(this._compressor.attack, Tone.Type.Time); + /** + * The release parameter + * @type {Time} + * @signal + */ + this.release = new Tone.Param(this._compressor.release, Tone.Type.Time); + /** + * The knee parameter + * @type {Decibels} + * @signal + */ + this.knee = new Tone.Param({ + 'param': this._compressor.knee, + 'units': Tone.Type.Decibels, + 'convert': false + }); + /** + * The ratio value + * @type {Number} + * @signal + */ + this.ratio = new Tone.Param({ + 'param': this._compressor.ratio, + 'convert': false + }); + //set the defaults + this._readOnly([ + 'knee', + 'release', + 'attack', + 'ratio', + 'threshold' + ]); + this.set(options); + }; + Tone.extend(Tone.Compressor, Tone.AudioNode); + /** + * @static + * @const + * @type {Object} + */ + Tone.Compressor.defaults = { + 'ratio': 12, + 'threshold': -24, + 'release': 0.25, + 'attack': 0.003, + 'knee': 30 + }; + /** + * clean up + * @returns {Tone.Compressor} this + */ + Tone.Compressor.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable([ + 'knee', + 'release', + 'attack', + 'ratio', + 'threshold' + ]); + this._compressor.disconnect(); + this._compressor = null; + this.attack.dispose(); + this.attack = null; + this.release.dispose(); + this.release = null; + this.threshold.dispose(); + this.threshold = null; + this.ratio.dispose(); + this.ratio = null; + this.knee.dispose(); + this.knee = null; + return this; + }; + return Tone.Compressor; + }); + Module(function (Tone) { + + /** + * @class Add a signal and a number or two signals. When no value is + * passed into the constructor, Tone.Add will sum <code>input[0]</code> + * and <code>input[1]</code>. If a value is passed into the constructor, + * the it will be added to the input. + * + * @constructor + * @extends {Tone.Signal} + * @param {number=} value If no value is provided, Tone.Add will sum the first + * and second inputs. + * @example + * var signal = new Tone.Signal(2); + * var add = new Tone.Add(2); + * signal.connect(add); + * //the output of add equals 4 + * @example + * //if constructed with no arguments + * //it will add the first and second inputs + * var add = new Tone.Add(); + * var sig0 = new Tone.Signal(3).connect(add, 0, 0); + * var sig1 = new Tone.Signal(4).connect(add, 0, 1); + * //the output of add equals 7. + */ + Tone.Add = function (value) { + Tone.Signal.call(this); + this.createInsOuts(2, 0); + /** + * the summing node + * @type {GainNode} + * @private + */ + this._sum = this.input[0] = this.input[1] = this.output = new Tone.Gain(); + /** + * @private + * @type {Tone.Signal} + */ + this._param = this.input[1] = new Tone.Signal(value); + this._param.connect(this._sum); + }; + Tone.extend(Tone.Add, Tone.Signal); + /** + * Clean up. + * @returns {Tone.Add} this + */ + Tone.Add.prototype.dispose = function () { + Tone.Signal.prototype.dispose.call(this); + this._sum.dispose(); + this._sum = null; + return this; + }; + return Tone.Add; + }); + Module(function (Tone) { + + /** + * @class Multiply two incoming signals. Or, if a number is given in the constructor, + * multiplies the incoming signal by that value. + * + * @constructor + * @extends {Tone.Signal} + * @param {number=} value Constant value to multiple. If no value is provided, + * it will return the product of the first and second inputs + * @example + * var mult = new Tone.Multiply(); + * var sigA = new Tone.Signal(3); + * var sigB = new Tone.Signal(4); + * sigA.connect(mult, 0, 0); + * sigB.connect(mult, 0, 1); + * //output of mult is 12. + * @example + * var mult = new Tone.Multiply(10); + * var sig = new Tone.Signal(2).connect(mult); + * //the output of mult is 20. + */ + Tone.Multiply = function (value) { + Tone.Signal.call(this); + this.createInsOuts(2, 0); + /** + * the input node is the same as the output node + * it is also the GainNode which handles the scaling of incoming signal + * + * @type {GainNode} + * @private + */ + this._mult = this.input[0] = this.output = new Tone.Gain(); + /** + * the scaling parameter + * @type {AudioParam} + * @private + */ + this._param = this.input[1] = this.output.gain; + this.value = Tone.defaultArg(value, 0); + }; + Tone.extend(Tone.Multiply, Tone.Signal); + /** + * clean up + * @returns {Tone.Multiply} this + */ + Tone.Multiply.prototype.dispose = function () { + Tone.Signal.prototype.dispose.call(this); + this._mult.dispose(); + this._mult = null; + this._param = null; + return this; + }; + return Tone.Multiply; + }); + Module(function (Tone) { + + /** + * @class Negate the incoming signal. i.e. an input signal of 10 will output -10 + * + * @constructor + * @extends {Tone.SignalBase} + * @example + * var neg = new Tone.Negate(); + * var sig = new Tone.Signal(-2).connect(neg); + * //output of neg is positive 2. + */ + Tone.Negate = function () { + Tone.SignalBase.call(this); + /** + * negation is done by multiplying by -1 + * @type {Tone.Multiply} + * @private + */ + this._multiply = this.input = this.output = new Tone.Multiply(-1); + }; + Tone.extend(Tone.Negate, Tone.SignalBase); + /** + * clean up + * @returns {Tone.Negate} this + */ + Tone.Negate.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._multiply.dispose(); + this._multiply = null; + return this; + }; + return Tone.Negate; + }); + Module(function (Tone) { + + /** + * @class Subtract the signal connected to <code>input[1]</code> from the signal connected + * to <code>input[0]</code>. If an argument is provided in the constructor, the + * signals <code>.value</code> will be subtracted from the incoming signal. + * + * @extends {Tone.Signal} + * @constructor + * @param {number=} value The value to subtract from the incoming signal. If the value + * is omitted, it will subtract the second signal from the first. + * @example + * var sub = new Tone.Subtract(1); + * var sig = new Tone.Signal(4).connect(sub); + * //the output of sub is 3. + * @example + * var sub = new Tone.Subtract(); + * var sigA = new Tone.Signal(10); + * var sigB = new Tone.Signal(2.5); + * sigA.connect(sub, 0, 0); + * sigB.connect(sub, 0, 1); + * //output of sub is 7.5 + */ + Tone.Subtract = function (value) { + Tone.Signal.call(this); + this.createInsOuts(2, 0); + /** + * the summing node + * @type {GainNode} + * @private + */ + this._sum = this.input[0] = this.output = new Tone.Gain(); + /** + * negate the input of the second input before connecting it + * to the summing node. + * @type {Tone.Negate} + * @private + */ + this._neg = new Tone.Negate(); + /** + * the node where the value is set + * @private + * @type {Tone.Signal} + */ + this._param = this.input[1] = new Tone.Signal(value); + this._param.chain(this._neg, this._sum); + }; + Tone.extend(Tone.Subtract, Tone.Signal); + /** + * Clean up. + * @returns {Tone.SignalBase} this + */ + Tone.Subtract.prototype.dispose = function () { + Tone.Signal.prototype.dispose.call(this); + this._neg.dispose(); + this._neg = null; + this._sum.disconnect(); + this._sum = null; + return this; + }; + return Tone.Subtract; + }); + Module(function (Tone) { + + /** + * @class Convert an incoming signal between 0, 1 to an equal power gain scale. + * + * @extends {Tone.SignalBase} + * @constructor + * @example + * var eqPowGain = new Tone.EqualPowerGain(); + */ + Tone.EqualPowerGain = function () { + Tone.SignalBase.call(this); + /** + * @type {Tone.WaveShaper} + * @private + */ + this._eqPower = this.input = this.output = new Tone.WaveShaper(function (val) { + if (Math.abs(val) < 0.001) { + //should output 0 when input is 0 + return 0; + } else { + return Tone.equalPowerScale(val); + } + }.bind(this), 4096); + }; + Tone.extend(Tone.EqualPowerGain, Tone.SignalBase); + /** + * clean up + * @returns {Tone.EqualPowerGain} this + */ + Tone.EqualPowerGain.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._eqPower.dispose(); + this._eqPower = null; + return this; + }; + return Tone.EqualPowerGain; + }); + Module(function (Tone) { + + /** + * @class Tone.Crossfade provides equal power fading between two inputs. + * More on crossfading technique [here](https://en.wikipedia.org/wiki/Fade_(audio_engineering)#Crossfading). + * + * @constructor + * @extends {Tone.AudioNode} + * @param {NormalRange} [initialFade=0.5] + * @example + * var crossFade = new Tone.CrossFade(0.5); + * //connect effect A to crossfade from + * //effect output 0 to crossfade input 0 + * effectA.connect(crossFade, 0, 0); + * //connect effect B to crossfade from + * //effect output 0 to crossfade input 1 + * effectB.connect(crossFade, 0, 1); + * crossFade.fade.value = 0; + * // ^ only effectA is output + * crossFade.fade.value = 1; + * // ^ only effectB is output + * crossFade.fade.value = 0.5; + * // ^ the two signals are mixed equally. + */ + Tone.CrossFade = function (initialFade) { + Tone.AudioNode.call(this); + this.createInsOuts(2, 1); + /** + * Alias for <code>input[0]</code>. + * @type {Tone.Gain} + */ + this.a = this.input[0] = new Tone.Gain(); + /** + * Alias for <code>input[1]</code>. + * @type {Tone.Gain} + */ + this.b = this.input[1] = new Tone.Gain(); + /** + * The mix between the two inputs. A fade value of 0 + * will output 100% <code>input[0]</code> and + * a value of 1 will output 100% <code>input[1]</code>. + * @type {NormalRange} + * @signal + */ + this.fade = new Tone.Signal(Tone.defaultArg(initialFade, 0.5), Tone.Type.NormalRange); + /** + * equal power gain cross fade + * @private + * @type {Tone.EqualPowerGain} + */ + this._equalPowerA = new Tone.EqualPowerGain(); + /** + * equal power gain cross fade + * @private + * @type {Tone.EqualPowerGain} + */ + this._equalPowerB = new Tone.EqualPowerGain(); + /** + * invert the incoming signal + * @private + * @type {Tone} + */ + this._one = this.context.getConstant(1); + /** + * invert the incoming signal + * @private + * @type {Tone.Subtract} + */ + this._invert = new Tone.Subtract(); + //connections + this.a.connect(this.output); + this.b.connect(this.output); + this.fade.chain(this._equalPowerB, this.b.gain); + this._one.connect(this._invert, 0, 0); + this.fade.connect(this._invert, 0, 1); + this._invert.chain(this._equalPowerA, this.a.gain); + this._readOnly('fade'); + }; + Tone.extend(Tone.CrossFade, Tone.AudioNode); + /** + * clean up + * @returns {Tone.CrossFade} this + */ + Tone.CrossFade.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable('fade'); + this._equalPowerA.dispose(); + this._equalPowerA = null; + this._equalPowerB.dispose(); + this._equalPowerB = null; + this.fade.dispose(); + this.fade = null; + this._invert.dispose(); + this._invert = null; + this._one = null; + this.a.dispose(); + this.a = null; + this.b.dispose(); + this.b = null; + return this; + }; + return Tone.CrossFade; + }); + Module(function (Tone) { + + /** + * @class Tone.Filter is a filter which allows for all of the same native methods + * as the [BiquadFilterNode](http://webaudio.github.io/web-audio-api/#the-biquadfilternode-interface). + * Tone.Filter has the added ability to set the filter rolloff at -12 + * (default), -24 and -48. + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Frequency|Object} [frequency] The cutoff frequency of the filter. + * @param {string=} type The type of filter. + * @param {number=} rolloff The drop in decibels per octave after the cutoff frequency. + * 3 choices: -12, -24, and -48 + * @example + * var filter = new Tone.Filter(200, "highpass"); + */ + Tone.Filter = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'type', + 'rolloff' + ], Tone.Filter); + Tone.AudioNode.call(this); + this.createInsOuts(1, 1); + /** + * the filter(s) + * @type {Array} + * @private + */ + this._filters = []; + /** + * The cutoff frequency of the filter. + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency); + /** + * The detune parameter + * @type {Cents} + * @signal + */ + this.detune = new Tone.Signal(0, Tone.Type.Cents); + /** + * The gain of the filter, only used in certain filter types + * @type {Number} + * @signal + */ + this.gain = new Tone.Signal({ + 'value': options.gain, + 'convert': false + }); + /** + * The Q or Quality of the filter + * @type {Positive} + * @signal + */ + this.Q = new Tone.Signal(options.Q); + /** + * the type of the filter + * @type {string} + * @private + */ + this._type = options.type; + /** + * the rolloff value of the filter + * @type {number} + * @private + */ + this._rolloff = options.rolloff; + //set the rolloff; + this.rolloff = options.rolloff; + this._readOnly([ + 'detune', + 'frequency', + 'gain', + 'Q' + ]); + }; + Tone.extend(Tone.Filter, Tone.AudioNode); + /** + * the default parameters + * + * @static + * @type {Object} + */ + Tone.Filter.defaults = { + 'type': 'lowpass', + 'frequency': 350, + 'rolloff': -12, + 'Q': 1, + 'gain': 0 + }; + /** + * The type of the filter. Types: "lowpass", "highpass", + * "bandpass", "lowshelf", "highshelf", "notch", "allpass", or "peaking". + * @memberOf Tone.Filter# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.Filter.prototype, 'type', { + get: function () { + return this._type; + }, + set: function (type) { + var types = [ + 'lowpass', + 'highpass', + 'bandpass', + 'lowshelf', + 'highshelf', + 'notch', + 'allpass', + 'peaking' + ]; + if (types.indexOf(type) === -1) { + throw new TypeError('Tone.Filter: invalid type ' + type); + } + this._type = type; + for (var i = 0; i < this._filters.length; i++) { + this._filters[i].type = type; + } + } + }); + /** + * The rolloff of the filter which is the drop in db + * per octave. Implemented internally by cascading filters. + * Only accepts the values -12, -24, -48 and -96. + * @memberOf Tone.Filter# + * @type {number} + * @name rolloff + */ + Object.defineProperty(Tone.Filter.prototype, 'rolloff', { + get: function () { + return this._rolloff; + }, + set: function (rolloff) { + rolloff = parseInt(rolloff, 10); + var possibilities = [ + -12, + -24, + -48, + -96 + ]; + var cascadingCount = possibilities.indexOf(rolloff); + //check the rolloff is valid + if (cascadingCount === -1) { + throw new RangeError('Tone.Filter: rolloff can only be -12, -24, -48 or -96'); + } + cascadingCount += 1; + this._rolloff = rolloff; + //first disconnect the filters and throw them away + this.input.disconnect(); + for (var i = 0; i < this._filters.length; i++) { + this._filters[i].disconnect(); + this._filters[i] = null; + } + this._filters = new Array(cascadingCount); + for (var count = 0; count < cascadingCount; count++) { + var filter = this.context.createBiquadFilter(); + filter.type = this._type; + this.frequency.connect(filter.frequency); + this.detune.connect(filter.detune); + this.Q.connect(filter.Q); + this.gain.connect(filter.gain); + this._filters[count] = filter; + } + //connect them up + var connectionChain = [this.input].concat(this._filters).concat([this.output]); + Tone.connectSeries.apply(Tone, connectionChain); + } + }); + /** + * Clean up. + * @return {Tone.Filter} this + */ + Tone.Filter.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + for (var i = 0; i < this._filters.length; i++) { + this._filters[i].disconnect(); + this._filters[i] = null; + } + this._filters = null; + this._writable([ + 'detune', + 'frequency', + 'gain', + 'Q' + ]); + this.frequency.dispose(); + this.Q.dispose(); + this.frequency = null; + this.Q = null; + this.detune.dispose(); + this.detune = null; + this.gain.dispose(); + this.gain = null; + return this; + }; + return Tone.Filter; + }); + Module(function (Tone) { + + /** + * @class Split the incoming signal into three bands (low, mid, high) + * with two crossover frequency controls. + * + * @extends {Tone.AudioNode} + * @constructor + * @param {Frequency|Object} [lowFrequency] the low/mid crossover frequency + * @param {Frequency} [highFrequency] the mid/high crossover frequency + */ + Tone.MultibandSplit = function () { + var options = Tone.defaults(arguments, [ + 'lowFrequency', + 'highFrequency' + ], Tone.MultibandSplit); + Tone.AudioNode.call(this); + /** + * the input + * @type {Tone.Gain} + * @private + */ + this.input = new Tone.Gain(); + /** + * the outputs + * @type {Array} + * @private + */ + this.output = new Array(3); + /** + * The low band. Alias for <code>output[0]</code> + * @type {Tone.Filter} + */ + this.low = this.output[0] = new Tone.Filter(0, 'lowpass'); + /** + * the lower filter of the mid band + * @type {Tone.Filter} + * @private + */ + this._lowMidFilter = new Tone.Filter(0, 'highpass'); + /** + * The mid band output. Alias for <code>output[1]</code> + * @type {Tone.Filter} + */ + this.mid = this.output[1] = new Tone.Filter(0, 'lowpass'); + /** + * The high band output. Alias for <code>output[2]</code> + * @type {Tone.Filter} + */ + this.high = this.output[2] = new Tone.Filter(0, 'highpass'); + /** + * The low/mid crossover frequency. + * @type {Frequency} + * @signal + */ + this.lowFrequency = new Tone.Signal(options.lowFrequency, Tone.Type.Frequency); + /** + * The mid/high crossover frequency. + * @type {Frequency} + * @signal + */ + this.highFrequency = new Tone.Signal(options.highFrequency, Tone.Type.Frequency); + /** + * The quality of all the filters + * @type {Number} + * @signal + */ + this.Q = new Tone.Signal(options.Q); + this.input.fan(this.low, this.high); + this.input.chain(this._lowMidFilter, this.mid); + //the frequency control signal + this.lowFrequency.connect(this.low.frequency); + this.lowFrequency.connect(this._lowMidFilter.frequency); + this.highFrequency.connect(this.mid.frequency); + this.highFrequency.connect(this.high.frequency); + //the Q value + this.Q.connect(this.low.Q); + this.Q.connect(this._lowMidFilter.Q); + this.Q.connect(this.mid.Q); + this.Q.connect(this.high.Q); + this._readOnly([ + 'high', + 'mid', + 'low', + 'highFrequency', + 'lowFrequency' + ]); + }; + Tone.extend(Tone.MultibandSplit, Tone.AudioNode); + /** + * @private + * @static + * @type {Object} + */ + Tone.MultibandSplit.defaults = { + 'lowFrequency': 400, + 'highFrequency': 2500, + 'Q': 1 + }; + /** + * Clean up. + * @returns {Tone.MultibandSplit} this + */ + Tone.MultibandSplit.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable([ + 'high', + 'mid', + 'low', + 'highFrequency', + 'lowFrequency' + ]); + this.low.dispose(); + this.low = null; + this._lowMidFilter.dispose(); + this._lowMidFilter = null; + this.mid.dispose(); + this.mid = null; + this.high.dispose(); + this.high = null; + this.lowFrequency.dispose(); + this.lowFrequency = null; + this.highFrequency.dispose(); + this.highFrequency = null; + this.Q.dispose(); + this.Q = null; + return this; + }; + return Tone.MultibandSplit; + }); + Module(function (Tone) { + + /** + * @class Tone.EQ3 is a three band EQ with control over low, mid, and high gain as + * well as the low and high crossover frequencies. + * + * @constructor + * @extends {Tone.AudioNode} + * + * @param {Decibels|Object} [lowLevel] The gain applied to the lows. + * @param {Decibels} [midLevel] The gain applied to the mid. + * @param {Decibels} [highLevel] The gain applied to the high. + * @example + * var eq = new Tone.EQ3(-10, 3, -20); + */ + Tone.EQ3 = function () { + var options = Tone.defaults(arguments, [ + 'low', + 'mid', + 'high' + ], Tone.EQ3); + Tone.AudioNode.call(this); + /** + * the output node + * @type {GainNode} + * @private + */ + this.output = new Tone.Gain(); + /** + * the multiband split + * @type {Tone.MultibandSplit} + * @private + */ + this._multibandSplit = this.input = new Tone.MultibandSplit({ + 'lowFrequency': options.lowFrequency, + 'highFrequency': options.highFrequency + }); + /** + * The gain for the lower signals + * @type {Tone.Gain} + * @private + */ + this._lowGain = new Tone.Gain(options.low, Tone.Type.Decibels); + /** + * The gain for the mid signals + * @type {Tone.Gain} + * @private + */ + this._midGain = new Tone.Gain(options.mid, Tone.Type.Decibels); + /** + * The gain in decibels of the high part + * @type {Tone.Gain} + * @private + */ + this._highGain = new Tone.Gain(options.high, Tone.Type.Decibels); + /** + * The gain in decibels of the low part + * @type {Decibels} + * @signal + */ + this.low = this._lowGain.gain; + /** + * The gain in decibels of the mid part + * @type {Decibels} + * @signal + */ + this.mid = this._midGain.gain; + /** + * The gain in decibels of the high part + * @type {Decibels} + * @signal + */ + this.high = this._highGain.gain; + /** + * The Q value for all of the filters. + * @type {Positive} + * @signal + */ + this.Q = this._multibandSplit.Q; + /** + * The low/mid crossover frequency. + * @type {Frequency} + * @signal + */ + this.lowFrequency = this._multibandSplit.lowFrequency; + /** + * The mid/high crossover frequency. + * @type {Frequency} + * @signal + */ + this.highFrequency = this._multibandSplit.highFrequency; + //the frequency bands + this._multibandSplit.low.chain(this._lowGain, this.output); + this._multibandSplit.mid.chain(this._midGain, this.output); + this._multibandSplit.high.chain(this._highGain, this.output); + this._readOnly([ + 'low', + 'mid', + 'high', + 'lowFrequency', + 'highFrequency' + ]); + }; + Tone.extend(Tone.EQ3, Tone.AudioNode); + /** + * the default values + */ + Tone.EQ3.defaults = { + 'low': 0, + 'mid': 0, + 'high': 0, + 'lowFrequency': 400, + 'highFrequency': 2500 + }; + /** + * clean up + * @returns {Tone.EQ3} this + */ + Tone.EQ3.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable([ + 'low', + 'mid', + 'high', + 'lowFrequency', + 'highFrequency' + ]); + this._multibandSplit.dispose(); + this._multibandSplit = null; + this.lowFrequency = null; + this.highFrequency = null; + this._lowGain.dispose(); + this._lowGain = null; + this._midGain.dispose(); + this._midGain = null; + this._highGain.dispose(); + this._highGain = null; + this.low = null; + this.mid = null; + this.high = null; + this.Q = null; + return this; + }; + return Tone.EQ3; + }); + Module(function (Tone) { + + /** + * @class Performs a linear scaling on an input signal. + * Scales a NormalRange input to between + * outputMin and outputMax. + * + * @constructor + * @extends {Tone.SignalBase} + * @param {number} [outputMin=0] The output value when the input is 0. + * @param {number} [outputMax=1] The output value when the input is 1. + * @example + * var scale = new Tone.Scale(50, 100); + * var signal = new Tone.Signal(0.5).connect(scale); + * //the output of scale equals 75 + */ + Tone.Scale = function (outputMin, outputMax) { + Tone.SignalBase.call(this); + /** + * @private + * @type {number} + */ + this._outputMin = Tone.defaultArg(outputMin, 0); + /** + * @private + * @type {number} + */ + this._outputMax = Tone.defaultArg(outputMax, 1); + /** + * @private + * @type {Tone.Multiply} + * @private + */ + this._scale = this.input = new Tone.Multiply(1); + /** + * @private + * @type {Tone.Add} + * @private + */ + this._add = this.output = new Tone.Add(0); + this._scale.connect(this._add); + this._setRange(); + }; + Tone.extend(Tone.Scale, Tone.SignalBase); + /** + * The minimum output value. This number is output when + * the value input value is 0. + * @memberOf Tone.Scale# + * @type {number} + * @name min + */ + Object.defineProperty(Tone.Scale.prototype, 'min', { + get: function () { + return this._outputMin; + }, + set: function (min) { + this._outputMin = min; + this._setRange(); + } + }); + /** + * The maximum output value. This number is output when + * the value input value is 1. + * @memberOf Tone.Scale# + * @type {number} + * @name max + */ + Object.defineProperty(Tone.Scale.prototype, 'max', { + get: function () { + return this._outputMax; + }, + set: function (max) { + this._outputMax = max; + this._setRange(); + } + }); + /** + * set the values + * @private + */ + Tone.Scale.prototype._setRange = function () { + this._add.value = this._outputMin; + this._scale.value = this._outputMax - this._outputMin; + }; + /** + * Clean up. + * @returns {Tone.Scale} this + */ + Tone.Scale.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._add.dispose(); + this._add = null; + this._scale.dispose(); + this._scale = null; + return this; + }; + return Tone.Scale; + }); + Module(function (Tone) { + /** + * @class Performs an exponential scaling on an input signal. + * Scales a NormalRange value [0,1] exponentially + * to the output range of outputMin to outputMax. + * + * @constructor + * @extends {Tone.SignalBase} + * @param {number} [outputMin=0] The output value when the input is 0. + * @param {number} [outputMax=1] The output value when the input is 1. + * @param {number} [exponent=2] The exponent which scales the incoming signal. + * @example + * var scaleExp = new Tone.ScaleExp(0, 100, 2); + * var signal = new Tone.Signal(0.5).connect(scaleExp); + */ + Tone.ScaleExp = function (outputMin, outputMax, exponent) { + Tone.SignalBase.call(this); + /** + * scale the input to the output range + * @type {Tone.Scale} + * @private + */ + this._scale = this.output = new Tone.Scale(outputMin, outputMax); + /** + * @private + * @type {Tone.Pow} + * @private + */ + this._exp = this.input = new Tone.Pow(Tone.defaultArg(exponent, 2)); + this._exp.connect(this._scale); + }; + Tone.extend(Tone.ScaleExp, Tone.SignalBase); + /** + * Instead of interpolating linearly between the <code>min</code> and + * <code>max</code> values, setting the exponent will interpolate between + * the two values with an exponential curve. + * @memberOf Tone.ScaleExp# + * @type {number} + * @name exponent + */ + Object.defineProperty(Tone.ScaleExp.prototype, 'exponent', { + get: function () { + return this._exp.value; + }, + set: function (exp) { + this._exp.value = exp; + } + }); + /** + * The minimum output value. This number is output when + * the value input value is 0. + * @memberOf Tone.ScaleExp# + * @type {number} + * @name min + */ + Object.defineProperty(Tone.ScaleExp.prototype, 'min', { + get: function () { + return this._scale.min; + }, + set: function (min) { + this._scale.min = min; + } + }); + /** + * The maximum output value. This number is output when + * the value input value is 1. + * @memberOf Tone.ScaleExp# + * @type {number} + * @name max + */ + Object.defineProperty(Tone.ScaleExp.prototype, 'max', { + get: function () { + return this._scale.max; + }, + set: function (max) { + this._scale.max = max; + } + }); + /** + * Clean up. + * @returns {Tone.ScaleExp} this + */ + Tone.ScaleExp.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._scale.dispose(); + this._scale = null; + this._exp.dispose(); + this._exp = null; + return this; + }; + return Tone.ScaleExp; + }); + Module(function (Tone) { + + /** + * @class Wrapper around Web Audio's native [DelayNode](http://webaudio.github.io/web-audio-api/#the-delaynode-interface). + * @extends {Tone} + * @param {Time=} delayTime The delay applied to the incoming signal. + * @param {Time=} maxDelay The maximum delay time. + */ + Tone.Delay = function () { + var options = Tone.defaults(arguments, [ + 'delayTime', + 'maxDelay' + ], Tone.Delay); + Tone.AudioNode.call(this); + /** + * The maximum delay time initialized with the node + * @type {Number} + * @private + */ + this._maxDelay = Math.max(this.toSeconds(options.maxDelay), this.toSeconds(options.delayTime)); + /** + * The native delay node + * @type {DelayNode} + * @private + */ + this._delayNode = this.input = this.output = this.context.createDelay(this._maxDelay); + /** + * The amount of time the incoming signal is + * delayed. + * @type {Time} + * @signal + */ + this.delayTime = new Tone.Param({ + 'param': this._delayNode.delayTime, + 'units': Tone.Type.Time, + 'value': options.delayTime + }); + this._readOnly('delayTime'); + }; + Tone.extend(Tone.Delay, Tone.AudioNode); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.Delay.defaults = { + 'maxDelay': 1, + 'delayTime': 0 + }; + /** + * The maximum delay time. This cannot be changed. The value is passed into the constructor. + * @memberof Tone.Delay# + * @type {Time} + * @name maxDelay + * @readOnly + */ + Object.defineProperty(Tone.Delay.prototype, 'maxDelay', { + get: function () { + return this._maxDelay; + } + }); + /** + * Clean up. + * @return {Tone.Delay} this + */ + Tone.Delay.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._delayNode.disconnect(); + this._delayNode = null; + this._writable('delayTime'); + this.delayTime = null; + return this; + }; + return Tone.Delay; + }); + Module(function (Tone) { + + /** + * @class Comb filters are basic building blocks for physical modeling. Read more + * about comb filters on [CCRMA's website](https://ccrma.stanford.edu/~jos/pasp/Feedback_Comb_Filters.html). + * + * @extends {Tone.AudioNode} + * @constructor + * @param {Time|Object} [delayTime] The delay time of the filter. + * @param {NormalRange=} resonance The amount of feedback the filter has. + */ + Tone.FeedbackCombFilter = function () { + var options = Tone.defaults(arguments, [ + 'delayTime', + 'resonance' + ], Tone.FeedbackCombFilter); + Tone.AudioNode.call(this); + /** + * the delay node + * @type {DelayNode} + * @private + */ + this._delay = this.input = this.output = new Tone.Delay(options.delayTime); + /** + * The amount of delay of the comb filter. + * @type {Time} + * @signal + */ + this.delayTime = this._delay.delayTime; + /** + * the feedback node + * @type {GainNode} + * @private + */ + this._feedback = new Tone.Gain(options.resonance, Tone.Type.NormalRange); + /** + * The amount of feedback of the delayed signal. + * @type {NormalRange} + * @signal + */ + this.resonance = this._feedback.gain; + this._delay.chain(this._feedback, this._delay); + this._readOnly([ + 'resonance', + 'delayTime' + ]); + }; + Tone.extend(Tone.FeedbackCombFilter, Tone.AudioNode); + /** + * the default parameters + * @static + * @const + * @type {Object} + */ + Tone.FeedbackCombFilter.defaults = { + 'delayTime': 0.1, + 'resonance': 0.5 + }; + /** + * clean up + * @returns {Tone.FeedbackCombFilter} this + */ + Tone.FeedbackCombFilter.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable([ + 'resonance', + 'delayTime' + ]); + this._delay.dispose(); + this._delay = null; + this.delayTime = null; + this._feedback.dispose(); + this._feedback = null; + this.resonance = null; + return this; + }; + return Tone.FeedbackCombFilter; + }); + Module(function (Tone) { + /** + * @class Get the current waveform data of the connected audio source. + * @extends {Tone.AudioNode} + * @param {Number=} size The size of the FFT. Value must be a power of + * two in the range 32 to 32768. + */ + Tone.FFT = function () { + var options = Tone.defaults(arguments, ['size'], Tone.FFT); + options.type = Tone.Analyser.Type.FFT; + Tone.AudioNode.call(this); + /** + * The analyser node. + * @private + * @type {Tone.Analyser} + */ + this._analyser = this.input = this.output = new Tone.Analyser(options); + }; + Tone.extend(Tone.FFT, Tone.AudioNode); + /** + * The default values. + * @type {Object} + * @const + */ + Tone.FFT.defaults = { 'size': 1024 }; + /** + * Gets the waveform of the audio source. Returns the waveform data + * of length [size](#size) as a Float32Array with values between -1 and 1. + * @returns {TypedArray} + */ + Tone.FFT.prototype.getValue = function () { + return this._analyser.getValue(); + }; + /** + * The size of analysis. This must be a power of two in the range 32 to 32768. + * @memberOf Tone.FFT# + * @type {Number} + * @name size + */ + Object.defineProperty(Tone.FFT.prototype, 'size', { + get: function () { + return this._analyser.size; + }, + set: function (size) { + this._analyser.size = size; + } + }); + /** + * Clean up. + * @return {Tone.FFT} this + */ + Tone.FFT.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._analyser.dispose(); + this._analyser = null; + }; + return Tone.FFT; + }); + Module(function (Tone) { + + /** + * @class Return the absolute value of an incoming signal. + * + * @constructor + * @extends {Tone.SignalBase} + * @example + * var signal = new Tone.Signal(-1); + * var abs = new Tone.Abs(); + * signal.connect(abs); + * //the output of abs is 1. + */ + Tone.Abs = function () { + Tone.SignalBase.call(this); + /** + * @type {Tone.LessThan} + * @private + */ + this._abs = this.input = this.output = new Tone.WaveShaper(function (val) { + if (Math.abs(val) < 0.001) { + return 0; + } else { + return Math.abs(val); + } + }, 1024); + }; + Tone.extend(Tone.Abs, Tone.SignalBase); + /** + * dispose method + * @returns {Tone.Abs} this + */ + Tone.Abs.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._abs.dispose(); + this._abs = null; + return this; + }; + return Tone.Abs; + }); + Module(function (Tone) { + + /** + * @class Tone.Follower is a crude envelope follower which will follow + * the amplitude of an incoming signal. + * Take care with small (< 0.02) attack or decay values + * as follower has some ripple which is exaggerated + * at these values. Read more about envelope followers (also known + * as envelope detectors) on [Wikipedia](https://en.wikipedia.org/wiki/Envelope_detector). + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Time|Object} [attack] The rate at which the follower rises. + * @param {Time=} release The rate at which the folower falls. + * @example + * var follower = new Tone.Follower(0.2, 0.4); + */ + Tone.Follower = function () { + var options = Tone.defaults(arguments, [ + 'attack', + 'release' + ], Tone.Follower); + Tone.AudioNode.call(this); + this.createInsOuts(1, 1); + /** + * @type {Tone.Abs} + * @private + */ + this._abs = new Tone.Abs(); + /** + * the lowpass filter which smooths the input + * @type {BiquadFilterNode} + * @private + */ + this._filter = this.context.createBiquadFilter(); + this._filter.type = 'lowpass'; + this._filter.frequency.value = 0; + this._filter.Q.value = -100; + /** + * @type {WaveShaperNode} + * @private + */ + this._frequencyValues = new Tone.WaveShaper(); + /** + * @type {Tone.Subtract} + * @private + */ + this._sub = new Tone.Subtract(); + /** + * @type {Tone.Delay} + * @private + */ + this._delay = new Tone.Delay(this.blockTime); + /** + * this keeps it far from 0, even for very small differences + * @type {Tone.Multiply} + * @private + */ + this._mult = new Tone.Multiply(10000); + /** + * @private + * @type {number} + */ + this._attack = options.attack; + /** + * @private + * @type {number} + */ + this._release = options.release; + //the smoothed signal to get the values + this.input.chain(this._abs, this._filter, this.output); + //the difference path + this._abs.connect(this._sub, 0, 1); + this._filter.chain(this._delay, this._sub); + //threshold the difference and use the thresh to set the frequency + this._sub.chain(this._mult, this._frequencyValues, this._filter.frequency); + //set the attack and release values in the table + this._setAttackRelease(this._attack, this._release); + }; + Tone.extend(Tone.Follower, Tone.AudioNode); + /** + * @static + * @type {Object} + */ + Tone.Follower.defaults = { + 'attack': 0.05, + 'release': 0.5 + }; + /** + * sets the attack and release times in the wave shaper + * @param {Time} attack + * @param {Time} release + * @private + */ + Tone.Follower.prototype._setAttackRelease = function (attack, release) { + var minTime = this.blockTime; + attack = Tone.Time(attack).toFrequency(); + release = Tone.Time(release).toFrequency(); + attack = Math.max(attack, minTime); + release = Math.max(release, minTime); + this._frequencyValues.setMap(function (val) { + if (val <= 0) { + return attack; + } else { + return release; + } + }); + }; + /** + * The attack time. + * @memberOf Tone.Follower# + * @type {Time} + * @name attack + */ + Object.defineProperty(Tone.Follower.prototype, 'attack', { + get: function () { + return this._attack; + }, + set: function (attack) { + this._attack = attack; + this._setAttackRelease(this._attack, this._release); + } + }); + /** + * The release time. + * @memberOf Tone.Follower# + * @type {Time} + * @name release + */ + Object.defineProperty(Tone.Follower.prototype, 'release', { + get: function () { + return this._release; + }, + set: function (release) { + this._release = release; + this._setAttackRelease(this._attack, this._release); + } + }); + /** + * Borrows the connect method from Signal so that the output can be used + * as a Tone.Signal control signal. + * @function + */ + Tone.Follower.prototype.connect = Tone.SignalBase.prototype.connect; + /** + * dispose + * @returns {Tone.Follower} this + */ + Tone.Follower.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._filter.disconnect(); + this._filter = null; + this._frequencyValues.disconnect(); + this._frequencyValues = null; + this._delay.dispose(); + this._delay = null; + this._sub.disconnect(); + this._sub = null; + this._abs.dispose(); + this._abs = null; + this._mult.dispose(); + this._mult = null; + this._curve = null; + return this; + }; + return Tone.Follower; + }); + Module(function (Tone) { + + /** + * @class Tone.ScaledEnvelop is an envelope which can be scaled + * to any range. It's useful for applying an envelope + * to a frequency or any other non-NormalRange signal + * parameter. + * + * @extends {Tone.Envelope} + * @constructor + * @param {Time|Object} [attack] the attack time in seconds + * @param {Time} [decay] the decay time in seconds + * @param {number} [sustain] a percentage (0-1) of the full amplitude + * @param {Time} [release] the release time in seconds + * @example + * var scaledEnv = new Tone.ScaledEnvelope({ + * "attack" : 0.2, + * "min" : 200, + * "max" : 2000 + * }); + * scaledEnv.connect(oscillator.frequency); + */ + Tone.ScaledEnvelope = function () { + //get all of the defaults + var options = Tone.defaults(arguments, [ + 'attack', + 'decay', + 'sustain', + 'release' + ], Tone.Envelope); + Tone.Envelope.call(this, options); + options = Tone.defaultArg(options, Tone.ScaledEnvelope.defaults); + /** + * scale the incoming signal by an exponent + * @type {Tone.Pow} + * @private + */ + this._exp = this.output = new Tone.Pow(options.exponent); + /** + * scale the signal to the desired range + * @type {Tone.Multiply} + * @private + */ + this._scale = this.output = new Tone.Scale(options.min, options.max); + this._sig.chain(this._exp, this._scale); + }; + Tone.extend(Tone.ScaledEnvelope, Tone.Envelope); + /** + * the default parameters + * @static + */ + Tone.ScaledEnvelope.defaults = { + 'min': 0, + 'max': 1, + 'exponent': 1 + }; + /** + * The envelope's min output value. This is the value which it + * starts at. + * @memberOf Tone.ScaledEnvelope# + * @type {number} + * @name min + */ + Object.defineProperty(Tone.ScaledEnvelope.prototype, 'min', { + get: function () { + return this._scale.min; + }, + set: function (min) { + this._scale.min = min; + } + }); + /** + * The envelope's max output value. In other words, the value + * at the peak of the attack portion of the envelope. + * @memberOf Tone.ScaledEnvelope# + * @type {number} + * @name max + */ + Object.defineProperty(Tone.ScaledEnvelope.prototype, 'max', { + get: function () { + return this._scale.max; + }, + set: function (max) { + this._scale.max = max; + } + }); + /** + * The envelope's exponent value. + * @memberOf Tone.ScaledEnvelope# + * @type {number} + * @name exponent + */ + Object.defineProperty(Tone.ScaledEnvelope.prototype, 'exponent', { + get: function () { + return this._exp.value; + }, + set: function (exp) { + this._exp.value = exp; + } + }); + /** + * clean up + * @returns {Tone.ScaledEnvelope} this + */ + Tone.ScaledEnvelope.prototype.dispose = function () { + Tone.Envelope.prototype.dispose.call(this); + this._scale.dispose(); + this._scale = null; + this._exp.dispose(); + this._exp = null; + return this; + }; + return Tone.ScaledEnvelope; + }); + Module(function (Tone) { + + /** + * @class Tone.FrequencyEnvelope is a Tone.ScaledEnvelope, but instead of `min` and `max` + * it's got a `baseFrequency` and `octaves` parameter. + * + * @extends {Tone.Envelope} + * @constructor + * @param {Time|Object} [attack] the attack time in seconds + * @param {Time} [decay] the decay time in seconds + * @param {number} [sustain] a percentage (0-1) of the full amplitude + * @param {Time} [release] the release time in seconds + * @example + * var freqEnv = new Tone.FrequencyEnvelope({ + * "attack" : 0.2, + * "baseFrequency" : "C2", + * "octaves" : 4 + * }); + * freqEnv.connect(oscillator.frequency); + */ + Tone.FrequencyEnvelope = function () { + var options = Tone.defaults(arguments, [ + 'attack', + 'decay', + 'sustain', + 'release' + ], Tone.Envelope); + Tone.ScaledEnvelope.call(this, options); + //merge it with the frequency envelope defaults + options = Tone.defaultArg(options, Tone.FrequencyEnvelope.defaults); + /** + * Stores the octave value + * @type {Positive} + * @private + */ + this._octaves = options.octaves; + //setup + this.baseFrequency = options.baseFrequency; + this.octaves = options.octaves; + }; + Tone.extend(Tone.FrequencyEnvelope, Tone.Envelope); + /** + * the default parameters + * @static + */ + Tone.FrequencyEnvelope.defaults = { + 'baseFrequency': 200, + 'octaves': 4, + 'exponent': 2 + }; + /** + * The envelope's mininum output value. This is the value which it + * starts at. + * @memberOf Tone.FrequencyEnvelope# + * @type {Frequency} + * @name baseFrequency + */ + Object.defineProperty(Tone.FrequencyEnvelope.prototype, 'baseFrequency', { + get: function () { + return this._scale.min; + }, + set: function (min) { + this._scale.min = this.toFrequency(min); + //also update the octaves + this.octaves = this._octaves; + } + }); + /** + * The number of octaves above the baseFrequency that the + * envelope will scale to. + * @memberOf Tone.FrequencyEnvelope# + * @type {Positive} + * @name octaves + */ + Object.defineProperty(Tone.FrequencyEnvelope.prototype, 'octaves', { + get: function () { + return this._octaves; + }, + set: function (octaves) { + this._octaves = octaves; + this._scale.max = this.baseFrequency * Math.pow(2, octaves); + } + }); + /** + * The envelope's exponent value. + * @memberOf Tone.FrequencyEnvelope# + * @type {number} + * @name exponent + */ + Object.defineProperty(Tone.FrequencyEnvelope.prototype, 'exponent', { + get: function () { + return this._exp.value; + }, + set: function (exp) { + this._exp.value = exp; + } + }); + /** + * clean up + * @returns {Tone.FrequencyEnvelope} this + */ + Tone.FrequencyEnvelope.prototype.dispose = function () { + Tone.ScaledEnvelope.prototype.dispose.call(this); + return this; + }; + return Tone.FrequencyEnvelope; + }); + Module(function (Tone) { + + /** + * @class GreaterThanZero outputs 1 when the input is strictly greater than zero + * + * @constructor + * @extends {Tone.SignalBase} + * @example + * var gt0 = new Tone.GreaterThanZero(); + * var sig = new Tone.Signal(0.01).connect(gt0); + * //the output of gt0 is 1. + * sig.value = 0; + * //the output of gt0 is 0. + */ + Tone.GreaterThanZero = function () { + Tone.SignalBase.call(this); + /** + * @type {Tone.WaveShaper} + * @private + */ + this._thresh = this.output = new Tone.WaveShaper(function (val) { + if (val <= 0) { + return 0; + } else { + return 1; + } + }, 127); + /** + * scale the first thresholded signal by a large value. + * this will help with values which are very close to 0 + * @type {Tone.Multiply} + * @private + */ + this._scale = this.input = new Tone.Multiply(10000); + //connections + this._scale.connect(this._thresh); + }; + Tone.extend(Tone.GreaterThanZero, Tone.SignalBase); + /** + * dispose method + * @returns {Tone.GreaterThanZero} this + */ + Tone.GreaterThanZero.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._scale.dispose(); + this._scale = null; + this._thresh.dispose(); + this._thresh = null; + return this; + }; + return Tone.GreaterThanZero; + }); + Module(function (Tone) { + + /** + * @class Output 1 if the signal is greater than the value, otherwise outputs 0. + * can compare two signals or a signal and a number. + * + * @constructor + * @extends {Tone.Signal} + * @param {number} [value=0] the value to compare to the incoming signal + * @example + * var gt = new Tone.GreaterThan(2); + * var sig = new Tone.Signal(4).connect(gt); + * //output of gt is equal 1. + */ + Tone.GreaterThan = function (value) { + Tone.Signal.call(this); + this.createInsOuts(2, 0); + /** + * subtract the amount from the incoming signal + * @type {Tone.Subtract} + * @private + */ + this._param = this.input[0] = new Tone.Subtract(value); + this.input[1] = this._param.input[1]; + /** + * compare that amount to zero + * @type {Tone.GreaterThanZero} + * @private + */ + this._gtz = this.output = new Tone.GreaterThanZero(); + //connect + this._param.connect(this._gtz); + }; + Tone.extend(Tone.GreaterThan, Tone.Signal); + /** + * dispose method + * @returns {Tone.GreaterThan} this + */ + Tone.GreaterThan.prototype.dispose = function () { + Tone.Signal.prototype.dispose.call(this); + this._gtz.dispose(); + this._gtz = null; + return this; + }; + return Tone.GreaterThan; + }); + Module(function (Tone) { + + /** + * @class Tone.Gate only passes a signal through when the incoming + * signal exceeds a specified threshold. To do this, Gate uses + * a Tone.Follower to follow the amplitude of the incoming signal. + * A common implementation of this class is a [Noise Gate](https://en.wikipedia.org/wiki/Noise_gate). + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Decibels|Object} [threshold] The threshold above which the gate will open. + * @param {Time=} attack The follower's attack time + * @param {Time=} release The follower's release time + * @example + * var gate = new Tone.Gate(-30, 0.2, 0.3).toMaster(); + * var mic = new Tone.UserMedia().connect(gate); + * //the gate will only pass through the incoming + * //signal when it's louder than -30db + */ + Tone.Gate = function () { + var options = Tone.defaults(arguments, [ + 'threshold', + 'attack', + 'release' + ], Tone.Gate); + Tone.AudioNode.call(this); + this.createInsOuts(1, 1); + /** + * @type {Tone.Follower} + * @private + */ + this._follower = new Tone.Follower(options.attack, options.release); + /** + * @type {Tone.GreaterThan} + * @private + */ + this._gt = new Tone.GreaterThan(Tone.dbToGain(options.threshold)); + //the connections + this.input.connect(this.output); + //the control signal + this.input.chain(this._gt, this._follower, this.output.gain); + }; + Tone.extend(Tone.Gate, Tone.AudioNode); + /** + * @const + * @static + * @type {Object} + */ + Tone.Gate.defaults = { + 'attack': 0.1, + 'release': 0.1, + 'threshold': -40 + }; + /** + * The threshold of the gate in decibels + * @memberOf Tone.Gate# + * @type {Decibels} + * @name threshold + */ + Object.defineProperty(Tone.Gate.prototype, 'threshold', { + get: function () { + return Tone.gainToDb(this._gt.value); + }, + set: function (thresh) { + this._gt.value = Tone.dbToGain(thresh); + } + }); + /** + * The attack speed of the gate + * @memberOf Tone.Gate# + * @type {Time} + * @name attack + */ + Object.defineProperty(Tone.Gate.prototype, 'attack', { + get: function () { + return this._follower.attack; + }, + set: function (attackTime) { + this._follower.attack = attackTime; + } + }); + /** + * The release speed of the gate + * @memberOf Tone.Gate# + * @type {Time} + * @name release + */ + Object.defineProperty(Tone.Gate.prototype, 'release', { + get: function () { + return this._follower.release; + }, + set: function (releaseTime) { + this._follower.release = releaseTime; + } + }); + /** + * Clean up. + * @returns {Tone.Gate} this + */ + Tone.Gate.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._follower.dispose(); + this._gt.dispose(); + this._follower = null; + this._gt = null; + return this; + }; + return Tone.Gate; + }); + Module(function (Tone) { + /** + * @class Tone.TickSignal extends Tone.Signal, but adds the capability + * to calculate the number of elapsed ticks. exponential and target curves + * are approximated with multiple linear ramps. + * + * Thank you Bruno Dias, H. Sofia Pinto, and David M. Matos, for your [WAC paper](https://smartech.gatech.edu/bitstream/handle/1853/54588/WAC2016-49.pdf) + * describing integrating timing functions for tempo calculations. + * + * @param {Number} value The initial value of the signal + * @extends {Tone.Signal} + */ + Tone.TickSignal = function (value) { + value = Tone.defaultArg(value, 1); + Tone.Signal.call(this, { + 'units': Tone.Type.Ticks, + 'value': value + }); + //extend the memory + this._events.memory = Infinity; + //clear the clock from the beginning + this.cancelScheduledValues(0); + //set an initial event + this._events.add({ + 'type': Tone.Param.AutomationType.SetValue, + 'time': 0, + 'value': value + }); + }; + Tone.extend(Tone.TickSignal, Tone.Signal); + /** + * Wraps Tone.Signal methods so that they also + * record the ticks. + * @param {Function} method + * @return {Function} + * @private + */ + function _wrapScheduleMethods(method) { + return function (value, time) { + time = this.toSeconds(time); + method.apply(this, arguments); + var event = this._events.get(time); + var previousEvent = this._events.previousEvent(event); + var ticksUntilTime = this._getTicksUntilEvent(previousEvent, time); + event.ticks = Math.max(ticksUntilTime, 0); + return this; + }; + } + Tone.TickSignal.prototype.setValueAtTime = _wrapScheduleMethods(Tone.Signal.prototype.setValueAtTime); + Tone.TickSignal.prototype.linearRampToValueAtTime = _wrapScheduleMethods(Tone.Signal.prototype.linearRampToValueAtTime); + /** + * Start exponentially approaching the target value at the given time with + * a rate having the given time constant. + * @param {number} value + * @param {Time} startTime + * @param {number} timeConstant + * @returns {Tone.TickSignal} this + */ + Tone.TickSignal.prototype.setTargetAtTime = function (value, time, constant) { + //aproximate it with multiple linear ramps + time = this.toSeconds(time); + this.setRampPoint(time); + value = this._fromUnits(value); + //start from previously scheduled value + var prevEvent = this._events.get(time); + var segments = Math.round(Math.max(1 / constant, 1)); + for (var i = 0; i <= segments; i++) { + var segTime = constant * i + time; + var rampVal = this._exponentialApproach(prevEvent.time, prevEvent.value, value, constant, segTime); + this.linearRampToValueAtTime(this._toUnits(rampVal), segTime); + } + return this; + }; + /** + * Schedules an exponential continuous change in parameter value from + * the previous scheduled parameter value to the given value. + * @param {number} value + * @param {Time} endTime + * @returns {Tone.TickSignal} this + */ + Tone.TickSignal.prototype.exponentialRampToValueAtTime = function (value, time) { + //aproximate it with multiple linear ramps + time = this.toSeconds(time); + value = this._fromUnits(value); + //start from previously scheduled value + var prevEvent = this._events.get(time); + if (prevEvent === null) { + prevEvent = { + 'value': this._initialValue, + 'time': 0 + }; + } + //approx 10 segments per second + var segments = Math.round(Math.max((time - prevEvent.time) * 10, 1)); + var segmentDur = (time - prevEvent.time) / segments; + for (var i = 0; i <= segments; i++) { + var segTime = segmentDur * i + prevEvent.time; + var rampVal = this._exponentialInterpolate(prevEvent.time, prevEvent.value, time, value, segTime); + this.linearRampToValueAtTime(this._toUnits(rampVal), segTime); + } + return this; + }; + /** + * Returns the tick value at the time. Takes into account + * any automation curves scheduled on the signal. + * @private + * @param {Time} time The time to get the tick count at + * @return {Ticks} The number of ticks which have elapsed at the time + * given any automations. + */ + Tone.TickSignal.prototype._getTicksUntilEvent = function (event, time) { + if (event === null) { + event = { + 'ticks': 0, + 'time': 0 + }; + } else if (Tone.isUndef(event.ticks)) { + var previousEvent = this._events.previousEvent(event); + event.ticks = this._getTicksUntilEvent(previousEvent, event.time); + } + var val0 = this.getValueAtTime(event.time); + var val1 = this.getValueAtTime(time); + //if it's right on the line, take the previous value + if (this._events.get(time).time === time && this._events.get(time).type === Tone.Param.AutomationType.SetValue) { + val1 = this.getValueAtTime(time - this.sampleTime); + } + return 0.5 * (time - event.time) * (val0 + val1) + event.ticks; + }; + /** + * Returns the tick value at the time. Takes into account + * any automation curves scheduled on the signal. + * @param {Time} time The time to get the tick count at + * @return {Ticks} The number of ticks which have elapsed at the time + * given any automations. + */ + Tone.TickSignal.prototype.getTicksAtTime = function (time) { + time = this.toSeconds(time); + var event = this._events.get(time); + return Math.max(this._getTicksUntilEvent(event, time), 0); + }; + /** + * Return the elapsed time of the number of ticks from the given time + * @param {Ticks} ticks The number of ticks to calculate + * @param {Time} time The time to get the next tick from + * @return {Seconds} The duration of the number of ticks from the given time in seconds + */ + Tone.TickSignal.prototype.getDurationOfTicks = function (ticks, time) { + time = this.toSeconds(time); + var currentTick = this.getTicksAtTime(time); + return this.getTimeOfTick(currentTick + ticks) - time; + }; + /** + * Given a tick, returns the time that tick occurs at. + * @param {Ticks} tick + * @return {Time} The time that the tick occurs. + */ + Tone.TickSignal.prototype.getTimeOfTick = function (tick) { + var before = this._events.get(tick, 'ticks'); + var after = this._events.getAfter(tick, 'ticks'); + if (before && before.ticks === tick) { + return before.time; + } else if (before && after && after.type === Tone.Param.AutomationType.Linear && before.value !== after.value) { + var val0 = this.getValueAtTime(before.time); + var val1 = this.getValueAtTime(after.time); + var delta = (val1 - val0) / (after.time - before.time); + var k = Math.sqrt(Math.pow(val0, 2) - 2 * delta * (before.ticks - tick)); + var sol1 = (-val0 + k) / delta; + var sol2 = (-val0 - k) / delta; + return (sol1 > 0 ? sol1 : sol2) + before.time; + } else if (before) { + if (before.value === 0) { + return Infinity; + } else { + return before.time + (tick - before.ticks) / before.value; + } + } else { + return tick / this._initialValue; + } + }; + /** + * Convert some number of ticks their the duration in seconds accounting + * for any automation curves starting at the given time. + * @param {Ticks} ticks The number of ticks to convert to seconds. + * @param {Time} [when=now] When along the automation timeline to convert the ticks. + * @return {Tone.Time} The duration in seconds of the ticks. + */ + Tone.TickSignal.prototype.ticksToTime = function (ticks, when) { + when = this.toSeconds(when); + return new Tone.Time(this.getDurationOfTicks(ticks, when)); + }; + /** + * The inverse of [ticksToTime](#tickstotime). Convert a duration in + * seconds to the corresponding number of ticks accounting for any + * automation curves starting at the given time. + * @param {Time} duration The time interval to convert to ticks. + * @param {Time} [when=now] When along the automation timeline to convert the ticks. + * @return {Tone.Ticks} The duration in ticks. + */ + Tone.TickSignal.prototype.timeToTicks = function (duration, when) { + when = this.toSeconds(when); + duration = this.toSeconds(duration); + var startTicks = this.getTicksAtTime(when); + var endTicks = this.getTicksAtTime(when + duration); + return new Tone.Ticks(endTicks - startTicks); + }; + return Tone.TickSignal; + }); + Module(function (Tone) { + + /** + * @class A Timeline State. Provides the methods: <code>setStateAtTime("state", time)</code> + * and <code>getValueAtTime(time)</code>. + * + * @extends {Tone.Timeline} + * @param {String} initial The initial state of the TimelineState. + * Defaults to <code>undefined</code> + */ + Tone.TimelineState = function (initial) { + Tone.Timeline.call(this); + /** + * The initial state + * @private + * @type {String} + */ + this._initial = initial; + }; + Tone.extend(Tone.TimelineState, Tone.Timeline); + /** + * Returns the scheduled state scheduled before or at + * the given time. + * @param {Number} time The time to query. + * @return {String} The name of the state input in setStateAtTime. + */ + Tone.TimelineState.prototype.getValueAtTime = function (time) { + var event = this.get(time); + if (event !== null) { + return event.state; + } else { + return this._initial; + } + }; + /** + * Add a state to the timeline. + * @param {String} state The name of the state to set. + * @param {Number} time The time to query. + * @returns {Tone.TimelineState} this + */ + Tone.TimelineState.prototype.setStateAtTime = function (state, time) { + //all state changes need to be >= the previous state time + //TODO throw error if time < the previous event time + this.add({ + 'state': state, + 'time': time + }); + return this; + }; + /** + * Return the event before the time with the given state + * @param {Tone.State} state The state to look for + * @param {Time} time When to check before + * @return {Object} The event with the given state before the time + */ + Tone.TimelineState.prototype.getLastState = function (state, time) { + time = this.toSeconds(time); + var index = this._search(time); + for (var i = index; i >= 0; i--) { + var event = this._timeline[i]; + if (event.state === state) { + return event; + } + } + }; + /** + * Return the event after the time with the given state + * @param {Tone.State} state The state to look for + * @param {Time} time When to check from + * @return {Object} The event with the given state after the time + */ + Tone.TimelineState.prototype.getNextState = function (state, time) { + time = this.toSeconds(time); + var index = this._search(time); + if (index !== -1) { + for (var i = index; i < this._timeline.length; i++) { + var event = this._timeline[i]; + if (event.state === state) { + return event; + } + } + } + }; + return Tone.TimelineState; + }); + Module(function (Tone) { + + /** + * @class Uses [Tone.TickSignal](TickSignal) to track elapsed ticks with + * complex automation curves. + * + * @constructor + * @param {Frequency} frequency The initial frequency that the signal ticks at + * @extends {Tone} + */ + Tone.TickSource = function () { + var options = Tone.defaults(arguments, ['frequency'], Tone.TickSource); + /** + * The frequency the callback function should be invoked. + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.TickSignal(options.frequency, Tone.Type.Frequency); + this._readOnly('frequency'); + /** + * The state timeline + * @type {Tone.TimelineState} + * @private + */ + this._state = new Tone.TimelineState(Tone.State.Stopped); + this._state.setStateAtTime(Tone.State.Stopped, 0); + /** + * The offset values of the ticks + * @type {Tone.Timeline} + * @private + */ + this._tickOffset = new Tone.Timeline(); + //add the first event + this.setTicksAtTime(0, 0); + }; + Tone.extend(Tone.TickSource); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.TickSource.defaults = { 'frequency': 1 }; + /** + * Returns the playback state of the source, either "started", "stopped" or "paused". + * @type {Tone.State} + * @readOnly + * @memberOf Tone.TickSource# + * @name state + */ + Object.defineProperty(Tone.TickSource.prototype, 'state', { + get: function () { + return this._state.getValueAtTime(this.now()); + } + }); + /** + * Start the clock at the given time. Optionally pass in an offset + * of where to start the tick counter from. + * @param {Time=} time The time the clock should start + * @param {Ticks=0} offset The number of ticks to start the source at + * @return {Tone.TickSource} this + */ + Tone.TickSource.prototype.start = function (time, offset) { + time = this.toSeconds(time); + if (this._state.getValueAtTime(time) !== Tone.State.Started) { + this._state.setStateAtTime(Tone.State.Started, time); + if (Tone.isDefined(offset)) { + this.setTicksAtTime(offset, time); + } + } + return this; + }; + /** + * Stop the clock. Stopping the clock resets the tick counter to 0. + * @param {Time} [time=now] The time when the clock should stop. + * @returns {Tone.TickSource} this + * @example + * clock.stop(); + */ + Tone.TickSource.prototype.stop = function (time) { + time = this.toSeconds(time); + //cancel the previous stop + if (this._state.getValueAtTime(time) === Tone.State.Stopped) { + var event = this._state.get(time); + if (event.time > 0) { + this._tickOffset.cancel(event.time); + this._state.cancel(event.time); + } + } + this._state.cancel(time); + this._state.setStateAtTime(Tone.State.Stopped, time); + this.setTicksAtTime(0, time); + return this; + }; + /** + * Pause the clock. Pausing does not reset the tick counter. + * @param {Time} [time=now] The time when the clock should stop. + * @returns {Tone.TickSource} this + */ + Tone.TickSource.prototype.pause = function (time) { + time = this.toSeconds(time); + if (this._state.getValueAtTime(time) === Tone.State.Started) { + this._state.setStateAtTime(Tone.State.Paused, time); + } + return this; + }; + /** + * Cancel start/stop/pause and setTickAtTime events scheduled after the given time. + * @param {Time} [time=now] When to clear the events after + * @returns {Tone.TickSource} this + */ + Tone.TickSource.prototype.cancel = function (time) { + time = this.toSeconds(time); + this._state.cancel(time); + this._tickOffset.cancel(time); + return this; + }; + /** + * Get the elapsed ticks at the given time + * @param {Time} time When to get the tick value + * @return {Ticks} The number of ticks + */ + Tone.TickSource.prototype.getTicksAtTime = function (time) { + time = this.toSeconds(time); + var stopEvent = this._state.getLastState(Tone.State.Stopped, time); + //this event allows forEachBetween to iterate until the current time + var tmpEvent = { + state: Tone.State.Paused, + time: time + }; + this._state.add(tmpEvent); + //keep track of the previous offset event + var lastState = stopEvent; + var elapsedTicks = 0; + //iterate through all the events since the last stop + this._state.forEachBetween(stopEvent.time, time + this.sampleTime, function (e) { + var periodStartTime = lastState.time; + //if there is an offset event in this period use that + var offsetEvent = this._tickOffset.get(e.time); + if (offsetEvent.time >= lastState.time) { + elapsedTicks = offsetEvent.ticks; + periodStartTime = offsetEvent.time; + } + if (lastState.state === Tone.State.Started && e.state !== Tone.State.Started) { + elapsedTicks += this.frequency.getTicksAtTime(e.time) - this.frequency.getTicksAtTime(periodStartTime); + } + lastState = e; + }.bind(this)); + //remove the temporary event + this._state.remove(tmpEvent); + //return the ticks + return elapsedTicks; + }; + /** + * The number of times the callback was invoked. Starts counting at 0 + * and increments after the callback was invoked. Returns -1 when stopped. + * @memberOf Tone.TickSource# + * @name ticks + * @type {Ticks} + */ + Object.defineProperty(Tone.TickSource.prototype, 'ticks', { + get: function () { + return this.getTicksAtTime(this.now()); + }, + set: function (t) { + this.setTicksAtTime(t, this.now()); + } + }); + /** + * The time since ticks=0 that the TickSource has been running. Accounts + * for tempo curves + * @memberOf Tone.TickSource# + * @name seconds + * @type {Seconds} + */ + Object.defineProperty(Tone.TickSource.prototype, 'seconds', { + get: function () { + return this.getSecondsAtTime(this.now()); + }, + set: function (s) { + var now = this.now(); + var ticks = this.frequency.timeToTicks(s, now); + this.setTicksAtTime(ticks, now); + } + }); + /** + * Return the elapsed seconds at the given time. + * @param {Time} time When to get the elapsed seconds + * @return {Seconds} The number of elapsed seconds + */ + Tone.TickSource.prototype.getSecondsAtTime = function (time) { + time = this.toSeconds(time); + var stopEvent = this._state.getLastState(Tone.State.Stopped, time); + //this event allows forEachBetween to iterate until the current time + var tmpEvent = { + state: Tone.State.Paused, + time: time + }; + this._state.add(tmpEvent); + //keep track of the previous offset event + var lastState = stopEvent; + var elapsedSeconds = 0; + //iterate through all the events since the last stop + this._state.forEachBetween(stopEvent.time, time + this.sampleTime, function (e) { + var periodStartTime = lastState.time; + //if there is an offset event in this period use that + var offsetEvent = this._tickOffset.get(e.time); + if (offsetEvent.time >= lastState.time) { + elapsedSeconds = offsetEvent.seconds; + periodStartTime = offsetEvent.time; + } + if (lastState.state === Tone.State.Started && e.state !== Tone.State.Started) { + elapsedSeconds += e.time - periodStartTime; + } + lastState = e; + }.bind(this)); + //remove the temporary event + this._state.remove(tmpEvent); + //return the ticks + return elapsedSeconds; + }; + /** + * Set the clock's ticks at the given time. + * @param {Ticks} ticks The tick value to set + * @param {Time} time When to set the tick value + * @return {Tone.TickSource} this + */ + Tone.TickSource.prototype.setTicksAtTime = function (ticks, time) { + time = this.toSeconds(time); + this._tickOffset.cancel(time); + this._tickOffset.add({ + 'time': time, + 'ticks': ticks, + 'seconds': this.frequency.getDurationOfTicks(ticks, time) + }); + return this; + }; + /** + * Returns the scheduled state at the given time. + * @param {Time} time The time to query. + * @return {String} The name of the state input in setStateAtTime. + * @example + * source.start("+0.1"); + * source.getStateAtTime("+0.1"); //returns "started" + */ + Tone.TickSource.prototype.getStateAtTime = function (time) { + time = this.toSeconds(time); + return this._state.getValueAtTime(time); + }; + /** + * Get the time of the given tick. The second argument + * is when to test before. Since ticks can be set (with setTicksAtTime) + * there may be multiple times for a given tick value. + * @param {Ticks} ticks The tick number. + * @param {Time=} before When to measure the tick value from. + * @return {Time} The time of the tick + */ + Tone.TickSource.prototype.getTimeOfTick = function (tick, before) { + before = Tone.defaultArg(before, this.now()); + var offset = this._tickOffset.get(before); + var event = this._state.get(before); + var startTime = Math.max(offset.time, event.time); + var absoluteTicks = this.frequency.getTicksAtTime(startTime) + tick - offset.ticks; + return this.frequency.getTimeOfTick(absoluteTicks); + }; + /** + * Invoke the callback event at all scheduled ticks between the + * start time and the end time + * @param {Time} startTime The beginning of the search range + * @param {Time} endTime The end of the search range + * @param {Function<Time,Ticks>} callback The callback to invoke with each tick + * @return {Tone.TickSource} this + */ + Tone.TickSource.prototype.forEachTickBetween = function (startTime, endTime, callback) { + //only iterate through the sections where it is "started" + var lastStateEvent = this._state.get(startTime); + this._state.forEachBetween(startTime, endTime, function (event) { + if (lastStateEvent.state === Tone.State.Started && event.state !== Tone.State.Started) { + this.forEachTickBetween(Math.max(lastStateEvent.time, startTime), event.time - this.sampleTime, callback); + } + lastStateEvent = event; + }.bind(this)); + startTime = Math.max(lastStateEvent.time, startTime); + if (lastStateEvent.state === Tone.State.Started && this._state) { + //figure out the difference between the frequency ticks and the + var startTicks = this.frequency.getTicksAtTime(startTime); + var ticksAtStart = this.frequency.getTicksAtTime(lastStateEvent.time); + var diff = startTicks - ticksAtStart; + var offset = diff % 1; + if (offset !== 0) { + offset = 1 - offset; + } + var nextTickTime = this.frequency.getTimeOfTick(startTicks + offset); + var error = null; + while (nextTickTime < endTime && this._state) { + try { + callback(nextTickTime, Math.round(this.getTicksAtTime(nextTickTime))); + } catch (e) { + error = e; + break; + } + if (this._state) { + nextTickTime += this.frequency.getDurationOfTicks(1, nextTickTime); + } + } + } + if (error) { + throw error; + } + return this; + }; + /** + * Clean up + * @returns {Tone.TickSource} this + */ + Tone.TickSource.prototype.dispose = function () { + Tone.Param.prototype.dispose.call(this); + this._state.dispose(); + this._state = null; + this._tickOffset.dispose(); + this._tickOffset = null; + this._writable('frequency'); + this.frequency.dispose(); + this.frequency = null; + return this; + }; + return Tone.TickSource; + }); + Module(function (Tone) { + + /** + * @class A sample accurate clock which provides a callback at the given rate. + * While the callback is not sample-accurate (it is still susceptible to + * loose JS timing), the time passed in as the argument to the callback + * is precise. For most applications, it is better to use Tone.Transport + * instead of the Clock by itself since you can synchronize multiple callbacks. + * + * @constructor + * @extends {Tone.Emitter} + * @param {function} callback The callback to be invoked with the time of the audio event + * @param {Frequency} frequency The rate of the callback + * @example + * //the callback will be invoked approximately once a second + * //and will print the time exactly once a second apart. + * var clock = new Tone.Clock(function(time){ + * console.log(time); + * }, 1); + */ + Tone.Clock = function () { + var options = Tone.defaults(arguments, [ + 'callback', + 'frequency' + ], Tone.Clock); + Tone.Emitter.call(this); + /** + * The callback function to invoke at the scheduled tick. + * @type {Function} + */ + this.callback = options.callback; + /** + * The next time the callback is scheduled. + * @type {Number} + * @private + */ + this._nextTick = 0; + /** + * The tick counter + * @type {Tone.TickSource} + * @private + */ + this._tickSource = new Tone.TickSource(options.frequency); + /** + * The last time the loop callback was invoked + * @private + * @type {Number} + */ + this._lastUpdate = 0; + /** + * The rate the callback function should be invoked. + * @type {BPM} + * @signal + */ + this.frequency = this._tickSource.frequency; + this._readOnly('frequency'); + /** + * The state timeline + * @type {Tone.TimelineState} + * @private + */ + this._state = new Tone.TimelineState(Tone.State.Stopped); + //add an initial state + this._state.setStateAtTime(Tone.State.Stopped, 0); + /** + * The loop function bound to its context. + * This is necessary to remove the event in the end. + * @type {Function} + * @private + */ + this._boundLoop = this._loop.bind(this); + //bind a callback to the worker thread + this.context.on('tick', this._boundLoop); + }; + Tone.extend(Tone.Clock, Tone.Emitter); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.Clock.defaults = { + 'callback': Tone.noOp, + 'frequency': 1 + }; + /** + * Returns the playback state of the source, either "started", "stopped" or "paused". + * @type {Tone.State} + * @readOnly + * @memberOf Tone.Clock# + * @name state + */ + Object.defineProperty(Tone.Clock.prototype, 'state', { + get: function () { + return this._state.getValueAtTime(this.now()); + } + }); + /** + * Start the clock at the given time. Optionally pass in an offset + * of where to start the tick counter from. + * @param {Time=} time The time the clock should start + * @param {Ticks=} offset Where the tick counter starts counting from. + * @return {Tone.Clock} this + */ + Tone.Clock.prototype.start = function (time, offset) { + time = this.toSeconds(time); + if (this._state.getValueAtTime(time) !== Tone.State.Started) { + this._state.setStateAtTime(Tone.State.Started, time); + this._tickSource.start(time, offset); + if (time < this._lastUpdate) { + this.emit('start', time, offset); + } + } + return this; + }; + /** + * Stop the clock. Stopping the clock resets the tick counter to 0. + * @param {Time} [time=now] The time when the clock should stop. + * @returns {Tone.Clock} this + * @example + * clock.stop(); + */ + Tone.Clock.prototype.stop = function (time) { + time = this.toSeconds(time); + this._state.cancel(time); + this._state.setStateAtTime(Tone.State.Stopped, time); + this._tickSource.stop(time); + if (time < this._lastUpdate) { + this.emit('stop', time); + } + return this; + }; + /** + * Pause the clock. Pausing does not reset the tick counter. + * @param {Time} [time=now] The time when the clock should stop. + * @returns {Tone.Clock} this + */ + Tone.Clock.prototype.pause = function (time) { + time = this.toSeconds(time); + if (this._state.getValueAtTime(time) === Tone.State.Started) { + this._state.setStateAtTime(Tone.State.Paused, time); + this._tickSource.pause(time); + if (time < this._lastUpdate) { + this.emit('pause', time); + } + } + return this; + }; + /** + * The number of times the callback was invoked. Starts counting at 0 + * and increments after the callback was invoked. + * @type {Ticks} + */ + Object.defineProperty(Tone.Clock.prototype, 'ticks', { + get: function () { + return Math.ceil(this.getTicksAtTime(this.now())); + }, + set: function (t) { + this._tickSource.ticks = t; + } + }); + /** + * The time since ticks=0 that the Clock has been running. Accounts + * for tempo curves + * @type {Seconds} + */ + Object.defineProperty(Tone.Clock.prototype, 'seconds', { + get: function () { + return this._tickSource.seconds; + }, + set: function (s) { + this._tickSource.seconds = s; + } + }); + /** + * Return the elapsed seconds at the given time. + * @param {Time} time When to get the elapsed seconds + * @return {Seconds} The number of elapsed seconds + */ + Tone.Clock.prototype.getSecondsAtTime = function (time) { + return this._tickSource.getSecondsAtTime(time); + }; + /** + * Set the clock's ticks at the given time. + * @param {Ticks} ticks The tick value to set + * @param {Time} time When to set the tick value + * @return {Tone.Clock} this + */ + Tone.Clock.prototype.setTicksAtTime = function (ticks, time) { + this._tickSource.setTicksAtTime(ticks, time); + return this; + }; + /** + * Get the clock's ticks at the given time. + * @param {Time} time When to get the tick value + * @return {Ticks} The tick value at the given time. + */ + Tone.Clock.prototype.getTicksAtTime = function (time) { + return this._tickSource.getTicksAtTime(time); + }; + /** + * Get the time of the next tick + * @param {Ticks} ticks The tick number. + * @param {Time} before + * @return {Tone.Clock} this + */ + Tone.Clock.prototype.nextTickTime = function (offset, when) { + when = this.toSeconds(when); + var currentTick = this.getTicksAtTime(when); + return this._tickSource.getTimeOfTick(currentTick + offset, when); + }; + /** + * The scheduling loop. + * @private + */ + Tone.Clock.prototype._loop = function () { + var startTime = this._lastUpdate; + var endTime = this.now(); + this._lastUpdate = endTime; + if (startTime !== endTime) { + //the state change events + this._state.forEachBetween(startTime, endTime, function (e) { + switch (e.state) { + case Tone.State.Started: + var offset = this._tickSource.getTicksAtTime(e.time); + this.emit('start', e.time, offset); + break; + case Tone.State.Stopped: + if (e.time !== 0) { + this.emit('stop', e.time); + } + break; + case Tone.State.Paused: + this.emit('pause', e.time); + break; + } + }.bind(this)); + //the tick callbacks + this._tickSource.forEachTickBetween(startTime, endTime, function (time, ticks) { + this.callback(time, ticks); + }.bind(this)); + } + }; + /** + * Returns the scheduled state at the given time. + * @param {Time} time The time to query. + * @return {String} The name of the state input in setStateAtTime. + * @example + * clock.start("+0.1"); + * clock.getStateAtTime("+0.1"); //returns "started" + */ + Tone.Clock.prototype.getStateAtTime = function (time) { + time = this.toSeconds(time); + return this._state.getValueAtTime(time); + }; + /** + * Clean up + * @returns {Tone.Clock} this + */ + Tone.Clock.prototype.dispose = function () { + Tone.Emitter.prototype.dispose.call(this); + this.context.off('tick', this._boundLoop); + this._writable('frequency'); + this._tickSource.dispose(); + this._tickSource = null; + this.frequency = null; + this._boundLoop = null; + this._nextTick = Infinity; + this.callback = null; + this._state.dispose(); + this._state = null; + }; + return Tone.Clock; + }); + Module(function (Tone) { + + /** + * @class Similar to Tone.Timeline, but all events represent + * intervals with both "time" and "duration" times. The + * events are placed in a tree structure optimized + * for querying an intersection point with the timeline + * events. Internally uses an [Interval Tree](https://en.wikipedia.org/wiki/Interval_tree) + * to represent the data. + * @extends {Tone} + */ + Tone.IntervalTimeline = function () { + Tone.call(this); + /** + * The root node of the inteval tree + * @type {IntervalNode} + * @private + */ + this._root = null; + /** + * Keep track of the length of the timeline. + * @type {Number} + * @private + */ + this._length = 0; + }; + Tone.extend(Tone.IntervalTimeline); + /** + * The event to add to the timeline. All events must + * have a time and duration value + * @param {Object} event The event to add to the timeline + * @return {Tone.IntervalTimeline} this + */ + Tone.IntervalTimeline.prototype.add = function (event) { + if (Tone.isUndef(event.time) || Tone.isUndef(event.duration)) { + throw new Error('Tone.IntervalTimeline: events must have time and duration parameters'); + } + event.time = event.time.valueOf(); + var node = new IntervalNode(event.time, event.time + event.duration, event); + if (this._root === null) { + this._root = node; + } else { + this._root.insert(node); + } + this._length++; + // Restructure tree to be balanced + while (node !== null) { + node.updateHeight(); + node.updateMax(); + this._rebalance(node); + node = node.parent; + } + return this; + }; + /** + * Remove an event from the timeline. + * @param {Object} event The event to remove from the timeline + * @return {Tone.IntervalTimeline} this + */ + Tone.IntervalTimeline.prototype.remove = function (event) { + if (this._root !== null) { + var results = []; + this._root.search(event.time, results); + for (var i = 0; i < results.length; i++) { + var node = results[i]; + if (node.event === event) { + this._removeNode(node); + this._length--; + break; + } + } + } + return this; + }; + /** + * The number of items in the timeline. + * @type {Number} + * @memberOf Tone.IntervalTimeline# + * @name length + * @readOnly + */ + Object.defineProperty(Tone.IntervalTimeline.prototype, 'length', { + get: function () { + return this._length; + } + }); + /** + * Remove events whose time time is after the given time + * @param {Number} time The time to query. + * @returns {Tone.IntervalTimeline} this + */ + Tone.IntervalTimeline.prototype.cancel = function (after) { + this.forEachFrom(after, function (event) { + this.remove(event); + }.bind(this)); + return this; + }; + /** + * Set the root node as the given node + * @param {IntervalNode} node + * @private + */ + Tone.IntervalTimeline.prototype._setRoot = function (node) { + this._root = node; + if (this._root !== null) { + this._root.parent = null; + } + }; + /** + * Replace the references to the node in the node's parent + * with the replacement node. + * @param {IntervalNode} node + * @param {IntervalNode} replacement + * @private + */ + Tone.IntervalTimeline.prototype._replaceNodeInParent = function (node, replacement) { + if (node.parent !== null) { + if (node.isLeftChild()) { + node.parent.left = replacement; + } else { + node.parent.right = replacement; + } + this._rebalance(node.parent); + } else { + this._setRoot(replacement); + } + }; + /** + * Remove the node from the tree and replace it with + * a successor which follows the schema. + * @param {IntervalNode} node + * @private + */ + Tone.IntervalTimeline.prototype._removeNode = function (node) { + if (node.left === null && node.right === null) { + this._replaceNodeInParent(node, null); + } else if (node.right === null) { + this._replaceNodeInParent(node, node.left); + } else if (node.left === null) { + this._replaceNodeInParent(node, node.right); + } else { + var balance = node.getBalance(); + var replacement, temp; + if (balance > 0) { + if (node.left.right === null) { + replacement = node.left; + replacement.right = node.right; + temp = replacement; + } else { + replacement = node.left.right; + while (replacement.right !== null) { + replacement = replacement.right; + } + replacement.parent.right = replacement.left; + temp = replacement.parent; + replacement.left = node.left; + replacement.right = node.right; + } + } else if (node.right.left === null) { + replacement = node.right; + replacement.left = node.left; + temp = replacement; + } else { + replacement = node.right.left; + while (replacement.left !== null) { + replacement = replacement.left; + } + replacement.parent = replacement.parent; + replacement.parent.left = replacement.right; + temp = replacement.parent; + replacement.left = node.left; + replacement.right = node.right; + } + if (node.parent !== null) { + if (node.isLeftChild()) { + node.parent.left = replacement; + } else { + node.parent.right = replacement; + } + } else { + this._setRoot(replacement); + } + // this._replaceNodeInParent(node, replacement); + this._rebalance(temp); + } + node.dispose(); + }; + /** + * Rotate the tree to the left + * @param {IntervalNode} node + * @private + */ + Tone.IntervalTimeline.prototype._rotateLeft = function (node) { + var parent = node.parent; + var isLeftChild = node.isLeftChild(); + // Make node.right the new root of this sub tree (instead of node) + var pivotNode = node.right; + node.right = pivotNode.left; + pivotNode.left = node; + if (parent !== null) { + if (isLeftChild) { + parent.left = pivotNode; + } else { + parent.right = pivotNode; + } + } else { + this._setRoot(pivotNode); + } + }; + /** + * Rotate the tree to the right + * @param {IntervalNode} node + * @private + */ + Tone.IntervalTimeline.prototype._rotateRight = function (node) { + var parent = node.parent; + var isLeftChild = node.isLeftChild(); + // Make node.left the new root of this sub tree (instead of node) + var pivotNode = node.left; + node.left = pivotNode.right; + pivotNode.right = node; + if (parent !== null) { + if (isLeftChild) { + parent.left = pivotNode; + } else { + parent.right = pivotNode; + } + } else { + this._setRoot(pivotNode); + } + }; + /** + * Balance the BST + * @param {IntervalNode} node + * @private + */ + Tone.IntervalTimeline.prototype._rebalance = function (node) { + var balance = node.getBalance(); + if (balance > 1) { + if (node.left.getBalance() < 0) { + this._rotateLeft(node.left); + } else { + this._rotateRight(node); + } + } else if (balance < -1) { + if (node.right.getBalance() > 0) { + this._rotateRight(node.right); + } else { + this._rotateLeft(node); + } + } + }; + /** + * Get an event whose time and duration span the give time. Will + * return the match whose "time" value is closest to the given time. + * @param {Object} event The event to add to the timeline + * @return {Object} The event which spans the desired time + */ + Tone.IntervalTimeline.prototype.get = function (time) { + if (this._root !== null) { + var results = []; + this._root.search(time, results); + if (results.length > 0) { + var max = results[0]; + for (var i = 1; i < results.length; i++) { + if (results[i].low > max.low) { + max = results[i]; + } + } + return max.event; + } + } + return null; + }; + /** + * Iterate over everything in the timeline. + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.IntervalTimeline} this + */ + Tone.IntervalTimeline.prototype.forEach = function (callback) { + if (this._root !== null) { + var allNodes = []; + this._root.traverse(function (node) { + allNodes.push(node); + }); + for (var i = 0; i < allNodes.length; i++) { + var ev = allNodes[i].event; + if (ev) { + callback(ev); + } + } + } + return this; + }; + /** + * Iterate over everything in the array in which the given time + * overlaps with the time and duration time of the event. + * @param {Number} time The time to check if items are overlapping + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.IntervalTimeline} this + */ + Tone.IntervalTimeline.prototype.forEachAtTime = function (time, callback) { + if (this._root !== null) { + var results = []; + this._root.search(time, results); + for (var i = results.length - 1; i >= 0; i--) { + var ev = results[i].event; + if (ev) { + callback(ev); + } + } + } + return this; + }; + /** + * Iterate over everything in the array in which the time is greater + * than or equal to the given time. + * @param {Number} time The time to check if items are before + * @param {Function} callback The callback to invoke with every item + * @returns {Tone.IntervalTimeline} this + */ + Tone.IntervalTimeline.prototype.forEachFrom = function (time, callback) { + if (this._root !== null) { + var results = []; + this._root.searchAfter(time, results); + for (var i = results.length - 1; i >= 0; i--) { + var ev = results[i].event; + callback(ev); + } + } + return this; + }; + /** + * Clean up + * @return {Tone.IntervalTimeline} this + */ + Tone.IntervalTimeline.prototype.dispose = function () { + var allNodes = []; + if (this._root !== null) { + this._root.traverse(function (node) { + allNodes.push(node); + }); + } + for (var i = 0; i < allNodes.length; i++) { + allNodes[i].dispose(); + } + allNodes = null; + this._root = null; + return this; + }; + /////////////////////////////////////////////////////////////////////////// + // INTERVAL NODE HELPER + /////////////////////////////////////////////////////////////////////////// + /** + * Represents a node in the binary search tree, with the addition + * of a "high" value which keeps track of the highest value of + * its children. + * References: + * https://brooknovak.wordpress.com/2013/12/07/augmented-interval-tree-in-c/ + * http://www.mif.vu.lt/~valdas/ALGORITMAI/LITERATURA/Cormen/Cormen.pdf + * @param {Number} low + * @param {Number} high + * @private + */ + var IntervalNode = function (low, high, event) { + //the event container + this.event = event; + //the low value + this.low = low; + //the high value + this.high = high; + //the high value for this and all child nodes + this.max = this.high; + //the nodes to the left + this._left = null; + //the nodes to the right + this._right = null; + //the parent node + this.parent = null; + //the number of child nodes + this.height = 0; + }; + /** + * Insert a node into the correct spot in the tree + * @param {IntervalNode} node + */ + IntervalNode.prototype.insert = function (node) { + if (node.low <= this.low) { + if (this.left === null) { + this.left = node; + } else { + this.left.insert(node); + } + } else if (this.right === null) { + this.right = node; + } else { + this.right.insert(node); + } + }; + /** + * Search the tree for nodes which overlap + * with the given point + * @param {Number} point The point to query + * @param {Array} results The array to put the results + */ + IntervalNode.prototype.search = function (point, results) { + // If p is to the right of the rightmost point of any interval + // in this node and all children, there won't be any matches. + if (point > this.max) { + return; + } + // Search left children + if (this.left !== null) { + this.left.search(point, results); + } + // Check this node + if (this.low <= point && this.high > point) { + results.push(this); + } + // If p is to the left of the time of this interval, + // then it can't be in any child to the right. + if (this.low > point) { + return; + } + // Search right children + if (this.right !== null) { + this.right.search(point, results); + } + }; + /** + * Search the tree for nodes which are less + * than the given point + * @param {Number} point The point to query + * @param {Array} results The array to put the results + */ + IntervalNode.prototype.searchAfter = function (point, results) { + // Check this node + if (this.low >= point) { + results.push(this); + if (this.left !== null) { + this.left.searchAfter(point, results); + } + } + // search the right side + if (this.right !== null) { + this.right.searchAfter(point, results); + } + }; + /** + * Invoke the callback on this element and both it's branches + * @param {Function} callback + */ + IntervalNode.prototype.traverse = function (callback) { + callback(this); + if (this.left !== null) { + this.left.traverse(callback); + } + if (this.right !== null) { + this.right.traverse(callback); + } + }; + /** + * Update the height of the node + */ + IntervalNode.prototype.updateHeight = function () { + if (this.left !== null && this.right !== null) { + this.height = Math.max(this.left.height, this.right.height) + 1; + } else if (this.right !== null) { + this.height = this.right.height + 1; + } else if (this.left !== null) { + this.height = this.left.height + 1; + } else { + this.height = 0; + } + }; + /** + * Update the height of the node + */ + IntervalNode.prototype.updateMax = function () { + this.max = this.high; + if (this.left !== null) { + this.max = Math.max(this.max, this.left.max); + } + if (this.right !== null) { + this.max = Math.max(this.max, this.right.max); + } + }; + /** + * The balance is how the leafs are distributed on the node + * @return {Number} Negative numbers are balanced to the right + */ + IntervalNode.prototype.getBalance = function () { + var balance = 0; + if (this.left !== null && this.right !== null) { + balance = this.left.height - this.right.height; + } else if (this.left !== null) { + balance = this.left.height + 1; + } else if (this.right !== null) { + balance = -(this.right.height + 1); + } + return balance; + }; + /** + * @returns {Boolean} true if this node is the left child + * of its parent + */ + IntervalNode.prototype.isLeftChild = function () { + return this.parent !== null && this.parent.left === this; + }; + /** + * get/set the left node + * @type {IntervalNode} + */ + Object.defineProperty(IntervalNode.prototype, 'left', { + get: function () { + return this._left; + }, + set: function (node) { + this._left = node; + if (node !== null) { + node.parent = this; + } + this.updateHeight(); + this.updateMax(); + } + }); + /** + * get/set the right node + * @type {IntervalNode} + */ + Object.defineProperty(IntervalNode.prototype, 'right', { + get: function () { + return this._right; + }, + set: function (node) { + this._right = node; + if (node !== null) { + node.parent = this; + } + this.updateHeight(); + this.updateMax(); + } + }); + /** + * null out references. + */ + IntervalNode.prototype.dispose = function () { + this.parent = null; + this._left = null; + this._right = null; + this.event = null; + }; + /////////////////////////////////////////////////////////////////////////// + // END INTERVAL NODE HELPER + /////////////////////////////////////////////////////////////////////////// + return Tone.IntervalTimeline; + }); + Module(function (Tone) { + /** + * @class Tone.Ticks is a primitive type for encoding Time values. + * Tone.Ticks can be constructed with or without the `new` keyword. Tone.Ticks can be passed + * into the parameter of any method which takes time as an argument. + * @constructor + * @extends {Tone.TransportTime} + * @param {String|Number} val The time value. + * @param {String=} units The units of the value. + * @example + * var t = Tone.Ticks("4n");//a quarter note + */ + Tone.Ticks = function (val, units) { + if (this instanceof Tone.Ticks) { + Tone.TransportTime.call(this, val, units); + } else { + return new Tone.Ticks(val, units); + } + }; + Tone.extend(Tone.Ticks, Tone.TransportTime); + /** + * The default units if none are given. + * @type {String} + * @private + */ + Tone.Ticks.prototype._defaultUnits = 'i'; + /** + * Get the current time in the given units + * @return {Ticks} + * @private + */ + Tone.Ticks.prototype._now = function () { + return Tone.Transport.ticks; + }; + /** + * Return the value of the beats in the current units + * @param {Number} beats + * @return {Number} + * @private + */ + Tone.Ticks.prototype._beatsToUnits = function (beats) { + return this._getPPQ() * beats; + }; + /** + * Returns the value of a second in the current units + * @param {Seconds} seconds + * @return {Number} + * @private + */ + Tone.Ticks.prototype._secondsToUnits = function (seconds) { + return seconds / (60 / this._getBpm()) * this._getPPQ(); + }; + /** + * Returns the value of a tick in the current time units + * @param {Ticks} ticks + * @return {Number} + * @private + */ + Tone.Ticks.prototype._ticksToUnits = function (ticks) { + return ticks; + }; + /** + * Return the time in ticks + * @return {Ticks} + */ + Tone.Ticks.prototype.toTicks = function () { + return this.valueOf(); + }; + /** + * Return the time in ticks + * @return {Ticks} + */ + Tone.Ticks.prototype.toSeconds = function () { + return this.valueOf() / this._getPPQ() * (60 / this._getBpm()); + }; + return Tone.Ticks; + }); + Module(function (Tone) { + /** + * @class Tone.TransportEvent is an internal class used by (Tone.Transport)[Transport] + * to schedule events. Do no invoke this class directly, it is + * handled from within Tone.Transport. + * @extends {Tone} + * @param {Object} options + */ + Tone.TransportEvent = function (Transport, options) { + options = Tone.defaultArg(options, Tone.TransportEvent.defaults); + Tone.call(this); + /** + * Reference to the Transport that created it + * @type {Tone.Transport} + */ + this.Transport = Transport; + /** + * The unique id of the event + * @type {Number} + */ + this.id = Tone.TransportEvent._eventId++; + /** + * The time the event starts + * @type {Ticks} + */ + this.time = Tone.Ticks(options.time); + /** + * The callback to invoke + * @type {Function} + */ + this.callback = options.callback; + /** + * If the event should be removed after being created. + * @type {Boolean} + * @private + */ + this._once = options.once; + }; + Tone.extend(Tone.TransportEvent); + /** + * The defaults + * @static + * @type {Object} + */ + Tone.TransportEvent.defaults = { + 'once': false, + 'callback': Tone.noOp + }; + /** + * Current ID counter + * @private + * @static + * @type {Number} + */ + Tone.TransportEvent._eventId = 0; + /** + * Invoke the event callback. + * @param {Time} time The AudioContext time in seconds of the event + */ + Tone.TransportEvent.prototype.invoke = function (time) { + if (this.callback) { + this.callback(time); + if (this._once && this.Transport) { + this.Transport.clear(this.id); + } + } + }; + /** + * Clean up + * @return {Tone.TransportEvent} this + */ + Tone.TransportEvent.prototype.dispose = function () { + Tone.prototype.dispose.call(this); + this.Transport = null; + this.callback = null; + this.time = null; + return this; + }; + return Tone.TransportEvent; + }); + Module(function (Tone) { + /** + * @class Tone.TransportRepeatEvent is an internal class used by Tone.Transport + * to schedule repeat events. This class should not be instantiated directly. + * @extends {Tone.TransportEvent} + * @param {Object} options + */ + Tone.TransportRepeatEvent = function (Transport, options) { + Tone.TransportEvent.call(this, Transport, options); + options = Tone.defaultArg(options, Tone.TransportRepeatEvent.defaults); + /** + * When the event should stop repeating + * @type {Ticks} + * @private + */ + this.duration = Tone.Ticks(options.duration); + /** + * The interval of the repeated event + * @type {Ticks} + * @private + */ + this._interval = Tone.Ticks(options.interval); + /** + * The ID of the current timeline event + * @type {Number} + * @private + */ + this._currentId = -1; + /** + * The ID of the next timeline event + * @type {Number} + * @private + */ + this._nextId = -1; + /** + * The time of the next event + * @type {Ticks} + * @private + */ + this._nextTick = this.time; + /** + * a reference to the bound start method + * @type {Function} + * @private + */ + this._boundRestart = this._restart.bind(this); + this.Transport.on('start loopStart', this._boundRestart); + this._restart(); + }; + Tone.extend(Tone.TransportRepeatEvent, Tone.TransportEvent); + /** + * The defaults + * @static + * @type {Object} + */ + Tone.TransportRepeatEvent.defaults = { + 'duration': Infinity, + 'interval': 1 + }; + /** + * Invoke the callback. Returns the tick time which + * the next event should be scheduled at. + * @param {Number} time The AudioContext time in seconds of the event + */ + Tone.TransportRepeatEvent.prototype.invoke = function (time) { + //create more events if necessary + this._createEvents(time); + //call the super class + Tone.TransportEvent.prototype.invoke.call(this, time); + }; + /** + * Push more events onto the timeline to keep up with the position of the timeline + * @private + */ + Tone.TransportRepeatEvent.prototype._createEvents = function (time) { + // schedule the next event + var ticks = this.Transport.getTicksAtTime(time); + if (ticks >= this.time && ticks >= this._nextTick && this._nextTick + this._interval < this.time + this.duration) { + this._nextTick += this._interval; + this._currentId = this._nextId; + this._nextId = this.Transport.scheduleOnce(this.invoke.bind(this), Tone.Ticks(this._nextTick)); + } + }; + /** + * Push more events onto the timeline to keep up with the position of the timeline + * @private + */ + Tone.TransportRepeatEvent.prototype._restart = function (time) { + this.Transport.clear(this._currentId); + this.Transport.clear(this._nextId); + this._nextTick = this.time; + var ticks = this.Transport.getTicksAtTime(time); + if (ticks > this.time) { + this._nextTick = this.time + Math.ceil((ticks - this.time) / this._interval) * this._interval; + } + this._currentId = this.Transport.scheduleOnce(this.invoke.bind(this), Tone.Ticks(this._nextTick)); + this._nextTick += this._interval; + this._nextId = this.Transport.scheduleOnce(this.invoke.bind(this), Tone.Ticks(this._nextTick)); + }; + /** + * Clean up + * @return {Tone.TransportRepeatEvent} this + */ + Tone.TransportRepeatEvent.prototype.dispose = function () { + this.Transport.clear(this._currentId); + this.Transport.clear(this._nextId); + this.Transport.off('start loopStart', this._boundRestart); + this._boundCreateEvents = null; + Tone.TransportEvent.prototype.dispose.call(this); + this.duration = null; + this._interval = null; + return this; + }; + return Tone.TransportRepeatEvent; + }); + Module(function (Tone) { + + /** + * @class Transport for timing musical events. + * Supports tempo curves and time changes. Unlike browser-based timing (setInterval, requestAnimationFrame) + * Tone.Transport timing events pass in the exact time of the scheduled event + * in the argument of the callback function. Pass that time value to the object + * you're scheduling. <br><br> + * A single transport is created for you when the library is initialized. + * <br><br> + * The transport emits the events: "start", "stop", "pause", and "loop" which are + * called with the time of that event as the argument. + * + * @extends {Tone.Emitter} + * @singleton + * @example + * //repeated event every 8th note + * Tone.Transport.scheduleRepeat(function(time){ + * //do something with the time + * }, "8n"); + * @example + * //schedule an event on the 16th measure + * Tone.Transport.schedule(function(time){ + * //do something with the time + * }, "16:0:0"); + */ + Tone.Transport = function () { + Tone.Emitter.call(this); + Tone.getContext(function () { + /////////////////////////////////////////////////////////////////////// + // LOOPING + ////////////////////////////////////////////////////////////////////// + /** + * If the transport loops or not. + * @type {boolean} + */ + this.loop = false; + /** + * The loop start position in ticks + * @type {Ticks} + * @private + */ + this._loopStart = 0; + /** + * The loop end position in ticks + * @type {Ticks} + * @private + */ + this._loopEnd = 0; + /////////////////////////////////////////////////////////////////////// + // CLOCK/TEMPO + ////////////////////////////////////////////////////////////////////// + /** + * Pulses per quarter is the number of ticks per quarter note. + * @private + * @type {Number} + */ + this._ppq = TransportConstructor.defaults.PPQ; + /** + * watches the main oscillator for timing ticks + * initially starts at 120bpm + * @private + * @type {Tone.Clock} + */ + this._clock = new Tone.Clock({ + 'callback': this._processTick.bind(this), + 'frequency': 0 + }); + this._bindClockEvents(); + /** + * The Beats Per Minute of the Transport. + * @type {BPM} + * @signal + * @example + * Tone.Transport.bpm.value = 80; + * //ramp the bpm to 120 over 10 seconds + * Tone.Transport.bpm.rampTo(120, 10); + */ + this.bpm = this._clock.frequency; + this.bpm._toUnits = this._toUnits.bind(this); + this.bpm._fromUnits = this._fromUnits.bind(this); + this.bpm.units = Tone.Type.BPM; + this.bpm.value = TransportConstructor.defaults.bpm; + this._readOnly('bpm'); + /** + * The time signature, or more accurately the numerator + * of the time signature over a denominator of 4. + * @type {Number} + * @private + */ + this._timeSignature = TransportConstructor.defaults.timeSignature; + /////////////////////////////////////////////////////////////////////// + // TIMELINE EVENTS + ////////////////////////////////////////////////////////////////////// + /** + * All the events in an object to keep track by ID + * @type {Object} + * @private + */ + this._scheduledEvents = {}; + /** + * The scheduled events. + * @type {Tone.Timeline} + * @private + */ + this._timeline = new Tone.Timeline(); + /** + * Repeated events + * @type {Array} + * @private + */ + this._repeatedEvents = new Tone.IntervalTimeline(); + /** + * All of the synced Signals + * @private + * @type {Array} + */ + this._syncedSignals = []; + /////////////////////////////////////////////////////////////////////// + // SWING + ////////////////////////////////////////////////////////////////////// + /** + * The subdivision of the swing + * @type {Ticks} + * @private + */ + this._swingTicks = TransportConstructor.defaults.PPQ / 2; + //8n + /** + * The swing amount + * @type {NormalRange} + * @private + */ + this._swingAmount = 0; + }.bind(this)); + }; + Tone.extend(Tone.Transport, Tone.Emitter); + /** + * the defaults + * @type {Object} + * @const + * @static + */ + Tone.Transport.defaults = { + 'bpm': 120, + 'swing': 0, + 'swingSubdivision': '8n', + 'timeSignature': 4, + 'loopStart': 0, + 'loopEnd': '4m', + 'PPQ': 192 + }; + /////////////////////////////////////////////////////////////////////////////// + // TICKS + /////////////////////////////////////////////////////////////////////////////// + /** + * called on every tick + * @param {number} tickTime clock relative tick time + * @private + */ + Tone.Transport.prototype._processTick = function (tickTime, ticks) { + //handle swing + if (this._swingAmount > 0 && ticks % this._ppq !== 0 && //not on a downbeat + ticks % (this._swingTicks * 2) !== 0) { + //add some swing + var progress = ticks % (this._swingTicks * 2) / (this._swingTicks * 2); + var amount = Math.sin(progress * Math.PI) * this._swingAmount; + tickTime += Tone.Ticks(this._swingTicks * 2 / 3).toSeconds() * amount; + } + //do the loop test + if (this.loop) { + if (ticks >= this._loopEnd) { + this.emit('loopEnd', tickTime); + this._clock.setTicksAtTime(this._loopStart, tickTime); + ticks = this._loopStart; + this.emit('loopStart', tickTime, this._clock.getSecondsAtTime(tickTime)); + this.emit('loop', tickTime); + } + } + //invoke the timeline events scheduled on this tick + this._timeline.forEachAtTime(ticks, function (event) { + event.invoke(tickTime); + }); + }; + /////////////////////////////////////////////////////////////////////////////// + // SCHEDULABLE EVENTS + /////////////////////////////////////////////////////////////////////////////// + /** + * Schedule an event along the timeline. + * @param {Function} callback The callback to be invoked at the time. + * @param {TransportTime} time The time to invoke the callback at. + * @return {Number} The id of the event which can be used for canceling the event. + * @example + * //trigger the callback when the Transport reaches the desired time + * Tone.Transport.schedule(function(time){ + * envelope.triggerAttack(time); + * }, "128i"); + */ + Tone.Transport.prototype.schedule = function (callback, time) { + var event = new Tone.TransportEvent(this, { + 'time': Tone.TransportTime(time), + 'callback': callback + }); + return this._addEvent(event, this._timeline); + }; + /** + * Schedule a repeated event along the timeline. The event will fire + * at the `interval` starting at the `startTime` and for the specified + * `duration`. + * @param {Function} callback The callback to invoke. + * @param {Time} interval The duration between successive + * callbacks. Must be a positive number. + * @param {TransportTime=} startTime When along the timeline the events should + * start being invoked. + * @param {Time} [duration=Infinity] How long the event should repeat. + * @return {Number} The ID of the scheduled event. Use this to cancel + * the event. + * @example + * //a callback invoked every eighth note after the first measure + * Tone.Transport.scheduleRepeat(callback, "8n", "1m"); + */ + Tone.Transport.prototype.scheduleRepeat = function (callback, interval, startTime, duration) { + var event = new Tone.TransportRepeatEvent(this, { + 'callback': callback, + 'interval': Tone.Time(interval), + 'time': Tone.TransportTime(startTime), + 'duration': Tone.Time(Tone.defaultArg(duration, Infinity)) + }); + //kick it off if the Transport is started + return this._addEvent(event, this._repeatedEvents); + }; + /** + * Schedule an event that will be removed after it is invoked. + * Note that if the given time is less than the current transport time, + * the event will be invoked immediately. + * @param {Function} callback The callback to invoke once. + * @param {TransportTime} time The time the callback should be invoked. + * @returns {Number} The ID of the scheduled event. + */ + Tone.Transport.prototype.scheduleOnce = function (callback, time) { + var event = new Tone.TransportEvent(this, { + 'time': Tone.TransportTime(time), + 'callback': callback, + 'once': true + }); + return this._addEvent(event, this._timeline); + }; + /** + * Clear the passed in event id from the timeline + * @param {Number} eventId The id of the event. + * @returns {Tone.Transport} this + */ + Tone.Transport.prototype.clear = function (eventId) { + if (this._scheduledEvents.hasOwnProperty(eventId)) { + var item = this._scheduledEvents[eventId.toString()]; + item.timeline.remove(item.event); + item.event.dispose(); + delete this._scheduledEvents[eventId.toString()]; + } + return this; + }; + /** + * Add an event to the correct timeline. Keep track of the + * timeline it was added to. + * @param {Tone.TransportEvent} event + * @param {Tone.Timeline} timeline + * @returns {Number} the event id which was just added + * @private + */ + Tone.Transport.prototype._addEvent = function (event, timeline) { + this._scheduledEvents[event.id.toString()] = { + 'event': event, + 'timeline': timeline + }; + timeline.add(event); + return event.id; + }; + /** + * Remove scheduled events from the timeline after + * the given time. Repeated events will be removed + * if their startTime is after the given time + * @param {TransportTime} [after=0] Clear all events after + * this time. + * @returns {Tone.Transport} this + */ + Tone.Transport.prototype.cancel = function (after) { + after = Tone.defaultArg(after, 0); + after = this.toTicks(after); + this._timeline.forEachFrom(after, function (event) { + this.clear(event.id); + }.bind(this)); + this._repeatedEvents.forEachFrom(after, function (event) { + this.clear(event.id); + }.bind(this)); + return this; + }; + /////////////////////////////////////////////////////////////////////////////// + // START/STOP/PAUSE + /////////////////////////////////////////////////////////////////////////////// + /** + * Bind start/stop/pause events from the clock and emit them. + * @private + */ + Tone.Transport.prototype._bindClockEvents = function () { + this._clock.on('start', function (time, offset) { + offset = Tone.Ticks(offset).toSeconds(); + this.emit('start', time, offset); + }.bind(this)); + this._clock.on('stop', function (time) { + this.emit('stop', time); + }.bind(this)); + this._clock.on('pause', function (time) { + this.emit('pause', time); + }.bind(this)); + }; + /** + * Returns the playback state of the source, either "started", "stopped", or "paused" + * @type {Tone.State} + * @readOnly + * @memberOf Tone.Transport# + * @name state + */ + Object.defineProperty(Tone.Transport.prototype, 'state', { + get: function () { + return this._clock.getStateAtTime(this.now()); + } + }); + /** + * Start the transport and all sources synced to the transport. + * @param {Time} [time=now] The time when the transport should start. + * @param {TransportTime=} offset The timeline offset to start the transport. + * @returns {Tone.Transport} this + * @example + * //start the transport in one second starting at beginning of the 5th measure. + * Tone.Transport.start("+1", "4:0:0"); + */ + Tone.Transport.prototype.start = function (time, offset) { + //start the clock + if (Tone.isDefined(offset)) { + offset = this.toTicks(offset); + } + this._clock.start(time, offset); + return this; + }; + /** + * Stop the transport and all sources synced to the transport. + * @param {Time} [time=now] The time when the transport should stop. + * @returns {Tone.Transport} this + * @example + * Tone.Transport.stop(); + */ + Tone.Transport.prototype.stop = function (time) { + this._clock.stop(time); + return this; + }; + /** + * Pause the transport and all sources synced to the transport. + * @param {Time} [time=now] + * @returns {Tone.Transport} this + */ + Tone.Transport.prototype.pause = function (time) { + this._clock.pause(time); + return this; + }; + /** + * Toggle the current state of the transport. If it is + * started, it will stop it, otherwise it will start the Transport. + * @param {Time=} time The time of the event + * @return {Tone.Transport} this + */ + Tone.Transport.prototype.toggle = function (time) { + time = this.toSeconds(time); + if (this._clock.getStateAtTime(time) !== Tone.State.Started) { + this.start(time); + } else { + this.stop(time); + } + return this; + }; + /////////////////////////////////////////////////////////////////////////////// + // SETTERS/GETTERS + /////////////////////////////////////////////////////////////////////////////// + /** + * The time signature as just the numerator over 4. + * For example 4/4 would be just 4 and 6/8 would be 3. + * @memberOf Tone.Transport# + * @type {Number|Array} + * @name timeSignature + * @example + * //common time + * Tone.Transport.timeSignature = 4; + * // 7/8 + * Tone.Transport.timeSignature = [7, 8]; + * //this will be reduced to a single number + * Tone.Transport.timeSignature; //returns 3.5 + */ + Object.defineProperty(Tone.Transport.prototype, 'timeSignature', { + get: function () { + return this._timeSignature; + }, + set: function (timeSig) { + if (Tone.isArray(timeSig)) { + timeSig = timeSig[0] / timeSig[1] * 4; + } + this._timeSignature = timeSig; + } + }); + /** + * When the Tone.Transport.loop = true, this is the starting position of the loop. + * @memberOf Tone.Transport# + * @type {Time} + * @name loopStart + */ + Object.defineProperty(Tone.Transport.prototype, 'loopStart', { + get: function () { + return Tone.Ticks(this._loopStart).toSeconds(); + }, + set: function (startPosition) { + this._loopStart = this.toTicks(startPosition); + } + }); + /** + * When the Tone.Transport.loop = true, this is the ending position of the loop. + * @memberOf Tone.Transport# + * @type {Time} + * @name loopEnd + */ + Object.defineProperty(Tone.Transport.prototype, 'loopEnd', { + get: function () { + return Tone.Ticks(this._loopEnd).toSeconds(); + }, + set: function (endPosition) { + this._loopEnd = this.toTicks(endPosition); + } + }); + /** + * Set the loop start and stop at the same time. + * @param {TransportTime} startPosition + * @param {TransportTime} endPosition + * @returns {Tone.Transport} this + * @example + * //loop over the first measure + * Tone.Transport.setLoopPoints(0, "1m"); + * Tone.Transport.loop = true; + */ + Tone.Transport.prototype.setLoopPoints = function (startPosition, endPosition) { + this.loopStart = startPosition; + this.loopEnd = endPosition; + return this; + }; + /** + * The swing value. Between 0-1 where 1 equal to + * the note + half the subdivision. + * @memberOf Tone.Transport# + * @type {NormalRange} + * @name swing + */ + Object.defineProperty(Tone.Transport.prototype, 'swing', { + get: function () { + return this._swingAmount; + }, + set: function (amount) { + //scale the values to a normal range + this._swingAmount = amount; + } + }); + /** + * Set the subdivision which the swing will be applied to. + * The default value is an 8th note. Value must be less + * than a quarter note. + * + * @memberOf Tone.Transport# + * @type {Time} + * @name swingSubdivision + */ + Object.defineProperty(Tone.Transport.prototype, 'swingSubdivision', { + get: function () { + return Tone.Ticks(this._swingTicks).toNotation(); + }, + set: function (subdivision) { + this._swingTicks = this.toTicks(subdivision); + } + }); + /** + * The Transport's position in Bars:Beats:Sixteenths. + * Setting the value will jump to that position right away. + * @memberOf Tone.Transport# + * @type {BarsBeatsSixteenths} + * @name position + */ + Object.defineProperty(Tone.Transport.prototype, 'position', { + get: function () { + var now = this.now(); + var ticks = this._clock.getTicksAtTime(now); + return Tone.Ticks(ticks).toBarsBeatsSixteenths(); + }, + set: function (progress) { + var ticks = this.toTicks(progress); + this.ticks = ticks; + } + }); + /** + * The Transport's position in seconds + * Setting the value will jump to that position right away. + * @memberOf Tone.Transport# + * @type {Seconds} + * @name seconds + */ + Object.defineProperty(Tone.Transport.prototype, 'seconds', { + get: function () { + return this._clock.seconds; + }, + set: function (s) { + var now = this.now(); + var ticks = this.bpm.timeToTicks(s, now); + this.ticks = ticks; + } + }); + /** + * The Transport's loop position as a normalized value. Always + * returns 0 if the transport if loop is not true. + * @memberOf Tone.Transport# + * @name progress + * @type {NormalRange} + */ + Object.defineProperty(Tone.Transport.prototype, 'progress', { + get: function () { + if (this.loop) { + var now = this.now(); + var ticks = this._clock.getTicksAtTime(now); + return (ticks - this._loopStart) / (this._loopEnd - this._loopStart); + } else { + return 0; + } + } + }); + /** + * The transports current tick position. + * + * @memberOf Tone.Transport# + * @type {Ticks} + * @name ticks + */ + Object.defineProperty(Tone.Transport.prototype, 'ticks', { + get: function () { + return this._clock.ticks; + }, + set: function (t) { + if (this._clock.ticks !== t) { + var now = this.now(); + //stop everything synced to the transport + if (this.state === Tone.State.Started) { + this.emit('stop', now); + this._clock.setTicksAtTime(t, now); + //restart it with the new time + this.emit('start', now, this.seconds); + } else { + this._clock.setTicksAtTime(t, now); + } + } + } + }); + /** + * Get the clock's ticks at the given time. + * @param {Time} time When to get the tick value + * @return {Ticks} The tick value at the given time. + */ + Tone.Transport.prototype.getTicksAtTime = function (time) { + return Math.round(this._clock.getTicksAtTime(time)); + }; + /** + * Return the elapsed seconds at the given time. + * @param {Time} time When to get the elapsed seconds + * @return {Seconds} The number of elapsed seconds + */ + Tone.Transport.prototype.getSecondsAtTime = function (time) { + return this._clock.getSecondsAtTime(time); + }; + /** + * Pulses Per Quarter note. This is the smallest resolution + * the Transport timing supports. This should be set once + * on initialization and not set again. Changing this value + * after other objects have been created can cause problems. + * + * @memberOf Tone.Transport# + * @type {Number} + * @name PPQ + */ + Object.defineProperty(Tone.Transport.prototype, 'PPQ', { + get: function () { + return this._ppq; + }, + set: function (ppq) { + var bpm = this.bpm.value; + this._ppq = ppq; + this.bpm.value = bpm; + } + }); + /** + * Convert from BPM to frequency (factoring in PPQ) + * @param {BPM} bpm The BPM value to convert to frequency + * @return {Frequency} The BPM as a frequency with PPQ factored in. + * @private + */ + Tone.Transport.prototype._fromUnits = function (bpm) { + return 1 / (60 / bpm / this.PPQ); + }; + /** + * Convert from frequency (with PPQ) into BPM + * @param {Frequency} freq The clocks frequency to convert to BPM + * @return {BPM} The frequency value as BPM. + * @private + */ + Tone.Transport.prototype._toUnits = function (freq) { + return freq / this.PPQ * 60; + }; + /////////////////////////////////////////////////////////////////////////////// + // SYNCING + /////////////////////////////////////////////////////////////////////////////// + /** + * Returns the time aligned to the next subdivision + * of the Transport. If the Transport is not started, + * it will return 0. + * Note: this will not work precisely during tempo ramps. + * @param {Time} subdivision The subdivision to quantize to + * @return {Number} The context time of the next subdivision. + * @example + * Tone.Transport.start(); //the transport must be started + * Tone.Transport.nextSubdivision("4n"); + */ + Tone.Transport.prototype.nextSubdivision = function (subdivision) { + subdivision = this.toTicks(subdivision); + if (this.state !== Tone.State.Started) { + //if the transport's not started, return 0 + return 0; + } else { + var now = this.now(); + //the remainder of the current ticks and the subdivision + var transportPos = this.getTicksAtTime(now); + var remainingTicks = subdivision - transportPos % subdivision; + return this._clock.nextTickTime(remainingTicks, now); + } + }; + /** + * Attaches the signal to the tempo control signal so that + * any changes in the tempo will change the signal in the same + * ratio. + * + * @param {Tone.Signal} signal + * @param {number=} ratio Optionally pass in the ratio between + * the two signals. Otherwise it will be computed + * based on their current values. + * @returns {Tone.Transport} this + */ + Tone.Transport.prototype.syncSignal = function (signal, ratio) { + if (!ratio) { + //get the sync ratio + var now = this.now(); + if (signal.getValueAtTime(now) !== 0) { + ratio = signal.getValueAtTime(now) / this.bpm.getValueAtTime(now); + } else { + ratio = 0; + } + } + var ratioSignal = new Tone.Gain(ratio); + this.bpm.chain(ratioSignal, signal._param); + this._syncedSignals.push({ + 'ratio': ratioSignal, + 'signal': signal, + 'initial': signal.value + }); + signal.value = 0; + return this; + }; + /** + * Unsyncs a previously synced signal from the transport's control. + * See Tone.Transport.syncSignal. + * @param {Tone.Signal} signal + * @returns {Tone.Transport} this + */ + Tone.Transport.prototype.unsyncSignal = function (signal) { + for (var i = this._syncedSignals.length - 1; i >= 0; i--) { + var syncedSignal = this._syncedSignals[i]; + if (syncedSignal.signal === signal) { + syncedSignal.ratio.dispose(); + syncedSignal.signal.value = syncedSignal.initial; + this._syncedSignals.splice(i, 1); + } + } + return this; + }; + /** + * Clean up. + * @returns {Tone.Transport} this + * @private + */ + Tone.Transport.prototype.dispose = function () { + Tone.Emitter.prototype.dispose.call(this); + this._clock.dispose(); + this._clock = null; + this._writable('bpm'); + this.bpm = null; + this._timeline.dispose(); + this._timeline = null; + this._repeatedEvents.dispose(); + this._repeatedEvents = null; + return this; + }; + /////////////////////////////////////////////////////////////////////////////// + // INITIALIZATION + /////////////////////////////////////////////////////////////////////////////// + var TransportConstructor = Tone.Transport; + Tone.Transport = new TransportConstructor(); + Tone.Context.on('init', function (context) { + if (context.Transport instanceof TransportConstructor) { + Tone.Transport = context.Transport; + } else { + Tone.Transport = new TransportConstructor(); + } + //store the Transport on the context so it can be retrieved later + context.Transport = Tone.Transport; + }); + Tone.Context.on('close', function (context) { + if (context.Transport instanceof TransportConstructor) { + context.Transport.dispose(); + } + }); + return Tone.Transport; + }); + Module(function (Tone) { + + /** + * @class Tone.Volume is a simple volume node, useful for creating a volume fader. + * + * @extends {Tone.AudioNode} + * @constructor + * @param {Decibels} [volume=0] the initial volume + * @example + * var vol = new Tone.Volume(-12); + * instrument.chain(vol, Tone.Master); + */ + Tone.Volume = function () { + var options = Tone.defaults(arguments, ['volume'], Tone.Volume); + Tone.AudioNode.call(this); + /** + * the output node + * @type {GainNode} + * @private + */ + this.output = this.input = new Tone.Gain(options.volume, Tone.Type.Decibels); + /** + * The unmuted volume + * @type {Decibels} + * @private + */ + this._unmutedVolume = options.volume; + /** + * The volume control in decibels. + * @type {Decibels} + * @signal + */ + this.volume = this.output.gain; + this._readOnly('volume'); + //set the mute initially + this.mute = options.mute; + }; + Tone.extend(Tone.Volume, Tone.AudioNode); + /** + * Defaults + * @type {Object} + * @const + * @static + */ + Tone.Volume.defaults = { + 'volume': 0, + 'mute': false + }; + /** + * Mute the output. + * @memberOf Tone.Volume# + * @type {boolean} + * @name mute + * @example + * //mute the output + * volume.mute = true; + */ + Object.defineProperty(Tone.Volume.prototype, 'mute', { + get: function () { + return this.volume.value === -Infinity; + }, + set: function (mute) { + if (!this.mute && mute) { + this._unmutedVolume = this.volume.value; + //maybe it should ramp here? + this.volume.value = -Infinity; + } else if (this.mute && !mute) { + this.volume.value = this._unmutedVolume; + } + } + }); + /** + * clean up + * @returns {Tone.Volume} this + */ + Tone.Volume.prototype.dispose = function () { + this.input.dispose(); + Tone.AudioNode.prototype.dispose.call(this); + this._writable('volume'); + this.volume.dispose(); + this.volume = null; + return this; + }; + return Tone.Volume; + }); + Module(function (Tone) { + + /** + * @class A single master output which is connected to the + * AudioDestinationNode (aka your speakers). + * It provides useful conveniences such as the ability + * to set the volume and mute the entire application. + * It also gives you the ability to apply master effects to your application. + * <br><br> + * Like Tone.Transport, A single Tone.Master is created + * on initialization and you do not need to explicitly construct one. + * + * @constructor + * @extends {Tone} + * @singleton + * @example + * //the audio will go from the oscillator to the speakers + * oscillator.connect(Tone.Master); + * //a convenience for connecting to the master output is also provided: + * oscillator.toMaster(); + * //the above two examples are equivalent. + */ + Tone.Master = function () { + Tone.AudioNode.call(this); + Tone.getContext(function () { + this.createInsOuts(1, 0); + /** + * The private volume node + * @type {Tone.Volume} + * @private + */ + this._volume = this.output = new Tone.Volume(); + /** + * The volume of the master output. + * @type {Decibels} + * @signal + */ + this.volume = this._volume.volume; + this._readOnly('volume'); + //connections + this.input.chain(this.output, this.context.destination); + }.bind(this)); + }; + Tone.extend(Tone.Master, Tone.AudioNode); + /** + * @type {Object} + * @const + */ + Tone.Master.defaults = { + 'volume': 0, + 'mute': false + }; + /** + * Mute the output. + * @memberOf Tone.Master# + * @type {boolean} + * @name mute + * @example + * //mute the output + * Tone.Master.mute = true; + */ + Object.defineProperty(Tone.Master.prototype, 'mute', { + get: function () { + return this._volume.mute; + }, + set: function (mute) { + this._volume.mute = mute; + } + }); + /** + * Add a master effects chain. NOTE: this will disconnect any nodes which were previously + * chained in the master effects chain. + * @param {AudioNode|Tone} args... All arguments will be connected in a row + * and the Master will be routed through it. + * @return {Tone.Master} this + * @example + * //some overall compression to keep the levels in check + * var masterCompressor = new Tone.Compressor({ + * "threshold" : -6, + * "ratio" : 3, + * "attack" : 0.5, + * "release" : 0.1 + * }); + * //give a little boost to the lows + * var lowBump = new Tone.Filter(200, "lowshelf"); + * //route everything through the filter + * //and compressor before going to the speakers + * Tone.Master.chain(lowBump, masterCompressor); + */ + Tone.Master.prototype.chain = function () { + this.input.disconnect(); + this.input.chain.apply(this.input, arguments); + arguments[arguments.length - 1].connect(this.output); + }; + /** + * Clean up + * @return {Tone.Master} this + */ + Tone.Master.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable('volume'); + this._volume.dispose(); + this._volume = null; + this.volume = null; + }; + /////////////////////////////////////////////////////////////////////////// + // AUGMENT TONE's PROTOTYPE + /////////////////////////////////////////////////////////////////////////// + /** + * Connect 'this' to the master output. Shorthand for this.connect(Tone.Master) + * @returns {Tone.AudioNode} this + * @example + * //connect an oscillator to the master output + * var osc = new Tone.Oscillator().toMaster(); + */ + Tone.AudioNode.prototype.toMaster = function () { + this.connect(Tone.Master); + return this; + }; + if (window.AudioNode) { + // Also augment AudioNode's prototype to include toMaster as a convenience + AudioNode.prototype.toMaster = function () { + this.connect(Tone.Master); + return this; + }; + } + /** + * initialize the module and listen for new audio contexts + */ + var MasterConstructor = Tone.Master; + Tone.Master = new MasterConstructor(); + Tone.Context.on('init', function (context) { + // if it already exists, just restore it + if (context.Master instanceof MasterConstructor) { + Tone.Master = context.Master; + } else { + Tone.Master = new MasterConstructor(); + } + context.Master = Tone.Master; + }); + Tone.Context.on('close', function (context) { + if (context.Master instanceof MasterConstructor) { + context.Master.dispose(); + } + }); + return Tone.Master; + }); + Module(function (Tone) { + + /** + * @class Base class for sources. Sources have start/stop methods + * and the ability to be synced to the + * start/stop of Tone.Transport. + * + * @constructor + * @extends {Tone.AudioNode} + * @example + * //Multiple state change events can be chained together, + * //but must be set in the correct order and with ascending times + * + * // OK + * state.start().stop("+0.2"); + * // AND + * state.start().stop("+0.2").start("+0.4").stop("+0.7") + * + * // BAD + * state.stop("+0.2").start(); + * // OR + * state.start("+0.3").stop("+0.2"); + * + */ + Tone.Source = function (options) { + options = Tone.defaultArg(options, Tone.Source.defaults); + Tone.AudioNode.call(this); + /** + * The output volume node + * @type {Tone.Volume} + * @private + */ + this._volume = this.output = new Tone.Volume(options.volume); + /** + * The volume of the output in decibels. + * @type {Decibels} + * @signal + * @example + * source.volume.value = -6; + */ + this.volume = this._volume.volume; + this._readOnly('volume'); + /** + * Keep track of the scheduled state. + * @type {Tone.TimelineState} + * @private + */ + this._state = new Tone.TimelineState(Tone.State.Stopped); + this._state.memory = 100; + /** + * The synced `start` callback function from the transport + * @type {Function} + * @private + */ + this._synced = false; + /** + * Keep track of all of the scheduled event ids + * @type {Array} + * @private + */ + this._scheduled = []; + //make the output explicitly stereo + this._volume.output.output.channelCount = 2; + this._volume.output.output.channelCountMode = 'explicit'; + //mute initially + this.mute = options.mute; + }; + Tone.extend(Tone.Source, Tone.AudioNode); + /** + * The default parameters + * @static + * @const + * @type {Object} + */ + Tone.Source.defaults = { + 'volume': 0, + 'mute': false + }; + /** + * Returns the playback state of the source, either "started" or "stopped". + * @type {Tone.State} + * @readOnly + * @memberOf Tone.Source# + * @name state + */ + Object.defineProperty(Tone.Source.prototype, 'state', { + get: function () { + if (this._synced) { + if (Tone.Transport.state === Tone.State.Started) { + return this._state.getValueAtTime(Tone.Transport.seconds); + } else { + return Tone.State.Stopped; + } + } else { + return this._state.getValueAtTime(this.now()); + } + } + }); + /** + * Mute the output. + * @memberOf Tone.Source# + * @type {boolean} + * @name mute + * @example + * //mute the output + * source.mute = true; + */ + Object.defineProperty(Tone.Source.prototype, 'mute', { + get: function () { + return this._volume.mute; + }, + set: function (mute) { + this._volume.mute = mute; + } + }); + //overwrite these functions + Tone.Source.prototype._start = Tone.noOp; + Tone.Source.prototype.restart = Tone.noOp; + Tone.Source.prototype._stop = Tone.noOp; + /** + * Start the source at the specified time. If no time is given, + * start the source now. + * @param {Time} [time=now] When the source should be started. + * @returns {Tone.Source} this + * @example + * source.start("+0.5"); //starts the source 0.5 seconds from now + */ + Tone.Source.prototype.start = function (time, offset, duration) { + if (Tone.isUndef(time) && this._synced) { + time = Tone.Transport.seconds; + } else { + time = this.toSeconds(time); + } + //if it's started, stop it and restart it + if (this._state.getValueAtTime(time) === Tone.State.Started) { + this._state.cancel(time); + this._state.setStateAtTime(Tone.State.Started, time); + this.restart(time, offset, duration); + } else { + this._state.setStateAtTime(Tone.State.Started, time); + if (this._synced) { + // add the offset time to the event + var event = this._state.get(time); + event.offset = Tone.defaultArg(offset, 0); + event.duration = duration; + var sched = Tone.Transport.schedule(function (t) { + this._start(t, offset, duration); + }.bind(this), time); + this._scheduled.push(sched); + //if it's already started + if (Tone.Transport.state === Tone.State.Started) { + this._syncedStart(this.now(), Tone.Transport.seconds); + } + } else { + this._start.apply(this, arguments); + } + } + return this; + }; + /** + * Stop the source at the specified time. If no time is given, + * stop the source now. + * @param {Time} [time=now] When the source should be stopped. + * @returns {Tone.Source} this + * @example + * source.stop(); // stops the source immediately + */ + Tone.Source.prototype.stop = function (time) { + if (Tone.isUndef(time) && this._synced) { + time = Tone.Transport.seconds; + } else { + time = this.toSeconds(time); + } + if (!this._synced) { + this._stop.apply(this, arguments); + } else { + var sched = Tone.Transport.schedule(this._stop.bind(this), time); + this._scheduled.push(sched); + } + this._state.cancel(time); + this._state.setStateAtTime(Tone.State.Stopped, time); + return this; + }; + /** + * Sync the source to the Transport so that all subsequent + * calls to `start` and `stop` are synced to the TransportTime + * instead of the AudioContext time. + * + * @returns {Tone.Source} this + * @example + * //sync the source so that it plays between 0 and 0.3 on the Transport's timeline + * source.sync().start(0).stop(0.3); + * //start the transport. + * Tone.Transport.start(); + * + * @example + * //start the transport with an offset and the sync'ed sources + * //will start in the correct position + * source.sync().start(0.1); + * //the source will be invoked with an offset of 0.4 + * Tone.Transport.start("+0.5", 0.5); + */ + Tone.Source.prototype.sync = function () { + this._synced = true; + this._syncedStart = function (time, offset) { + if (offset > 0) { + // get the playback state at that time + var stateEvent = this._state.get(offset); + // listen for start events which may occur in the middle of the sync'ed time + if (stateEvent && stateEvent.state === Tone.State.Started && stateEvent.time !== offset) { + // get the offset + var startOffset = offset - this.toSeconds(stateEvent.time); + var duration; + if (stateEvent.duration) { + duration = this.toSeconds(stateEvent.duration) - startOffset; + } + this._start(time, this.toSeconds(stateEvent.offset) + startOffset, duration); + } + } + }.bind(this); + this._syncedStop = function (time) { + var seconds = Tone.Transport.getSecondsAtTime(Math.max(time - this.sampleTime, 0)); + if (this._state.getValueAtTime(seconds) === Tone.State.Started) { + this._stop(time); + } + }.bind(this); + Tone.Transport.on('start loopStart', this._syncedStart); + Tone.Transport.on('stop pause loopEnd', this._syncedStop); + return this; + }; + /** + * Unsync the source to the Transport. See Tone.Source.sync + * @returns {Tone.Source} this + */ + Tone.Source.prototype.unsync = function () { + if (this._synced) { + Tone.Transport.off('stop pause loopEnd', this._syncedStop); + Tone.Transport.off('start loopStart', this._syncedStart); + } + this._synced = false; + // clear all of the scheduled ids + for (var i = 0; i < this._scheduled.length; i++) { + var id = this._scheduled[i]; + Tone.Transport.clear(id); + } + this._scheduled = []; + this._state.cancel(0); + return this; + }; + /** + * Clean up. + * @return {Tone.Source} this + */ + Tone.Source.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this.unsync(); + this._scheduled = null; + this._writable('volume'); + this._volume.dispose(); + this._volume = null; + this.volume = null; + this._state.dispose(); + this._state = null; + }; + return Tone.Source; + }); + Module(function (Tone) { + /** + * AudioBuffer.copyTo/FromChannel polyfill + * @private + */ + if (Tone.supported) { + if (!AudioBuffer.prototype.copyToChannel) { + AudioBuffer.prototype.copyToChannel = function (src, chanNum, start) { + var channel = this.getChannelData(chanNum); + start = start || 0; + for (var i = 0; i < channel.length; i++) { + channel[i + start] = src[i]; + } + }; + AudioBuffer.prototype.copyFromChannel = function (dest, chanNum, start) { + var channel = this.getChannelData(chanNum); + start = start || 0; + for (var i = 0; i < dest.length; i++) { + dest[i] = channel[i + start]; + } + }; + } + } + }); + Module(function (Tone) { + + /** + * @class Buffer loading and storage. Tone.Buffer is used internally by all + * classes that make requests for audio files such as Tone.Player, + * Tone.Sampler and Tone.Convolver. + * + * Aside from load callbacks from individual buffers, Tone.Buffer + * provides events which keep track of the loading progress + * of _all_ of the buffers. These are Tone.Buffer.on("load" / "progress" / "error") + * + * @constructor + * @extends {Tone} + * @param {AudioBuffer|String} url The url to load, or the audio buffer to set. + * @param {Function=} onload A callback which is invoked after the buffer is loaded. + * It's recommended to use `Tone.Buffer.on('load', callback)` instead + * since it will give you a callback when _all_ buffers are loaded. + * @param {Function=} onerror The callback to invoke if there is an error + * @example + * var buffer = new Tone.Buffer("path/to/sound.mp3", function(){ + * //the buffer is now available. + * var buff = buffer.get(); + * }); + * @example + * //can load provide fallback extension types if the first type is not supported. + * var buffer = new Tone.Buffer("path/to/sound.[mp3|ogg|wav]"); + */ + Tone.Buffer = function () { + var options = Tone.defaults(arguments, [ + 'url', + 'onload', + 'onerror' + ], Tone.Buffer); + Tone.call(this); + /** + * stores the loaded AudioBuffer + * @type {AudioBuffer} + * @private + */ + this._buffer = null; + /** + * indicates if the buffer should be reversed or not + * @type {Boolean} + * @private + */ + this._reversed = options.reverse; + /** + * The XHR + * @type {XMLHttpRequest} + * @private + */ + this._xhr = null; + /** + * Private callback when the buffer is loaded. + * @type {Function} + * @private + */ + this._onload = Tone.noOp; + if (options.url instanceof AudioBuffer || options.url instanceof Tone.Buffer) { + this.set(options.url); + // invoke the onload callback + if (options.onload) { + if (this.loaded) { + options.onload(this); + } else { + this._onload = options.onload; + } + } + } else if (Tone.isString(options.url)) { + this.load(options.url).then(options.onload).catch(options.onerror); + } + }; + Tone.extend(Tone.Buffer); + /** + * the default parameters + * @type {Object} + */ + Tone.Buffer.defaults = { + 'url': undefined, + 'reverse': false, + 'onload': Tone.noOp, + 'onerror': Tone.noOp + }; + /** + * Pass in an AudioBuffer or Tone.Buffer to set the value + * of this buffer. + * @param {AudioBuffer|Tone.Buffer} buffer the buffer + * @returns {Tone.Buffer} this + */ + Tone.Buffer.prototype.set = function (buffer) { + if (buffer instanceof Tone.Buffer) { + if (buffer.loaded) { + this._buffer = buffer.get(); + } else { + buffer._onload = function () { + this.set(buffer); + this._onload(this); + }.bind(this); + } + } else { + this._buffer = buffer; + } + return this; + }; + /** + * @return {AudioBuffer} The audio buffer stored in the object. + */ + Tone.Buffer.prototype.get = function () { + return this._buffer; + }; + /** + * Makes an xhr reqest for the selected url then decodes + * the file as an audio buffer. Invokes + * the callback once the audio buffer loads. + * @param {String} url The url of the buffer to load. + * filetype support depends on the + * browser. + * @returns {Promise} returns a Promise which resolves with the Tone.Buffer + */ + Tone.Buffer.prototype.load = function (url, onload, onerror) { + var promise = new Promise(function (load, error) { + this._xhr = Tone.Buffer.load(url, //success + function (buff) { + this._xhr = null; + this.set(buff); + load(this); + this._onload(this); + if (onload) { + onload(this); + } + }.bind(this), //error + function (err) { + this._xhr = null; + error(err); + if (onerror) { + onerror(err); + } + }.bind(this)); + }.bind(this)); + return promise; + }; + /** + * dispose and disconnect + * @returns {Tone.Buffer} this + */ + Tone.Buffer.prototype.dispose = function () { + Tone.prototype.dispose.call(this); + this._buffer = null; + if (this._xhr) { + Tone.Buffer._removeFromDownloadQueue(this._xhr); + this._xhr.abort(); + this._xhr = null; + } + return this; + }; + /** + * If the buffer is loaded or not + * @memberOf Tone.Buffer# + * @type {Boolean} + * @name loaded + * @readOnly + */ + Object.defineProperty(Tone.Buffer.prototype, 'loaded', { + get: function () { + return this.length > 0; + } + }); + /** + * The duration of the buffer. + * @memberOf Tone.Buffer# + * @type {Number} + * @name duration + * @readOnly + */ + Object.defineProperty(Tone.Buffer.prototype, 'duration', { + get: function () { + if (this._buffer) { + return this._buffer.duration; + } else { + return 0; + } + } + }); + /** + * The length of the buffer in samples + * @memberOf Tone.Buffer# + * @type {Number} + * @name length + * @readOnly + */ + Object.defineProperty(Tone.Buffer.prototype, 'length', { + get: function () { + if (this._buffer) { + return this._buffer.length; + } else { + return 0; + } + } + }); + /** + * The number of discrete audio channels. Returns 0 if no buffer + * is loaded. + * @memberOf Tone.Buffer# + * @type {Number} + * @name numberOfChannels + * @readOnly + */ + Object.defineProperty(Tone.Buffer.prototype, 'numberOfChannels', { + get: function () { + if (this._buffer) { + return this._buffer.numberOfChannels; + } else { + return 0; + } + } + }); + /** + * Set the audio buffer from the array. To create a multichannel AudioBuffer, + * pass in a multidimensional array. + * @param {Float32Array} array The array to fill the audio buffer + * @return {Tone.Buffer} this + */ + Tone.Buffer.prototype.fromArray = function (array) { + var isMultidimensional = array[0].length > 0; + var channels = isMultidimensional ? array.length : 1; + var len = isMultidimensional ? array[0].length : array.length; + var buffer = this.context.createBuffer(channels, len, this.context.sampleRate); + if (!isMultidimensional && channels === 1) { + array = [array]; + } + for (var c = 0; c < channels; c++) { + buffer.copyToChannel(array[c], c); + } + this._buffer = buffer; + return this; + }; + /** + * Sums muliple channels into 1 channel + * @param {Number=} channel Optionally only copy a single channel from the array. + * @return {Array} + */ + Tone.Buffer.prototype.toMono = function (chanNum) { + if (Tone.isNumber(chanNum)) { + this.fromArray(this.toArray(chanNum)); + } else { + var outputArray = new Float32Array(this.length); + var numChannels = this.numberOfChannels; + for (var channel = 0; channel < numChannels; channel++) { + var channelArray = this.toArray(channel); + for (var i = 0; i < channelArray.length; i++) { + outputArray[i] += channelArray[i]; + } + } + //divide by the number of channels + outputArray = outputArray.map(function (sample) { + return sample / numChannels; + }); + this.fromArray(outputArray); + } + return this; + }; + /** + * Get the buffer as an array. Single channel buffers will return a 1-dimensional + * Float32Array, and multichannel buffers will return multidimensional arrays. + * @param {Number=} channel Optionally only copy a single channel from the array. + * @return {Array} + */ + Tone.Buffer.prototype.toArray = function (channel) { + if (Tone.isNumber(channel)) { + return this.getChannelData(channel); + } else if (this.numberOfChannels === 1) { + return this.toArray(0); + } else { + var ret = []; + for (var c = 0; c < this.numberOfChannels; c++) { + ret[c] = this.getChannelData(c); + } + return ret; + } + }; + /** + * Returns the Float32Array representing the PCM audio data for the specific channel. + * @param {Number} channel The channel number to return + * @return {Float32Array} The audio as a TypedArray + */ + Tone.Buffer.prototype.getChannelData = function (channel) { + return this._buffer.getChannelData(channel); + }; + /** + * Cut a subsection of the array and return a buffer of the + * subsection. Does not modify the original buffer + * @param {Time} start The time to start the slice + * @param {Time=} end The end time to slice. If none is given + * will default to the end of the buffer + * @return {Tone.Buffer} this + */ + Tone.Buffer.prototype.slice = function (start, end) { + end = Tone.defaultArg(end, this.duration); + var startSamples = Math.floor(this.context.sampleRate * this.toSeconds(start)); + var endSamples = Math.floor(this.context.sampleRate * this.toSeconds(end)); + var replacement = []; + for (var i = 0; i < this.numberOfChannels; i++) { + replacement[i] = this.toArray(i).slice(startSamples, endSamples); + } + var retBuffer = new Tone.Buffer().fromArray(replacement); + return retBuffer; + }; + /** + * Reverse the buffer. + * @private + * @return {Tone.Buffer} this + */ + Tone.Buffer.prototype._reverse = function () { + if (this.loaded) { + for (var i = 0; i < this.numberOfChannels; i++) { + Array.prototype.reverse.call(this.getChannelData(i)); + } + } + return this; + }; + /** + * Reverse the buffer. + * @memberOf Tone.Buffer# + * @type {Boolean} + * @name reverse + */ + Object.defineProperty(Tone.Buffer.prototype, 'reverse', { + get: function () { + return this._reversed; + }, + set: function (rev) { + if (this._reversed !== rev) { + this._reversed = rev; + this._reverse(); + } + } + }); + /////////////////////////////////////////////////////////////////////////// + // STATIC METHODS + /////////////////////////////////////////////////////////////////////////// + //statically inherits Emitter methods + Tone.Emitter.mixin(Tone.Buffer); + /** + * the static queue for all of the xhr requests + * @type {Array} + * @private + */ + Tone.Buffer._downloadQueue = []; + /** + * A path which is prefixed before every url. + * @type {String} + * @static + */ + Tone.Buffer.baseUrl = ''; + /** + * Create a Tone.Buffer from the array. To create a multichannel AudioBuffer, + * pass in a multidimensional array. + * @param {Float32Array} array The array to fill the audio buffer + * @return {Tone.Buffer} A Tone.Buffer created from the array + */ + Tone.Buffer.fromArray = function (array) { + return new Tone.Buffer().fromArray(array); + }; + /** + * Creates a Tone.Buffer from a URL, returns a promise + * which resolves to a Tone.Buffer + * @param {String} url The url to load. + * @return {Promise<Tone.Buffer>} A promise which resolves to a Tone.Buffer + */ + Tone.Buffer.fromUrl = function (url) { + var buffer = new Tone.Buffer(); + return buffer.load(url).then(function () { + return buffer; + }); + }; + /** + * Remove an xhr request from the download queue + * @private + */ + Tone.Buffer._removeFromDownloadQueue = function (request) { + var index = Tone.Buffer._downloadQueue.indexOf(request); + if (index !== -1) { + Tone.Buffer._downloadQueue.splice(index, 1); + } + }; + /** + * Loads a url using XMLHttpRequest. + * @param {String} url + * @param {Function} onload + * @param {Function} onerror + * @param {Function} onprogress + * @return {XMLHttpRequest} + */ + Tone.Buffer.load = function (url, onload, onerror) { + //default + onload = Tone.defaultArg(onload, Tone.noOp); + // test if the url contains multiple extensions + var matches = url.match(/\[(.+\|?)+\]$/); + if (matches) { + var extensions = matches[1].split('|'); + var extension = extensions[0]; + for (var i = 0; i < extensions.length; i++) { + if (Tone.Buffer.supportsType(extensions[i])) { + extension = extensions[i]; + break; + } + } + url = url.replace(matches[0], extension); + } + function onError(e) { + Tone.Buffer._removeFromDownloadQueue(request); + Tone.Buffer.emit('error', e); + if (onerror) { + onerror(e); + } else { + throw e; + } + } + function onProgress() { + //calculate the progress + var totalProgress = 0; + for (var i = 0; i < Tone.Buffer._downloadQueue.length; i++) { + totalProgress += Tone.Buffer._downloadQueue[i].progress; + } + Tone.Buffer.emit('progress', totalProgress / Tone.Buffer._downloadQueue.length); + } + var request = new XMLHttpRequest(); + request.open('GET', Tone.Buffer.baseUrl + url, true); + request.responseType = 'arraybuffer'; + //start out as 0 + request.progress = 0; + Tone.Buffer._downloadQueue.push(request); + request.addEventListener('load', function () { + if (request.status === 200) { + Tone.context.decodeAudioData(request.response).then(function (buff) { + request.progress = 1; + onProgress(); + onload(buff); + Tone.Buffer._removeFromDownloadQueue(request); + if (Tone.Buffer._downloadQueue.length === 0) { + //emit the event at the end + Tone.Buffer.emit('load'); + } + }).catch(function () { + Tone.Buffer._removeFromDownloadQueue(request); + onError('Tone.Buffer: could not decode audio data: ' + url); + }); + } else { + onError('Tone.Buffer: could not locate file: ' + url); + } + }); + request.addEventListener('error', onError); + request.addEventListener('progress', function (event) { + if (event.lengthComputable) { + //only go to 95%, the last 5% is when the audio is decoded + request.progress = event.loaded / event.total * 0.95; + onProgress(); + } + }); + request.send(); + return request; + }; + /** + * Stop all of the downloads in progress + * @return {Tone.Buffer} + * @static + */ + Tone.Buffer.cancelDownloads = function () { + Tone.Buffer._downloadQueue.slice().forEach(function (request) { + Tone.Buffer._removeFromDownloadQueue(request); + request.abort(); + }); + return Tone.Buffer; + }; + /** + * Checks a url's extension to see if the current browser can play that file type. + * @param {String} url The url/extension to test + * @return {Boolean} If the file extension can be played + * @static + * @example + * Tone.Buffer.supportsType("wav"); //returns true + * Tone.Buffer.supportsType("path/to/file.wav"); //returns true + */ + Tone.Buffer.supportsType = function (url) { + var extension = url.split('.'); + extension = extension[extension.length - 1]; + var response = document.createElement('audio').canPlayType('audio/' + extension); + return response !== ''; + }; + /** + * Returns a Promise which resolves when all of the buffers have loaded + * @return {Promise} + */ + Tone.loaded = function () { + var onload, onerror; + function removeEvents() { + //remove the events when it's resolved + Tone.Buffer.off('load', onload); + Tone.Buffer.off('error', onerror); + } + return new Promise(function (success, fail) { + onload = function () { + success(); + }; + onerror = function () { + fail(); + }; + //add the event listeners + Tone.Buffer.on('load', onload); + Tone.Buffer.on('error', onerror); + }).then(removeEvents).catch(function (e) { + removeEvents(); + throw new Error(e); + }); + }; + return Tone.Buffer; + }); + Module(function (Tone) { + /** + * @class Wrapper around the native fire-and-forget OscillatorNode. Adds the + * ability to reschedule the stop method. + * @extends {Tone.AudioNode} + * @param {AudioBuffer|Tone.Buffer} buffer The buffer to play + * @param {Function} onload The callback to invoke when the + * buffer is done playing. + */ + Tone.OscillatorNode = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'type' + ], Tone.OscillatorNode); + Tone.AudioNode.call(this, options); + /** + * The callback to invoke after the + * buffer source is done playing. + * @type {Function} + */ + this.onended = options.onended; + /** + * The oscillator start time + * @type {Number} + * @private + */ + this._startTime = -1; + /** + * The oscillator stop time + * @type {Number} + * @private + */ + this._stopTime = -1; + /** + * The gain node which envelopes the OscillatorNode + * @type {Tone.Gain} + * @private + */ + this._gainNode = this.output = new Tone.Gain(); + this._gainNode.gain.setValueAtTime(0, this.context.currentTime); + /** + * The oscillator + * @type {OscillatorNode} + * @private + */ + this._oscillator = this.context.createOscillator(); + this._oscillator.connect(this._gainNode); + this.type = options.type; + /** + * The frequency of the oscillator + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Param(this._oscillator.frequency, Tone.Type.Frequency); + this.frequency.value = options.frequency; + /** + * The detune of the oscillator + * @type {Frequency} + * @signal + */ + this.detune = new Tone.Param(this._oscillator.detune, Tone.Type.Cents); + this.detune.value = options.detune; + /** + * The value that the buffer ramps to + * @type {Gain} + * @private + */ + this._gain = 1; + }; + Tone.extend(Tone.OscillatorNode, Tone.AudioNode); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.OscillatorNode.defaults = { + 'frequency': 440, + 'detune': 0, + 'type': 'sine', + 'onended': Tone.noOp + }; + /** + * Returns the playback state of the oscillator, either "started" or "stopped". + * @type {Tone.State} + * @readOnly + * @memberOf Tone.OscillatorNode# + * @name state + */ + Object.defineProperty(Tone.OscillatorNode.prototype, 'state', { + get: function () { + return this.getStateAtTime(this.now()); + } + }); + /** + * Get the playback state at the given time + * @param {Time} time The time to test the state at + * @return {Tone.State} The playback state. + */ + Tone.OscillatorNode.prototype.getStateAtTime = function (time) { + time = this.toSeconds(time); + if (this._startTime !== -1 && time >= this._startTime && (this._stopTime === -1 || time <= this._stopTime)) { + return Tone.State.Started; + } else { + return Tone.State.Stopped; + } + }; + /** + * Start the oscillator node at the given time + * @param {Time=} time When to start the oscillator + * @return {OscillatorNode} this + */ + Tone.OscillatorNode.prototype.start = function (time) { + if (this._startTime === -1) { + this._startTime = this.toSeconds(time); + this._oscillator.start(this._startTime); + var now = this.context.currentTime; + this._gainNode.gain.cancelScheduledValues(now); + this._gainNode.gain.setValueAtTime(0, now); + this._gainNode.gain.setValueAtTime(1, this._startTime); + } else { + throw new Error('cannot call OscillatorNode.start more than once'); + } + return this; + }; + /** + * Sets an arbitrary custom periodic waveform given a PeriodicWave. + * @param {PeriodicWave} periodicWave PeriodicWave should be created with context.createPeriodicWave + * @return {OscillatorNode} this + */ + Tone.OscillatorNode.prototype.setPeriodicWave = function (periodicWave) { + this._oscillator.setPeriodicWave(periodicWave); + return this; + }; + /** + * Stop the oscillator node at the given time + * @param {Time=} time When to stop the oscillator + * @return {OscillatorNode} this + */ + Tone.OscillatorNode.prototype.stop = function (time) { + //cancel the previous stop + this.cancelStop(); + //reschedule it + this._stopTime = this.toSeconds(time); + this._gainNode.gain.setValueAtTime(0, this._stopTime); + this.context.clearTimeout(this._timeout); + this._timeout = this.context.setTimeout(function () { + this._oscillator.stop(this.now()); + this.onended(); + }.bind(this), this._stopTime - this.now()); + return this; + }; + /** + * Cancel a scheduled stop event + * @return {Tone.OscillatorNode} this + */ + Tone.OscillatorNode.prototype.cancelStop = function () { + if (this._startTime !== -1) { + //cancel the stop envelope + this._gainNode.gain.cancelScheduledValues(this._startTime + this.sampleTime); + this._gainNode.gain.setValueAtTime(1, Math.max(this.now(), this._startTime)); + this.context.clearTimeout(this._timeout); + this._stopTime = -1; + } + return this; + }; + /** + * The oscillator type. Either 'sine', 'sawtooth', 'square', or 'triangle' + * @memberOf Tone.OscillatorNode# + * @type {Time} + * @name type + */ + Object.defineProperty(Tone.OscillatorNode.prototype, 'type', { + get: function () { + return this._oscillator.type; + }, + set: function (type) { + this._oscillator.type = type; + } + }); + /** + * Clean up. + * @return {Tone.OscillatorNode} this + */ + Tone.OscillatorNode.prototype.dispose = function () { + this.context.clearTimeout(this._timeout); + Tone.AudioNode.prototype.dispose.call(this); + this.onended = null; + this._oscillator.disconnect(); + this._oscillator = null; + this._gainNode.dispose(); + this._gainNode = null; + this.frequency.dispose(); + this.frequency = null; + this.detune.dispose(); + this.detune = null; + return this; + }; + return Tone.OscillatorNode; + }); + Module(function (Tone) { + + /** + * @class Tone.Oscillator supports a number of features including + * phase rotation, multiple oscillator types (see Tone.Oscillator.type), + * and Transport syncing (see Tone.Oscillator.syncFrequency). + * + * @constructor + * @extends {Tone.Source} + * @param {Frequency} [frequency] Starting frequency + * @param {string} [type] The oscillator type. Read more about type below. + * @example + * //make and start a 440hz sine tone + * var osc = new Tone.Oscillator(440, "sine").toMaster().start(); + */ + Tone.Oscillator = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'type' + ], Tone.Oscillator); + Tone.Source.call(this, options); + /** + * the main oscillator + * @type {OscillatorNode} + * @private + */ + this._oscillator = null; + /** + * The frequency control. + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency); + /** + * The detune control signal. + * @type {Cents} + * @signal + */ + this.detune = new Tone.Signal(options.detune, Tone.Type.Cents); + /** + * the periodic wave + * @type {PeriodicWave} + * @private + */ + this._wave = null; + /** + * The partials of the oscillator + * @type {Array} + * @private + */ + this._partials = Tone.defaultArg(options.partials, [1]); + /** + * the phase of the oscillator + * between 0 - 360 + * @type {number} + * @private + */ + this._phase = options.phase; + /** + * the type of the oscillator + * @type {string} + * @private + */ + this._type = null; + //setup + this.type = options.type; + this.phase = this._phase; + this._readOnly([ + 'frequency', + 'detune' + ]); + }; + Tone.extend(Tone.Oscillator, Tone.Source); + /** + * the default parameters + * @type {Object} + */ + Tone.Oscillator.defaults = { + 'type': 'sine', + 'frequency': 440, + 'detune': 0, + 'phase': 0, + 'partials': [] + }; + /** + * The Oscillator types + * @enum {String} + */ + Tone.Oscillator.Type = { + Sine: 'sine', + Triangle: 'triangle', + Sawtooth: 'sawtooth', + Square: 'square', + Custom: 'custom' + }; + /** + * start the oscillator + * @param {Time} [time=now] + * @private + */ + Tone.Oscillator.prototype._start = function (time) { + //new oscillator with previous values + this._oscillator = new Tone.OscillatorNode(); + if (this._wave) { + this._oscillator.setPeriodicWave(this._wave); + } else { + this._oscillator.type = this._type; + } + //connect the control signal to the oscillator frequency & detune + this._oscillator.connect(this.output); + this.frequency.connect(this._oscillator.frequency); + this.detune.connect(this._oscillator.detune); + //start the oscillator + time = this.toSeconds(time); + this._oscillator.start(time); + }; + /** + * stop the oscillator + * @private + * @param {Time} [time=now] (optional) timing parameter + * @returns {Tone.Oscillator} this + */ + Tone.Oscillator.prototype._stop = function (time) { + if (this._oscillator) { + time = this.toSeconds(time); + this._oscillator.stop(time); + } + return this; + }; + /** + * Restart the oscillator. Does not stop the oscillator, but instead + * just cancels any scheduled 'stop' from being invoked. + * @param {Time=} time + * @return {Tone.Oscillator} this + */ + Tone.Oscillator.prototype.restart = function (time) { + this._oscillator.cancelStop(); + this._state.cancel(this.toSeconds(time)); + return this; + }; + /** + * Sync the signal to the Transport's bpm. Any changes to the transports bpm, + * will also affect the oscillators frequency. + * @returns {Tone.Oscillator} this + * @example + * Tone.Transport.bpm.value = 120; + * osc.frequency.value = 440; + * //the ration between the bpm and the frequency will be maintained + * osc.syncFrequency(); + * Tone.Transport.bpm.value = 240; + * // the frequency of the oscillator is doubled to 880 + */ + Tone.Oscillator.prototype.syncFrequency = function () { + Tone.Transport.syncSignal(this.frequency); + return this; + }; + /** + * Unsync the oscillator's frequency from the Transport. + * See Tone.Oscillator.syncFrequency + * @returns {Tone.Oscillator} this + */ + Tone.Oscillator.prototype.unsyncFrequency = function () { + Tone.Transport.unsyncSignal(this.frequency); + return this; + }; + /** + * The type of the oscillator: either sine, square, triangle, or sawtooth. Also capable of + * setting the first x number of partials of the oscillator. For example: "sine4" would + * set be the first 4 partials of the sine wave and "triangle8" would set the first + * 8 partials of the triangle wave. + * <br><br> + * Uses PeriodicWave internally even for native types so that it can set the phase. + * PeriodicWave equations are from the + * [Webkit Web Audio implementation](https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/modules/webaudio/PeriodicWave.cpp&sq=package:chromium). + * + * @memberOf Tone.Oscillator# + * @type {string} + * @name type + * @example + * //set it to a square wave + * osc.type = "square"; + * @example + * //set the first 6 partials of a sawtooth wave + * osc.type = "sawtooth6"; + */ + Object.defineProperty(Tone.Oscillator.prototype, 'type', { + get: function () { + return this._type; + }, + set: function (type) { + var isBasicType = [ + Tone.Oscillator.Type.Sine, + Tone.Oscillator.Type.Square, + Tone.Oscillator.Type.Triangle, + Tone.Oscillator.Type.Sawtooth + ].includes(type); + if (this._phase === 0 && isBasicType) { + this._wave = null; + //just go with the basic approach + if (this._oscillator !== null) { + this._oscillator.type === type; + } + } else { + var coefs = this._getRealImaginary(type, this._phase); + var periodicWave = this.context.createPeriodicWave(coefs[0], coefs[1]); + this._wave = periodicWave; + if (this._oscillator !== null) { + this._oscillator.setPeriodicWave(this._wave); + } + } + this._type = type; + } + }); + /** + * Returns the real and imaginary components based + * on the oscillator type. + * @returns {Array} [real, imaginary] + * @private + */ + Tone.Oscillator.prototype._getRealImaginary = function (type, phase) { + var fftSize = 4096; + var periodicWaveSize = fftSize / 2; + var real = new Float32Array(periodicWaveSize); + var imag = new Float32Array(periodicWaveSize); + var partialCount = 1; + if (type === Tone.Oscillator.Type.Custom) { + partialCount = this._partials.length + 1; + periodicWaveSize = partialCount; + } else { + var partial = /^(sine|triangle|square|sawtooth)(\d+)$/.exec(type); + if (partial) { + partialCount = parseInt(partial[2]) + 1; + type = partial[1]; + partialCount = Math.max(partialCount, 2); + periodicWaveSize = partialCount; + } + } + for (var n = 1; n < periodicWaveSize; ++n) { + var piFactor = 2 / (n * Math.PI); + var b; + switch (type) { + case Tone.Oscillator.Type.Sine: + b = n <= partialCount ? 1 : 0; + break; + case Tone.Oscillator.Type.Square: + b = n & 1 ? 2 * piFactor : 0; + break; + case Tone.Oscillator.Type.Sawtooth: + b = piFactor * (n & 1 ? 1 : -1); + break; + case Tone.Oscillator.Type.Triangle: + if (n & 1) { + b = 2 * (piFactor * piFactor) * (n - 1 >> 1 & 1 ? -1 : 1); + } else { + b = 0; + } + break; + case Tone.Oscillator.Type.Custom: + b = this._partials[n - 1]; + break; + default: + throw new TypeError('Tone.Oscillator: invalid type: ' + type); + } + if (b !== 0) { + real[n] = -b * Math.sin(phase * n); + imag[n] = b * Math.cos(phase * n); + } else { + real[n] = 0; + imag[n] = 0; + } + } + return [ + real, + imag + ]; + }; + /** + * Compute the inverse FFT for a given phase. + * @param {Float32Array} real + * @param {Float32Array} imag + * @param {NormalRange} phase + * @return {AudioRange} + * @private + */ + Tone.Oscillator.prototype._inverseFFT = function (real, imag, phase) { + var sum = 0; + var len = real.length; + for (var i = 0; i < len; i++) { + sum += real[i] * Math.cos(i * phase) + imag[i] * Math.sin(i * phase); + } + return sum; + }; + /** + * Returns the initial value of the oscillator. + * @return {AudioRange} + * @private + */ + Tone.Oscillator.prototype._getInitialValue = function () { + var coefs = this._getRealImaginary(this._type, 0); + var real = coefs[0]; + var imag = coefs[1]; + var maxValue = 0; + var twoPi = Math.PI * 2; + //check for peaks in 8 places + for (var i = 0; i < 8; i++) { + maxValue = Math.max(this._inverseFFT(real, imag, i / 8 * twoPi), maxValue); + } + return -this._inverseFFT(real, imag, this._phase) / maxValue; + }; + /** + * The partials of the waveform. A partial represents + * the amplitude at a harmonic. The first harmonic is the + * fundamental frequency, the second is the octave and so on + * following the harmonic series. + * Setting this value will automatically set the type to "custom". + * The value is an empty array when the type is not "custom". + * @memberOf Tone.Oscillator# + * @type {Array} + * @name partials + * @example + * osc.partials = [1, 0.2, 0.01]; + */ + Object.defineProperty(Tone.Oscillator.prototype, 'partials', { + get: function () { + if (this._type !== Tone.Oscillator.Type.Custom) { + return []; + } else { + return this._partials; + } + }, + set: function (partials) { + this._partials = partials; + this.type = Tone.Oscillator.Type.Custom; + } + }); + /** + * The phase of the oscillator in degrees. + * @memberOf Tone.Oscillator# + * @type {Degrees} + * @name phase + * @example + * osc.phase = 180; //flips the phase of the oscillator + */ + Object.defineProperty(Tone.Oscillator.prototype, 'phase', { + get: function () { + return this._phase * (180 / Math.PI); + }, + set: function (phase) { + this._phase = phase * Math.PI / 180; + //reset the type + this.type = this._type; + } + }); + /** + * Dispose and disconnect. + * @return {Tone.Oscillator} this + */ + Tone.Oscillator.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + if (this._oscillator !== null) { + this._oscillator.dispose(); + this._oscillator = null; + } + this._wave = null; + this._writable([ + 'frequency', + 'detune' + ]); + this.frequency.dispose(); + this.frequency = null; + this.detune.dispose(); + this.detune = null; + this._partials = null; + return this; + }; + return Tone.Oscillator; + }); + Module(function (Tone) { + + /** + * @class AudioToGain converts an input in AudioRange [-1,1] to NormalRange [0,1]. + * See Tone.GainToAudio. + * + * @extends {Tone.SignalBase} + * @constructor + * @example + * var a2g = new Tone.AudioToGain(); + */ + Tone.AudioToGain = function () { + Tone.SignalBase.call(this); + /** + * @type {WaveShaperNode} + * @private + */ + this._norm = this.input = this.output = new Tone.WaveShaper(function (x) { + return (x + 1) / 2; + }); + }; + Tone.extend(Tone.AudioToGain, Tone.SignalBase); + /** + * clean up + * @returns {Tone.AudioToGain} this + */ + Tone.AudioToGain.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._norm.dispose(); + this._norm = null; + return this; + }; + return Tone.AudioToGain; + }); + Module(function (Tone) { + /** + * @class Tone.Zero outputs 0's at audio-rate. The reason this has to be + * it's own class is that many browsers optimize out Tone.Signal + * with a value of 0 and will not process nodes further down the graph. + * @extends {Tone.SignalBase} + */ + Tone.Zero = function () { + Tone.SignalBase.call(this); + /** + * The gain node + * @type {Tone.Gain} + * @private + */ + this._gain = this.input = this.output = new Tone.Gain(); + this.context.getConstant(0).connect(this._gain); + }; + Tone.extend(Tone.Zero, Tone.SignalBase); + /** + * clean up + * @return {Tone.Zero} this + */ + Tone.Zero.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._gain.dispose(); + this._gain = null; + return this; + }; + return Tone.Zero; + }); + Module(function (Tone) { + + /** + * @class LFO stands for low frequency oscillator. Tone.LFO produces an output signal + * which can be attached to an AudioParam or Tone.Signal + * in order to modulate that parameter with an oscillator. The LFO can + * also be synced to the transport to start/stop and change when the tempo changes. + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Frequency|Object} [frequency] The frequency of the oscillation. Typically, LFOs will be + * in the frequency range of 0.1 to 10 hertz. + * @param {number=} min The minimum output value of the LFO. + * @param {number=} max The maximum value of the LFO. + * @example + * var lfo = new Tone.LFO("4n", 400, 4000); + * lfo.connect(filter.frequency); + */ + Tone.LFO = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'min', + 'max' + ], Tone.LFO); + Tone.AudioNode.call(this); + /** + * The oscillator. + * @type {Tone.Oscillator} + * @private + */ + this._oscillator = new Tone.Oscillator({ + 'frequency': options.frequency, + 'type': options.type + }); + /** + * the lfo's frequency + * @type {Frequency} + * @signal + */ + this.frequency = this._oscillator.frequency; + /** + * The amplitude of the LFO, which controls the output range between + * the min and max output. For example if the min is -10 and the max + * is 10, setting the amplitude to 0.5 would make the LFO modulate + * between -5 and 5. + * @type {Number} + * @signal + */ + this.amplitude = this._oscillator.volume; + this.amplitude.units = Tone.Type.NormalRange; + this.amplitude.value = options.amplitude; + /** + * The signal which is output when the LFO is stopped + * @type {Tone.Signal} + * @private + */ + this._stoppedSignal = new Tone.Signal(0, Tone.Type.AudioRange); + /** + * Just outputs zeros. + * @type {Tone.Zero} + * @private + */ + this._zeros = new Tone.Zero(); + /** + * The value that the LFO outputs when it's stopped + * @type {AudioRange} + * @private + */ + this._stoppedValue = 0; + /** + * @type {Tone.AudioToGain} + * @private + */ + this._a2g = new Tone.AudioToGain(); + /** + * @type {Tone.Scale} + * @private + */ + this._scaler = this.output = new Tone.Scale(options.min, options.max); + /** + * the units of the LFO (used for converting) + * @type {Tone.Type} + * @private + */ + this._units = Tone.Type.Default; + this.units = options.units; + //connect it up + this._oscillator.chain(this._a2g, this._scaler); + this._zeros.connect(this._a2g); + this._stoppedSignal.connect(this._a2g); + this._readOnly([ + 'amplitude', + 'frequency' + ]); + this.phase = options.phase; + }; + Tone.extend(Tone.LFO, Tone.AudioNode); + /** + * the default parameters + * + * @static + * @const + * @type {Object} + */ + Tone.LFO.defaults = { + 'type': 'sine', + 'min': 0, + 'max': 1, + 'phase': 0, + 'frequency': '4n', + 'amplitude': 1, + 'units': Tone.Type.Default + }; + /** + * Start the LFO. + * @param {Time} [time=now] the time the LFO will start + * @returns {Tone.LFO} this + */ + Tone.LFO.prototype.start = function (time) { + time = this.toSeconds(time); + this._stoppedSignal.setValueAtTime(0, time); + this._oscillator.start(time); + return this; + }; + /** + * Stop the LFO. + * @param {Time} [time=now] the time the LFO will stop + * @returns {Tone.LFO} this + */ + Tone.LFO.prototype.stop = function (time) { + time = this.toSeconds(time); + this._stoppedSignal.setValueAtTime(this._stoppedValue, time); + this._oscillator.stop(time); + return this; + }; + /** + * Sync the start/stop/pause to the transport + * and the frequency to the bpm of the transport + * @returns {Tone.LFO} this + * @example + * lfo.frequency.value = "8n"; + * lfo.sync().start(0) + * //the rate of the LFO will always be an eighth note, + * //even as the tempo changes + */ + Tone.LFO.prototype.sync = function () { + this._oscillator.sync(); + this._oscillator.syncFrequency(); + return this; + }; + /** + * unsync the LFO from transport control + * @returns {Tone.LFO} this + */ + Tone.LFO.prototype.unsync = function () { + this._oscillator.unsync(); + this._oscillator.unsyncFrequency(); + return this; + }; + /** + * The miniumum output of the LFO. + * @memberOf Tone.LFO# + * @type {number} + * @name min + */ + Object.defineProperty(Tone.LFO.prototype, 'min', { + get: function () { + return this._toUnits(this._scaler.min); + }, + set: function (min) { + min = this._fromUnits(min); + this._scaler.min = min; + } + }); + /** + * The maximum output of the LFO. + * @memberOf Tone.LFO# + * @type {number} + * @name max + */ + Object.defineProperty(Tone.LFO.prototype, 'max', { + get: function () { + return this._toUnits(this._scaler.max); + }, + set: function (max) { + max = this._fromUnits(max); + this._scaler.max = max; + } + }); + /** + * The type of the oscillator: sine, square, sawtooth, triangle. + * @memberOf Tone.LFO# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.LFO.prototype, 'type', { + get: function () { + return this._oscillator.type; + }, + set: function (type) { + this._oscillator.type = type; + this._stoppedValue = this._oscillator._getInitialValue(); + this._stoppedSignal.value = this._stoppedValue; + } + }); + /** + * The phase of the LFO. + * @memberOf Tone.LFO# + * @type {number} + * @name phase + */ + Object.defineProperty(Tone.LFO.prototype, 'phase', { + get: function () { + return this._oscillator.phase; + }, + set: function (phase) { + this._oscillator.phase = phase; + this._stoppedValue = this._oscillator._getInitialValue(); + this._stoppedSignal.value = this._stoppedValue; + } + }); + /** + * The output units of the LFO. + * @memberOf Tone.LFO# + * @type {Tone.Type} + * @name units + */ + Object.defineProperty(Tone.LFO.prototype, 'units', { + get: function () { + return this._units; + }, + set: function (val) { + var currentMin = this.min; + var currentMax = this.max; + //convert the min and the max + this._units = val; + this.min = currentMin; + this.max = currentMax; + } + }); + /** + * Mute the output. + * @memberOf Tone.LFO# + * @type {Boolean} + * @name mute + */ + Object.defineProperty(Tone.LFO.prototype, 'mute', { + get: function () { + return this._oscillator.mute; + }, + set: function (mute) { + this._oscillator.mute = mute; + } + }); + /** + * Returns the playback state of the source, either "started" or "stopped". + * @type {Tone.State} + * @readOnly + * @memberOf Tone.LFO# + * @name state + */ + Object.defineProperty(Tone.LFO.prototype, 'state', { + get: function () { + return this._oscillator.state; + } + }); + /** + * Connect the output of the LFO to an AudioParam, AudioNode, or Tone Node. + * Tone.LFO will automatically convert to the destination units of the + * will get the units from the connected node. + * @param {Tone | AudioParam | AudioNode} node + * @param {number} [outputNum=0] optionally which output to connect from + * @param {number} [inputNum=0] optionally which input to connect to + * @returns {Tone.LFO} this + * @private + */ + Tone.LFO.prototype.connect = function (node) { + if (node.constructor === Tone.Signal || node.constructor === Tone.Param) { + this.convert = node.convert; + this.units = node.units; + } + Tone.SignalBase.prototype.connect.apply(this, arguments); + return this; + }; + /** + * private method borrowed from Param converts + * units from their destination value + * @function + * @private + */ + Tone.LFO.prototype._fromUnits = Tone.Param.prototype._fromUnits; + /** + * private method borrowed from Param converts + * units to their destination value + * @function + * @private + */ + Tone.LFO.prototype._toUnits = Tone.Param.prototype._toUnits; + /** + * disconnect and dispose + * @returns {Tone.LFO} this + */ + Tone.LFO.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable([ + 'amplitude', + 'frequency' + ]); + this._oscillator.dispose(); + this._oscillator = null; + this._stoppedSignal.dispose(); + this._stoppedSignal = null; + this._zeros.dispose(); + this._zeros = null; + this._scaler.dispose(); + this._scaler = null; + this._a2g.dispose(); + this._a2g = null; + this.frequency = null; + this.amplitude = null; + return this; + }; + return Tone.LFO; + }); + Module(function (Tone) { + + /** + * @class Tone.Limiter will limit the loudness of an incoming signal. + * It is composed of a Tone.Compressor with a fast attack + * and release. Limiters are commonly used to safeguard against + * signal clipping. Unlike a compressor, limiters do not provide + * smooth gain reduction and almost completely prevent + * additional gain above the threshold. + * + * @extends {Tone.AudioNode} + * @constructor + * @param {number} threshold The theshold above which the limiting is applied. + * @example + * var limiter = new Tone.Limiter(-6); + */ + Tone.Limiter = function () { + var options = Tone.defaults(arguments, ['threshold'], Tone.Limiter); + Tone.AudioNode.call(this); + /** + * the compressor + * @private + * @type {Tone.Compressor} + */ + this._compressor = this.input = this.output = new Tone.Compressor({ + 'attack': 0.001, + 'decay': 0.001, + 'threshold': options.threshold + }); + /** + * The threshold of of the limiter + * @type {Decibel} + * @signal + */ + this.threshold = this._compressor.threshold; + this._readOnly('threshold'); + }; + Tone.extend(Tone.Limiter, Tone.AudioNode); + /** + * The default value + * @type {Object} + * @const + * @static + */ + Tone.Limiter.defaults = { 'threshold': -12 }; + /** + * Clean up. + * @returns {Tone.Limiter} this + */ + Tone.Limiter.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._compressor.dispose(); + this._compressor = null; + this._writable('threshold'); + this.threshold = null; + return this; + }; + return Tone.Limiter; + }); + Module(function (Tone) { + + /** + * @class Tone.Lowpass is a lowpass feedback comb filter. It is similar to + * Tone.FeedbackCombFilter, but includes a lowpass filter. + * + * @extends {Tone.AudioNode} + * @constructor + * @param {Time|Object} [delayTime] The delay time of the comb filter + * @param {NormalRange=} resonance The resonance (feedback) of the comb filter + * @param {Frequency=} dampening The cutoff of the lowpass filter dampens the + * signal as it is fedback. + */ + Tone.LowpassCombFilter = function () { + var options = Tone.defaults(arguments, [ + 'delayTime', + 'resonance', + 'dampening' + ], Tone.LowpassCombFilter); + Tone.AudioNode.call(this); + this.createInsOuts(1, 1); + /** + * the delay node + * @type {DelayNode} + * @private + */ + this._delay = this.input = new Tone.Delay(options.delayTime); + /** + * The delayTime of the comb filter. + * @type {Time} + * @signal + */ + this.delayTime = this._delay.delayTime; + /** + * the lowpass filter + * @type {BiquadFilterNode} + * @private + */ + this._lowpass = this.output = this.context.createBiquadFilter(); + this._lowpass.Q.value = -3.0102999566398125; + this._lowpass.type = 'lowpass'; + /** + * The dampening control of the feedback + * @type {Frequency} + * @signal + */ + this.dampening = new Tone.Param({ + 'param': this._lowpass.frequency, + 'units': Tone.Type.Frequency, + 'value': options.dampening + }); + /** + * the feedback gain + * @type {Tone.Gain} + * @private + */ + this._feedback = new Tone.Gain(options.resonance, Tone.Type.NormalRange); + /** + * The amount of feedback of the delayed signal. + * @type {NormalRange} + * @signal + */ + this.resonance = this._feedback.gain; + //connections + this._delay.chain(this._lowpass, this._feedback, this._delay); + this._readOnly([ + 'dampening', + 'resonance', + 'delayTime' + ]); + }; + Tone.extend(Tone.LowpassCombFilter, Tone.AudioNode); + /** + * the default parameters + * @static + * @const + * @type {Object} + */ + Tone.LowpassCombFilter.defaults = { + 'delayTime': 0.1, + 'resonance': 0.5, + 'dampening': 3000 + }; + /** + * Clean up. + * @returns {Tone.LowpassCombFilter} this + */ + Tone.LowpassCombFilter.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable([ + 'dampening', + 'resonance', + 'delayTime' + ]); + this.dampening.dispose(); + this.dampening = null; + this.resonance.dispose(); + this.resonance = null; + this._delay.dispose(); + this._delay = null; + this.delayTime = null; + this._lowpass.disconnect(); + this._lowpass = null; + this._feedback.disconnect(); + this._feedback = null; + return this; + }; + return Tone.LowpassCombFilter; + }); + Module(function (Tone) { + + /** + * @class Tone.Merge brings two signals into the left and right + * channels of a single stereo channel. + * + * @constructor + * @extends {Tone.AudioNode} + * @example + * var merge = new Tone.Merge().toMaster(); + * //routing a sine tone in the left channel + * //and noise in the right channel + * var osc = new Tone.Oscillator().connect(merge.left); + * var noise = new Tone.Noise().connect(merge.right); + * //starting our oscillators + * noise.start(); + * osc.start(); + */ + Tone.Merge = function () { + Tone.AudioNode.call(this); + this.createInsOuts(2, 0); + /** + * The left input channel. + * Alias for <code>input[0]</code> + * @type {GainNode} + */ + this.left = this.input[0] = new Tone.Gain(); + /** + * The right input channel. + * Alias for <code>input[1]</code>. + * @type {GainNode} + */ + this.right = this.input[1] = new Tone.Gain(); + /** + * the merger node for the two channels + * @type {ChannelMergerNode} + * @private + */ + this._merger = this.output = this.context.createChannelMerger(2); + //connections + this.left.connect(this._merger, 0, 0); + this.right.connect(this._merger, 0, 1); + this.left.channelCount = 1; + this.right.channelCount = 1; + this.left.channelCountMode = 'explicit'; + this.right.channelCountMode = 'explicit'; + }; + Tone.extend(Tone.Merge, Tone.AudioNode); + /** + * Clean up. + * @returns {Tone.Merge} this + */ + Tone.Merge.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this.left.dispose(); + this.left = null; + this.right.dispose(); + this.right = null; + this._merger.disconnect(); + this._merger = null; + return this; + }; + return Tone.Merge; + }); + Module(function (Tone) { + + /** + * @class Tone.Meter gets the [RMS](https://en.wikipedia.org/wiki/Root_mean_square) + * of an input signal with some averaging applied. It can also get the raw + * value of the input signal. + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Number} smoothing The amount of smoothing applied between frames. + * @example + * var meter = new Tone.Meter(); + * var mic = new Tone.UserMedia().open(); + * //connect mic to the meter + * mic.connect(meter); + * //the current level of the mic input in decibels + * var level = meter.getValue(); + */ + Tone.Meter = function () { + var options = Tone.defaults(arguments, ['smoothing'], Tone.Meter); + Tone.AudioNode.call(this); + /** + * The analyser node which computes the levels. + * @private + * @type {Tone.Analyser} + */ + this.input = this.output = this._analyser = new Tone.Analyser('waveform', 1024); + /** + * The amount of carryover between the current and last frame. + * Only applied meter for "level" type. + * @type {Number} + */ + this.smoothing = options.smoothing; + }; + Tone.extend(Tone.Meter, Tone.AudioNode); + /** + * The defaults + * @type {Object} + * @static + * @const + */ + Tone.Meter.defaults = { 'smoothing': 0.8 }; + /** + * Get the current decibel value of the incoming signal + * @returns {Decibels} + */ + Tone.Meter.prototype.getLevel = function () { + this._analyser.type = 'fft'; + var values = this._analyser.getValue(); + var offset = 28; + // normalizes most signal levels + // TODO: compute loudness from FFT + return Math.max.apply(this, values) + offset; + }; + /** + * Get the signal value of the incoming signal + * @returns {Number} + */ + Tone.Meter.prototype.getValue = function () { + this._analyser.type = 'waveform'; + var value = this._analyser.getValue(); + return value[0]; + }; + /** + * A value from 0 -> 1 where 0 represents no time averaging with the last analysis frame. + * @memberOf Tone.Meter# + * @type {Number} + * @name smoothing + * @readOnly + */ + Object.defineProperty(Tone.Meter.prototype, 'smoothing', { + get: function () { + return this._analyser.smoothing; + }, + set: function (val) { + this._analyser.smoothing = val; + } + }); + /** + * Clean up. + * @returns {Tone.Meter} this + */ + Tone.Meter.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._analyser.dispose(); + this._analyser = null; + return this; + }; + return Tone.Meter; + }); + Module(function (Tone) { + + /** + * @class Tone.Split splits an incoming signal into left and right channels. + * + * @constructor + * @extends {Tone.AudioNode} + * @example + * var split = new Tone.Split(); + * stereoSignal.connect(split); + */ + Tone.Split = function () { + Tone.AudioNode.call(this); + this.createInsOuts(0, 2); + /** + * @type {ChannelSplitterNode} + * @private + */ + this._splitter = this.input = this.context.createChannelSplitter(2); + this._splitter.channelCount = 2; + this._splitter.channelCountMode = 'explicit'; + /** + * Left channel output. + * Alias for <code>output[0]</code> + * @type {Tone.Gain} + */ + this.left = this.output[0] = new Tone.Gain(); + /** + * Right channel output. + * Alias for <code>output[1]</code> + * @type {Tone.Gain} + */ + this.right = this.output[1] = new Tone.Gain(); + //connections + this._splitter.connect(this.left, 0, 0); + this._splitter.connect(this.right, 1, 0); + }; + Tone.extend(Tone.Split, Tone.AudioNode); + /** + * Clean up. + * @returns {Tone.Split} this + */ + Tone.Split.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._splitter.disconnect(); + this.left.dispose(); + this.left = null; + this.right.dispose(); + this.right = null; + this._splitter = null; + return this; + }; + return Tone.Split; + }); + Module(function (Tone) { + + /** + * @class Mid/Side processing separates the the 'mid' signal + * (which comes out of both the left and the right channel) + * and the 'side' (which only comes out of the the side channels). <br><br> + * <code> + * Mid = (Left+Right)/sqrt(2); // obtain mid-signal from left and right<br> + * Side = (Left-Right)/sqrt(2); // obtain side-signal from left and righ<br> + * </code> + * + * @extends {Tone.AudioNode} + * @constructor + */ + Tone.MidSideSplit = function () { + Tone.AudioNode.call(this); + this.createInsOuts(0, 2); + /** + * split the incoming signal into left and right channels + * @type {Tone.Split} + * @private + */ + this._split = this.input = new Tone.Split(); + /** + * The mid send. Connect to mid processing. Alias for + * <code>output[0]</code> + * @type {Tone.Add} + */ + this._midAdd = new Tone.Add(); + /** + * Multiply the _midAdd by sqrt(1/2) + * @type {Tone.Multiply} + */ + this.mid = this.output[0] = new Tone.Multiply(Math.SQRT1_2); + /** + * The side output. Connect to side processing. Also Output 1 + * @type {Tone.Subtract} + */ + this._sideSubtract = new Tone.Subtract(); + /** + * Multiply the _midAdd by sqrt(1/2) + * @type {Tone.Multiply} + */ + this.side = this.output[1] = new Tone.Multiply(Math.SQRT1_2); + this._split.connect(this._midAdd, 0, 0); + this._split.connect(this._midAdd, 1, 1); + this._split.connect(this._sideSubtract, 0, 0); + this._split.connect(this._sideSubtract, 1, 1); + this._midAdd.connect(this.mid); + this._sideSubtract.connect(this.side); + }; + Tone.extend(Tone.MidSideSplit, Tone.AudioNode); + /** + * clean up + * @returns {Tone.MidSideSplit} this + */ + Tone.MidSideSplit.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this.mid.dispose(); + this.mid = null; + this.side.dispose(); + this.side = null; + this._midAdd.dispose(); + this._midAdd = null; + this._sideSubtract.dispose(); + this._sideSubtract = null; + this._split.dispose(); + this._split = null; + return this; + }; + return Tone.MidSideSplit; + }); + Module(function (Tone) { + + /** + * @class Mid/Side processing separates the the 'mid' signal + * (which comes out of both the left and the right channel) + * and the 'side' (which only comes out of the the side channels). + * MidSideMerge merges the mid and side signal after they've been seperated + * by Tone.MidSideSplit.<br><br> + * <code> + * Left = (Mid+Side)/sqrt(2); // obtain left signal from mid and side<br> + * Right = (Mid-Side)/sqrt(2); // obtain right signal from mid and side<br> + * </code> + * + * @extends {Tone.AudioNode} + * @constructor + */ + Tone.MidSideMerge = function () { + Tone.AudioNode.call(this); + this.createInsOuts(2, 0); + /** + * The mid signal input. Alias for + * <code>input[0]</code> + * @type {Tone.Gain} + */ + this.mid = this.input[0] = new Tone.Gain(); + /** + * recombine the mid/side into Left + * @type {Tone.Add} + * @private + */ + this._left = new Tone.Add(); + /** + * Multiply the left by sqrt(1/2) + * @type {Tone.Multiply} + */ + this._timesTwoLeft = new Tone.Multiply(Math.SQRT1_2); + /** + * The side signal input. Alias for + * <code>input[1]</code> + * @type {Tone.Gain} + */ + this.side = this.input[1] = new Tone.Gain(); + /** + * recombine the mid/side into Right + * @type {Tone.Subtract} + * @private + */ + this._right = new Tone.Subtract(); + /** + * Multiply the right by sqrt(1/2) + * @type {Tone.Multiply} + */ + this._timesTwoRight = new Tone.Multiply(Math.SQRT1_2); + /** + * Merge the left/right signal back into a stereo signal. + * @type {Tone.Merge} + * @private + */ + this._merge = this.output = new Tone.Merge(); + this.mid.connect(this._left, 0, 0); + this.side.connect(this._left, 0, 1); + this.mid.connect(this._right, 0, 0); + this.side.connect(this._right, 0, 1); + this._left.connect(this._timesTwoLeft); + this._right.connect(this._timesTwoRight); + this._timesTwoLeft.connect(this._merge, 0, 0); + this._timesTwoRight.connect(this._merge, 0, 1); + }; + Tone.extend(Tone.MidSideMerge, Tone.AudioNode); + /** + * clean up + * @returns {Tone.MidSideMerge} this + */ + Tone.MidSideMerge.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this.mid.dispose(); + this.mid = null; + this.side.dispose(); + this.side = null; + this._left.dispose(); + this._left = null; + this._timesTwoLeft.dispose(); + this._timesTwoLeft = null; + this._right.dispose(); + this._right = null; + this._timesTwoRight.dispose(); + this._timesTwoRight = null; + this._merge.dispose(); + this._merge = null; + return this; + }; + return Tone.MidSideMerge; + }); + Module(function (Tone) { + + /** + * @class Tone.MidSideCompressor applies two different compressors to the mid + * and side signal components. See Tone.MidSideSplit. + * + * @extends {Tone.AudioNode} + * @param {Object} options The options that are passed to the mid and side + * compressors. + * @constructor + */ + Tone.MidSideCompressor = function (options) { + Tone.AudioNode.call(this); + options = Tone.defaultArg(options, Tone.MidSideCompressor.defaults); + /** + * the mid/side split + * @type {Tone.MidSideSplit} + * @private + */ + this._midSideSplit = this.input = new Tone.MidSideSplit(); + /** + * the mid/side recombination + * @type {Tone.MidSideMerge} + * @private + */ + this._midSideMerge = this.output = new Tone.MidSideMerge(); + /** + * The compressor applied to the mid signal + * @type {Tone.Compressor} + */ + this.mid = new Tone.Compressor(options.mid); + /** + * The compressor applied to the side signal + * @type {Tone.Compressor} + */ + this.side = new Tone.Compressor(options.side); + this._midSideSplit.mid.chain(this.mid, this._midSideMerge.mid); + this._midSideSplit.side.chain(this.side, this._midSideMerge.side); + this._readOnly([ + 'mid', + 'side' + ]); + }; + Tone.extend(Tone.MidSideCompressor, Tone.AudioNode); + /** + * @const + * @static + * @type {Object} + */ + Tone.MidSideCompressor.defaults = { + 'mid': { + 'ratio': 3, + 'threshold': -24, + 'release': 0.03, + 'attack': 0.02, + 'knee': 16 + }, + 'side': { + 'ratio': 6, + 'threshold': -30, + 'release': 0.25, + 'attack': 0.03, + 'knee': 10 + } + }; + /** + * Clean up. + * @returns {Tone.MidSideCompressor} this + */ + Tone.MidSideCompressor.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable([ + 'mid', + 'side' + ]); + this.mid.dispose(); + this.mid = null; + this.side.dispose(); + this.side = null; + this._midSideSplit.dispose(); + this._midSideSplit = null; + this._midSideMerge.dispose(); + this._midSideMerge = null; + return this; + }; + return Tone.MidSideCompressor; + }); + Module(function (Tone) { + + /** + * @class Tone.Mono coerces the incoming mono or stereo signal into a mono signal + * where both left and right channels have the same value. This can be useful + * for [stereo imaging](https://en.wikipedia.org/wiki/Stereo_imaging). + * + * @extends {Tone.AudioNode} + * @constructor + */ + Tone.Mono = function () { + Tone.AudioNode.call(this); + this.createInsOuts(1, 0); + /** + * merge the signal + * @type {Tone.Merge} + * @private + */ + this._merge = this.output = new Tone.Merge(); + this.input.connect(this._merge, 0, 0); + this.input.connect(this._merge, 0, 1); + }; + Tone.extend(Tone.Mono, Tone.AudioNode); + /** + * clean up + * @returns {Tone.Mono} this + */ + Tone.Mono.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._merge.dispose(); + this._merge = null; + return this; + }; + return Tone.Mono; + }); + Module(function (Tone) { + + /** + * @class A compressor with seperate controls over low/mid/high dynamics + * + * @extends {Tone.AudioNode} + * @constructor + * @param {Object} options The low/mid/high compressor settings. + * @example + * var multiband = new Tone.MultibandCompressor({ + * "lowFrequency" : 200, + * "highFrequency" : 1300 + * "low" : { + * "threshold" : -12 + * } + * }) + */ + Tone.MultibandCompressor = function (options) { + Tone.AudioNode.call(this); + options = Tone.defaultArg(arguments, Tone.MultibandCompressor.defaults); + /** + * split the incoming signal into high/mid/low + * @type {Tone.MultibandSplit} + * @private + */ + this._splitter = this.input = new Tone.MultibandSplit({ + 'lowFrequency': options.lowFrequency, + 'highFrequency': options.highFrequency + }); + /** + * low/mid crossover frequency. + * @type {Frequency} + * @signal + */ + this.lowFrequency = this._splitter.lowFrequency; + /** + * mid/high crossover frequency. + * @type {Frequency} + * @signal + */ + this.highFrequency = this._splitter.highFrequency; + /** + * the output + * @type {Tone.Gain} + * @private + */ + this.output = new Tone.Gain(); + /** + * The compressor applied to the low frequencies. + * @type {Tone.Compressor} + */ + this.low = new Tone.Compressor(options.low); + /** + * The compressor applied to the mid frequencies. + * @type {Tone.Compressor} + */ + this.mid = new Tone.Compressor(options.mid); + /** + * The compressor applied to the high frequencies. + * @type {Tone.Compressor} + */ + this.high = new Tone.Compressor(options.high); + //connect the compressor + this._splitter.low.chain(this.low, this.output); + this._splitter.mid.chain(this.mid, this.output); + this._splitter.high.chain(this.high, this.output); + this._readOnly([ + 'high', + 'mid', + 'low', + 'highFrequency', + 'lowFrequency' + ]); + }; + Tone.extend(Tone.MultibandCompressor, Tone.AudioNode); + /** + * @const + * @static + * @type {Object} + */ + Tone.MultibandCompressor.defaults = { + 'low': Tone.Compressor.defaults, + 'mid': Tone.Compressor.defaults, + 'high': Tone.Compressor.defaults, + 'lowFrequency': 250, + 'highFrequency': 2000 + }; + /** + * clean up + * @returns {Tone.MultibandCompressor} this + */ + Tone.MultibandCompressor.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._splitter.dispose(); + this._writable([ + 'high', + 'mid', + 'low', + 'highFrequency', + 'lowFrequency' + ]); + this.low.dispose(); + this.mid.dispose(); + this.high.dispose(); + this._splitter = null; + this.low = null; + this.mid = null; + this.high = null; + this.lowFrequency = null; + this.highFrequency = null; + return this; + }; + return Tone.MultibandCompressor; + }); + Module(function (Tone) { + if (Tone.supported && !window.StereoPannerNode) { + /** + * @class Shimmed StereoPannerNode + * @param {AudioContext} context + * @private + */ + var StereoPannerNode = function (context) { + /** + * The audio context + * @type {AudioContext} + */ + this.context = context; + /** + * The left/right panning. [-1, 1] + * @type {AudioRange} + * @signal + */ + this.pan = new Tone.Signal(0, Tone.Type.AudioRange); + /** + * Equal power scaling of the right gain + * @type {Tone.WaveShaper} + */ + var rightWaveShaper = new Tone.WaveShaper(function (val) { + return Tone.equalPowerScale((val + 1) / 2); + }, 4096); + /** + * Equal power scaling of the left gain + * @type {Tone.WaveShaper} + * @private + */ + var leftWaveShaper = new Tone.WaveShaper(function (val) { + return Tone.equalPowerScale(1 - (val + 1) / 2); + }, 4096); + /** + * The left gain value + * @type {Tone.Gain} + * @private + */ + var leftGain = new Tone.Gain(); + /** + * The right gain value + * @type {Tone.Gain} + * @private + */ + var rightGain = new Tone.Gain(); + /** + * Split the incoming signal + * @type {Tone.Split} + * @private + */ + var split = this.input = new Tone.Split(); + /** + * Keeps the waveshapers from optimizing 0s + * @type {Tone.Zero} + * @private + */ + var zero = new Tone.Zero(); + zero.fan(rightWaveShaper, leftWaveShaper); + /** + * Merge the outgoing signal + * @type {Tone.Merge} + * @private + */ + var merge = this.output = new Tone.Merge(); + //connections + split.left.chain(leftGain, merge.left); + split.right.chain(rightGain, merge.right); + this.pan.chain(leftWaveShaper, leftGain.gain); + this.pan.chain(rightWaveShaper, rightGain.gain); + }; + StereoPannerNode.prototype.disconnect = function () { + this.output.disconnect.apply(this.output, arguments); + }; + StereoPannerNode.prototype.connect = function () { + this.output.connect.apply(this.output, arguments); + }; + //add it to the AudioContext + AudioContext.prototype.createStereoPanner = function () { + return new StereoPannerNode(this); + }; + Tone.Context.prototype.createStereoPanner = function () { + return new StereoPannerNode(this); + }; + } + }); + Module(function (Tone) { + + /** + * @class Tone.Panner is an equal power Left/Right Panner and does not + * support 3D. Panner uses the StereoPannerNode when available. + * + * @constructor + * @extends {Tone.AudioNode} + * @param {NormalRange} [initialPan=0] The initail panner value (center). + * @example + * //pan the input signal hard right. + * var panner = new Tone.Panner(1); + */ + Tone.Panner = function (initialPan) { + Tone.AudioNode.call(this); + /** + * the panner node + * @type {StereoPannerNode} + * @private + */ + this._panner = this.input = this.output = this.context.createStereoPanner(); + /** + * The pan control. -1 = hard left, 1 = hard right. + * @type {AudioRange} + * @signal + */ + this.pan = this._panner.pan; + //initial value + this.pan.value = Tone.defaultArg(initialPan, 0); + this._readOnly('pan'); + }; + Tone.extend(Tone.Panner, Tone.AudioNode); + /** + * Clean up. + * @returns {Tone.Panner} this + */ + Tone.Panner.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable('pan'); + this._panner.disconnect(); + this._panner = null; + this.pan = null; + return this; + }; + return Tone.Panner; + }); + Module(function (Tone) { + + /** + * @class A spatialized panner node which supports equalpower or HRTF panning. + * Tries to normalize the API across various browsers. See Tone.Listener + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Number} positionX The initial x position. + * @param {Number} positionY The initial y position. + * @param {Number} positionZ The initial z position. + */ + Tone.Panner3D = function () { + var options = Tone.defaults(arguments, [ + 'positionX', + 'positionY', + 'positionZ' + ], Tone.Panner3D); + Tone.AudioNode.call(this); + /** + * The panner node + * @type {PannerNode} + * @private + */ + this._panner = this.input = this.output = this.context.createPanner(); + //set some values + this._panner.panningModel = options.panningModel; + this._panner.maxDistance = options.maxDistance; + this._panner.distanceModel = options.distanceModel; + this._panner.coneOuterGain = options.coneOuterGain; + this._panner.coneOuterAngle = options.coneOuterAngle; + this._panner.coneInnerAngle = options.coneInnerAngle; + this._panner.refDistance = options.refDistance; + this._panner.rolloffFactor = options.rolloffFactor; + /** + * Holds the current orientation + * @type {Array} + * @private + */ + this._orientation = [ + options.orientationX, + options.orientationY, + options.orientationZ + ]; + /** + * Holds the current position + * @type {Array} + * @private + */ + this._position = [ + options.positionX, + options.positionY, + options.positionZ + ]; + // set the default position/orientation + this.orientationX = options.orientationX; + this.orientationY = options.orientationY; + this.orientationZ = options.orientationZ; + this.positionX = options.positionX; + this.positionY = options.positionY; + this.positionZ = options.positionZ; + }; + Tone.extend(Tone.Panner3D, Tone.AudioNode); + /** + * Defaults according to the specification + * @static + * @const + * @type {Object} + */ + Tone.Panner3D.defaults = { + 'positionX': 0, + 'positionY': 0, + 'positionZ': 0, + 'orientationX': 0, + 'orientationY': 0, + 'orientationZ': 0, + 'panningModel': 'equalpower', + 'maxDistance': 10000, + 'distanceModel': 'inverse', + 'coneOuterGain': 0, + 'coneOuterAngle': 360, + 'coneInnerAngle': 360, + 'refDistance': 1, + 'rolloffFactor': 1 + }; + /** + * The ramp time which is applied to the setTargetAtTime + * @type {Number} + * @private + */ + Tone.Panner3D.prototype._rampTimeConstant = 0.01; + /** + * Sets the position of the source in 3d space. + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @return {Tone.Panner3D} this + */ + Tone.Panner3D.prototype.setPosition = function (x, y, z) { + if (this._panner.positionX) { + var now = this.now(); + this._panner.positionX.setTargetAtTime(x, now, this._rampTimeConstant); + this._panner.positionY.setTargetAtTime(y, now, this._rampTimeConstant); + this._panner.positionZ.setTargetAtTime(z, now, this._rampTimeConstant); + } else { + this._panner.setPosition(x, y, z); + } + this._position = Array.prototype.slice.call(arguments); + return this; + }; + /** + * Sets the orientation of the source in 3d space. + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @return {Tone.Panner3D} this + */ + Tone.Panner3D.prototype.setOrientation = function (x, y, z) { + if (this._panner.orientationX) { + var now = this.now(); + this._panner.orientationX.setTargetAtTime(x, now, this._rampTimeConstant); + this._panner.orientationY.setTargetAtTime(y, now, this._rampTimeConstant); + this._panner.orientationZ.setTargetAtTime(z, now, this._rampTimeConstant); + } else { + this._panner.setOrientation(x, y, z); + } + this._orientation = Array.prototype.slice.call(arguments); + return this; + }; + /** + * The x position of the panner object. + * @type {Number} + * @memberOf Tone.Panner3D# + * @name positionX + */ + Object.defineProperty(Tone.Panner3D.prototype, 'positionX', { + set: function (pos) { + this._position[0] = pos; + this.setPosition.apply(this, this._position); + }, + get: function () { + return this._position[0]; + } + }); + /** + * The y position of the panner object. + * @type {Number} + * @memberOf Tone.Panner3D# + * @name positionY + */ + Object.defineProperty(Tone.Panner3D.prototype, 'positionY', { + set: function (pos) { + this._position[1] = pos; + this.setPosition.apply(this, this._position); + }, + get: function () { + return this._position[1]; + } + }); + /** + * The z position of the panner object. + * @type {Number} + * @memberOf Tone.Panner3D# + * @name positionZ + */ + Object.defineProperty(Tone.Panner3D.prototype, 'positionZ', { + set: function (pos) { + this._position[2] = pos; + this.setPosition.apply(this, this._position); + }, + get: function () { + return this._position[2]; + } + }); + /** + * The x orientation of the panner object. + * @type {Number} + * @memberOf Tone.Panner3D# + * @name orientationX + */ + Object.defineProperty(Tone.Panner3D.prototype, 'orientationX', { + set: function (pos) { + this._orientation[0] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[0]; + } + }); + /** + * The y orientation of the panner object. + * @type {Number} + * @memberOf Tone.Panner3D# + * @name orientationY + */ + Object.defineProperty(Tone.Panner3D.prototype, 'orientationY', { + set: function (pos) { + this._orientation[1] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[1]; + } + }); + /** + * The z orientation of the panner object. + * @type {Number} + * @memberOf Tone.Panner3D# + * @name orientationZ + */ + Object.defineProperty(Tone.Panner3D.prototype, 'orientationZ', { + set: function (pos) { + this._orientation[2] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[2]; + } + }); + /** + * Proxy a property on the panner to an exposed public propery + * @param {String} prop + * @private + */ + Tone.Panner3D._aliasProperty = function (prop) { + Object.defineProperty(Tone.Panner3D.prototype, prop, { + set: function (val) { + this._panner[prop] = val; + }, + get: function () { + return this._panner[prop]; + } + }); + }; + /** + * The panning model. Either "equalpower" or "HRTF". + * @type {String} + * @memberOf Tone.Panner3D# + * @name panningModel + */ + Tone.Panner3D._aliasProperty('panningModel'); + /** + * A reference distance for reducing volume as source move further from the listener + * @type {Number} + * @memberOf Tone.Panner3D# + * @name refDistance + */ + Tone.Panner3D._aliasProperty('refDistance'); + /** + * Describes how quickly the volume is reduced as source moves away from listener. + * @type {Number} + * @memberOf Tone.Panner3D# + * @name rolloffFactor + */ + Tone.Panner3D._aliasProperty('rolloffFactor'); + /** + * The distance model used by, "linear", "inverse", or "exponential". + * @type {String} + * @memberOf Tone.Panner3D# + * @name distanceModel + */ + Tone.Panner3D._aliasProperty('distanceModel'); + /** + * The angle, in degrees, inside of which there will be no volume reduction + * @type {Degrees} + * @memberOf Tone.Panner3D# + * @name coneInnerAngle + */ + Tone.Panner3D._aliasProperty('coneInnerAngle'); + /** + * The angle, in degrees, outside of which the volume will be reduced + * to a constant value of coneOuterGain + * @type {Degrees} + * @memberOf Tone.Panner3D# + * @name coneOuterAngle + */ + Tone.Panner3D._aliasProperty('coneOuterAngle'); + /** + * The gain outside of the coneOuterAngle + * @type {Gain} + * @memberOf Tone.Panner3D# + * @name coneOuterGain + */ + Tone.Panner3D._aliasProperty('coneOuterGain'); + /** + * The maximum distance between source and listener, + * after which the volume will not be reduced any further. + * @type {Positive} + * @memberOf Tone.Panner3D# + * @name maxDistance + */ + Tone.Panner3D._aliasProperty('maxDistance'); + /** + * Clean up. + * @returns {Tone.Panner3D} this + */ + Tone.Panner3D.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._panner.disconnect(); + this._panner = null; + this._orientation = null; + this._position = null; + return this; + }; + return Tone.Panner3D; + }); + Module(function (Tone) { + + /** + * @class Tone.PanVol is a Tone.Panner and Tone.Volume in one. + * + * @extends {Tone.AudioNode} + * @constructor + * @param {AudioRange} pan the initial pan + * @param {number} volume The output volume. + * @example + * //pan the incoming signal left and drop the volume + * var panVol = new Tone.PanVol(-0.25, -12); + */ + Tone.PanVol = function () { + var options = Tone.defaults(arguments, [ + 'pan', + 'volume' + ], Tone.PanVol); + Tone.AudioNode.call(this); + /** + * The panning node + * @type {Tone.Panner} + * @private + */ + this._panner = this.input = new Tone.Panner(options.pan); + /** + * The L/R panning control. + * @type {AudioRange} + * @signal + */ + this.pan = this._panner.pan; + /** + * The volume node + * @type {Tone.Volume} + * @private + */ + this._volume = this.output = new Tone.Volume(options.volume); + /** + * The volume control in decibels. + * @type {Decibels} + * @signal + */ + this.volume = this._volume.volume; + //connections + this._panner.connect(this._volume); + this.mute = options.mute; + this._readOnly([ + 'pan', + 'volume' + ]); + }; + Tone.extend(Tone.PanVol, Tone.AudioNode); + /** + * The defaults + * @type {Object} + * @const + * @static + */ + Tone.PanVol.defaults = { + 'pan': 0, + 'volume': 0, + 'mute': false + }; + /** + * Mute/unmute the volume + * @memberOf Tone.PanVol# + * @name mute + * @type {Boolean} + */ + Object.defineProperty(Tone.PanVol.prototype, 'mute', { + get: function () { + return this._volume.mute; + }, + set: function (mute) { + this._volume.mute = mute; + } + }); + /** + * clean up + * @returns {Tone.PanVol} this + */ + Tone.PanVol.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._writable([ + 'pan', + 'volume' + ]); + this._panner.dispose(); + this._panner = null; + this.pan = null; + this._volume.dispose(); + this._volume = null; + this.volume = null; + return this; + }; + return Tone.PanVol; + }); + Module(function (Tone) { + /** + * @class Tone.Solo lets you isolate a specific audio stream. When + * an instance is set to `solo=true`, it will mute all other instances. + * @extends {Tone.AudioNode} + * @example + * var soloA = new Tone.Solo() + * var soloB = new Tone.Solo() + * soloA.solo = true + * //no audio will pass through soloB + */ + Tone.Solo = function () { + var options = Tone.defaults(arguments, ['solo'], Tone.Solo); + Tone.AudioNode.call(this); + /** + * The input and output node + * @type {Tone.Gain} + */ + this.input = this.output = new Tone.Gain(); + /** + * A bound _soloed method + * @type {Function} + * @private + */ + this._soloBind = this._soloed.bind(this); + //listen for solo events class-wide. + this.context.on('solo', this._soloBind); + //set initially + this.solo = options.solo; + }; + Tone.extend(Tone.Solo, Tone.AudioNode); + /** + * The defaults + * @type {Object} + * @static + */ + Tone.Solo.defaults = { solo: false }; + /** + * Isolates this instance and mutes all other instances of Tone.Solo. + * Only one instance can be soloed at a time. A soloed + * instance will report `solo=false` when another instance is soloed. + * @memberOf Tone.Solo# + * @type {Boolean} + * @name solo + */ + Object.defineProperty(Tone.Solo.prototype, 'solo', { + get: function () { + return this._isSoloed(); + }, + set: function (solo) { + if (solo) { + this._addSolo(); + } else { + this._removeSolo(); + } + this.context.emit('solo', this); + } + }); + /** + * If the current instance is muted, i.e. another instance is soloed + * @memberOf Tone.Solo# + * @type {Boolean} + * @name muted + * @readOnly + */ + Object.defineProperty(Tone.Solo.prototype, 'muted', { + get: function () { + return this.input.gain.value === 0; + } + }); + /** + * Add this to the soloed array + * @private + */ + Tone.Solo.prototype._addSolo = function () { + if (!Tone.isArray(this.context._currentSolo)) { + this.context._currentSolo = []; + } + if (!this._isSoloed()) { + this.context._currentSolo.push(this); + } + }; + /** + * Remove this from the soloed array + * @private + */ + Tone.Solo.prototype._removeSolo = function () { + if (this._isSoloed()) { + var index = this.context._currentSolo.indexOf(this); + this.context._currentSolo.splice(index, 1); + } + }; + /** + * @return {Boolean} Is this on the soloed array + * @private + */ + Tone.Solo.prototype._isSoloed = function () { + if (Tone.isArray(this.context._currentSolo)) { + return this.context._currentSolo.length !== 0 && this.context._currentSolo.indexOf(this) !== -1; + } else { + return false; + } + }; + /** + * @return {Boolean} Returns true if no one is soloed + * @private + */ + Tone.Solo.prototype._noSolos = function () { + return !Tone.isArray(this.context._currentSolo) || this.context._currentSolo.length === 0; + }; + /** + * Solo the current instance and unsolo all other instances. + * @param {Tone.Solo} instance The instance which is being soloed/unsoloed. + * @private + */ + Tone.Solo.prototype._soloed = function () { + if (this._isSoloed()) { + this.input.gain.value = 1; + } else if (this._noSolos()) { + //no one is soloed + this.input.gain.value = 1; + } else { + this.input.gain.value = 0; + } + }; + /** + * Clean up + * @return {Tone.Solo} this + */ + Tone.Solo.prototype.dispose = function () { + this.context.off('solo', this._soloBind); + this._removeSolo(); + this._soloBind = null; + Tone.AudioNode.prototype.dispose.call(this); + return this; + }; + return Tone.Solo; + }); + Module(function (Tone) { + /** + * @class Get the current waveform data of the connected audio source. + * @extends {Tone.AudioNode} + * @param {Number=} size The size of the FFT. Value must be a power of + * two in the range 32 to 32768. + */ + Tone.Waveform = function () { + var options = Tone.defaults(arguments, ['size'], Tone.Waveform); + options.type = Tone.Analyser.Type.Waveform; + Tone.AudioNode.call(this); + /** + * The analyser node. + * @private + * @type {Tone.Analyser} + */ + this._analyser = this.input = this.output = new Tone.Analyser(options); + }; + Tone.extend(Tone.Waveform, Tone.AudioNode); + /** + * The default values. + * @type {Object} + * @const + */ + Tone.Waveform.defaults = { 'size': 1024 }; + /** + * Gets the waveform of the audio source. Returns the waveform data + * of length [size](#size) as a Float32Array with values between -1 and 1. + * @returns {TypedArray} + */ + Tone.Waveform.prototype.getValue = function () { + return this._analyser.getValue(); + }; + /** + * The size of analysis. This must be a power of two in the range 32 to 32768. + * @memberOf Tone.Waveform# + * @type {Number} + * @name size + */ + Object.defineProperty(Tone.Waveform.prototype, 'size', { + get: function () { + return this._analyser.size; + }, + set: function (size) { + this._analyser.size = size; + } + }); + /** + * Clean up. + * @return {Tone.Waveform} this + */ + Tone.Waveform.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._analyser.dispose(); + this._analyser = null; + }; + return Tone.Waveform; + }); + Module(function (Tone) { + + /** + * @class Tone.CtrlInterpolate will interpolate between given values based + * on the "index" property. Passing in an array or object literal + * will interpolate each of the parameters. Note (i.e. "C3") + * and Time (i.e. "4n + 2") can be interpolated. All other values are + * assumed to be numbers. + * @example + * var interp = new Tone.CtrlInterpolate([0, 2, 9, 4]); + * interp.index = 0.75; + * interp.value; //returns 1.5 + * + * @example + * var interp = new Tone.CtrlInterpolate([ + * [2, 4, 5], + * [9, 3, 2], + * ]); + * @param {Array} values The array of values to interpolate over + * @param {Positive} index The initial interpolation index. + * @extends {Tone} + */ + Tone.CtrlInterpolate = function () { + var options = Tone.defaults(arguments, [ + 'values', + 'index' + ], Tone.CtrlInterpolate); + Tone.call(this); + /** + * The values to interpolate between + * @type {Array} + */ + this.values = options.values; + /** + * The interpolated index between values. For example: a value of 1.5 + * would interpolate equally between the value at index 1 + * and the value at index 2. + * @example + * interp.index = 0; + * interp.value; //returns the value at 0 + * interp.index = 0.5; + * interp.value; //returns the value between indices 0 and 1. + * @type {Positive} + */ + this.index = options.index; + }; + Tone.extend(Tone.CtrlInterpolate); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.CtrlInterpolate.defaults = { + 'index': 0, + 'values': [] + }; + /** + * The current interpolated value based on the index + * @readOnly + * @memberOf Tone.CtrlInterpolate# + * @type {*} + * @name value + */ + Object.defineProperty(Tone.CtrlInterpolate.prototype, 'value', { + get: function () { + var index = this.index; + index = Math.min(index, this.values.length - 1); + var lowerPosition = Math.floor(index); + var lower = this.values[lowerPosition]; + var upper = this.values[Math.ceil(index)]; + return this._interpolate(index - lowerPosition, lower, upper); + } + }); + /** + * Internal interpolation routine + * @param {NormalRange} index The index between the lower and upper + * @param {*} lower + * @param {*} upper + * @return {*} The interpolated value + * @private + */ + Tone.CtrlInterpolate.prototype._interpolate = function (index, lower, upper) { + if (Tone.isArray(lower)) { + var retArray = []; + for (var i = 0; i < lower.length; i++) { + retArray[i] = this._interpolate(index, lower[i], upper[i]); + } + return retArray; + } else if (Tone.isObject(lower)) { + var retObj = {}; + for (var attr in lower) { + retObj[attr] = this._interpolate(index, lower[attr], upper[attr]); + } + return retObj; + } else { + lower = this._toNumber(lower); + upper = this._toNumber(upper); + return (1 - index) * lower + index * upper; + } + }; + /** + * Convert from the given type into a number + * @param {Number|String} value + * @return {Number} + * @private + */ + Tone.CtrlInterpolate.prototype._toNumber = function (val) { + if (Tone.isNumber(val)) { + return val; + } else { + //otherwise assume that it's Time... + return this.toSeconds(val); + } + }; + /** + * Clean up + * @return {Tone.CtrlInterpolate} this + */ + Tone.CtrlInterpolate.prototype.dispose = function () { + this.values = null; + }; + return Tone.CtrlInterpolate; + }); + Module(function (Tone) { + + /** + * @class Tone.CtrlMarkov represents a Markov Chain where each call + * to Tone.CtrlMarkov.next will move to the next state. If the next + * state choice is an array, the next state is chosen randomly with + * even probability for all of the choices. For a weighted probability + * of the next choices, pass in an object with "state" and "probability" attributes. + * The probabilities will be normalized and then chosen. If no next options + * are given for the current state, the state will stay there. + * @extends {Tone} + * @example + * var chain = new Tone.CtrlMarkov({ + * "beginning" : ["end", "middle"], + * "middle" : "end" + * }); + * chain.value = "beginning"; + * chain.next(); //returns "end" or "middle" with 50% probability + * + * @example + * var chain = new Tone.CtrlMarkov({ + * "beginning" : [{"value" : "end", "probability" : 0.8}, + * {"value" : "middle", "probability" : 0.2}], + * "middle" : "end" + * }); + * chain.value = "beginning"; + * chain.next(); //returns "end" with 80% probability or "middle" with 20%. + * @param {Object} values An object with the state names as the keys + * and the next state(s) as the values. + */ + Tone.CtrlMarkov = function (values, initial) { + Tone.call(this); + /** + * The Markov values with states as the keys + * and next state(s) as the values. + * @type {Object} + */ + this.values = Tone.defaultArg(values, {}); + /** + * The current state of the Markov values. The next + * state will be evaluated and returned when Tone.CtrlMarkov.next + * is invoked. + * @type {String} + */ + this.value = Tone.defaultArg(initial, Object.keys(this.values)[0]); + }; + Tone.extend(Tone.CtrlMarkov); + /** + * Returns the next state of the Markov values. + * @return {String} + */ + Tone.CtrlMarkov.prototype.next = function () { + if (this.values.hasOwnProperty(this.value)) { + var next = this.values[this.value]; + if (Tone.isArray(next)) { + var distribution = this._getProbDistribution(next); + var rand = Math.random(); + var total = 0; + for (var i = 0; i < distribution.length; i++) { + var dist = distribution[i]; + if (rand > total && rand < total + dist) { + var chosen = next[i]; + if (Tone.isObject(chosen)) { + this.value = chosen.value; + } else { + this.value = chosen; + } + } + total += dist; + } + } else { + this.value = next; + } + } + return this.value; + }; + /** + * Choose randomly from an array weighted options in the form + * {"state" : string, "probability" : number} or an array of values + * @param {Array} options + * @return {Array} The randomly selected choice + * @private + */ + Tone.CtrlMarkov.prototype._getProbDistribution = function (options) { + var distribution = []; + var total = 0; + var needsNormalizing = false; + for (var i = 0; i < options.length; i++) { + var option = options[i]; + if (Tone.isObject(option)) { + needsNormalizing = true; + distribution[i] = option.probability; + } else { + distribution[i] = 1 / options.length; + } + total += distribution[i]; + } + if (needsNormalizing) { + //normalize the values + for (var j = 0; j < distribution.length; j++) { + distribution[j] = distribution[j] / total; + } + } + return distribution; + }; + /** + * Clean up + * @return {Tone.CtrlMarkov} this + */ + Tone.CtrlMarkov.prototype.dispose = function () { + this.values = null; + }; + return Tone.CtrlMarkov; + }); + Module(function (Tone) { + + /** + * @class Generate patterns from an array of values. + * Has a number of arpeggiation and randomized + * selection patterns. + * <ul> + * <li>"up" - cycles upward</li> + * <li>"down" - cycles downward</li> + * <li>"upDown" - up then and down</li> + * <li>"downUp" - cycles down then and up</li> + * <li>"alternateUp" - jump up two and down one</li> + * <li>"alternateDown" - jump down two and up one</li> + * <li>"random" - randomly select an index</li> + * <li>"randomWalk" - randomly moves one index away from the current position</li> + * <li>"randomOnce" - randomly select an index without repeating until all values have been chosen.</li> + * </ul> + * @param {Array} values An array of options to choose from. + * @param {Tone.CtrlPattern.Type=} type The name of the pattern. + * @extends {Tone} + */ + Tone.CtrlPattern = function () { + var options = Tone.defaults(arguments, [ + 'values', + 'type' + ], Tone.CtrlPattern); + Tone.call(this); + /** + * The array of values to arpeggiate over + * @type {Array} + */ + this.values = options.values; + /** + * The current position in the values array + * @type {Number} + */ + this.index = 0; + /** + * The type placeholder + * @type {Tone.CtrlPattern.Type} + * @private + */ + this._type = null; + /** + * Shuffled values for the RandomOnce type + * @type {Array} + * @private + */ + this._shuffled = null; + /** + * The direction of the movement + * @type {String} + * @private + */ + this._direction = null; + this.type = options.type; + }; + Tone.extend(Tone.CtrlPattern); + /** + * The Control Patterns + * @type {Object} + * @static + */ + Tone.CtrlPattern.Type = { + Up: 'up', + Down: 'down', + UpDown: 'upDown', + DownUp: 'downUp', + AlternateUp: 'alternateUp', + AlternateDown: 'alternateDown', + Random: 'random', + RandomWalk: 'randomWalk', + RandomOnce: 'randomOnce' + }; + /** + * The default values. + * @type {Object} + */ + Tone.CtrlPattern.defaults = { + 'type': Tone.CtrlPattern.Type.Up, + 'values': [] + }; + /** + * The value at the current index of the pattern. + * @readOnly + * @memberOf Tone.CtrlPattern# + * @type {*} + * @name value + */ + Object.defineProperty(Tone.CtrlPattern.prototype, 'value', { + get: function () { + //some safeguards + if (this.values.length === 0) { + return; + } else if (this.values.length === 1) { + return this.values[0]; + } + this.index = Math.min(this.index, this.values.length - 1); + var val = this.values[this.index]; + if (this.type === Tone.CtrlPattern.Type.RandomOnce) { + if (this.values.length !== this._shuffled.length) { + this._shuffleValues(); + } + val = this.values[this._shuffled[this.index]]; + } + return val; + } + }); + /** + * The pattern used to select the next + * item from the values array + * @memberOf Tone.CtrlPattern# + * @type {Tone.CtrlPattern.Type} + * @name type + */ + Object.defineProperty(Tone.CtrlPattern.prototype, 'type', { + get: function () { + return this._type; + }, + set: function (type) { + this._type = type; + this._shuffled = null; + //the first index + if (this._type === Tone.CtrlPattern.Type.Up || this._type === Tone.CtrlPattern.Type.UpDown || this._type === Tone.CtrlPattern.Type.RandomOnce || this._type === Tone.CtrlPattern.Type.AlternateUp) { + this.index = 0; + } else if (this._type === Tone.CtrlPattern.Type.Down || this._type === Tone.CtrlPattern.Type.DownUp || this._type === Tone.CtrlPattern.Type.AlternateDown) { + this.index = this.values.length - 1; + } + //the direction + if (this._type === Tone.CtrlPattern.Type.UpDown || this._type === Tone.CtrlPattern.Type.AlternateUp) { + this._direction = Tone.CtrlPattern.Type.Up; + } else if (this._type === Tone.CtrlPattern.Type.DownUp || this._type === Tone.CtrlPattern.Type.AlternateDown) { + this._direction = Tone.CtrlPattern.Type.Down; + } + //randoms + if (this._type === Tone.CtrlPattern.Type.RandomOnce) { + this._shuffleValues(); + } else if (this._type === Tone.CtrlPattern.Random) { + this.index = Math.floor(Math.random() * this.values.length); + } + } + }); + /** + * Return the next value given the current position + * and pattern. + * @return {*} The next value + */ + Tone.CtrlPattern.prototype.next = function () { + var type = this.type; + //choose the next index + if (type === Tone.CtrlPattern.Type.Up) { + this.index++; + if (this.index >= this.values.length) { + this.index = 0; + } + } else if (type === Tone.CtrlPattern.Type.Down) { + this.index--; + if (this.index < 0) { + this.index = this.values.length - 1; + } + } else if (type === Tone.CtrlPattern.Type.UpDown || type === Tone.CtrlPattern.Type.DownUp) { + if (this._direction === Tone.CtrlPattern.Type.Up) { + this.index++; + } else { + this.index--; + } + if (this.index < 0) { + this.index = 1; + this._direction = Tone.CtrlPattern.Type.Up; + } else if (this.index >= this.values.length) { + this.index = this.values.length - 2; + this._direction = Tone.CtrlPattern.Type.Down; + } + } else if (type === Tone.CtrlPattern.Type.Random) { + this.index = Math.floor(Math.random() * this.values.length); + } else if (type === Tone.CtrlPattern.Type.RandomWalk) { + if (Math.random() < 0.5) { + this.index--; + this.index = Math.max(this.index, 0); + } else { + this.index++; + this.index = Math.min(this.index, this.values.length - 1); + } + } else if (type === Tone.CtrlPattern.Type.RandomOnce) { + this.index++; + if (this.index >= this.values.length) { + this.index = 0; + //reshuffle the values for next time + this._shuffleValues(); + } + } else if (type === Tone.CtrlPattern.Type.AlternateUp) { + if (this._direction === Tone.CtrlPattern.Type.Up) { + this.index += 2; + this._direction = Tone.CtrlPattern.Type.Down; + } else { + this.index -= 1; + this._direction = Tone.CtrlPattern.Type.Up; + } + if (this.index >= this.values.length) { + this.index = 0; + this._direction = Tone.CtrlPattern.Type.Up; + } + } else if (type === Tone.CtrlPattern.Type.AlternateDown) { + if (this._direction === Tone.CtrlPattern.Type.Up) { + this.index += 1; + this._direction = Tone.CtrlPattern.Type.Down; + } else { + this.index -= 2; + this._direction = Tone.CtrlPattern.Type.Up; + } + if (this.index < 0) { + this.index = this.values.length - 1; + this._direction = Tone.CtrlPattern.Type.Down; + } + } + return this.value; + }; + /** + * Shuffles the values and places the results into the _shuffled + * @private + */ + Tone.CtrlPattern.prototype._shuffleValues = function () { + var copy = []; + this._shuffled = []; + for (var i = 0; i < this.values.length; i++) { + copy[i] = i; + } + while (copy.length > 0) { + var randVal = copy.splice(Math.floor(copy.length * Math.random()), 1); + this._shuffled.push(randVal[0]); + } + }; + /** + * Clean up + * @returns {Tone.CtrlPattern} this + */ + Tone.CtrlPattern.prototype.dispose = function () { + this._shuffled = null; + this.values = null; + }; + return Tone.CtrlPattern; + }); + Module(function (Tone) { + + /** + * @class Choose a random value. + * @extends {Tone} + * @example + * var randomWalk = new Tone.CtrlRandom({ + * "min" : 0, + * "max" : 10, + * "integer" : true + * }); + * randomWalk.eval(); + * + * @param {Number|Time=} min The minimum return value. + * @param {Number|Time=} max The maximum return value. + */ + Tone.CtrlRandom = function () { + var options = Tone.defaults(arguments, [ + 'min', + 'max' + ], Tone.CtrlRandom); + Tone.call(this); + /** + * The minimum return value + * @type {Number|Time} + */ + this.min = options.min; + /** + * The maximum return value + * @type {Number|Time} + */ + this.max = options.max; + /** + * If the return value should be an integer + * @type {Boolean} + */ + this.integer = options.integer; + }; + Tone.extend(Tone.CtrlRandom); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.CtrlRandom.defaults = { + 'min': 0, + 'max': 1, + 'integer': false + }; + /** + * Return a random value between min and max. + * @readOnly + * @memberOf Tone.CtrlRandom# + * @type {*} + * @name value + */ + Object.defineProperty(Tone.CtrlRandom.prototype, 'value', { + get: function () { + var min = this.toSeconds(this.min); + var max = this.toSeconds(this.max); + var rand = Math.random(); + var val = rand * min + (1 - rand) * max; + if (this.integer) { + val = Math.floor(val); + } + return val; + } + }); + return Tone.CtrlRandom; + }); + Module(function (Tone) { + /** + * @class A data structure for holding multiple buffers. + * + * @param {Object|Array} urls An object literal or array + * of urls to load. + * @param {Function=} callback The callback to invoke when + * the buffers are loaded. + * @extends {Tone} + * @example + * //load a whole bank of piano samples + * var pianoSamples = new Tone.Buffers({ + * "C4" : "path/to/C4.mp3" + * "C#4" : "path/to/C#4.mp3" + * "D4" : "path/to/D4.mp3" + * "D#4" : "path/to/D#4.mp3" + * ... + * }, function(){ + * //play one of the samples when they all load + * player.buffer = pianoSamples.get("C4"); + * player.start(); + * }); + * @example + * //To pass in additional parameters in the second parameter + * var buffers = new Tone.Buffers(urls, { + * "onload" : callback, + * "baseUrl" : "../path/to/audio/" + * }) + */ + Tone.Buffers = function (urls) { + //remove the urls from the options + var args = Array.prototype.slice.call(arguments); + args.shift(); + var options = Tone.defaults(args, [ + 'onload', + 'baseUrl' + ], Tone.Buffers); + Tone.call(this); + /** + * All of the buffers + * @type {Object} + * @private + */ + this._buffers = {}; + /** + * A path which is prefixed before every url. + * @type {String} + */ + this.baseUrl = options.baseUrl; + this._loadingCount = 0; + //add each one + for (var key in urls) { + this._loadingCount++; + this.add(key, urls[key], this._bufferLoaded.bind(this, options.onload)); + } + }; + Tone.extend(Tone.Buffers); + /** + * Defaults + * @type {Object} + */ + Tone.Buffers.defaults = { + 'onload': Tone.noOp, + 'baseUrl': '' + }; + /** + * True if the buffers object has a buffer by that name. + * @param {String|Number} name The key or index of the + * buffer. + * @return {Boolean} + */ + Tone.Buffers.prototype.has = function (name) { + return this._buffers.hasOwnProperty(name); + }; + /** + * Get a buffer by name. If an array was loaded, + * then use the array index. + * @param {String|Number} name The key or index of the + * buffer. + * @return {Tone.Buffer} + */ + Tone.Buffers.prototype.get = function (name) { + if (this.has(name)) { + return this._buffers[name]; + } else { + throw new Error('Tone.Buffers: no buffer named ' + name); + } + }; + /** + * A buffer was loaded. decrement the counter. + * @param {Function} callback + * @private + */ + Tone.Buffers.prototype._bufferLoaded = function (callback) { + this._loadingCount--; + if (this._loadingCount === 0 && callback) { + callback(this); + } + }; + /** + * If the buffers are loaded or not + * @memberOf Tone.Buffers# + * @type {Boolean} + * @name loaded + * @readOnly + */ + Object.defineProperty(Tone.Buffers.prototype, 'loaded', { + get: function () { + var isLoaded = true; + for (var buffName in this._buffers) { + var buff = this.get(buffName); + isLoaded = isLoaded && buff.loaded; + } + return isLoaded; + } + }); + /** + * Add a buffer by name and url to the Buffers + * @param {String} name A unique name to give + * the buffer + * @param {String|Tone.Buffer|Audiobuffer} url Either the url of the bufer, + * or a buffer which will be added + * with the given name. + * @param {Function=} callback The callback to invoke + * when the url is loaded. + */ + Tone.Buffers.prototype.add = function (name, url, callback) { + callback = Tone.defaultArg(callback, Tone.noOp); + if (url instanceof Tone.Buffer) { + this._buffers[name] = url; + callback(this); + } else if (url instanceof AudioBuffer) { + this._buffers[name] = new Tone.Buffer(url); + callback(this); + } else if (Tone.isString(url)) { + this._buffers[name] = new Tone.Buffer(this.baseUrl + url, callback); + } + return this; + }; + /** + * Clean up. + * @return {Tone.Buffers} this + */ + Tone.Buffers.prototype.dispose = function () { + Tone.prototype.dispose.call(this); + for (var name in this._buffers) { + this._buffers[name].dispose(); + } + this._buffers = null; + return this; + }; + return Tone.Buffers; + }); + Module(function (Tone) { + + /** + * buses are another way of routing audio + * + * augments Tone.prototype to include send and recieve + */ + /** + * All of the routes + * + * @type {Object} + * @static + * @private + */ + var Buses = {}; + /** + * Send this signal to the channel name. + * @param {String} channelName A named channel to send the signal to. + * @param {Decibels} amount The amount of the source to send to the bus. + * @return {GainNode} The gain node which connects this node to the desired channel. + * Can be used to adjust the levels of the send. + * @example + * source.send("reverb", -12); + */ + Tone.prototype.send = function (channelName, amount) { + if (!Buses.hasOwnProperty(channelName)) { + Buses[channelName] = this.context.createGain(); + } + amount = Tone.defaultArg(amount, 0); + var sendKnob = new Tone.Gain(amount, Tone.Type.Decibels); + this.connect(sendKnob); + sendKnob.connect(Buses[channelName]); + return sendKnob; + }; + /** + * Recieve the input from the desired channelName to the input + * + * @param {String} channelName A named channel to send the signal to. + * @param {Number=} channelNumber The channel to connect to + * @returns {Tone} this + * @example + * reverbEffect.receive("reverb"); + */ + Tone.prototype.receive = function (channelName, inputNum) { + if (!Buses.hasOwnProperty(channelName)) { + Buses[channelName] = this.context.createGain(); + } + Buses[channelName].connect(this, 0, inputNum); + return this; + }; + //remove all the send/receives when a new audio context is passed in + Tone.Context.on('init', function (context) { + if (context.Buses) { + Buses = context.Buses; + } else { + Buses = {}; + context.Buses = Buses; + } + }); + return Tone; + }); + Module(function (Tone) { + + /** + * @class Tone.Draw is useful for synchronizing visuals and audio events. + * Callbacks from Tone.Transport or any of the Tone.Event classes + * always happen _before_ the scheduled time and are not synchronized + * to the animation frame so they are not good for triggering tightly + * synchronized visuals and sound. Tone.Draw makes it easy to schedule + * callbacks using the AudioContext time and uses requestAnimationFrame. + * + * @singleton + * @extends {Tone} + * @example + * Tone.Transport.schedule(function(time){ + * //use the time argument to schedule a callback with Tone.Draw + * Tone.Draw.schedule(function(){ + * //do drawing or DOM manipulation here + * }, time) + * }, "+0.5") + */ + Tone.Draw = function () { + Tone.call(this); + /** + * All of the events. + * @type {Tone.Timeline} + * @private + */ + this._events = new Tone.Timeline(); + /** + * The duration after which events are not invoked. + * @type {Number} + * @default 0.25 + */ + this.expiration = 0.25; + /** + * The amount of time before the scheduled time + * that the callback can be invoked. Default is + * half the time of an animation frame (0.008 seconds). + * @type {Number} + * @default 0.008 + */ + this.anticipation = 0.008; + /** + * The draw loop + * @type {Function} + * @private + */ + this._boundDrawLoop = this._drawLoop.bind(this); + }; + Tone.extend(Tone.Draw); + /** + * Schedule a function at the given time to be invoked + * on the nearest animation frame. + * @param {Function} callback Callback is invoked at the given time. + * @param {Time} time The time relative to the AudioContext time + * to invoke the callback. + * @return {Tone.Draw} this + */ + Tone.Draw.prototype.schedule = function (callback, time) { + this._events.add({ + callback: callback, + time: this.toSeconds(time) + }); + //start the draw loop on the first event + if (this._events.length === 1) { + requestAnimationFrame(this._boundDrawLoop); + } + return this; + }; + /** + * Cancel events scheduled after the given time + * @param {Time=} after Time after which scheduled events will + * be removed from the scheduling timeline. + * @return {Tone.Draw} this + */ + Tone.Draw.prototype.cancel = function (after) { + this._events.cancel(this.toSeconds(after)); + return this; + }; + /** + * The draw loop + * @private + */ + Tone.Draw.prototype._drawLoop = function () { + var now = Tone.now(); + while (this._events.length && this._events.peek().time - this.anticipation <= now) { + var event = this._events.shift(); + if (now - event.time <= this.expiration) { + event.callback(); + } + } + if (this._events.length > 0) { + requestAnimationFrame(this._boundDrawLoop); + } + }; + //make a singleton + Tone.Draw = new Tone.Draw(); + return Tone.Draw; + }); + Module(function (Tone) { + + /** + * @class Both Tone.Panner3D and Tone.Listener have a position in 3D space + * using a right-handed cartesian coordinate system. + * The units used in the coordinate system are not defined; + * these coordinates are independent/invariant of any particular + * units such as meters or feet. Tone.Panner3D objects have an forward + * vector representing the direction the sound is projecting. Additionally, + * they have a sound cone representing how directional the sound is. + * For example, the sound could be omnidirectional, in which case it would + * be heard anywhere regardless of its forward, or it can be more directional + * and heard only if it is facing the listener. Tone.Listener objects + * (representing a person's ears) have an forward and up vector + * representing in which direction the person is facing. Because both the + * source stream and the listener can be moving, they both have a velocity + * vector representing both the speed and direction of movement. Taken together, + * these two velocities can be used to generate a doppler shift effect which changes the pitch. + * <br><br> + * Note: the position of the Listener will have no effect on nodes not connected to a Tone.Panner3D + * + * @constructor + * @extends {Tone} + * @singleton + */ + Tone.Listener = function () { + Tone.call(this); + /** + * Holds the current forward orientation + * @type {Array} + * @private + */ + this._orientation = [ + 0, + 0, + 0, + 0, + 0, + 0 + ]; + /** + * Holds the current position + * @type {Array} + * @private + */ + this._position = [ + 0, + 0, + 0 + ]; + Tone.getContext(function () { + // set the default position/forward + this.set(ListenerConstructor.defaults); + }.bind(this)); + }; + Tone.extend(Tone.Listener); + /** + * Defaults according to the specification + * @static + * @const + * @type {Object} + */ + Tone.Listener.defaults = { + 'positionX': 0, + 'positionY': 0, + 'positionZ': 0, + 'forwardX': 0, + 'forwardY': 0, + 'forwardZ': 1, + 'upX': 0, + 'upY': 1, + 'upZ': 0 + }; + /** + * The ramp time which is applied to the setTargetAtTime + * @type {Number} + * @private + */ + Tone.Listener.prototype._rampTimeConstant = 0.01; + /** + * Sets the position of the listener in 3d space. + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @return {Tone.Listener} this + */ + Tone.Listener.prototype.setPosition = function (x, y, z) { + if (this.context.listener.positionX) { + var now = this.now(); + this.context.listener.positionX.setTargetAtTime(x, now, this._rampTimeConstant); + this.context.listener.positionY.setTargetAtTime(y, now, this._rampTimeConstant); + this.context.listener.positionZ.setTargetAtTime(z, now, this._rampTimeConstant); + } else { + this.context.listener.setPosition(x, y, z); + } + this._position = Array.prototype.slice.call(arguments); + return this; + }; + /** + * Sets the orientation of the listener using two vectors, the forward + * vector (which direction the listener is facing) and the up vector + * (which the up direction of the listener). An up vector + * of 0, 0, 1 is equivalent to the listener standing up in the Z direction. + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @param {Number} upX + * @param {Number} upY + * @param {Number} upZ + * @return {Tone.Listener} this + */ + Tone.Listener.prototype.setOrientation = function (x, y, z, upX, upY, upZ) { + if (this.context.listener.forwardX) { + var now = this.now(); + this.context.listener.forwardX.setTargetAtTime(x, now, this._rampTimeConstant); + this.context.listener.forwardY.setTargetAtTime(y, now, this._rampTimeConstant); + this.context.listener.forwardZ.setTargetAtTime(z, now, this._rampTimeConstant); + this.context.listener.upX.setTargetAtTime(upX, now, this._rampTimeConstant); + this.context.listener.upY.setTargetAtTime(upY, now, this._rampTimeConstant); + this.context.listener.upZ.setTargetAtTime(upZ, now, this._rampTimeConstant); + } else { + this.context.listener.setOrientation(x, y, z, upX, upY, upZ); + } + this._orientation = Array.prototype.slice.call(arguments); + return this; + }; + /** + * The x position of the panner object. + * @type {Number} + * @memberOf Tone.Listener# + * @name positionX + */ + Object.defineProperty(Tone.Listener.prototype, 'positionX', { + set: function (pos) { + this._position[0] = pos; + this.setPosition.apply(this, this._position); + }, + get: function () { + return this._position[0]; + } + }); + /** + * The y position of the panner object. + * @type {Number} + * @memberOf Tone.Listener# + * @name positionY + */ + Object.defineProperty(Tone.Listener.prototype, 'positionY', { + set: function (pos) { + this._position[1] = pos; + this.setPosition.apply(this, this._position); + }, + get: function () { + return this._position[1]; + } + }); + /** + * The z position of the panner object. + * @type {Number} + * @memberOf Tone.Listener# + * @name positionZ + */ + Object.defineProperty(Tone.Listener.prototype, 'positionZ', { + set: function (pos) { + this._position[2] = pos; + this.setPosition.apply(this, this._position); + }, + get: function () { + return this._position[2]; + } + }); + /** + * The x coordinate of the listeners front direction. i.e. + * which way they are facing. + * @type {Number} + * @memberOf Tone.Listener# + * @name forwardX + */ + Object.defineProperty(Tone.Listener.prototype, 'forwardX', { + set: function (pos) { + this._orientation[0] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[0]; + } + }); + /** + * The y coordinate of the listeners front direction. i.e. + * which way they are facing. + * @type {Number} + * @memberOf Tone.Listener# + * @name forwardY + */ + Object.defineProperty(Tone.Listener.prototype, 'forwardY', { + set: function (pos) { + this._orientation[1] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[1]; + } + }); + /** + * The z coordinate of the listeners front direction. i.e. + * which way they are facing. + * @type {Number} + * @memberOf Tone.Listener# + * @name forwardZ + */ + Object.defineProperty(Tone.Listener.prototype, 'forwardZ', { + set: function (pos) { + this._orientation[2] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[2]; + } + }); + /** + * The x coordinate of the listener's up direction. i.e. + * the direction the listener is standing in. + * @type {Number} + * @memberOf Tone.Listener# + * @name upX + */ + Object.defineProperty(Tone.Listener.prototype, 'upX', { + set: function (pos) { + this._orientation[3] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[3]; + } + }); + /** + * The y coordinate of the listener's up direction. i.e. + * the direction the listener is standing in. + * @type {Number} + * @memberOf Tone.Listener# + * @name upY + */ + Object.defineProperty(Tone.Listener.prototype, 'upY', { + set: function (pos) { + this._orientation[4] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[4]; + } + }); + /** + * The z coordinate of the listener's up direction. i.e. + * the direction the listener is standing in. + * @type {Number} + * @memberOf Tone.Listener# + * @name upZ + */ + Object.defineProperty(Tone.Listener.prototype, 'upZ', { + set: function (pos) { + this._orientation[5] = pos; + this.setOrientation.apply(this, this._orientation); + }, + get: function () { + return this._orientation[5]; + } + }); + /** + * Clean up. + * @returns {Tone.Listener} this + */ + Tone.Listener.prototype.dispose = function () { + this._orientation = null; + this._position = null; + return this; + }; + //SINGLETON SETUP + var ListenerConstructor = Tone.Listener; + Tone.Listener = new ListenerConstructor(); + Tone.Context.on('init', function (context) { + if (context.Listener instanceof ListenerConstructor) { + //a single listener object + Tone.Listener = context.Listener; + } else { + //make new Listener insides + Tone.Listener = new ListenerConstructor(); + } + context.Listener = Tone.Listener; + }); + //END SINGLETON SETUP + return Tone.Listener; + }); + Module(function (Tone) { + /** + * Because of a bug in iOS causing the currentTime to increment + * before the rendering is started, sometimes it takes multiple + * attempts to render the audio correctly. + * @private + */ + function attemptRender(callback, duration, sampleRate, tries) { + tries = Tone.defaultArg(tries, 0); + var context = new Tone.OfflineContext(2, duration, sampleRate); + Tone.context = context; + //invoke the callback/scheduling + var response = callback(Tone.Transport); + if (context.currentTime > 0 && tries < 1000) { + return attemptRender(callback, duration, sampleRate, ++tries); + } else { + return { + 'response': response, + 'context': context + }; + } + } + /** + * Generate a buffer by rendering all of the Tone.js code within the callback using the OfflineAudioContext. + * The OfflineAudioContext is capable of rendering much faster than real time in many cases. + * The callback function also passes in an offline instance of Tone.Transport which can be used + * to schedule events along the Transport. **NOTE** OfflineAudioContext has the same restrictions + * as the AudioContext in that on certain platforms (like iOS) it must be invoked by an explicit + * user action like a click or tap. + * @param {Function} callback All Tone.js nodes which are created and scheduled within this callback are recorded into the output Buffer. + * @param {Time} duration the amount of time to record for. + * @return {Promise} The promise which is invoked with the Tone.Buffer of the recorded output. + * @example + * //render 2 seconds of the oscillator + * Tone.Offline(function(){ + * //only nodes created in this callback will be recorded + * var oscillator = new Tone.Oscillator().toMaster().start(0) + * //schedule their events + * }, 2).then(function(buffer){ + * //do something with the output buffer + * }) + * @example + * //can also schedule events along the Transport + * //using the passed in Offline Transport + * Tone.Offline(function(Transport){ + * var osc = new Tone.Oscillator().toMaster() + * Transport.schedule(function(time){ + * osc.start(time).stop(time + 0.1) + * }, 1) + * Transport.start(0.2) + * }, 4).then(function(buffer){ + * //do something with the output buffer + * }) + */ + Tone.Offline = function (callback, duration) { + //set the OfflineAudioContext + var sampleRate = Tone.context.sampleRate; + var originalContext = Tone.context; + var renderRet = attemptRender(callback, duration, sampleRate); + var response = renderRet.response; + var context = renderRet.context; + var ret; + if (response instanceof Promise) { + //wait for the promise to resolve + ret = response.then(function () { + //then render the audio + return context.render(); + }); + } else { + //process the audio + ret = context.render(); + } + //return the original AudioContext + Tone.context = originalContext; + //return the audio + return ret.then(function (buffer) { + //wrap it in a Tone.Buffer + return new Tone.Buffer(buffer); + }); + }; + return Tone.Offline; + }); + Module(function (Tone) { + + /** + * @class Tone.Effect is the base class for effects. Connect the effect between + * the effectSend and effectReturn GainNodes, then control the amount of + * effect which goes to the output using the wet control. + * + * @constructor + * @extends {Tone.AudioNode} + * @param {NormalRange|Object} [wet] The starting wet value. + */ + Tone.Effect = function () { + var options = Tone.defaults(arguments, ['wet'], Tone.Effect); + Tone.AudioNode.call(this); + this.createInsOuts(1, 1); + /** + * the drywet knob to control the amount of effect + * @type {Tone.CrossFade} + * @private + */ + this._dryWet = new Tone.CrossFade(options.wet); + /** + * The wet control is how much of the effected + * will pass through to the output. 1 = 100% effected + * signal, 0 = 100% dry signal. + * @type {NormalRange} + * @signal + */ + this.wet = this._dryWet.fade; + /** + * connect the effectSend to the input of hte effect + * @type {Tone.Gain} + * @private + */ + this.effectSend = new Tone.Gain(); + /** + * connect the output of the effect to the effectReturn + * @type {Tone.Gain} + * @private + */ + this.effectReturn = new Tone.Gain(); + //connections + this.input.connect(this._dryWet.a); + this.input.connect(this.effectSend); + this.effectReturn.connect(this._dryWet.b); + this._dryWet.connect(this.output); + this._readOnly(['wet']); + }; + Tone.extend(Tone.Effect, Tone.AudioNode); + /** + * @static + * @type {Object} + */ + Tone.Effect.defaults = { 'wet': 1 }; + /** + * chains the effect in between the effectSend and effectReturn + * @param {Tone} effect + * @private + * @returns {Tone.Effect} this + */ + Tone.Effect.prototype.connectEffect = function (effect) { + this.effectSend.chain(effect, this.effectReturn); + return this; + }; + /** + * Clean up. + * @returns {Tone.Effect} this + */ + Tone.Effect.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._dryWet.dispose(); + this._dryWet = null; + this.effectSend.dispose(); + this.effectSend = null; + this.effectReturn.dispose(); + this.effectReturn = null; + this._writable(['wet']); + this.wet = null; + return this; + }; + return Tone.Effect; + }); + Module(function (Tone) { + + /** + * @class Tone.AutoFilter is a Tone.Filter with a Tone.LFO connected to the filter cutoff frequency. + * Setting the LFO rate and depth allows for control over the filter modulation rate + * and depth. + * + * @constructor + * @extends {Tone.Effect} + * @param {Time|Object} [frequency] The rate of the LFO. + * @param {Frequency=} baseFrequency The lower value of the LFOs oscillation + * @param {Frequency=} octaves The number of octaves above the baseFrequency + * @example + * //create an autofilter and start it's LFO + * var autoFilter = new Tone.AutoFilter("4n").toMaster().start(); + * //route an oscillator through the filter and start it + * var oscillator = new Tone.Oscillator().connect(autoFilter).start(); + */ + Tone.AutoFilter = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'baseFrequency', + 'octaves' + ], Tone.AutoFilter); + Tone.Effect.call(this, options); + /** + * the lfo which drives the filter cutoff + * @type {Tone.LFO} + * @private + */ + this._lfo = new Tone.LFO({ + 'frequency': options.frequency, + 'amplitude': options.depth + }); + /** + * The range of the filter modulating between the min and max frequency. + * 0 = no modulation. 1 = full modulation. + * @type {NormalRange} + * @signal + */ + this.depth = this._lfo.amplitude; + /** + * How fast the filter modulates between min and max. + * @type {Frequency} + * @signal + */ + this.frequency = this._lfo.frequency; + /** + * The filter node + * @type {Tone.Filter} + */ + this.filter = new Tone.Filter(options.filter); + /** + * The octaves placeholder + * @type {Positive} + * @private + */ + this._octaves = 0; + //connections + this.connectEffect(this.filter); + this._lfo.connect(this.filter.frequency); + this.type = options.type; + this._readOnly([ + 'frequency', + 'depth' + ]); + this.octaves = options.octaves; + this.baseFrequency = options.baseFrequency; + }; + //extend Effect + Tone.extend(Tone.AutoFilter, Tone.Effect); + /** + * defaults + * @static + * @type {Object} + */ + Tone.AutoFilter.defaults = { + 'frequency': 1, + 'type': 'sine', + 'depth': 1, + 'baseFrequency': 200, + 'octaves': 2.6, + 'filter': { + 'type': 'lowpass', + 'rolloff': -12, + 'Q': 1 + } + }; + /** + * Start the effect. + * @param {Time} [time=now] When the LFO will start. + * @returns {Tone.AutoFilter} this + */ + Tone.AutoFilter.prototype.start = function (time) { + this._lfo.start(time); + return this; + }; + /** + * Stop the effect. + * @param {Time} [time=now] When the LFO will stop. + * @returns {Tone.AutoFilter} this + */ + Tone.AutoFilter.prototype.stop = function (time) { + this._lfo.stop(time); + return this; + }; + /** + * Sync the filter to the transport. + * @param {Time} [delay=0] Delay time before starting the effect after the + * Transport has started. + * @returns {Tone.AutoFilter} this + */ + Tone.AutoFilter.prototype.sync = function (delay) { + this._lfo.sync(delay); + return this; + }; + /** + * Unsync the filter from the transport. + * @returns {Tone.AutoFilter} this + */ + Tone.AutoFilter.prototype.unsync = function () { + this._lfo.unsync(); + return this; + }; + /** + * Type of oscillator attached to the AutoFilter. + * Possible values: "sine", "square", "triangle", "sawtooth". + * @memberOf Tone.AutoFilter# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.AutoFilter.prototype, 'type', { + get: function () { + return this._lfo.type; + }, + set: function (type) { + this._lfo.type = type; + } + }); + /** + * The minimum value of the filter's cutoff frequency. + * @memberOf Tone.AutoFilter# + * @type {Frequency} + * @name min + */ + Object.defineProperty(Tone.AutoFilter.prototype, 'baseFrequency', { + get: function () { + return this._lfo.min; + }, + set: function (freq) { + this._lfo.min = this.toFrequency(freq); + //and set the max + this.octaves = this._octaves; + } + }); + /** + * The maximum value of the filter's cutoff frequency. + * @memberOf Tone.AutoFilter# + * @type {Positive} + * @name octaves + */ + Object.defineProperty(Tone.AutoFilter.prototype, 'octaves', { + get: function () { + return this._octaves; + }, + set: function (oct) { + this._octaves = oct; + this._lfo.max = this.baseFrequency * Math.pow(2, oct); + } + }); + /** + * Clean up. + * @returns {Tone.AutoFilter} this + */ + Tone.AutoFilter.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._lfo.dispose(); + this._lfo = null; + this.filter.dispose(); + this.filter = null; + this._writable([ + 'frequency', + 'depth' + ]); + this.frequency = null; + this.depth = null; + return this; + }; + return Tone.AutoFilter; + }); + Module(function (Tone) { + + /** + * @class Tone.AutoPanner is a Tone.Panner with an LFO connected to the pan amount. + * More on using autopanners [here](https://www.ableton.com/en/blog/autopan-chopper-effect-and-more-liveschool/). + * + * @constructor + * @extends {Tone.Effect} + * @param {Frequency|Object} [frequency] Rate of left-right oscillation. + * @example + * //create an autopanner and start it's LFO + * var autoPanner = new Tone.AutoPanner("4n").toMaster().start(); + * //route an oscillator through the panner and start it + * var oscillator = new Tone.Oscillator().connect(autoPanner).start(); + */ + Tone.AutoPanner = function () { + var options = Tone.defaults(arguments, ['frequency'], Tone.AutoPanner); + Tone.Effect.call(this, options); + /** + * the lfo which drives the panning + * @type {Tone.LFO} + * @private + */ + this._lfo = new Tone.LFO({ + 'frequency': options.frequency, + 'amplitude': options.depth, + 'min': -1, + 'max': 1 + }); + /** + * The amount of panning between left and right. + * 0 = always center. 1 = full range between left and right. + * @type {NormalRange} + * @signal + */ + this.depth = this._lfo.amplitude; + /** + * the panner node which does the panning + * @type {Tone.Panner} + * @private + */ + this._panner = new Tone.Panner(); + /** + * How fast the panner modulates between left and right. + * @type {Frequency} + * @signal + */ + this.frequency = this._lfo.frequency; + //connections + this.connectEffect(this._panner); + this._lfo.connect(this._panner.pan); + this.type = options.type; + this._readOnly([ + 'depth', + 'frequency' + ]); + }; + //extend Effect + Tone.extend(Tone.AutoPanner, Tone.Effect); + /** + * defaults + * @static + * @type {Object} + */ + Tone.AutoPanner.defaults = { + 'frequency': 1, + 'type': 'sine', + 'depth': 1 + }; + /** + * Start the effect. + * @param {Time} [time=now] When the LFO will start. + * @returns {Tone.AutoPanner} this + */ + Tone.AutoPanner.prototype.start = function (time) { + this._lfo.start(time); + return this; + }; + /** + * Stop the effect. + * @param {Time} [time=now] When the LFO will stop. + * @returns {Tone.AutoPanner} this + */ + Tone.AutoPanner.prototype.stop = function (time) { + this._lfo.stop(time); + return this; + }; + /** + * Sync the panner to the transport. + * @param {Time} [delay=0] Delay time before starting the effect after the + * Transport has started. + * @returns {Tone.AutoPanner} this + */ + Tone.AutoPanner.prototype.sync = function (delay) { + this._lfo.sync(delay); + return this; + }; + /** + * Unsync the panner from the transport + * @returns {Tone.AutoPanner} this + */ + Tone.AutoPanner.prototype.unsync = function () { + this._lfo.unsync(); + return this; + }; + /** + * Type of oscillator attached to the AutoFilter. + * Possible values: "sine", "square", "triangle", "sawtooth". + * @memberOf Tone.AutoFilter# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.AutoPanner.prototype, 'type', { + get: function () { + return this._lfo.type; + }, + set: function (type) { + this._lfo.type = type; + } + }); + /** + * clean up + * @returns {Tone.AutoPanner} this + */ + Tone.AutoPanner.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._lfo.dispose(); + this._lfo = null; + this._panner.dispose(); + this._panner = null; + this._writable([ + 'depth', + 'frequency' + ]); + this.frequency = null; + this.depth = null; + return this; + }; + return Tone.AutoPanner; + }); + Module(function (Tone) { + + /** + * @class Tone.AutoWah connects a Tone.Follower to a bandpass filter (Tone.Filter). + * The frequency of the filter is adjusted proportionally to the + * incoming signal's amplitude. Inspiration from [Tuna.js](https://github.com/Dinahmoe/tuna). + * + * @constructor + * @extends {Tone.Effect} + * @param {Frequency|Object} [baseFrequency] The frequency the filter is set + * to at the low point of the wah + * @param {Positive} [octaves] The number of octaves above the baseFrequency + * the filter will sweep to when fully open + * @param {Decibels} [sensitivity] The decibel threshold sensitivity for + * the incoming signal. Normal range of -40 to 0. + * @example + * var autoWah = new Tone.AutoWah(50, 6, -30).toMaster(); + * //initialize the synth and connect to autowah + * var synth = new Synth.connect(autoWah); + * //Q value influences the effect of the wah - default is 2 + * autoWah.Q.value = 6; + * //more audible on higher notes + * synth.triggerAttackRelease("C4", "8n") + */ + Tone.AutoWah = function () { + var options = Tone.defaults(arguments, [ + 'baseFrequency', + 'octaves', + 'sensitivity' + ], Tone.AutoWah); + Tone.Effect.call(this, options); + /** + * The envelope follower. Set the attack/release + * timing to adjust how the envelope is followed. + * @type {Tone.Follower} + * @private + */ + this.follower = new Tone.Follower(options.follower); + /** + * scales the follower value to the frequency domain + * @type {Tone} + * @private + */ + this._sweepRange = new Tone.ScaleExp(0, 1, 0.5); + /** + * @type {number} + * @private + */ + this._baseFrequency = options.baseFrequency; + /** + * @type {number} + * @private + */ + this._octaves = options.octaves; + /** + * the input gain to adjust the sensitivity + * @type {Tone.Gain} + * @private + */ + this._inputBoost = new Tone.Gain(); + /** + * @type {BiquadFilterNode} + * @private + */ + this._bandpass = new Tone.Filter({ + 'rolloff': -48, + 'frequency': 0, + 'Q': options.Q + }); + /** + * @type {Tone.Filter} + * @private + */ + this._peaking = new Tone.Filter(0, 'peaking'); + this._peaking.gain.value = options.gain; + /** + * The gain of the filter. + * @type {Number} + * @signal + */ + this.gain = this._peaking.gain; + /** + * The quality of the filter. + * @type {Positive} + * @signal + */ + this.Q = this._bandpass.Q; + //the control signal path + this.effectSend.chain(this._inputBoost, this.follower, this._sweepRange); + this._sweepRange.connect(this._bandpass.frequency); + this._sweepRange.connect(this._peaking.frequency); + //the filtered path + this.effectSend.chain(this._bandpass, this._peaking, this.effectReturn); + //set the initial value + this._setSweepRange(); + this.sensitivity = options.sensitivity; + this._readOnly([ + 'gain', + 'Q' + ]); + }; + Tone.extend(Tone.AutoWah, Tone.Effect); + /** + * @static + * @type {Object} + */ + Tone.AutoWah.defaults = { + 'baseFrequency': 100, + 'octaves': 6, + 'sensitivity': 0, + 'Q': 2, + 'gain': 2, + 'follower': { + 'attack': 0.3, + 'release': 0.5 + } + }; + /** + * The number of octaves that the filter will sweep above the + * baseFrequency. + * @memberOf Tone.AutoWah# + * @type {Number} + * @name octaves + */ + Object.defineProperty(Tone.AutoWah.prototype, 'octaves', { + get: function () { + return this._octaves; + }, + set: function (octaves) { + this._octaves = octaves; + this._setSweepRange(); + } + }); + /** + * The base frequency from which the sweep will start from. + * @memberOf Tone.AutoWah# + * @type {Frequency} + * @name baseFrequency + */ + Object.defineProperty(Tone.AutoWah.prototype, 'baseFrequency', { + get: function () { + return this._baseFrequency; + }, + set: function (baseFreq) { + this._baseFrequency = baseFreq; + this._setSweepRange(); + } + }); + /** + * The sensitivity to control how responsive to the input signal the filter is. + * @memberOf Tone.AutoWah# + * @type {Decibels} + * @name sensitivity + */ + Object.defineProperty(Tone.AutoWah.prototype, 'sensitivity', { + get: function () { + return Tone.gainToDb(1 / this._inputBoost.gain.value); + }, + set: function (sensitivy) { + this._inputBoost.gain.value = 1 / Tone.dbToGain(sensitivy); + } + }); + /** + * sets the sweep range of the scaler + * @private + */ + Tone.AutoWah.prototype._setSweepRange = function () { + this._sweepRange.min = this._baseFrequency; + this._sweepRange.max = Math.min(this._baseFrequency * Math.pow(2, this._octaves), this.context.sampleRate / 2); + }; + /** + * Clean up. + * @returns {Tone.AutoWah} this + */ + Tone.AutoWah.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this.follower.dispose(); + this.follower = null; + this._sweepRange.dispose(); + this._sweepRange = null; + this._bandpass.dispose(); + this._bandpass = null; + this._peaking.dispose(); + this._peaking = null; + this._inputBoost.dispose(); + this._inputBoost = null; + this._writable([ + 'gain', + 'Q' + ]); + this.gain = null; + this.Q = null; + return this; + }; + return Tone.AutoWah; + }); + Module(function (Tone) { + + /** + * @class Signal-rate modulo operator. Only works in AudioRange [-1, 1] and for modulus + * values in the NormalRange. + * + * @constructor + * @extends {Tone.SignalBase} + * @param {NormalRange} modulus The modulus to apply. + * @example + * var mod = new Tone.Modulo(0.2) + * var sig = new Tone.Signal(0.5).connect(mod); + * //mod outputs 0.1 + */ + Tone.Modulo = function (modulus) { + Tone.SignalBase.call(this); + this.createInsOuts(1, 0); + /** + * A waveshaper gets the integer multiple of + * the input signal and the modulus. + * @private + * @type {Tone.WaveShaper} + */ + this._shaper = new Tone.WaveShaper(Math.pow(2, 16)); + /** + * the integer multiple is multiplied by the modulus + * @type {Tone.Multiply} + * @private + */ + this._multiply = new Tone.Multiply(); + /** + * and subtracted from the input signal + * @type {Tone.Subtract} + * @private + */ + this._subtract = this.output = new Tone.Subtract(); + /** + * the modulus signal + * @type {Tone.Signal} + * @private + */ + this._modSignal = new Tone.Signal(modulus); + //connections + this.input.fan(this._shaper, this._subtract); + this._modSignal.connect(this._multiply, 0, 0); + this._shaper.connect(this._multiply, 0, 1); + this._multiply.connect(this._subtract, 0, 1); + this._setWaveShaper(modulus); + }; + Tone.extend(Tone.Modulo, Tone.SignalBase); + /** + * @param {number} mod the modulus to apply + * @private + */ + Tone.Modulo.prototype._setWaveShaper = function (mod) { + this._shaper.setMap(function (val) { + var multiple = Math.floor((val + 0.0001) / mod); + return multiple; + }); + }; + /** + * The modulus value. + * @memberOf Tone.Modulo# + * @type {NormalRange} + * @name value + */ + Object.defineProperty(Tone.Modulo.prototype, 'value', { + get: function () { + return this._modSignal.value; + }, + set: function (mod) { + this._modSignal.value = mod; + this._setWaveShaper(mod); + } + }); + /** + * clean up + * @returns {Tone.Modulo} this + */ + Tone.Modulo.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._shaper.dispose(); + this._shaper = null; + this._multiply.dispose(); + this._multiply = null; + this._subtract.dispose(); + this._subtract = null; + this._modSignal.dispose(); + this._modSignal = null; + return this; + }; + return Tone.Modulo; + }); + Module(function (Tone) { + + /** + * @class Tone.Bitcrusher downsamples the incoming signal to a different bitdepth. + * Lowering the bitdepth of the signal creates distortion. Read more about Bitcrushing + * on [Wikipedia](https://en.wikipedia.org/wiki/Bitcrusher). + * + * @constructor + * @extends {Tone.Effect} + * @param {Number} bits The number of bits to downsample the signal. Nominal range + * of 1 to 8. + * @example + * //initialize crusher and route a synth through it + * var crusher = new Tone.BitCrusher(4).toMaster(); + * var synth = new Tone.MonoSynth().connect(crusher); + */ + Tone.BitCrusher = function () { + var options = Tone.defaults(arguments, ['bits'], Tone.BitCrusher); + Tone.Effect.call(this, options); + var invStepSize = 1 / Math.pow(2, options.bits - 1); + /** + * Subtract the input signal and the modulus of the input signal + * @type {Tone.Subtract} + * @private + */ + this._subtract = new Tone.Subtract(); + /** + * The mod function + * @type {Tone.Modulo} + * @private + */ + this._modulo = new Tone.Modulo(invStepSize); + /** + * keeps track of the bits + * @type {number} + * @private + */ + this._bits = options.bits; + //connect it up + this.effectSend.fan(this._subtract, this._modulo); + this._modulo.connect(this._subtract, 0, 1); + this._subtract.connect(this.effectReturn); + }; + Tone.extend(Tone.BitCrusher, Tone.Effect); + /** + * the default values + * @static + * @type {Object} + */ + Tone.BitCrusher.defaults = { 'bits': 4 }; + /** + * The bit depth of the effect. Nominal range of 1-8. + * @memberOf Tone.BitCrusher# + * @type {number} + * @name bits + */ + Object.defineProperty(Tone.BitCrusher.prototype, 'bits', { + get: function () { + return this._bits; + }, + set: function (bits) { + this._bits = bits; + var invStepSize = 1 / Math.pow(2, bits - 1); + this._modulo.value = invStepSize; + } + }); + /** + * Clean up. + * @returns {Tone.BitCrusher} this + */ + Tone.BitCrusher.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._subtract.dispose(); + this._subtract = null; + this._modulo.dispose(); + this._modulo = null; + return this; + }; + return Tone.BitCrusher; + }); + Module(function (Tone) { + + /** + * @class Tone.ChebyShev is a Chebyshev waveshaper, an effect which is good + * for making different types of distortion sounds. + * Note that odd orders sound very different from even ones, + * and order = 1 is no change. + * Read more at [music.columbia.edu](http://music.columbia.edu/cmc/musicandcomputers/chapter4/04_06.php). + * + * @extends {Tone.Effect} + * @constructor + * @param {Positive|Object} [order] The order of the chebyshev polynomial. Normal range between 1-100. + * @example + * //create a new cheby + * var cheby = new Tone.Chebyshev(50); + * //create a monosynth connected to our cheby + * synth = new Tone.MonoSynth().connect(cheby); + */ + Tone.Chebyshev = function () { + var options = Tone.defaults(arguments, ['order'], Tone.Chebyshev); + Tone.Effect.call(this, options); + /** + * @type {WaveShaperNode} + * @private + */ + this._shaper = new Tone.WaveShaper(4096); + /** + * holds onto the order of the filter + * @type {number} + * @private + */ + this._order = options.order; + this.connectEffect(this._shaper); + this.order = options.order; + this.oversample = options.oversample; + }; + Tone.extend(Tone.Chebyshev, Tone.Effect); + /** + * @static + * @const + * @type {Object} + */ + Tone.Chebyshev.defaults = { + 'order': 1, + 'oversample': 'none' + }; + /** + * get the coefficient for that degree + * @param {number} x the x value + * @param {number} degree + * @param {Object} memo memoize the computed value. + * this speeds up computation greatly. + * @return {number} the coefficient + * @private + */ + Tone.Chebyshev.prototype._getCoefficient = function (x, degree, memo) { + if (memo.hasOwnProperty(degree)) { + return memo[degree]; + } else if (degree === 0) { + memo[degree] = 0; + } else if (degree === 1) { + memo[degree] = x; + } else { + memo[degree] = 2 * x * this._getCoefficient(x, degree - 1, memo) - this._getCoefficient(x, degree - 2, memo); + } + return memo[degree]; + }; + /** + * The order of the Chebyshev polynomial which creates + * the equation which is applied to the incoming + * signal through a Tone.WaveShaper. The equations + * are in the form:<br> + * order 2: 2x^2 + 1<br> + * order 3: 4x^3 + 3x <br> + * @memberOf Tone.Chebyshev# + * @type {Positive} + * @name order + */ + Object.defineProperty(Tone.Chebyshev.prototype, 'order', { + get: function () { + return this._order; + }, + set: function (order) { + this._order = order; + var curve = new Array(4096); + var len = curve.length; + for (var i = 0; i < len; ++i) { + var x = i * 2 / len - 1; + if (x === 0) { + //should output 0 when input is 0 + curve[i] = 0; + } else { + curve[i] = this._getCoefficient(x, order, {}); + } + } + this._shaper.curve = curve; + } + }); + /** + * The oversampling of the effect. Can either be "none", "2x" or "4x". + * @memberOf Tone.Chebyshev# + * @type {string} + * @name oversample + */ + Object.defineProperty(Tone.Chebyshev.prototype, 'oversample', { + get: function () { + return this._shaper.oversample; + }, + set: function (oversampling) { + this._shaper.oversample = oversampling; + } + }); + /** + * Clean up. + * @returns {Tone.Chebyshev} this + */ + Tone.Chebyshev.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._shaper.dispose(); + this._shaper = null; + return this; + }; + return Tone.Chebyshev; + }); + Module(function (Tone) { + + /** + * @class Base class for Stereo effects. Provides effectSendL/R and effectReturnL/R. + * + * @constructor + * @extends {Tone.Effect} + */ + Tone.StereoEffect = function () { + //get the defaults + Tone.AudioNode.call(this); + var options = Tone.defaults(arguments, ['wet'], Tone.Effect); + this.createInsOuts(1, 1); + /** + * the drywet knob to control the amount of effect + * @type {Tone.CrossFade} + * @private + */ + this._dryWet = new Tone.CrossFade(options.wet); + /** + * The wet control, i.e. how much of the effected + * will pass through to the output. + * @type {NormalRange} + * @signal + */ + this.wet = this._dryWet.fade; + /** + * then split it + * @type {Tone.Split} + * @private + */ + this._split = new Tone.Split(); + /** + * the effects send LEFT + * @type {GainNode} + * @private + */ + this.effectSendL = this._split.left; + /** + * the effects send RIGHT + * @type {GainNode} + * @private + */ + this.effectSendR = this._split.right; + /** + * the stereo effect merger + * @type {Tone.Merge} + * @private + */ + this._merge = new Tone.Merge(); + /** + * the effect return LEFT + * @type {GainNode} + * @private + */ + this.effectReturnL = this._merge.left; + /** + * the effect return RIGHT + * @type {GainNode} + * @private + */ + this.effectReturnR = this._merge.right; + //connections + this.input.connect(this._split); + //dry wet connections + this.input.connect(this._dryWet, 0, 0); + this._merge.connect(this._dryWet, 0, 1); + this._dryWet.connect(this.output); + this._readOnly(['wet']); + }; + Tone.extend(Tone.StereoEffect, Tone.Effect); + /** + * Clean up. + * @returns {Tone.StereoEffect} this + */ + Tone.StereoEffect.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._dryWet.dispose(); + this._dryWet = null; + this._split.dispose(); + this._split = null; + this._merge.dispose(); + this._merge = null; + this.effectSendL = null; + this.effectSendR = null; + this.effectReturnL = null; + this.effectReturnR = null; + this._writable(['wet']); + this.wet = null; + return this; + }; + return Tone.StereoEffect; + }); + Module(function (Tone) { + + /** + * @class Tone.Chorus is a stereo chorus effect composed of + * a left and right delay with a Tone.LFO applied to the delayTime of each channel. + * Inspiration from [Tuna.js](https://github.com/Dinahmoe/tuna/blob/master/tuna.js). + * Read more on the chorus effect on [SoundOnSound](http://www.soundonsound.com/sos/jun04/articles/synthsecrets.htm). + * + * @constructor + * @extends {Tone.StereoEffect} + * @param {Frequency|Object} [frequency] The frequency of the LFO. + * @param {Milliseconds} [delayTime] The delay of the chorus effect in ms. + * @param {NormalRange} [depth] The depth of the chorus. + * @example + * var chorus = new Tone.Chorus(4, 2.5, 0.5); + * var synth = new Tone.PolySynth(4, Tone.MonoSynth).connect(chorus); + * synth.triggerAttackRelease(["C3","E3","G3"], "8n"); + */ + Tone.Chorus = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'delayTime', + 'depth' + ], Tone.Chorus); + Tone.StereoEffect.call(this, options); + /** + * the depth of the chorus + * @type {number} + * @private + */ + this._depth = options.depth; + /** + * the delayTime + * @type {number} + * @private + */ + this._delayTime = options.delayTime / 1000; + /** + * the lfo which controls the delayTime + * @type {Tone.LFO} + * @private + */ + this._lfoL = new Tone.LFO({ + 'frequency': options.frequency, + 'min': 0, + 'max': 1 + }); + /** + * another LFO for the right side with a 180 degree phase diff + * @type {Tone.LFO} + * @private + */ + this._lfoR = new Tone.LFO({ + 'frequency': options.frequency, + 'min': 0, + 'max': 1, + 'phase': 180 + }); + /** + * delay for left + * @type {Tone.Delay} + * @private + */ + this._delayNodeL = new Tone.Delay(); + /** + * delay for right + * @type {Tone.Delay} + * @private + */ + this._delayNodeR = new Tone.Delay(); + /** + * The frequency of the LFO which modulates the delayTime. + * @type {Frequency} + * @signal + */ + this.frequency = this._lfoL.frequency; + //connections + this.effectSendL.chain(this._delayNodeL, this.effectReturnL); + this.effectSendR.chain(this._delayNodeR, this.effectReturnR); + //and pass through to make the detune apparent + this.effectSendL.connect(this.effectReturnL); + this.effectSendR.connect(this.effectReturnR); + //lfo setup + this._lfoL.connect(this._delayNodeL.delayTime); + this._lfoR.connect(this._delayNodeR.delayTime); + //start the lfo + this._lfoL.start(); + this._lfoR.start(); + //have one LFO frequency control the other + this._lfoL.frequency.connect(this._lfoR.frequency); + //set the initial values + this.depth = this._depth; + this.frequency.value = options.frequency; + this.type = options.type; + this._readOnly(['frequency']); + this.spread = options.spread; + }; + Tone.extend(Tone.Chorus, Tone.StereoEffect); + /** + * @static + * @type {Object} + */ + Tone.Chorus.defaults = { + 'frequency': 1.5, + 'delayTime': 3.5, + 'depth': 0.7, + 'type': 'sine', + 'spread': 180 + }; + /** + * The depth of the effect. A depth of 1 makes the delayTime + * modulate between 0 and 2*delayTime (centered around the delayTime). + * @memberOf Tone.Chorus# + * @type {NormalRange} + * @name depth + */ + Object.defineProperty(Tone.Chorus.prototype, 'depth', { + get: function () { + return this._depth; + }, + set: function (depth) { + this._depth = depth; + var deviation = this._delayTime * depth; + this._lfoL.min = Math.max(this._delayTime - deviation, 0); + this._lfoL.max = this._delayTime + deviation; + this._lfoR.min = Math.max(this._delayTime - deviation, 0); + this._lfoR.max = this._delayTime + deviation; + } + }); + /** + * The delayTime in milliseconds of the chorus. A larger delayTime + * will give a more pronounced effect. Nominal range a delayTime + * is between 2 and 20ms. + * @memberOf Tone.Chorus# + * @type {Milliseconds} + * @name delayTime + */ + Object.defineProperty(Tone.Chorus.prototype, 'delayTime', { + get: function () { + return this._delayTime * 1000; + }, + set: function (delayTime) { + this._delayTime = delayTime / 1000; + this.depth = this._depth; + } + }); + /** + * The oscillator type of the LFO. + * @memberOf Tone.Chorus# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.Chorus.prototype, 'type', { + get: function () { + return this._lfoL.type; + }, + set: function (type) { + this._lfoL.type = type; + this._lfoR.type = type; + } + }); + /** + * Amount of stereo spread. When set to 0, both LFO's will be panned centrally. + * When set to 180, LFO's will be panned hard left and right respectively. + * @memberOf Tone.Chorus# + * @type {Degrees} + * @name spread + */ + Object.defineProperty(Tone.Chorus.prototype, 'spread', { + get: function () { + return this._lfoR.phase - this._lfoL.phase; + }, + set: function (spread) { + this._lfoL.phase = 90 - spread / 2; + this._lfoR.phase = spread / 2 + 90; + } + }); + /** + * Clean up. + * @returns {Tone.Chorus} this + */ + Tone.Chorus.prototype.dispose = function () { + Tone.StereoEffect.prototype.dispose.call(this); + this._lfoL.dispose(); + this._lfoL = null; + this._lfoR.dispose(); + this._lfoR = null; + this._delayNodeL.dispose(); + this._delayNodeL = null; + this._delayNodeR.dispose(); + this._delayNodeR = null; + this._writable('frequency'); + this.frequency = null; + return this; + }; + return Tone.Chorus; + }); + Module(function (Tone) { + + /** + * @class Tone.Convolver is a wrapper around the Native Web Audio + * [ConvolverNode](http://webaudio.github.io/web-audio-api/#the-convolvernode-interface). + * Convolution is useful for reverb and filter emulation. Read more about convolution reverb on + * [Wikipedia](https://en.wikipedia.org/wiki/Convolution_reverb). + * + * @constructor + * @extends {Tone.Effect} + * @param {string|Tone.Buffer|Object} [url] The URL of the impulse response or the Tone.Buffer + * contianing the impulse response. + * @param {Function=} onload The callback to invoke when the url is loaded. + * @example + * //initializing the convolver with an impulse response + * var convolver = new Tone.Convolver("./path/to/ir.wav").toMaster(); + */ + Tone.Convolver = function () { + var options = Tone.defaults(arguments, [ + 'url', + 'onload' + ], Tone.Convolver); + Tone.Effect.call(this, options); + /** + * convolver node + * @type {ConvolverNode} + * @private + */ + this._convolver = this.context.createConvolver(); + /** + * the convolution buffer + * @type {Tone.Buffer} + * @private + */ + this._buffer = new Tone.Buffer(options.url, function (buffer) { + this._convolver.buffer = buffer.get(); + options.onload(); + }.bind(this)); + this.connectEffect(this._convolver); + }; + Tone.extend(Tone.Convolver, Tone.Effect); + /** + * @static + * @const + * @type {Object} + */ + Tone.Convolver.defaults = { 'onload': Tone.noOp }; + /** + * The convolver's buffer + * @memberOf Tone.Convolver# + * @type {AudioBuffer} + * @name buffer + */ + Object.defineProperty(Tone.Convolver.prototype, 'buffer', { + get: function () { + return this._buffer.get(); + }, + set: function (buffer) { + this._buffer.set(buffer); + this._convolver.buffer = this._buffer.get(); + } + }); + /** + * Load an impulse response url as an audio buffer. + * Decodes the audio asynchronously and invokes + * the callback once the audio buffer loads. + * @param {string} url The url of the buffer to load. + * filetype support depends on the + * browser. + * @param {function=} callback + * @returns {Promise} + */ + Tone.Convolver.prototype.load = function (url, callback) { + return this._buffer.load(url, function (buff) { + this.buffer = buff; + if (callback) { + callback(); + } + }.bind(this)); + }; + /** + * Clean up. + * @returns {Tone.Convolver} this + */ + Tone.Convolver.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._convolver.disconnect(); + this._convolver = null; + this._buffer.dispose(); + this._buffer = null; + return this; + }; + return Tone.Convolver; + }); + Module(function (Tone) { + + /** + * @class Tone.Distortion is a simple distortion effect using Tone.WaveShaper. + * Algorithm from [a stackoverflow answer](http://stackoverflow.com/a/22313408). + * + * @extends {Tone.Effect} + * @constructor + * @param {Number|Object} [distortion] The amount of distortion (nominal range of 0-1) + * @example + * var dist = new Tone.Distortion(0.8).toMaster(); + * var fm = new Tone.SimpleFM().connect(dist); + * //this sounds good on bass notes + * fm.triggerAttackRelease("A1", "8n"); + */ + Tone.Distortion = function () { + var options = Tone.defaults(arguments, ['distortion'], Tone.Distortion); + Tone.Effect.call(this, options); + /** + * @type {Tone.WaveShaper} + * @private + */ + this._shaper = new Tone.WaveShaper(4096); + /** + * holds the distortion amount + * @type {number} + * @private + */ + this._distortion = options.distortion; + this.connectEffect(this._shaper); + this.distortion = options.distortion; + this.oversample = options.oversample; + }; + Tone.extend(Tone.Distortion, Tone.Effect); + /** + * @static + * @const + * @type {Object} + */ + Tone.Distortion.defaults = { + 'distortion': 0.4, + 'oversample': 'none' + }; + /** + * The amount of distortion. + * @memberOf Tone.Distortion# + * @type {NormalRange} + * @name distortion + */ + Object.defineProperty(Tone.Distortion.prototype, 'distortion', { + get: function () { + return this._distortion; + }, + set: function (amount) { + this._distortion = amount; + var k = amount * 100; + var deg = Math.PI / 180; + this._shaper.setMap(function (x) { + if (Math.abs(x) < 0.001) { + //should output 0 when input is 0 + return 0; + } else { + return (3 + k) * x * 20 * deg / (Math.PI + k * Math.abs(x)); + } + }); + } + }); + /** + * The oversampling of the effect. Can either be "none", "2x" or "4x". + * @memberOf Tone.Distortion# + * @type {string} + * @name oversample + */ + Object.defineProperty(Tone.Distortion.prototype, 'oversample', { + get: function () { + return this._shaper.oversample; + }, + set: function (oversampling) { + this._shaper.oversample = oversampling; + } + }); + /** + * Clean up. + * @returns {Tone.Distortion} this + */ + Tone.Distortion.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._shaper.dispose(); + this._shaper = null; + return this; + }; + return Tone.Distortion; + }); + Module(function (Tone) { + + /** + * @class Tone.FeedbackEffect provides a loop between an + * audio source and its own output. This is a base-class + * for feedback effects. + * + * @constructor + * @extends {Tone.Effect} + * @param {NormalRange|Object} [feedback] The initial feedback value. + */ + Tone.FeedbackEffect = function () { + var options = Tone.defaults(arguments, ['feedback'], Tone.FeedbackEffect); + Tone.Effect.call(this, options); + /** + * the gain which controls the feedback + * @type {Tone.Gain} + * @private + */ + this._feedbackGain = new Tone.Gain(options.feedback, Tone.Type.NormalRange); + /** + * The amount of signal which is fed back into the effect input. + * @type {NormalRange} + * @signal + */ + this.feedback = this._feedbackGain.gain; + //the feedback loop + this.effectReturn.chain(this._feedbackGain, this.effectSend); + this._readOnly(['feedback']); + }; + Tone.extend(Tone.FeedbackEffect, Tone.Effect); + /** + * @static + * @type {Object} + */ + Tone.FeedbackEffect.defaults = { 'feedback': 0.125 }; + /** + * Clean up. + * @returns {Tone.FeedbackEffect} this + */ + Tone.FeedbackEffect.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._writable(['feedback']); + this._feedbackGain.dispose(); + this._feedbackGain = null; + this.feedback = null; + return this; + }; + return Tone.FeedbackEffect; + }); + Module(function (Tone) { + + /** + * @class Tone.FeedbackDelay is a DelayNode in which part of output + * signal is fed back into the delay. + * + * @constructor + * @extends {Tone.FeedbackEffect} + * @param {Time|Object} [delayTime] The delay applied to the incoming signal. + * @param {NormalRange=} feedback The amount of the effected signal which + * is fed back through the delay. + * @example + * var feedbackDelay = new Tone.FeedbackDelay("8n", 0.5).toMaster(); + * var tom = new Tone.DrumSynth({ + * "octaves" : 4, + * "pitchDecay" : 0.1 + * }).connect(feedbackDelay); + * tom.triggerAttackRelease("A2","32n"); + */ + Tone.FeedbackDelay = function () { + var options = Tone.defaults(arguments, [ + 'delayTime', + 'feedback' + ], Tone.FeedbackDelay); + Tone.FeedbackEffect.call(this, options); + /** + * the delay node + * @type {Tone.Delay} + * @private + */ + this._delayNode = new Tone.Delay(options.delayTime, options.maxDelay); + /** + * The delayTime of the DelayNode. + * @type {Time} + * @signal + */ + this.delayTime = this._delayNode.delayTime; + // connect it up + this.connectEffect(this._delayNode); + this._readOnly(['delayTime']); + }; + Tone.extend(Tone.FeedbackDelay, Tone.FeedbackEffect); + /** + * The default values. + * @const + * @static + * @type {Object} + */ + Tone.FeedbackDelay.defaults = { + 'delayTime': 0.25, + 'maxDelay': 1 + }; + /** + * clean up + * @returns {Tone.FeedbackDelay} this + */ + Tone.FeedbackDelay.prototype.dispose = function () { + Tone.FeedbackEffect.prototype.dispose.call(this); + this._delayNode.dispose(); + this._delayNode = null; + this._writable(['delayTime']); + this.delayTime = null; + return this; + }; + return Tone.FeedbackDelay; + }); + Module(function (Tone) { + + /** + * an array of comb filter delay values from Freeverb implementation + * @static + * @private + * @type {Array} + */ + var combFilterTunings = [ + 1557 / 44100, + 1617 / 44100, + 1491 / 44100, + 1422 / 44100, + 1277 / 44100, + 1356 / 44100, + 1188 / 44100, + 1116 / 44100 + ]; + /** + * an array of allpass filter frequency values from Freeverb implementation + * @private + * @static + * @type {Array} + */ + var allpassFilterFrequencies = [ + 225, + 556, + 441, + 341 + ]; + /** + * @class Tone.Freeverb is a reverb based on [Freeverb](https://ccrma.stanford.edu/~jos/pasp/Freeverb.html). + * Read more on reverb on [Sound On Sound](https://web.archive.org/web/20160404083902/http://www.soundonsound.com:80/sos/feb01/articles/synthsecrets.asp). + * + * @extends {Tone.Effect} + * @constructor + * @param {NormalRange|Object} [roomSize] Correlated to the decay time. + * @param {Frequency} [dampening] The cutoff frequency of a lowpass filter as part + * of the reverb. + * @example + * var freeverb = new Tone.Freeverb().toMaster(); + * freeverb.dampening.value = 1000; + * //routing synth through the reverb + * var synth = new Tone.AMSynth().connect(freeverb); + */ + Tone.Freeverb = function () { + var options = Tone.defaults(arguments, [ + 'roomSize', + 'dampening' + ], Tone.Freeverb); + Tone.StereoEffect.call(this, options); + /** + * The roomSize value between. A larger roomSize + * will result in a longer decay. + * @type {NormalRange} + * @signal + */ + this.roomSize = new Tone.Signal(options.roomSize, Tone.Type.NormalRange); + /** + * The amount of dampening of the reverberant signal. + * @type {Frequency} + * @signal + */ + this.dampening = new Tone.Signal(options.dampening, Tone.Type.Frequency); + /** + * the comb filters + * @type {Array} + * @private + */ + this._combFilters = []; + /** + * the allpass filters on the left + * @type {Array} + * @private + */ + this._allpassFiltersL = []; + /** + * the allpass filters on the right + * @type {Array} + * @private + */ + this._allpassFiltersR = []; + //make the allpass filters on the right + for (var l = 0; l < allpassFilterFrequencies.length; l++) { + var allpassL = this.context.createBiquadFilter(); + allpassL.type = 'allpass'; + allpassL.frequency.value = allpassFilterFrequencies[l]; + this._allpassFiltersL.push(allpassL); + } + //make the allpass filters on the left + for (var r = 0; r < allpassFilterFrequencies.length; r++) { + var allpassR = this.context.createBiquadFilter(); + allpassR.type = 'allpass'; + allpassR.frequency.value = allpassFilterFrequencies[r]; + this._allpassFiltersR.push(allpassR); + } + //make the comb filters + for (var c = 0; c < combFilterTunings.length; c++) { + var lfpf = new Tone.LowpassCombFilter(combFilterTunings[c]); + if (c < combFilterTunings.length / 2) { + this.effectSendL.chain(lfpf, this._allpassFiltersL[0]); + } else { + this.effectSendR.chain(lfpf, this._allpassFiltersR[0]); + } + this.roomSize.connect(lfpf.resonance); + this.dampening.connect(lfpf.dampening); + this._combFilters.push(lfpf); + } + //chain the allpass filters togetehr + Tone.connectSeries.apply(Tone, this._allpassFiltersL); + Tone.connectSeries.apply(Tone, this._allpassFiltersR); + this._allpassFiltersL[this._allpassFiltersL.length - 1].connect(this.effectReturnL); + this._allpassFiltersR[this._allpassFiltersR.length - 1].connect(this.effectReturnR); + this._readOnly([ + 'roomSize', + 'dampening' + ]); + }; + Tone.extend(Tone.Freeverb, Tone.StereoEffect); + /** + * @static + * @type {Object} + */ + Tone.Freeverb.defaults = { + 'roomSize': 0.7, + 'dampening': 3000 + }; + /** + * Clean up. + * @returns {Tone.Freeverb} this + */ + Tone.Freeverb.prototype.dispose = function () { + Tone.StereoEffect.prototype.dispose.call(this); + for (var al = 0; al < this._allpassFiltersL.length; al++) { + this._allpassFiltersL[al].disconnect(); + this._allpassFiltersL[al] = null; + } + this._allpassFiltersL = null; + for (var ar = 0; ar < this._allpassFiltersR.length; ar++) { + this._allpassFiltersR[ar].disconnect(); + this._allpassFiltersR[ar] = null; + } + this._allpassFiltersR = null; + for (var cf = 0; cf < this._combFilters.length; cf++) { + this._combFilters[cf].dispose(); + this._combFilters[cf] = null; + } + this._combFilters = null; + this._writable([ + 'roomSize', + 'dampening' + ]); + this.roomSize.dispose(); + this.roomSize = null; + this.dampening.dispose(); + this.dampening = null; + return this; + }; + return Tone.Freeverb; + }); + Module(function (Tone) { + + /** + * an array of the comb filter delay time values + * @private + * @static + * @type {Array} + */ + var combFilterDelayTimes = [ + 1687 / 25000, + 1601 / 25000, + 2053 / 25000, + 2251 / 25000 + ]; + /** + * the resonances of each of the comb filters + * @private + * @static + * @type {Array} + */ + var combFilterResonances = [ + 0.773, + 0.802, + 0.753, + 0.733 + ]; + /** + * the allpass filter frequencies + * @private + * @static + * @type {Array} + */ + var allpassFilterFreqs = [ + 347, + 113, + 37 + ]; + /** + * @class Tone.JCReverb is a simple [Schroeder Reverberator](https://ccrma.stanford.edu/~jos/pasp/Schroeder_Reverberators.html) + * tuned by John Chowning in 1970. + * It is made up of three allpass filters and four Tone.FeedbackCombFilter. + * + * + * @extends {Tone.Effect} + * @constructor + * @param {NormalRange|Object} [roomSize] Coorelates to the decay time. + * @example + * var reverb = new Tone.JCReverb(0.4).connect(Tone.Master); + * var delay = new Tone.FeedbackDelay(0.5); + * //connecting the synth to reverb through delay + * var synth = new Tone.DuoSynth().chain(delay, reverb); + * synth.triggerAttackRelease("A4","8n"); + */ + Tone.JCReverb = function () { + var options = Tone.defaults(arguments, ['roomSize'], Tone.JCReverb); + Tone.StereoEffect.call(this, options); + /** + * room size control values between [0,1] + * @type {NormalRange} + * @signal + */ + this.roomSize = new Tone.Signal(options.roomSize, Tone.Type.NormalRange); + /** + * scale the room size + * @type {Tone.Scale} + * @private + */ + this._scaleRoomSize = new Tone.Scale(-0.733, 0.197); + /** + * a series of allpass filters + * @type {Array} + * @private + */ + this._allpassFilters = []; + /** + * parallel feedback comb filters + * @type {Array} + * @private + */ + this._feedbackCombFilters = []; + //make the allpass filters + for (var af = 0; af < allpassFilterFreqs.length; af++) { + var allpass = this.context.createBiquadFilter(); + allpass.type = 'allpass'; + allpass.frequency.value = allpassFilterFreqs[af]; + this._allpassFilters.push(allpass); + } + //and the comb filters + for (var cf = 0; cf < combFilterDelayTimes.length; cf++) { + var fbcf = new Tone.FeedbackCombFilter(combFilterDelayTimes[cf], 0.1); + this._scaleRoomSize.connect(fbcf.resonance); + fbcf.resonance.value = combFilterResonances[cf]; + this._allpassFilters[this._allpassFilters.length - 1].connect(fbcf); + if (cf < combFilterDelayTimes.length / 2) { + fbcf.connect(this.effectReturnL); + } else { + fbcf.connect(this.effectReturnR); + } + this._feedbackCombFilters.push(fbcf); + } + //chain the allpass filters together + this.roomSize.connect(this._scaleRoomSize); + Tone.connectSeries.apply(Tone, this._allpassFilters); + this.effectSendL.connect(this._allpassFilters[0]); + this.effectSendR.connect(this._allpassFilters[0]); + this._readOnly(['roomSize']); + }; + Tone.extend(Tone.JCReverb, Tone.StereoEffect); + /** + * the default values + * @static + * @const + * @type {Object} + */ + Tone.JCReverb.defaults = { 'roomSize': 0.5 }; + /** + * Clean up. + * @returns {Tone.JCReverb} this + */ + Tone.JCReverb.prototype.dispose = function () { + Tone.StereoEffect.prototype.dispose.call(this); + for (var apf = 0; apf < this._allpassFilters.length; apf++) { + this._allpassFilters[apf].disconnect(); + this._allpassFilters[apf] = null; + } + this._allpassFilters = null; + for (var fbcf = 0; fbcf < this._feedbackCombFilters.length; fbcf++) { + this._feedbackCombFilters[fbcf].dispose(); + this._feedbackCombFilters[fbcf] = null; + } + this._feedbackCombFilters = null; + this._writable(['roomSize']); + this.roomSize.dispose(); + this.roomSize = null; + this._scaleRoomSize.dispose(); + this._scaleRoomSize = null; + return this; + }; + return Tone.JCReverb; + }); + Module(function (Tone) { + + /** + * @class Mid/Side processing separates the the 'mid' signal + * (which comes out of both the left and the right channel) + * and the 'side' (which only comes out of the the side channels) + * and effects them separately before being recombined. + * Applies a Mid/Side seperation and recombination. + * Algorithm found in [kvraudio forums](http://www.kvraudio.com/forum/viewtopic.php?t=212587). + * <br><br> + * This is a base-class for Mid/Side Effects. + * + * @extends {Tone.Effect} + * @constructor + */ + Tone.MidSideEffect = function () { + Tone.Effect.apply(this, arguments); + /** + * The mid/side split + * @type {Tone.MidSideSplit} + * @private + */ + this._midSideSplit = new Tone.MidSideSplit(); + /** + * The mid/side merge + * @type {Tone.MidSideMerge} + * @private + */ + this._midSideMerge = new Tone.MidSideMerge(); + /** + * The mid send. Connect to mid processing + * @type {Tone} + * @private + */ + this.midSend = this._midSideSplit.mid; + /** + * The side send. Connect to side processing + * @type {Tone} + * @private + */ + this.sideSend = this._midSideSplit.side; + /** + * The mid return connection + * @type {GainNode} + * @private + */ + this.midReturn = this._midSideMerge.mid; + /** + * The side return connection + * @type {GainNode} + * @private + */ + this.sideReturn = this._midSideMerge.side; + //the connections + this.effectSend.connect(this._midSideSplit); + this._midSideMerge.connect(this.effectReturn); + }; + Tone.extend(Tone.MidSideEffect, Tone.Effect); + /** + * Clean up. + * @returns {Tone.MidSideEffect} this + */ + Tone.MidSideEffect.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._midSideSplit.dispose(); + this._midSideSplit = null; + this._midSideMerge.dispose(); + this._midSideMerge = null; + this.midSend = null; + this.sideSend = null; + this.midReturn = null; + this.sideReturn = null; + return this; + }; + return Tone.MidSideEffect; + }); + Module(function (Tone) { + + /** + * @class Tone.Phaser is a phaser effect. Phasers work by changing the phase + * of different frequency components of an incoming signal. Read more on + * [Wikipedia](https://en.wikipedia.org/wiki/Phaser_(effect)). + * Inspiration for this phaser comes from [Tuna.js](https://github.com/Dinahmoe/tuna/). + * + * @extends {Tone.StereoEffect} + * @constructor + * @param {Frequency|Object} [frequency] The speed of the phasing. + * @param {number} [octaves] The octaves of the effect. + * @param {Frequency} [baseFrequency] The base frequency of the filters. + * @example + * var phaser = new Tone.Phaser({ + * "frequency" : 15, + * "octaves" : 5, + * "baseFrequency" : 1000 + * }).toMaster(); + * var synth = new Tone.FMSynth().connect(phaser); + * synth.triggerAttackRelease("E3", "2n"); + */ + Tone.Phaser = function () { + //set the defaults + var options = Tone.defaults(arguments, [ + 'frequency', + 'octaves', + 'baseFrequency' + ], Tone.Phaser); + Tone.StereoEffect.call(this, options); + /** + * the lfo which controls the frequency on the left side + * @type {Tone.LFO} + * @private + */ + this._lfoL = new Tone.LFO(options.frequency, 0, 1); + /** + * the lfo which controls the frequency on the right side + * @type {Tone.LFO} + * @private + */ + this._lfoR = new Tone.LFO(options.frequency, 0, 1); + this._lfoR.phase = 180; + /** + * the base modulation frequency + * @type {number} + * @private + */ + this._baseFrequency = options.baseFrequency; + /** + * the octaves of the phasing + * @type {number} + * @private + */ + this._octaves = options.octaves; + /** + * The quality factor of the filters + * @type {Positive} + * @signal + */ + this.Q = new Tone.Signal(options.Q, Tone.Type.Positive); + /** + * the array of filters for the left side + * @type {Array} + * @private + */ + this._filtersL = this._makeFilters(options.stages, this._lfoL, this.Q); + /** + * the array of filters for the left side + * @type {Array} + * @private + */ + this._filtersR = this._makeFilters(options.stages, this._lfoR, this.Q); + /** + * the frequency of the effect + * @type {Tone.Signal} + */ + this.frequency = this._lfoL.frequency; + this.frequency.value = options.frequency; + //connect them up + this.effectSendL.connect(this._filtersL[0]); + this.effectSendR.connect(this._filtersR[0]); + this._filtersL[options.stages - 1].connect(this.effectReturnL); + this._filtersR[options.stages - 1].connect(this.effectReturnR); + //control the frequency with one LFO + this._lfoL.frequency.connect(this._lfoR.frequency); + //set the options + this.baseFrequency = options.baseFrequency; + this.octaves = options.octaves; + //start the lfo + this._lfoL.start(); + this._lfoR.start(); + this._readOnly([ + 'frequency', + 'Q' + ]); + }; + Tone.extend(Tone.Phaser, Tone.StereoEffect); + /** + * defaults + * @static + * @type {object} + */ + Tone.Phaser.defaults = { + 'frequency': 0.5, + 'octaves': 3, + 'stages': 10, + 'Q': 10, + 'baseFrequency': 350 + }; + /** + * @param {number} stages + * @returns {Array} the number of filters all connected together + * @private + */ + Tone.Phaser.prototype._makeFilters = function (stages, connectToFreq, Q) { + var filters = new Array(stages); + //make all the filters + for (var i = 0; i < stages; i++) { + var filter = this.context.createBiquadFilter(); + filter.type = 'allpass'; + Q.connect(filter.Q); + connectToFreq.connect(filter.frequency); + filters[i] = filter; + } + Tone.connectSeries.apply(Tone, filters); + return filters; + }; + /** + * The number of octaves the phase goes above + * the baseFrequency + * @memberOf Tone.Phaser# + * @type {Positive} + * @name octaves + */ + Object.defineProperty(Tone.Phaser.prototype, 'octaves', { + get: function () { + return this._octaves; + }, + set: function (octaves) { + this._octaves = octaves; + var max = this._baseFrequency * Math.pow(2, octaves); + this._lfoL.max = max; + this._lfoR.max = max; + } + }); + /** + * The the base frequency of the filters. + * @memberOf Tone.Phaser# + * @type {number} + * @name baseFrequency + */ + Object.defineProperty(Tone.Phaser.prototype, 'baseFrequency', { + get: function () { + return this._baseFrequency; + }, + set: function (freq) { + this._baseFrequency = freq; + this._lfoL.min = freq; + this._lfoR.min = freq; + this.octaves = this._octaves; + } + }); + /** + * clean up + * @returns {Tone.Phaser} this + */ + Tone.Phaser.prototype.dispose = function () { + Tone.StereoEffect.prototype.dispose.call(this); + this._writable([ + 'frequency', + 'Q' + ]); + this.Q.dispose(); + this.Q = null; + this._lfoL.dispose(); + this._lfoL = null; + this._lfoR.dispose(); + this._lfoR = null; + for (var i = 0; i < this._filtersL.length; i++) { + this._filtersL[i].disconnect(); + this._filtersL[i] = null; + } + this._filtersL = null; + for (var j = 0; j < this._filtersR.length; j++) { + this._filtersR[j].disconnect(); + this._filtersR[j] = null; + } + this._filtersR = null; + this.frequency = null; + return this; + }; + return Tone.Phaser; + }); + Module(function (Tone) { + + /** + * @class Just like a stereo feedback effect, but the feedback is routed from left to right + * and right to left instead of on the same channel. + * + * @constructor + * @extends {Tone.StereoEffect} + */ + Tone.StereoXFeedbackEffect = function () { + var options = Tone.defaults(arguments, ['feedback'], Tone.FeedbackEffect); + Tone.StereoEffect.call(this, options); + /** + * The amount of feedback from the output + * back into the input of the effect (routed + * across left and right channels). + * @type {NormalRange} + * @signal + */ + this.feedback = new Tone.Signal(options.feedback, Tone.Type.NormalRange); + /** + * the left side feeback + * @type {Tone.Gain} + * @private + */ + this._feedbackLR = new Tone.Gain(); + /** + * the right side feeback + * @type {Tone.Gain} + * @private + */ + this._feedbackRL = new Tone.Gain(); + //connect it up + this.effectReturnL.chain(this._feedbackLR, this.effectSendR); + this.effectReturnR.chain(this._feedbackRL, this.effectSendL); + this.feedback.fan(this._feedbackLR.gain, this._feedbackRL.gain); + this._readOnly(['feedback']); + }; + Tone.extend(Tone.StereoXFeedbackEffect, Tone.StereoEffect); + /** + * clean up + * @returns {Tone.StereoXFeedbackEffect} this + */ + Tone.StereoXFeedbackEffect.prototype.dispose = function () { + Tone.StereoEffect.prototype.dispose.call(this); + this._writable(['feedback']); + this.feedback.dispose(); + this.feedback = null; + this._feedbackLR.dispose(); + this._feedbackLR = null; + this._feedbackRL.dispose(); + this._feedbackRL = null; + return this; + }; + return Tone.StereoXFeedbackEffect; + }); + Module(function (Tone) { + + /** + * @class Tone.PingPongDelay is a feedback delay effect where the echo is heard + * first in one channel and next in the opposite channel. In a stereo + * system these are the right and left channels. + * PingPongDelay in more simplified terms is two Tone.FeedbackDelays + * with independent delay values. Each delay is routed to one channel + * (left or right), and the channel triggered second will always + * trigger at the same interval after the first. + * + * @constructor + * @extends {Tone.StereoXFeedbackEffect} + * @param {Time|Object} [delayTime] The delayTime between consecutive echos. + * @param {NormalRange=} feedback The amount of the effected signal which + * is fed back through the delay. + * @example + * var pingPong = new Tone.PingPongDelay("4n", 0.2).toMaster(); + * var drum = new Tone.DrumSynth().connect(pingPong); + * drum.triggerAttackRelease("C4", "32n"); + */ + Tone.PingPongDelay = function () { + var options = Tone.defaults(arguments, [ + 'delayTime', + 'feedback' + ], Tone.PingPongDelay); + Tone.StereoXFeedbackEffect.call(this, options); + /** + * the delay node on the left side + * @type {Tone.Delay} + * @private + */ + this._leftDelay = new Tone.Delay(0, options.maxDelayTime); + /** + * the delay node on the right side + * @type {Tone.Delay} + * @private + */ + this._rightDelay = new Tone.Delay(0, options.maxDelayTime); + /** + * the predelay on the right side + * @type {Tone.Delay} + * @private + */ + this._rightPreDelay = new Tone.Delay(0, options.maxDelayTime); + /** + * the delay time signal + * @type {Time} + * @signal + */ + this.delayTime = new Tone.Signal(options.delayTime, Tone.Type.Time); + //connect it up + this.effectSendL.chain(this._leftDelay, this.effectReturnL); + this.effectSendR.chain(this._rightPreDelay, this._rightDelay, this.effectReturnR); + this.delayTime.fan(this._leftDelay.delayTime, this._rightDelay.delayTime, this._rightPreDelay.delayTime); + //rearranged the feedback to be after the rightPreDelay + this._feedbackLR.disconnect(); + this._feedbackLR.connect(this._rightDelay); + this._readOnly(['delayTime']); + }; + Tone.extend(Tone.PingPongDelay, Tone.StereoXFeedbackEffect); + /** + * @static + * @type {Object} + */ + Tone.PingPongDelay.defaults = { + 'delayTime': 0.25, + 'maxDelayTime': 1 + }; + /** + * Clean up. + * @returns {Tone.PingPongDelay} this + */ + Tone.PingPongDelay.prototype.dispose = function () { + Tone.StereoXFeedbackEffect.prototype.dispose.call(this); + this._leftDelay.dispose(); + this._leftDelay = null; + this._rightDelay.dispose(); + this._rightDelay = null; + this._rightPreDelay.dispose(); + this._rightPreDelay = null; + this._writable(['delayTime']); + this.delayTime.dispose(); + this.delayTime = null; + return this; + }; + return Tone.PingPongDelay; + }); + Module(function (Tone) { + + /** + * @class Tone.PitchShift does near-realtime pitch shifting to the incoming signal. + * The effect is achieved by speeding up or slowing down the delayTime + * of a DelayNode using a sawtooth wave. + * Algorithm found in [this pdf](http://dsp-book.narod.ru/soundproc.pdf). + * Additional reference by [Miller Pucket](http://msp.ucsd.edu/techniques/v0.11/book-html/node115.html). + * + * @extends {Tone.FeedbackEffect} + * @param {Interval=} pitch The interval to transpose the incoming signal by. + */ + Tone.PitchShift = function () { + var options = Tone.defaults(arguments, ['pitch'], Tone.PitchShift); + Tone.FeedbackEffect.call(this, options); + /** + * The pitch signal + * @type {Tone.Signal} + * @private + */ + this._frequency = new Tone.Signal(0); + /** + * Uses two DelayNodes to cover up the jump in + * the sawtooth wave. + * @type {DelayNode} + * @private + */ + this._delayA = new Tone.Delay(0, 1); + /** + * The first LFO. + * @type {Tone.LFO} + * @private + */ + this._lfoA = new Tone.LFO({ + 'min': 0, + 'max': 0.1, + 'type': 'sawtooth' + }).connect(this._delayA.delayTime); + /** + * The second DelayNode + * @type {DelayNode} + * @private + */ + this._delayB = new Tone.Delay(0, 1); + /** + * The first LFO. + * @type {Tone.LFO} + * @private + */ + this._lfoB = new Tone.LFO({ + 'min': 0, + 'max': 0.1, + 'type': 'sawtooth', + 'phase': 180 + }).connect(this._delayB.delayTime); + /** + * Crossfade quickly between the two delay lines + * to cover up the jump in the sawtooth wave + * @type {Tone.CrossFade} + * @private + */ + this._crossFade = new Tone.CrossFade(); + /** + * LFO which alternates between the two + * delay lines to cover up the disparity in the + * sawtooth wave. + * @type {Tone.LFO} + * @private + */ + this._crossFadeLFO = new Tone.LFO({ + 'min': 0, + 'max': 1, + 'type': 'triangle', + 'phase': 90 + }).connect(this._crossFade.fade); + /** + * The delay node + * @type {Tone.Delay} + * @private + */ + this._feedbackDelay = new Tone.Delay(options.delayTime); + /** + * The amount of delay on the input signal + * @type {Time} + * @signal + */ + this.delayTime = this._feedbackDelay.delayTime; + this._readOnly('delayTime'); + /** + * Hold the current pitch + * @type {Number} + * @private + */ + this._pitch = options.pitch; + /** + * Hold the current windowSize + * @type {Number} + * @private + */ + this._windowSize = options.windowSize; + //connect the two delay lines up + this._delayA.connect(this._crossFade.a); + this._delayB.connect(this._crossFade.b); + //connect the frequency + this._frequency.fan(this._lfoA.frequency, this._lfoB.frequency, this._crossFadeLFO.frequency); + //route the input + this.effectSend.fan(this._delayA, this._delayB); + this._crossFade.chain(this._feedbackDelay, this.effectReturn); + //start the LFOs at the same time + var now = this.now(); + this._lfoA.start(now); + this._lfoB.start(now); + this._crossFadeLFO.start(now); + //set the initial value + this.windowSize = this._windowSize; + }; + Tone.extend(Tone.PitchShift, Tone.FeedbackEffect); + /** + * default values + * @static + * @type {Object} + * @const + */ + Tone.PitchShift.defaults = { + 'pitch': 0, + 'windowSize': 0.1, + 'delayTime': 0, + 'feedback': 0 + }; + /** + * Repitch the incoming signal by some interval (measured + * in semi-tones). + * @memberOf Tone.PitchShift# + * @type {Interval} + * @name pitch + * @example + * pitchShift.pitch = -12; //down one octave + * pitchShift.pitch = 7; //up a fifth + */ + Object.defineProperty(Tone.PitchShift.prototype, 'pitch', { + get: function () { + return this._pitch; + }, + set: function (interval) { + this._pitch = interval; + var factor = 0; + if (interval < 0) { + this._lfoA.min = 0; + this._lfoA.max = this._windowSize; + this._lfoB.min = 0; + this._lfoB.max = this._windowSize; + factor = Tone.intervalToFrequencyRatio(interval - 1) + 1; + } else { + this._lfoA.min = this._windowSize; + this._lfoA.max = 0; + this._lfoB.min = this._windowSize; + this._lfoB.max = 0; + factor = Tone.intervalToFrequencyRatio(interval) - 1; + } + this._frequency.value = factor * (1.2 / this._windowSize); + } + }); + /** + * The window size corresponds roughly to the sample length in a looping sampler. + * Smaller values are desirable for a less noticeable delay time of the pitch shifted + * signal, but larger values will result in smoother pitch shifting for larger intervals. + * A nominal range of 0.03 to 0.1 is recommended. + * @memberOf Tone.PitchShift# + * @type {Time} + * @name windowSize + * @example + * pitchShift.windowSize = 0.1; + */ + Object.defineProperty(Tone.PitchShift.prototype, 'windowSize', { + get: function () { + return this._windowSize; + }, + set: function (size) { + this._windowSize = this.toSeconds(size); + this.pitch = this._pitch; + } + }); + /** + * Clean up. + * @return {Tone.PitchShift} this + */ + Tone.PitchShift.prototype.dispose = function () { + Tone.FeedbackEffect.prototype.dispose.call(this); + this._frequency.dispose(); + this._frequency = null; + this._delayA.disconnect(); + this._delayA = null; + this._delayB.disconnect(); + this._delayB = null; + this._lfoA.dispose(); + this._lfoA = null; + this._lfoB.dispose(); + this._lfoB = null; + this._crossFade.dispose(); + this._crossFade = null; + this._crossFadeLFO.dispose(); + this._crossFadeLFO = null; + this._writable('delayTime'); + this._feedbackDelay.dispose(); + this._feedbackDelay = null; + this.delayTime = null; + return this; + }; + return Tone.PitchShift; + }); + Module(function (Tone) { + /** + * @class Wrapper around the native BufferSourceNode. + * @extends {Tone.AudioNode} + * @param {AudioBuffer|Tone.Buffer} buffer The buffer to play + * @param {Function} onload The callback to invoke when the + * buffer is done playing. + */ + Tone.BufferSource = function () { + var options = Tone.defaults(arguments, [ + 'buffer', + 'onload' + ], Tone.BufferSource); + Tone.AudioNode.call(this, options); + /** + * The callback to invoke after the + * buffer source is done playing. + * @type {Function} + */ + this.onended = options.onended; + /** + * The time that the buffer was started. + * @type {Number} + * @private + */ + this._startTime = -1; + /** + * An additional flag if the actual BufferSourceNode + * has been started. b/c stopping an unstarted buffer + * will throw it into an invalid state + * @type {Boolean} + * @private + */ + this._sourceStarted = false; + /** + * Flag if the source has already been stopped + * @type {Boolean} + * @private + */ + this._sourceStopped = false; + /** + * The time that the buffer is scheduled to stop. + * @type {Number} + * @private + */ + this._stopTime = -1; + /** + * The gain node which envelopes the BufferSource + * @type {Tone.Gain} + * @private + */ + this._gainNode = this.output = new Tone.Gain(); + /** + * The buffer source + * @type {AudioBufferSourceNode} + * @private + */ + this._source = this.context.createBufferSource(); + this._source.connect(this._gainNode); + this._source.onended = this._onended.bind(this); + /** + * The private buffer instance + * @type {Tone.Buffer} + * @private + */ + this._buffer = new Tone.Buffer(options.buffer, options.onload); + /** + * The playbackRate of the buffer + * @type {Positive} + * @signal + */ + this.playbackRate = new Tone.Param(this._source.playbackRate, Tone.Type.Positive); + /** + * The fadeIn time of the amplitude envelope. + * @type {Time} + */ + this.fadeIn = options.fadeIn; + /** + * The fadeOut time of the amplitude envelope. + * @type {Time} + */ + this.fadeOut = options.fadeOut; + /** + * The curve applied to the fades, either "linear" or "exponential" + * @type {String} + */ + this.curve = options.curve; + /** + * The value that the buffer ramps to + * @type {Gain} + * @private + */ + this._gain = 1; + /** + * The onended timeout + * @type {Number} + * @private + */ + this._onendedTimeout = -1; + //set some values initially + this.loop = options.loop; + this.loopStart = options.loopStart; + this.loopEnd = options.loopEnd; + this.playbackRate.value = options.playbackRate; + }; + Tone.extend(Tone.BufferSource, Tone.AudioNode); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.BufferSource.defaults = { + 'onended': Tone.noOp, + 'onload': Tone.noOp, + 'loop': false, + 'loopStart': 0, + 'loopEnd': 0, + 'fadeIn': 0, + 'fadeOut': 0, + 'curve': 'linear', + 'playbackRate': 1 + }; + /** + * Returns the playback state of the source, either "started" or "stopped". + * @type {Tone.State} + * @readOnly + * @memberOf Tone.BufferSource# + * @name state + */ + Object.defineProperty(Tone.BufferSource.prototype, 'state', { + get: function () { + return this.getStateAtTime(this.now()); + } + }); + /** + * Get the playback state at the given time + * @param {Time} time The time to test the state at + * @return {Tone.State} The playback state. + */ + Tone.BufferSource.prototype.getStateAtTime = function (time) { + time = this.toSeconds(time); + if (this._startTime !== -1 && time >= this._startTime && !this._sourceStopped) { + return Tone.State.Started; + } else { + return Tone.State.Stopped; + } + }; + /** + * Start the buffer + * @param {Time} [startTime=now] When the player should start. + * @param {Time} [offset=0] The offset from the beginning of the sample + * to start at. + * @param {Time=} duration How long the sample should play. If no duration + * is given, it will default to the full length + * of the sample (minus any offset) + * @param {Gain} [gain=1] The gain to play the buffer back at. + * @param {Time=} fadeInTime The optional fadeIn ramp time. + * @return {Tone.BufferSource} this + */ + Tone.BufferSource.prototype.start = function (time, offset, duration, gain, fadeInTime) { + if (this._startTime !== -1) { + throw new Error('Tone.BufferSource can only be started once.'); + } + if (!this.buffer.loaded) { + throw new Error('Tone.BufferSource: buffer is either not set or not loaded.'); + } + time = this.toSeconds(time); + //if it's a loop the default offset is the loopstart point + if (this.loop) { + offset = Tone.defaultArg(offset, this.loopStart); + } else { + //otherwise the default offset is 0 + offset = Tone.defaultArg(offset, 0); + } + offset = this.toSeconds(offset); + gain = Tone.defaultArg(gain, 1); + this._gain = gain; + fadeInTime = this.toSeconds(Tone.defaultArg(fadeInTime, this.fadeIn)); + this.fadeIn = fadeInTime; + if (fadeInTime > 0) { + this._gainNode.gain.setValueAtTime(0, time); + if (this.curve === 'linear') { + this._gainNode.gain.linearRampToValueAtTime(this._gain, time + fadeInTime); + } else { + this._gainNode.gain.exponentialApproachValueAtTime(this._gain, time, fadeInTime); + } + } else { + this._gainNode.gain.setValueAtTime(gain, time); + } + this._startTime = time; + var computedDur = this.toSeconds(Tone.defaultArg(duration, this.buffer.duration - offset % this.buffer.duration)); + computedDur = Math.max(computedDur, 0); + if (Tone.isDefined(duration)) { + //clip the duration when not looping + if (!this.loop) { + computedDur = Math.min(computedDur, this.buffer.duration - offset % this.buffer.duration); + } + this.stop(time + computedDur, this.fadeOut); + } + //start the buffer source + if (this.loop) { + //modify the offset if it's greater than the loop time + var loopEnd = this.loopEnd || this.buffer.duration; + var loopStart = this.loopStart; + var loopDuration = loopEnd - loopStart; + //move the offset back + if (offset >= loopEnd) { + offset = (offset - loopStart) % loopDuration + loopStart; + } + } + this._source.buffer = this.buffer.get(); + this._source.loopEnd = this.loopEnd || this.buffer.duration; + if (offset < this.buffer.duration) { + this._sourceStarted = true; + this._source.start(time, offset); + } + return this; + }; + /** + * Stop the buffer. Optionally add a ramp time to fade the + * buffer out. + * @param {Time=} time The time the buffer should stop. + * @param {Time=} fadeOutTime How long the gain should fade out for + * @return {Tone.BufferSource} this + */ + Tone.BufferSource.prototype.stop = function (time, fadeOutTime) { + if (!this.buffer.loaded) { + throw new Error('Tone.BufferSource: buffer is either not set or not loaded.'); + } + if (this._sourceStopped) { + return; + } + time = this.toSeconds(time); + //if the event has already been scheduled, clear it + if (this._stopTime !== -1) { + this.cancelStop(); + } + //stop if it's schedule before the start time + if (time <= this._startTime) { + this._gainNode.gain.cancelScheduledValues(time); + this._gainNode.gain.value = 0; + return this; + } + time = Math.max(this._startTime + this.fadeIn + this.sampleTime, time); + //cancel the previous curve + this._gainNode.gain.cancelScheduledValues(time); + this._stopTime = time; + //the fadeOut time + fadeOutTime = this.toSeconds(Tone.defaultArg(fadeOutTime, this.fadeOut)); + var heldDuration = time - this._startTime - this.fadeIn - this.sampleTime; + if (!this.loop) { + //make sure the fade does not go beyond the length of the buffer + heldDuration = Math.min(heldDuration, this.buffer.duration); + } + fadeOutTime = Math.min(heldDuration, fadeOutTime); + var startFade = time - fadeOutTime; + if (fadeOutTime > this.sampleTime) { + this._gainNode.gain.setValueAtTime(this._gain, startFade); + if (this.curve === 'linear') { + this._gainNode.gain.linearRampToValueAtTime(0, time); + } else { + this._gainNode.gain.exponentialApproachValueAtTime(0, startFade, fadeOutTime); + } + } else { + this._gainNode.gain.setValueAtTime(0, time); + } + Tone.context.clearTimeout(this._onendedTimeout); + this._onendedTimeout = Tone.context.setTimeout(this._onended.bind(this), this._stopTime - this.now()); + return this; + }; + /** + * Cancel a scheduled stop event + * @return {Tone.BufferSource} this + */ + Tone.BufferSource.prototype.cancelStop = function () { + if (this._startTime !== -1 && !this._sourceStopped) { + //cancel the stop envelope + var fadeInTime = this.toSeconds(this.fadeIn); + this._gainNode.gain.cancelScheduledValues(this._startTime + fadeInTime + this.sampleTime); + this._gainNode.gain.setValueAtTime(1, Math.max(this.now(), this._startTime + fadeInTime + this.sampleTime)); + this.context.clearTimeout(this._onendedTimeout); + this._stopTime = -1; + } + return this; + }; + /** + * Internal callback when the buffer is ended. + * Invokes `onended` and disposes the node. + * @private + */ + Tone.BufferSource.prototype._onended = function () { + if (!this._sourceStopped) { + this._sourceStopped = true; + //allow additional time for the exponential curve to fully decay + var additionalTail = this.curve === 'exponential' ? this.fadeOut * 2 : 0; + if (this._sourceStarted && this._stopTime !== -1) { + this._source.stop(this._stopTime + additionalTail); + } + this.onended(this); + } + }; + /** + * If loop is true, the loop will start at this position. + * @memberOf Tone.BufferSource# + * @type {Time} + * @name loopStart + */ + Object.defineProperty(Tone.BufferSource.prototype, 'loopStart', { + get: function () { + return this._source.loopStart; + }, + set: function (loopStart) { + this._source.loopStart = this.toSeconds(loopStart); + } + }); + /** + * If loop is true, the loop will end at this position. + * @memberOf Tone.BufferSource# + * @type {Time} + * @name loopEnd + */ + Object.defineProperty(Tone.BufferSource.prototype, 'loopEnd', { + get: function () { + return this._source.loopEnd; + }, + set: function (loopEnd) { + this._source.loopEnd = this.toSeconds(loopEnd); + } + }); + /** + * The audio buffer belonging to the player. + * @memberOf Tone.BufferSource# + * @type {Tone.Buffer} + * @name buffer + */ + Object.defineProperty(Tone.BufferSource.prototype, 'buffer', { + get: function () { + return this._buffer; + }, + set: function (buffer) { + this._buffer.set(buffer); + } + }); + /** + * If the buffer should loop once it's over. + * @memberOf Tone.BufferSource# + * @type {Boolean} + * @name loop + */ + Object.defineProperty(Tone.BufferSource.prototype, 'loop', { + get: function () { + return this._source.loop; + }, + set: function (loop) { + this._source.loop = loop; + this.cancelStop(); + } + }); + /** + * Clean up. + * @return {Tone.BufferSource} this + */ + Tone.BufferSource.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this.onended = null; + this._source.onended = null; + this._source.disconnect(); + this._source = null; + this._gainNode.dispose(); + this._gainNode = null; + this._buffer.dispose(); + this._buffer = null; + this._startTime = -1; + this.playbackRate = null; + Tone.context.clearTimeout(this._onendedTimeout); + return this; + }; + return Tone.BufferSource; + }); + Module(function (Tone) { + + /** + * @class Tone.Noise is a noise generator. It uses looped noise buffers to save on performance. + * Tone.Noise supports the noise types: "pink", "white", and "brown". Read more about + * colors of noise on [Wikipedia](https://en.wikipedia.org/wiki/Colors_of_noise). + * + * @constructor + * @extends {Tone.Source} + * @param {string} type the noise type (white|pink|brown) + * @example + * //initialize the noise and start + * var noise = new Tone.Noise("pink").start(); + * + * //make an autofilter to shape the noise + * var autoFilter = new Tone.AutoFilter({ + * "frequency" : "8m", + * "min" : 800, + * "max" : 15000 + * }).connect(Tone.Master); + * + * //connect the noise + * noise.connect(autoFilter); + * //start the autofilter LFO + * autoFilter.start() + */ + Tone.Noise = function () { + var options = Tone.defaults(arguments, ['type'], Tone.Noise); + Tone.Source.call(this, options); + /** + * @private + * @type {AudioBufferSourceNode} + */ + this._source = null; + /** + * the buffer + * @private + * @type {AudioBuffer} + */ + this._type = options.type; + /** + * The playback rate of the noise. Affects + * the "frequency" of the noise. + * @type {Positive} + * @signal + */ + this._playbackRate = options.playbackRate; + }; + Tone.extend(Tone.Noise, Tone.Source); + /** + * the default parameters + * + * @static + * @const + * @type {Object} + */ + Tone.Noise.defaults = { + 'type': 'white', + 'playbackRate': 1 + }; + /** + * The type of the noise. Can be "white", "brown", or "pink". + * @memberOf Tone.Noise# + * @type {string} + * @name type + * @example + * noise.type = "white"; + */ + Object.defineProperty(Tone.Noise.prototype, 'type', { + get: function () { + return this._type; + }, + set: function (type) { + if (this._type !== type) { + if (type in _noiseBuffers) { + this._type = type; + //if it's playing, stop and restart it + if (this.state === Tone.State.Started) { + var now = this.now(); + this._stop(now); + this._start(now); + } + } else { + throw new TypeError('Tone.Noise: invalid type: ' + type); + } + } + } + }); + /** + * The playback rate of the noise. Affects + * the "frequency" of the noise. + * @type {Positive} + * @signal + */ + Object.defineProperty(Tone.Noise.prototype, 'playbackRate', { + get: function () { + return this._playbackRate; + }, + set: function (rate) { + this._playbackRate = rate; + if (this._source) { + this._source.playbackRate.value = rate; + } + } + }); + /** + * internal start method + * + * @param {Time} time + * @private + */ + Tone.Noise.prototype._start = function (time) { + var buffer = _noiseBuffers[this._type]; + this._source = new Tone.BufferSource(buffer).connect(this.output); + this._source.loop = true; + this._source.playbackRate.value = this._playbackRate; + this._source.start(this.toSeconds(time), Math.random() * (buffer.duration - 0.001)); + }; + /** + * internal stop method + * + * @param {Time} time + * @private + */ + Tone.Noise.prototype._stop = function (time) { + if (this._source) { + this._source.stop(this.toSeconds(time)); + this._source = null; + } + }; + /** + * Restarts the noise. + * @param {[type]} time [description] + * @return {[type]} [description] + */ + Tone.Noise.prototype.restart = function (time) { + //TODO could be optimized by cancelling the buffer source 'stop' + //stop and restart + this._stop(time); + this._start(time); + }; + /** + * Clean up. + * @returns {Tone.Noise} this + */ + Tone.Noise.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + if (this._source !== null) { + this._source.disconnect(); + this._source = null; + } + this._buffer = null; + return this; + }; + /////////////////////////////////////////////////////////////////////////// + // THE BUFFERS + /////////////////////////////////////////////////////////////////////////// + //Noise buffer stats + var bufferLength = 44100 * 5; + var channels = 2; + /** + * The noise arrays. Generated on initialization. + * borrowed heavily from https://github.com/zacharydenton/noise.js + * (c) 2013 Zach Denton (MIT) + * @static + * @private + * @type {Array} + */ + var _noiseArrays = { + 'pink': function () { + var buffer = []; + for (var channelNum = 0; channelNum < channels; channelNum++) { + var channel = new Float32Array(bufferLength); + buffer[channelNum] = channel; + var b0, b1, b2, b3, b4, b5, b6; + b0 = b1 = b2 = b3 = b4 = b5 = b6 = 0; + for (var i = 0; i < bufferLength; i++) { + var white = Math.random() * 2 - 1; + b0 = 0.99886 * b0 + white * 0.0555179; + b1 = 0.99332 * b1 + white * 0.0750759; + b2 = 0.969 * b2 + white * 0.153852; + b3 = 0.8665 * b3 + white * 0.3104856; + b4 = 0.55 * b4 + white * 0.5329522; + b5 = -0.7616 * b5 - white * 0.016898; + channel[i] = b0 + b1 + b2 + b3 + b4 + b5 + b6 + white * 0.5362; + channel[i] *= 0.11; + // (roughly) compensate for gain + b6 = white * 0.115926; + } + } + return buffer; + }(), + 'brown': function () { + var buffer = []; + for (var channelNum = 0; channelNum < channels; channelNum++) { + var channel = new Float32Array(bufferLength); + buffer[channelNum] = channel; + var lastOut = 0; + for (var i = 0; i < bufferLength; i++) { + var white = Math.random() * 2 - 1; + channel[i] = (lastOut + 0.02 * white) / 1.02; + lastOut = channel[i]; + channel[i] *= 3.5; // (roughly) compensate for gain + } + } + return buffer; + }(), + 'white': function () { + var buffer = []; + for (var channelNum = 0; channelNum < channels; channelNum++) { + var channel = new Float32Array(bufferLength); + buffer[channelNum] = channel; + for (var i = 0; i < bufferLength; i++) { + channel[i] = Math.random() * 2 - 1; + } + } + return buffer; + }() + }; + /** + * static noise buffers + * @static + * @private + * @type {Tone.Buffer} + */ + var _noiseBuffers = {}; + //create the Tone.Buffers + function createBuffers() { + for (var type in _noiseArrays) { + _noiseBuffers[type] = new Tone.Buffer().fromArray(_noiseArrays[type]); + } + } + //create the noise buffers + Tone.getContext(createBuffers); + Tone.Context.on('init', createBuffers); + return Tone.Noise; + }); + Module(function (Tone) { + + /** + * @class Simple convolution created with decaying noise. + * Generates an Impulse Response Buffer + * with Tone.Offline then feeds the IR into ConvolverNode. + * Note: the Reverb will not make any sound until [generate](#generate) + * has been invoked and resolved. + * + * Inspiration from [ReverbGen](https://github.com/adelespinasse/reverbGen). + * Copyright (c) 2014 Alan deLespinasse Apache 2.0 License. + * + * @extends {Tone.Convolver} + * @param {Time=} decay The amount of time it will reverberate for. + */ + Tone.Reverb = function () { + var options = Tone.defaults(arguments, ['decay'], Tone.Reverb); + Tone.Effect.call(this, options); + /** + * Convolver node + * @type {ConvolverNode} + * @private + */ + this._convolver = this.context.createConvolver(); + /** + * The duration of the reverb + * @type {Time} + */ + this.decay = options.decay; + /** + * The amount of time before the reverb is fully + * ramped in. + * @type {Time} + */ + this.preDelay = options.preDelay; + this.connectEffect(this._convolver); + }; + Tone.extend(Tone.Reverb, Tone.Effect); + /** + * The defaults + * @type {Object} + * @static + */ + Tone.Reverb.defaults = { + 'decay': 1.5, + 'preDelay': 0.01 + }; + /** + * Generate the Impulse Response. Returns a promise while the IR is being + * generated. + * @return {Promise<Tone.Reverb>} Promise which returns this object. + */ + Tone.Reverb.prototype.generate = function () { + return Tone.Offline(function () { + //create a noise burst which decays over the duration + var noiseL = new Tone.Noise(); + var noiseR = new Tone.Noise(); + var merge = new Tone.Merge(); + noiseL.connect(merge.left); + noiseR.connect(merge.right); + var gainNode = new Tone.Gain().toMaster(); + merge.connect(gainNode); + noiseL.start(0); + noiseR.start(0); + //short fade in + gainNode.gain.setValueAtTime(0, 0); + gainNode.gain.linearRampToValueAtTime(1, this.preDelay); + //decay + gainNode.gain.exponentialApproachValueAtTime(0, this.preDelay, this.decay - this.preDelay); + }.bind(this), this.decay).then(function (buffer) { + this._convolver.buffer = buffer.get(); + return this; + }.bind(this)); + }; + /** + * Clean up. + * @return {Tone.Reverb} this + */ + Tone.Reverb.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._convolver.disconnect(); + this._convolver = null; + return this; + }; + return Tone.Reverb; + }); + Module(function (Tone) { + + /** + * @class Base class for stereo feedback effects where the effectReturn + * is fed back into the same channel. + * + * @constructor + * @extends {Tone.StereoEffect} + */ + Tone.StereoFeedbackEffect = function () { + var options = Tone.defaults(arguments, ['feedback'], Tone.FeedbackEffect); + Tone.StereoEffect.call(this, options); + /** + * controls the amount of feedback + * @type {NormalRange} + * @signal + */ + this.feedback = new Tone.Signal(options.feedback, Tone.Type.NormalRange); + /** + * the left side feeback + * @type {Tone.Gain} + * @private + */ + this._feedbackL = new Tone.Gain(); + /** + * the right side feeback + * @type {Tone.Gain} + * @private + */ + this._feedbackR = new Tone.Gain(); + //connect it up + this.effectReturnL.chain(this._feedbackL, this.effectSendL); + this.effectReturnR.chain(this._feedbackR, this.effectSendR); + this.feedback.fan(this._feedbackL.gain, this._feedbackR.gain); + this._readOnly(['feedback']); + }; + Tone.extend(Tone.StereoFeedbackEffect, Tone.StereoEffect); + /** + * clean up + * @returns {Tone.StereoFeedbackEffect} this + */ + Tone.StereoFeedbackEffect.prototype.dispose = function () { + Tone.StereoEffect.prototype.dispose.call(this); + this._writable(['feedback']); + this.feedback.dispose(); + this.feedback = null; + this._feedbackL.dispose(); + this._feedbackL = null; + this._feedbackR.dispose(); + this._feedbackR = null; + return this; + }; + return Tone.StereoFeedbackEffect; + }); + Module(function (Tone) { + + /** + * @class Applies a width factor to the mid/side seperation. + * 0 is all mid and 1 is all side. + * Algorithm found in [kvraudio forums](http://www.kvraudio.com/forum/viewtopic.php?t=212587). + * <br><br> + * <code> + * Mid *= 2*(1-width)<br> + * Side *= 2*width + * </code> + * + * @extends {Tone.MidSideEffect} + * @constructor + * @param {NormalRange|Object} [width] The stereo width. A width of 0 is mono and 1 is stereo. 0.5 is no change. + */ + Tone.StereoWidener = function () { + var options = Tone.defaults(arguments, ['width'], Tone.StereoWidener); + Tone.MidSideEffect.call(this, options); + /** + * The width control. 0 = 100% mid. 1 = 100% side. 0.5 = no change. + * @type {NormalRange} + * @signal + */ + this.width = new Tone.Signal(options.width, Tone.Type.NormalRange); + this._readOnly(['width']); + /** + * Two times the (1-width) for the mid channel + * @type {Tone.Multiply} + * @private + */ + this._twoTimesWidthMid = new Tone.Multiply(2); + /** + * Two times the width for the side channel + * @type {Tone.Multiply} + * @private + */ + this._twoTimesWidthSide = new Tone.Multiply(2); + /** + * Mid multiplier + * @type {Tone.Multiply} + * @private + */ + this._midMult = new Tone.Multiply(); + this._twoTimesWidthMid.connect(this._midMult, 0, 1); + this.midSend.chain(this._midMult, this.midReturn); + /** + * 1 - width + * @type {Tone} + */ + this._oneMinusWidth = new Tone.Subtract(); + this._oneMinusWidth.connect(this._twoTimesWidthMid); + this.context.getConstant(1).connect(this._oneMinusWidth, 0, 0); + this.width.connect(this._oneMinusWidth, 0, 1); + /** + * Side multiplier + * @type {Tone.Multiply} + * @private + */ + this._sideMult = new Tone.Multiply(); + this.width.connect(this._twoTimesWidthSide); + this._twoTimesWidthSide.connect(this._sideMult, 0, 1); + this.sideSend.chain(this._sideMult, this.sideReturn); + }; + Tone.extend(Tone.StereoWidener, Tone.MidSideEffect); + /** + * the default values + * @static + * @type {Object} + */ + Tone.StereoWidener.defaults = { 'width': 0.5 }; + /** + * Clean up. + * @returns {Tone.StereoWidener} this + */ + Tone.StereoWidener.prototype.dispose = function () { + Tone.MidSideEffect.prototype.dispose.call(this); + this._writable(['width']); + this.width.dispose(); + this.width = null; + this._midMult.dispose(); + this._midMult = null; + this._sideMult.dispose(); + this._sideMult = null; + this._twoTimesWidthMid.dispose(); + this._twoTimesWidthMid = null; + this._twoTimesWidthSide.dispose(); + this._twoTimesWidthSide = null; + this._oneMinusWidth.dispose(); + this._oneMinusWidth = null; + return this; + }; + return Tone.StereoWidener; + }); + Module(function (Tone) { + + /** + * @class Tone.Tremolo modulates the amplitude of an incoming signal using a Tone.LFO. + * The type, frequency, and depth of the LFO is controllable. + * + * @extends {Tone.StereoEffect} + * @constructor + * @param {Frequency} [frequency] The rate of the effect. + * @param {NormalRange} [depth] The depth of the effect. + * @example + * //create a tremolo and start it's LFO + * var tremolo = new Tone.Tremolo(9, 0.75).toMaster().start(); + * //route an oscillator through the tremolo and start it + * var oscillator = new Tone.Oscillator().connect(tremolo).start(); + */ + Tone.Tremolo = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'depth' + ], Tone.Tremolo); + Tone.StereoEffect.call(this, options); + /** + * The tremelo LFO in the left channel + * @type {Tone.LFO} + * @private + */ + this._lfoL = new Tone.LFO({ + 'phase': options.spread, + 'min': 1, + 'max': 0 + }); + /** + * The tremelo LFO in the left channel + * @type {Tone.LFO} + * @private + */ + this._lfoR = new Tone.LFO({ + 'phase': options.spread, + 'min': 1, + 'max': 0 + }); + /** + * Where the gain is multiplied + * @type {Tone.Gain} + * @private + */ + this._amplitudeL = new Tone.Gain(); + /** + * Where the gain is multiplied + * @type {Tone.Gain} + * @private + */ + this._amplitudeR = new Tone.Gain(); + /** + * The frequency of the tremolo. + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency); + /** + * The depth of the effect. A depth of 0, has no effect + * on the amplitude, and a depth of 1 makes the amplitude + * modulate fully between 0 and 1. + * @type {NormalRange} + * @signal + */ + this.depth = new Tone.Signal(options.depth, Tone.Type.NormalRange); + this._readOnly([ + 'frequency', + 'depth' + ]); + this.effectSendL.chain(this._amplitudeL, this.effectReturnL); + this.effectSendR.chain(this._amplitudeR, this.effectReturnR); + this._lfoL.connect(this._amplitudeL.gain); + this._lfoR.connect(this._amplitudeR.gain); + this.frequency.fan(this._lfoL.frequency, this._lfoR.frequency); + this.depth.fan(this._lfoR.amplitude, this._lfoL.amplitude); + this.type = options.type; + this.spread = options.spread; + }; + Tone.extend(Tone.Tremolo, Tone.StereoEffect); + /** + * @static + * @const + * @type {Object} + */ + Tone.Tremolo.defaults = { + 'frequency': 10, + 'type': 'sine', + 'depth': 0.5, + 'spread': 180 + }; + /** + * Start the tremolo. + * @param {Time} [time=now] When the tremolo begins. + * @returns {Tone.Tremolo} this + */ + Tone.Tremolo.prototype.start = function (time) { + this._lfoL.start(time); + this._lfoR.start(time); + return this; + }; + /** + * Stop the tremolo. + * @param {Time} [time=now] When the tremolo stops. + * @returns {Tone.Tremolo} this + */ + Tone.Tremolo.prototype.stop = function (time) { + this._lfoL.stop(time); + this._lfoR.stop(time); + return this; + }; + /** + * Sync the effect to the transport. + * @param {Time} [delay=0] Delay time before starting the effect after the + * Transport has started. + * @returns {Tone.AutoFilter} this + */ + Tone.Tremolo.prototype.sync = function (delay) { + this._lfoL.sync(delay); + this._lfoR.sync(delay); + Tone.Transport.syncSignal(this.frequency); + return this; + }; + /** + * Unsync the filter from the transport + * @returns {Tone.Tremolo} this + */ + Tone.Tremolo.prototype.unsync = function () { + this._lfoL.unsync(); + this._lfoR.unsync(); + Tone.Transport.unsyncSignal(this.frequency); + return this; + }; + /** + * The Tremolo's oscillator type. + * @memberOf Tone.Tremolo# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.Tremolo.prototype, 'type', { + get: function () { + return this._lfoL.type; + }, + set: function (type) { + this._lfoL.type = type; + this._lfoR.type = type; + } + }); + /** + * Amount of stereo spread. When set to 0, both LFO's will be panned centrally. + * When set to 180, LFO's will be panned hard left and right respectively. + * @memberOf Tone.Tremolo# + * @type {Degrees} + * @name spread + */ + Object.defineProperty(Tone.Tremolo.prototype, 'spread', { + get: function () { + return this._lfoR.phase - this._lfoL.phase; //180 + }, + set: function (spread) { + this._lfoL.phase = 90 - spread / 2; + this._lfoR.phase = spread / 2 + 90; + } + }); + /** + * clean up + * @returns {Tone.Tremolo} this + */ + Tone.Tremolo.prototype.dispose = function () { + Tone.StereoEffect.prototype.dispose.call(this); + this._writable([ + 'frequency', + 'depth' + ]); + this._lfoL.dispose(); + this._lfoL = null; + this._lfoR.dispose(); + this._lfoR = null; + this._amplitudeL.dispose(); + this._amplitudeL = null; + this._amplitudeR.dispose(); + this._amplitudeR = null; + this.frequency = null; + this.depth = null; + return this; + }; + return Tone.Tremolo; + }); + Module(function (Tone) { + + /** + * @class A Vibrato effect composed of a Tone.Delay and a Tone.LFO. The LFO + * modulates the delayTime of the delay, causing the pitch to rise + * and fall. + * @extends {Tone.Effect} + * @param {Frequency} frequency The frequency of the vibrato. + * @param {NormalRange} depth The amount the pitch is modulated. + */ + Tone.Vibrato = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'depth' + ], Tone.Vibrato); + Tone.Effect.call(this, options); + /** + * The delay node used for the vibrato effect + * @type {Tone.Delay} + * @private + */ + this._delayNode = new Tone.Delay(0, options.maxDelay); + /** + * The LFO used to control the vibrato + * @type {Tone.LFO} + * @private + */ + this._lfo = new Tone.LFO({ + 'type': options.type, + 'min': 0, + 'max': options.maxDelay, + 'frequency': options.frequency, + 'phase': -90 //offse the phase so the resting position is in the center + }).start().connect(this._delayNode.delayTime); + /** + * The frequency of the vibrato + * @type {Frequency} + * @signal + */ + this.frequency = this._lfo.frequency; + /** + * The depth of the vibrato. + * @type {NormalRange} + * @signal + */ + this.depth = this._lfo.amplitude; + this.depth.value = options.depth; + this._readOnly([ + 'frequency', + 'depth' + ]); + this.effectSend.chain(this._delayNode, this.effectReturn); + }; + Tone.extend(Tone.Vibrato, Tone.Effect); + /** + * The defaults + * @type {Object} + * @const + */ + Tone.Vibrato.defaults = { + 'maxDelay': 0.005, + 'frequency': 5, + 'depth': 0.1, + 'type': 'sine' + }; + /** + * Type of oscillator attached to the Vibrato. + * @memberOf Tone.Vibrato# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.Vibrato.prototype, 'type', { + get: function () { + return this._lfo.type; + }, + set: function (type) { + this._lfo.type = type; + } + }); + /** + * Clean up. + * @returns {Tone.Vibrato} this + */ + Tone.Vibrato.prototype.dispose = function () { + Tone.Effect.prototype.dispose.call(this); + this._delayNode.dispose(); + this._delayNode = null; + this._lfo.dispose(); + this._lfo = null; + this._writable([ + 'frequency', + 'depth' + ]); + this.frequency = null; + this.depth = null; + }; + return Tone.Vibrato; + }); + Module(function (Tone) { + + /** + * @class Tone.Event abstracts away Tone.Transport.schedule and provides a schedulable + * callback for a single or repeatable events along the timeline. + * + * @extends {Tone} + * @param {function} callback The callback to invoke at the time. + * @param {*} value The value or values which should be passed to + * the callback function on invocation. + * @example + * var chord = new Tone.Event(function(time, chord){ + * //the chord as well as the exact time of the event + * //are passed in as arguments to the callback function + * }, ["D4", "E4", "F4"]); + * //start the chord at the beginning of the transport timeline + * chord.start(); + * //loop it every measure for 8 measures + * chord.loop = 8; + * chord.loopEnd = "1m"; + */ + Tone.Event = function () { + var options = Tone.defaults(arguments, [ + 'callback', + 'value' + ], Tone.Event); + Tone.call(this); + /** + * Loop value + * @type {Boolean|Positive} + * @private + */ + this._loop = options.loop; + /** + * The callback to invoke. + * @type {Function} + */ + this.callback = options.callback; + /** + * The value which is passed to the + * callback function. + * @type {*} + * @private + */ + this.value = options.value; + /** + * When the note is scheduled to start. + * @type {Number} + * @private + */ + this._loopStart = this.toTicks(options.loopStart); + /** + * When the note is scheduled to start. + * @type {Number} + * @private + */ + this._loopEnd = this.toTicks(options.loopEnd); + /** + * Tracks the scheduled events + * @type {Tone.TimelineState} + * @private + */ + this._state = new Tone.TimelineState(Tone.State.Stopped); + /** + * The playback speed of the note. A speed of 1 + * is no change. + * @private + * @type {Positive} + */ + this._playbackRate = 1; + /** + * A delay time from when the event is scheduled to start + * @type {Ticks} + * @private + */ + this._startOffset = 0; + /** + * private holder of probability value + * @type {NormalRange} + * @private + */ + this._probability = options.probability; + /** + * the amount of variation from the + * given time. + * @type {Boolean|Time} + * @private + */ + this._humanize = options.humanize; + /** + * If mute is true, the callback won't be + * invoked. + * @type {Boolean} + */ + this.mute = options.mute; + //set the initial values + this.playbackRate = options.playbackRate; + }; + Tone.extend(Tone.Event); + /** + * The default values + * @type {Object} + * @const + */ + Tone.Event.defaults = { + 'callback': Tone.noOp, + 'loop': false, + 'loopEnd': '1m', + 'loopStart': 0, + 'playbackRate': 1, + 'value': null, + 'probability': 1, + 'mute': false, + 'humanize': false + }; + /** + * Reschedule all of the events along the timeline + * with the updated values. + * @param {Time} after Only reschedules events after the given time. + * @return {Tone.Event} this + * @private + */ + Tone.Event.prototype._rescheduleEvents = function (after) { + //if no argument is given, schedules all of the events + after = Tone.defaultArg(after, -1); + this._state.forEachFrom(after, function (event) { + var duration; + if (event.state === Tone.State.Started) { + if (Tone.isDefined(event.id)) { + Tone.Transport.clear(event.id); + } + var startTick = event.time + Math.round(this.startOffset / this._playbackRate); + if (this._loop) { + duration = Infinity; + if (Tone.isNumber(this._loop)) { + duration = this._loop * this._getLoopDuration(); + } + var nextEvent = this._state.getAfter(startTick); + if (nextEvent !== null) { + duration = Math.min(duration, nextEvent.time - startTick); + } + if (duration !== Infinity) { + //schedule a stop since it's finite duration + this._state.setStateAtTime(Tone.State.Stopped, startTick + duration + 1); + duration = Tone.Ticks(duration); + } + var interval = Tone.Ticks(this._getLoopDuration()); + event.id = Tone.Transport.scheduleRepeat(this._tick.bind(this), interval, Tone.Ticks(startTick), duration); + } else { + event.id = Tone.Transport.schedule(this._tick.bind(this), Tone.Ticks(startTick)); + } + } + }.bind(this)); + return this; + }; + /** + * Returns the playback state of the note, either "started" or "stopped". + * @type {String} + * @readOnly + * @memberOf Tone.Event# + * @name state + */ + Object.defineProperty(Tone.Event.prototype, 'state', { + get: function () { + return this._state.getValueAtTime(Tone.Transport.ticks); + } + }); + /** + * The start from the scheduled start time + * @type {Ticks} + * @memberOf Tone.Event# + * @name startOffset + * @private + */ + Object.defineProperty(Tone.Event.prototype, 'startOffset', { + get: function () { + return this._startOffset; + }, + set: function (offset) { + this._startOffset = offset; + } + }); + /** + * The probability of the notes being triggered. + * @memberOf Tone.Event# + * @type {NormalRange} + * @name probability + */ + Object.defineProperty(Tone.Event.prototype, 'probability', { + get: function () { + return this._probability; + }, + set: function (prob) { + this._probability = prob; + } + }); + /** + * If set to true, will apply small random variation + * to the callback time. If the value is given as a time, it will randomize + * by that amount. + * @example + * event.humanize = true; + * @type {Boolean|Time} + * @name humanize + */ + Object.defineProperty(Tone.Event.prototype, 'humanize', { + get: function () { + return this._humanize; + }, + set: function (variation) { + this._humanize = variation; + } + }); + /** + * Start the note at the given time. + * @param {TimelinePosition} time When the note should start. + * @return {Tone.Event} this + */ + Tone.Event.prototype.start = function (time) { + time = this.toTicks(time); + if (this._state.getValueAtTime(time) === Tone.State.Stopped) { + this._state.add({ + 'state': Tone.State.Started, + 'time': time, + 'id': undefined + }); + this._rescheduleEvents(time); + } + return this; + }; + /** + * Stop the Event at the given time. + * @param {TimelinePosition} time When the note should stop. + * @return {Tone.Event} this + */ + Tone.Event.prototype.stop = function (time) { + this.cancel(time); + time = this.toTicks(time); + if (this._state.getValueAtTime(time) === Tone.State.Started) { + this._state.setStateAtTime(Tone.State.Stopped, time); + var previousEvent = this._state.getBefore(time); + var reschedulTime = time; + if (previousEvent !== null) { + reschedulTime = previousEvent.time; + } + this._rescheduleEvents(reschedulTime); + } + return this; + }; + /** + * Cancel all scheduled events greater than or equal to the given time + * @param {TimelinePosition} [time=0] The time after which events will be cancel. + * @return {Tone.Event} this + */ + Tone.Event.prototype.cancel = function (time) { + time = Tone.defaultArg(time, -Infinity); + time = this.toTicks(time); + this._state.forEachFrom(time, function (event) { + Tone.Transport.clear(event.id); + }); + this._state.cancel(time); + return this; + }; + /** + * The callback function invoker. Also + * checks if the Event is done playing + * @param {Number} time The time of the event in seconds + * @private + */ + Tone.Event.prototype._tick = function (time) { + var ticks = Tone.Transport.getTicksAtTime(time); + if (!this.mute && this._state.getValueAtTime(ticks) === Tone.State.Started) { + if (this.probability < 1 && Math.random() > this.probability) { + return; + } + if (this.humanize) { + var variation = 0.02; + if (!Tone.isBoolean(this.humanize)) { + variation = this.toSeconds(this.humanize); + } + time += (Math.random() * 2 - 1) * variation; + } + this.callback(time, this.value); + } + }; + /** + * Get the duration of the loop. + * @return {Ticks} + * @private + */ + Tone.Event.prototype._getLoopDuration = function () { + return Math.round((this._loopEnd - this._loopStart) / this._playbackRate); + }; + /** + * If the note should loop or not + * between Tone.Event.loopStart and + * Tone.Event.loopEnd. An integer + * value corresponds to the number of + * loops the Event does after it starts. + * @memberOf Tone.Event# + * @type {Boolean|Positive} + * @name loop + */ + Object.defineProperty(Tone.Event.prototype, 'loop', { + get: function () { + return this._loop; + }, + set: function (loop) { + this._loop = loop; + this._rescheduleEvents(); + } + }); + /** + * The playback rate of the note. Defaults to 1. + * @memberOf Tone.Event# + * @type {Positive} + * @name playbackRate + * @example + * note.loop = true; + * //repeat the note twice as fast + * note.playbackRate = 2; + */ + Object.defineProperty(Tone.Event.prototype, 'playbackRate', { + get: function () { + return this._playbackRate; + }, + set: function (rate) { + this._playbackRate = rate; + this._rescheduleEvents(); + } + }); + /** + * The loopEnd point is the time the event will loop + * if Tone.Event.loop is true. + * @memberOf Tone.Event# + * @type {Time} + * @name loopEnd + */ + Object.defineProperty(Tone.Event.prototype, 'loopEnd', { + get: function () { + return Tone.Ticks(this._loopEnd).toSeconds(); + }, + set: function (loopEnd) { + this._loopEnd = this.toTicks(loopEnd); + if (this._loop) { + this._rescheduleEvents(); + } + } + }); + /** + * The time when the loop should start. + * @memberOf Tone.Event# + * @type {Time} + * @name loopStart + */ + Object.defineProperty(Tone.Event.prototype, 'loopStart', { + get: function () { + return Tone.Ticks(this._loopStart).toSeconds(); + }, + set: function (loopStart) { + this._loopStart = this.toTicks(loopStart); + if (this._loop) { + this._rescheduleEvents(); + } + } + }); + /** + * The current progress of the loop interval. + * Returns 0 if the event is not started yet or + * it is not set to loop. + * @memberOf Tone.Event# + * @type {NormalRange} + * @name progress + * @readOnly + */ + Object.defineProperty(Tone.Event.prototype, 'progress', { + get: function () { + if (this._loop) { + var ticks = Tone.Transport.ticks; + var lastEvent = this._state.get(ticks); + if (lastEvent !== null && lastEvent.state === Tone.State.Started) { + var loopDuration = this._getLoopDuration(); + var progress = (ticks - lastEvent.time) % loopDuration; + return progress / loopDuration; + } else { + return 0; + } + } else { + return 0; + } + } + }); + /** + * Clean up + * @return {Tone.Event} this + */ + Tone.Event.prototype.dispose = function () { + this.cancel(); + this._state.dispose(); + this._state = null; + this.callback = null; + this.value = null; + }; + return Tone.Event; + }); + Module(function (Tone) { + /** + * @class Tone.Loop creates a looped callback at the + * specified interval. The callback can be + * started, stopped and scheduled along + * the Transport's timeline. + * @example + * var loop = new Tone.Loop(function(time){ + * //triggered every eighth note. + * console.log(time); + * }, "8n").start(0); + * Tone.Transport.start(); + * @extends {Tone} + * @param {Function} callback The callback to invoke with the event. + * @param {Time} interval The time between successive callback calls. + */ + Tone.Loop = function () { + var options = Tone.defaults(arguments, [ + 'callback', + 'interval' + ], Tone.Loop); + Tone.call(this); + /** + * The event which produces the callbacks + */ + this._event = new Tone.Event({ + 'callback': this._tick.bind(this), + 'loop': true, + 'loopEnd': options.interval, + 'playbackRate': options.playbackRate, + 'probability': options.probability + }); + /** + * The callback to invoke with the next event in the pattern + * @type {Function} + */ + this.callback = options.callback; + //set the iterations + this.iterations = options.iterations; + }; + Tone.extend(Tone.Loop); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.Loop.defaults = { + 'interval': '4n', + 'callback': Tone.noOp, + 'playbackRate': 1, + 'iterations': Infinity, + 'probability': true, + 'mute': false + }; + /** + * Start the loop at the specified time along the Transport's + * timeline. + * @param {TimelinePosition=} time When to start the Loop. + * @return {Tone.Loop} this + */ + Tone.Loop.prototype.start = function (time) { + this._event.start(time); + return this; + }; + /** + * Stop the loop at the given time. + * @param {TimelinePosition=} time When to stop the Arpeggio + * @return {Tone.Loop} this + */ + Tone.Loop.prototype.stop = function (time) { + this._event.stop(time); + return this; + }; + /** + * Cancel all scheduled events greater than or equal to the given time + * @param {TimelinePosition} [time=0] The time after which events will be cancel. + * @return {Tone.Loop} this + */ + Tone.Loop.prototype.cancel = function (time) { + this._event.cancel(time); + return this; + }; + /** + * Internal function called when the notes should be called + * @param {Number} time The time the event occurs + * @private + */ + Tone.Loop.prototype._tick = function (time) { + this.callback(time); + }; + /** + * The state of the Loop, either started or stopped. + * @memberOf Tone.Loop# + * @type {String} + * @name state + * @readOnly + */ + Object.defineProperty(Tone.Loop.prototype, 'state', { + get: function () { + return this._event.state; + } + }); + /** + * The progress of the loop as a value between 0-1. 0, when + * the loop is stopped or done iterating. + * @memberOf Tone.Loop# + * @type {NormalRange} + * @name progress + * @readOnly + */ + Object.defineProperty(Tone.Loop.prototype, 'progress', { + get: function () { + return this._event.progress; + } + }); + /** + * The time between successive callbacks. + * @example + * loop.interval = "8n"; //loop every 8n + * @memberOf Tone.Loop# + * @type {Time} + * @name interval + */ + Object.defineProperty(Tone.Loop.prototype, 'interval', { + get: function () { + return this._event.loopEnd; + }, + set: function (interval) { + this._event.loopEnd = interval; + } + }); + /** + * The playback rate of the loop. The normal playback rate is 1 (no change). + * A `playbackRate` of 2 would be twice as fast. + * @memberOf Tone.Loop# + * @type {Time} + * @name playbackRate + */ + Object.defineProperty(Tone.Loop.prototype, 'playbackRate', { + get: function () { + return this._event.playbackRate; + }, + set: function (rate) { + this._event.playbackRate = rate; + } + }); + /** + * Random variation +/-0.01s to the scheduled time. + * Or give it a time value which it will randomize by. + * @type {Boolean|Time} + * @memberOf Tone.Loop# + * @name humanize + */ + Object.defineProperty(Tone.Loop.prototype, 'humanize', { + get: function () { + return this._event.humanize; + }, + set: function (variation) { + this._event.humanize = variation; + } + }); + /** + * The probably of the callback being invoked. + * @memberOf Tone.Loop# + * @type {NormalRange} + * @name probability + */ + Object.defineProperty(Tone.Loop.prototype, 'probability', { + get: function () { + return this._event.probability; + }, + set: function (prob) { + this._event.probability = prob; + } + }); + /** + * Muting the Loop means that no callbacks are invoked. + * @memberOf Tone.Loop# + * @type {Boolean} + * @name mute + */ + Object.defineProperty(Tone.Loop.prototype, 'mute', { + get: function () { + return this._event.mute; + }, + set: function (mute) { + this._event.mute = mute; + } + }); + /** + * The number of iterations of the loop. The default + * value is Infinity (loop forever). + * @memberOf Tone.Loop# + * @type {Positive} + * @name iterations + */ + Object.defineProperty(Tone.Loop.prototype, 'iterations', { + get: function () { + if (this._event.loop === true) { + return Infinity; + } else { + return this._event.loop; + } + }, + set: function (iters) { + if (iters === Infinity) { + this._event.loop = true; + } else { + this._event.loop = iters; + } + } + }); + /** + * Clean up + * @return {Tone.Loop} this + */ + Tone.Loop.prototype.dispose = function () { + this._event.dispose(); + this._event = null; + this.callback = null; + }; + return Tone.Loop; + }); + Module(function (Tone) { + + /** + * @class Tone.Part is a collection Tone.Events which can be + * started/stopped and looped as a single unit. + * + * @extends {Tone.Event} + * @param {Function} callback The callback to invoke on each event + * @param {Array} events the array of events + * @example + * var part = new Tone.Part(function(time, note){ + * //the notes given as the second element in the array + * //will be passed in as the second argument + * synth.triggerAttackRelease(note, "8n", time); + * }, [[0, "C2"], ["0:2", "C3"], ["0:3:2", "G2"]]); + * @example + * //use an array of objects as long as the object has a "time" attribute + * var part = new Tone.Part(function(time, value){ + * //the value is an object which contains both the note and the velocity + * synth.triggerAttackRelease(value.note, "8n", time, value.velocity); + * }, [{"time" : 0, "note" : "C3", "velocity": 0.9}, + * {"time" : "0:2", "note" : "C4", "velocity": 0.5} + * ]).start(0); + */ + Tone.Part = function () { + var options = Tone.defaults(arguments, [ + 'callback', + 'events' + ], Tone.Part); + Tone.Event.call(this, options); + /** + * An array of Objects. + * @type {Array} + * @private + */ + this._events = []; + //add the events + for (var i = 0; i < options.events.length; i++) { + if (Array.isArray(options.events[i])) { + this.add(options.events[i][0], options.events[i][1]); + } else { + this.add(options.events[i]); + } + } + }; + Tone.extend(Tone.Part, Tone.Event); + /** + * The default values + * @type {Object} + * @const + */ + Tone.Part.defaults = { + 'callback': Tone.noOp, + 'loop': false, + 'loopEnd': '1m', + 'loopStart': 0, + 'playbackRate': 1, + 'probability': 1, + 'humanize': false, + 'mute': false, + 'events': [] + }; + /** + * Start the part at the given time. + * @param {TransportTime} time When to start the part. + * @param {Time=} offset The offset from the start of the part + * to begin playing at. + * @return {Tone.Part} this + */ + Tone.Part.prototype.start = function (time, offset) { + var ticks = this.toTicks(time); + if (this._state.getValueAtTime(ticks) !== Tone.State.Started) { + if (this._loop) { + offset = Tone.defaultArg(offset, this._loopStart); + } else { + offset = Tone.defaultArg(offset, 0); + } + offset = this.toTicks(offset); + this._state.add({ + 'state': Tone.State.Started, + 'time': ticks, + 'offset': offset + }); + this._forEach(function (event) { + this._startNote(event, ticks, offset); + }); + } + return this; + }; + /** + * Start the event in the given event at the correct time given + * the ticks and offset and looping. + * @param {Tone.Event} event + * @param {Ticks} ticks + * @param {Ticks} offset + * @private + */ + Tone.Part.prototype._startNote = function (event, ticks, offset) { + ticks -= offset; + if (this._loop) { + if (event.startOffset >= this._loopStart && event.startOffset < this._loopEnd) { + if (event.startOffset < offset) { + //start it on the next loop + ticks += this._getLoopDuration(); + } + event.start(Tone.Ticks(ticks)); + } else if (event.startOffset < this._loopStart && event.startOffset >= offset) { + event.loop = false; + event.start(Tone.Ticks(ticks)); + } + } else if (event.startOffset >= offset) { + event.start(Tone.Ticks(ticks)); + } + }; + /** + * The start from the scheduled start time + * @type {Ticks} + * @memberOf Tone.Part# + * @name startOffset + * @private + */ + Object.defineProperty(Tone.Part.prototype, 'startOffset', { + get: function () { + return this._startOffset; + }, + set: function (offset) { + this._startOffset = offset; + this._forEach(function (event) { + event.startOffset += this._startOffset; + }); + } + }); + /** + * Stop the part at the given time. + * @param {TimelinePosition} time When to stop the part. + * @return {Tone.Part} this + */ + Tone.Part.prototype.stop = function (time) { + var ticks = this.toTicks(time); + this._state.cancel(ticks); + this._state.setStateAtTime(Tone.State.Stopped, ticks); + this._forEach(function (event) { + event.stop(time); + }); + return this; + }; + /** + * Get/Set an Event's value at the given time. + * If a value is passed in and no event exists at + * the given time, one will be created with that value. + * If two events are at the same time, the first one will + * be returned. + * @example + * part.at("1m"); //returns the part at the first measure + * + * part.at("2m", "C2"); //set the value at "2m" to C2. + * //if an event didn't exist at that time, it will be created. + * @param {TransportTime} time The time of the event to get or set. + * @param {*=} value If a value is passed in, the value of the + * event at the given time will be set to it. + * @return {Tone.Event} the event at the time + */ + Tone.Part.prototype.at = function (time, value) { + time = Tone.TransportTime(time); + var tickTime = Tone.Ticks(1).toSeconds(); + for (var i = 0; i < this._events.length; i++) { + var event = this._events[i]; + if (Math.abs(time.toTicks() - event.startOffset) < tickTime) { + if (Tone.isDefined(value)) { + event.value = value; + } + return event; + } + } + //if there was no event at that time, create one + if (Tone.isDefined(value)) { + this.add(time, value); + //return the new event + return this._events[this._events.length - 1]; + } else { + return null; + } + }; + /** + * Add a an event to the part. + * @param {Time} time The time the note should start. + * If an object is passed in, it should + * have a 'time' attribute and the rest + * of the object will be used as the 'value'. + * @param {Tone.Event|*} value + * @returns {Tone.Part} this + * @example + * part.add("1m", "C#+11"); + */ + Tone.Part.prototype.add = function (time, value) { + //extract the parameters + if (time.hasOwnProperty('time')) { + value = time; + time = value.time; + } + time = this.toTicks(time); + var event; + if (value instanceof Tone.Event) { + event = value; + event.callback = this._tick.bind(this); + } else { + event = new Tone.Event({ + 'callback': this._tick.bind(this), + 'value': value + }); + } + //the start offset + event.startOffset = time; + //initialize the values + event.set({ + 'loopEnd': this.loopEnd, + 'loopStart': this.loopStart, + 'loop': this.loop, + 'humanize': this.humanize, + 'playbackRate': this.playbackRate, + 'probability': this.probability + }); + this._events.push(event); + //start the note if it should be played right now + this._restartEvent(event); + return this; + }; + /** + * Restart the given event + * @param {Tone.Event} event + * @private + */ + Tone.Part.prototype._restartEvent = function (event) { + this._state.forEach(function (stateEvent) { + if (stateEvent.state === Tone.State.Started) { + this._startNote(event, stateEvent.time, stateEvent.offset); + } else { + //stop the note + event.stop(Tone.Ticks(stateEvent.time)); + } + }.bind(this)); + }; + /** + * Remove an event from the part. Will recursively iterate + * into nested parts to find the event. + * @param {Time} time The time of the event + * @param {*} value Optionally select only a specific event value + * @return {Tone.Part} this + */ + Tone.Part.prototype.remove = function (time, value) { + //extract the parameters + if (time.hasOwnProperty('time')) { + value = time; + time = value.time; + } + time = this.toTicks(time); + for (var i = this._events.length - 1; i >= 0; i--) { + var event = this._events[i]; + if (event instanceof Tone.Part) { + event.remove(time, value); + } else if (event.startOffset === time) { + if (Tone.isUndef(value) || Tone.isDefined(value) && event.value === value) { + this._events.splice(i, 1); + event.dispose(); + } + } + } + return this; + }; + /** + * Remove all of the notes from the group. + * @return {Tone.Part} this + */ + Tone.Part.prototype.removeAll = function () { + this._forEach(function (event) { + event.dispose(); + }); + this._events = []; + return this; + }; + /** + * Cancel scheduled state change events: i.e. "start" and "stop". + * @param {TimelinePosition} after The time after which to cancel the scheduled events. + * @return {Tone.Part} this + */ + Tone.Part.prototype.cancel = function (after) { + this._forEach(function (event) { + event.cancel(after); + }); + this._state.cancel(this.toTicks(after)); + return this; + }; + /** + * Iterate over all of the events + * @param {Function} callback + * @param {Object} ctx The context + * @private + */ + Tone.Part.prototype._forEach = function (callback, ctx) { + if (this._events) { + ctx = Tone.defaultArg(ctx, this); + for (var i = this._events.length - 1; i >= 0; i--) { + var e = this._events[i]; + if (e instanceof Tone.Part) { + e._forEach(callback, ctx); + } else { + callback.call(ctx, e); + } + } + } + return this; + }; + /** + * Set the attribute of all of the events + * @param {String} attr the attribute to set + * @param {*} value The value to set it to + * @private + */ + Tone.Part.prototype._setAll = function (attr, value) { + this._forEach(function (event) { + event[attr] = value; + }); + }; + /** + * Internal tick method + * @param {Number} time The time of the event in seconds + * @private + */ + Tone.Part.prototype._tick = function (time, value) { + if (!this.mute) { + this.callback(time, value); + } + }; + /** + * Determine if the event should be currently looping + * given the loop boundries of this Part. + * @param {Tone.Event} event The event to test + * @private + */ + Tone.Part.prototype._testLoopBoundries = function (event) { + if (event.startOffset < this._loopStart || event.startOffset >= this._loopEnd) { + event.cancel(0); + } else if (event.state === Tone.State.Stopped) { + //reschedule it if it's stopped + this._restartEvent(event); + } + }; + /** + * The probability of the notes being triggered. + * @memberOf Tone.Part# + * @type {NormalRange} + * @name probability + */ + Object.defineProperty(Tone.Part.prototype, 'probability', { + get: function () { + return this._probability; + }, + set: function (prob) { + this._probability = prob; + this._setAll('probability', prob); + } + }); + /** + * If set to true, will apply small random variation + * to the callback time. If the value is given as a time, it will randomize + * by that amount. + * @example + * event.humanize = true; + * @type {Boolean|Time} + * @name humanize + */ + Object.defineProperty(Tone.Part.prototype, 'humanize', { + get: function () { + return this._humanize; + }, + set: function (variation) { + this._humanize = variation; + this._setAll('humanize', variation); + } + }); + /** + * If the part should loop or not + * between Tone.Part.loopStart and + * Tone.Part.loopEnd. An integer + * value corresponds to the number of + * loops the Part does after it starts. + * @memberOf Tone.Part# + * @type {Boolean|Positive} + * @name loop + * @example + * //loop the part 8 times + * part.loop = 8; + */ + Object.defineProperty(Tone.Part.prototype, 'loop', { + get: function () { + return this._loop; + }, + set: function (loop) { + this._loop = loop; + this._forEach(function (event) { + event._loopStart = this._loopStart; + event._loopEnd = this._loopEnd; + event.loop = loop; + this._testLoopBoundries(event); + }); + } + }); + /** + * The loopEnd point determines when it will + * loop if Tone.Part.loop is true. + * @memberOf Tone.Part# + * @type {Time} + * @name loopEnd + */ + Object.defineProperty(Tone.Part.prototype, 'loopEnd', { + get: function () { + return Tone.Ticks(this._loopEnd).toSeconds(); + }, + set: function (loopEnd) { + this._loopEnd = this.toTicks(loopEnd); + if (this._loop) { + this._forEach(function (event) { + event.loopEnd = loopEnd; + this._testLoopBoundries(event); + }); + } + } + }); + /** + * The loopStart point determines when it will + * loop if Tone.Part.loop is true. + * @memberOf Tone.Part# + * @type {Time} + * @name loopStart + */ + Object.defineProperty(Tone.Part.prototype, 'loopStart', { + get: function () { + return Tone.Ticks(this._loopStart).toSeconds(); + }, + set: function (loopStart) { + this._loopStart = this.toTicks(loopStart); + if (this._loop) { + this._forEach(function (event) { + event.loopStart = this.loopStart; + this._testLoopBoundries(event); + }); + } + } + }); + /** + * The playback rate of the part + * @memberOf Tone.Part# + * @type {Positive} + * @name playbackRate + */ + Object.defineProperty(Tone.Part.prototype, 'playbackRate', { + get: function () { + return this._playbackRate; + }, + set: function (rate) { + this._playbackRate = rate; + this._setAll('playbackRate', rate); + } + }); + /** + * The number of scheduled notes in the part. + * @memberOf Tone.Part# + * @type {Positive} + * @name length + * @readOnly + */ + Object.defineProperty(Tone.Part.prototype, 'length', { + get: function () { + return this._events.length; + } + }); + /** + * Clean up + * @return {Tone.Part} this + */ + Tone.Part.prototype.dispose = function () { + this.removeAll(); + this._state.dispose(); + this._state = null; + this.callback = null; + this._events = null; + return this; + }; + return Tone.Part; + }); + Module(function (Tone) { + /** + * @class Tone.Pattern arpeggiates between the given notes + * in a number of patterns. See Tone.CtrlPattern for + * a full list of patterns. + * @example + * var pattern = new Tone.Pattern(function(time, note){ + * //the order of the notes passed in depends on the pattern + * }, ["C2", "D4", "E5", "A6"], "upDown"); + * @extends {Tone.Loop} + * @param {Function} callback The callback to invoke with the + * event. + * @param {Array} values The values to arpeggiate over. + */ + Tone.Pattern = function () { + var options = Tone.defaults(arguments, [ + 'callback', + 'values', + 'pattern' + ], Tone.Pattern); + Tone.Loop.call(this, options); + /** + * The pattern manager + * @type {Tone.CtrlPattern} + * @private + */ + this._pattern = new Tone.CtrlPattern({ + 'values': options.values, + 'type': options.pattern, + 'index': options.index + }); + }; + Tone.extend(Tone.Pattern, Tone.Loop); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.Pattern.defaults = { + 'pattern': Tone.CtrlPattern.Type.Up, + 'callback': Tone.noOp, + 'values': [] + }; + /** + * Internal function called when the notes should be called + * @param {Number} time The time the event occurs + * @private + */ + Tone.Pattern.prototype._tick = function (time) { + this.callback(time, this._pattern.value); + this._pattern.next(); + }; + /** + * The current index in the values array. + * @memberOf Tone.Pattern# + * @type {Positive} + * @name index + */ + Object.defineProperty(Tone.Pattern.prototype, 'index', { + get: function () { + return this._pattern.index; + }, + set: function (i) { + this._pattern.index = i; + } + }); + /** + * The array of events. + * @memberOf Tone.Pattern# + * @type {Array} + * @name values + */ + Object.defineProperty(Tone.Pattern.prototype, 'values', { + get: function () { + return this._pattern.values; + }, + set: function (vals) { + this._pattern.values = vals; + } + }); + /** + * The current value of the pattern. + * @memberOf Tone.Pattern# + * @type {*} + * @name value + * @readOnly + */ + Object.defineProperty(Tone.Pattern.prototype, 'value', { + get: function () { + return this._pattern.value; + } + }); + /** + * The pattern type. See Tone.CtrlPattern for the full list of patterns. + * @memberOf Tone.Pattern# + * @type {String} + * @name pattern + */ + Object.defineProperty(Tone.Pattern.prototype, 'pattern', { + get: function () { + return this._pattern.type; + }, + set: function (pattern) { + this._pattern.type = pattern; + } + }); + /** + * Clean up + * @return {Tone.Pattern} this + */ + Tone.Pattern.prototype.dispose = function () { + Tone.Loop.prototype.dispose.call(this); + this._pattern.dispose(); + this._pattern = null; + }; + return Tone.Pattern; + }); + Module(function (Tone) { + + /** + * @class A sequence is an alternate notation of a part. Instead + * of passing in an array of [time, event] pairs, pass + * in an array of events which will be spaced at the + * given subdivision. Sub-arrays will subdivide that beat + * by the number of items are in the array. + * Sequence notation inspiration from [Tidal](http://yaxu.org/tidal/) + * @param {Function} callback The callback to invoke with every note + * @param {Array} events The sequence + * @param {Time} subdivision The subdivision between which events are placed. + * @extends {Tone.Part} + * @example + * var seq = new Tone.Sequence(function(time, note){ + * console.log(note); + * //straight quater notes + * }, ["C4", "E4", "G4", "A4"], "4n"); + * @example + * var seq = new Tone.Sequence(function(time, note){ + * console.log(note); + * //subdivisions are given as subarrays + * }, ["C4", ["E4", "D4", "E4"], "G4", ["A4", "G4"]]); + */ + Tone.Sequence = function () { + var options = Tone.defaults(arguments, [ + 'callback', + 'events', + 'subdivision' + ], Tone.Sequence); + //remove the events + var events = options.events; + delete options.events; + Tone.Part.call(this, options); + /** + * The subdivison of each note + * @type {Ticks} + * @private + */ + this._subdivision = this.toTicks(options.subdivision); + //if no time was passed in, the loop end is the end of the cycle + if (Tone.isUndef(options.loopEnd) && Tone.isDefined(events)) { + this._loopEnd = events.length * this._subdivision; + } + //defaults to looping + this._loop = true; + //add all of the events + if (Tone.isDefined(events)) { + for (var i = 0; i < events.length; i++) { + this.add(i, events[i]); + } + } + }; + Tone.extend(Tone.Sequence, Tone.Part); + /** + * The default values. + * @type {Object} + */ + Tone.Sequence.defaults = { 'subdivision': '4n' }; + /** + * The subdivision of the sequence. This can only be + * set in the constructor. The subdivision is the + * interval between successive steps. + * @type {Time} + * @memberOf Tone.Sequence# + * @name subdivision + * @readOnly + */ + Object.defineProperty(Tone.Sequence.prototype, 'subdivision', { + get: function () { + return Tone.Ticks(this._subdivision).toSeconds(); + } + }); + /** + * Get/Set an index of the sequence. If the index contains a subarray, + * a Tone.Sequence representing that sub-array will be returned. + * @example + * var sequence = new Tone.Sequence(playNote, ["E4", "C4", "F#4", ["A4", "Bb3"]]) + * sequence.at(0)// => returns "E4" + * //set a value + * sequence.at(0, "G3"); + * //get a nested sequence + * sequence.at(3).at(1)// => returns "Bb3" + * @param {Positive} index The index to get or set + * @param {*} value Optionally pass in the value to set at the given index. + */ + Tone.Sequence.prototype.at = function (index, value) { + //if the value is an array, + if (Tone.isArray(value)) { + //remove the current event at that index + this.remove(index); + } + //call the parent's method + return Tone.Part.prototype.at.call(this, this._indexTime(index), value); + }; + /** + * Add an event at an index, if there's already something + * at that index, overwrite it. If `value` is an array, + * it will be parsed as a subsequence. + * @param {Number} index The index to add the event to + * @param {*} value The value to add at that index + * @returns {Tone.Sequence} this + */ + Tone.Sequence.prototype.add = function (index, value) { + if (value === null) { + return this; + } + if (Tone.isArray(value)) { + //make a subsequence and add that to the sequence + var subSubdivision = Math.round(this._subdivision / value.length); + value = new Tone.Sequence(this._tick.bind(this), value, Tone.Ticks(subSubdivision)); + } + Tone.Part.prototype.add.call(this, this._indexTime(index), value); + return this; + }; + /** + * Remove a value from the sequence by index + * @param {Number} index The index of the event to remove + * @returns {Tone.Sequence} this + */ + Tone.Sequence.prototype.remove = function (index, value) { + Tone.Part.prototype.remove.call(this, this._indexTime(index), value); + return this; + }; + /** + * Get the time of the index given the Sequence's subdivision + * @param {Number} index + * @return {Time} The time of that index + * @private + */ + Tone.Sequence.prototype._indexTime = function (index) { + if (index instanceof Tone.TransportTime) { + return index; + } else { + return Tone.Ticks(index * this._subdivision + this.startOffset).toSeconds(); + } + }; + /** + * Clean up. + * @return {Tone.Sequence} this + */ + Tone.Sequence.prototype.dispose = function () { + Tone.Part.prototype.dispose.call(this); + return this; + }; + return Tone.Sequence; + }); + Module(function (Tone) { + + /** + * @class Tone.PulseOscillator is a pulse oscillator with control over pulse width, + * also known as the duty cycle. At 50% duty cycle (width = 0.5) the wave is + * a square and only odd-numbered harmonics are present. At all other widths + * even-numbered harmonics are present. Read more + * [here](https://wigglewave.wordpress.com/2014/08/16/pulse-waveforms-and-harmonics/). + * + * @constructor + * @extends {Tone.Source} + * @param {Frequency} [frequency] The frequency of the oscillator + * @param {NormalRange} [width] The width of the pulse + * @example + * var pulse = new Tone.PulseOscillator("E5", 0.4).toMaster().start(); + */ + Tone.PulseOscillator = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'width' + ], Tone.Oscillator); + Tone.Source.call(this, options); + /** + * The width of the pulse. + * @type {NormalRange} + * @signal + */ + this.width = new Tone.Signal(options.width, Tone.Type.NormalRange); + /** + * gate the width amount + * @type {Tone.Gain} + * @private + */ + this._widthGate = new Tone.Gain(); + /** + * the sawtooth oscillator + * @type {Tone.Oscillator} + * @private + */ + this._sawtooth = new Tone.Oscillator({ + frequency: options.frequency, + detune: options.detune, + type: 'sawtooth', + phase: options.phase + }); + /** + * The frequency control. + * @type {Frequency} + * @signal + */ + this.frequency = this._sawtooth.frequency; + /** + * The detune in cents. + * @type {Cents} + * @signal + */ + this.detune = this._sawtooth.detune; + /** + * Threshold the signal to turn it into a square + * @type {Tone.WaveShaper} + * @private + */ + this._thresh = new Tone.WaveShaper(function (val) { + if (val < 0) { + return -1; + } else { + return 1; + } + }); + //connections + this._sawtooth.chain(this._thresh, this.output); + this.width.chain(this._widthGate, this._thresh); + this._readOnly([ + 'width', + 'frequency', + 'detune' + ]); + }; + Tone.extend(Tone.PulseOscillator, Tone.Source); + /** + * The default parameters. + * @static + * @const + * @type {Object} + */ + Tone.PulseOscillator.defaults = { + 'frequency': 440, + 'detune': 0, + 'phase': 0, + 'width': 0.2 + }; + /** + * start the oscillator + * @param {Time} time + * @private + */ + Tone.PulseOscillator.prototype._start = function (time) { + time = this.toSeconds(time); + this._sawtooth.start(time); + this._widthGate.gain.setValueAtTime(1, time); + }; + /** + * stop the oscillator + * @param {Time} time + * @private + */ + Tone.PulseOscillator.prototype._stop = function (time) { + time = this.toSeconds(time); + this._sawtooth.stop(time); + //the width is still connected to the output. + //that needs to be stopped also + this._widthGate.gain.setValueAtTime(0, time); + }; + /** + * restart the oscillator + * @param {Time} time (optional) timing parameter + * @private + */ + Tone.PulseOscillator.prototype.restart = function (time) { + this._sawtooth.restart(time); + }; + /** + * The phase of the oscillator in degrees. + * @memberOf Tone.PulseOscillator# + * @type {Degrees} + * @name phase + */ + Object.defineProperty(Tone.PulseOscillator.prototype, 'phase', { + get: function () { + return this._sawtooth.phase; + }, + set: function (phase) { + this._sawtooth.phase = phase; + } + }); + /** + * The type of the oscillator. Always returns "pulse". + * @readOnly + * @memberOf Tone.PulseOscillator# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.PulseOscillator.prototype, 'type', { + get: function () { + return 'pulse'; + } + }); + /** + * The partials of the waveform. Cannot set partials for this waveform type + * @memberOf Tone.PulseOscillator# + * @type {Array} + * @name partials + * @private + */ + Object.defineProperty(Tone.PulseOscillator.prototype, 'partials', { + get: function () { + return []; + } + }); + /** + * Clean up method. + * @return {Tone.PulseOscillator} this + */ + Tone.PulseOscillator.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + this._sawtooth.dispose(); + this._sawtooth = null; + this._writable([ + 'width', + 'frequency', + 'detune' + ]); + this.width.dispose(); + this.width = null; + this._widthGate.dispose(); + this._widthGate = null; + this._thresh.dispose(); + this._thresh = null; + this.frequency = null; + this.detune = null; + return this; + }; + return Tone.PulseOscillator; + }); + Module(function (Tone) { + + /** + * @class Tone.PWMOscillator modulates the width of a Tone.PulseOscillator + * at the modulationFrequency. This has the effect of continuously + * changing the timbre of the oscillator by altering the harmonics + * generated. + * + * @extends {Tone.Source} + * @constructor + * @param {Frequency} frequency The starting frequency of the oscillator. + * @param {Frequency} modulationFrequency The modulation frequency of the width of the pulse. + * @example + * var pwm = new Tone.PWMOscillator("Ab3", 0.3).toMaster().start(); + */ + Tone.PWMOscillator = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'modulationFrequency' + ], Tone.PWMOscillator); + Tone.Source.call(this, options); + /** + * the pulse oscillator + * @type {Tone.PulseOscillator} + * @private + */ + this._pulse = new Tone.PulseOscillator(options.modulationFrequency); + //change the pulse oscillator type + this._pulse._sawtooth.type = 'sine'; + /** + * the modulator + * @type {Tone.Oscillator} + * @private + */ + this._modulator = new Tone.Oscillator({ + 'frequency': options.frequency, + 'detune': options.detune, + 'phase': options.phase + }); + /** + * Scale the oscillator so it doesn't go silent + * at the extreme values. + * @type {Tone.Multiply} + * @private + */ + this._scale = new Tone.Multiply(2); + /** + * The frequency control. + * @type {Frequency} + * @signal + */ + this.frequency = this._modulator.frequency; + /** + * The detune of the oscillator. + * @type {Cents} + * @signal + */ + this.detune = this._modulator.detune; + /** + * The modulation rate of the oscillator. + * @type {Frequency} + * @signal + */ + this.modulationFrequency = this._pulse.frequency; + //connections + this._modulator.chain(this._scale, this._pulse.width); + this._pulse.connect(this.output); + this._readOnly([ + 'modulationFrequency', + 'frequency', + 'detune' + ]); + }; + Tone.extend(Tone.PWMOscillator, Tone.Source); + /** + * default values + * @static + * @type {Object} + * @const + */ + Tone.PWMOscillator.defaults = { + 'frequency': 440, + 'detune': 0, + 'phase': 0, + 'modulationFrequency': 0.4 + }; + /** + * start the oscillator + * @param {Time} [time=now] + * @private + */ + Tone.PWMOscillator.prototype._start = function (time) { + time = this.toSeconds(time); + this._modulator.start(time); + this._pulse.start(time); + }; + /** + * stop the oscillator + * @param {Time} time (optional) timing parameter + * @private + */ + Tone.PWMOscillator.prototype._stop = function (time) { + time = this.toSeconds(time); + this._modulator.stop(time); + this._pulse.stop(time); + }; + /** + * restart the oscillator + * @param {Time} time (optional) timing parameter + * @private + */ + Tone.PWMOscillator.prototype.restart = function (time) { + this._modulator.restart(time); + this._pulse.restart(time); + }; + /** + * The type of the oscillator. Always returns "pwm". + * @readOnly + * @memberOf Tone.PWMOscillator# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.PWMOscillator.prototype, 'type', { + get: function () { + return 'pwm'; + } + }); + /** + * The partials of the waveform. Cannot set partials for this waveform type + * @memberOf Tone.PWMOscillator# + * @type {Array} + * @name partials + * @private + */ + Object.defineProperty(Tone.PWMOscillator.prototype, 'partials', { + get: function () { + return []; + } + }); + /** + * The phase of the oscillator in degrees. + * @memberOf Tone.PWMOscillator# + * @type {number} + * @name phase + */ + Object.defineProperty(Tone.PWMOscillator.prototype, 'phase', { + get: function () { + return this._modulator.phase; + }, + set: function (phase) { + this._modulator.phase = phase; + } + }); + /** + * Clean up. + * @return {Tone.PWMOscillator} this + */ + Tone.PWMOscillator.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + this._pulse.dispose(); + this._pulse = null; + this._scale.dispose(); + this._scale = null; + this._modulator.dispose(); + this._modulator = null; + this._writable([ + 'modulationFrequency', + 'frequency', + 'detune' + ]); + this.frequency = null; + this.detune = null; + this.modulationFrequency = null; + return this; + }; + return Tone.PWMOscillator; + }); + Module(function (Tone) { + + /** + * @class Tone.FMOscillator + * + * @extends {Tone.Source} + * @constructor + * @param {Frequency} frequency The starting frequency of the oscillator. + * @param {String} type The type of the carrier oscillator. + * @param {String} modulationType The type of the modulator oscillator. + * @example + * //a sine oscillator frequency-modulated by a square wave + * var fmOsc = new Tone.FMOscillator("Ab3", "sine", "square").toMaster().start(); + */ + Tone.FMOscillator = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'type', + 'modulationType' + ], Tone.FMOscillator); + Tone.Source.call(this, options); + /** + * The carrier oscillator + * @type {Tone.Oscillator} + * @private + */ + this._carrier = new Tone.Oscillator(options.frequency, options.type); + /** + * The oscillator's frequency + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency); + /** + * The detune control signal. + * @type {Cents} + * @signal + */ + this.detune = this._carrier.detune; + this.detune.value = options.detune; + /** + * The modulation index which is in essence the depth or amount of the modulation. In other terms it is the + * ratio of the frequency of the modulating signal (mf) to the amplitude of the + * modulating signal (ma) -- as in ma/mf. + * @type {Positive} + * @signal + */ + this.modulationIndex = new Tone.Multiply(options.modulationIndex); + this.modulationIndex.units = Tone.Type.Positive; + /** + * The modulating oscillator + * @type {Tone.Oscillator} + * @private + */ + this._modulator = new Tone.Oscillator(options.frequency, options.modulationType); + /** + * Harmonicity is the frequency ratio between the carrier and the modulator oscillators. + * A harmonicity of 1 gives both oscillators the same frequency. + * Harmonicity = 2 means a change of an octave. + * @type {Positive} + * @signal + * @example + * //pitch the modulator an octave below carrier + * synth.harmonicity.value = 0.5; + */ + this.harmonicity = new Tone.Multiply(options.harmonicity); + this.harmonicity.units = Tone.Type.Positive; + /** + * the node where the modulation happens + * @type {Tone.Gain} + * @private + */ + this._modulationNode = new Tone.Gain(0); + //connections + this.frequency.connect(this._carrier.frequency); + this.frequency.chain(this.harmonicity, this._modulator.frequency); + this.frequency.chain(this.modulationIndex, this._modulationNode); + this._modulator.connect(this._modulationNode.gain); + this._modulationNode.connect(this._carrier.frequency); + this._carrier.connect(this.output); + this.detune.connect(this._modulator.detune); + this.phase = options.phase; + this._readOnly([ + 'modulationIndex', + 'frequency', + 'detune', + 'harmonicity' + ]); + }; + Tone.extend(Tone.FMOscillator, Tone.Source); + /** + * default values + * @static + * @type {Object} + * @const + */ + Tone.FMOscillator.defaults = { + 'frequency': 440, + 'detune': 0, + 'phase': 0, + 'modulationIndex': 2, + 'modulationType': 'square', + 'harmonicity': 1 + }; + /** + * start the oscillator + * @param {Time} [time=now] + * @private + */ + Tone.FMOscillator.prototype._start = function (time) { + this._modulator.start(time); + this._carrier.start(time); + }; + /** + * stop the oscillator + * @param {Time} time (optional) timing parameter + * @private + */ + Tone.FMOscillator.prototype._stop = function (time) { + this._modulator.stop(time); + this._carrier.stop(time); + }; + /** + * stop the oscillator + * @param {Time} time (optional) timing parameter + * @private + */ + Tone.FMOscillator.prototype.restart = function (time) { + this._modulator.restart(time); + this._carrier.restart(time); + }; + /** + * The type of the carrier oscillator + * @memberOf Tone.FMOscillator# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.FMOscillator.prototype, 'type', { + get: function () { + return this._carrier.type; + }, + set: function (type) { + this._carrier.type = type; + } + }); + /** + * The type of the modulator oscillator + * @memberOf Tone.FMOscillator# + * @type {String} + * @name modulationType + */ + Object.defineProperty(Tone.FMOscillator.prototype, 'modulationType', { + get: function () { + return this._modulator.type; + }, + set: function (type) { + this._modulator.type = type; + } + }); + /** + * The phase of the oscillator in degrees. + * @memberOf Tone.FMOscillator# + * @type {number} + * @name phase + */ + Object.defineProperty(Tone.FMOscillator.prototype, 'phase', { + get: function () { + return this._carrier.phase; + }, + set: function (phase) { + this._carrier.phase = phase; + this._modulator.phase = phase; + } + }); + /** + * The partials of the carrier waveform. A partial represents + * the amplitude at a harmonic. The first harmonic is the + * fundamental frequency, the second is the octave and so on + * following the harmonic series. + * Setting this value will automatically set the type to "custom". + * The value is an empty array when the type is not "custom". + * @memberOf Tone.FMOscillator# + * @type {Array} + * @name partials + * @example + * osc.partials = [1, 0.2, 0.01]; + */ + Object.defineProperty(Tone.FMOscillator.prototype, 'partials', { + get: function () { + return this._carrier.partials; + }, + set: function (partials) { + this._carrier.partials = partials; + } + }); + /** + * Clean up. + * @return {Tone.FMOscillator} this + */ + Tone.FMOscillator.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + this._writable([ + 'modulationIndex', + 'frequency', + 'detune', + 'harmonicity' + ]); + this.frequency.dispose(); + this.frequency = null; + this.detune = null; + this.harmonicity.dispose(); + this.harmonicity = null; + this._carrier.dispose(); + this._carrier = null; + this._modulator.dispose(); + this._modulator = null; + this._modulationNode.dispose(); + this._modulationNode = null; + this.modulationIndex.dispose(); + this.modulationIndex = null; + return this; + }; + return Tone.FMOscillator; + }); + Module(function (Tone) { + + /** + * @class Tone.AMOscillator + * + * @extends {Tone.Oscillator} + * @constructor + * @param {Frequency} frequency The starting frequency of the oscillator. + * @param {String} type The type of the carrier oscillator. + * @param {String} modulationType The type of the modulator oscillator. + * @example + * //a sine oscillator frequency-modulated by a square wave + * var fmOsc = new Tone.AMOscillator("Ab3", "sine", "square").toMaster().start(); + */ + Tone.AMOscillator = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'type', + 'modulationType' + ], Tone.AMOscillator); + Tone.Source.call(this, options); + /** + * The carrier oscillator + * @type {Tone.Oscillator} + * @private + */ + this._carrier = new Tone.Oscillator(options.frequency, options.type); + /** + * The oscillator's frequency + * @type {Frequency} + * @signal + */ + this.frequency = this._carrier.frequency; + /** + * The detune control signal. + * @type {Cents} + * @signal + */ + this.detune = this._carrier.detune; + this.detune.value = options.detune; + /** + * The modulating oscillator + * @type {Tone.Oscillator} + * @private + */ + this._modulator = new Tone.Oscillator(options.frequency, options.modulationType); + /** + * convert the -1,1 output to 0,1 + * @type {Tone.AudioToGain} + * @private + */ + this._modulationScale = new Tone.AudioToGain(); + /** + * Harmonicity is the frequency ratio between the carrier and the modulator oscillators. + * A harmonicity of 1 gives both oscillators the same frequency. + * Harmonicity = 2 means a change of an octave. + * @type {Positive} + * @signal + * @example + * //pitch the modulator an octave below carrier + * synth.harmonicity.value = 0.5; + */ + this.harmonicity = new Tone.Multiply(options.harmonicity); + this.harmonicity.units = Tone.Type.Positive; + /** + * the node where the modulation happens + * @type {Tone.Gain} + * @private + */ + this._modulationNode = new Tone.Gain(0); + //connections + this.frequency.chain(this.harmonicity, this._modulator.frequency); + this.detune.connect(this._modulator.detune); + this._modulator.chain(this._modulationScale, this._modulationNode.gain); + this._carrier.chain(this._modulationNode, this.output); + this.phase = options.phase; + this._readOnly([ + 'frequency', + 'detune', + 'harmonicity' + ]); + }; + Tone.extend(Tone.AMOscillator, Tone.Oscillator); + /** + * default values + * @static + * @type {Object} + * @const + */ + Tone.AMOscillator.defaults = { + 'frequency': 440, + 'detune': 0, + 'phase': 0, + 'modulationType': 'square', + 'harmonicity': 1 + }; + /** + * start the oscillator + * @param {Time} [time=now] + * @private + */ + Tone.AMOscillator.prototype._start = function (time) { + this._modulator.start(time); + this._carrier.start(time); + }; + /** + * stop the oscillator + * @param {Time} time (optional) timing parameter + * @private + */ + Tone.AMOscillator.prototype._stop = function (time) { + this._modulator.stop(time); + this._carrier.stop(time); + }; + /** + * restart the oscillator + * @param {Time} time (optional) timing parameter + * @private + */ + Tone.AMOscillator.prototype.restart = function (time) { + this._modulator.restart(time); + this._carrier.restart(time); + }; + /** + * The type of the carrier oscillator + * @memberOf Tone.AMOscillator# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.AMOscillator.prototype, 'type', { + get: function () { + return this._carrier.type; + }, + set: function (type) { + this._carrier.type = type; + } + }); + /** + * The type of the modulator oscillator + * @memberOf Tone.AMOscillator# + * @type {string} + * @name modulationType + */ + Object.defineProperty(Tone.AMOscillator.prototype, 'modulationType', { + get: function () { + return this._modulator.type; + }, + set: function (type) { + this._modulator.type = type; + } + }); + /** + * The phase of the oscillator in degrees. + * @memberOf Tone.AMOscillator# + * @type {number} + * @name phase + */ + Object.defineProperty(Tone.AMOscillator.prototype, 'phase', { + get: function () { + return this._carrier.phase; + }, + set: function (phase) { + this._carrier.phase = phase; + this._modulator.phase = phase; + } + }); + /** + * The partials of the carrier waveform. A partial represents + * the amplitude at a harmonic. The first harmonic is the + * fundamental frequency, the second is the octave and so on + * following the harmonic series. + * Setting this value will automatically set the type to "custom". + * The value is an empty array when the type is not "custom". + * @memberOf Tone.AMOscillator# + * @type {Array} + * @name partials + * @example + * osc.partials = [1, 0.2, 0.01]; + */ + Object.defineProperty(Tone.AMOscillator.prototype, 'partials', { + get: function () { + return this._carrier.partials; + }, + set: function (partials) { + this._carrier.partials = partials; + } + }); + /** + * Clean up. + * @return {Tone.AMOscillator} this + */ + Tone.AMOscillator.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + this._writable([ + 'frequency', + 'detune', + 'harmonicity' + ]); + this.frequency = null; + this.detune = null; + this.harmonicity.dispose(); + this.harmonicity = null; + this._carrier.dispose(); + this._carrier = null; + this._modulator.dispose(); + this._modulator = null; + this._modulationNode.dispose(); + this._modulationNode = null; + this._modulationScale.dispose(); + this._modulationScale = null; + return this; + }; + return Tone.AMOscillator; + }); + Module(function (Tone) { + + /** + * @class Tone.FatOscillator + * + * @extends {Tone.Source} + * @constructor + * @param {Frequency} frequency The starting frequency of the oscillator. + * @param {String} type The type of the carrier oscillator. + * @param {String} modulationType The type of the modulator oscillator. + * @example + * //a sine oscillator frequency-modulated by a square wave + * var fmOsc = new Tone.FatOscillator("Ab3", "sine", "square").toMaster().start(); + */ + Tone.FatOscillator = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'type', + 'spread' + ], Tone.FatOscillator); + Tone.Source.call(this, options); + /** + * The oscillator's frequency + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency); + /** + * The detune control signal. + * @type {Cents} + * @signal + */ + this.detune = new Tone.Signal(options.detune, Tone.Type.Cents); + /** + * The array of oscillators + * @type {Array} + * @private + */ + this._oscillators = []; + /** + * The total spread of the oscillators + * @type {Cents} + * @private + */ + this._spread = options.spread; + /** + * The type of the oscillator + * @type {String} + * @private + */ + this._type = options.type; + /** + * The phase of the oscillators + * @type {Degrees} + * @private + */ + this._phase = options.phase; + /** + * The partials array + * @type {Array} + * @private + */ + this._partials = Tone.defaultArg(options.partials, []); + //set the count initially + this.count = options.count; + this._readOnly([ + 'frequency', + 'detune' + ]); + }; + Tone.extend(Tone.FatOscillator, Tone.Source); + /** + * default values + * @static + * @type {Object} + * @const + */ + Tone.FatOscillator.defaults = { + 'frequency': 440, + 'detune': 0, + 'phase': 0, + 'spread': 20, + 'count': 3, + 'type': 'sawtooth' + }; + /** + * start the oscillator + * @param {Time} [time=now] + * @private + */ + Tone.FatOscillator.prototype._start = function (time) { + time = this.toSeconds(time); + this._forEach(function (osc) { + osc.start(time); + }); + }; + /** + * stop the oscillator + * @param {Time} [time=now] + * @private + */ + Tone.FatOscillator.prototype._stop = function (time) { + time = this.toSeconds(time); + this._forEach(function (osc) { + osc.stop(time); + }); + }; + /** + * restart the oscillator + * @param {Time} time (optional) timing parameter + * @private + */ + Tone.FatOscillator.prototype.restart = function (time) { + time = this.toSeconds(time); + this._forEach(function (osc) { + osc.restart(time); + }); + }; + /** + * Iterate over all of the oscillators + * @param {Function} iterator The iterator function + * @private + */ + Tone.FatOscillator.prototype._forEach = function (iterator) { + for (var i = 0; i < this._oscillators.length; i++) { + iterator.call(this, this._oscillators[i], i); + } + }; + /** + * The type of the carrier oscillator + * @memberOf Tone.FatOscillator# + * @type {string} + * @name type + */ + Object.defineProperty(Tone.FatOscillator.prototype, 'type', { + get: function () { + return this._type; + }, + set: function (type) { + this._type = type; + this._forEach(function (osc) { + osc.type = type; + }); + } + }); + /** + * The detune spread between the oscillators. If "count" is + * set to 3 oscillators and the "spread" is set to 40, + * the three oscillators would be detuned like this: [-20, 0, 20] + * for a total detune spread of 40 cents. + * @memberOf Tone.FatOscillator# + * @type {Cents} + * @name spread + */ + Object.defineProperty(Tone.FatOscillator.prototype, 'spread', { + get: function () { + return this._spread; + }, + set: function (spread) { + this._spread = spread; + if (this._oscillators.length > 1) { + var start = -spread / 2; + var step = spread / (this._oscillators.length - 1); + this._forEach(function (osc, i) { + osc.detune.value = start + step * i; + }); + } + } + }); + /** + * The number of detuned oscillators + * @memberOf Tone.FatOscillator# + * @type {Number} + * @name count + */ + Object.defineProperty(Tone.FatOscillator.prototype, 'count', { + get: function () { + return this._oscillators.length; + }, + set: function (count) { + count = Math.max(count, 1); + if (this._oscillators.length !== count) { + // var partials = this.partials; + // var type = this.type; + //dispose the previous oscillators + this._forEach(function (osc) { + osc.dispose(); + }); + this._oscillators = []; + for (var i = 0; i < count; i++) { + var osc = new Tone.Oscillator(); + if (this.type === Tone.Oscillator.Type.Custom) { + osc.partials = this._partials; + } else { + osc.type = this._type; + } + osc.phase = this._phase; + osc.volume.value = -6 - count * 1.1; + this.frequency.connect(osc.frequency); + this.detune.connect(osc.detune); + osc.connect(this.output); + this._oscillators[i] = osc; + } + //set the spread + this.spread = this._spread; + if (this.state === Tone.State.Started) { + this._forEach(function (osc) { + osc.start(); + }); + } + } + } + }); + /** + * The phase of the oscillator in degrees. + * @memberOf Tone.FatOscillator# + * @type {Number} + * @name phase + */ + Object.defineProperty(Tone.FatOscillator.prototype, 'phase', { + get: function () { + return this._phase; + }, + set: function (phase) { + this._phase = phase; + this._forEach(function (osc) { + osc.phase = phase; + }); + } + }); + /** + * The partials of the carrier waveform. A partial represents + * the amplitude at a harmonic. The first harmonic is the + * fundamental frequency, the second is the octave and so on + * following the harmonic series. + * Setting this value will automatically set the type to "custom". + * The value is an empty array when the type is not "custom". + * @memberOf Tone.FatOscillator# + * @type {Array} + * @name partials + * @example + * osc.partials = [1, 0.2, 0.01]; + */ + Object.defineProperty(Tone.FatOscillator.prototype, 'partials', { + get: function () { + return this._partials; + }, + set: function (partials) { + this._partials = partials; + this._type = Tone.Oscillator.Type.Custom; + this._forEach(function (osc) { + osc.partials = partials; + }); + } + }); + /** + * Clean up. + * @return {Tone.FatOscillator} this + */ + Tone.FatOscillator.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + this._writable([ + 'frequency', + 'detune' + ]); + this.frequency.dispose(); + this.frequency = null; + this.detune.dispose(); + this.detune = null; + this._forEach(function (osc) { + osc.dispose(); + }); + this._oscillators = null; + this._partials = null; + return this; + }; + return Tone.FatOscillator; + }); + Module(function (Tone) { + + /** + * @class Tone.OmniOscillator aggregates Tone.Oscillator, Tone.PulseOscillator, + * Tone.PWMOscillator, Tone.FMOscillator, Tone.AMOscillator, and Tone.FatOscillator + * into one class. The oscillator class can be changed by setting the `type`. + * `omniOsc.type = "pwm"` will set it to the Tone.PWMOscillator. Prefixing + * any of the basic types ("sine", "square4", etc.) with "fm", "am", or "fat" + * will use the FMOscillator, AMOscillator or FatOscillator respectively. + * For example: `omniOsc.type = "fatsawtooth"` will create set the oscillator + * to a FatOscillator of type "sawtooth". + * + * @extends {Tone.Source} + * @constructor + * @param {Frequency} frequency The initial frequency of the oscillator. + * @param {String} type The type of the oscillator. + * @example + * var omniOsc = new Tone.OmniOscillator("C#4", "pwm"); + */ + Tone.OmniOscillator = function () { + var options = Tone.defaults(arguments, [ + 'frequency', + 'type' + ], Tone.OmniOscillator); + Tone.Source.call(this, options); + /** + * The frequency control. + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency); + /** + * The detune control + * @type {Cents} + * @signal + */ + this.detune = new Tone.Signal(options.detune, Tone.Type.Cents); + /** + * the type of the oscillator source + * @type {String} + * @private + */ + this._sourceType = undefined; + /** + * the oscillator + * @type {Tone.Oscillator} + * @private + */ + this._oscillator = null; + //set the oscillator + this.type = options.type; + this._readOnly([ + 'frequency', + 'detune' + ]); + //set the options + this.set(options); + }; + Tone.extend(Tone.OmniOscillator, Tone.Source); + /** + * default values + * @static + * @type {Object} + * @const + */ + Tone.OmniOscillator.defaults = { + 'frequency': 440, + 'detune': 0, + 'type': 'sine', + 'phase': 0 + }; + /** + * @enum {String} + * @private + */ + var OmniOscType = { + Pulse: 'PulseOscillator', + PWM: 'PWMOscillator', + Osc: 'Oscillator', + FM: 'FMOscillator', + AM: 'AMOscillator', + Fat: 'FatOscillator' + }; + /** + * start the oscillator + * @param {Time} [time=now] the time to start the oscillator + * @private + */ + Tone.OmniOscillator.prototype._start = function (time) { + this._oscillator.start(time); + }; + /** + * start the oscillator + * @param {Time} [time=now] the time to start the oscillator + * @private + */ + Tone.OmniOscillator.prototype._stop = function (time) { + this._oscillator.stop(time); + }; + Tone.OmniOscillator.prototype.restart = function (time) { + this._oscillator.restart(time); + }; + /** + * The type of the oscillator. Can be any of the basic types: sine, square, triangle, sawtooth. Or + * prefix the basic types with "fm", "am", or "fat" to use the FMOscillator, AMOscillator or FatOscillator + * types. The oscillator could also be set to "pwm" or "pulse". All of the parameters of the + * oscillator's class are accessible when the oscillator is set to that type, but throws an error + * when it's not. + * + * @memberOf Tone.OmniOscillator# + * @type {String} + * @name type + * @example + * omniOsc.type = "pwm"; + * //modulationFrequency is parameter which is available + * //only when the type is "pwm". + * omniOsc.modulationFrequency.value = 0.5; + * @example + * //an square wave frequency modulated by a sawtooth + * omniOsc.type = "fmsquare"; + * omniOsc.modulationType = "sawtooth"; + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'type', { + get: function () { + var prefix = ''; + if (this._sourceType === OmniOscType.FM) { + prefix = 'fm'; + } else if (this._sourceType === OmniOscType.AM) { + prefix = 'am'; + } else if (this._sourceType === OmniOscType.Fat) { + prefix = 'fat'; + } + return prefix + this._oscillator.type; + }, + set: function (type) { + if (type.substr(0, 2) === 'fm') { + this._createNewOscillator(OmniOscType.FM); + this._oscillator.type = type.substr(2); + } else if (type.substr(0, 2) === 'am') { + this._createNewOscillator(OmniOscType.AM); + this._oscillator.type = type.substr(2); + } else if (type.substr(0, 3) === 'fat') { + this._createNewOscillator(OmniOscType.Fat); + this._oscillator.type = type.substr(3); + } else if (type === 'pwm') { + this._createNewOscillator(OmniOscType.PWM); + } else if (type === 'pulse') { + this._createNewOscillator(OmniOscType.Pulse); + } else { + this._createNewOscillator(OmniOscType.Osc); + this._oscillator.type = type; + } + } + }); + /** + * The partials of the waveform. A partial represents + * the amplitude at a harmonic. The first harmonic is the + * fundamental frequency, the second is the octave and so on + * following the harmonic series. + * Setting this value will automatically set the type to "custom". + * The value is an empty array when the type is not "custom". + * This is not available on "pwm" and "pulse" oscillator types. + * @memberOf Tone.OmniOscillator# + * @type {Array} + * @name partials + * @example + * osc.partials = [1, 0.2, 0.01]; + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'partials', { + get: function () { + return this._oscillator.partials; + }, + set: function (partials) { + this._oscillator.partials = partials; + } + }); + /** + * Set a member/attribute of the oscillator. + * @param {Object|String} params + * @param {number=} value + * @param {Time=} rampTime + * @returns {Tone.OmniOscillator} this + */ + Tone.OmniOscillator.prototype.set = function (params, value) { + //make sure the type is set first + if (params === 'type') { + this.type = value; + } else if (Tone.isObject(params) && params.hasOwnProperty('type')) { + this.type = params.type; + } + //then set the rest + Tone.prototype.set.apply(this, arguments); + return this; + }; + /** + * connect the oscillator to the frequency and detune signals + * @private + */ + Tone.OmniOscillator.prototype._createNewOscillator = function (oscType) { + if (oscType !== this._sourceType) { + this._sourceType = oscType; + var OscillatorConstructor = Tone[oscType]; + //short delay to avoid clicks on the change + var now = this.now(); + if (this._oscillator !== null) { + var oldOsc = this._oscillator; + oldOsc.stop(now); + //dispose the old one + this.context.setTimeout(function () { + oldOsc.dispose(); + oldOsc = null; + }, this.blockTime); + } + this._oscillator = new OscillatorConstructor(); + this.frequency.connect(this._oscillator.frequency); + this.detune.connect(this._oscillator.detune); + this._oscillator.connect(this.output); + if (this.state === Tone.State.Started) { + this._oscillator.start(now); + } + } + }; + /** + * The phase of the oscillator in degrees. + * @memberOf Tone.OmniOscillator# + * @type {Degrees} + * @name phase + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'phase', { + get: function () { + return this._oscillator.phase; + }, + set: function (phase) { + this._oscillator.phase = phase; + } + }); + /** + * The width of the oscillator (only if the oscillator is set to "pulse") + * @memberOf Tone.OmniOscillator# + * @type {NormalRange} + * @signal + * @name width + * @example + * var omniOsc = new Tone.OmniOscillator(440, "pulse"); + * //can access the width attribute only if type === "pulse" + * omniOsc.width.value = 0.2; + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'width', { + get: function () { + if (this._sourceType === OmniOscType.Pulse) { + return this._oscillator.width; + } + } + }); + /** + * The number of detuned oscillators + * @memberOf Tone.OmniOscillator# + * @type {Number} + * @name count + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'count', { + get: function () { + if (this._sourceType === OmniOscType.Fat) { + return this._oscillator.count; + } + }, + set: function (count) { + if (this._sourceType === OmniOscType.Fat) { + this._oscillator.count = count; + } + } + }); + /** + * The detune spread between the oscillators. If "count" is + * set to 3 oscillators and the "spread" is set to 40, + * the three oscillators would be detuned like this: [-20, 0, 20] + * for a total detune spread of 40 cents. See Tone.FatOscillator + * for more info. + * @memberOf Tone.OmniOscillator# + * @type {Cents} + * @name spread + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'spread', { + get: function () { + if (this._sourceType === OmniOscType.Fat) { + return this._oscillator.spread; + } + }, + set: function (spread) { + if (this._sourceType === OmniOscType.Fat) { + this._oscillator.spread = spread; + } + } + }); + /** + * The type of the modulator oscillator. Only if the oscillator + * is set to "am" or "fm" types. see. Tone.AMOscillator or Tone.FMOscillator + * for more info. + * @memberOf Tone.OmniOscillator# + * @type {String} + * @name modulationType + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'modulationType', { + get: function () { + if (this._sourceType === OmniOscType.FM || this._sourceType === OmniOscType.AM) { + return this._oscillator.modulationType; + } + }, + set: function (mType) { + if (this._sourceType === OmniOscType.FM || this._sourceType === OmniOscType.AM) { + this._oscillator.modulationType = mType; + } + } + }); + /** + * The modulation index which is in essence the depth or amount of the modulation. In other terms it is the + * ratio of the frequency of the modulating signal (mf) to the amplitude of the + * modulating signal (ma) -- as in ma/mf. + * See Tone.FMOscillator for more info. + * @type {Positive} + * @signal + * @name modulationIndex + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'modulationIndex', { + get: function () { + if (this._sourceType === OmniOscType.FM) { + return this._oscillator.modulationIndex; + } + } + }); + /** + * Harmonicity is the frequency ratio between the carrier and the modulator oscillators. + * A harmonicity of 1 gives both oscillators the same frequency. + * Harmonicity = 2 means a change of an octave. See Tone.AMOscillator or Tone.FMOscillator + * for more info. + * @memberOf Tone.OmniOscillator# + * @signal + * @type {Positive} + * @name harmonicity + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'harmonicity', { + get: function () { + if (this._sourceType === OmniOscType.FM || this._sourceType === OmniOscType.AM) { + return this._oscillator.harmonicity; + } + } + }); + /** + * The modulationFrequency Signal of the oscillator + * (only if the oscillator type is set to pwm). See + * Tone.PWMOscillator for more info. + * @memberOf Tone.OmniOscillator# + * @type {Frequency} + * @signal + * @name modulationFrequency + * @example + * var omniOsc = new Tone.OmniOscillator(440, "pwm"); + * //can access the modulationFrequency attribute only if type === "pwm" + * omniOsc.modulationFrequency.value = 0.2; + */ + Object.defineProperty(Tone.OmniOscillator.prototype, 'modulationFrequency', { + get: function () { + if (this._sourceType === OmniOscType.PWM) { + return this._oscillator.modulationFrequency; + } + } + }); + /** + * Clean up. + * @return {Tone.OmniOscillator} this + */ + Tone.OmniOscillator.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + this._writable([ + 'frequency', + 'detune' + ]); + this.detune.dispose(); + this.detune = null; + this.frequency.dispose(); + this.frequency = null; + this._oscillator.dispose(); + this._oscillator = null; + this._sourceType = null; + return this; + }; + return Tone.OmniOscillator; + }); + Module(function (Tone) { + + /** + * @class Base-class for all instruments + * + * @constructor + * @extends {Tone.AudioNode} + */ + Tone.Instrument = function (options) { + //get the defaults + options = Tone.defaultArg(options, Tone.Instrument.defaults); + Tone.AudioNode.call(this); + /** + * The output and volume triming node + * @type {Tone.Volume} + * @private + */ + this._volume = this.output = new Tone.Volume(options.volume); + /** + * The volume of the output in decibels. + * @type {Decibels} + * @signal + * @example + * source.volume.value = -6; + */ + this.volume = this._volume.volume; + this._readOnly('volume'); + /** + * Keep track of all events scheduled to the transport + * when the instrument is 'synced' + * @type {Array<Number>} + * @private + */ + this._scheduledEvents = []; + }; + Tone.extend(Tone.Instrument, Tone.AudioNode); + /** + * the default attributes + * @type {object} + */ + Tone.Instrument.defaults = { + /** the volume of the output in decibels */ + 'volume': 0 + }; + /** + * @abstract + * @param {string|number} note the note to trigger + * @param {Time} [time=now] the time to trigger the ntoe + * @param {number} [velocity=1] the velocity to trigger the note + */ + Tone.Instrument.prototype.triggerAttack = Tone.noOp; + /** + * @abstract + * @param {Time} [time=now] when to trigger the release + */ + Tone.Instrument.prototype.triggerRelease = Tone.noOp; + /** + * Sync the instrument to the Transport. All subsequent calls of + * [triggerAttack](#triggerattack) and [triggerRelease](#triggerrelease) + * will be scheduled along the transport. + * @example + * instrument.sync() + * //schedule 3 notes when the transport first starts + * instrument.triggerAttackRelease('C4', '8n', 0) + * instrument.triggerAttackRelease('E4', '8n', '8n') + * instrument.triggerAttackRelease('G4', '8n', '4n') + * //start the transport to hear the notes + * Transport.start() + * @returns {Tone.Instrument} this + */ + Tone.Instrument.prototype.sync = function () { + this._syncMethod('triggerAttack', 1); + this._syncMethod('triggerRelease', 0); + return this; + }; + /** + * Wrap the given method so that it can be synchronized + * @param {String} method Which method to wrap and sync + * @param {Number} timePosition What position the time argument appears in + * @private + */ + Tone.Instrument.prototype._syncMethod = function (method, timePosition) { + var originalMethod = this['_original_' + method] = this[method]; + this[method] = function () { + var args = Array.prototype.slice.call(arguments); + var time = args[timePosition]; + var id = Tone.Transport.schedule(function (t) { + args[timePosition] = t; + originalMethod.apply(this, args); + }.bind(this), time); + this._scheduledEvents.push(id); + }.bind(this); + }; + /** + * Unsync the instrument from the Transport + * @returns {Tone.Instrument} this + */ + Tone.Instrument.prototype.unsync = function () { + this._scheduledEvents.forEach(function (id) { + Tone.Transport.clear(id); + }); + this._scheduledEvents = []; + if (this._original_triggerAttack) { + this.triggerAttack = this._original_triggerAttack; + this.triggerRelease = this._original_triggerRelease; + } + return this; + }; + /** + * Trigger the attack and then the release after the duration. + * @param {Frequency} note The note to trigger. + * @param {Time} duration How long the note should be held for before + * triggering the release. This value must be greater than 0. + * @param {Time} [time=now] When the note should be triggered. + * @param {NormalRange} [velocity=1] The velocity the note should be triggered at. + * @returns {Tone.Instrument} this + * @example + * //trigger "C4" for the duration of an 8th note + * synth.triggerAttackRelease("C4", "8n"); + */ + Tone.Instrument.prototype.triggerAttackRelease = function (note, duration, time, velocity) { + time = this.toSeconds(time); + duration = this.toSeconds(duration); + this.triggerAttack(note, time, velocity); + this.triggerRelease(time + duration); + return this; + }; + /** + * clean up + * @returns {Tone.Instrument} this + */ + Tone.Instrument.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._volume.dispose(); + this._volume = null; + this._writable(['volume']); + this.volume = null; + this.unsync(); + this._scheduledEvents = null; + return this; + }; + return Tone.Instrument; + }); + Module(function (Tone) { + + /** + * @class This is an abstract base class for other monophonic instruments to + * extend. IMPORTANT: It does not make any sound on its own and + * shouldn't be directly instantiated. + * + * @constructor + * @abstract + * @extends {Tone.Instrument} + */ + Tone.Monophonic = function (options) { + //get the defaults + options = Tone.defaultArg(options, Tone.Monophonic.defaults); + Tone.Instrument.call(this, options); + /** + * The glide time between notes. + * @type {Time} + */ + this.portamento = options.portamento; + }; + Tone.extend(Tone.Monophonic, Tone.Instrument); + /** + * @static + * @const + * @type {Object} + */ + Tone.Monophonic.defaults = { 'portamento': 0 }; + /** + * Trigger the attack of the note optionally with a given velocity. + * + * + * @param {Frequency} note The note to trigger. + * @param {Time} [time=now] When the note should start. + * @param {number} [velocity=1] velocity The velocity scaler + * determines how "loud" the note + * will be triggered. + * @returns {Tone.Monophonic} this + * @example + * synth.triggerAttack("C4"); + * @example + * //trigger the note a half second from now at half velocity + * synth.triggerAttack("C4", "+0.5", 0.5); + */ + Tone.Monophonic.prototype.triggerAttack = function (note, time, velocity) { + time = this.toSeconds(time); + this._triggerEnvelopeAttack(time, velocity); + this.setNote(note, time); + return this; + }; + /** + * Trigger the release portion of the envelope + * @param {Time} [time=now] If no time is given, the release happens immediatly + * @returns {Tone.Monophonic} this + * @example + * synth.triggerRelease(); + */ + Tone.Monophonic.prototype.triggerRelease = function (time) { + time = this.toSeconds(time); + this._triggerEnvelopeRelease(time); + return this; + }; + /** + * override this method with the actual method + * @abstract + * @private + */ + Tone.Monophonic.prototype._triggerEnvelopeAttack = function () { + }; + /** + * override this method with the actual method + * @abstract + * @private + */ + Tone.Monophonic.prototype._triggerEnvelopeRelease = function () { + }; + /** + * Get the level of the output at the given time. Measures + * the envelope(s) value at the time. + * @param {Time} time The time to query the envelope value + * @return {NormalRange} The output level between 0-1 + */ + Tone.Monophonic.prototype.getLevelAtTime = function (time) { + time = this.toSeconds(time); + return this.envelope.getValueAtTime(time); + }; + /** + * Set the note at the given time. If no time is given, the note + * will set immediately. + * @param {Frequency} note The note to change to. + * @param {Time} [time=now] The time when the note should be set. + * @returns {Tone.Monophonic} this + * @example + * //change to F#6 in one quarter note from now. + * synth.setNote("F#6", "+4n"); + * @example + * //change to Bb4 right now + * synth.setNote("Bb4"); + */ + Tone.Monophonic.prototype.setNote = function (note, time) { + time = this.toSeconds(time); + if (this.portamento > 0 && this.getLevelAtTime(time) > 0.05) { + var portTime = this.toSeconds(this.portamento); + this.frequency.exponentialRampTo(note, portTime, time); + } else { + this.frequency.setValueAtTime(note, time); + } + return this; + }; + return Tone.Monophonic; + }); + Module(function (Tone) { + + /** + * @class Tone.Synth is composed simply of a Tone.OmniOscillator + * routed through a Tone.AmplitudeEnvelope. + * <img src="https://docs.google.com/drawings/d/1-1_0YW2Z1J2EPI36P8fNCMcZG7N1w1GZluPs4og4evo/pub?w=1163&h=231"> + * + * @constructor + * @extends {Tone.Monophonic} + * @param {Object} [options] the options available for the synth + * see defaults below + * @example + * var synth = new Tone.Synth().toMaster(); + * synth.triggerAttackRelease("C4", "8n"); + */ + Tone.Synth = function (options) { + //get the defaults + options = Tone.defaultArg(options, Tone.Synth.defaults); + Tone.Monophonic.call(this, options); + /** + * The oscillator. + * @type {Tone.OmniOscillator} + */ + this.oscillator = new Tone.OmniOscillator(options.oscillator); + /** + * The frequency control. + * @type {Frequency} + * @signal + */ + this.frequency = this.oscillator.frequency; + /** + * The detune control. + * @type {Cents} + * @signal + */ + this.detune = this.oscillator.detune; + /** + * The amplitude envelope. + * @type {Tone.AmplitudeEnvelope} + */ + this.envelope = new Tone.AmplitudeEnvelope(options.envelope); + //connect the oscillators to the output + this.oscillator.chain(this.envelope, this.output); + this._readOnly([ + 'oscillator', + 'frequency', + 'detune', + 'envelope' + ]); + }; + Tone.extend(Tone.Synth, Tone.Monophonic); + /** + * @const + * @static + * @type {Object} + */ + Tone.Synth.defaults = { + 'oscillator': { 'type': 'triangle' }, + 'envelope': { + 'attack': 0.005, + 'decay': 0.1, + 'sustain': 0.3, + 'release': 1 + } + }; + /** + * start the attack portion of the envelope + * @param {Time} [time=now] the time the attack should start + * @param {number} [velocity=1] the velocity of the note (0-1) + * @returns {Tone.Synth} this + * @private + */ + Tone.Synth.prototype._triggerEnvelopeAttack = function (time, velocity) { + //the envelopes + this.envelope.triggerAttack(time, velocity); + this.oscillator.start(time); + //if there is no release portion, stop the oscillator + if (this.envelope.sustain === 0) { + this.oscillator.stop(time + this.envelope.attack + this.envelope.decay); + } + return this; + }; + /** + * start the release portion of the envelope + * @param {Time} [time=now] the time the release should start + * @returns {Tone.Synth} this + * @private + */ + Tone.Synth.prototype._triggerEnvelopeRelease = function (time) { + time = this.toSeconds(time); + this.envelope.triggerRelease(time); + this.oscillator.stop(time + this.envelope.release); + return this; + }; + /** + * clean up + * @returns {Tone.Synth} this + */ + Tone.Synth.prototype.dispose = function () { + Tone.Monophonic.prototype.dispose.call(this); + this._writable([ + 'oscillator', + 'frequency', + 'detune', + 'envelope' + ]); + this.oscillator.dispose(); + this.oscillator = null; + this.envelope.dispose(); + this.envelope = null; + this.frequency = null; + this.detune = null; + return this; + }; + return Tone.Synth; + }); + Module(function (Tone) { + + /** + * @class AMSynth uses the output of one Tone.Synth to modulate the + * amplitude of another Tone.Synth. The harmonicity (the ratio between + * the two signals) affects the timbre of the output signal greatly. + * Read more about Amplitude Modulation Synthesis on + * [SoundOnSound](https://web.archive.org/web/20160404103653/http://www.soundonsound.com:80/sos/mar00/articles/synthsecrets.htm). + * <img src="https://docs.google.com/drawings/d/1TQu8Ed4iFr1YTLKpB3U1_hur-UwBrh5gdBXc8BxfGKw/pub?w=1009&h=457"> + * + * @constructor + * @extends {Tone.Monophonic} + * @param {Object} [options] the options available for the synth + * see defaults below + * @example + * var synth = new Tone.AMSynth().toMaster(); + * synth.triggerAttackRelease("C4", "4n"); + */ + Tone.AMSynth = function (options) { + options = Tone.defaultArg(options, Tone.AMSynth.defaults); + Tone.Monophonic.call(this, options); + /** + * The carrier voice. + * @type {Tone.Synth} + * @private + */ + this._carrier = new Tone.Synth(); + this._carrier.volume.value = -10; + /** + * The carrier's oscillator + * @type {Tone.Oscillator} + */ + this.oscillator = this._carrier.oscillator; + /** + * The carrier's envelope + * @type {Tone.AmplitudeEnvelope} + */ + this.envelope = this._carrier.envelope.set(options.envelope); + /** + * The modulator voice. + * @type {Tone.Synth} + * @private + */ + this._modulator = new Tone.Synth(); + this._modulator.volume.value = -10; + /** + * The modulator's oscillator which is applied + * to the amplitude of the oscillator + * @type {Tone.Oscillator} + */ + this.modulation = this._modulator.oscillator.set(options.modulation); + /** + * The modulator's envelope + * @type {Tone.AmplitudeEnvelope} + */ + this.modulationEnvelope = this._modulator.envelope.set(options.modulationEnvelope); + /** + * The frequency. + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(440, Tone.Type.Frequency); + /** + * The detune in cents + * @type {Cents} + * @signal + */ + this.detune = new Tone.Signal(options.detune, Tone.Type.Cents); + /** + * Harmonicity is the ratio between the two voices. A harmonicity of + * 1 is no change. Harmonicity = 2 means a change of an octave. + * @type {Positive} + * @signal + * @example + * //pitch voice1 an octave below voice0 + * synth.harmonicity.value = 0.5; + */ + this.harmonicity = new Tone.Multiply(options.harmonicity); + this.harmonicity.units = Tone.Type.Positive; + /** + * convert the -1,1 output to 0,1 + * @type {Tone.AudioToGain} + * @private + */ + this._modulationScale = new Tone.AudioToGain(); + /** + * the node where the modulation happens + * @type {Tone.Gain} + * @private + */ + this._modulationNode = new Tone.Gain(); + //control the two voices frequency + this.frequency.connect(this._carrier.frequency); + this.frequency.chain(this.harmonicity, this._modulator.frequency); + this.detune.fan(this._carrier.detune, this._modulator.detune); + this._modulator.chain(this._modulationScale, this._modulationNode.gain); + this._carrier.chain(this._modulationNode, this.output); + this._readOnly([ + 'frequency', + 'harmonicity', + 'oscillator', + 'envelope', + 'modulation', + 'modulationEnvelope', + 'detune' + ]); + }; + Tone.extend(Tone.AMSynth, Tone.Monophonic); + /** + * @static + * @type {Object} + */ + Tone.AMSynth.defaults = { + 'harmonicity': 3, + 'detune': 0, + 'oscillator': { 'type': 'sine' }, + 'envelope': { + 'attack': 0.01, + 'decay': 0.01, + 'sustain': 1, + 'release': 0.5 + }, + 'modulation': { 'type': 'square' }, + 'modulationEnvelope': { + 'attack': 0.5, + 'decay': 0, + 'sustain': 1, + 'release': 0.5 + } + }; + /** + * trigger the attack portion of the note + * + * @param {Time} [time=now] the time the note will occur + * @param {NormalRange} [velocity=1] the velocity of the note + * @private + * @returns {Tone.AMSynth} this + */ + Tone.AMSynth.prototype._triggerEnvelopeAttack = function (time, velocity) { + //the port glide + time = this.toSeconds(time); + //the envelopes + this._carrier._triggerEnvelopeAttack(time, velocity); + this._modulator._triggerEnvelopeAttack(time); + return this; + }; + /** + * trigger the release portion of the note + * + * @param {Time} [time=now] the time the note will release + * @private + * @returns {Tone.AMSynth} this + */ + Tone.AMSynth.prototype._triggerEnvelopeRelease = function (time) { + this._carrier._triggerEnvelopeRelease(time); + this._modulator._triggerEnvelopeRelease(time); + return this; + }; + /** + * clean up + * @returns {Tone.AMSynth} this + */ + Tone.AMSynth.prototype.dispose = function () { + Tone.Monophonic.prototype.dispose.call(this); + this._writable([ + 'frequency', + 'harmonicity', + 'oscillator', + 'envelope', + 'modulation', + 'modulationEnvelope', + 'detune' + ]); + this._carrier.dispose(); + this._carrier = null; + this._modulator.dispose(); + this._modulator = null; + this.frequency.dispose(); + this.frequency = null; + this.detune.dispose(); + this.detune = null; + this.harmonicity.dispose(); + this.harmonicity = null; + this._modulationScale.dispose(); + this._modulationScale = null; + this._modulationNode.dispose(); + this._modulationNode = null; + this.oscillator = null; + this.envelope = null; + this.modulationEnvelope = null; + this.modulation = null; + return this; + }; + return Tone.AMSynth; + }); + Module(function (Tone) { + + /** + * @class Tone.MonoSynth is composed of one oscillator, one filter, and two envelopes. + * The amplitude of the Tone.Oscillator and the cutoff frequency of the + * Tone.Filter are controlled by Tone.Envelopes. + * <img src="https://docs.google.com/drawings/d/1gaY1DF9_Hzkodqf8JI1Cg2VZfwSElpFQfI94IQwad38/pub?w=924&h=240"> + * + * @constructor + * @extends {Tone.Monophonic} + * @param {Object} [options] the options available for the synth + * see defaults below + * @example + * var synth = new Tone.MonoSynth({ + * "oscillator" : { + * "type" : "square" + * }, + * "envelope" : { + * "attack" : 0.1 + * } + * }).toMaster(); + * synth.triggerAttackRelease("C4", "8n"); + */ + Tone.MonoSynth = function (options) { + //get the defaults + options = Tone.defaultArg(options, Tone.MonoSynth.defaults); + Tone.Monophonic.call(this, options); + /** + * The oscillator. + * @type {Tone.OmniOscillator} + */ + this.oscillator = new Tone.OmniOscillator(options.oscillator); + /** + * The frequency control. + * @type {Frequency} + * @signal + */ + this.frequency = this.oscillator.frequency; + /** + * The detune control. + * @type {Cents} + * @signal + */ + this.detune = this.oscillator.detune; + /** + * The filter. + * @type {Tone.Filter} + */ + this.filter = new Tone.Filter(options.filter); + /** + * The filter envelope. + * @type {Tone.FrequencyEnvelope} + */ + this.filterEnvelope = new Tone.FrequencyEnvelope(options.filterEnvelope); + /** + * The amplitude envelope. + * @type {Tone.AmplitudeEnvelope} + */ + this.envelope = new Tone.AmplitudeEnvelope(options.envelope); + //connect the oscillators to the output + this.oscillator.chain(this.filter, this.envelope, this.output); + //connect the filter envelope + this.filterEnvelope.connect(this.filter.frequency); + this._readOnly([ + 'oscillator', + 'frequency', + 'detune', + 'filter', + 'filterEnvelope', + 'envelope' + ]); + }; + Tone.extend(Tone.MonoSynth, Tone.Monophonic); + /** + * @const + * @static + * @type {Object} + */ + Tone.MonoSynth.defaults = { + 'frequency': 'C4', + 'detune': 0, + 'oscillator': { 'type': 'square' }, + 'filter': { + 'Q': 6, + 'type': 'lowpass', + 'rolloff': -24 + }, + 'envelope': { + 'attack': 0.005, + 'decay': 0.1, + 'sustain': 0.9, + 'release': 1 + }, + 'filterEnvelope': { + 'attack': 0.06, + 'decay': 0.2, + 'sustain': 0.5, + 'release': 2, + 'baseFrequency': 200, + 'octaves': 7, + 'exponent': 2 + } + }; + /** + * start the attack portion of the envelope + * @param {Time} [time=now] the time the attack should start + * @param {NormalRange} [velocity=1] the velocity of the note (0-1) + * @returns {Tone.MonoSynth} this + * @private + */ + Tone.MonoSynth.prototype._triggerEnvelopeAttack = function (time, velocity) { + time = this.toSeconds(time); + //the envelopes + this.envelope.triggerAttack(time, velocity); + this.filterEnvelope.triggerAttack(time); + this.oscillator.start(time); + if (this.envelope.sustain === 0) { + this.oscillator.stop(time + this.envelope.attack + this.envelope.decay); + } + return this; + }; + /** + * start the release portion of the envelope + * @param {Time} [time=now] the time the release should start + * @returns {Tone.MonoSynth} this + * @private + */ + Tone.MonoSynth.prototype._triggerEnvelopeRelease = function (time) { + this.envelope.triggerRelease(time); + this.filterEnvelope.triggerRelease(time); + this.oscillator.stop(time + this.envelope.release); + return this; + }; + /** + * clean up + * @returns {Tone.MonoSynth} this + */ + Tone.MonoSynth.prototype.dispose = function () { + Tone.Monophonic.prototype.dispose.call(this); + this._writable([ + 'oscillator', + 'frequency', + 'detune', + 'filter', + 'filterEnvelope', + 'envelope' + ]); + this.oscillator.dispose(); + this.oscillator = null; + this.envelope.dispose(); + this.envelope = null; + this.filterEnvelope.dispose(); + this.filterEnvelope = null; + this.filter.dispose(); + this.filter = null; + this.frequency = null; + this.detune = null; + return this; + }; + return Tone.MonoSynth; + }); + Module(function (Tone) { + + /** + * @class Tone.DuoSynth is a monophonic synth composed of two + * MonoSynths run in parallel with control over the + * frequency ratio between the two voices and vibrato effect. + * <img src="https://docs.google.com/drawings/d/1bL4GXvfRMMlqS7XyBm9CjL9KJPSUKbcdBNpqOlkFLxk/pub?w=1012&h=448"> + * + * @constructor + * @extends {Tone.Monophonic} + * @param {Object} [options] the options available for the synth + * see defaults below + * @example + * var duoSynth = new Tone.DuoSynth().toMaster(); + * duoSynth.triggerAttackRelease("C4", "2n"); + */ + Tone.DuoSynth = function (options) { + options = Tone.defaultArg(options, Tone.DuoSynth.defaults); + Tone.Monophonic.call(this, options); + /** + * the first voice + * @type {Tone.MonoSynth} + */ + this.voice0 = new Tone.MonoSynth(options.voice0); + this.voice0.volume.value = -10; + /** + * the second voice + * @type {Tone.MonoSynth} + */ + this.voice1 = new Tone.MonoSynth(options.voice1); + this.voice1.volume.value = -10; + /** + * The vibrato LFO. + * @type {Tone.LFO} + * @private + */ + this._vibrato = new Tone.LFO(options.vibratoRate, -50, 50); + this._vibrato.start(); + /** + * the vibrato frequency + * @type {Frequency} + * @signal + */ + this.vibratoRate = this._vibrato.frequency; + /** + * the vibrato gain + * @type {Tone.Gain} + * @private + */ + this._vibratoGain = new Tone.Gain(options.vibratoAmount, Tone.Type.Positive); + /** + * The amount of vibrato + * @type {Positive} + * @signal + */ + this.vibratoAmount = this._vibratoGain.gain; + /** + * the frequency control + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(440, Tone.Type.Frequency); + /** + * Harmonicity is the ratio between the two voices. A harmonicity of + * 1 is no change. Harmonicity = 2 means a change of an octave. + * @type {Positive} + * @signal + * @example + * //pitch voice1 an octave below voice0 + * duoSynth.harmonicity.value = 0.5; + */ + this.harmonicity = new Tone.Multiply(options.harmonicity); + this.harmonicity.units = Tone.Type.Positive; + //control the two voices frequency + this.frequency.connect(this.voice0.frequency); + this.frequency.chain(this.harmonicity, this.voice1.frequency); + this._vibrato.connect(this._vibratoGain); + this._vibratoGain.fan(this.voice0.detune, this.voice1.detune); + this.voice0.connect(this.output); + this.voice1.connect(this.output); + this._readOnly([ + 'voice0', + 'voice1', + 'frequency', + 'vibratoAmount', + 'vibratoRate' + ]); + }; + Tone.extend(Tone.DuoSynth, Tone.Monophonic); + /** + * @static + * @type {Object} + */ + Tone.DuoSynth.defaults = { + 'vibratoAmount': 0.5, + 'vibratoRate': 5, + 'harmonicity': 1.5, + 'voice0': { + 'volume': -10, + 'portamento': 0, + 'oscillator': { 'type': 'sine' }, + 'filterEnvelope': { + 'attack': 0.01, + 'decay': 0, + 'sustain': 1, + 'release': 0.5 + }, + 'envelope': { + 'attack': 0.01, + 'decay': 0, + 'sustain': 1, + 'release': 0.5 + } + }, + 'voice1': { + 'volume': -10, + 'portamento': 0, + 'oscillator': { 'type': 'sine' }, + 'filterEnvelope': { + 'attack': 0.01, + 'decay': 0, + 'sustain': 1, + 'release': 0.5 + }, + 'envelope': { + 'attack': 0.01, + 'decay': 0, + 'sustain': 1, + 'release': 0.5 + } + } + }; + /** + * start the attack portion of the envelopes + * + * @param {Time} [time=now] the time the attack should start + * @param {NormalRange} [velocity=1] the velocity of the note (0-1) + * @returns {Tone.DuoSynth} this + * @private + */ + Tone.DuoSynth.prototype._triggerEnvelopeAttack = function (time, velocity) { + time = this.toSeconds(time); + this.voice0._triggerEnvelopeAttack(time, velocity); + this.voice1._triggerEnvelopeAttack(time, velocity); + return this; + }; + /** + * start the release portion of the envelopes + * + * @param {Time} [time=now] the time the release should start + * @returns {Tone.DuoSynth} this + * @private + */ + Tone.DuoSynth.prototype._triggerEnvelopeRelease = function (time) { + this.voice0._triggerEnvelopeRelease(time); + this.voice1._triggerEnvelopeRelease(time); + return this; + }; + /** + * Get the level of the output at the given time. Measures + * the envelope(s) value at the time. + * @param {Time} time The time to query the envelope value + * @return {NormalRange} The output level between 0-1 + */ + Tone.DuoSynth.prototype.getLevelAtTime = function (time) { + return (this.voice0.getLevelAtTime(time) + this.voice1.getLevelAtTime(time)) / 2; + }; + /** + * clean up + * @returns {Tone.DuoSynth} this + */ + Tone.DuoSynth.prototype.dispose = function () { + Tone.Monophonic.prototype.dispose.call(this); + this._writable([ + 'voice0', + 'voice1', + 'frequency', + 'vibratoAmount', + 'vibratoRate' + ]); + this.voice0.dispose(); + this.voice0 = null; + this.voice1.dispose(); + this.voice1 = null; + this.frequency.dispose(); + this.frequency = null; + this._vibratoGain.dispose(); + this._vibratoGain = null; + this._vibrato = null; + this.harmonicity.dispose(); + this.harmonicity = null; + this.vibratoAmount.dispose(); + this.vibratoAmount = null; + this.vibratoRate = null; + return this; + }; + return Tone.DuoSynth; + }); + Module(function (Tone) { + + /** + * @class FMSynth is composed of two Tone.Synths where one Tone.Synth modulates + * the frequency of a second Tone.Synth. A lot of spectral content + * can be explored using the modulationIndex parameter. Read more about + * frequency modulation synthesis on Sound On Sound: [Part 1](https://web.archive.org/web/20160403123704/http://www.soundonsound.com/sos/apr00/articles/synthsecrets.htm), [Part 2](https://web.archive.org/web/20160403115835/http://www.soundonsound.com/sos/may00/articles/synth.htm). + * <img src="https://docs.google.com/drawings/d/1h0PUDZXPgi4Ikx6bVT6oncrYPLluFKy7lj53puxj-DM/pub?w=902&h=462"> + * + * @constructor + * @extends {Tone.Monophonic} + * @param {Object} [options] the options available for the synth + * see defaults below + * @example + * var fmSynth = new Tone.FMSynth().toMaster(); + * fmSynth.triggerAttackRelease("C5", "4n"); + */ + Tone.FMSynth = function (options) { + options = Tone.defaultArg(options, Tone.FMSynth.defaults); + Tone.Monophonic.call(this, options); + /** + * The carrier voice. + * @type {Tone.Synth} + * @private + */ + this._carrier = new Tone.Synth(options.carrier); + this._carrier.volume.value = -10; + /** + * The carrier's oscillator + * @type {Tone.Oscillator} + */ + this.oscillator = this._carrier.oscillator; + /** + * The carrier's envelope + * @type {Tone.Oscillator} + */ + this.envelope = this._carrier.envelope.set(options.envelope); + /** + * The modulator voice. + * @type {Tone.Synth} + * @private + */ + this._modulator = new Tone.Synth(options.modulator); + this._modulator.volume.value = -10; + /** + * The modulator's oscillator which is applied + * to the amplitude of the oscillator + * @type {Tone.Oscillator} + */ + this.modulation = this._modulator.oscillator.set(options.modulation); + /** + * The modulator's envelope + * @type {Tone.Oscillator} + */ + this.modulationEnvelope = this._modulator.envelope.set(options.modulationEnvelope); + /** + * The frequency control. + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(440, Tone.Type.Frequency); + /** + * The detune in cents + * @type {Cents} + * @signal + */ + this.detune = new Tone.Signal(options.detune, Tone.Type.Cents); + /** + * Harmonicity is the ratio between the two voices. A harmonicity of + * 1 is no change. Harmonicity = 2 means a change of an octave. + * @type {Positive} + * @signal + * @example + * //pitch voice1 an octave below voice0 + * synth.harmonicity.value = 0.5; + */ + this.harmonicity = new Tone.Multiply(options.harmonicity); + this.harmonicity.units = Tone.Type.Positive; + /** + * The modulation index which essentially the depth or amount of the modulation. It is the + * ratio of the frequency of the modulating signal (mf) to the amplitude of the + * modulating signal (ma) -- as in ma/mf. + * @type {Positive} + * @signal + */ + this.modulationIndex = new Tone.Multiply(options.modulationIndex); + this.modulationIndex.units = Tone.Type.Positive; + /** + * the node where the modulation happens + * @type {GainNode} + * @private + */ + this._modulationNode = new Tone.Gain(0); + //control the two voices frequency + this.frequency.connect(this._carrier.frequency); + this.frequency.chain(this.harmonicity, this._modulator.frequency); + this.frequency.chain(this.modulationIndex, this._modulationNode); + this.detune.fan(this._carrier.detune, this._modulator.detune); + this._modulator.connect(this._modulationNode.gain); + this._modulationNode.connect(this._carrier.frequency); + this._carrier.connect(this.output); + this._readOnly([ + 'frequency', + 'harmonicity', + 'modulationIndex', + 'oscillator', + 'envelope', + 'modulation', + 'modulationEnvelope', + 'detune' + ]); + }; + Tone.extend(Tone.FMSynth, Tone.Monophonic); + /** + * @static + * @type {Object} + */ + Tone.FMSynth.defaults = { + 'harmonicity': 3, + 'modulationIndex': 10, + 'detune': 0, + 'oscillator': { 'type': 'sine' }, + 'envelope': { + 'attack': 0.01, + 'decay': 0.01, + 'sustain': 1, + 'release': 0.5 + }, + 'modulation': { 'type': 'square' }, + 'modulationEnvelope': { + 'attack': 0.5, + 'decay': 0, + 'sustain': 1, + 'release': 0.5 + } + }; + /** + * trigger the attack portion of the note + * + * @param {Time} [time=now] the time the note will occur + * @param {number} [velocity=1] the velocity of the note + * @returns {Tone.FMSynth} this + * @private + */ + Tone.FMSynth.prototype._triggerEnvelopeAttack = function (time, velocity) { + time = this.toSeconds(time); + //the envelopes + this._carrier._triggerEnvelopeAttack(time, velocity); + this._modulator._triggerEnvelopeAttack(time); + return this; + }; + /** + * trigger the release portion of the note + * + * @param {Time} [time=now] the time the note will release + * @returns {Tone.FMSynth} this + * @private + */ + Tone.FMSynth.prototype._triggerEnvelopeRelease = function (time) { + time = this.toSeconds(time); + this._carrier._triggerEnvelopeRelease(time); + this._modulator._triggerEnvelopeRelease(time); + return this; + }; + /** + * clean up + * @returns {Tone.FMSynth} this + */ + Tone.FMSynth.prototype.dispose = function () { + Tone.Monophonic.prototype.dispose.call(this); + this._writable([ + 'frequency', + 'harmonicity', + 'modulationIndex', + 'oscillator', + 'envelope', + 'modulation', + 'modulationEnvelope', + 'detune' + ]); + this._carrier.dispose(); + this._carrier = null; + this._modulator.dispose(); + this._modulator = null; + this.frequency.dispose(); + this.frequency = null; + this.detune.dispose(); + this.detune = null; + this.modulationIndex.dispose(); + this.modulationIndex = null; + this.harmonicity.dispose(); + this.harmonicity = null; + this._modulationNode.dispose(); + this._modulationNode = null; + this.oscillator = null; + this.envelope = null; + this.modulationEnvelope = null; + this.modulation = null; + return this; + }; + return Tone.FMSynth; + }); + Module(function (Tone) { + + /** + * @class Tone.MembraneSynth makes kick and tom sounds using a single oscillator + * with an amplitude envelope and frequency ramp. A Tone.OmniOscillator + * is routed through a Tone.AmplitudeEnvelope to the output. The drum + * quality of the sound comes from the frequency envelope applied + * during Tone.MembraneSynth.triggerAttack(note). The frequency envelope + * starts at <code>note * .octaves</code> and ramps to <code>note</code> + * over the duration of <code>.pitchDecay</code>. + * + * @constructor + * @extends {Tone.Instrument} + * @param {Object} [options] the options available for the synth + * see defaults below + * @example + * var synth = new Tone.MembraneSynth().toMaster(); + * synth.triggerAttackRelease("C2", "8n"); + */ + Tone.MembraneSynth = function (options) { + options = Tone.defaultArg(options, Tone.MembraneSynth.defaults); + Tone.Instrument.call(this, options); + /** + * The oscillator. + * @type {Tone.OmniOscillator} + */ + this.oscillator = new Tone.OmniOscillator(options.oscillator); + /** + * The amplitude envelope. + * @type {Tone.AmplitudeEnvelope} + */ + this.envelope = new Tone.AmplitudeEnvelope(options.envelope); + /** + * The number of octaves the pitch envelope ramps. + * @type {Positive} + */ + this.octaves = options.octaves; + /** + * The amount of time the frequency envelope takes. + * @type {Time} + */ + this.pitchDecay = options.pitchDecay; + this.oscillator.chain(this.envelope, this.output); + this._readOnly([ + 'oscillator', + 'envelope' + ]); + }; + Tone.extend(Tone.MembraneSynth, Tone.Instrument); + /** + * @static + * @type {Object} + */ + Tone.MembraneSynth.defaults = { + 'pitchDecay': 0.05, + 'octaves': 10, + 'oscillator': { 'type': 'sine' }, + 'envelope': { + 'attack': 0.001, + 'decay': 0.4, + 'sustain': 0.01, + 'release': 1.4, + 'attackCurve': 'exponential' + } + }; + /** + * Trigger the note at the given time with the given velocity. + * + * @param {Frequency} note the note + * @param {Time} [time=now] the time, if not given is now + * @param {number} [velocity=1] velocity defaults to 1 + * @returns {Tone.MembraneSynth} this + * @example + * kick.triggerAttack(60); + */ + Tone.MembraneSynth.prototype.triggerAttack = function (note, time, velocity) { + time = this.toSeconds(time); + note = this.toFrequency(note); + var maxNote = note * this.octaves; + this.oscillator.frequency.setValueAtTime(maxNote, time); + this.oscillator.frequency.exponentialRampToValueAtTime(note, time + this.toSeconds(this.pitchDecay)); + this.envelope.triggerAttack(time, velocity); + this.oscillator.start(time); + return this; + }; + /** + * Trigger the release portion of the note. + * + * @param {Time} [time=now] the time the note will release + * @returns {Tone.MembraneSynth} this + */ + Tone.MembraneSynth.prototype.triggerRelease = function (time) { + time = this.toSeconds(time); + this.envelope.triggerRelease(time); + this.oscillator.stop(time + this.envelope.release); + return this; + }; + /** + * Clean up. + * @returns {Tone.MembraneSynth} this + */ + Tone.MembraneSynth.prototype.dispose = function () { + Tone.Instrument.prototype.dispose.call(this); + this._writable([ + 'oscillator', + 'envelope' + ]); + this.oscillator.dispose(); + this.oscillator = null; + this.envelope.dispose(); + this.envelope = null; + return this; + }; + return Tone.MembraneSynth; + }); + Module(function (Tone) { + /** + * Inharmonic ratio of frequencies based on the Roland TR-808 + * Taken from https://ccrma.stanford.edu/papers/tr-808-cymbal-physically-informed-circuit-bendable-digital-model + * @private + * @static + * @type {Array} + */ + var inharmRatios = [ + 1, + 1.483, + 1.932, + 2.546, + 2.63, + 3.897 + ]; + /** + * @class A highly inharmonic and spectrally complex source with a highpass filter + * and amplitude envelope which is good for making metalophone sounds. Based + * on CymbalSynth by [@polyrhythmatic](https://github.com/polyrhythmatic). + * Inspiration from [Sound on Sound](https://web.archive.org/web/20160610143924/https://www.soundonsound.com/sos/jul02/articles/synthsecrets0702.asp). + * + * @constructor + * @extends {Tone.Instrument} + * @param {Object} [options] The options availble for the synth + * see defaults below + */ + Tone.MetalSynth = function (options) { + options = Tone.defaultArg(options, Tone.MetalSynth.defaults); + Tone.Instrument.call(this, options); + /** + * The frequency of the cymbal + * @type {Frequency} + * @signal + */ + this.frequency = new Tone.Signal(options.frequency, Tone.Type.Frequency); + /** + * The array of FMOscillators + * @type {Array} + * @private + */ + this._oscillators = []; + /** + * The frequency multipliers + * @type {Array} + * @private + */ + this._freqMultipliers = []; + /** + * The amplitude for the body + * @type {Tone.Gain} + * @private + */ + this._amplitue = new Tone.Gain(0).connect(this.output); + /** + * highpass the output + * @type {Tone.Filter} + * @private + */ + this._highpass = new Tone.Filter({ + 'type': 'highpass', + 'Q': -3.0102999566398125 + }).connect(this._amplitue); + /** + * The number of octaves the highpass + * filter frequency ramps + * @type {Number} + * @private + */ + this._octaves = options.octaves; + /** + * Scale the body envelope + * for the bandpass + * @type {Tone.Scale} + * @private + */ + this._filterFreqScaler = new Tone.Scale(options.resonance, 7000); + /** + * The envelope which is connected both to the + * amplitude and highpass filter's cutoff frequency + * @type {Tone.Envelope} + */ + this.envelope = new Tone.Envelope({ + 'attack': options.envelope.attack, + 'attackCurve': 'linear', + 'decay': options.envelope.decay, + 'sustain': 0, + 'release': options.envelope.release + }).chain(this._filterFreqScaler, this._highpass.frequency); + this.envelope.connect(this._amplitue.gain); + for (var i = 0; i < inharmRatios.length; i++) { + var osc = new Tone.FMOscillator({ + 'type': 'square', + 'modulationType': 'square', + 'harmonicity': options.harmonicity, + 'modulationIndex': options.modulationIndex + }); + osc.connect(this._highpass); + this._oscillators[i] = osc; + var mult = new Tone.Multiply(inharmRatios[i]); + this._freqMultipliers[i] = mult; + this.frequency.chain(mult, osc.frequency); + } + //set the octaves + this.octaves = options.octaves; + }; + Tone.extend(Tone.MetalSynth, Tone.Instrument); + /** + * default values + * @static + * @const + * @type {Object} + */ + Tone.MetalSynth.defaults = { + 'frequency': 200, + 'envelope': { + 'attack': 0.001, + 'decay': 1.4, + 'release': 0.2 + }, + 'harmonicity': 5.1, + 'modulationIndex': 32, + 'resonance': 4000, + 'octaves': 1.5 + }; + /** + * Trigger the attack. + * @param {Time} time When the attack should be triggered. + * @param {NormalRange} [velocity=1] The velocity that the envelope should be triggered at. + * @return {Tone.MetalSynth} this + */ + Tone.MetalSynth.prototype.triggerAttack = function (time, vel) { + time = this.toSeconds(time); + vel = Tone.defaultArg(vel, 1); + this.envelope.triggerAttack(time, vel); + this._oscillators.forEach(function (osc) { + osc.start(time); + }); + //if the sustain is 0, stop the oscillator as well + if (this.envelope.sustain === 0) { + this._oscillators.forEach(function (osc) { + osc.stop(time + this.envelope.attack + this.envelope.decay); + }.bind(this)); + } + return this; + }; + /** + * Trigger the release of the envelope. + * @param {Time} time When the release should be triggered. + * @return {Tone.MetalSynth} this + */ + Tone.MetalSynth.prototype.triggerRelease = function (time) { + time = this.toSeconds(time); + this.envelope.triggerRelease(time); + this._oscillators.forEach(function (osc) { + osc.stop(time + this.envelope.release); + }.bind(this)); + return this; + }; + /** + * Sync the instrument to the Transport. All subsequent calls of + * [triggerAttack](#triggerattack) and [triggerRelease](#triggerrelease) + * will be scheduled along the transport. + * @example + * synth.sync() + * //schedule 3 notes when the transport first starts + * synth.triggerAttackRelease('8n', 0) + * synth.triggerAttackRelease('8n', '8n') + * synth.triggerAttackRelease('8n', '4n') + * //start the transport to hear the notes + * Transport.start() + * @returns {Tone.Instrument} this + */ + Tone.MetalSynth.prototype.sync = function () { + this._syncMethod('triggerAttack', 0); + this._syncMethod('triggerRelease', 0); + return this; + }; + /** + * Trigger the attack and release of the envelope after the given + * duration. + * @param {Time} duration The duration before triggering the release + * @param {Time} time When the attack should be triggered. + * @param {NormalRange} [velocity=1] The velocity that the envelope should be triggered at. + * @return {Tone.MetalSynth} this + */ + Tone.MetalSynth.prototype.triggerAttackRelease = function (duration, time, velocity) { + time = this.toSeconds(time); + duration = this.toSeconds(duration); + this.triggerAttack(time, velocity); + this.triggerRelease(time + duration); + return this; + }; + /** + * The modulationIndex of the oscillators which make up the source. + * see Tone.FMOscillator.modulationIndex + * @memberOf Tone.MetalSynth# + * @type {Positive} + * @name modulationIndex + */ + Object.defineProperty(Tone.MetalSynth.prototype, 'modulationIndex', { + get: function () { + return this._oscillators[0].modulationIndex.value; + }, + set: function (val) { + for (var i = 0; i < this._oscillators.length; i++) { + this._oscillators[i].modulationIndex.value = val; + } + } + }); + /** + * The harmonicity of the oscillators which make up the source. + * see Tone.FMOscillator.harmonicity + * @memberOf Tone.MetalSynth# + * @type {Positive} + * @name harmonicity + */ + Object.defineProperty(Tone.MetalSynth.prototype, 'harmonicity', { + get: function () { + return this._oscillators[0].harmonicity.value; + }, + set: function (val) { + for (var i = 0; i < this._oscillators.length; i++) { + this._oscillators[i].harmonicity.value = val; + } + } + }); + /** + * The frequency of the highpass filter attached to the envelope + * @memberOf Tone.MetalSynth# + * @type {Frequency} + * @name resonance + */ + Object.defineProperty(Tone.MetalSynth.prototype, 'resonance', { + get: function () { + return this._filterFreqScaler.min; + }, + set: function (val) { + this._filterFreqScaler.min = val; + this.octaves = this._octaves; + } + }); + /** + * The number of octaves above the "resonance" frequency + * that the filter ramps during the attack/decay envelope + * @memberOf Tone.MetalSynth# + * @type {Number} + * @name octaves + */ + Object.defineProperty(Tone.MetalSynth.prototype, 'octaves', { + get: function () { + return this._octaves; + }, + set: function (octs) { + this._octaves = octs; + this._filterFreqScaler.max = this._filterFreqScaler.min * Math.pow(2, octs); + } + }); + /** + * Clean up + * @returns {Tone.MetalSynth} this + */ + Tone.MetalSynth.prototype.dispose = function () { + Tone.Instrument.prototype.dispose.call(this); + for (var i = 0; i < this._oscillators.length; i++) { + this._oscillators[i].dispose(); + this._freqMultipliers[i].dispose(); + } + this._oscillators = null; + this._freqMultipliers = null; + this.frequency.dispose(); + this.frequency = null; + this._filterFreqScaler.dispose(); + this._filterFreqScaler = null; + this._amplitue.dispose(); + this._amplitue = null; + this.envelope.dispose(); + this.envelope = null; + this._highpass.dispose(); + this._highpass = null; + }; + return Tone.MetalSynth; + }); + Module(function (Tone) { + + /** + * @class Tone.NoiseSynth is composed of a noise generator (Tone.Noise), one filter (Tone.Filter), + * and two envelopes (Tone.Envelop). One envelope controls the amplitude + * of the noise and the other is controls the cutoff frequency of the filter. + * <img src="https://docs.google.com/drawings/d/1rqzuX9rBlhT50MRvD2TKml9bnZhcZmzXF1rf_o7vdnE/pub?w=918&h=242"> + * + * @constructor + * @extends {Tone.Instrument} + * @param {Object} [options] the options available for the synth + * see defaults below + * @example + * var noiseSynth = new Tone.NoiseSynth().toMaster(); + * noiseSynth.triggerAttackRelease("8n"); + */ + Tone.NoiseSynth = function (options) { + //get the defaults + options = Tone.defaultArg(options, Tone.NoiseSynth.defaults); + Tone.Instrument.call(this, options); + /** + * The noise source. + * @type {Tone.Noise} + * @example + * noiseSynth.set("noise.type", "brown"); + */ + this.noise = new Tone.Noise(); + /** + * The amplitude envelope. + * @type {Tone.AmplitudeEnvelope} + */ + this.envelope = new Tone.AmplitudeEnvelope(options.envelope); + //connect the noise to the output + this.noise.chain(this.envelope, this.output); + this._readOnly([ + 'noise', + 'envelope' + ]); + }; + Tone.extend(Tone.NoiseSynth, Tone.Instrument); + /** + * @const + * @static + * @type {Object} + */ + Tone.NoiseSynth.defaults = { + 'noise': { 'type': 'white' }, + 'envelope': { + 'attack': 0.005, + 'decay': 0.1, + 'sustain': 0 + } + }; + /** + * Start the attack portion of the envelopes. Unlike other + * instruments, Tone.NoiseSynth doesn't have a note. + * @param {Time} [time=now] the time the attack should start + * @param {number} [velocity=1] the velocity of the note (0-1) + * @returns {Tone.NoiseSynth} this + * @example + * noiseSynth.triggerAttack(); + */ + Tone.NoiseSynth.prototype.triggerAttack = function (time, velocity) { + //the envelopes + this.envelope.triggerAttack(time, velocity); + //start the noise + this.noise.start(time); + if (this.envelope.sustain === 0) { + this.noise.stop(time = this.envelope.attack + this.envelope.decay); + } + return this; + }; + /** + * Start the release portion of the envelopes. + * @param {Time} [time=now] the time the release should start + * @returns {Tone.NoiseSynth} this + */ + Tone.NoiseSynth.prototype.triggerRelease = function (time) { + this.envelope.triggerRelease(time); + this.noise.stop(time + this.envelope.release); + return this; + }; + /** + * Sync the instrument to the Transport. All subsequent calls of + * [triggerAttack](#triggerattack) and [triggerRelease](#triggerrelease) + * will be scheduled along the transport. + * @example + * synth.sync() + * //schedule 3 notes when the transport first starts + * synth.triggerAttackRelease('8n', 0) + * synth.triggerAttackRelease('8n', '8n') + * synth.triggerAttackRelease('8n', '4n') + * //start the transport to hear the notes + * Transport.start() + * @returns {Tone.Instrument} this + */ + Tone.NoiseSynth.prototype.sync = function () { + this._syncMethod('triggerAttack', 0); + this._syncMethod('triggerRelease', 0); + return this; + }; + /** + * Trigger the attack and then the release. + * @param {Time} duration the duration of the note + * @param {Time} [time=now] the time of the attack + * @param {number} [velocity=1] the velocity + * @returns {Tone.NoiseSynth} this + */ + Tone.NoiseSynth.prototype.triggerAttackRelease = function (duration, time, velocity) { + time = this.toSeconds(time); + duration = this.toSeconds(duration); + this.triggerAttack(time, velocity); + this.triggerRelease(time + duration); + return this; + }; + /** + * Clean up. + * @returns {Tone.NoiseSynth} this + */ + Tone.NoiseSynth.prototype.dispose = function () { + Tone.Instrument.prototype.dispose.call(this); + this._writable([ + 'noise', + 'envelope' + ]); + this.noise.dispose(); + this.noise = null; + this.envelope.dispose(); + this.envelope = null; + return this; + }; + return Tone.NoiseSynth; + }); + Module(function (Tone) { + + /** + * @class Karplus-String string synthesis. Often out of tune. + * Will change when the AudioWorkerNode is available across + * browsers. + * + * @constructor + * @extends {Tone.Instrument} + * @param {Object} [options] see the defaults + * @example + * var plucky = new Tone.PluckSynth().toMaster(); + * plucky.triggerAttack("C4"); + */ + Tone.PluckSynth = function (options) { + options = Tone.defaultArg(options, Tone.PluckSynth.defaults); + Tone.Instrument.call(this, options); + /** + * @type {Tone.Noise} + * @private + */ + this._noise = new Tone.Noise('pink'); + /** + * The amount of noise at the attack. + * Nominal range of [0.1, 20] + * @type {number} + */ + this.attackNoise = options.attackNoise; + /** + * the LFCF + * @type {Tone.LowpassCombFilter} + * @private + */ + this._lfcf = new Tone.LowpassCombFilter({ + 'resonance': options.resonance, + 'dampening': options.dampening + }); + /** + * The resonance control. + * @type {NormalRange} + * @signal + */ + this.resonance = this._lfcf.resonance; + /** + * The dampening control. i.e. the lowpass filter frequency of the comb filter + * @type {Frequency} + * @signal + */ + this.dampening = this._lfcf.dampening; + //connections + this._noise.connect(this._lfcf); + this._lfcf.connect(this.output); + this._readOnly([ + 'resonance', + 'dampening' + ]); + }; + Tone.extend(Tone.PluckSynth, Tone.Instrument); + /** + * @static + * @const + * @type {Object} + */ + Tone.PluckSynth.defaults = { + 'attackNoise': 1, + 'dampening': 4000, + 'resonance': 0.7 + }; + /** + * Trigger the note. + * @param {Frequency} note The note to trigger. + * @param {Time} [time=now] When the note should be triggered. + * @returns {Tone.PluckSynth} this + */ + Tone.PluckSynth.prototype.triggerAttack = function (note, time) { + note = this.toFrequency(note); + time = this.toSeconds(time); + var delayAmount = 1 / note; + this._lfcf.delayTime.setValueAtTime(delayAmount, time); + this._noise.start(time); + this._noise.stop(time + delayAmount * this.attackNoise); + return this; + }; + /** + * Clean up. + * @returns {Tone.PluckSynth} this + */ + Tone.PluckSynth.prototype.dispose = function () { + Tone.Instrument.prototype.dispose.call(this); + this._noise.dispose(); + this._lfcf.dispose(); + this._noise = null; + this._lfcf = null; + this._writable([ + 'resonance', + 'dampening' + ]); + this.dampening = null; + this.resonance = null; + return this; + }; + return Tone.PluckSynth; + }); + Module(function (Tone) { + + /** + * @class Tone.PolySynth handles voice creation and allocation for any + * instruments passed in as the second paramter. PolySynth is + * not a synthesizer by itself, it merely manages voices of + * one of the other types of synths, allowing any of the + * monophonic synthesizers to be polyphonic. + * + * @constructor + * @extends {Tone.Instrument} + * @param {number|Object} [polyphony=4] The number of voices to create + * @param {function} [voice=Tone.Synth] The constructor of the voices + * uses Tone.Synth by default. + * @example + * //a polysynth composed of 6 Voices of Synth + * var synth = new Tone.PolySynth(6, Tone.Synth).toMaster(); + * //set the attributes using the set interface + * synth.set("detune", -1200); + * //play a chord + * synth.triggerAttackRelease(["C4", "E4", "A4"], "4n"); + */ + Tone.PolySynth = function () { + var options = Tone.defaults(arguments, [ + 'polyphony', + 'voice' + ], Tone.PolySynth); + Tone.Instrument.call(this, options); + options = Tone.defaultArg(options, Tone.Instrument.defaults); + //max polyphony + options.polyphony = Math.min(Tone.PolySynth.MAX_POLYPHONY, options.polyphony); + /** + * the array of voices + * @type {Array} + */ + this.voices = new Array(options.polyphony); + /** + * The queue of voices with data about last trigger + * and the triggered note + * @private + * @type {Array} + */ + this._triggers = new Array(options.polyphony); + /** + * The detune in cents + * @type {Cents} + * @signal + */ + this.detune = new Tone.Signal(options.detune, Tone.Type.Cents); + this._readOnly('detune'); + //create the voices + for (var i = 0; i < options.polyphony; i++) { + var v = new options.voice(arguments[2], arguments[3]); + if (!(v instanceof Tone.Monophonic)) { + throw new Error('Synth constructor must be instance of Tone.Monophonic'); + } + this.voices[i] = v; + v.connect(this.output); + if (v.hasOwnProperty('detune')) { + this.detune.connect(v.detune); + } + this._triggers[i] = { + release: -1, + note: null, + voice: v + }; + } + }; + Tone.extend(Tone.PolySynth, Tone.Instrument); + /** + * the defaults + * @const + * @static + * @type {Object} + */ + Tone.PolySynth.defaults = { + 'polyphony': 4, + 'volume': 0, + 'detune': 0, + 'voice': Tone.Synth + }; + /** + * Trigger the attack portion of the note + * @param {Frequency|Array} notes The notes to play. Accepts a single + * Frequency or an array of frequencies. + * @param {Time} [time=now] The start time of the note. + * @param {number} [velocity=1] The velocity of the note. + * @returns {Tone.PolySynth} this + * @example + * //trigger a chord immediately with a velocity of 0.2 + * poly.triggerAttack(["Ab3", "C4", "F5"], undefined, 0.2); + */ + Tone.PolySynth.prototype.triggerAttack = function (notes, time, velocity) { + if (!Array.isArray(notes)) { + notes = [notes]; + } + time = this.toSeconds(time); + for (var i = 0; i < notes.length; i++) { + var val = notes[i]; + //trigger the oldest voice + var oldest = this._triggers[0]; + for (var j = 1; j < this._triggers.length; j++) { + if (this._triggers[j].release < oldest.release) { + oldest = this._triggers[j]; + } + } + oldest.release = Infinity; + oldest.note = JSON.stringify(val); + oldest.voice.triggerAttack(val, time, velocity); + } + return this; + }; + /** + * Trigger the attack and release after the specified duration + * + * @param {Frequency|Array} notes The notes to play. Accepts a single + * Frequency or an array of frequencies. + * @param {Time} duration the duration of the note + * @param {Time} [time=now] if no time is given, defaults to now + * @param {number} [velocity=1] the velocity of the attack (0-1) + * @returns {Tone.PolySynth} this + * @example + * //trigger a chord for a duration of a half note + * poly.triggerAttackRelease(["Eb3", "G4", "C5"], "2n"); + * @example + * //can pass in an array of durations as well + * poly.triggerAttackRelease(["Eb3", "G4", "C5"], ["2n", "4n", "4n"]); + */ + Tone.PolySynth.prototype.triggerAttackRelease = function (notes, duration, time, velocity) { + time = this.toSeconds(time); + this.triggerAttack(notes, time, velocity); + if (Tone.isArray(duration) && Tone.isArray(notes)) { + for (var i = 0; i < notes.length; i++) { + var d = duration[Math.min(i, duration.length - 1)]; + this.triggerRelease(notes[i], time + this.toSeconds(d)); + } + } else { + this.triggerRelease(notes, time + this.toSeconds(duration)); + } + return this; + }; + /** + * Trigger the release of the note. Unlike monophonic instruments, + * a note (or array of notes) needs to be passed in as the first argument. + * @param {Frequency|Array} notes The notes to play. Accepts a single + * Frequency or an array of frequencies. + * @param {Time} [time=now] When the release will be triggered. + * @returns {Tone.PolySynth} this + * @example + * poly.triggerRelease(["Ab3", "C4", "F5"], "+2n"); + */ + Tone.PolySynth.prototype.triggerRelease = function (notes, time) { + if (!Array.isArray(notes)) { + notes = [notes]; + } + time = this.toSeconds(time); + for (var i = 0; i < notes.length; i++) { + //get the voice + var stringified = JSON.stringify(notes[i]); + for (var v = 0; v < this._triggers.length; v++) { + var desc = this._triggers[v]; + if (desc.note === stringified && desc.release > time) { + desc.voice.triggerRelease(time); + desc.release = time; + } + } + } + return this; + }; + /** + * Sync the instrument to the Transport. All subsequent calls of + * [triggerAttack](#triggerattack) and [triggerRelease](#triggerrelease) + * will be scheduled along the transport. + * @example + * synth.sync() + * //schedule 3 notes when the transport first starts + * synth.triggerAttackRelease('8n', 0) + * synth.triggerAttackRelease('8n', '8n') + * synth.triggerAttackRelease('8n', '4n') + * //start the transport to hear the notes + * Transport.start() + * @returns {Tone.Instrument} this + */ + Tone.PolySynth.prototype.sync = function () { + this._syncMethod('triggerAttack', 1); + this._syncMethod('triggerRelease', 1); + return this; + }; + /** + * Set a member/attribute of the voices. + * @param {Object|string} params + * @param {number=} value + * @param {Time=} rampTime + * @returns {Tone.PolySynth} this + * @example + * poly.set({ + * "filter" : { + * "type" : "highpass" + * }, + * "envelope" : { + * "attack" : 0.25 + * } + * }); + */ + Tone.PolySynth.prototype.set = function (params, value, rampTime) { + for (var i = 0; i < this.voices.length; i++) { + this.voices[i].set(params, value, rampTime); + } + return this; + }; + /** + * Get the synth's attributes. Given no arguments get + * will return all available object properties and their corresponding + * values. Pass in a single attribute to retrieve or an array + * of attributes. The attribute strings can also include a "." + * to access deeper properties. + * @param {Array=} params the parameters to get, otherwise will return + * all available. + */ + Tone.PolySynth.prototype.get = function (params) { + return this.voices[0].get(params); + }; + /** + * Trigger the release portion of all the currently active voices. + * @param {Time} [time=now] When the notes should be released. + * @return {Tone.PolySynth} this + */ + Tone.PolySynth.prototype.releaseAll = function (time) { + time = this.toSeconds(time); + for (var i = 0; i < this._triggers.length; i++) { + var desc = this._triggers[i]; + if (desc.release > time) { + desc.release = time; + desc.voice.triggerRelease(time); + } + } + return this; + }; + /** + * Clean up. + * @returns {Tone.PolySynth} this + */ + Tone.PolySynth.prototype.dispose = function () { + Tone.Instrument.prototype.dispose.call(this); + for (var i = 0; i < this.voices.length; i++) { + this.voices[i].dispose(); + this.voices[i] = null; + } + this._writable('detune'); + this.detune.dispose(); + this.detune = null; + this.voices = null; + this._triggers = null; + return this; + }; + /** + * The maximum number of notes that can be allocated + * to a polysynth. + * @type {Number} + * @static + */ + Tone.PolySynth.MAX_POLYPHONY = 20; + return Tone.PolySynth; + }); + Module(function (Tone) { + /** + * @class Automatically interpolates between a set of pitched samples. Pass in an object which maps the note's pitch or midi value to the url, then you can trigger the attack and release of that note like other instruments. By automatically repitching the samples, it is possible to play pitches which were not explicitly included which can save loading time. + * For sample or buffer playback where repitching is not necessary, use [Tone.Player](https://tonejs.github.io/docs/Player). + * @param {Object} samples An object of samples mapping either Midi + * Note Numbers or Scientific Pitch Notation + * to the url of that sample. + * @param {Function=} onload The callback to invoke when all of the samples are loaded. + * @param {String=} baseUrl The root URL of all of the samples, which is prepended to all the URLs. + * @example + * var sampler = new Tone.Sampler({ + * "C3" : "path/to/C3.mp3", + * "D#3" : "path/to/Dsharp3.mp3", + * "F#3" : "path/to/Fsharp3.mp3", + * "A3" : "path/to/A3.mp3", + * }, function(){ + * //sampler will repitch the closest sample + * sampler.triggerAttack("D3") + * }) + * @extends {Tone.Instrument} + */ + Tone.Sampler = function (urls) { + // shift arguments over one. Those are the remainder of the options + var args = Array.prototype.slice.call(arguments); + args.shift(); + var options = Tone.defaults(args, [ + 'onload', + 'baseUrl' + ], Tone.Sampler); + Tone.Instrument.call(this, options); + var urlMap = {}; + for (var note in urls) { + if (Tone.isNote(note)) { + //convert the note name to MIDI + var mid = Tone.Frequency(note).toMidi(); + urlMap[mid] = urls[note]; + } else if (!isNaN(parseFloat(note))) { + //otherwise if it's numbers assume it's midi + urlMap[note] = urls[note]; + } else { + throw new Error('Tone.Sampler: url keys must be the note\'s pitch'); + } + } + /** + * The stored and loaded buffers + * @type {Tone.Buffers} + * @private + */ + this._buffers = new Tone.Buffers(urlMap, options.onload, options.baseUrl); + /** + * The object of all currently playing BufferSources + * @type {Object} + * @private + */ + this._activeSources = {}; + /** + * The envelope applied to the beginning of the sample. + * @type {Time} + */ + this.attack = options.attack; + /** + * The envelope applied to the end of the envelope. + * @type {Time} + */ + this.release = options.release; + }; + Tone.extend(Tone.Sampler, Tone.Instrument); + /** + * The defaults + * @const + * @type {Object} + */ + Tone.Sampler.defaults = { + attack: 0, + release: 0.1, + onload: Tone.noOp, + baseUrl: '' + }; + /** + * Returns the difference in steps between the given midi note at the closets sample. + * @param {Midi} midi + * @return {Interval} + * @private + */ + Tone.Sampler.prototype._findClosest = function (midi) { + //searches within 8 octaves of the given midi note + var MAX_INTERVAL = 96; + var interval = 0; + while (interval < MAX_INTERVAL) { + // check above and below + if (this._buffers.has(midi + interval)) { + return -interval; + } else if (this._buffers.has(midi - interval)) { + return interval; + } + interval++; + } + return null; + }; + /** + * @param {Frequency} note The note to play + * @param {Time=} time When to play the note + * @param {NormalRange=} velocity The velocity to play the sample back. + * @return {Tone.Sampler} this + */ + Tone.Sampler.prototype.triggerAttack = function (note, time, velocity) { + var midi = Tone.Frequency(note).toMidi(); + // find the closest note pitch + var difference = this._findClosest(midi); + if (difference !== null) { + var closestNote = midi - difference; + var buffer = this._buffers.get(closestNote); + // play that note + var source = new Tone.BufferSource({ + 'buffer': buffer, + 'playbackRate': Tone.intervalToFrequencyRatio(difference), + 'fadeIn': this.attack, + 'fadeOut': this.release, + 'curve': 'exponential' + }).connect(this.output); + source.start(time, 0, buffer.duration, velocity); + // add it to the active sources + if (!Tone.isArray(this._activeSources[midi])) { + this._activeSources[midi] = []; + } + this._activeSources[midi].push({ + note: midi, + source: source + }); + } + return this; + }; + /** + * @param {Frequency} note The note to release. + * @param {Time=} time When to release the note. + * @return {Tone.Sampler} this + */ + Tone.Sampler.prototype.triggerRelease = function (note, time) { + var midi = Tone.Frequency(note).toMidi(); + // find the note + if (this._activeSources[midi] && this._activeSources[midi].length) { + var source = this._activeSources[midi].shift().source; + time = this.toSeconds(time); + source.stop(time + this.release, this.release); + } + return this; + }; + /** + * Release all currently active notes. + * @param {Time=} time When to release the notes. + * @return {Tone.Sampler} this + */ + Tone.Sampler.prototype.releaseAll = function (time) { + time = this.toSeconds(time); + for (var note in this._activeSources) { + var sources = this._activeSources[note]; + while (sources.length) { + var source = sources.shift().source; + source.stop(time + this.release, this.release); + } + } + return this; + }; + /** + * Sync the instrument to the Transport. All subsequent calls of + * [triggerAttack](#triggerattack) and [triggerRelease](#triggerrelease) + * will be scheduled along the transport. + * @example + * synth.sync() + * //schedule 3 notes when the transport first starts + * synth.triggerAttackRelease('8n', 0) + * synth.triggerAttackRelease('8n', '8n') + * synth.triggerAttackRelease('8n', '4n') + * //start the transport to hear the notes + * Transport.start() + * @returns {Tone.Instrument} this + */ + Tone.Sampler.prototype.sync = function () { + this._syncMethod('triggerAttack', 1); + this._syncMethod('triggerRelease', 1); + return this; + }; + /** + * Invoke the attack phase, then after the duration, invoke the release. + * @param {Frequency} note The note to play + * @param {Time} duration The time the note should be held + * @param {Time=} time When to start the attack + * @param {NormalRange} [velocity=1] The velocity of the attack + * @return {Tone.Sampler} this + */ + Tone.Sampler.prototype.triggerAttackRelease = function (note, duration, time, velocity) { + time = this.toSeconds(time); + duration = this.toSeconds(duration); + this.triggerAttack(note, time, velocity); + this.triggerRelease(note, time + duration); + return this; + }; + /** + * Add a note to the sampler. + * @param {Note|Midi} note The buffer's pitch. + * @param {String|Tone.Buffer|Audiobuffer} url Either the url of the bufer, + * or a buffer which will be added + * with the given name. + * @param {Function=} callback The callback to invoke + * when the url is loaded. + */ + Tone.Sampler.prototype.add = function (note, url, callback) { + if (Tone.isNote(note)) { + //convert the note name to MIDI + var mid = Tone.Frequency(note).toMidi(); + this._buffers.add(mid, url, callback); + } else if (!isNaN(parseFloat(note))) { + //otherwise if it's numbers assume it's midi + this._buffers.add(note, url, callback); + } else { + throw new Error('Tone.Sampler: note must be the note\'s pitch. Instead got ' + note); + } + }; + /** + * If the buffers are loaded or not + * @memberOf Tone.Sampler# + * @type {Boolean} + * @name loaded + * @readOnly + */ + Object.defineProperty(Tone.Sampler.prototype, 'loaded', { + get: function () { + return this._buffers.loaded; + } + }); + /** + * Clean up + * @return {Tone.Sampler} this + */ + Tone.Sampler.prototype.dispose = function () { + Tone.Instrument.prototype.dispose.call(this); + this._buffers.dispose(); + this._buffers = null; + for (var midi in this._activeSources) { + this._activeSources[midi].forEach(function (event) { + event.source.dispose(); + }); + } + this._activeSources = null; + return this; + }; + return Tone.Sampler; + }); + Module(function (Tone) { + if (Tone.supported) { + if (!OscillatorNode.prototype.setPeriodicWave) { + OscillatorNode.prototype.setPeriodicWave = OscillatorNode.prototype.setWaveTable; + } + if (!AudioContext.prototype.createPeriodicWave) { + AudioContext.prototype.createPeriodicWave = AudioContext.prototype.createWaveTable; + } + } + }); + Module(function (Tone) { + + /** + * @class Maps a NormalRange [0, 1] to an AudioRange [-1, 1]. + * See also Tone.AudioToGain. + * + * @extends {Tone.SignalBase} + * @constructor + * @example + * var g2a = new Tone.GainToAudio(); + */ + Tone.GainToAudio = function () { + Tone.SignalBase.call(this); + /** + * @type {WaveShaperNode} + * @private + */ + this._norm = this.input = this.output = new Tone.WaveShaper(function (x) { + return Math.abs(x) * 2 - 1; + }); + }; + Tone.extend(Tone.GainToAudio, Tone.SignalBase); + /** + * clean up + * @returns {Tone.GainToAudio} this + */ + Tone.GainToAudio.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._norm.dispose(); + this._norm = null; + return this; + }; + return Tone.GainToAudio; + }); + Module(function (Tone) { + + /** + * @class Normalize takes an input min and max and maps it linearly to NormalRange [0,1] + * + * @extends {Tone.SignalBase} + * @constructor + * @param {number} inputMin the min input value + * @param {number} inputMax the max input value + * @example + * var norm = new Tone.Normalize(2, 4); + * var sig = new Tone.Signal(3).connect(norm); + * //output of norm is 0.5. + */ + Tone.Normalize = function (inputMin, inputMax) { + Tone.SignalBase.call(this); + /** + * the min input value + * @type {number} + * @private + */ + this._inputMin = Tone.defaultArg(inputMin, 0); + /** + * the max input value + * @type {number} + * @private + */ + this._inputMax = Tone.defaultArg(inputMax, 1); + /** + * subtract the min from the input + * @type {Tone.Add} + * @private + */ + this._sub = this.input = new Tone.Add(0); + /** + * divide by the difference between the input and output + * @type {Tone.Multiply} + * @private + */ + this._div = this.output = new Tone.Multiply(1); + this._sub.connect(this._div); + this._setRange(); + }; + Tone.extend(Tone.Normalize, Tone.SignalBase); + /** + * The minimum value the input signal will reach. + * @memberOf Tone.Normalize# + * @type {number} + * @name min + */ + Object.defineProperty(Tone.Normalize.prototype, 'min', { + get: function () { + return this._inputMin; + }, + set: function (min) { + this._inputMin = min; + this._setRange(); + } + }); + /** + * The maximum value the input signal will reach. + * @memberOf Tone.Normalize# + * @type {number} + * @name max + */ + Object.defineProperty(Tone.Normalize.prototype, 'max', { + get: function () { + return this._inputMax; + }, + set: function (max) { + this._inputMax = max; + this._setRange(); + } + }); + /** + * set the values + * @private + */ + Tone.Normalize.prototype._setRange = function () { + this._sub.value = -this._inputMin; + this._div.value = 1 / (this._inputMax - this._inputMin); + }; + /** + * clean up + * @returns {Tone.Normalize} this + */ + Tone.Normalize.prototype.dispose = function () { + Tone.SignalBase.prototype.dispose.call(this); + this._sub.dispose(); + this._sub = null; + this._div.dispose(); + this._div = null; + return this; + }; + return Tone.Normalize; + }); + Module(function (Tone) { + /** + * @class Tone.TransportTimelineSignal extends Tone.Signal, but adds the ability to synchronize the signal to the signal to the Tone.Transport + * @extends {Tone.Signal} + */ + Tone.TransportTimelineSignal = function () { + Tone.Signal.apply(this, arguments); + /** + * The real signal output + * @type {Tone.Signal} + * @private + */ + this.output = this._outputSig = new Tone.Signal(this._initialValue); + /** + * Keep track of the last value. (small optimization) + * @private + * @type {Number} + */ + this._lastVal = this.value; + /** + * The event id of the tick update loop + * @private + * @type {Number} + */ + this._synced = Tone.Transport.scheduleRepeat(this._onTick.bind(this), '1i'); + /** + * A bound version of the anchor value methods + * @type {Function} + * @private + */ + this._bindAnchorValue = this._anchorValue.bind(this); + Tone.Transport.on('start stop pause', this._bindAnchorValue); + this._events.memory = Infinity; + }; + Tone.extend(Tone.TransportTimelineSignal, Tone.Signal); + /** + * Callback which is invoked every tick. + * @private + * @param {Number} time + * @return {Tone.TransportTimelineSignal} this + */ + Tone.TransportTimelineSignal.prototype._onTick = function (time) { + var val = this.getValueAtTime(Tone.Transport.seconds); + if (this._lastVal !== val) { + this._lastVal = val; + //approximate ramp curves with linear ramps + this._outputSig.linearRampToValueAtTime(val, time); + } + }; + /** + * Anchor the value at the start and stop of the Transport + * @param {Number} time The time of the event + * @return {Tone.TransportTimelineSignal} this + * @private + */ + Tone.TransportTimelineSignal.prototype._anchorValue = function (time) { + var val = this.getValueAtTime(Tone.Transport.seconds); + this._lastVal = val; + this._outputSig.cancelScheduledValues(time); + this._outputSig.setValueAtTime(val, time); + return this; + }; + /** + * Get the scheduled value at the given time. This will + * return the unconverted (raw) value. + * @param {TransportTime} time The time in seconds. + * @return {Number} The scheduled value at the given time. + */ + Tone.TransportTimelineSignal.prototype.getValueAtTime = function (time) { + time = Tone.TransportTime(time); + return Tone.Signal.prototype.getValueAtTime.call(this, time); + }; + /** + * Set the output of the signal at the given time + * @param {Number} value The value to change to at the given time + * @param {TransportTime} time The time to change the signal + * @return {Tone.TransportTimelineSignal} this + */ + Tone.TransportTimelineSignal.prototype.setValueAtTime = function (value, time) { + time = Tone.TransportTime(time); + Tone.Signal.prototype.setValueAtTime.call(this, value, time); + return this; + }; + /** + * Linear ramp to the given value from the previous scheduled point to the given value + * @param {Number} value The value to change to at the given time + * @param {TransportTime} time The time to change the signal + * @return {Tone.TransportTimelineSignal} this + */ + Tone.TransportTimelineSignal.prototype.linearRampToValueAtTime = function (value, time) { + time = Tone.TransportTime(time); + Tone.Signal.prototype.linearRampToValueAtTime.call(this, value, time); + return this; + }; + /** + * Exponential ramp to the given value from the previous scheduled point to the given value + * @param {Number} value The value to change to at the given time + * @param {TransportTime} time The time to change the signal + * @return {Tone.TransportTimelineSignal} this + */ + Tone.TransportTimelineSignal.prototype.exponentialRampToValueAtTime = function (value, time) { + time = Tone.TransportTime(time); + Tone.Signal.prototype.exponentialRampToValueAtTime.call(this, value, time); + return this; + }; + /** + * Start exponentially approaching the target value at the given time with + * a rate having the given time constant. + * @param {number} value + * @param {TransportTime} startTime + * @param {number} timeConstant + * @return {Tone.TransportTimelineSignal} this + */ + Tone.TransportTimelineSignal.prototype.setTargetAtTime = function (value, startTime, timeConstant) { + startTime = Tone.TransportTime(startTime); + Tone.Signal.prototype.setTargetAtTime.call(this, value, startTime, timeConstant); + return this; + }; + /** + * Cancels all scheduled parameter changes with times greater than or + * equal to startTime. + * @param {TransportTime} startTime + * @returns {Tone.Param} this + */ + Tone.TransportTimelineSignal.prototype.cancelScheduledValues = function (startTime) { + startTime = Tone.TransportTime(startTime); + Tone.Signal.prototype.cancelScheduledValues.call(this, startTime); + return this; + }; + /** + * Set an array of arbitrary values starting at the given time for the given duration. + * @param {Float32Array} values + * @param {Time} startTime + * @param {Time} duration + * @param {NormalRange} [scaling=1] If the values in the curve should be scaled by some value + * @returns {Tone.Signal} this + */ + Tone.TransportTimelineSignal.prototype.setValueCurveAtTime = function (values, startTime, duration, scaling) { + startTime = Tone.TransportTime(startTime); + duration = Tone.TransportTime(duration); + Tone.Signal.prototype.setValueCurveAtTime.call(this, values, startTime, duration, scaling); + return this; + }; + /** + * This is similar to [cancelScheduledValues](#cancelScheduledValues) except + * it holds the automated value at time until the next automated event. + * @param {Time} time + * @returns {Tone.TransportTimelineSignal} this + */ + Tone.TransportTimelineSignal.prototype.cancelAndHoldAtTime = function (time) { + return Tone.Signal.prototype.cancelAndHoldAtTime.call(this, Tone.TransportTime(time)); + }; + /** + * Dispose and disconnect + * @return {Tone.TransportTimelineSignal} this + */ + Tone.TransportTimelineSignal.prototype.dispose = function () { + Tone.Transport.clear(this._synced); + Tone.Transport.off('start stop pause', this._syncedCallback); + this._events.cancel(0); + Tone.Signal.prototype.dispose.call(this); + this._outputSig.dispose(); + this._outputSig = null; + }; + return Tone.TransportTimelineSignal; + }); + Module(function (Tone) { + /** + * @class Tone.GrainPlayer implements [granular synthesis](https://en.wikipedia.org/wiki/Granular_synthesis). + * Granular Synthesis enables you to adjust pitch and playback rate independently. The grainSize is the + * amount of time each small chunk of audio is played for and the overlap is the + * amount of crossfading transition time between successive grains. + * @extends {Tone.Source} + * @param {String|Tone.Buffer} url The url to load, or the Tone.Buffer to play. + * @param {Function=} callback The callback to invoke after the url is loaded. + */ + Tone.GrainPlayer = function () { + var options = Tone.defaults(arguments, [ + 'url', + 'onload' + ], Tone.GrainPlayer); + Tone.Source.call(this, options); + /** + * The audio buffer belonging to the player. + * @type {Tone.Buffer} + */ + this.buffer = new Tone.Buffer(options.url, options.onload); + /** + * Create a repeating tick to schedule + * the grains. + * @type {Tone.Clock} + * @private + */ + this._clock = new Tone.Clock(this._tick.bind(this), options.grainSize); + /** + * @type {Number} + * @private + */ + this._loopStart = 0; + /** + * @type {Number} + * @private + */ + this._loopEnd = 0; + /** + * All of the currently playing BufferSources + * @type {Array} + * @private + */ + this._activeSources = []; + /** + * @type {Number} + * @private + */ + this._playbackRate = options.playbackRate; + /** + * @type {Number} + * @private + */ + this._grainSize = options.grainSize; + /** + * @private + * @type {Number} + */ + this._overlap = options.overlap; + /** + * Adjust the pitch independently of the playbackRate. + * @type {Cents} + */ + this.detune = options.detune; + //setup + this.overlap = options.overlap; + this.loop = options.loop; + this.playbackRate = options.playbackRate; + this.grainSize = options.grainSize; + this.loopStart = options.loopStart; + this.loopEnd = options.loopEnd; + this.reverse = options.reverse; + this._clock.on('stop', this._onstop.bind(this)); + }; + Tone.extend(Tone.GrainPlayer, Tone.Source); + /** + * the default parameters + * @static + * @const + * @type {Object} + */ + Tone.GrainPlayer.defaults = { + 'onload': Tone.noOp, + 'overlap': 0.1, + 'grainSize': 0.2, + 'playbackRate': 1, + 'detune': 0, + 'loop': false, + 'loopStart': 0, + 'loopEnd': 0, + 'reverse': false + }; + /** + * Play the buffer at the given startTime. Optionally add an offset + * and/or duration which will play the buffer from a position + * within the buffer for the given duration. + * + * @param {Time} [startTime=now] When the player should start. + * @param {Time} [offset=0] The offset from the beginning of the sample + * to start at. + * @param {Time=} duration How long the sample should play. If no duration + * is given, it will default to the full length + * of the sample (minus any offset) + * @returns {Tone.GrainPlayer} this + * @memberOf Tone.GrainPlayer# + * @method start + * @name start + */ + /** + * Internal start method + * @param {Time} time + * @param {Time} offset + * @private + */ + Tone.GrainPlayer.prototype._start = function (time, offset, duration) { + offset = Tone.defaultArg(offset, 0); + offset = this.toSeconds(offset); + time = this.toSeconds(time); + this._offset = offset; + this._clock.start(time); + if (duration) { + this.stop(time + this.toSeconds(duration)); + } + }; + /** + * Internal start method + * @param {Time} time + * @private + */ + Tone.GrainPlayer.prototype._stop = function (time) { + this._clock.stop(time); + }; + /** + * Invoked when the clock is stopped + * @param {Number} time + * @private + */ + Tone.GrainPlayer.prototype._onstop = function (time) { + //stop the players + this._activeSources.forEach(function (source) { + source.stop(time, 0); + }); + }; + /** + * Invoked on each clock tick. scheduled a new + * grain at this time. + * @param {Time} time + * @private + */ + Tone.GrainPlayer.prototype._tick = function (time) { + var fadeIn = this._offset < this._overlap ? 0 : this._overlap; + var source = new Tone.BufferSource({ + 'buffer': this.buffer, + 'fadeIn': fadeIn, + 'fadeOut': this._overlap, + 'loop': this.loop, + 'loopStart': this._loopStart, + 'loopEnd': this._loopEnd, + 'playbackRate': Tone.intervalToFrequencyRatio(this.detune / 100) + }).connect(this.output); + source.start(time, this._offset); + this._offset += this.grainSize; + source.stop(time + this.grainSize); + //add it to the active sources + this._activeSources.push(source); + //remove it when it's done + source.onended = function () { + var index = this._activeSources.indexOf(source); + if (index !== -1) { + this._activeSources.splice(index, 1); + } + }.bind(this); + }; + /** + * Jump to a specific time and play it. + * @param {Time} offset The offset to jump to. + * @param {Time=} time When to make the jump. + * @return {Tone.GrainPlayer} this + */ + Tone.GrainPlayer.prototype.seek = function (offset, time) { + this._offset = this.toSeconds(offset); + this._tick(this.toSeconds(time)); + return this; + }; + /** + * The playback rate of the sample + * @memberOf Tone.GrainPlayer# + * @type {Positive} + * @name playbackRate + */ + Object.defineProperty(Tone.GrainPlayer.prototype, 'playbackRate', { + get: function () { + return this._playbackRate; + }, + set: function (rate) { + this._playbackRate = rate; + this.grainSize = this._grainSize; + } + }); + /** + * The loop start time. + * @memberOf Tone.GrainPlayer# + * @type {Time} + * @name loopStart + */ + Object.defineProperty(Tone.GrainPlayer.prototype, 'loopStart', { + get: function () { + return this._loopStart; + }, + set: function (time) { + this._loopStart = this.toSeconds(time); + } + }); + /** + * The loop end time. + * @memberOf Tone.GrainPlayer# + * @type {Time} + * @name loopEnd + */ + Object.defineProperty(Tone.GrainPlayer.prototype, 'loopEnd', { + get: function () { + return this._loopEnd; + }, + set: function (time) { + this._loopEnd = this.toSeconds(time); + } + }); + /** + * The direction the buffer should play in + * @memberOf Tone.GrainPlayer# + * @type {boolean} + * @name reverse + */ + Object.defineProperty(Tone.GrainPlayer.prototype, 'reverse', { + get: function () { + return this.buffer.reverse; + }, + set: function (rev) { + this.buffer.reverse = rev; + } + }); + /** + * The size of each chunk of audio that the + * buffer is chopped into and played back at. + * @memberOf Tone.GrainPlayer# + * @type {Time} + * @name grainSize + */ + Object.defineProperty(Tone.GrainPlayer.prototype, 'grainSize', { + get: function () { + return this._grainSize; + }, + set: function (size) { + this._grainSize = this.toSeconds(size); + this._clock.frequency.value = this._playbackRate / this._grainSize; + } + }); + /** + * This is the duration of the cross-fade between + * sucessive grains. + * @memberOf Tone.GrainPlayer# + * @type {Time} + * @name overlap + */ + Object.defineProperty(Tone.GrainPlayer.prototype, 'overlap', { + get: function () { + return this._overlap; + }, + set: function (time) { + this._overlap = this.toSeconds(time); + } + }); + /** + * Clean up + * @return {Tone.GrainPlayer} this + */ + Tone.GrainPlayer.prototype.dispose = function () { + Tone.Source.prototype.dispose.call(this); + this.buffer.dispose(); + this.buffer = null; + this._clock.dispose(); + this._clock = null; + this._activeSources.forEach(function (source) { + source.dispose(); + }); + this._activeSources = null; + return this; + }; + return Tone.GrainPlayer; + }); + Module(function (Tone) { + + /** + * @class Tone.Player is an audio file player with start, loop, and stop functions. + * + * @constructor + * @extends {Tone.Source} + * @param {string|AudioBuffer} url Either the AudioBuffer or the url from + * which to load the AudioBuffer + * @param {Function=} onload The function to invoke when the buffer is loaded. + * Recommended to use Tone.Buffer.on('load') instead. + * @example + * var player = new Tone.Player("./path/to/sample.mp3").toMaster(); + * //play as soon as the buffer is loaded + * player.autostart = true; + */ + Tone.Player = function (url) { + var options; + if (url instanceof Tone.Buffer && url.loaded) { + url = url.get(); + options = Tone.Player.defaults; + } else { + options = Tone.defaults(arguments, [ + 'url', + 'onload' + ], Tone.Player); + } + Tone.Source.call(this, options); + /** + * If the file should play as soon + * as the buffer is loaded. + * @type {Boolean} + * @example + * //will play as soon as it's loaded + * var player = new Tone.Player({ + * "url" : "./path/to/sample.mp3", + * "autostart" : true, + * }).toMaster(); + */ + this.autostart = options.autostart; + /** + * the buffer + * @private + * @type {Tone.Buffer} + */ + this._buffer = new Tone.Buffer({ + 'url': options.url, + 'onload': this._onload.bind(this, options.onload), + 'reverse': options.reverse + }); + if (url instanceof AudioBuffer) { + this._buffer.set(url); + } + /** + * if the buffer should loop once it's over + * @type {Boolean} + * @private + */ + this._loop = options.loop; + /** + * if 'loop' is true, the loop will start at this position + * @type {Time} + * @private + */ + this._loopStart = options.loopStart; + /** + * if 'loop' is true, the loop will end at this position + * @type {Time} + * @private + */ + this._loopEnd = options.loopEnd; + /** + * the playback rate + * @private + * @type {Number} + */ + this._playbackRate = options.playbackRate; + /** + * All of the active buffer source nodes + * @type {Array<Tone.BufferSource>} + * @private + */ + this._activeSources = []; + /** + * The elapsed time counter. + * @type {Tone.TickSource} + * @private + */ + this._elapsedTime = new Tone.TickSource(options.playbackRate); + /** + * The fadeIn time of the amplitude envelope. + * @type {Time} + */ + this.fadeIn = options.fadeIn; + /** + * The fadeOut time of the amplitude envelope. + * @type {Time} + */ + this.fadeOut = options.fadeOut; + }; + Tone.extend(Tone.Player, Tone.Source); + /** + * the default parameters + * @static + * @const + * @type {Object} + */ + Tone.Player.defaults = { + 'onload': Tone.noOp, + 'playbackRate': 1, + 'loop': false, + 'autostart': false, + 'loopStart': 0, + 'loopEnd': 0, + 'retrigger': false, + 'reverse': false, + 'fadeIn': 0, + 'fadeOut': 0 + }; + /** + * Load the audio file as an audio buffer. + * Decodes the audio asynchronously and invokes + * the callback once the audio buffer loads. + * Note: this does not need to be called if a url + * was passed in to the constructor. Only use this + * if you want to manually load a new url. + * @param {string} url The url of the buffer to load. + * Filetype support depends on the + * browser. + * @param {Function=} callback The function to invoke once + * the sample is loaded. + * @returns {Promise} + */ + Tone.Player.prototype.load = function (url, callback) { + return this._buffer.load(url, this._onload.bind(this, callback)); + }; + /** + * Internal callback when the buffer is loaded. + * @private + */ + Tone.Player.prototype._onload = function (callback) { + callback = Tone.defaultArg(callback, Tone.noOp); + callback(this); + if (this.autostart) { + this.start(); + } + }; + /** + * Internal callback when the buffer is done playing. + * @private + */ + Tone.Player.prototype._onSourceEnd = function (source) { + var index = this._activeSources.indexOf(source); + this._activeSources.splice(index, 1); + }; + /** + * Play the buffer at the given startTime. Optionally add an offset + * and/or duration which will play the buffer from a position + * within the buffer for the given duration. + * + * @param {Time} [startTime=now] When the player should start. + * @param {Time} [offset=0] The offset from the beginning of the sample + * to start at. + * @param {Time=} duration How long the sample should play. If no duration + * is given, it will default to the full length + * of the sample (minus any offset) + * @returns {Tone.Player} this + * @memberOf Tone.Player# + * @method start + * @name start + */ + /** + * Internal start method + * @private + */ + Tone.Player.prototype._start = function (startTime, offset, duration) { + //if it's a loop the default offset is the loopstart point + if (this._loop) { + offset = Tone.defaultArg(offset, this._loopStart); + } else { + //otherwise the default offset is 0 + offset = Tone.defaultArg(offset, 0); + } + //compute the values in seconds + offset = this.toSeconds(offset); + var computedDuration = Tone.defaultArg(duration, Math.max(this._buffer.duration - offset, 0)); + computedDuration = this.toSeconds(computedDuration); + startTime = this.toSeconds(startTime); + //start the elapsed time counter + this._elapsedTime.start(startTime, offset); + //make the source + var source = new Tone.BufferSource({ + 'buffer': this._buffer, + 'loop': this._loop, + 'loopStart': this._loopStart, + 'loopEnd': this._loopEnd, + 'onended': this._onSourceEnd.bind(this), + 'playbackRate': this._playbackRate, + 'fadeIn': this.fadeIn, + 'fadeOut': this.fadeOut + }).connect(this.output); + //set the looping properties + if (!this._loop && !this._synced) { + //if it's not looping, set the state change at the end of the sample + this._state.setStateAtTime(Tone.State.Stopped, startTime + computedDuration / this._playbackRate); + } + //add it to the array of active sources + this._activeSources.push(source); + //start it + if (this._loop && Tone.isUndef(duration)) { + source.start(startTime, offset); + } else { + source.start(startTime, offset, computedDuration); + } + return this; + }; + /** + * Stop playback. + * @private + * @param {Time} [time=now] + * @returns {Tone.Player} this + */ + Tone.Player.prototype._stop = function (time) { + time = this.toSeconds(time); + this._elapsedTime.stop(time); + this._activeSources.forEach(function (source) { + source.stop(time); + }); + return this; + }; + /** + * Stop and then restart the player from the beginning (or offset) + * @param {Time} [startTime=now] When the player should start. + * @param {Time} [offset=0] The offset from the beginning of the sample + * to start at. + * @param {Time=} duration How long the sample should play. If no duration + * is given, it will default to the full length + * of the sample (minus any offset) + * @returns {Tone.Player} this + */ + Tone.Player.prototype.restart = function (time, offset, duration) { + this._stop(time); + this._start(time, offset, duration); + return this; + }; + /** + * Seek to a specific time in the player's buffer. If the + * source is no longer playing at that time, it will stop. + * If you seek to a time that + * @param {Time} offset The time to seek to. + * @param {Time=} time The time for the seek event to occur. + * @return {Tone.Player} this + * @example + * source.start(0.2); + * source.stop(0.4); + */ + Tone.Player.prototype.seek = function (offset, time) { + time = this.toSeconds(time); + if (this._state.getValueAtTime(time) === Tone.State.Started) { + offset = this.toSeconds(offset); + // if it's currently playing, stop it + this._stop(time); + //restart it at the given time + this._start(time, offset); + } + return this; + }; + /** + * Set the loop start and end. Will only loop if loop is + * set to true. + * @param {Time} loopStart The loop end time + * @param {Time} loopEnd The loop end time + * @returns {Tone.Player} this + * @example + * //loop 0.1 seconds of the file. + * player.setLoopPoints(0.2, 0.3); + * player.loop = true; + */ + Tone.Player.prototype.setLoopPoints = function (loopStart, loopEnd) { + this.loopStart = loopStart; + this.loopEnd = loopEnd; + return this; + }; + /** + * If loop is true, the loop will start at this position. + * @memberOf Tone.Player# + * @type {Time} + * @name loopStart + */ + Object.defineProperty(Tone.Player.prototype, 'loopStart', { + get: function () { + return this._loopStart; + }, + set: function (loopStart) { + this._loopStart = loopStart; + //get the current source + this._activeSources.forEach(function (source) { + source.loopStart = loopStart; + }); + } + }); + /** + * If loop is true, the loop will end at this position. + * @memberOf Tone.Player# + * @type {Time} + * @name loopEnd + */ + Object.defineProperty(Tone.Player.prototype, 'loopEnd', { + get: function () { + return this._loopEnd; + }, + set: function (loopEnd) { + this._loopEnd = loopEnd; + //get the current source + this._activeSources.forEach(function (source) { + source.loopEnd = loopEnd; + }); + } + }); + /** + * The audio buffer belonging to the player. + * @memberOf Tone.Player# + * @type {Tone.Buffer} + * @name buffer + */ + Object.defineProperty(Tone.Player.prototype, 'buffer', { + get: function () { + return this._buffer; + }, + set: function (buffer) { + this._buffer.set(buffer); + } + }); + /** + * If the buffer should loop once it's over. + * @memberOf Tone.Player# + * @type {Boolean} + * @name loop + */ + Object.defineProperty(Tone.Player.prototype, 'loop', { + get: function () { + return this._loop; + }, + set: function (loop) { + //if no change, do nothing + if (this._loop === loop) { + return; + } + this._loop = loop; + var now = this.now(); + if (!loop) { + //stop the playback on the next cycle + this._stopAtNextIteration(now); + } else { + //remove the next stopEvent + var stopEvent = this._state.getNextState(Tone.State.Stopped, now); + if (stopEvent) { + this._activeSources.forEach(function (source) { + source.loop = loop; + }); + this._state.cancel(stopEvent.time); + this._elapsedTime.cancel(stopEvent.time); + } + } + } + }); + /** + * Schedules a stop event at the next full iteration. Used + * for scheduling stop when the loop state or playbackRate changes + * @param {Number} now The current time + * @private + */ + Tone.Player.prototype._stopAtNextIteration = function (now) { + if (this._state.getValueAtTime(now) === Tone.State.Started) { + var nextStop = this._state.getNextState(Tone.State.Stopped, now); + var position = this._elapsedTime.getTicksAtTime(now); + var iterations = Math.max(Math.ceil(position / this.buffer.duration), 1); + var stopTime = this._elapsedTime.getTimeOfTick(iterations * this.buffer.duration, nextStop ? nextStop.time - this.sampleTime : Infinity); + this.stop(stopTime); + } + }; + /** + * The playback speed. 1 is normal speed. This is not a signal because + * Safari and iOS currently don't support playbackRate as a signal. + * @memberOf Tone.Player# + * @type {Number} + * @name playbackRate + */ + Object.defineProperty(Tone.Player.prototype, 'playbackRate', { + get: function () { + return this._playbackRate; + }, + set: function (rate) { + this._playbackRate = rate; + var now = this.now(); + this._elapsedTime.frequency.setValueAtTime(rate, now); + //if it's not looping + if (!this._loop) { + this._stopAtNextIteration(now); + } + //set all the sources + this._activeSources.forEach(function (source) { + source.playbackRate.setValueAtTime(rate, now); + }); + } + }); + /** + * The current playback position of the buffer. + * @memberOf Tone.Player# + * @type {Number} + * @name position + */ + Object.defineProperty(Tone.Player.prototype, 'position', { + get: function () { + var now = this.now(); + if (this._state.getValueAtTime(now) === Tone.State.Started && this.loaded) { + var duration = this.buffer.duration; + var position = this._elapsedTime.getTicksAtTime(now); + return position % duration; + } else { + return 0; + } + } + }); + /** + * The direction the buffer should play in + * @memberOf Tone.Player# + * @type {Boolean} + * @name reverse + */ + Object.defineProperty(Tone.Player.prototype, 'reverse', { + get: function () { + return this._buffer.reverse; + }, + set: function (rev) { + this._buffer.reverse = rev; + } + }); + /** + * If all the buffer is loaded + * @memberOf Tone.Player# + * @type {Boolean} + * @name loaded + * @readOnly + */ + Object.defineProperty(Tone.Player.prototype, 'loaded', { + get: function () { + return this._buffer.loaded; + } + }); + /** + * Dispose and disconnect. + * @return {Tone.Player} this + */ + Tone.Player.prototype.dispose = function () { + //disconnect all of the players + this._activeSources.forEach(function (source) { + source.dispose(); + }); + this._activeSources = null; + Tone.Source.prototype.dispose.call(this); + this._buffer.dispose(); + this._buffer = null; + this._elapsedTime.dispose(); + this._elapsedTime = null; + return this; + }; + return Tone.Player; + }); + Module(function (Tone) { + + /** + * @class Tone.Players combines multiple [Tone.Player](Player) objects. + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Object} urls An object mapping a name to a url. + * @param {function=} onload The function to invoke when all buffers are loaded. + */ + Tone.Players = function (urls) { + var args = Array.prototype.slice.call(arguments); + args.shift(); + var options = Tone.defaults(args, ['onload'], Tone.Players); + Tone.call(this); + /** + * The output volume node + * @type {Tone.Volume} + * @private + */ + this._volume = this.output = new Tone.Volume(options.volume); + /** + * The volume of the output in decibels. + * @type {Decibels} + * @signal + * @example + * source.volume.value = -6; + */ + this.volume = this._volume.volume; + this._readOnly('volume'); + //make the output explicitly stereo + this._volume.output.output.channelCount = 2; + this._volume.output.output.channelCountMode = 'explicit'; + //mute initially + this.mute = options.mute; + /** + * The container of all of the players + * @type {Object} + * @private + */ + this._players = {}; + /** + * The loading count + * @type {Number} + * @private + */ + this._loadingCount = 0; + /** + * private holder of the fadeIn time + * @type {Time} + * @private + */ + this._fadeIn = options.fadeIn; + /** + * private holder of the fadeOut time + * @type {Time} + * @private + */ + this._fadeOut = options.fadeOut; + //add all of the players + for (var name in urls) { + this._loadingCount++; + this.add(name, urls[name], this._bufferLoaded.bind(this, options.onload)); + } + }; + Tone.extend(Tone.Players, Tone.AudioNode); + /** + * The default values + * @type {Object} + */ + Tone.Players.defaults = { + 'volume': 0, + 'mute': false, + 'onload': Tone.noOp, + 'fadeIn': 0, + 'fadeOut': 0 + }; + /** + * A buffer was loaded. decrement the counter. + * @param {Function} callback + * @private + */ + Tone.Players.prototype._bufferLoaded = function (callback) { + this._loadingCount--; + if (this._loadingCount === 0 && callback) { + callback(this); + } + }; + /** + * Mute the output. + * @memberOf Tone.Source# + * @type {boolean} + * @name mute + * @example + * //mute the output + * source.mute = true; + */ + Object.defineProperty(Tone.Players.prototype, 'mute', { + get: function () { + return this._volume.mute; + }, + set: function (mute) { + this._volume.mute = mute; + } + }); + /** + * The fadeIn time of the amplitude envelope. + * @memberOf Tone.Source# + * @type {Time} + * @name fadeIn + */ + Object.defineProperty(Tone.Players.prototype, 'fadeIn', { + get: function () { + return this._fadeIn; + }, + set: function (fadeIn) { + this._fadeIn = fadeIn; + this._forEach(function (player) { + player.fadeIn = fadeIn; + }); + } + }); + /** + * The fadeOut time of the amplitude envelope. + * @memberOf Tone.Source# + * @type {Time} + * @name fadeOut + */ + Object.defineProperty(Tone.Players.prototype, 'fadeOut', { + get: function () { + return this._fadeOut; + }, + set: function (fadeOut) { + this._fadeOut = fadeOut; + this._forEach(function (player) { + player.fadeOut = fadeOut; + }); + } + }); + /** + * The state of the players object. Returns "started" if any of the players are playing. + * @memberOf Tone.Players# + * @type {String} + * @name state + * @readOnly + */ + Object.defineProperty(Tone.Players.prototype, 'state', { + get: function () { + var playing = false; + this._forEach(function (player) { + playing = playing || player.state === Tone.State.Started; + }); + return playing ? Tone.State.Started : Tone.State.Stopped; + } + }); + /** + * True if the buffers object has a buffer by that name. + * @param {String|Number} name The key or index of the + * buffer. + * @return {Boolean} + */ + Tone.Players.prototype.has = function (name) { + return this._players.hasOwnProperty(name); + }; + /** + * Get a player by name. + * @param {String} name The players name as defined in + * the constructor object or `add` method. + * @return {Tone.Player} + */ + Tone.Players.prototype.get = function (name) { + if (this.has(name)) { + return this._players[name]; + } else { + throw new Error('Tone.Players: no player named ' + name); + } + }; + /** + * Iterate over all of the players + * @param {Function} callback + * @return {Tone.Players} this + * @private + */ + Tone.Players.prototype._forEach = function (callback) { + for (var playerName in this._players) { + callback(this._players[playerName], playerName); + } + return this; + }; + /** + * If all the buffers are loaded or not + * @memberOf Tone.Players# + * @type {Boolean} + * @name loaded + * @readOnly + */ + Object.defineProperty(Tone.Players.prototype, 'loaded', { + get: function () { + var isLoaded = true; + this._forEach(function (player) { + isLoaded = isLoaded && player.loaded; + }); + return isLoaded; + } + }); + /** + * Add a player by name and url to the Players + * @param {String} name A unique name to give the player + * @param {String|Tone.Buffer|Audiobuffer} url Either the url of the bufer, + * or a buffer which will be added + * with the given name. + * @param {Function=} callback The callback to invoke + * when the url is loaded. + */ + Tone.Players.prototype.add = function (name, url, callback) { + this._players[name] = new Tone.Player(url, callback).connect(this.output); + this._players[name].fadeIn = this._fadeIn; + this._players[name].fadeOut = this._fadeOut; + return this; + }; + /** + * Stop all of the players at the given time + * @param {Time} time The time to stop all of the players. + * @return {Tone.Players} this + */ + Tone.Players.prototype.stopAll = function (time) { + this._forEach(function (player) { + player.stop(time); + }); + }; + /** + * Dispose and disconnect. + * @return {Tone.Players} this + */ + Tone.Players.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this._volume.dispose(); + this._volume = null; + this._writable('volume'); + this.volume = null; + this.output = null; + this._forEach(function (player) { + player.dispose(); + }); + this._players = null; + return this; + }; + return Tone.Players; + }); + Module(function (Tone) { + + /** + * @class Tone.UserMedia uses MediaDevices.getUserMedia to open up + * and external microphone or audio input. Check + * [MediaDevices API Support](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) + * to see which browsers are supported. Access to an external input + * is limited to secure (HTTPS) connections. + * + * @constructor + * @extends {Tone.AudioNode} + * @param {Decibels=} volume The level of the input + * @example + * //list the inputs and open the third one + * var motu = new Tone.UserMedia(); + * + * //opening the input asks the user to activate their mic + * motu.open().then(function(){ + * //promise resolves when input is available + * }); + */ + Tone.UserMedia = function () { + var options = Tone.defaults(arguments, ['volume'], Tone.UserMedia); + Tone.AudioNode.call(this); + /** + * The MediaStreamNode + * @type {MediaStreamAudioSourceNode} + * @private + */ + this._mediaStream = null; + /** + * The media stream created by getUserMedia. + * @type {LocalMediaStream} + * @private + */ + this._stream = null; + /** + * The open device + * @type {MediaDeviceInfo} + * @private + */ + this._device = null; + /** + * The output volume node + * @type {Tone.Volume} + * @private + */ + this._volume = this.output = new Tone.Volume(options.volume); + /** + * The volume of the output in decibels. + * @type {Decibels} + * @signal + * @example + * input.volume.value = -6; + */ + this.volume = this._volume.volume; + this._readOnly('volume'); + this.mute = options.mute; + }; + Tone.extend(Tone.UserMedia, Tone.AudioNode); + /** + * the default parameters + * @type {Object} + */ + Tone.UserMedia.defaults = { + 'volume': 0, + 'mute': false + }; + /** + * Open the media stream. If a string is passed in, it is assumed + * to be the label or id of the stream, if a number is passed in, + * it is the input number of the stream. + * @param {String|Number} [labelOrId="default"] The label or id of the audio input media device. + * With no argument, the default stream is opened. + * @return {Promise} The promise is resolved when the stream is open. + */ + Tone.UserMedia.prototype.open = function (labelOrId) { + return Tone.UserMedia.enumerateDevices().then(function (devices) { + var device; + if (Tone.isNumber(labelOrId)) { + device = devices[labelOrId]; + } else { + device = devices.find(function (device) { + return device.label === labelOrId || device.deviceId === labelOrId; + }); + //didn't find a matching device + if (!device && devices.length > 0) { + device = devices[0]; + } else if (!device && Tone.isDefined(labelOrId)) { + throw new Error('Tone.UserMedia: no matching device: ' + labelOrId); + } + } + this._device = device; + //do getUserMedia + var constraints = { + audio: { + 'echoCancellation': false, + 'sampleRate': this.context.sampleRate + } + }; + if (device) { + constraints.audio.deviceId = device.deviceId; + } + return navigator.mediaDevices.getUserMedia(constraints).then(function (stream) { + //start a new source only if the previous one is closed + if (!this._stream) { + this._stream = stream; + //Wrap a MediaStreamSourceNode around the live input stream. + this._mediaStream = this.context.createMediaStreamSource(stream); + //Connect the MediaStreamSourceNode to a gate gain node + this._mediaStream.connect(this.output); + } + return this; + }.bind(this)); + }.bind(this)); + }; + /** + * Close the media stream + * @return {Tone.UserMedia} this + */ + Tone.UserMedia.prototype.close = function () { + if (this._stream) { + this._stream.getAudioTracks().forEach(function (track) { + track.stop(); + }); + this._stream = null; + //remove the old media stream + this._mediaStream.disconnect(); + this._mediaStream = null; + } + this._device = null; + return this; + }; + /** + * Returns a promise which resolves with the list of audio input devices available. + * @return {Promise} The promise that is resolved with the devices + * @static + * @example + * Tone.UserMedia.enumerateDevices().then(function(devices){ + * console.log(devices) + * }) + */ + Tone.UserMedia.enumerateDevices = function () { + return navigator.mediaDevices.enumerateDevices().then(function (devices) { + return devices.filter(function (device) { + return device.kind === 'audioinput'; + }); + }); + }; + /** + * Returns the playback state of the source, "started" when the microphone is open + * and "stopped" when the mic is closed. + * @type {Tone.State} + * @readOnly + * @memberOf Tone.UserMedia# + * @name state + */ + Object.defineProperty(Tone.UserMedia.prototype, 'state', { + get: function () { + return this._stream && this._stream.active ? Tone.State.Started : Tone.State.Stopped; + } + }); + /** + * Returns an identifier for the represented device that is + * persisted across sessions. It is un-guessable by other applications and + * unique to the origin of the calling application. It is reset when the + * user clears cookies (for Private Browsing, a different identifier is + * used that is not persisted across sessions). Returns undefined when the + * device is not open. + * @type {String} + * @readOnly + * @memberOf Tone.UserMedia# + * @name deviceId + */ + Object.defineProperty(Tone.UserMedia.prototype, 'deviceId', { + get: function () { + if (this._device) { + return this._device.deviceId; + } + } + }); + /** + * Returns a group identifier. Two devices have the + * same group identifier if they belong to the same physical device. + * Returns undefined when the device is not open. + * @type {String} + * @readOnly + * @memberOf Tone.UserMedia# + * @name groupId + */ + Object.defineProperty(Tone.UserMedia.prototype, 'groupId', { + get: function () { + if (this._device) { + return this._device.groupId; + } + } + }); + /** + * Returns a label describing this device (for example "Built-in Microphone"). + * Returns undefined when the device is not open or label is not available + * because of permissions. + * @type {String} + * @readOnly + * @memberOf Tone.UserMedia# + * @name groupId + */ + Object.defineProperty(Tone.UserMedia.prototype, 'label', { + get: function () { + if (this._device) { + return this._device.label; + } + } + }); + /** + * Mute the output. + * @memberOf Tone.UserMedia# + * @type {boolean} + * @name mute + * @example + * //mute the output + * userMedia.mute = true; + */ + Object.defineProperty(Tone.UserMedia.prototype, 'mute', { + get: function () { + return this._volume.mute; + }, + set: function (mute) { + this._volume.mute = mute; + } + }); + /** + * Clean up. + * @return {Tone.UserMedia} this + */ + Tone.UserMedia.prototype.dispose = function () { + Tone.AudioNode.prototype.dispose.call(this); + this.close(); + this._writable('volume'); + this._volume.dispose(); + this._volume = null; + this.volume = null; + return this; + }; + /** + * If getUserMedia is supported by the browser. + * @type {Boolean} + * @memberOf Tone.UserMedia# + * @name supported + * @static + * @readOnly + */ + Object.defineProperty(Tone.UserMedia, 'supported', { + get: function () { + return Tone.isDefined(navigator.mediaDevices) && Tone.isFunction(navigator.mediaDevices.getUserMedia); + } + }); + return Tone.UserMedia; + }); + Module(function (Tone) { + /** + * @class Tone.Midi is a primitive type for encoding Time values. + * Tone.Midi can be constructed with or without the `new` keyword. Tone.Midi can be passed + * into the parameter of any method which takes time as an argument. + * @constructor + * @extends {Tone.Frequency} + * @param {String|Number} val The time value. + * @param {String=} units The units of the value. + * @example + * var t = Tone.Midi("4n");//a quarter note + */ + Tone.Midi = function (val, units) { + if (this instanceof Tone.Midi) { + Tone.Frequency.call(this, val, units); + } else { + return new Tone.Midi(val, units); + } + }; + Tone.extend(Tone.Midi, Tone.Frequency); + /** + * The default units if none are given. + * @type {String} + * @private + */ + Tone.Midi.prototype._defaultUnits = 'midi'; + /** + * Returns the value of a frequency in the current units + * @param {Frequency} freq + * @return {Number} + * @private + */ + Tone.Midi.prototype._frequencyToUnits = function (freq) { + return Tone.Frequency.ftom(Tone.Frequency.prototype._frequencyToUnits.call(this, freq)); + }; + /** + * Returns the value of a tick in the current time units + * @param {Ticks} ticks + * @return {Number} + * @private + */ + Tone.Midi.prototype._ticksToUnits = function (ticks) { + return Tone.Frequency.ftom(Tone.Frequency.prototype._ticksToUnits.call(this, ticks)); + }; + /** + * Return the value of the beats in the current units + * @param {Number} beats + * @return {Number} + * @private + */ + Tone.Midi.prototype._beatsToUnits = function (beats) { + return Tone.Frequency.ftom(Tone.Frequency.prototype._beatsToUnits.call(this, beats)); + }; + /** + * Returns the value of a second in the current units + * @param {Seconds} seconds + * @return {Number} + * @private + */ + Tone.Midi.prototype._secondsToUnits = function (seconds) { + return Tone.Frequency.ftom(Tone.Frequency.prototype._secondsToUnits.call(this, seconds)); + }; + /** + * Return the value of the frequency as a MIDI note + * @return {MIDI} + * @example + * Tone.Midi(60).toMidi(); //60 + */ + Tone.Midi.prototype.toMidi = function () { + return this.valueOf(); + }; + /** + * Return the value of the frequency as a MIDI note + * @return {MIDI} + * @example + * Tone.Midi(60).toMidi(); //60 + */ + Tone.Midi.prototype.toFrequency = function () { + return Tone.Frequency.mtof(this.toMidi()); + }; + /** + * Transposes the frequency by the given number of semitones. + * @param {Interval} interval + * @return {Tone.Frequency} A new transposed frequency + * @example + * Tone.Frequency("A4").transpose(3); //"C5" + */ + Tone.Midi.prototype.transpose = function (interval) { + return new this.constructor(this.toMidi() + interval); + }; + return Tone.Midi; + }); + + return Tone; +})); + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + +// optional / simple context binding +var aFunction = __webpack_require__(33); +module.exports = function(fn, that, length){ + aFunction(fn); + if(that === undefined)return fn; + switch(length){ + case 1: return function(a){ + return fn.call(that, a); + }; + case 2: return function(a, b){ + return fn.call(that, a, b); + }; + case 3: return function(a, b, c){ + return fn.call(that, a, b, c); + }; + } + return function(/* ...args */){ + return fn.apply(that, arguments); + }; +}; + +/***/ }), +/* 23 */ +/***/ (function(module, exports) { + +module.exports = true; + +/***/ }), +/* 24 */ +/***/ (function(module, exports) { + +exports.f = {}.propertyIsEnumerable; + +/***/ }), +/* 25 */ +/***/ (function(module, exports) { + +module.exports = function(bitmap, value){ + return { + enumerable : !(bitmap & 1), + configurable: !(bitmap & 2), + writable : !(bitmap & 4), + value : value + }; +}; + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + +var def = __webpack_require__(8).f + , has = __webpack_require__(6) + , TAG = __webpack_require__(0)('toStringTag'); + +module.exports = function(it, tag, stat){ + if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag}); +}; + +/***/ }), +/* 27 */ +/***/ (function(module, exports) { + +var id = 0 + , px = Math.random(); +module.exports = function(key){ + return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); +}; + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var $at = __webpack_require__(122)(true); + +// 21.1.3.27 String.prototype[@@iterator]() +__webpack_require__(55)(String, 'String', function(iterated){ + this._t = String(iterated); // target + this._i = 0; // next index +// 21.1.5.2.1 %StringIteratorPrototype%.next() +}, function(){ + var O = this._t + , index = this._i + , point; + if(index >= O.length)return {value: undefined, done: true}; + point = $at(O, index); + this._i += point.length; + return {value: point, done: false}; +}); + +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(126); +var global = __webpack_require__(2) + , hide = __webpack_require__(7) + , Iterators = __webpack_require__(14) + , TO_STRING_TAG = __webpack_require__(0)('toStringTag'); + +for(var collections = ['NodeList', 'DOMTokenList', 'MediaList', 'StyleSheetList', 'CSSRuleList'], i = 0; i < 5; i++){ + var NAME = collections[i] + , Collection = global[NAME] + , proto = Collection && Collection.prototype; + if(proto && !proto[TO_STRING_TAG])hide(proto, TO_STRING_TAG, NAME); + Iterators[NAME] = Iterators.Array; +} + +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.dataURItoBlob = exports.tap = exports.mtof = exports.ftom = exports.requestAudioContext = exports.get_diff_bounds = exports.get_bounds = exports.browser = exports.norm = exports.mod = exports.choice = undefined; + +var _log = __webpack_require__(83); + +var _log2 = _interopRequireDefault(_log); + +var _assign = __webpack_require__(31); + +var _assign2 = _interopRequireDefault(_assign); + +var _tone = __webpack_require__(21); + +var _tone2 = _interopRequireDefault(_tone); + +var _startAudioContext = __webpack_require__(80); + +var _startAudioContext2 = _interopRequireDefault(_startAudioContext); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var isIphone = navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i); +var isIpad = navigator.userAgent.match(/iPad/i); +var isAndroid = navigator.userAgent.match(/Android/i); +var isMobile = isIphone || isIpad || isAndroid; +var isDesktop = !isMobile; + +document.body.classList.add(isMobile ? 'mobile' : 'desktop'); + +var browser = { isIphone: isIphone, isIpad: isIpad, isMobile: isMobile, isDesktop: isDesktop }; + +function choice(a) { + return a[Math.floor(Math.random() * a.length)]; +} +function mod(n, m) { + return n - m * Math.floor(n / m); +} +function norm(n, min, max) { + return (n - min) / (max - min); +} + +function requestAudioContext(fn) { + if (isMobile) { + var container = document.createElement('div'); + var button = document.createElement('div'); + button.innerHTML = 'Tap to start - please unmute your phone'; + (0, _assign2.default)(container.style, { + position: 'absolute', + width: '100%', + height: '100%', + zIndex: '10000', + top: '0px', + left: '0px', + backgroundColor: 'rgba(0, 0, 0, 0.8)' + }); + (0, _assign2.default)(button.style, { + position: 'absolute', + left: '50%', + top: '50%', + padding: '20px', + backgroundColor: '#7F33ED', + color: 'white', + fontFamily: 'monospace', + borderRadius: '3px', + transform: 'translate3D(-50%,-50%,0)', + textAlign: 'center', + lineHeight: '1.5' + }); + container.appendChild(button); + document.body.appendChild(container); + _startAudioContext2.default.setContext(_tone2.default.context); + _startAudioContext2.default.on(button); + _startAudioContext2.default.onStarted(function (_) { + container.remove(); + fn(); + }); + } else { + fn(); + } +} + +function dataURItoBlob(dataURI) { + // convert base64 to raw binary data held in a string + // doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this + var byteString = atob(dataURI.split(',')[1]); + + // separate out the mime component + var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; + + // write the bytes of the string to an ArrayBuffer + var ab = new ArrayBuffer(byteString.length); + + // create a view into the buffer + var ia = new Uint8Array(ab); + + // set the bytes of the buffer to the correct values + for (var i = 0; i < byteString.length; i++) { + ia[i] = byteString.charCodeAt(i); + } + + // write the ArrayBuffer to a blob, and you're done + var blob = new Blob([ab], { type: mimeString }); + return blob; +} +function ftom(f) { + // return (Math.log(f) - Math.log(261.626)) / Math.log(2) + 4.0 + return 69 + 12 * (0, _log2.default)(f / 440); +} +function mtof(m) { + return 440 * Math.pow(2, (m - 69) / 12); +} +function tap(fn) { + return function (e) { + if (browser.isMobile) fn();else if (e.press) fn(); + }; +} + +/* get minimum and maximum variance from row-to-row */ + +function get_diff_bounds(rows) { + var diffs = rows.map(function (row) { + var row_min = Math.min.apply(Math, row); + var row_max = Math.max.apply(Math, row); + return row_max - row_min; + }); + var min = Math.min.apply(Math, diffs); + var max = Math.max.apply(Math, diffs); + return { min: min, max: max }; +} + +/* get minimum and maximum values from a dataset */ + +function get_bounds(dataset) { + var rows = dataset.lines; + // rows.forEach(row => row.shift()) + rows = rows.map(function (a) { + return a.map(function (n) { + return parseFloat(n); + }); + }); + var max = rows.reduce(function (a, b) { + return b.reduce(function (z, bb) { + return Math.max(z, bb); + }, a); + }, -Infinity); + var min = rows.reduce(function (a, b) { + return b.reduce(function (z, bb) { + return Math.min(z, bb); + }, a); + }, Infinity); + return { rows: rows, max: max, min: min }; +} + +exports.choice = choice; +exports.mod = mod; +exports.norm = norm; +exports.browser = browser; +exports.get_bounds = get_bounds; +exports.get_diff_bounds = get_diff_bounds; +exports.requestAudioContext = requestAudioContext; +exports.ftom = ftom; +exports.mtof = mtof; +exports.tap = tap; +exports.dataURItoBlob = dataURItoBlob; + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = { "default": __webpack_require__(93), __esModule: true }; + +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(global) { + +var buffer = __webpack_require__(3); +var Buffer = buffer.Buffer; +var SlowBuffer = buffer.SlowBuffer; +var MAX_LEN = buffer.kMaxLength || 2147483647; +exports.alloc = function alloc(size, fill, encoding) { + if (typeof Buffer.alloc === 'function') { + return Buffer.alloc(size, fill, encoding); + } + if (typeof encoding === 'number') { + throw new TypeError('encoding must not be number'); + } + if (typeof size !== 'number') { + throw new TypeError('size must be a number'); + } + if (size > MAX_LEN) { + throw new RangeError('size is too large'); + } + var enc = encoding; + var _fill = fill; + if (_fill === undefined) { + enc = undefined; + _fill = 0; + } + var buf = new Buffer(size); + if (typeof _fill === 'string') { + var fillBuf = new Buffer(_fill, enc); + var flen = fillBuf.length; + var i = -1; + while (++i < size) { + buf[i] = fillBuf[i % flen]; + } + } else { + buf.fill(_fill); + } + return buf; +} +exports.allocUnsafe = function allocUnsafe(size) { + if (typeof Buffer.allocUnsafe === 'function') { + return Buffer.allocUnsafe(size); + } + if (typeof size !== 'number') { + throw new TypeError('size must be a number'); + } + if (size > MAX_LEN) { + throw new RangeError('size is too large'); + } + return new Buffer(size); +} +exports.from = function from(value, encodingOrOffset, length) { + if (typeof Buffer.from === 'function' && (!global.Uint8Array || Uint8Array.from !== Buffer.from)) { + return Buffer.from(value, encodingOrOffset, length); + } + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number'); + } + if (typeof value === 'string') { + return new Buffer(value, encodingOrOffset); + } + if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { + var offset = encodingOrOffset; + if (arguments.length === 1) { + return new Buffer(value); + } + if (typeof offset === 'undefined') { + offset = 0; + } + var len = length; + if (typeof len === 'undefined') { + len = value.byteLength - offset; + } + if (offset >= value.byteLength) { + throw new RangeError('\'offset\' is out of bounds'); + } + if (len > value.byteLength - offset) { + throw new RangeError('\'length\' is out of bounds'); + } + return new Buffer(value.slice(offset, offset + len)); + } + if (Buffer.isBuffer(value)) { + var out = new Buffer(value.length); + value.copy(out, 0, 0, value.length); + return out; + } + if (value) { + if (Array.isArray(value) || (typeof ArrayBuffer !== 'undefined' && value.buffer instanceof ArrayBuffer) || 'length' in value) { + return new Buffer(value); + } + if (value.type === 'Buffer' && Array.isArray(value.data)) { + return new Buffer(value.data); + } + } + + throw new TypeError('First argument must be a string, Buffer, ' + 'ArrayBuffer, Array, or array-like object.'); +} +exports.allocUnsafeSlow = function allocUnsafeSlow(size) { + if (typeof Buffer.allocUnsafeSlow === 'function') { + return Buffer.allocUnsafeSlow(size); + } + if (typeof size !== 'number') { + throw new TypeError('size must be a number'); + } + if (size >= MAX_LEN) { + throw new RangeError('size is too large'); + } + return new SlowBuffer(size); +} + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(20))) + +/***/ }), +/* 33 */ +/***/ (function(module, exports) { + +module.exports = function(it){ + if(typeof it != 'function')throw TypeError(it + ' is not a function!'); + return it; +}; + +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + +// getting tag from 19.1.3.6 Object.prototype.toString() +var cof = __webpack_require__(17) + , TAG = __webpack_require__(0)('toStringTag') + // ES3 wrong here + , ARG = cof(function(){ return arguments; }()) == 'Arguments'; + +// fallback for IE11 Script Access Denied error +var tryGet = function(it, key){ + try { + return it[key]; + } catch(e){ /* empty */ } +}; + +module.exports = function(it){ + var O, T, B; + return it === undefined ? 'Undefined' : it === null ? 'Null' + // @@toStringTag case + : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T + // builtinTag case + : ARG ? cof(O) + // ES3 arguments fallback + : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; +}; + +/***/ }), +/* 35 */ +/***/ (function(module, exports) { + +// 7.2.1 RequireObjectCoercible(argument) +module.exports = function(it){ + if(it == undefined)throw TypeError("Can't call method on " + it); + return it; +}; + +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { + +var isObject = __webpack_require__(18) + , document = __webpack_require__(2).document + // in old IE typeof document.createElement is 'object' + , is = isObject(document) && isObject(document.createElement); +module.exports = function(it){ + return is ? document.createElement(it) : {}; +}; + +/***/ }), +/* 37 */ +/***/ (function(module, exports) { + +// IE 8- don't enum bug keys +module.exports = ( + 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' +).split(','); + +/***/ }), +/* 38 */ +/***/ (function(module, exports) { + +exports.f = Object.getOwnPropertySymbols; + +/***/ }), +/* 39 */ +/***/ (function(module, exports, __webpack_require__) { + +var shared = __webpack_require__(40)('keys') + , uid = __webpack_require__(27); +module.exports = function(key){ + return shared[key] || (shared[key] = uid(key)); +}; + +/***/ }), +/* 40 */ +/***/ (function(module, exports, __webpack_require__) { + +var global = __webpack_require__(2) + , SHARED = '__core-js_shared__' + , store = global[SHARED] || (global[SHARED] = {}); +module.exports = function(key){ + return store[key] || (store[key] = {}); +}; + +/***/ }), +/* 41 */ +/***/ (function(module, exports) { + +// 7.1.4 ToInteger +var ceil = Math.ceil + , floor = Math.floor; +module.exports = function(it){ + return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); +}; + +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { + +// 7.1.13 ToObject(argument) +var defined = __webpack_require__(35); +module.exports = function(it){ + return Object(defined(it)); +}; + +/***/ }), +/* 43 */ +/***/ (function(module, exports, __webpack_require__) { + +// 7.1.1 ToPrimitive(input [, PreferredType]) +var isObject = __webpack_require__(18); +// instead of the ES6 spec version, we didn't implement @@toPrimitive case +// and the second argument - flag - preferred type is a string +module.exports = function(it, S){ + if(!isObject(it))return it; + var fn, val; + if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val; + if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val; + if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val; + throw TypeError("Can't convert object to primitive value"); +}; + +/***/ }), +/* 44 */ +/***/ (function(module, exports, __webpack_require__) { + +var global = __webpack_require__(2) + , core = __webpack_require__(1) + , LIBRARY = __webpack_require__(23) + , wksExt = __webpack_require__(45) + , defineProperty = __webpack_require__(8).f; +module.exports = function(name){ + var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {}); + if(name.charAt(0) != '_' && !(name in $Symbol))defineProperty($Symbol, name, {value: wksExt.f(name)}); +}; + +/***/ }), +/* 45 */ +/***/ (function(module, exports, __webpack_require__) { + +exports.f = __webpack_require__(0); + +/***/ }), +/* 46 */ +/***/ (function(module, exports) { + +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; +} +module.exports = EventEmitter; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; +}; + +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; + + if (!this._events) + this._events = {}; + + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } + } + } + + handler = this._events[type]; + + if (isUndefined(handler)) + return false; + + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); + } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } + + return true; +}; + +EventEmitter.prototype.addListener = function(type, listener) { + var m; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events) + this._events = {}; + + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); + + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; + } + + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } + } + + return this; +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + var fired = false; + + function g() { + this.removeListener(type, g); + + if (!fired) { + fired = true; + listener.apply(this, arguments); + } + } + + g.listener = listener; + this.on(type, g); + + return this; +}; + +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events || !this._events[type]) + return this; + + list = this._events[type]; + length = list.length; + position = -1; + + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } + + if (position < 0) + return this; + + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); + } + + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } + + return this; +}; + +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; + + if (!this._events) + return this; + + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; + } + + listeners = this._events[type]; + + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; + + return this; +}; + +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; +}; + +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; + + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; + } + return 0; +}; + +EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); +}; + +function isFunction(arg) { + return typeof arg === 'function'; +} + +function isNumber(arg) { + return typeof arg === 'number'; +} + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} + +function isUndefined(arg) { + return arg === void 0; +} + + +/***/ }), +/* 47 */ +/***/ (function(module, exports, __webpack_require__) { + +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var Buffer = __webpack_require__(3).Buffer; + +var isBufferEncoding = Buffer.isEncoding + || function(encoding) { + switch (encoding && encoding.toLowerCase()) { + case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true; + default: return false; + } + } + + +function assertEncoding(encoding) { + if (encoding && !isBufferEncoding(encoding)) { + throw new Error('Unknown encoding: ' + encoding); + } +} + +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. CESU-8 is handled as part of the UTF-8 encoding. +// +// @TODO Handling all encodings inside a single object makes it very difficult +// to reason about this code, so it should be split up in the future. +// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code +// points as used by CESU-8. +var StringDecoder = exports.StringDecoder = function(encoding) { + this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); + assertEncoding(encoding); + switch (this.encoding) { + case 'utf8': + // CESU-8 represents each of Surrogate Pair by 3-bytes + this.surrogateSize = 3; + break; + case 'ucs2': + case 'utf16le': + // UTF-16 represents each of Surrogate Pair by 2-bytes + this.surrogateSize = 2; + this.detectIncompleteChar = utf16DetectIncompleteChar; + break; + case 'base64': + // Base-64 stores 3 bytes in 4 chars, and pads the remainder. + this.surrogateSize = 3; + this.detectIncompleteChar = base64DetectIncompleteChar; + break; + default: + this.write = passThroughWrite; + return; + } + + // Enough space to store all bytes of a single character. UTF-8 needs 4 + // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). + this.charBuffer = new Buffer(6); + // Number of bytes received for the current incomplete multi-byte character. + this.charReceived = 0; + // Number of bytes expected for the current incomplete multi-byte character. + this.charLength = 0; +}; + + +// write decodes the given buffer and returns it as JS string that is +// guaranteed to not contain any partial multi-byte characters. Any partial +// character found at the end of the buffer is buffered up, and will be +// returned when calling write again with the remaining bytes. +// +// Note: Converting a Buffer containing an orphan surrogate to a String +// currently works, but converting a String to a Buffer (via `new Buffer`, or +// Buffer#write) will replace incomplete surrogates with the unicode +// replacement character. See https://codereview.chromium.org/121173009/ . +StringDecoder.prototype.write = function(buffer) { + var charStr = ''; + // if our last write ended with an incomplete multibyte character + while (this.charLength) { + // determine how many remaining bytes this buffer has to offer for this char + var available = (buffer.length >= this.charLength - this.charReceived) ? + this.charLength - this.charReceived : + buffer.length; + + // add the new bytes to the char buffer + buffer.copy(this.charBuffer, this.charReceived, 0, available); + this.charReceived += available; + + if (this.charReceived < this.charLength) { + // still not enough chars in this buffer? wait for more ... + return ''; + } + + // remove bytes belonging to the current character from the buffer + buffer = buffer.slice(available, buffer.length); + + // get the character that was split + charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); + + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + var charCode = charStr.charCodeAt(charStr.length - 1); + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + this.charLength += this.surrogateSize; + charStr = ''; + continue; + } + this.charReceived = this.charLength = 0; + + // if there are no more bytes in this buffer, just emit our char + if (buffer.length === 0) { + return charStr; + } + break; + } + + // determine and set charLength / charReceived + this.detectIncompleteChar(buffer); + + var end = buffer.length; + if (this.charLength) { + // buffer the incomplete character bytes we got + buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end); + end -= this.charReceived; + } + + charStr += buffer.toString(this.encoding, 0, end); + + var end = charStr.length - 1; + var charCode = charStr.charCodeAt(end); + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + var size = this.surrogateSize; + this.charLength += size; + this.charReceived += size; + this.charBuffer.copy(this.charBuffer, size, 0, size); + buffer.copy(this.charBuffer, 0, 0, size); + return charStr.substring(0, end); + } + + // or just emit the charStr + return charStr; +}; + +// detectIncompleteChar determines if there is an incomplete UTF-8 character at +// the end of the given buffer. If so, it sets this.charLength to the byte +// length that character, and sets this.charReceived to the number of bytes +// that are available for this character. +StringDecoder.prototype.detectIncompleteChar = function(buffer) { + // determine how many bytes we have to check at the end of this buffer + var i = (buffer.length >= 3) ? 3 : buffer.length; + + // Figure out if one of the last i bytes of our buffer announces an + // incomplete char. + for (; i > 0; i--) { + var c = buffer[buffer.length - i]; + + // See http://en.wikipedia.org/wiki/UTF-8#Description + + // 110XXXXX + if (i == 1 && c >> 5 == 0x06) { + this.charLength = 2; + break; + } + + // 1110XXXX + if (i <= 2 && c >> 4 == 0x0E) { + this.charLength = 3; + break; + } + + // 11110XXX + if (i <= 3 && c >> 3 == 0x1E) { + this.charLength = 4; + break; + } + } + this.charReceived = i; +}; + +StringDecoder.prototype.end = function(buffer) { + var res = ''; + if (buffer && buffer.length) + res = this.write(buffer); + + if (this.charReceived) { + var cr = this.charReceived; + var buf = this.charBuffer; + var enc = this.encoding; + res += buf.slice(0, cr).toString(enc); + } + + return res; +}; + +function passThroughWrite(buffer) { + return buffer.toString(this.encoding); +} + +function utf16DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 2; + this.charLength = this.charReceived ? 2 : 0; +} + +function base64DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 3; + this.charLength = this.charReceived ? 3 : 0; +} + + +/***/ }), +/* 48 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(process) { + +if (!process.version || + process.version.indexOf('v0.') === 0 || + process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { + module.exports = nextTick; +} else { + module.exports = process.nextTick; +} + +function nextTick(fn, arg1, arg2, arg3) { + if (typeof fn !== 'function') { + throw new TypeError('"callback" argument must be a function'); + } + var len = arguments.length; + var args, i; + switch (len) { + case 0: + case 1: + return process.nextTick(fn); + case 2: + return process.nextTick(function afterTickOne() { + fn.call(null, arg1); + }); + case 3: + return process.nextTick(function afterTickTwo() { + fn.call(null, arg1, arg2); + }); + case 4: + return process.nextTick(function afterTickThree() { + fn.call(null, arg1, arg2, arg3); + }); + default: + args = new Array(len - 1); + i = 0; + while (i < args.length) { + args[i++] = arguments[i]; + } + return process.nextTick(function afterTick() { + fn.apply(null, args); + }); + } +} + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10))) + +/***/ }), +/* 49 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(process, setImmediate) {// A bit simpler than readable streams. +// Implement an async ._write(chunk, encoding, cb), and it'll handle all +// the drain event emission and buffering. + + + +module.exports = Writable; + +/*<replacement>*/ +var processNextTick = __webpack_require__(48); +/*</replacement>*/ + +/*<replacement>*/ +var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick; +/*</replacement>*/ + +/*<replacement>*/ +var Duplex; +/*</replacement>*/ + +Writable.WritableState = WritableState; + +/*<replacement>*/ +var util = __webpack_require__(19); +util.inherits = __webpack_require__(16); +/*</replacement>*/ + +/*<replacement>*/ +var internalUtil = { + deprecate: __webpack_require__(147) +}; +/*</replacement>*/ + +/*<replacement>*/ +var Stream = __webpack_require__(67); +/*</replacement>*/ + +var Buffer = __webpack_require__(3).Buffer; +/*<replacement>*/ +var bufferShim = __webpack_require__(32); +/*</replacement>*/ + +util.inherits(Writable, Stream); + +function nop() {} + +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; +} + +function WritableState(options, stream) { + Duplex = Duplex || __webpack_require__(11); + + options = options || {}; + + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; + + if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode; + + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; + + // cast to ints. + this.highWaterMark = ~~this.highWaterMark; + + // drain event flag. + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; + + // a flag to see when we're in the middle of a write. + this.writing = false; + + // when true all writes will be buffered until .uncork() call + this.corked = 0; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function (er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + + this.bufferedRequest = null; + this.lastBufferedRequest = null; + + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; + + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; + + // True if the error was already emitted and should not be thrown again + this.errorEmitted = false; + + // count buffered requests + this.bufferedRequestCount = 0; + + // allocate the first CorkedRequest, there is always + // one allocated and free to use, and we maintain at most two + this.corkedRequestsFree = new CorkedRequest(this); +} + +WritableState.prototype.getBuffer = function getBuffer() { + var current = this.bufferedRequest; + var out = []; + while (current) { + out.push(current); + current = current.next; + } + return out; +}; + +(function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function () { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.') + }); + } catch (_) {} +})(); + +// Test _writableState for inheritance to account for Duplex streams, +// whose prototype chain only points to Readable. +var realHasInstance; +if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable, Symbol.hasInstance, { + value: function (object) { + if (realHasInstance.call(this, object)) return true; + + return object && object._writableState instanceof WritableState; + } + }); +} else { + realHasInstance = function (object) { + return object instanceof this; + }; +} + +function Writable(options) { + Duplex = Duplex || __webpack_require__(11); + + // Writable ctor is applied to Duplexes, too. + // `realHasInstance` is necessary because using plain `instanceof` + // would return false, as no `_writableState` property is attached. + + // Trying to use the custom `instanceof` for Writable here will also break the + // Node.js LazyTransform implementation, which has a non-trivial getter for + // `_writableState` that would lead to infinite recursion. + if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { + return new Writable(options); + } + + this._writableState = new WritableState(options, this); + + // legacy. + this.writable = true; + + if (options) { + if (typeof options.write === 'function') this._write = options.write; + + if (typeof options.writev === 'function') this._writev = options.writev; + } + + Stream.call(this); +} + +// Otherwise people can pipe Writable streams, which is just wrong. +Writable.prototype.pipe = function () { + this.emit('error', new Error('Cannot pipe, not readable')); +}; + +function writeAfterEnd(stream, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + processNextTick(cb, er); +} + +// Checks that a user-supplied chunk is valid, especially for the particular +// mode the stream is in. Currently this means that `null` is never accepted +// and undefined/non-string values are only allowed in object mode. +function validChunk(stream, state, chunk, cb) { + var valid = true; + var er = false; + + if (chunk === null) { + er = new TypeError('May not write null values to stream'); + } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + if (er) { + stream.emit('error', er); + processNextTick(cb, er); + valid = false; + } + return valid; +} + +Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + var isBuf = Buffer.isBuffer(chunk); + + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + + if (typeof cb !== 'function') cb = nop; + + if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); + } + + return ret; +}; + +Writable.prototype.cork = function () { + var state = this._writableState; + + state.corked++; +}; + +Writable.prototype.uncork = function () { + var state = this._writableState; + + if (state.corked) { + state.corked--; + + if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + } +}; + +Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); + this._writableState.defaultEncoding = encoding; + return this; +}; + +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = bufferShim.from(chunk, encoding); + } + return chunk; +} + +// if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. +function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + chunk = decodeChunk(state, chunk, encoding); + if (Buffer.isBuffer(chunk)) encoding = 'buffer'; + } + var len = state.objectMode ? 1 : chunk.length; + + state.length += len; + + var ret = state.length < state.highWaterMark; + // we must ensure that previous needDrain will not be reset to false. + if (!ret) state.needDrain = true; + + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = new WriteReq(chunk, encoding, cb); + if (last) { + last.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; + } + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); + } + + return ret; +} + +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} + +function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; + if (sync) processNextTick(cb, er);else cb(er); + + stream._writableState.errorEmitted = true; + stream.emit('error', er); +} + +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; +} + +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + + onwriteStateUpdate(state); + + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state); + + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); + } + + if (sync) { + /*<replacement>*/ + asyncWrite(afterWrite, stream, state, finished, cb); + /*</replacement>*/ + } else { + afterWrite(stream, state, finished, cb); + } + } +} + +function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); +} + +// Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} + +// if there's something in the buffer waiting, then process it +function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; + + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; + + var count = 0; + while (entry) { + buffer[count] = entry; + entry = entry.next; + count += 1; + } + + doWrite(stream, state, true, state.length, buffer, '', holder.finish); + + // doWrite is almost always async, defer these to save a bit of time + // as the hot path ends with doWrite + state.pendingcb++; + state.lastBufferedRequest = null; + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + state.corkedRequestsFree = new CorkedRequest(state); + } + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + break; + } + } + + if (entry === null) state.lastBufferedRequest = null; + } + + state.bufferedRequestCount = 0; + state.bufferedRequest = entry; + state.bufferProcessing = false; +} + +Writable.prototype._write = function (chunk, encoding, cb) { + cb(new Error('_write() is not implemented')); +}; + +Writable.prototype._writev = null; + +Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; + + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); + + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); + } + + // ignore unnecessary end() calls. + if (!state.ending && !state.finished) endWritable(this, state, cb); +}; + +function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; +} + +function prefinish(stream, state) { + if (!state.prefinished) { + state.prefinished = true; + stream.emit('prefinish'); + } +} + +function finishMaybe(stream, state) { + var need = needFinish(state); + if (need) { + if (state.pendingcb === 0) { + prefinish(stream, state); + state.finished = true; + stream.emit('finish'); + } else { + prefinish(stream, state); + } + } + return need; +} + +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) processNextTick(cb);else stream.once('finish', cb); + } + state.ended = true; + stream.writable = false; +} + +// It seems a linked list but it is not +// there will be only 2 of these for each stream +function CorkedRequest(state) { + var _this = this; + + this.next = null; + this.entry = null; + this.finish = function (err) { + var entry = _this.entry; + _this.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + if (state.corkedRequestsFree) { + state.corkedRequestsFree.next = _this; + } else { + state.corkedRequestsFree = _this; + } + }; +} +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10), __webpack_require__(68).setImmediate)) + +/***/ }), +/* 50 */ +/***/ (function(module, exports, __webpack_require__) { + +exports = module.exports = __webpack_require__(65); +exports.Stream = exports; +exports.Readable = exports; +exports.Writable = __webpack_require__(49); +exports.Duplex = __webpack_require__(11); +exports.Transform = __webpack_require__(66); +exports.PassThrough = __webpack_require__(139); + + +/***/ }), +/* 51 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _intonation = __webpack_require__(78); + +var _intonation2 = _interopRequireDefault(_intonation); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var meantone = '! meanquar.scl\n!\n1/4-comma meantone scale. Pietro Aaron\'s temperament (1523)\n 12\n!\n 76.04900\n 193.15686\n 310.26471\n 5/4\n 503.42157\n 579.47057\n 696.57843\n 25/16\n 889.73529\n 1006.84314\n 1082.89214\n 2/1\n'; + +var shares = '! shares.scl\n!\nA scale based on shares of wealth\n!\n1.\n5.\n15.\n32.\n52.\n78.\n116.\n182.\n521.\n1000.\n'; + +var shares_sum = '! shares_sum.scl\n!\nA scale based on summing shares of wealth\n!\n1\n6.0\n21.0\n53.0\n105.0\n183.0\n299.0\n481.0\n1002.0\n2/1\n'; + +var mavila = '! mavila12.scl\n!\nA 12-note mavila scale (for warping meantone-based music), 5-limit TOP\n 12\n!\n-30.99719\n 163.50770\n 358.01258\n 327.01540\n 521.52028\n 490.52310\n 685.02798\n 654.03080\n 848.53568\n 1043.04057\n 1012.04338\n 1206.54826\n'; + +var carlos_alpha = '! carlos_alpha.scl\n!\nWendy Carlos\' Alpha scale with perfect fifth divided in nine\n 18\n!\n 78.00000\n 156.00000\n 234.00000\n 312.00000\n 390.00000\n 468.00000\n 546.00000\n 624.00000\n 702.00000\n 780.00000\n 858.00000\n 936.00000\n 1014.00000\n 1092.00000\n 1170.00000\n 1248.00000\n 1326.00000\n 1404.00000\n'; + +var lamonte = '! young-lm_piano.scl\n!\nLaMonte Young\'s Well-Tempered Piano\n12\n!\n567/512\n9/8\n147/128\n21/16\n1323/1024\n189/128\n3/2\n49/32\n7/4\n441/256\n63/32\n2/1\n'; + +var colundi = '! colundi.scl\n!\nColundi scale\n10\n!\n9/8\n171/140\n137/112\n43/35\n3/2\n421/280\n213/140\n263/150\n66/35\n2/1\n'; + +var liu_major = '! liu_major.scl\n!\nLinus Liu\'s Major Scale, see his 1978 book, "Intonation Theory" \n 7\n!\n 10/9\n 100/81\n 4/3\n 3/2\n 5/3\n 50/27\n 2/1\n'; +var liu_pentatonic = '! liu_pent.scl\n!\nLinus Liu\'s "pentatonic scale" \n 7\n!\n 9/8\n 81/64\n 27/20\n 3/2\n 27/16\n 243/128\n 81/40\n'; + +var liu_minor = '! LIU_MINor.scl\n!\nLinus Liu\'s Harmonic Minor \n 7\n!\n 10/9\n 6/5\n 4/3\n 40/27\n 8/5\n 50/27\n 2/1\n'; + +var liu_melodic_minor = '! liu_mel.scl\n!\nLinus Liu\'s Melodic Minor, use 5 and 7 descending and 6 and 8 ascending \n 9\n!\n 10/9\n 6/5\n 4/3\n 3/2\n 81/50\n 5/3\n 9/5\n 50/27\n 2/1\n'; + +var scales = [{ + intervals: '1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1', + name: "harmonic scale" +}, { + root: 450, + intervals: '1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1', + name: "harmonic scale @ 450" +}, { + tet: 5 +}, { + tet: 12 +}, { + tet: 17 +}, { + intervals: '1/1 81/80 33/32 21/20 16/15 12/11 11/10 10/9 9/8 8/7 7/6 32/27 6/5 11/9 5/4 14/11 9/7 21/16 4/3 27/20 11/8 7/5 10/7 16/11 40/27 3/2 32/21 14/9 11/7 8/5 18/11 5/3 27/16 12/7 7/4 16/9 9/5 20/11 11/6 15/8 40/21 64/33 160/81 2/1', + name: "harry partch scale" +}, { + scl: lamonte +}, { + scl: meantone +}, { + scl: mavila +}, { + scl: carlos_alpha +}, { + scl: colundi +}, { + scl: shares +}, { + scl: shares_sum +}, { + scl: liu_major +}, { + scl: liu_minor +}, { + scl: liu_melodic_minor +}, { + scl: liu_pentatonic +}].map(function (opt) { + return new _intonation2.default(opt); +}); + +var scale = scales[0]; +var handleChange = function handleChange() {}; + +function build() { + scales.forEach(function (scale, i) { + scale.heading = document.createElement('div'); + scale.heading.innerHTML = scale.name; + scale.heading.classList.add('heading'); + scale.heading.addEventListener('click', function () { + pick(i); + }); + scale_list.appendChild(scale.heading); + }); + pick(0); +} +function build_options(el) { + scales.forEach(function (scale, i) { + var option = document.createElement('option'); + option.innerHTML = scale.name; + option.value = i; + el.appendChild(option); + }); + el.addEventListener('input', function (e) { + pick(e.target.value); + }); + pick(0); +} + +function pick(i) { + if (scale) { + scale.heading && scale.heading.classList.remove('selected'); + } + scale = scales[i]; + scale.heading && scale.heading.classList.add('selected'); + handleChange(scale); +} + +function current() { + return scale; +} + +function onChange(fn) { + handleChange = fn; +} + +function names() { + return scales.map(function (scale) { + return scale.name; + }); +} + +exports.default = { scales: scales, current: current, build: build, build_options: build_options, pick: pick, names: names, onChange: onChange }; + +/***/ }), +/* 52 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = __webpack_require__(2).document && document.documentElement; + +/***/ }), +/* 53 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = !__webpack_require__(5) && !__webpack_require__(13)(function(){ + return Object.defineProperty(__webpack_require__(36)('div'), 'a', {get: function(){ return 7; }}).a != 7; +}); + +/***/ }), +/* 54 */ +/***/ (function(module, exports, __webpack_require__) { + +// fallback for non-array-like ES3 and non-enumerable old V8 strings +var cof = __webpack_require__(17); +module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){ + return cof(it) == 'String' ? it.split('') : Object(it); +}; + +/***/ }), +/* 55 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var LIBRARY = __webpack_require__(23) + , $export = __webpack_require__(12) + , redefine = __webpack_require__(59) + , hide = __webpack_require__(7) + , has = __webpack_require__(6) + , Iterators = __webpack_require__(14) + , $iterCreate = __webpack_require__(107) + , setToStringTag = __webpack_require__(26) + , getPrototypeOf = __webpack_require__(117) + , ITERATOR = __webpack_require__(0)('iterator') + , BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next` + , FF_ITERATOR = '@@iterator' + , KEYS = 'keys' + , VALUES = 'values'; + +var returnThis = function(){ return this; }; + +module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){ + $iterCreate(Constructor, NAME, next); + var getMethod = function(kind){ + if(!BUGGY && kind in proto)return proto[kind]; + switch(kind){ + case KEYS: return function keys(){ return new Constructor(this, kind); }; + case VALUES: return function values(){ return new Constructor(this, kind); }; + } return function entries(){ return new Constructor(this, kind); }; + }; + var TAG = NAME + ' Iterator' + , DEF_VALUES = DEFAULT == VALUES + , VALUES_BUG = false + , proto = Base.prototype + , $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT] + , $default = $native || getMethod(DEFAULT) + , $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined + , $anyNative = NAME == 'Array' ? proto.entries || $native : $native + , methods, key, IteratorPrototype; + // Fix native + if($anyNative){ + IteratorPrototype = getPrototypeOf($anyNative.call(new Base)); + if(IteratorPrototype !== Object.prototype){ + // Set @@toStringTag to native iterators + setToStringTag(IteratorPrototype, TAG, true); + // fix for some old engines + if(!LIBRARY && !has(IteratorPrototype, ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis); + } + } + // fix Array#{values, @@iterator}.name in V8 / FF + if(DEF_VALUES && $native && $native.name !== VALUES){ + VALUES_BUG = true; + $default = function values(){ return $native.call(this); }; + } + // Define iterator + if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){ + hide(proto, ITERATOR, $default); + } + // Plug for library + Iterators[NAME] = $default; + Iterators[TAG] = returnThis; + if(DEFAULT){ + methods = { + values: DEF_VALUES ? $default : getMethod(VALUES), + keys: IS_SET ? $default : getMethod(KEYS), + entries: $entries + }; + if(FORCED)for(key in methods){ + if(!(key in proto))redefine(proto, key, methods[key]); + } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods); + } + return methods; +}; + +/***/ }), +/* 56 */ +/***/ (function(module, exports, __webpack_require__) { + +// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) +var anObject = __webpack_require__(4) + , dPs = __webpack_require__(114) + , enumBugKeys = __webpack_require__(37) + , IE_PROTO = __webpack_require__(39)('IE_PROTO') + , Empty = function(){ /* empty */ } + , PROTOTYPE = 'prototype'; + +// Create object with fake `null` prototype: use iframe Object with cleared prototype +var createDict = function(){ + // Thrash, waste and sodomy: IE GC bug + var iframe = __webpack_require__(36)('iframe') + , i = enumBugKeys.length + , lt = '<' + , gt = '>' + , iframeDocument; + iframe.style.display = 'none'; + __webpack_require__(52).appendChild(iframe); + iframe.src = 'javascript:'; // eslint-disable-line no-script-url + // createDict = iframe.contentWindow.Object; + // html.removeChild(iframe); + iframeDocument = iframe.contentWindow.document; + iframeDocument.open(); + iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); + iframeDocument.close(); + createDict = iframeDocument.F; + while(i--)delete createDict[PROTOTYPE][enumBugKeys[i]]; + return createDict(); +}; + +module.exports = Object.create || function create(O, Properties){ + var result; + if(O !== null){ + Empty[PROTOTYPE] = anObject(O); + result = new Empty; + Empty[PROTOTYPE] = null; + // add "__proto__" for Object.getPrototypeOf polyfill + result[IE_PROTO] = O; + } else result = createDict(); + return Properties === undefined ? result : dPs(result, Properties); +}; + + +/***/ }), +/* 57 */ +/***/ (function(module, exports, __webpack_require__) { + +// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) +var $keys = __webpack_require__(58) + , hiddenKeys = __webpack_require__(37).concat('length', 'prototype'); + +exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O){ + return $keys(O, hiddenKeys); +}; + +/***/ }), +/* 58 */ +/***/ (function(module, exports, __webpack_require__) { + +var has = __webpack_require__(6) + , toIObject = __webpack_require__(9) + , arrayIndexOf = __webpack_require__(100)(false) + , IE_PROTO = __webpack_require__(39)('IE_PROTO'); + +module.exports = function(object, names){ + var O = toIObject(object) + , i = 0 + , result = [] + , key; + for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key); + // Don't enum bug & hidden keys + while(names.length > i)if(has(O, key = names[i++])){ + ~arrayIndexOf(result, key) || result.push(key); + } + return result; +}; + +/***/ }), +/* 59 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = __webpack_require__(7); + +/***/ }), +/* 60 */ +/***/ (function(module, exports, __webpack_require__) { + +var ctx = __webpack_require__(22) + , invoke = __webpack_require__(103) + , html = __webpack_require__(52) + , cel = __webpack_require__(36) + , global = __webpack_require__(2) + , process = global.process + , setTask = global.setImmediate + , clearTask = global.clearImmediate + , MessageChannel = global.MessageChannel + , counter = 0 + , queue = {} + , ONREADYSTATECHANGE = 'onreadystatechange' + , defer, channel, port; +var run = function(){ + var id = +this; + if(queue.hasOwnProperty(id)){ + var fn = queue[id]; + delete queue[id]; + fn(); + } +}; +var listener = function(event){ + run.call(event.data); +}; +// Node.js 0.9+ & IE10+ has setImmediate, otherwise: +if(!setTask || !clearTask){ + setTask = function setImmediate(fn){ + var args = [], i = 1; + while(arguments.length > i)args.push(arguments[i++]); + queue[++counter] = function(){ + invoke(typeof fn == 'function' ? fn : Function(fn), args); + }; + defer(counter); + return counter; + }; + clearTask = function clearImmediate(id){ + delete queue[id]; + }; + // Node.js 0.8- + if(__webpack_require__(17)(process) == 'process'){ + defer = function(id){ + process.nextTick(ctx(run, id, 1)); + }; + // Browsers with MessageChannel, includes WebWorkers + } else if(MessageChannel){ + channel = new MessageChannel; + port = channel.port2; + channel.port1.onmessage = listener; + defer = ctx(port.postMessage, port, 1); + // Browsers with postMessage, skip WebWorkers + // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' + } else if(global.addEventListener && typeof postMessage == 'function' && !global.importScripts){ + defer = function(id){ + global.postMessage(id + '', '*'); + }; + global.addEventListener('message', listener, false); + // IE8- + } else if(ONREADYSTATECHANGE in cel('script')){ + defer = function(id){ + html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function(){ + html.removeChild(this); + run.call(id); + }; + }; + // Rest old browsers + } else { + defer = function(id){ + setTimeout(ctx(run, id, 1), 0); + }; + } +} +module.exports = { + set: setTask, + clear: clearTask +}; + +/***/ }), +/* 61 */ +/***/ (function(module, exports, __webpack_require__) { + +// 7.1.15 ToLength +var toInteger = __webpack_require__(41) + , min = Math.min; +module.exports = function(it){ + return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 +}; + +/***/ }), +/* 62 */ +/***/ (function(module, exports, __webpack_require__) { + +var classof = __webpack_require__(34) + , ITERATOR = __webpack_require__(0)('iterator') + , Iterators = __webpack_require__(14); +module.exports = __webpack_require__(1).getIteratorMethod = function(it){ + if(it != undefined)return it[ITERATOR] + || it['@@iterator'] + || Iterators[classof(it)]; +}; + +/***/ }), +/* 63 */ +/***/ (function(module, exports) { + + + +/***/ }), +/* 64 */ +/***/ (function(module, exports) { + +var toString = {}.toString; + +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; + + +/***/ }), +/* 65 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(process) { + +module.exports = Readable; + +/*<replacement>*/ +var processNextTick = __webpack_require__(48); +/*</replacement>*/ + +/*<replacement>*/ +var isArray = __webpack_require__(64); +/*</replacement>*/ + +/*<replacement>*/ +var Duplex; +/*</replacement>*/ + +Readable.ReadableState = ReadableState; + +/*<replacement>*/ +var EE = __webpack_require__(46).EventEmitter; + +var EElistenerCount = function (emitter, type) { + return emitter.listeners(type).length; +}; +/*</replacement>*/ + +/*<replacement>*/ +var Stream = __webpack_require__(67); +/*</replacement>*/ + +var Buffer = __webpack_require__(3).Buffer; +/*<replacement>*/ +var bufferShim = __webpack_require__(32); +/*</replacement>*/ + +/*<replacement>*/ +var util = __webpack_require__(19); +util.inherits = __webpack_require__(16); +/*</replacement>*/ + +/*<replacement>*/ +var debugUtil = __webpack_require__(153); +var debug = void 0; +if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); +} else { + debug = function () {}; +} +/*</replacement>*/ + +var BufferList = __webpack_require__(140); +var StringDecoder; + +util.inherits(Readable, Stream); + +var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; + +function prependListener(emitter, event, fn) { + // Sadly this is not cacheable as some libraries bundle their own + // event emitter implementation with them. + if (typeof emitter.prependListener === 'function') { + return emitter.prependListener(event, fn); + } else { + // This is a hack to make sure that our error handler is attached before any + // userland ones. NEVER DO THIS. This is here only because this code needs + // to continue to work with older versions of Node.js that do not include + // the prependListener() method. The goal is to eventually remove this hack. + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; + } +} + +function ReadableState(options, stream) { + Duplex = Duplex || __webpack_require__(11); + + options = options || {}; + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + + if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; + + // cast to ints. + this.highWaterMark = ~~this.highWaterMark; + + // A linked list is used to store data chunks instead of an array because the + // linked list can remove elements from the beginning faster than + // array.shift() + this.buffer = new BufferList(); + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // when piping, we only care about 'readable' events that happen + // after read()ing all the bytes and not getting any pushback. + this.ranOut = false; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) StringDecoder = __webpack_require__(47).StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +function Readable(options) { + Duplex = Duplex || __webpack_require__(11); + + if (!(this instanceof Readable)) return new Readable(options); + + this._readableState = new ReadableState(options, this); + + // legacy + this.readable = true; + + if (options && typeof options.read === 'function') this._read = options.read; + + Stream.call(this); +} + +// Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. +Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + + if (!state.objectMode && typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = bufferShim.from(chunk, encoding); + encoding = ''; + } + } + + return readableAddChunk(this, state, chunk, encoding, false); +}; + +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function (chunk) { + var state = this._readableState; + return readableAddChunk(this, state, chunk, '', true); +}; + +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; +}; + +function readableAddChunk(stream, state, chunk, encoding, addToFront) { + var er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (state.ended && !addToFront) { + var e = new Error('stream.push() after EOF'); + stream.emit('error', e); + } else if (state.endEmitted && addToFront) { + var _e = new Error('stream.unshift() after end event'); + stream.emit('error', _e); + } else { + var skipAdd; + if (state.decoder && !addToFront && !encoding) { + chunk = state.decoder.write(chunk); + skipAdd = !state.objectMode && chunk.length === 0; + } + + if (!addToFront) state.reading = false; + + // Don't add to the buffer if we've decoded to an empty string chunk and + // we're not in object mode + if (!skipAdd) { + // if we want the data now, just emit it. + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + + if (state.needReadable) emitReadable(stream); + } + } + + maybeReadMore(stream, state); + } + } else if (!addToFront) { + state.reading = false; + } + + return needMoreData(state); +} + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); +} + +// backwards compatibility. +Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = __webpack_require__(47).StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; + return this; +}; + +// Don't raise the hwm > 8MB +var MAX_HWM = 0x800000; +function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 to prevent increasing hwm excessively in + // tiny amounts + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + return n; +} + +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function howMuchToRead(n, state) { + if (n <= 0 || state.length === 0 && state.ended) return 0; + if (state.objectMode) return 1; + if (n !== n) { + // Only flow one buffer at a time + if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; + } + // If we're asking for more than the current hwm, then raise the hwm. + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + if (n <= state.length) return n; + // Don't have enough + if (!state.ended) { + state.needReadable = true; + return 0; + } + return state.length; +} + +// you can override either this method, or the async _read(n) below. +Readable.prototype.read = function (n) { + debug('read', n); + n = parseInt(n, 10); + var state = this._readableState; + var nOrig = n; + + if (n !== 0) state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + if (state.length === 0) endReadable(this); + return null; + } + + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + debug('need readable', doRead); + + // if we currently have less than the highWaterMark, then also read some + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } + + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } else if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (!state.reading) n = howMuchToRead(nOrig, state); + } + + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; + + if (ret === null) { + state.needReadable = true; + n = 0; + } else { + state.length -= n; + } + + if (state.length === 0) { + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (!state.ended) state.needReadable = true; + + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended) endReadable(this); + } + + if (ret !== null) this.emit('data', ret); + + return ret; +}; + +function chunkInvalid(state, chunk) { + var er = null; + if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + +function onEofChunk(stream, state) { + if (state.ended) return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); +} + +// Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. +function emitReadable(stream) { + var state = stream._readableState; + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream); + } +} + +function emitReadable_(stream) { + debug('emit readable'); + stream.emit('readable'); + flow(stream); +} + +// at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + processNextTick(maybeReadMore_, stream, state); + } +} + +function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break;else len = state.length; + } + state.readingMore = false; +} + +// abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. +Readable.prototype._read = function (n) { + this.emit('error', new Error('_read() is not implemented')); +}; + +Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; + + var endFn = doEnd ? onend : cleanup; + if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn); + + dest.on('unpipe', onunpipe); + function onunpipe(readable) { + debug('onunpipe'); + if (readable === src) { + cleanup(); + } + } + + function onend() { + debug('onend'); + dest.end(); + } + + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + + var cleanedUp = false; + function cleanup() { + debug('cleanup'); + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', cleanup); + src.removeListener('data', ondata); + + cleanedUp = true; + + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); + } + + // If the user pushes more data while we're writing to dest then we'll end up + // in ondata again. However, we only want to increase awaitDrain once because + // dest will only emit one 'drain' event for the multiple writes. + // => Introduce a guard on increasing awaitDrain. + var increasedAwaitDrain = false; + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + increasedAwaitDrain = false; + var ret = dest.write(chunk); + if (false === ret && !increasedAwaitDrain) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + // => Check whether `dest` is still a piping destination. + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { + debug('false write response, pause', src._readableState.awaitDrain); + src._readableState.awaitDrain++; + increasedAwaitDrain = true; + } + src.pause(); + } + } + + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); + } + + // Make sure our error handler is attached before userland ones. + prependListener(dest, 'error', onerror); + + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } + + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function () { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; +} + +Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) return this; + + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; + + if (!dest) dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this); + return this; + } + + // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var i = 0; i < len; i++) { + dests[i].emit('unpipe', this); + }return this; + } + + // try to find the right one. + var index = indexOf(state.pipes, dest); + if (index === -1) return this; + + state.pipes.splice(index, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; + + dest.emit('unpipe', this); + + return this; +}; + +// set up data events if they are asked for +// Ensure readable listeners eventually get something +Readable.prototype.on = function (ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + + if (ev === 'data') { + // Start flowing on next tick if stream isn't explicitly paused + if (this._readableState.flowing !== false) this.resume(); + } else if (ev === 'readable') { + var state = this._readableState; + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.emittedReadable = false; + if (!state.reading) { + processNextTick(nReadingNextTick, this); + } else if (state.length) { + emitReadable(this, state); + } + } + } + + return res; +}; +Readable.prototype.addListener = Readable.prototype.on; + +function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); +} + +// pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. +Readable.prototype.resume = function () { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + state.flowing = true; + resume(this, state); + } + return this; +}; + +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + processNextTick(resume_, stream, state); + } +} + +function resume_(stream, state) { + if (!state.reading) { + debug('resume read 0'); + stream.read(0); + } + + state.resumeScheduled = false; + state.awaitDrain = 0; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); +} + +Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + if (false !== this._readableState.flowing) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + return this; +}; + +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + while (state.flowing && stream.read() !== null) {} +} + +// wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. +Readable.prototype.wrap = function (stream) { + var state = this._readableState; + var paused = false; + + var self = this; + stream.on('end', function () { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) self.push(chunk); + } + + self.push(null); + }); + + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); + + // don't skip over falsy values in objectMode + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + + var ret = self.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); + + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function (method) { + return function () { + return stream[method].apply(stream, arguments); + }; + }(i); + } + } + + // proxy certain important events. + for (var n = 0; n < kProxyEvents.length; n++) { + stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n])); + } + + // when we try to consume some more bytes, simply unpause the + // underlying stream. + self._read = function (n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; + + return self; +}; + +// exposed for testing purposes only. +Readable._fromList = fromList; + +// Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromList(n, state) { + // nothing buffered + if (state.length === 0) return null; + + var ret; + if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { + // read it all, truncate the list + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + // read part of list + ret = fromListPartial(n, state.buffer, state.decoder); + } + + return ret; +} + +// Extracts only enough buffered data to satisfy the amount requested. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromListPartial(n, list, hasStrings) { + var ret; + if (n < list.head.data.length) { + // slice is the same for buffers and strings + ret = list.head.data.slice(0, n); + list.head.data = list.head.data.slice(n); + } else if (n === list.head.data.length) { + // first chunk is a perfect match + ret = list.shift(); + } else { + // result spans more than one buffer + ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); + } + return ret; +} + +// Copies a specified amount of characters from the list of buffered data +// chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBufferString(n, list) { + var p = list.head; + var c = 1; + var ret = p.data; + n -= ret.length; + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = str.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} + +// Copies a specified amount of bytes from the list of buffered data chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBuffer(n, list) { + var ret = bufferShim.allocUnsafe(n); + var p = list.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = buf.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} + +function endReadable(stream) { + var state = stream._readableState; + + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); + + if (!state.endEmitted) { + state.ended = true; + processNextTick(endReadableNT, state, stream); + } +} + +function endReadableNT(state, stream) { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } +} + +function forEach(xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } +} + +function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; +} +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10))) + +/***/ }), +/* 66 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. + + + +module.exports = Transform; + +var Duplex = __webpack_require__(11); + +/*<replacement>*/ +var util = __webpack_require__(19); +util.inherits = __webpack_require__(16); +/*</replacement>*/ + +util.inherits(Transform, Duplex); + +function TransformState(stream) { + this.afterTransform = function (er, data) { + return afterTransform(stream, er, data); + }; + + this.needTransform = false; + this.transforming = false; + this.writecb = null; + this.writechunk = null; + this.writeencoding = null; +} + +function afterTransform(stream, er, data) { + var ts = stream._transformState; + ts.transforming = false; + + var cb = ts.writecb; + + if (!cb) return stream.emit('error', new Error('no writecb in Transform class')); + + ts.writechunk = null; + ts.writecb = null; + + if (data !== null && data !== undefined) stream.push(data); + + cb(er); + + var rs = stream._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + stream._read(rs.highWaterMark); + } +} + +function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); + + Duplex.call(this, options); + + this._transformState = new TransformState(this); + + var stream = this; + + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; + + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; + + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; + + if (typeof options.flush === 'function') this._flush = options.flush; + } + + // When the writable side finishes, then flush out anything remaining. + this.once('prefinish', function () { + if (typeof this._flush === 'function') this._flush(function (er, data) { + done(stream, er, data); + });else done(stream); + }); +} + +Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; + +// This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. +Transform.prototype._transform = function (chunk, encoding, cb) { + throw new Error('_transform() is not implemented'); +}; + +Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); + } +}; + +// Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. +Transform.prototype._read = function (n) { + var ts = this._transformState; + + if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; + +function done(stream, er, data) { + if (er) return stream.emit('error', er); + + if (data !== null && data !== undefined) stream.push(data); + + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + var ws = stream._writableState; + var ts = stream._transformState; + + if (ws.length) throw new Error('Calling transform done when ws.length != 0'); + + if (ts.transforming) throw new Error('Calling transform done when still transforming'); + + return stream.push(null); +} + +/***/ }), +/* 67 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = __webpack_require__(46).EventEmitter; + + +/***/ }), +/* 68 */ +/***/ (function(module, exports, __webpack_require__) { + +var apply = Function.prototype.apply; + +// DOM APIs, for completeness + +exports.setTimeout = function() { + return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); +}; +exports.setInterval = function() { + return new Timeout(apply.call(setInterval, window, arguments), clearInterval); +}; +exports.clearTimeout = +exports.clearInterval = function(timeout) { + if (timeout) { + timeout.close(); + } +}; + +function Timeout(id, clearFn) { + this._id = id; + this._clearFn = clearFn; +} +Timeout.prototype.unref = Timeout.prototype.ref = function() {}; +Timeout.prototype.close = function() { + this._clearFn.call(window, this._id); +}; + +// Does not start the time, just sets up the members needed. +exports.enroll = function(item, msecs) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = msecs; +}; + +exports.unenroll = function(item) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = -1; +}; + +exports._unrefActive = exports.active = function(item) { + clearTimeout(item._idleTimeoutId); + + var msecs = item._idleTimeout; + if (msecs >= 0) { + item._idleTimeoutId = setTimeout(function onTimeout() { + if (item._onTimeout) + item._onTimeout(); + }, msecs); + } +}; + +// setimmediate attaches itself to the global object +__webpack_require__(144); +exports.setImmediate = setImmediate; +exports.clearImmediate = clearImmediate; + + +/***/ }), +/* 69 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.load = undefined; + +var _promise = __webpack_require__(85); + +var _promise2 = _interopRequireDefault(_promise); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var files = [ +// "gun_violence", +"mass_shootings"]; +var parse = __webpack_require__(134); + +var dataPromises = files.map(function (name) { + return fetch('./data/' + name + '.csv').then(function (rows) { + return rows.text(); + }).then(function (text) { + return new _promise2.default(function (resolve, reject) { + parse(text, {}, function (err, lines) { + return resolve(lines); + }); + }); + }).then(function (lines) { + console.log(name, lines); + var h = lines.shift(); + return { + name: name.replace(/_/g, ' '), + h: h, + lines: lines.filter(function (s) { + return !!s; + }) + }; + }); +}); +var allPromises = _promise2.default.all(dataPromises).then(function (data) { + return data.reduce(function (a, b) { + console.log(b); + a[b.name.replace(/-/g, '_')] = b; + return a; + }, {}); +}); +var load = function load() { + return allPromises; +}; + +exports.load = load; + +/***/ }), +/* 70 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var keys = {}; +var key_numbers = {}; +var letters = "zxcvbnmasdfghjklqwertyuiop"; +var numbers = "1234567890"; + +var callback = function callback() {}; + +letters.toUpperCase().split("").map(function (k, i) { + keys[k.charCodeAt(0)] = i; +}); + +numbers.split("").map(function (k, i) { + keys[k.charCodeAt(0)] = i + letters.length; + key_numbers[k.charCodeAt(0)] = true; +}); + +window.addEventListener("keydown", keydown, true); +function keydown(e) { + if (e.altKey || e.ctrlKey || e.metaKey) { + e.stopPropagation(); + return; + } + if (document.activeElement instanceof HTMLInputElement && e.keyCode in key_numbers) { + e.stopPropagation(); + return; + } + if (!(e.keyCode in keys)) return; + var index = keys[e.keyCode]; + if (e.shiftKey) index += letters.length; + index -= 7; + callback(index); +} + +function listen(fn) { + callback = fn; +} + +exports.default = { listen: listen }; + +/***/ }), +/* 71 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.note_values = exports.MidiWriter = undefined; +exports.midi_init = midi_init; +exports.play_note = play_note; + +var _tone = __webpack_require__(21); + +var _tone2 = _interopRequireDefault(_tone); + +var _webmidi = __webpack_require__(154); + +var _webmidi2 = _interopRequireDefault(_webmidi); + +var _scales = __webpack_require__(51); + +var _scales2 = _interopRequireDefault(_scales); + +var _util = __webpack_require__(30); + +var _kalimba = __webpack_require__(79); + +var _kalimba2 = _interopRequireDefault(_kalimba); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var midiDevice = void 0; + +var MidiWriter = exports.MidiWriter = __webpack_require__(136); + +var note_values = exports.note_values = [[8, '8 measures', 8 * 512], [4, '4 measures', 4 * 512], [2, '2 measures', 2 * 512], [1, 'whole note', 512], [1 / 2, 'half note', 256], [1 / 3, 'third note', [170, 170, 171]], [1 / 4, 'quarter note', 128], [1 / 5, 'fifth note', [51, 51, 51, 51, 52]], [1 / 6, 'sixth note', [85, 85, 86, 85, 85, 86]], [1 / 8, 'eighth note', 64], [1 / 10, 'tenth note', [25, 26, 26, 25, 26, 25, 26, 26, 25, 26]], [1 / 12, 'twelfth note', [21, 21, 22, 21, 21, 22, 21, 21, 22, 21, 21, 22]], [1 / 16, 'sixteenth note', 32], [1 / 32, 'thirtysecond note', 16]]; + +function midi_init() { + _webmidi2.default.enable(midi_ready); + function midi_ready(err) { + if (err) { + console.error('webmidi failed to initialize'); + return; + } + if (!_webmidi2.default.outputs.length) { + console.error('no MIDI output found'); + return; + } + console.log(_webmidi2.default.inputs); + console.log(_webmidi2.default.outputs); + if (_webmidi2.default.outputs.length > 1) { + var filtered = _webmidi2.default.outputs.filter(function (output) { + return output.name.match(/prodipe/i); + }); + if (filtered.length) { + // midiDevice = filtered[0] + } + } + // midiDevice = midiDevice || WebMidi.outputs[0] + // console.log(midiDevice.name) + } +} + +/* play a single note */ + +function play_note(index, duration) { + var channel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "all"; + var exporting = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + + // console.log(index) + var scale = _scales2.default.current(); + var freq = scale.index(index + Math.round(nx.offset.value), nx.octave.value); + var midi_note = (0, _util.ftom)(freq); + var cents = midi_note % 1; + if (cents > 0.5) { + midi_note += 1; + cents -= 1; + } + cents *= 2; + midi_note = Math.floor(midi_note); + if ((midiDevice || exporting) && midi_note > 127) return 0; + var note = _tone2.default.Frequency(Math.floor(midi_note), "midi").toNote(); + if (exporting || midiDevice) { + duration = duration || 60000 / _tone2.default.Transport.bpm.value; + if (!exporting) { + midiDevice.playNote(note, channel, { duration: duration }); + if (sendPitchBend) { + midiDevice.sendPitchBend(cents, channel); + } + } + } else { + _kalimba2.default.play(freq); + } + return note; +} + +/* play the next note in sequence */ + +function play_sequence(i, bounds, note_time) { + var channel = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "all"; + var rows = bounds.rows, + min = bounds.min, + max = bounds.max; + + var count = rows.length * rows[0].length; + if (i >= count) i = 0; + var y = Math.floor(i / rows[0].length); + var x = i % rows[0].length; + if (!x) console.log(y); + var n = rows[y][x]; + i += 1; + if (i >= count) i = 0; + var midi_note = play_note(norm(n, min, max) * nx.multiply.value, note_time, channel, exporting); + return [i, [midi_note]]; +} + +/* play the next row as an interval */ + +function play_interval_sequence(i, bounds, note_time) { + var channel = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "all"; + var rows = bounds.rows, + min = bounds.min, + max = bounds.max; + + var count = rows.length; + if (i >= count) i = 0; + var y = i % count; + var row = rows[y]; + if (!row) { + i = 0;return; + } + var row_min = Math.min.apply(Math, row); + // const row_max = Math.max.apply(Math, row) + var row_f0 = norm(row_min, min, max); + var row_root = row_f0 * nx.multiply.value; + var notes = row.map(function (n) { + var note = row_root + norm(n - row_min, diff.min, diff.max) * nx.interval.value; + play_note(note, note_time, channel, exporting); + }); + i += 1; + return [i, notes]; +} + +/* generate a 1-track midi file by calling the play function repeatedly */ + +function export_pattern_as_midi(datasetName, bounds, tempo, timingIndex, play_fn) { + var behavior = document.querySelector('#behavior').value; + var rows = bounds.rows; + + var count = behavior === 'sequence' ? rows[0].length * rows.length : rows.length; + var notes = void 0; + var note_time = void 0; + var timing = note_values[timingIndex][2]; + var midi_track = new MidiWriter.Track(); + midi_track.setTempo(tempo); + for (var i = 0, len = count; i < len; i++) { + notes = play_fn(i, bounds, exporting = true)[1]; + if (timing.length) { + note_time = timing[i % timing.length]; + } else { + note_time = timing; + } + midi_track.addEvent(new MidiWriter.NoteEvent({ pitch: notes, duration: 't' + note_time })); + } + var writer = new MidiWriter.Writer([midi_track]); + var blob = dataURItoBlob(writer.dataUri()); + saveAs(blob, 'Recording - ' + datasetName + '.mid'); +} + +/***/ }), +/* 72 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _keys = __webpack_require__(84); + +var _keys2 = _interopRequireDefault(_keys); + +exports.update_value_on_change = update_value_on_change; +exports.update_radio_value_on_change = update_radio_value_on_change; +exports.build_options = build_options; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* ui - update an int/float value */ + +function update_value_on_change(el, id, is_int, fn) { + var label = document.querySelector(id + ' + .val'); + var update = function update(v) { + label.innerHTML = is_int ? parseInt(v) : v.toFixed(2); + fn && fn(v); + }; + el.on('change', update); + update(el.value); + el.update = update; +} + +/* ui - update a radio button */ + +function update_radio_value_on_change(el, id, values, fn) { + var old_v = el.active; + var label = document.querySelector(id + ' + .val'); + var update = function update(v) { + if (v === -1) { + v = el.active = old_v; + } else { + old_v = v; + } + label.innerHTML = values[v][1]; + fn && fn(v); + }; + el.on('change', update); + update(el.active); + el.update = update; +} + +/* ui - bind/build a select dropdown */ + +function build_options(el, lists, fn) { + (0, _keys2.default)(lists).forEach(function (key) { + var list = lists[key]; + var option = document.createElement('option'); + option.innerHTML = list.name; + option.value = key; + el.appendChild(option); + }); + el.addEventListener('input', function (e) { + fn(e.target.value); + }); +} + +/***/ }), +/* 73 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.__esModule = true; + +var _assign = __webpack_require__(31); + +var _assign2 = _interopRequireDefault(_assign); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = _assign2.default || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; +}; + +/***/ }), +/* 74 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.__esModule = true; + +var _isIterable2 = __webpack_require__(82); + +var _isIterable3 = _interopRequireDefault(_isIterable2); + +var _getIterator2 = __webpack_require__(81); + +var _getIterator3 = _interopRequireDefault(_getIterator2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function () { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = (0, _getIterator3.default)(arr), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + return function (arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if ((0, _isIterable3.default)(Object(arr))) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; +}(); + +/***/ }), +/* 75 */ +/***/ (function(module, exports, __webpack_require__) { + +var __WEBPACK_AMD_DEFINE_RESULT__;/* FileSaver.js + * A saveAs() FileSaver implementation. + * 1.3.2 + * 2016-06-16 18:25:19 + * + * By Eli Grey, http://eligrey.com + * License: MIT + * See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md + */ + +/*global self */ +/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */ + +/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */ + +var saveAs = saveAs || (function(view) { + "use strict"; + // IE <10 is explicitly unsupported + if (typeof view === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) { + return; + } + var + doc = view.document + // only get URL when necessary in case Blob.js hasn't overridden it yet + , get_URL = function() { + return view.URL || view.webkitURL || view; + } + , save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a") + , can_use_save_link = "download" in save_link + , click = function(node) { + var event = new MouseEvent("click"); + node.dispatchEvent(event); + } + , is_safari = /constructor/i.test(view.HTMLElement) || view.safari + , is_chrome_ios =/CriOS\/[\d]+/.test(navigator.userAgent) + , throw_outside = function(ex) { + (view.setImmediate || view.setTimeout)(function() { + throw ex; + }, 0); + } + , force_saveable_type = "application/octet-stream" + // the Blob API is fundamentally broken as there is no "downloadfinished" event to subscribe to + , arbitrary_revoke_timeout = 1000 * 40 // in ms + , revoke = function(file) { + var revoker = function() { + if (typeof file === "string") { // file is an object URL + get_URL().revokeObjectURL(file); + } else { // file is a File + file.remove(); + } + }; + setTimeout(revoker, arbitrary_revoke_timeout); + } + , dispatch = function(filesaver, event_types, event) { + event_types = [].concat(event_types); + var i = event_types.length; + while (i--) { + var listener = filesaver["on" + event_types[i]]; + if (typeof listener === "function") { + try { + listener.call(filesaver, event || filesaver); + } catch (ex) { + throw_outside(ex); + } + } + } + } + , auto_bom = function(blob) { + // prepend BOM for UTF-8 XML and text/* types (including HTML) + // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF + if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) { + return new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type}); + } + return blob; + } + , FileSaver = function(blob, name, no_auto_bom) { + if (!no_auto_bom) { + blob = auto_bom(blob); + } + // First try a.download, then web filesystem, then object URLs + var + filesaver = this + , type = blob.type + , force = type === force_saveable_type + , object_url + , dispatch_all = function() { + dispatch(filesaver, "writestart progress write writeend".split(" ")); + } + // on any filesys errors revert to saving with object URLs + , fs_error = function() { + if ((is_chrome_ios || (force && is_safari)) && view.FileReader) { + // Safari doesn't allow downloading of blob urls + var reader = new FileReader(); + reader.onloadend = function() { + var url = is_chrome_ios ? reader.result : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;'); + var popup = view.open(url, '_blank'); + if(!popup) view.location.href = url; + url=undefined; // release reference before dispatching + filesaver.readyState = filesaver.DONE; + dispatch_all(); + }; + reader.readAsDataURL(blob); + filesaver.readyState = filesaver.INIT; + return; + } + // don't create more object URLs than needed + if (!object_url) { + object_url = get_URL().createObjectURL(blob); + } + if (force) { + view.location.href = object_url; + } else { + var opened = view.open(object_url, "_blank"); + if (!opened) { + // Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html + view.location.href = object_url; + } + } + filesaver.readyState = filesaver.DONE; + dispatch_all(); + revoke(object_url); + } + ; + filesaver.readyState = filesaver.INIT; + + if (can_use_save_link) { + object_url = get_URL().createObjectURL(blob); + setTimeout(function() { + save_link.href = object_url; + save_link.download = name; + click(save_link); + dispatch_all(); + revoke(object_url); + filesaver.readyState = filesaver.DONE; + }); + return; + } + + fs_error(); + } + , FS_proto = FileSaver.prototype + , saveAs = function(blob, name, no_auto_bom) { + return new FileSaver(blob, name || blob.name || "download", no_auto_bom); + } + ; + // IE 10+ (native saveAs) + if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) { + return function(blob, name, no_auto_bom) { + name = name || blob.name || "download"; + + if (!no_auto_bom) { + blob = auto_bom(blob); + } + return navigator.msSaveOrOpenBlob(blob, name); + }; + } + + FS_proto.abort = function(){}; + FS_proto.readyState = FS_proto.INIT = 0; + FS_proto.WRITING = 1; + FS_proto.DONE = 2; + + FS_proto.error = + FS_proto.onwritestart = + FS_proto.onprogress = + FS_proto.onwrite = + FS_proto.onabort = + FS_proto.onerror = + FS_proto.onwriteend = + null; + + return saveAs; +}( + typeof self !== "undefined" && self + || typeof window !== "undefined" && window + || this.content +)); +// `self` is undefined in Firefox for Android content script context +// while `this` is nsIContentFrameMessageManager +// with an attribute `content` that corresponds to the window + +if (typeof module !== "undefined" && module.exports) { + module.exports.saveAs = saveAs; +} else if (("function" !== "undefined" && __webpack_require__(151) !== null) && (__webpack_require__(152) !== null)) { + !(__WEBPACK_AMD_DEFINE_RESULT__ = function() { + return saveAs; + }.call(exports, __webpack_require__, exports, module), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); +} + + +/***/ }), +/* 76 */ +/***/ (function(module, exports, __webpack_require__) { + +(function webpackUniversalModuleDefinition(root, factory) { + if(true) + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["Nexus"] = factory(); + else + root["Nexus"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; +/******/ +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; + + var NexusUI = _interopRequire(__webpack_require__(1)); + + module.exports = NexusUI; + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; }; + + var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + exports.colors = colors; + exports.context = context; + exports.clock = clock; + Object.defineProperty(exports, "__esModule", { + value: true + }); + "use strict"; + + var Interfaces = _interopRequire(__webpack_require__(2)); + + var math = _interopRequire(__webpack_require__(5)); + + var Rack = _interopRequire(__webpack_require__(38)); + + var Tune = _interopRequire(__webpack_require__(40)); + + var Transform = _interopRequireWildcard(__webpack_require__(39)); + + var Counter = __webpack_require__(28); + var Radio = __webpack_require__(41); + var Drunk = __webpack_require__(27); + var Sequence = __webpack_require__(26); + var Matrix = __webpack_require__(25); + + var WAAClock = _interopRequire(__webpack_require__(42)); + + var Interval = _interopRequire(__webpack_require__(45)); + + /** + NexusUI => created as Nexus + */ + + var NexusUI = (function () { + function NexusUI(context) { + _classCallCheck(this, NexusUI); + + for (var key in Interfaces) { + this[key] = Interfaces[key]; + } + + for (var key in math) { + this[key] = math[key]; + } + + var Core = { + Rack: Rack + }; + + var Models = { + Counter: Counter, + Radio: Radio, + Drunk: Drunk, + Sequence: Sequence, + Matrix: Matrix + }; + + for (var key in Models) { + this[key] = Models[key]; + } + + for (var key in Core) { + this[key] = Core[key]; + } + + var DefaultContext = window.AudioContext || window.webkitAudioContext; + this._context = context || new DefaultContext(); + + this.tune = new Tune(); + this.note = this.tune.note.bind(this.tune); + + this.clock = new WAAClock(this._context); + this.clock.start(); + this.Interval = Interval; + + this.colors = { + accent: "#2bb", + fill: "#eee", + light: "#fff", + dark: "#333", + mediumLight: "#ccc", + mediumDark: "#666" + }; + + this.transform = Transform; + this.add = Transform.add; + + this.Add = {}; + for (var key in Interfaces) { + this.Add[key] = Transform.add.bind(this, key); + } + + /* create default component size */ + /* jshint ignore:start */ + var existingStylesheets = document.getElementsByTagName("style"); + var defaultSizeDeclaration = "[nexus-ui]{height:5000px;width:5000px}"; + var defaultStyleNode = document.createElement("style"); + defaultStyleNode.type = "text/css"; + defaultStyleNode.innerHTML = defaultSizeDeclaration; + if (existingStylesheets.length > 0) { + var parent = existingStylesheets[0].parentNode; + parent.insertBefore(defaultStyleNode, existingStylesheets[0]); + } else { + document.write("<style>" + defaultSizeDeclaration + "</style>"); + } + /* jshint ignore:end */ + } + + _createClass(NexusUI, { + context: { + get: function () { + return this._context; + }, + set: function (ctx) { + this.clock.stop(); + this._context = ctx; + this.clock = new WAAClock(this.context); + this.clock.start(); + } + } + }); + + return NexusUI; + })(); + + var Nexus = new NexusUI(); + + function colors() { + return Nexus.colors; + } + + function context() { + return Nexus.context; + } + + function clock() { + return Nexus.clock; + } + + exports["default"] = Nexus; + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + module.exports = { + Position: __webpack_require__(3), + Slider: __webpack_require__(14), + Toggle: __webpack_require__(15), + /* Range: require('./rangeslider'), + Waveform: require('./waveform'), */ + Button: __webpack_require__(16), + TextButton: __webpack_require__(18), + RadioButton: __webpack_require__(19), + Number: __webpack_require__(20), + Select: __webpack_require__(21), + Dial: __webpack_require__(22), + Piano: __webpack_require__(23), + Sequencer: __webpack_require__(24), + Pan2D: __webpack_require__(29), + Tilt: __webpack_require__(30), + Multislider: __webpack_require__(31), + Pan: __webpack_require__(33), + Envelope: __webpack_require__(34), + Spectrogram: __webpack_require__(35), + Meter: __webpack_require__(36), + Oscilloscope: __webpack_require__(37) + }; + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + + + "use strict"; + + var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; }; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var svg = __webpack_require__(4); + var Interface = __webpack_require__(6); + var Step = __webpack_require__(11); + + var Interaction = _interopRequireWildcard(__webpack_require__(12)); + + /** + * Position + * + * @description Two-dimensional touch slider. + * + * @demo <span nexus-ui="position"></span> + * + * @example + * var position = new Nexus.Position('#target') + * + * @example + * var position = new Nexus.Position('#target',{ + * 'size': [200,200], + * 'mode': 'absolute', // "absolute" or "relative" + * 'x': 0.5, // initial x value + * 'minX': 0, + * 'maxX': 1, + * 'stepX': 0, + * 'y': 0.5, // initial y value + * 'minY': 0, + * 'maxY': 1, + * 'stepY': 0 + * }) + * + * @output + * change + * Fires any time the interface's value changes. <br> + * The event data is an object with x and y properties containing the x and y values of the interface. + * + * @outputexample + * position.on('change',function(v) { + * console.log(v); + * }) + * + * + */ + + var Position = (function (_Interface) { + function Position() { + _classCallCheck(this, Position); + + var options = ["value"]; + + var defaults = { + size: [200, 200], + mode: "absolute", + minX: 0, + maxX: 1, + stepX: 0, + x: 0.5, + minY: 0, + maxY: 1, + stepY: 0, + y: 0.5 + }; + + _get(Object.getPrototypeOf(Position.prototype), "constructor", this).call(this, arguments, options, defaults); + + this._x = new Step(this.settings.minX, this.settings.maxX, this.settings.stepX, this.settings.x); + this._y = new Step(this.settings.minY, this.settings.maxY, this.settings.stepY, this.settings.y); + + this.position = { + x: new Interaction.Handle(this.settings.mode, "horizontal", [0, this.width], [this.height, 0]), + y: new Interaction.Handle(this.settings.mode, "vertical", [0, this.width], [this.height, 0]) + }; + this.position.x.value = this._x.normalized; + this.position.y.value = this._y.normalized; + + this.init(); + this.render(); + } + + _inherits(Position, _Interface); + + _createClass(Position, { + buildInterface: { + value: function buildInterface() { + + this.knob = svg.create("circle"); + this.element.appendChild(this.knob); + } + }, + sizeInterface: { + value: function sizeInterface() { + + this.position.x.resize([0, this.width], [this.height, 0]); + this.position.y.resize([0, this.width], [this.height, 0]); + + this._minDimension = Math.min(this.width, this.height); + + this.knobRadius = { + off: ~ ~(this._minDimension / 100) * 5 + 5 }; + this.knobRadius.on = this.knobRadius.off * 2; + + this.knob.setAttribute("cx", this.width / 2); + this.knob.setAttribute("cy", this.height / 2); + this.knob.setAttribute("r", this.knobRadius.off); + } + }, + colorInterface: { + value: function colorInterface() { + this.element.style.backgroundColor = this.colors.fill; + this.knob.setAttribute("fill", this.colors.accent); + } + }, + render: { + value: function render() { + if (this.clicked) { + // this.knobRadius = 30; + this.knob.setAttribute("r", this.knobRadius.on); + } else { + // this.knobRadius = 15; + this.knob.setAttribute("r", this.knobRadius.off); + } + + this.knobCoordinates = { + x: this._x.normalized * this.width, + y: this.height - this._y.normalized * this.height + }; + + this.knob.setAttribute("cx", this.knobCoordinates.x); + this.knob.setAttribute("cy", this.knobCoordinates.y); + } + }, + click: { + value: function click() { + this.position.x.anchor = this.mouse; + this.position.y.anchor = this.mouse; + this.move(); + } + }, + move: { + value: function move() { + if (this.clicked) { + this.position.x.update(this.mouse); + this.position.y.update(this.mouse); + this._x.updateNormal(this.position.x.value); + this._y.updateNormal(this.position.y.value); + this.emit("change", { + x: this._x.value, + y: this._y.value + }); + this.render(); + } + } + }, + release: { + value: function release() { + this.render(); + } + }, + x: { + + /** + * The interface's x value. When set, it will automatically adjust to fit min/max/step settings of the interface. + * @type {object} + * @example position.x = 0.5; + */ + + get: function () { + return this._x.value; + }, + set: function (value) { + this._x.update(value); + this.emit("change", { + x: this._x.value, + y: this._y.value + }); + this.render(); + } + }, + y: { + + /** + * The interface's y values. When set, it will automatically adjust to fit min/max/step settings of the interface. + * @type {object} + * @example position.x = 0.5; + */ + + get: function () { + return this._y.value; + }, + set: function (value) { + this._y.update(value); + this.emit("change", { + x: this._x.value, + y: this._y.value + }); + this.render(); + } + }, + normalized: { + get: function () { + return { + x: this._x.normalized, + y: this._y.normalized + }; + } + }, + minX: { + + /** + * The lower limit of value on the x axis + * @type {object} + */ + + get: function () { + return this._x.min; + }, + set: function (v) { + this._x.min = v; + this.render(); + } + }, + minY: { + + /** + * The lower limit of value on the y axis + * @type {object} + */ + + get: function () { + return this._y.min; + }, + set: function (v) { + this._y.min = v; + this.render(); + } + }, + maxX: { + + /** + * The upper limit of value on the x axis + * @type {object} + */ + + get: function () { + return this._x.max; + }, + set: function (v) { + this._x.max = v; + this.render(); + } + }, + maxY: { + + /** + * The upper limit of value on the y axis + * @type {object} + */ + + get: function () { + return this._y.max; + }, + set: function (v) { + this._y.max = v; + this.render(); + } + }, + stepX: { + + /** + * The incremental step of values on the x axis + * @type {object} + */ + + get: function () { + return this._x.step; + }, + set: function (v) { + this._x.step = v; + this.render(); + } + }, + stepY: { + + /** + * The incremental step of values on the y axis + * @type {object} + */ + + get: function () { + return this._y.step; + }, + set: function (v) { + this._y.step = v; + this.render(); + } + }, + mode: { + + /** + Absolute mode (position's value jumps to mouse click position) or relative mode (mouse drag changes value relative to its current position). Default: "absolute". + @type {string} + @example position.mode = "relative"; + */ + + get: function () { + return this.position.x.mode; + }, + set: function (v) { + this.position.x.mode = v; + this.position.y.mode = v; + } + } + }); + + return Position; + })(Interface); + + module.exports = Position; + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var math = __webpack_require__(5); + + module.exports = { + + create: function (type) { + return document.createElementNS("http://www.w3.org/2000/svg", type); + }, + + arc: function (x, y, radius, startAngle, endAngle) { + + var start = math.toCartesian(radius, endAngle); + var end = math.toCartesian(radius, startAngle); + + var largeArcFlag = endAngle - startAngle <= 180 ? "0" : "1"; + + var d = ["M", start.x + x, start.y + y, "A", radius, radius, 0, largeArcFlag, 0, end.x + x, end.y + y].join(" "); + + return d; + }, + + radialGradient: function (defs, numberOfStops) { + + var id = "gradient" + math.ri(100000000000); + var stops = []; + + var gradient = document.createElementNS("http://www.w3.org/2000/svg", "radialGradient"); + gradient.setAttribute("id", id); + gradient.setAttribute("cx", "50%"); + gradient.setAttribute("cy", "50%"); + gradient.setAttribute("r", "50%"); + + defs.appendChild(gradient); + + for (var i = 0; i < numberOfStops; i++) { + var _stop = document.createElementNS("http://www.w3.org/2000/svg", "stop"); + _stop.setAttribute("id", "stop" + i); + //stop.setAttribute('offset', '70%'); + //stop.setAttribute('stop-color', 'White'); + gradient.appendChild(_stop); + stops.push(_stop); + } + + return { + id: id, + stops: stops, + element: gradient + }; + } + + }; + +/***/ }), +/* 5 */ +/***/ (function(module, exports) { + + "use strict"; + + /** + * Limit a number to within a minimum and maximum + * @param {number} value Input value + * @param {number} min Lower limit + * @param {number} max Upper limit + * @return {number} The input value constrained within the lower and upper limits + * @example + * Nexus.clip(11,0,10) // returns 10 + * Nexus.clip(-1,0,10) // returns 0 + * Nexus.clip(5,0,10) // returns 5 + */ + + exports.clip = function (value, min, max) { + return Math.min(Math.max(value, min), max); + }; + + exports.normalize = function (value, min, max) { + return (value - min) / (max - min); + }; + + /** + * Scale a value from one range to another range. + * @param {number} inNum Input value + * @param {number} inMin Input range minimum + * @param {number} inMax Input range maximum + * @param {number} outMin Output range minimum + * @param {number} outMax Output range maximum + * @return {number} The input value scaled to its new range + * @example + * Nexus.scale(0.5,0,1,0,10) // returns 5 + * Nexus.scale(0.9,0,1,1,0) // returns 0.1 + */ + exports.scale = function (inNum, inMin, inMax, outMin, outMax) { + if (inMin === inMax) { + return outMin; + } + return (inNum - inMin) * (outMax - outMin) / (inMax - inMin) + outMin; + }; + + exports.toPolar = function (x, y) { + var r = Math.sqrt(x * x + y * y); + + var theta = Math.atan2(y, x); + if (theta < 0) { + theta = theta + 2 * Math.PI; + } + return { radius: r, angle: theta }; + }; + + exports.toCartesian = function (radius, angle) { + var cos = Math.cos(angle); + var sin = Math.sin(angle); + return { x: radius * cos, y: radius * sin * -1 }; + }; + /* + exports.polarToCartesian(centerX, centerY, radius, angleInDegrees) { + var angleInRadians = (angleInDegrees-90) * Math.PI / 180.0; + + return { + x: centerX + (radius * Math.cos(angleInRadians)), + y: centerY + (radius * Math.sin(angleInRadians)) + }; + } */ + + exports.prune = function (data, scale) { + return parseFloat(data.toFixed(scale)); + }; + + exports.invert = function (inNum) { + return exports.scale(inNum, 1, 0, 0, 1); + }; + + /** + * Convert a MIDi note number to a frequency value in equal temperament. + * @param {number} midi MIDI note value + * @return {number} Frequence value + * @example + * Nexus.mtof(60) // returns the frequency number of Middle C + */ + exports.mtof = function (midi) { + return Math.pow(2, (midi - 69) / 12) * 440; + }; + + /** + * Interpolate between two numbers + * @param {number} loc Interpolation index (0-1) + * @param {number} min Lower value + * @param {number} max Upper value + * @return {number} Interpolated value + * @example + * Nexus.interp(0.5,2,4) // returns 3 + * Nexus.interp(0.1,0,10) // returns 1 + */ + exports.interp = function (loc, min, max) { + return loc * (max - min) + min; + }; + + /** + * Return a random choice from a list of arguments + * @return {various} One random argument + * @example + * Nexus.pick(1,2,3,4) // returns 1, 2, 3, or 4 + * Nexus.pick(function1,function2) // returns either function1 or function2 + */ + exports.pick = function () { + return arguments[~ ~(Math.random() * arguments.length)]; + }; + + /** + * Returns an octave multiplier for frequency values + * @param {number} num Relative octave number (e.g. -1 for one octave down, 1 for one octave up) + * @return {number} Octave multiplier + * @example + * Nexus.octave(-1) // returns 0.5 + * Nexus.octave(0) // returns 1 + * Nexus.octave(1) // returns 2 + * Nexus.octave(2) // returns 4 + */ + exports.octave = function (num) { + return Math.pow(2, num); + }; + + /** + * Random integer generator. If no second argument is given, will return random integer from 0 to bound1. + * @param {number} bound1 Minimum random value + * @param {number} bound2 Maximum random value + * @return {number} Random integer between lower and upper boundary + * @example + * Nexus.ri(10) // returns random int from 0 to 10 + * Nexus.ri(20,2000) // returns random int from 20 to 2000 + */ + exports.ri = function (bound1, bound2) { + if (!bound2) { + bound2 = bound1; + bound1 = 0; + } + var low = Math.min(bound1, bound2); + var high = Math.max(bound1, bound2); + return Math.floor(Math.random() * (high - low) + low); + }; + + /** + * Random float number generator. If no second argument is given, will return random float from 0 to bound1. + * @param {number} bound1 Minimum random value + * @param {number} bound2 Maximum random value + * @return {number} Random float between lower and upper boundary + * @example + * Nexus.rf(1) // returns random float from 0 to 1 + * Nexus.rf(1,2) // returns random float from 1 to 2 + */ + exports.rf = function (bound1, bound2) { + if (!bound2) { + bound2 = bound1; + bound1 = 0; + } + var low = Math.min(bound1, bound2); + var high = Math.max(bound1, bound2); + return Math.random() * (high - low) + low; + }; + + exports.cycle = function (input, min, max) { + input++; + if (input >= max) { + input = min; + } + return input; + }; + + /** + * Average an array of numbers + * @param {Array} data Array of numbers to average + * @return {number} Average of the input data + * @example + * Nexus.average([0,2,4,6,8,10]) // returns 5 + */ + exports.average = function (data) { + var total = 0; + for (var i = 0; i < data.length; i++) { + total += data[i]; + } + return total / data.length; + }; + + /** + * Get the distance from one (x,y) point to another (x,y) point + * @param {number} x1 x of first point + * @param {number} y1 y of first point + * @param {number} x2 x of second point + * @param {number} y2 y of second poiny + * @return {number} Distance + * @example + * Nexus.distance(0,0,3,4) // returns 5 + */ + exports.distance = function (x1, y1, x2, y2) { + var a = x1 - x2; + var b = y1 - y2; + return Math.sqrt(a * a + b * b); + }; + + exports.gainToDB = function (gain) { + return 20 * Math.log10(gain); + }; + + /** + * Flip a coin, returning either 0 or 1 according to a probability + * @param {number} [odds=0.5] Likelihood of returning 1 + * @return {number} 1 or 0 + * @example + * Nexus.coin(0.1) // returns 1 (10% of the time) or 0 (90% of the time) + */ + exports.coin = function () { + var odds = arguments[0] === undefined ? 0.5 : arguments[0]; + + if (exports.rf(0, 1) < odds) { + return 1; + } else { + return 0; + } + }; + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var svg = __webpack_require__(4); + var dom = __webpack_require__(7); + var util = __webpack_require__(8); + var touch = __webpack_require__(9); + var EventEmitter = __webpack_require__(10); + + var colors = __webpack_require__(1).colors; + + /** + Interface + */ + + var Interface = (function (_EventEmitter) { + function Interface(args, options, defaults) { + _classCallCheck(this, Interface); + + _get(Object.getPrototypeOf(Interface.prototype), "constructor", this).call(this); + this.type = this.constructor.name; + this.settings = this.parseSettings(args, options, defaults); + this.mouse = {}; + this.wait = false; + this.colors = {}; + var defaultColors = colors(); // jshint ignore:line + this.colors.accent = defaultColors.accent; + this.colors.fill = defaultColors.fill; + this.colors.light = defaultColors.light; + this.colors.dark = defaultColors.dark; + this.colors.mediumLight = defaultColors.mediumLight; + this.colors.mediumDark = defaultColors.mediumDark; + } + + _inherits(Interface, _EventEmitter); + + _createClass(Interface, { + parseSettings: { + value: function parseSettings(args, options, defaults) { + + options.unshift("target"); + defaults.defaultSize = defaults.size.splice(0, 2); + defaults.size = false; + + var settings = { + target: document.body, + colors: {}, // should inherit from a colors module, + snapWithParent: true, + event: function event() {}, + component: false + }; + + for (var key in defaults) { + settings[key] = defaults[key]; + } + + for (var i = 0; i < args.length; i++) { + // grabs the next argument + var setting = args[i]; + // if it's an object, it must be the settings object + if (util.isObject(setting)) { + for (var key in setting) { + settings[key] = setting[key]; + } + // if it's a function, it must be the event setting + } else if (typeof setting === "function") { + settings.event = setting; + // otherwise, consider it one of the widget's custom options + } else if (options.length >= 1) { + // grab the first option -- i.e. 'target' + var key = options.splice(0, 1)[0]; + settings[key] = setting; + } + } + + /* handle common settings */ + + // target + this.parent = dom.parseElement(settings.target); + + // nexus-ui attribute + if (this.parent && this.parent instanceof HTMLElement && !settings.component) { + if (!this.parent.hasAttribute("nexus-ui")) { + this.parent.setAttribute("nexus-ui", ""); + } + } + + // size + + if (settings.size && Array.isArray(settings.size) && settings.snapWithParent) { + this.width = settings.size[0]; + this.height = settings.size[1]; + this.parent.style.width = this.width + "px"; + this.parent.style.height = this.height + "px"; + } else if (settings.snapWithParent && !settings.component) { + + this.width = parseFloat(window.getComputedStyle(this.parent, null).getPropertyValue("width").replace("px", "")); + this.height = parseFloat(window.getComputedStyle(this.parent, null).getPropertyValue("height").replace("px", "")); + + if (this.width == 5000) { + this.width = settings.defaultSize[0]; + this.parent.style.width = this.parent.width = this.width + "px"; + } + if (this.height == 5000) { + this.height = settings.defaultSize[1]; + this.parent.style.height = this.parent.height = this.height + "px"; + } + } else { + settings.size = settings.defaultSize; + this.width = settings.size[0]; + this.height = settings.size[1]; + } + + // event + if (settings.event) { + this.event = this.on("change", settings.event); + } else { + this.event = false; + } + + return settings; + } + }, + init: { + value: function init() { + this.buildFrame(); + this.buildInterface(); + this.sizeInterface(); + this.attachListeners(); + this.colorInterface(); + this.finalTouches(); + } + }, + buildFrame: { + value: function buildFrame() { + this.element = svg.create("svg"); + this.element.setAttribute("width", this.width); + this.element.setAttribute("height", this.height); + this.parent.appendChild(this.element); + } + }, + buildInterface: { + value: function buildInterface() {} + }, + sizeInterface: { + value: function sizeInterface() {} + }, + colorInterface: { + value: function colorInterface() {} + }, + attachListeners: { + value: function attachListeners() { + var _this = this; + + this.interactionTarget = this.interactionTarget || this.element; + + // Setup interaction + if (touch.exists) { + this.interactionTarget.addEventListener("touchstart", function (evt) { + return _this.preTouch(evt); + }); + this.interactionTarget.addEventListener("touchmove", function (evt) { + return _this.preTouchMove(evt); + }); + this.interactionTarget.addEventListener("touchend", function (evt) { + return _this.preTouchRelease(evt); + }); + } + this.boundPreMove = function (evt) { + return _this.preMove(evt); + }; + this.boundPreRelease = function (evt) { + return _this.preRelease(evt); + }; + this.interactionTarget.addEventListener("mousedown", function (evt) { + return _this.preClick(evt); + }); + } + }, + finalTouches: { + value: function finalTouches() { + this.element.style.cursor = "pointer"; + } + }, + preClick: { + value: function preClick(e) { + // 10000 getComputedStyle calls takes 100 ms. + // .:. one takes about .01ms + if (this.element instanceof HTMLElement) { + this.width = window.getComputedStyle(this.element, null).getPropertyValue("width").replace("px", ""); + } + // 10000 getComputedStyle calls takes 40 ms. + // .:. one takes about .004ms + this.offset = dom.findPosition(this.element); + this.mouse = dom.locateMouse(e, this.offset); + this.clicked = true; + this.click(); + this.moveEvent = document.addEventListener("mousemove", this.boundPreMove); + this.releaseEvent = document.addEventListener("mouseup", this.boundPreRelease); + this.emit("click"); + e.preventDefault(); + e.stopPropagation(); + } + }, + preMove: { + value: function preMove(e) { + var _this = this; + + if (!this.wait) { + this.mouse = dom.locateMouse(e, this.offset); + this.move(); + this.wait = true; + setTimeout(function () { + _this.wait = false; + }, 25); + } + e.preventDefault(); + e.stopPropagation(); + } + }, + preRelease: { + value: function preRelease(e) { + this.mouse = dom.locateMouse(e, this.offset); + this.clicked = false; + this.release(); + this.emit("release"); + document.removeEventListener("mousemove", this.boundPreMove); + document.removeEventListener("mouseup", this.boundPreRelease); + e.preventDefault(); + e.stopPropagation(); + } + }, + click: { + value: function click() {} + }, + move: { + value: function move() {} + }, + release: { + value: function release() {} + }, + preTouch: { + + /* touch */ + + value: function preTouch(e) { + if (this.element instanceof HTMLElement) { + this.width = window.getComputedStyle(this.element, null).getPropertyValue("width").replace("px", ""); + } + this.offset = dom.findPosition(this.element); + this.mouse = dom.locateTouch(e, this.offset); + this.clicked = true; + this.touch(e); + this.emit("click"); + e.preventDefault(); + e.stopPropagation(); + } + }, + preTouchMove: { + value: function preTouchMove(e) { + if (this.clicked) { + this.mouse = dom.locateTouch(e, this.offset); + this.touchMove(); + e.preventDefault(); + e.stopPropagation(); + } + } + }, + preTouchRelease: { + value: function preTouchRelease(e) { + this.mouse = dom.locateTouch(e, this.offset); + this.clicked = false; + this.touchRelease(); + this.emit("release"); + e.preventDefault(); + e.stopPropagation(); + } + }, + touch: { + value: function touch() { + this.click(); + } + }, + touchMove: { + value: function touchMove() { + this.move(); + } + }, + touchRelease: { + value: function touchRelease() { + this.release(); + } + }, + resize: { + + /** + * Resize the interface + * @param width {number} New width in pixels + * @param height {number} New height in pixels + * + * @example + * button.resize(100,100); + */ + + value: function resize(width, height) { + this.width = width; + this.height = height; + this.parent.style.width = this.width + "px"; + this.parent.style.height = this.height + "px"; + this.element.setAttribute("width", this.width); + this.element.setAttribute("height", this.height); + this.sizeInterface(); + } + }, + empty: { + value: function empty() { + while (this.element.lastChild) { + this.element.removeChild(this.element.lastChild); + } + } + }, + destroy: { + + /** + * Remove the interface from the page and cancel its event listener(s). + * + * @example + * button.destroy(); + */ + + value: function destroy() { + this.empty(); + this.parent.removeChild(this.element); + this.removeAllListeners(); + if (this.instrument) { + delete this.instrument[this.id]; + } + this.customDestroy(); + } + }, + customDestroy: { + value: function customDestroy() {} + }, + colorize: { + value: function colorize(type, color) { + this.colors[type] = color; + this.colorInterface(); + } + } + }); + + return Interface; + })(EventEmitter); + + module.exports = Interface; + +/***/ }), +/* 7 */ +/***/ (function(module, exports) { + + "use strict"; + + exports.findPosition = function (el) { + var viewportOffset = el.getBoundingClientRect(); + var top = viewportOffset.top + window.scrollY; + var left = viewportOffset.left + window.scrollX; + return { top: top, left: left }; + }; + + exports.parseElement = function (parent) { + if (typeof parent === "string") { + parent = document.getElementById(parent.replace("#", "")); + } + + if (parent instanceof HTMLElement || parent instanceof SVGElement) { + return parent; + } else { + return "No valid parent argument"; + } + }; + + exports.locateMouse = function (e, offset) { + return { + x: e.pageX - offset.left, + y: e.pageY - offset.top + }; + }; + + exports.locateTouch = function (e, offset) { + return { + x: e.targetTouches.length ? e.targetTouches[0].pageX - offset.left : false, + y: e.targetTouches.length ? e.targetTouches[0].pageY - offset.top : false + }; + }; + + exports.SmartCanvas = function (parent) { + var _this = this; + + this.element = document.createElement("canvas"); + this.context = this.element.getContext("2d"); + parent.appendChild(this.element); + + this.resize = function (w, h) { + _this.element.width = w * 2; + _this.element.height = h * 2; + _this.element.style.width = w + "px"; + _this.element.style.height = h + "px"; + }; + }; + +/***/ }), +/* 8 */ +/***/ (function(module, exports) { + + "use strict"; + + exports.isObject = function (obj) { + if (typeof obj === "object" && !Array.isArray(obj) && obj !== null && obj instanceof SVGElement === false && obj instanceof HTMLElement === false) { + return true; + } else { + return false; + } + }; + +/***/ }), +/* 9 */ +/***/ (function(module, exports) { + + "use strict"; + + exports.exists = "ontouchstart" in document.documentElement; + +/***/ }), +/* 10 */ +/***/ (function(module, exports) { + + // Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; + } + module.exports = EventEmitter; + + // Backwards-compat with node 0.10.x + EventEmitter.EventEmitter = EventEmitter; + + EventEmitter.prototype._events = undefined; + EventEmitter.prototype._maxListeners = undefined; + + // By default EventEmitters will print a warning if more than 10 listeners are + // added to it. This is a useful default which helps finding memory leaks. + EventEmitter.defaultMaxListeners = 10; + + // Obviously not all Emitters should be limited to 10. This function allows + // that to be increased. Set to zero for unlimited. + EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; + }; + + EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; + + if (!this._events) + this._events = {}; + + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } + } + } + + handler = this._events[type]; + + if (isUndefined(handler)) + return false; + + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); + } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } + + return true; + }; + + EventEmitter.prototype.addListener = function(type, listener) { + var m; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events) + this._events = {}; + + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); + + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; + } + + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } + } + + return this; + }; + + EventEmitter.prototype.on = EventEmitter.prototype.addListener; + + EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + var fired = false; + + function g() { + this.removeListener(type, g); + + if (!fired) { + fired = true; + listener.apply(this, arguments); + } + } + + g.listener = listener; + this.on(type, g); + + return this; + }; + + // emits a 'removeListener' event iff the listener was removed + EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events || !this._events[type]) + return this; + + list = this._events[type]; + length = list.length; + position = -1; + + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } + + if (position < 0) + return this; + + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); + } + + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } + + return this; + }; + + EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; + + if (!this._events) + return this; + + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; + } + + listeners = this._events[type]; + + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; + + return this; + }; + + EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; + }; + + EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; + + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; + } + return 0; + }; + + EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); + }; + + function isFunction(arg) { + return typeof arg === 'function'; + } + + function isNumber(arg) { + return typeof arg === 'number'; + } + + function isObject(arg) { + return typeof arg === 'object' && arg !== null; + } + + function isUndefined(arg) { + return arg === void 0; + } + + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var math = __webpack_require__(5); + + /** + Creates a steppable value with minimum, maximum, and step size. This is used in many interfaces to constrict their values to certain ranges. + @param {number} [min=0] minimum + @param {number} [max=1] maximum + @param {number} [step=0] + @param {number} [value=0] initial value + @returns {Object} Step + */ + + var Step = (function () { + function Step() { + var min = arguments[0] === undefined ? 0 : arguments[0]; + var max = arguments[1] === undefined ? 1 : arguments[1]; + var step = arguments[2] === undefined ? 0 : arguments[2]; + var value = arguments[3] === undefined ? 0 : arguments[3]; + + _classCallCheck(this, Step); + + //Object.assign(this,{min,max,step}); + //Cannot use Object.assign because not supported in Safari. + //I would expect for Babel to take care of this but it is not. + this.min = min; + this.max = max; + this.step = step; + this.value = value; + this.changed = false; + this.oldValue = false; + this.update(this.value); + } + + _createClass(Step, { + update: { + + /** + Update with a new value. The value will be auto-adjusted to fit the min/max/step. + @param {number} value + */ + + value: function update(value) { + if (this.step) { + // this.value = math.clip(Math.round(value / (this.step)) * this.step, this.min,this.max); + this.value = math.clip(Math.round((value - this.min) / this.step) * this.step + this.min, this.min, this.max); + } else { + this.value = math.clip(value, this.min, this.max); + } + if (this.oldValue !== this.value) { + this.oldValue = this.value; + this.changed = true; + } else { + this.changed = false; + } + return this.value; + } + }, + updateNormal: { + + /** + Update with a normalized value 0-1. + @param {number} value + */ + + value: function updateNormal(value) { + this.value = math.scale(value, 0, 1, this.min, this.max); + return this.update(this.value); + } + }, + normalized: { + + /** + Get a normalized version of this.value . Not settable. + */ + + get: function () { + return math.normalize(this.value, this.min, this.max); + } + } + }); + + return Step; + })(); + + module.exports = Step; + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + "use strict"; + + var math = _interopRequire(__webpack_require__(5)); + + var ToggleModel = _interopRequire(__webpack_require__(13)); + + /* + how to use : + + dial.interaction = new Handle('radial','relative',this.width,this.height); + // dial.interaction.mode = 'relative' + // dial.interaction.direction = 'radial' + + on click: + dial.interaction.anchor = this.mouse; + + on move: + dial.interaction.update(this.mouse); + + console.log( dial.interaction.value ); should be a normalized value. + + */ + + /* + absolute/relative are property: mode + radial/vertical/horizontal/2d are property: direction + + plan : + + if relative -- + NO on click, get value offset between current value and click value. + NO on move, use click value - offset + INSTEAD + use delta -- bc vertical motion on dial is impossible otherwise + also allow to set sensitivity + + */ + + var Handle = exports.Handle = (function () { + function Handle() { + var mode = arguments[0] === undefined ? "absolute" : arguments[0]; + var direction = arguments[1] === undefined ? "vertical" : arguments[1]; + var xbound = arguments[2] === undefined ? [0, 100] : arguments[2]; + var ybound = arguments[3] === undefined ? [0, 100] : arguments[3]; + + _classCallCheck(this, Handle); + + this.mode = mode; + this.direction = direction; + this.previous = 0; + this.value = 0; + this.sensitivity = 1; + this.resize(xbound, ybound); + } + + _createClass(Handle, { + resize: { + value: function resize(xbound, ybound) { + this.boundary = { + min: { + x: xbound[0], + y: ybound[0] + }, + max: { + x: xbound[1], + y: ybound[1] + }, + center: { + x: (xbound[1] - xbound[0]) / 2 + xbound[0], + y: (ybound[1] - ybound[0]) / 2 + ybound[0] + } + }; + } + }, + anchor: { + set: function (mouse) { + this._anchor = this.convertPositionToValue(mouse); + }, + get: function () { + return this._anchor; + } + }, + update: { + value: function update(mouse) { + if (this.mode === "relative") { + var increment = this.convertPositionToValue(mouse) - this.anchor; + if (Math.abs(increment) > 0.5) { + increment = 0; + } + this.anchor = mouse; + this.value = this.value + increment * this.sensitivity; + } else { + this.value = this.convertPositionToValue(mouse); + } + this.value = math.clip(this.value, 0, 1); + } + }, + convertPositionToValue: { + value: function convertPositionToValue(current) { + switch (this.direction) { + case "radial": + var position = math.toPolar(current.x - this.boundary.center.x, current.y - this.boundary.center.y); + position = position.angle / (Math.PI * 2); + position = (position - 0.25 + 1) % 1; + return position; + case "vertical": + return math.scale(current.y, this.boundary.min.y, this.boundary.max.y, 0, 1); + case "horizontal": + return math.scale(current.x, this.boundary.min.x, this.boundary.max.x, 0, 1); + } + } + } + }); + + return Handle; + })(); + + var Button = exports.Button = (function () { + function Button() { + var mode = arguments[0] === undefined ? "button" : arguments[0]; + + _classCallCheck(this, Button); + + this.mode = mode; + this.state = new ToggleModel(); + this.paintbrush = false; + } + + _createClass(Button, { + click: { + value: function click() { + switch (this.mode) { + case "impulse": + this.state.on(); + if (this.timeout) { + clearTimeout(this.timeout); + } + this.timeout = setTimeout(this.state.off.bind(this), 30); + this.emit("change", this.state); + break; + case "button": + this.turnOn(); + this.emit("change", this.state); + break; + case "aftertouch": + this.position = { + x: math.clip(this.mouse.x / this.width, 0, 1), + y: math.clip(1 - this.mouse.y / this.height, 0, 1) + }; + this.turnOn(); + this.emit("change", { + state: this.state, + x: this.position.x, + y: this.position.y }); + break; + case "toggle": + this.flip(); + this.emit("change", this.state); + break; + } + } + }, + move: { + value: function move() { + if (this.mode === "aftertouch") { + this.position = { + x: math.clip(this.mouse.x / this.width, 0, 1), + y: math.clip(1 - this.mouse.y / this.height, 0, 1) + }; + this.emit("change", { + state: this.state, + x: this.position.x, + y: this.position.y }); + this.render(); + } + } + }, + release: { + value: function release() { + switch (this.mode) { + case "button": + this.turnOff(); + this.emit("change", this.state); + break; + case "aftertouch": + this.turnOff(); + this.position = { + x: this.mouse.x / this.width, + y: 1 - this.mouse.y / this.height + }; + this.emit("change", { + state: this.state, + x: this.position.x, + y: this.position.y }); + break; + } + } + } + }); + + return Button; + })(); + +/***/ }), +/* 13 */ +/***/ (function(module, exports) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var Toggle = (function () { + function Toggle(state) { + _classCallCheck(this, Toggle); + + this.state = state || false; + } + + _createClass(Toggle, { + flip: { + value: function flip(state) { + if (state || state === false) { + this.state = state; + } else { + this.state = !this.state; + } + } + }, + on: { + value: function on() { + this.state = true; + } + }, + off: { + value: function off() { + this.state = false; + } + } + }); + + return Toggle; + })(); + + module.exports = Toggle; + +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; }; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var svg = __webpack_require__(4); + var Interface = __webpack_require__(6); + var Step = __webpack_require__(11); + + var Interaction = _interopRequireWildcard(__webpack_require__(12)); + + /** + * Slider + * + * @description Horizontal or vertical slider with settable interaction modes. + * + * @demo <span nexus-ui="slider" step=0.2></span> + * + * @example + * var slider = new Nexus.Slider('#target') + * + * @example + * var slider = new Nexus.Slider('#target',{ + * 'size': [120,20], + * 'mode': 'relative', // 'relative' or 'absolute' + * 'min': 0, + * 'max': 1, + * 'step': 0, + * 'value': 0 + * }) + * + * @output + * change + * Fires when the interface's value changes. <br> + * Event data: <i>number</i> The number value of the interface. + * + * @outputexample + * slider.on('change',function(v) { + * console.log(v); + * }) + * + * + */ + + var Slider = (function (_Interface) { + function Slider() { + _classCallCheck(this, Slider); + + var options = ["min", "max", "value"]; + + var defaults = { + size: [120, 20], + mode: "relative", // 'relative' or 'absolute' + min: 0, + max: 1, + step: 0, + value: 0 + }; + + _get(Object.getPrototypeOf(Slider.prototype), "constructor", this).call(this, arguments, options, defaults); + + this.orientation = "vertical"; // This will change automatically to 'horizontal'if the interface is wider than it is tall. + + this._value = new Step(this.settings.min, this.settings.max, this.settings.step, this.settings.value); + + this.position = new Interaction.Handle(this.settings.mode, this.orientation, [0, this.width], [this.height, 0]); + this.position.value = this._value.normalized; + + this.init(); + + this.position.direction = this.orientation; + + this.emit("change", this.value); + } + + _inherits(Slider, _Interface); + + _createClass(Slider, { + buildInterface: { + value: function buildInterface() { + + this.bar = svg.create("rect"); + this.fillbar = svg.create("rect"); + this.knob = svg.create("circle"); + + this.element.appendChild(this.bar); + this.element.appendChild(this.fillbar); + this.element.appendChild(this.knob); + } + }, + sizeInterface: { + value: function sizeInterface() { + + if (this.width < this.height) { + this.orientation = "vertical"; + } else { + this.orientation = "horizontal"; + } + + if (this.position) { + this.position.resize([0, this.width], [this.height, 0]); + } + + var x = undefined, + y = undefined, + w = undefined, + h = undefined, + barOffset = undefined, + cornerRadius = undefined; + this.knobData = { + level: 0, + r: 0 + }; + + if (this.orientation === "vertical") { + this.thickness = this.width / 2; + x = this.width / 2; + y = 0; + w = this.thickness; + h = this.height; + this.knobData.r = this.thickness * 0.8; + this.knobData.level = h - this.knobData.r - this.normalized * (h - this.knobData.r * 2); + barOffset = "translate(" + this.thickness * -1 / 2 + ",0)"; + cornerRadius = w / 2; + } else { + this.thickness = this.height / 2; + x = 0; + y = this.height / 2; + w = this.width; + h = this.thickness; + this.knobData.r = this.thickness * 0.8; + this.knobData.level = this.normalized * (w - this.knobData.r * 2) + this.knobData.r; + barOffset = "translate(0," + this.thickness * -1 / 2 + ")"; + cornerRadius = h / 2; + } + + this.bar.setAttribute("x", x); + this.bar.setAttribute("y", y); + this.bar.setAttribute("transform", barOffset); + this.bar.setAttribute("rx", cornerRadius); // corner radius + this.bar.setAttribute("ry", cornerRadius); + this.bar.setAttribute("width", w); + this.bar.setAttribute("height", h); + + if (this.orientation === "vertical") { + this.fillbar.setAttribute("x", x); + this.fillbar.setAttribute("y", this.knobData.level); + this.fillbar.setAttribute("width", w); + this.fillbar.setAttribute("height", h - this.knobData.level); + } else { + this.fillbar.setAttribute("x", 0); + this.fillbar.setAttribute("y", y); + this.fillbar.setAttribute("width", this.knobData.level); + this.fillbar.setAttribute("height", h); + } + this.fillbar.setAttribute("transform", barOffset); + this.fillbar.setAttribute("rx", cornerRadius); + this.fillbar.setAttribute("ry", cornerRadius); + + if (this.orientation === "vertical") { + this.knob.setAttribute("cx", x); + this.knob.setAttribute("cy", this.knobData.level); + } else { + this.knob.setAttribute("cx", this.knobData.level); + this.knob.setAttribute("cy", y); + } + this.knob.setAttribute("r", this.knobData.r); + } + }, + colorInterface: { + value: function colorInterface() { + this.bar.setAttribute("fill", this.colors.fill); + this.fillbar.setAttribute("fill", this.colors.accent); + this.knob.setAttribute("fill", this.colors.accent); + } + }, + render: { + value: function render() { + if (!this.clicked) { + this.knobData.r = this.thickness * 0.75; + } + this.knob.setAttribute("r", this.knobData.r); + + if (this.orientation === "vertical") { + this.knobData.level = this.knobData.r + this._value.normalized * (this.height - this.knobData.r * 2); + this.knob.setAttribute("cy", this.height - this.knobData.level); + this.fillbar.setAttribute("y", this.height - this.knobData.level); + this.fillbar.setAttribute("height", this.knobData.level); + } else { + this.knobData.level = this._value.normalized * (this.width - this.knobData.r * 2) + this.knobData.r; + this.knob.setAttribute("cx", this.knobData.level); + this.fillbar.setAttribute("x", 0); + this.fillbar.setAttribute("width", this.knobData.level); + } + } + }, + click: { + value: function click() { + this.knobData.r = this.thickness * 0.9; + this.position.anchor = this.mouse; + this.move(); + } + }, + move: { + value: function move() { + if (this.clicked) { + this.position.update(this.mouse); + this._value.updateNormal(this.position.value); + this.emit("change", this._value.value); + this.render(); + } + } + }, + release: { + value: function release() { + this.render(); + } + }, + normalized: { + get: function () { + return this._value.normalized; + } + }, + value: { + + /** + The slider's current value. If set manually, will update the interface and trigger the output event. + @type {number} + @example slider.value = 10; + */ + + get: function () { + return this._value.value; + }, + set: function (v) { + this._value.update(v); + this.position.value = this._value.normalized; + this.emit("change", this._value.value); + this.render(); + } + }, + min: { + + /** + Lower limit of the sliders's output range + @type {number} + @example slider.min = 1000; + */ + + get: function () { + return this._value.min; + }, + set: function (v) { + this._value.min = v; + } + }, + max: { + + /** + Upper limit of the slider's output range + @type {number} + @example slider.max = 1000; + */ + + get: function () { + return this._value.max; + }, + set: function (v) { + this._value.max = v; + } + }, + step: { + + /** + The increment that the slider's value changes by. + @type {number} + @example slider.step = 5; + */ + + get: function () { + return this._value.step; + }, + set: function (v) { + this._value.step = v; + } + }, + mode: { + + /** + Absolute mode (slider's value jumps to mouse click position) or relative mode (mouse drag changes value relative to its current position). Default: "relative". + @type {string} + @example slider.mode = "relative"; + */ + + get: function () { + return this.position.mode; + }, + set: function (v) { + this.position.mode = v; + } + } + }); + + return Slider; + })(Interface); + + module.exports = Slider; + +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var svg = __webpack_require__(4); + var ToggleModel = __webpack_require__(13); + var Interface = __webpack_require__(6); + + /** + * Toggle + * + * @description Binary switch + * + * @demo <span nexus-ui="toggle"></span> + * + * @example + * var toggle = new Nexus.Toggle('#target') + * + * @example + * var toggle = new Nexus.Toggle('#target',{ + * 'size': [40,20], + * 'state': false + * }) + * + * @output + * change + * Fires any time the interface's value changes. <br> + * Parameter: The boolean state of the interface. + * + * @outputexample + * toggle.on('change',function(v) { + * console.log(v); + * }) + * + * + */ + + var Toggle = (function (_Interface) { + function Toggle() { + _classCallCheck(this, Toggle); + + var options = ["value"]; + + var defaults = { + size: [40, 20], + target: false, + state: false + }; + + _get(Object.getPrototypeOf(Toggle.prototype), "constructor", this).call(this, arguments, options, defaults); + + this._state = new ToggleModel(this.settings.state); + + this.init(); + } + + _inherits(Toggle, _Interface); + + _createClass(Toggle, { + buildInterface: { + value: function buildInterface() { + + this.bar = svg.create("rect"); + this.knob = svg.create("circle"); + this.element.appendChild(this.bar); + this.element.appendChild(this.knob); + } + }, + sizeInterface: { + value: function sizeInterface() { + + if (this.height < this.width / 2) { + this.knobSize = this.height / 2; + } else { + this.knobSize = this.width / 4; + } + + this.bar.setAttribute("x", this.width / 2 - this.knobSize * 1.5); + this.bar.setAttribute("y", this.height / 2 - this.knobSize / 2); + this.bar.setAttribute("rx", this.knobSize / 2); + this.bar.setAttribute("ry", this.knobSize / 2); + this.bar.setAttribute("width", this.knobSize * 3); + this.bar.setAttribute("height", this.knobSize); + + this.knob.setAttribute("cx", this.width / 2 - this.knobSize); + this.knob.setAttribute("cy", this.height / 2); + this.knob.setAttribute("r", this.knobSize); + } + }, + colorInterface: { + value: function colorInterface() { + this.knob.setAttribute("fill", this.colors.accent); + this.render(); + } + }, + render: { + value: function render() { + if (!this.state) { + this.knob.setAttribute("cx", this.width / 2 - this.knobSize); + this.bar.setAttribute("fill", this.colors.fill); + } else { + this.knob.setAttribute("cx", this.width / 2 + this.knobSize); + this.bar.setAttribute("fill", this.colors.accent); + } + } + }, + click: { + value: function click() { + this.flip(); + this.render(); + this.emit("change", this.state); + } + }, + state: { + + /** + Whether the toggle is currently on or off. Setting this property will update the toggle interface and trigger the output event. + @type {boolean} + @example toggle.state = false; + */ + + get: function () { + return this._state.state; + }, + set: function (value) { + this._state.flip(value); + this.emit("change", this.state); + this.render(); + } + }, + flip: { + + /** + * Switch the toggle state to its opposite state + * @example + * toggle.flip(); + */ + + value: function flip() { + this._state.flip(); + this.render(); + } + } + }); + + return Toggle; + })(Interface); + + module.exports = Toggle; + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var svg = __webpack_require__(4); + var ButtonTemplate = __webpack_require__(17); + + /** + * Button + * + * @description Circular button with optional aftertouch. + * + * @demo <span nexus-ui="button"></span> + * + * @example + * var button = new Nexus.Button('#target') + * + * @example + * var button = new Nexus.Button('#target',{ + * 'size': [80,80], + * 'mode': 'aftertouch', + * 'state': false + * }) + * + * @output + * change + * Fires any time the interface's value changes. <br> + * In <b>button mode</b>, <b>toggle mode</b>, and <b>impulse mode</b>, the output data is a boolean describing the state of the button.<br> + * In <b>aftertouch mode</b>, the output data is an object containing x (0-1) and y (0-1) positions of aftertouch. + * + * @outputexample + * button.on('change',function(v) { + * // v is the value of the button + * console.log(v); + * }) + * + */ + + var Button = (function (_ButtonTemplate) { + function Button() { + _classCallCheck(this, Button); + + var options = ["mode"]; + + var defaults = { + size: [80, 80], + mode: "aftertouch", // button, aftertouch, impulse, toggle + state: false + }; + + _get(Object.getPrototypeOf(Button.prototype), "constructor", this).call(this, arguments, options, defaults); + + /** + * Interaction mode: supports "button", "aftertouch", "impulse", or "toggle" + * @type {string} + * @example button.mode = 'toggle'; + */ + this.mode = this.settings.mode; + + this.init(); + this.render(); + } + + _inherits(Button, _ButtonTemplate); + + _createClass(Button, { + buildInterface: { + value: function buildInterface() { + this.pad = svg.create("circle"); + this.element.appendChild(this.pad); + + this.interactionTarget = this.pad; + + // only used if in 'aftertouch' mode + this.defs = svg.create("defs"); + this.element.appendChild(this.defs); + + this.gradient = svg.radialGradient(this.defs, 2); + + this.gradient.stops[0].setAttribute("offset", "30%"); + + this.gradient.stops[1].setAttribute("offset", "100%"); + } + }, + sizeInterface: { + value: function sizeInterface() { + + this.pad.setAttribute("cx", this.width / 2); + this.pad.setAttribute("cy", this.height / 2); + this.pad.setAttribute("r", Math.min(this.width, this.height) / 2 - this.width / 40); + this.pad.setAttribute("stroke-width", this.width / 20); + } + }, + colorInterface: { + value: function colorInterface() { + + this.gradient.stops[0].setAttribute("stop-color", this.colors.accent); + this.gradient.stops[1].setAttribute("stop-color", this.colors.fill); + this.render(); + } + }, + render: { + + /* + * Update the visual interface using its current state + * + * @example + * button.render(); + */ + + value: function render() { + if (!this.state) { + this.pad.setAttribute("fill", this.colors.fill); + this.pad.setAttribute("stroke", this.colors.mediumLight); + } else { + if (this.mode === "aftertouch") { + this.pad.setAttribute("stroke", "url(#" + this.gradient.id + ")"); + this.gradient.element.setAttribute("cx", this.position.x * 100 + "%"); + this.gradient.element.setAttribute("cy", (1 - this.position.y) * 100 + "%"); + } else { + this.pad.setAttribute("stroke", this.colors.accent); + } + this.pad.setAttribute("fill", this.colors.accent); + } + } + } + }); + + return Button; + })(ButtonTemplate); + + module.exports = Button; + +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var svg = __webpack_require__(4); + var math = __webpack_require__(5); + var ToggleModel = __webpack_require__(13); + var Interface = __webpack_require__(6); + + /** + Button Template + */ + + var ButtonTemplate = (function (_Interface) { + function ButtonTemplate(args, options, defaults) { + _classCallCheck(this, ButtonTemplate); + + _get(Object.getPrototypeOf(ButtonTemplate.prototype), "constructor", this).call(this, args, options, defaults); + + this.mode = this.settings.mode || "button"; + + this.position = { + x: 0, + y: 0 + }; + + this._state = new ToggleModel(this.settings.state); + } + + _inherits(ButtonTemplate, _Interface); + + _createClass(ButtonTemplate, { + buildInterface: { + value: function buildInterface() { + this.pad = svg.create("circle"); + this.pad.setAttribute("fill", "#d18"); + this.pad.setAttribute("stroke", "#d18"); + this.pad.setAttribute("stroke-width", 4); + + this.element.appendChild(this.pad); + + this.interactionTarget = this.pad; + + this.sizeInterface(); + } + }, + sizeInterface: { + value: function sizeInterface() { + this.pad.setAttribute("cx", this.width / 2); + this.pad.setAttribute("cy", this.height / 2); + this.pad.setAttribute("r", Math.min(this.width, this.height) / 2 - 2); + } + }, + render: { + value: function render() { + if (!this.state) { + this.pad.setAttribute("fill", this.colors.fill); + this.pad.setAttribute("stroke", this.colors.mediumLight); + } else { + this.pad.setAttribute("fill", this.colors.accent); + this.pad.setAttribute("stroke", this.colors.accent); + } + } + }, + down: { + value: function down(paintbrush) { + switch (this.mode) { + case "impulse": + this.turnOn(); + if (this.timeout) { + clearTimeout(this.timeout); + } + this.timeout = setTimeout(this.turnOff.bind(this), 30); + // this.emit('change',this.state); + break; + case "button": + this.turnOn(); + // this.emit('change',this.state); + break; + case "aftertouch": + this.position = { + x: math.clip(this.mouse.x / this.width, 0, 1), + y: math.clip(1 - this.mouse.y / this.height, 0, 1) + }; + this.turnOn(); + // this.emit('change',{ + // state: this.state, + // x: this.position.x, + // y: this.position.y, + // }); + break; + case "toggle": + this.flip(paintbrush); + // this.emit('change',this.state); + break; + } + } + }, + bend: { + value: function bend(mouse) { + if (this.mode === "aftertouch") { + this.mouse = mouse || this.mouse; + this.position = { + x: math.clip(this.mouse.x / this.width, 0, 1), + y: math.clip(1 - this.mouse.y / this.height, 0, 1) + }; + this.emit("change", { + state: this.state, + x: this.position.x, + y: this.position.y }); + this.render(); + } + } + }, + up: { + value: function up() { + switch (this.mode) { + case "button": + this.turnOff(); + // this.emit('change',this.state); + break; + case "aftertouch": + this.turnOff(); + this.position = { + x: math.clip(this.mouse.x / this.width, 0, 1), + y: math.clip(1 - this.mouse.y / this.height, 0, 1) + }; + // this.emit('change',{ + // state: this.state, + // x: this.position.x, + // y: this.position.y, + // }); + break; + } + } + }, + click: { + + /* overwritable interaction handlers */ + + value: function click() { + this.down(); + } + }, + move: { + value: function move() { + this.bend(); + } + }, + release: { + value: function release() { + this.up(); + } + }, + state: { + + /** + Whether the button is on (pressed) or off (not pressed) + @type {boolean} + @example button.state = true; + */ + + get: function () { + return this._state.state; + }, + set: function (value) { + this._state.flip(value); + if (this.mode === "aftertouch") { + this.emit("change", { + state: this.state, + x: this.position.x, + y: this.position.y }); + } else { + this.emit("change", this.state); + } + this.render(); + } + }, + flip: { + + /** + Change the button to its alternate state (off=>on, on=>off), or flip it to a specified state. + @param value {boolean} (Optional) State to flip to. + @example button.flip(); + */ + + value: function flip(value) { + this._state.flip(value); + if (this.mode === "aftertouch") { + this.emit("change", { + state: this.state, + x: this.position.x, + y: this.position.y }); + } else { + this.emit("change", this.state); + } + this.render(); + } + }, + turnOn: { + + /** + Turn the button's state to true. + @example button.turnOn(); + */ + + value: function turnOn(emitting) { + this._state.on(); + if (emitting !== false) { + if (this.mode === "aftertouch") { + this.emit("change", { + state: this.state, + x: this.position.x, + y: this.position.y }); + } else { + this.emit("change", this.state); + } + } + this.render(); + } + }, + turnOff: { + + /** + Turn the button's state to false. + @example button.turnOff(); + */ + + value: function turnOff(emitting) { + this._state.off(); + if (emitting !== false) { + if (this.mode === "aftertouch") { + this.emit("change", { + state: this.state, + x: this.position.x, + y: this.position.y }); + } else { + this.emit("change", this.state); + } + } + this.render(); + } + } + }); + + return ButtonTemplate; + })(Interface); + + module.exports = ButtonTemplate; + +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var ButtonTemplate = __webpack_require__(17); + + /** + * TextButton + * + * @description Text button + * + * @demo <span nexus-ui="textButton"></span> + * + * @example + * var textbutton = new Nexus.TextButton('#target') + * + * @example + * var textbutton = new Nexus.TextButton('#target',{ + * 'size': [150,50], + * 'state': false, + * 'text': 'Play', + * 'alternateText': 'Stop' + * }) + * + * @output + * change + * Fires any time the interface's value changes. <br> + * The event data is a <i>string</i> of the text on the button at the moment it was clicked. + * + * @outputexample + * textbutton.on('change',function(v) { + * console.log(v); + * }) + * + */ + + var TextButton = (function (_ButtonTemplate) { + function TextButton() { + _classCallCheck(this, TextButton); + + var options = ["value"]; + + var defaults = { + size: [150, 50], + state: false, + text: "Play" + }; + + _get(Object.getPrototypeOf(TextButton.prototype), "constructor", this).call(this, arguments, options, defaults); + + this._text = this.settings.text; + + if (this.settings.alternate) { + //TODO: Remove this conditional in a breaking-changes release + this.settings.alternateText = this.settings.alternate; + console.warn("'alternate' initiator is deprecated. Use 'alternateText' instead."); + } + this._alternateText = this.settings.alternateText; + this.mode = this.settings.alternateText ? "toggle" : "button"; + this.init(); + this.render(); + + this.state = this.settings.state; + } + + _inherits(TextButton, _ButtonTemplate); + + _createClass(TextButton, { + buildFrame: { + value: function buildFrame() { + + this.element = document.createElement("div"); + this.parent.appendChild(this.element); + + this.textElement = document.createElement("div"); + this.textElement.innerHTML = this._text; + this.element.appendChild(this.textElement); + } + }, + buildInterface: { + value: function buildInterface() {} + }, + colorInterface: { + value: function colorInterface() { + this.element.style.color = this.colors.dark; + this.render(); + } + }, + sizeInterface: { + value: function sizeInterface() { + var textsize = this.height / 3; + var textsize2 = this.width / (this._text.length + 2); + textsize = Math.min(textsize, textsize2); + if (this.alternateText) { + var textsize3 = this.width / (this.alternateText.length + 2); + textsize = Math.min(textsize, textsize3); + } + var styles = "width: " + this.width + "px;"; + styles += "height: " + this.height + "px;"; + styles += "padding: " + (this.height - textsize) / 2 + "px 0px;"; + styles += "box-sizing: border-box;"; + styles += "text-align: center;"; + styles += "font-family: inherit;"; + styles += "font-weight: 700;"; + styles += "opacity: 1;"; + styles += "font-size:" + textsize + "px;"; + this.textElement.style.cssText = styles; + this.render(); + } + }, + render: { + value: function render() { + if (!this.state) { + this.element.style.backgroundColor = this.colors.fill; + this.textElement.style.color = this.colors.dark; + this.textElement.innerHTML = this._text; + } else { + this.element.style.backgroundColor = this.colors.accent; + this.textElement.style.color = this.colors.fill; + if (this.alternateText) { + this.textElement.innerHTML = this._alternateText; + } else { + this.textElement.innerHTML = this._text; + } + } + } + }, + alternateText: { + + /** + The text to display when the button is in its "on" state. If set, this puts the button in "toggle" mode. + @type {String} + */ + + get: function () { + return this._alternateText; + }, + set: function (text) { + if (text) { + this.mode = "toggle"; + } else { + this.mode = "button"; + } + this._alternateText = text; + this.render(); + } + }, + text: { + + /** + The text to display. (If .alternateText exists, then this .text will only be displayed when the button is in its "off" state.) + @type {String} + */ + + get: function () { + return this._text; + }, + set: function (text) { + this._text = text; + this.sizeInterface(); + this.render(); + } + } + }); + + return TextButton; + })(ButtonTemplate); + + module.exports = TextButton; + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + //let svg = require('../util/svg'); + var Interface = __webpack_require__(6); + var Button = __webpack_require__(16); + + /** + * RadioButton + * + * @description An array of buttons. By default, selecting one button will deselect all other buttons, but this can be customized using the API below. + * + * @demo <div nexus-ui="RadioButton"></div> + * + * @example + * var radiobutton = new Nexus.RadioButton('#target') + * + * @example + * var radiobutton = new Nexus.RadioButton('#target',{ + * 'size': [120,25], + * 'numberOfButtons': 4, + * 'active': -1 + * }) + * + * @output + * change + * Fires any time the interface's value changes. <br> + * The event data an <i>integer</i>, the index of the button that is currently on. If no button is selected, the value will be -1. + * + * @outputexample + * radiobutton.on('change',function(v) { + * console.log(v); + * }) + * + */ + + var RadioButton = (function (_Interface) { + function RadioButton() { + _classCallCheck(this, RadioButton); + + var options = ["value"]; + + var defaults = { + size: [120, 25], + numberOfButtons: 4, + active: -1 + }; + + _get(Object.getPrototypeOf(RadioButton.prototype), "constructor", this).call(this, arguments, options, defaults); + + this.buttons = []; + this._numberOfButtons = this.settings.numberOfButtons; + this.active = this.settings.active; + + this.init(); + this.render(); + } + + _inherits(RadioButton, _Interface); + + _createClass(RadioButton, { + buildFrame: { + value: function buildFrame() { + this.element = document.createElement("div"); + this.parent.appendChild(this.element); + } + }, + buildInterface: { + value: function buildInterface() { + + for (var i = 0; i < this._numberOfButtons; i++) { + var container = document.createElement("span"); + + var button = new Button(container, { + mode: "toggle", + component: true }, this.update.bind(this, i)); + + this.buttons.push(button); + this.element.appendChild(container); + } + } + }, + sizeInterface: { + value: function sizeInterface() { + + var buttonWidth = this.width / this._numberOfButtons; + var buttonHeight = this.height; + + for (var i = 0; i < this._numberOfButtons; i++) { + this.buttons[i].resize(buttonWidth, buttonHeight); + } + } + }, + colorInterface: { + value: function colorInterface() { + for (var i = 0; i < this._numberOfButtons; i++) { + this.buttons[i].colors = this.colors; + this.buttons[i].render(); + } + } + }, + update: { + value: function update(index) { + if (this.buttons[index].state) { + this.select(index); + } else { + this.deselect(); + } + // this.render(); + } + }, + render: { + value: function render() { + for (var i = 0; i < this.buttons.length; i++) { + if (i === this.active) { + this.buttons[i].turnOn(false); + } else { + this.buttons[i].turnOff(false); + } + } + } + }, + select: { + + /** + Select one button and deselect all other buttons. + @param index {number} The index of the button to select + */ + + value: function select(index) { + if (index >= 0 && index < this.buttons.length) { + this.active = index; + this.emit("change", this.active); + this.render(); + } + } + }, + deselect: { + + /** + Deselect all buttons. + */ + + value: function deselect() { + this.active = -1; + this.emit("change", this.active); + this.render(); + } + }, + numberOfButtons: { + get: function () { + return this._numberOfButtons; + }, + + /** + * Update how many buttons are in the interface + * @param {number} buttons How many buttons are in the interface + */ + set: function (buttons) { + this._numberOfButtons = buttons; + for (var i = 0; i < this.buttons.length; i++) { + this.buttons[i].destroy(); + } + this.buttons = []; + // for (let i=0;i<this.buttons.length;i++) { + // this.buttons[i].destroy(); + // } + this.empty(); + this.buildInterface(); + } + } + }); + + return RadioButton; + })(Interface); + + module.exports = RadioButton; + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var Interface = __webpack_require__(6); + var Step = __webpack_require__(11); + var math = __webpack_require__(5); + + /** + * Number + * + * @description Number interface which is controllable by dragging or typing. + * + * @demo <span nexus-ui="number"></span> + * + * @example + * var number = new Nexus.Number('#target') + * + * @example + * var number = new Nexus.Number('#target',{ + * 'size': [60,30], + * 'value': 0, + * 'min': 0, + * 'max': 20000, + * 'step': 1 + * }) + * + * @output + * change + * Fires any time the interface's value changes. <br> + * The event data is the number value of the interface. + * + * @outputexample + * number.on('change',function(v) { + * console.log(v); + * }) + * + * + */ + + var Number = (function (_Interface) { + function Number() { + _classCallCheck(this, Number); + + var options = ["value"]; + + var defaults = { + size: [60, 30], + value: 0, + min: 0, + max: 20000, + step: 1 + }; + + _get(Object.getPrototypeOf(Number.prototype), "constructor", this).call(this, arguments, options, defaults); + + this._value = new Step(this.settings.min, this.settings.max, this.settings.step, this.settings.value); + + /* + Default: 2. How many decimal places to clip the number's visual rendering to. This does not affect number's actual value output -- for that, set the step property to .01, .1, or 1. + @type {number} + @example number.decimalPlaces = 2; + */ + this.decimalPlaces = 2; + this.actual = 0; + + this.max = this._value.max; + + this.min = this._value.min; + + this.step = this._value.step; + + this.init(); + this.render(); + } + + _inherits(Number, _Interface); + + _createClass(Number, { + buildFrame: { + value: function buildFrame() { + this.element = document.createElement("input"); + this.element.type = "text"; + + this.element.addEventListener("blur", (function () { + this.element.style.backgroundColor = this.colors.fill; + this.element.style.color = this.colors.dark; + if (this.element.value !== this.value) { + this.value = parseFloat(this.element.value); + this.render(); + } + }).bind(this)); + + this.element.addEventListener("keydown", (function (e) { + if (e.which < 48 || e.which > 57) { + if (e.which !== 189 && e.which !== 190 && e.which !== 8) { + e.preventDefault(); + } + } + if (e.which === 13) { + this.element.blur(); + this.value = this.element.value; + this.emit("change", this.value); + this.render(); + } + }).bind(this)); + + this.parent.appendChild(this.element); + } + }, + sizeInterface: { + value: function sizeInterface() { + + this._minDimension = Math.min(this.width, this.height); + + var styles = "width: " + this.width + "px;"; + styles += "height: " + this.height + "px;"; + styles += "background-color: #e7e7e7;"; + styles += "color: #333;"; + styles += "font-family: arial;"; + styles += "font-weight: 500;"; + styles += "font-size:" + this._minDimension / 2 + "px;"; + // styles += 'highlight: #d18;'; + styles += "border: none;"; + styles += "outline: none;"; + styles += "padding: " + this._minDimension / 4 + "px " + this._minDimension / 4 + "px;"; + styles += "box-sizing: border-box;"; + styles += "userSelect: text;"; + styles += "mozUserSelect: text;"; + styles += "webkitUserSelect: text;"; + this.element.style.cssText += styles; + + // to add eventually + // var css = '#'+this.elementID+'::selection{ background-color: transparent }'; + + this.element.value = this.value; + } + }, + colorInterface: { + value: function colorInterface() { + this.element.style.backgroundColor = this.colors.fill; + this.element.style.color = this.colors.dark; + } + }, + render: { + value: function render() { + + this.element.value = math.prune(this.value, this.decimalPlaces); + } + }, + click: { + value: function click() { + this.hasMoved = false; + this.element.readOnly = true; + this.actual = this.value; + this.initial = { y: this.mouse.y }; + this.changeFactor = math.invert(this.mouse.x / this.width); + console.log(this.changeFactor); + } + }, + move: { + value: function move() { + this.hasMoved = true; + if (this.clicked) { + + var newvalue = this.actual - (this.mouse.y - this.initial.y) * (math.clip(this.max - this.min, 0, 1000) / 200) * Math.pow(this.changeFactor, 2); + this.value = newvalue; + + this.render(); + if (this._value.changed) { + this.emit("change", this.value); + } + } + } + }, + release: { + value: function release() { + if (!this.hasMoved) { + this.element.readOnly = false; + this.element.focus(); + this.element.setSelectionRange(0, this.element.value.length); + this.element.style.backgroundColor = this.colors.accent; + this.element.style.color = this.colors.light; + } else { + document.body.focus(); + } + } + }, + link: { + + /** + Connect this number interface to a dial or slider + @param {Interface} element Element to connect to. + @example number.link(slider) + */ + + value: function link(destination) { + var _this = this; + + this.min = destination.min; + this.max = destination.max; + this.step = destination.step; + destination.on("change", function (v) { + _this.passiveUpdate(v); + }); + this.on("change", function (v) { + destination.value = v; + }); + this.value = destination.value; + /* return { + listener1: listener1, + listener2: listener2, + destroy: () => { + listener1.remove() (or similar) + listener2.remove() (or similar) + } + } */ + } + }, + passiveUpdate: { + value: function passiveUpdate(v) { + this._value.update(v); + this.render(); + } + }, + value: { + + /** + The interface's current value. If set manually, will update the interface and trigger the output event. + @type {number} + @example number.value = 10; + */ + + get: function () { + return this._value.value; + }, + set: function (v) { + this._value.update(v); + this.emit("change", this.value); + this.render(); + } + }, + min: { + + /** + Lower limit of the number's output range + @type {number} + @example number.min = 1000; + */ + + get: function () { + return this._value.min; + }, + set: function (v) { + this._value.min = v; + } + }, + max: { + + /** + Upper limit of the number's output range + @type {number} + @example number.max = 1000; + */ + + get: function () { + return this._value.max; + }, + set: function (v) { + this._value.max = v; + } + }, + step: { + + /** + The increment that the number's value changes by. + @type {number} + @example number.step = 5; + */ + + get: function () { + return this._value.step; + }, + set: function (v) { + this._value.step = v; + } + } + }); + + return Number; + })(Interface); + + module.exports = Number; + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var Interface = __webpack_require__(6); + + /** + * Select + * + * @description Dropdown menu + * + * @demo <span nexus-ui="select"></span> + * + * @example + * var select = new Nexus.Select('#target') + * + * @example + * var select = new Nexus.Select('#target',{ + * 'size': [100,30], + * 'options': ['default','options'] + * }) + * + * @output + * change + * Fires any time the interface's value changes. <br> + * The event data is an object containing the text value of the selected option, as well as the numeric index of the selection. + * + * @outputexample + * select.on('change',function(v) { + * console.log(v); + * }) + * + * + */ + + var Select = (function (_Interface) { + function Select() { + _classCallCheck(this, Select); + + var options = ["value"]; + + var defaults = { + size: [100, 30], + options: ["default", "options"] + }; + + _get(Object.getPrototypeOf(Select.prototype), "constructor", this).call(this, arguments, options, defaults); + + this._selectedIndex = -1; + this._value = false; + + this._options = this.settings.options; + + this.init(); + this.render(); + } + + _inherits(Select, _Interface); + + _createClass(Select, { + buildFrame: { + value: function buildFrame() { + this.element = document.createElement("select"); + this.element.style.fontSize = this.height / 2 + "px"; + this.element.style.outline = "none"; + this.element.style.highlight = "none"; + this.element.style.width = this.width + "px"; + this.element.style.height = this.height + "px"; + + this.boundRender = this.render.bind(this); + + this.element.addEventListener("change", this.boundRender); + + this.parent.appendChild(this.element); + } + }, + attachListeners: { + value: function attachListeners() {} + }, + buildInterface: { + value: function buildInterface() { + + this.defineOptions(); + } + }, + colorInterface: { + value: function colorInterface() { + this.element.style.backgroundColor = this.colors.fill; + this.element.style.color = this.colors.dark; + this.element.style.border = "solid 0px " + this.colors.mediumLight; + } + }, + render: { + value: function render() { + + this._value = this.element.options[this.element.selectedIndex].text; + this._selectedIndex = this.element.selectedIndex; + this.emit("change", { + value: this._value, + index: this._selectedIndex + }); + } + }, + click: { + value: function click() {} + }, + move: { + value: function move() {} + }, + release: { + value: function release() {} + }, + defineOptions: { + + /** + * Update the list of options. This removes all existing options and creates a new list of options. + * @param {array} options New array of options + */ + + value: function defineOptions(options) { + + /* function removeOptions(selectbox) + { + var i; + for(i = selectbox.options.length - 1 ; i >= 0 ; i--) + { + selectbox.remove(i); + } + } + //using the function: + removeOptions(document.getElementById("mySelectObject")); */ + + if (options) { + this._options = options; + } + + for (var i = this.element.options.length - 1; i >= 0; i--) { + this.element.remove(i); + } + + for (var i = 0; i < this._options.length; i++) { + this.element.options.add(new Option(this._options[i], i)); + } + } + }, + value: { + + /** + The text of the option that is currently selected. If set, will update the interface and trigger the output event. + @type {String} + @example select.value = "sawtooth"; + */ + + get: function () { + return this._value; + }, + set: function (v) { + this._value = v; + for (var i = 0; i < this.element.options.length; i++) { + if (v === this.element.options[i].text) { + this.selectedIndex = i; + break; + } + } + } + }, + selectedIndex: { + + /** + The numeric index of the option that is currently selected. If set, will update the interface and trigger the output event. + @type {number} + @example select.selectedIndex = 2; + */ + + get: function () { + return this._selectedIndex; + }, + set: function (v) { + this._selectedIndex = v; + this.element.selectedIndex = v; + this.render(); + } + }, + customDestroy: { + value: function customDestroy() { + this.element.removeEventListener("change", this.boundRender); + } + } + }); + + return Select; + })(Interface); + + module.exports = Select; + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; }; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var svg = __webpack_require__(4); + var math = __webpack_require__(5); + var Interface = __webpack_require__(6); + var Step = __webpack_require__(11); + + var Interaction = _interopRequireWildcard(__webpack_require__(12)); + + /** + * Dial + * + * + * @description Dial with radial or linear interaction. + * + * @demo <span nexus-ui="dial"></span> + * + * @example + * var dial = new Nexus.Dial('#target') + * + * @example + * var dial = new Nexus.Dial('#target',{ + * 'size': [75,75], + * 'interaction': 'radial', // "radial", "vertical", or "horizontal" + * 'mode': 'relative', // "absolute" or "relative" + * 'min': 0, + * 'max': 1, + * 'step': 0, + * 'value': 0 + * }) + * + * @output + * change + * Fires any time the interface's value changes. <br> + * The event data is the number value of the interface. + * + * @outputexample + * dial.on('change',function(v) { + * console.log(v); + * }) + * + * @tutorial + * Dial + * ygGMxq + * + */ + + var Dial = (function (_Interface) { + function Dial() { + _classCallCheck(this, Dial); + + var options = ["min", "max", "value"]; + + var defaults = { + size: [75, 75], + interaction: "radial", // radial, vertical, horizontal + mode: "relative", // absolute, relative + min: 0, + max: 1, + step: 0, + value: 0 + }; + + _get(Object.getPrototypeOf(Dial.prototype), "constructor", this).call(this, arguments, options, defaults); + + this.interaction = this.settings.interaction; + + this._value = new Step(this.settings.min, this.settings.max, this.settings.step, this.settings.value); + + this.position = new Interaction.Handle(this.settings.mode, this.interaction, [0, this.width], [this.height, 0]); + + this.init(); + + this.value = this._value.value; + + this.position.value = this._value.normalized; + + this.previousAngle = false; + + this.emit("change", this.value); + } + + _inherits(Dial, _Interface); + + _createClass(Dial, { + buildInterface: { + value: function buildInterface() { + + this.background = svg.create("circle"); + this.screw = svg.create("circle"); + this.handle = svg.create("path"); + this.handle2 = svg.create("path"); + this.handleFill = svg.create("path"); + this.handle2Fill = svg.create("path"); + this.handleLine = svg.create("path"); + + this.element.appendChild(this.background); + this.element.appendChild(this.handle); + this.element.appendChild(this.handle2); + this.element.appendChild(this.handleFill); + this.element.appendChild(this.handle2Fill); + this.element.appendChild(this.handleLine); + this.element.appendChild(this.screw); + } + }, + sizeInterface: { + value: function sizeInterface() { + + this.position.resize([0, this.width], [this.height, 0]); + + var center = { + x: this.width / 2, + y: this.height / 2 + }; + + var diameter = Math.min(this.width, this.height); + + this.background.setAttribute("cx", center.x); + this.background.setAttribute("cy", center.y); + this.background.setAttribute("r", diameter / 2 - diameter / 40); + + this.screw.setAttribute("cx", center.x); + this.screw.setAttribute("cy", center.y); + this.screw.setAttribute("r", diameter / 12); + + var value = this.value; + + var handlePoints = { + start: Math.PI * 1.5, + end: math.clip(math.scale(value, 0, 0.5, Math.PI * 1.5, Math.PI * 0.5), Math.PI * 0.5, Math.PI * 1.5) + }; + var handle2Points = { + start: Math.PI * 2.5, + end: math.clip(math.scale(value, 0.5, 1, Math.PI * 2.5, Math.PI * 1.5), Math.PI * 1.5, Math.PI * 2.5) + }; + + var handlePath = svg.arc(center.x, center.y, diameter / 2 - diameter / 40, handlePoints.start, handlePoints.end); + var handle2Path = svg.arc(center.x, center.y, diameter / 2 - diameter / 40, handle2Points.start, handle2Points.end); + + this.handle.setAttribute("d", handlePath); + this.handle.setAttribute("stroke-width", diameter / 20); + this.handle.setAttribute("fill", "none"); + + this.handle2.setAttribute("d", handle2Path); + this.handle2.setAttribute("stroke-width", diameter / 20); + this.handle2.setAttribute("fill", "none"); + + handlePath += " L " + center.x + " " + center.y; + + this.handleFill.setAttribute("d", handlePath); + this.handleFill.setAttribute("fill-opacity", "0.3"); + + handle2Path += " L " + center.x + " " + center.y; + + this.handle2Fill.setAttribute("d", handle2Path); + this.handle2Fill.setAttribute("fill-opacity", "0.3"); + + var arcEndingA = undefined; + if (value < 0.5) { + arcEndingA = handlePoints.end; + } else { + arcEndingA = handle2Points.end; + } + + var arcEndingX = center.x + Math.cos(arcEndingA) * (diameter / 2); + var arcEndingY = center.y + Math.sin(arcEndingA) * (diameter / 2) * -1; + + this.handleLine.setAttribute("d", "M " + center.x + " " + center.y + " L " + arcEndingX + " " + arcEndingY); + this.handleLine.setAttribute("stroke-width", diameter / 20); + } + }, + colorInterface: { + value: function colorInterface() { + this.background.setAttribute("fill", this.colors.fill); + this.screw.setAttribute("fill", this.colors.accent); + this.handle.setAttribute("stroke", this.colors.accent); + this.handle2.setAttribute("stroke", this.colors.accent); + this.handleFill.setAttribute("fill", this.colors.accent); + this.handle2Fill.setAttribute("fill", this.colors.accent); + this.handleLine.setAttribute("stroke", this.colors.accent); + } + }, + render: { + value: function render() { + var value = this._value.normalized; + + var center = { + x: this.width / 2, + y: this.height / 2 + }; + + var diameter = Math.min(this.width, this.height); + + var handlePoints = { + start: Math.PI * 1.5, + end: math.clip(math.scale(value, 0, 0.5, Math.PI * 1.5, Math.PI * 0.5), Math.PI * 0.5, Math.PI * 1.5) + }; + var handle2Points = { + start: Math.PI * 2.5, + end: math.clip(math.scale(value, 0.5, 1, Math.PI * 2.5, Math.PI * 1.5), Math.PI * 1.5, Math.PI * 2.5) + }; + + var handlePath = svg.arc(center.x, center.y, diameter / 2 - diameter / 40, handlePoints.start, handlePoints.end); + var handle2Path = svg.arc(center.x, center.y, diameter / 2 - diameter / 40, handle2Points.start, handle2Points.end); + + this.handle.setAttribute("d", handlePath); + this.handle2.setAttribute("d", handle2Path); + + handlePath += " L " + center.x + " " + center.y; + + this.handleFill.setAttribute("d", handlePath); + + handle2Path += " L " + center.x + " " + center.y; + + this.handle2Fill.setAttribute("d", handle2Path); + + var arcEndingA = undefined; + if (value <= 0.5) { + arcEndingA = handlePoints.end; + } else { + arcEndingA = handle2Points.end; + } + + var arcEndingX = center.x + Math.cos(arcEndingA) * (diameter / 2); + var arcEndingY = center.y + Math.sin(arcEndingA) * (diameter / 2) * -1; + + this.handleLine.setAttribute("d", "M " + center.x + " " + center.y + " L " + arcEndingX + " " + arcEndingY); + } + }, + click: { + value: function click() { + if (this.mode === "relative") { + this.previousAngle = false; + } + this.position.anchor = this.mouse; + this.position.value = this._value.normalized; + this.move(); + } + }, + move: { + value: function move() { + if (this.clicked) { + + this.position.update(this.mouse); + + var angle = this.position.value * Math.PI * 2; + + if (angle < 0) { + angle += Math.PI * 2; + } + + if (this.mode === "relative") { + if (this.previousAngle !== false && Math.abs(this.previousAngle - angle) > 2) { + if (this.previousAngle > 3) { + angle = Math.PI * 2; + } else { + angle = 0; + } + } + } /* else { + if (this.previousAngle !== false && Math.abs(this.previousAngle - angle) > 2) { + if (this.previousAngle > 3) { + angle = Math.PI*2; + } else { + angle = 0; + } + } + } */ + this.previousAngle = angle; + + var realValue = angle / (Math.PI * 2); + + this.value = this._value.updateNormal(realValue); + + if (this.mode === "relative") { + this.position.value = realValue; + } + + this.emit("change", this._value.value); + + this.render(); + } + } + }, + release: { + value: function release() {} + }, + value: { + + /* + Dial's value. When set, it will automatically be adjust to fit min/max/step settings of the interface. + @type {number} + @example dial.value = 10; + get value() { + return this._value.value; + } + set value(value) { + this._value.update(value); + this.emit('change',this.value); + this.render(); + } + */ + + /** + Dial's value. When set, it will automatically be adjust to fit min/max/step settings of the interface. + @type {number} + @example dial.value = 10; + */ + + get: function () { + return this._value.value; + }, + set: function (v) { + this._value.update(v); + this.position.value = this._value.normalized; + this.emit("change", this._value.value); + this.render(); + } + }, + min: { + + /** + Lower limit of the dial's output range + @type {number} + @example dial.min = 1000; + */ + + get: function () { + return this._value.min; + }, + set: function (v) { + this._value.min = v; + } + }, + max: { + + /** + Upper limit of the dial's output range + @type {number} + @example dial.max = 1000; + */ + + get: function () { + return this._value.max; + }, + set: function (v) { + this._value.max = v; + } + }, + step: { + + /** + The increment that the dial's value changes by. + @type {number} + @example dial.step = 5; + */ + + get: function () { + return this._value.step; + }, + set: function (v) { + this._value.step = v; + } + }, + mode: { + + /** + Absolute mode (dial's value jumps to mouse click position) or relative mode (mouse drag changes value relative to its current position). Default: "relative". + @type {string} + @example dial.mode = "relative"; + */ + + get: function () { + return this.position.mode; + }, + set: function (v) { + this.position.mode = v; + } + }, + normalized: { + + /** + Normalized value of the dial. + @type {number} + @example dial.normalized = 0.5; + */ + + get: function () { + return this._value.normalized; + }, + set: function (v) { + this._value.updateNormal(v); + this.emit("change", this.value); + } + } + }); + + return Dial; + })(Interface); + + module.exports = Dial; + +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var svg = __webpack_require__(4); + var Interface = __webpack_require__(6); + var ButtonTemplate = __webpack_require__(17); + var touch = __webpack_require__(9); + + var PianoKey = (function (_ButtonTemplate) { + function PianoKey() { + _classCallCheck(this, PianoKey); + + var options = ["value", "note", "color"]; + + var defaults = { + size: [80, 80], + target: false, + mode: "button", + value: 0 + }; + + _get(Object.getPrototypeOf(PianoKey.prototype), "constructor", this).call(this, arguments, options, defaults); + + this.note = this.settings.note; + this.color = this.settings.color; + + this.colors = { + w: "#fff", + b: "#666" }; + + this.init(); + this.render(); + } + + _inherits(PianoKey, _ButtonTemplate); + + _createClass(PianoKey, { + buildFrame: { + value: function buildFrame() { + this.element = svg.create("svg"); + this.element.setAttribute("width", this.width); + this.element.setAttribute("height", this.height); + this.parent.appendChild(this.element); + } + }, + buildInterface: { + value: function buildInterface() { + var _this = this; + + this.pad = svg.create("rect"); + + this.element.appendChild(this.pad); + + this.interactionTarget = this.pad; + + /* events */ + + if (!touch.exists) { + + this.click = function () { + // console.log('click'); + _this.piano.interacting = true; + _this.piano.paintbrush = !_this.state; + _this.down(_this.piano.paintbrush); + }; + + this.pad.addEventListener("mouseover", function () { + if (_this.piano.interacting) { + // console.log('mouseover'); + _this.down(_this.piano.paintbrush); + } + }); + + this.move = function () { + if (_this.piano.interacting) { + // console.log('move'); + _this.bend(); + } + }; + + this.release = function () { + _this.piano.interacting = false; + // console.log('release'); + // this.up(); + }; + this.pad.addEventListener("mouseup", function () { + if (_this.piano.interacting) { + // console.log('mouseup'); + _this.up(); + } + }); + this.pad.addEventListener("mouseout", function () { + if (_this.piano.interacting) { + // console.log('mouseout'); + _this.up(); + } + }); + } + } + }, + sizeInterface: { + value: function sizeInterface() { + + //let radius = Math.min(this.width,this.height) / 5; + var radius = 0; + + this.pad.setAttribute("x", 0.5); + this.pad.setAttribute("y", 0.5); + if (this.width > 2) { + this.pad.setAttribute("width", this.width - 1); + } else { + this.pad.setAttribute("width", this.width); + } + if (this.height > 2) { + this.pad.setAttribute("height", this.height); + } else { + this.pad.setAttribute("height", this.height); + } + this.pad.setAttribute("rx", radius); + this.pad.setAttribute("ry", radius); + } + }, + render: { + value: function render() { + if (!this.state) { + this.pad.setAttribute("fill", this.colors[this.color]); + } else { + this.pad.setAttribute("fill", this.colors.accent); + } + } + } + }); + + return PianoKey; + })(ButtonTemplate); + + /** + * Piano + * + * @description Piano keyboard interface + * + * @demo <div nexus-ui="piano"></div> + * + * @example + * var piano = new Nexus.Piano('#target') + * + * @example + * var piano = new Nexus.Piano('#target',{ + * 'size': [500,125], + * 'mode': 'button', // 'button', 'toggle', or 'impulse' + * 'lowNote': 24, + * 'highNote': 60 + * }) + * + * @output + * change + * Fires any time a new key is pressed or released <br> + * The event data is an object containing <i>note</i> and <i>state</i> properties. + * + * @outputexample + * piano.on('change',function(v) { + * console.log(v); + * }) + * + */ + + var Piano = (function (_Interface) { + function Piano() { + _classCallCheck(this, Piano); + + var options = ["value"]; + + var defaults = { + size: [500, 125], + lowNote: 24, + highNote: 60, + mode: "button" + }; + + _get(Object.getPrototypeOf(Piano.prototype), "constructor", this).call(this, arguments, options, defaults); + + this.keyPattern = ["w", "b", "w", "b", "w", "w", "b", "w", "b", "w", "b", "w"]; + + this.paintbrush = false; + + this.mode = this.settings.mode; + + this.range = { + low: this.settings.lowNote, + high: this.settings.highNote + }; + + this.range.size = this.range.high - this.range.low; + + this.keys = []; + + this.toggleTo = false; + + this.init(); + this.render(); + } + + _inherits(Piano, _Interface); + + _createClass(Piano, { + buildFrame: { + value: function buildFrame() { + this.element = document.createElement("div"); + this.element.style.position = "relative"; + this.element.style.borderRadius = "0px"; + this.element.style.display = "block"; + this.element.style.width = "100%"; + this.element.style.height = "100%"; + this.parent.appendChild(this.element); + } + }, + buildInterface: { + value: function buildInterface() { + + this.keys = []; + + for (var i = 0; i < this.range.high - this.range.low; i++) { + + var container = document.createElement("span"); + var scaleIndex = (i + this.range.low) % this.keyPattern.length; + + var key = new PianoKey(container, { + component: true, + note: i + this.range.low, + color: this.keyPattern[scaleIndex], + mode: this.mode + }, this.keyChange.bind(this, i + this.range.low)); + + key.piano = this; + + if (touch.exists) { + key.pad.index = i; + key.preClick = key.preMove = key.preRelease = function () {}; + key.click = key.move = key.release = function () {}; + key.preTouch = key.preTouchMove = key.preTouchRelease = function () {}; + key.touch = key.touchMove = key.touchRelease = function () {}; + } + + this.keys.push(key); + this.element.appendChild(container); + } + if (touch.exists) { + this.addTouchListeners(); + } + } + }, + sizeInterface: { + value: function sizeInterface() { + + var keyX = 0; + + var keyPositions = []; + + for (var i = 0; i < this.range.high - this.range.low; i++) { + + keyPositions.push(keyX); + + var scaleIndex = (i + this.range.low) % this.keyPattern.length; + var nextScaleIndex = (i + 1 + this.range.low) % this.keyPattern.length; + if (i + 1 + this.range.low >= this.range.high) { + keyX += 1; + } else if (this.keyPattern[scaleIndex] === "w" && this.keyPattern[nextScaleIndex] === "w") { + keyX += 1; + } else { + keyX += 0.5; + } + } + var keysWide = keyX; + + // let padding = this.width / 120; + var padding = 1; + var buttonWidth = (this.width - padding * 2) / keysWide; + var buttonHeight = (this.height - padding * 2) / 2; + + for (var i = 0; i < this.keys.length; i++) { + + var container = this.keys[i].parent; + container.style.position = "absolute"; + container.style.left = keyPositions[i] * buttonWidth + padding + "px"; + if (this.keys[i].color === "w") { + container.style.top = padding + "px"; + this.keys[i].resize(buttonWidth, buttonHeight * 2); + } else { + container.style.zIndex = 1; + container.style.top = padding + "px"; + this.keys[i].resize(buttonWidth, buttonHeight * 1.1); + } + } + } + }, + colorInterface: { + value: function colorInterface() { + + // Piano keys don't actually have a stroke border + // They have space between them, which shows the Piano bg color + this.element.style.backgroundColor = this.colors.mediumLight; + + for (var i = 0; i < this.keys.length; i++) { + this.keys[i].colors = { + w: this.colors.light, + b: this.colors.dark, + accent: this.colors.accent, + border: this.colors.mediumLight + }; + this.keys[i].colorInterface(); + this.keys[i].render(); + } + } + }, + keyChange: { + value: function keyChange(note, on) { + // emit data for any key turning on/off + // "note" is the note value + // "on" is a boolean whether it is on or off + // in aftertouch mode, "on: is an object with state/x/y properties + var data = { + note: note + }; + if (typeof on === "object") { + data.state = on.state; + // data.x = on.x + // data.y = on.y + } else { + data.state = on; + } + this.emit("change", data); + } + }, + render: { + + /* drag(note,on) { + this.emit('change',{ + note: note, + state: on + }); + } */ + + value: function render() {} + }, + addTouchListeners: { + value: function addTouchListeners() { + var _this = this; + + this.preClick = this.preMove = this.preRelease = function () {}; + this.click = this.move = this.release = function () {}; + this.preTouch = this.preTouchMove = this.preTouchRelease = function () {}; + this.touch = this.touchMove = this.touchRelease = function () {}; + + this.currentElement = false; + + this.element.addEventListener("touchstart", function (e) { + console.log("touchstart"); + var element = document.elementFromPoint(e.targetTouches[0].clientX, e.targetTouches[0].clientY); + var key = _this.keys[element.index]; + _this.paintbrush = !key.state; + key.down(_this.paintbrush); + _this.currentElement = element.index; + e.preventDefault(); + e.stopPropagation(); + }); + + this.element.addEventListener("touchmove", function (e) { + var element = document.elementFromPoint(e.targetTouches[0].clientX, e.targetTouches[0].clientY); + var key = _this.keys[element.index]; + if (element.index !== _this.currentElement) { + if (_this.currentElement) { + var pastKey = _this.keys[_this.currentElement]; + pastKey.up(); + } + key.down(_this.paintbrush); + } else { + key.bend(); + } + _this.currentElement = element.index; + e.preventDefault(); + e.stopPropagation(); + }); + + this.element.addEventListener("touchend", function (e) { + // no touches to calculate because none remaining + var key = _this.keys[_this.currentElement]; + key.up(); + _this.interacting = false; + _this.currentElement = false; + e.preventDefault(); + e.stopPropagation(); + }); + } + }, + setRange: { + + /** + Define the pitch range (lowest and highest note) of the piano keyboard. + @param low {number} MIDI note value of the lowest note on the keyboard + @param high {number} MIDI note value of the highest note on the keyboard + */ + + value: function setRange(low, high) { + this.range.low = low; + this.range.high = high; + this.empty(); + this.buildInterface(); + } + }, + toggleKey: { + + /** + Turn a key on or off using its MIDI note value; + @param note {number} MIDI note value of the key to change + @param on {boolean} Whether the note should turn on or off + */ + + value: function toggleKey(note, on) { + this.keys[note - this.range.low].flip(on); + } + }, + toggleIndex: { + + /** + Turn a key on or off using its key index on the piano interface. + @param index {number} Index of the key to change + @param on {boolean} Whether the note should turn on or off + */ + + value: function toggleIndex(index, on) { + this.keys[index].flip(on); + } + } + }); + + return Piano; + })(Interface); + + module.exports = Piano; + + // loop through and render the keys? + +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var svg = __webpack_require__(4); + var dom = __webpack_require__(7); + var Interface = __webpack_require__(6); + var ButtonTemplate = __webpack_require__(17); + var MatrixModel = __webpack_require__(25); + var CounterModel = __webpack_require__(28); + var touch = __webpack_require__(9); + + var MatrixCell = (function (_ButtonTemplate) { + function MatrixCell() { + _classCallCheck(this, MatrixCell); + + var options = ["value"]; + + var defaults = { + size: [80, 80], + target: false, + mode: "toggle", + value: 0 + }; + + _get(Object.getPrototypeOf(MatrixCell.prototype), "constructor", this).call(this, arguments, options, defaults); + + this.index = this.settings.index; + this.row = this.settings.row; + this.column = this.settings.column; + + this.matrix = this.settings.matrix; + + this.interacting = false; + this.paintbrush = false; + + this.init(); + this.render(); + } + + _inherits(MatrixCell, _ButtonTemplate); + + _createClass(MatrixCell, { + buildFrame: { + value: function buildFrame() { + this.element = svg.create("svg"); + this.element.setAttribute("width", this.width); + this.element.setAttribute("height", this.height); + this.element.style.top = "0px"; + this.element.style.left = "0px"; + this.element.style.position = "absolute"; + this.parent.appendChild(this.element); + } + }, + buildInterface: { + value: function buildInterface() { + var _this = this; + + this.pad = svg.create("rect"); + this.element.appendChild(this.pad); + + this.interactionTarget = this.pad; + + /* events */ + + if (!touch.exists) { + + this.click = function () { + _this.matrix.interacting = true; + _this.matrix.paintbrush = !_this.state; + _this.down(_this.matrix.paintbrush); + }; + this.pad.addEventListener("mouseover", function () { + if (_this.matrix.interacting) { + _this.down(_this.matrix.paintbrush); + } + }); + + this.move = function () {}; + this.pad.addEventListener("mousemove", function (e) { + if (_this.matrix.interacting) { + if (!_this.offset) { + _this.offset = dom.findPosition(_this.element); + } + _this.mouse = dom.locateMouse(e, _this.offset); + _this.bend(); + } + }); + + this.release = function () { + _this.matrix.interacting = false; + }; + this.pad.addEventListener("mouseup", function () { + if (_this.matrix.interacting) { + _this.up(); + } + }); + this.pad.addEventListener("mouseout", function () { + if (_this.matrix.interacting) { + _this.up(); + } + }); + } + } + }, + sizeInterface: { + value: function sizeInterface() { + + this.pad.setAttribute("x", 1); + this.pad.setAttribute("y", 1); + if (this.width > 2) { + this.pad.setAttribute("width", this.width - 2); + } else { + this.pad.setAttribute("width", this.width); + } + if (this.height > 2) { + this.pad.setAttribute("height", this.height - 2); + } else { + this.pad.setAttribute("height", this.height); + } + //this.pad.setAttribute('height', this.height - 2); + this.pad.setAttribute("fill", this.matrix.colors.fill); + } + }, + render: { + value: function render() { + if (!this.state) { + this.pad.setAttribute("fill", this.matrix.colors.fill); + } else { + this.pad.setAttribute("fill", this.matrix.colors.accent); + } + } + } + }); + + return MatrixCell; + })(ButtonTemplate); + + /** + * Sequencer + * + * @description Grid of buttons with built-in step sequencer. + * + * @demo <div nexus-ui="sequencer" style="width:400px;height:200px;"></div> + * + * @example + * var sequencer = new Nexus.Sequencer('#target') + * + * @example + * var sequencer = new Nexus.Sequencer('#target',{ + * 'size': [400,200], + * 'mode': 'toggle', + * 'rows': 5, + * 'columns': 10 + *}) + * + * @output + * change + * Fires any time the interface's matrix changes. <br> + * The event data is an object containing <i>row</i> (number), <i>column</i> (number), and <i>state</i> (boolean) properties. + * + * @outputexample + * sequencer.on('change',function(v) { + * console.log(v); + * }) + * + * @output + * step + * Fires any time the sequencer steps to the next column, in sequece mode. <br> + * The event data is an <i>array</i> containing all values in the column, <i>bottom row first</i>. + * + * @outputexample + * sequencer.on('step',function(v) { + * console.log(v); + * }) + */ + + var Sequencer = (function (_Interface) { + function Sequencer() { + _classCallCheck(this, Sequencer); + + var options = ["value"]; + + var defaults = { + size: [400, 200], + mode: "toggle", + rows: 5, + columns: 10 + }; + + _get(Object.getPrototypeOf(Sequencer.prototype), "constructor", this).call(this, arguments, options, defaults); + + this.active = -1; + + /** + * Button interaction mode: see Button + * @type {string} + * @example button.mode = 'toggle'; + */ + this.mode = this.settings.mode; + + /** + * The interval object which controls timing and sequence scheduling. + * @type {interval} + */ + this.interval = new Nexus.Interval(200, function () {}, false); // jshint ignore:line + + /** + * A Matrix model containing methods for manipulating the sequencer's array of values. To learn how to manipulate the matrix, read about the matrix model. + * @type {matrix} + */ + this.matrix = new MatrixModel(this.settings.rows, this.settings.columns); + this.matrix.ui = this; + + /** + * A Counter model which the sequencer steps through. For example, you could use this model to step through the sequencer in reverse, randomly, or in a drunk walk. + * @type {counter} + */ + this.stepper = new CounterModel(0, this.columns); + + this.init(); + } + + _inherits(Sequencer, _Interface); + + _createClass(Sequencer, { + buildFrame: { + value: function buildFrame() { + this.element = document.createElement("div"); + this.element.style.position = "relative"; + this.element.style.display = "block"; + this.element.style.width = "100%"; + this.element.style.height = "100%"; + this.parent.appendChild(this.element); + if (touch.exists) { + this.addTouchListeners(); + } + } + }, + buildInterface: { + value: function buildInterface() { + + this.cells = []; + for (var i = 0; i < this.matrix.length; i++) { + + var _location = this.matrix.locate(i); + // returns {row,col} + + var container = document.createElement("span"); + container.style.position = "absolute"; + + var cell = new MatrixCell(container, { + component: true, + index: i, + row: _location.row, + column: _location.column, + mode: this.mode, + matrix: this + }, this.keyChange.bind(this, i)); + + // cell.matrix = this; + if (touch.exists) { + cell.pad.index = i; + cell.preClick = cell.preMove = cell.preRelease = function () {}; + cell.click = cell.move = cell.release = function () {}; + cell.preTouch = cell.preTouchMove = cell.preTouchRelease = function () {}; + cell.touch = cell.touchMove = cell.touchRelease = function () {}; + } + + this.cells.push(cell); + this.element.appendChild(container); + } + this.sizeInterface(); + } + }, + sizeInterface: { + value: function sizeInterface() { + + var cellWidth = this.width / this.columns; + var cellHeight = this.height / this.rows; + + for (var i = 0; i < this.cells.length; i++) { + var container = this.cells[i].parent; + container.style.left = this.cells[i].column * cellWidth + "px"; + container.style.top = this.cells[i].row * cellHeight + "px"; + this.cells[i].resize(cellWidth, cellHeight); + } + } + }, + colorInterface: { + value: function colorInterface() { + for (var i = 0; i < this.cells.length; i++) { + this.cells[i].render(); + } + } + }, + update: { + value: function update() { + var _this = this; + + // console.log("updating...") + //on = on || false; + this.matrix.iterate(function (r, c, i) { + // console.log(this.matrix.pattern[r][c], this.cells[i].state); + if (_this.matrix.pattern[r][c] !== _this.cells[i].state) { + if (_this.matrix.pattern[r][c] > 0) { + _this.cells[i].turnOn(); + } else { + _this.cells[i].turnOff(); + } + } + }); + } + }, + keyChange: { + + // update => cell.turnOn => cell.emit => keyChange (seq.emit) => matrix.set.cell => update + // + // interaction => keyChange => matrix.set.cell => update => cell.turnOn + // => emit + // + // set.cell => update => needs to emit. + + value: function keyChange(note, on) { + // emit data for any key turning on/off + // i is the note index + // v is whether it is on or off + var cell = this.matrix.locate(note); + // this.matrix.set.cell(cell.column,cell.row,on); + this.matrix.pattern[cell.row][cell.column] = on; + var data = { + row: cell.row, + column: cell.column, + state: on + }; + this.emit("change", data); + } + }, + render: { + value: function render() { + var _this = this; + + if (this.stepper.value >= 0) { + this.matrix.iterate(function (r, c, i) { + if (c === _this.stepper.value) { + _this.cells[i].pad.setAttribute("stroke", _this.colors.mediumLight); + _this.cells[i].pad.setAttribute("stroke-width", "1"); + _this.cells[i].pad.setAttribute("stroke-opacity", "1"); + } else { + _this.cells[i].pad.setAttribute("stroke", "none"); + } + }); + } + } + }, + start: { + + /** + * Start sequencing + * @param {number} ms Beat tempo in milliseconds + */ + + value: function start(ms) { + this.interval.event = this.next.bind(this); + if (ms) { + this.interval.ms(ms); + } + this.interval.start(); + } + }, + stop: { + + /** + Stop sequencing + */ + + value: function stop() { + this.interval.stop(); + } + }, + next: { + + /** + Manually jump to the next column and trigger the 'change' event. The "next" column is determined by your mode of sequencing. + */ + + value: function next() { + this.stepper.next(); + this.emit("step", this.matrix.column(this.stepper.value).reverse()); + this.render(); + } + }, + addTouchListeners: { + value: function addTouchListeners() { + var _this = this; + + this.preClick = this.preMove = this.preRelease = function () {}; + this.click = this.move = this.release = function () {}; + this.preTouch = this.preTouchMove = this.preTouchRelease = function () {}; + this.touch = this.touchMove = this.touchRelease = function () {}; + + this.currentElement = false; + + this.element.addEventListener("touchstart", function (e) { + var element = document.elementFromPoint(e.targetTouches[0].clientX, e.targetTouches[0].clientY); + var cell = _this.cells[element.index]; + _this.paintbrush = !cell.state; + cell.down(_this.paintbrush); + _this.currentElement = element.index; + e.preventDefault(); + e.stopPropagation(); + }); + + this.element.addEventListener("touchmove", function (e) { + var element = document.elementFromPoint(e.targetTouches[0].clientX, e.targetTouches[0].clientY); + var cell = _this.cells[element.index]; + if (element.index !== _this.currentElement) { + if (_this.currentElement >= 0) { + var pastCell = _this.cells[_this.currentElement]; + pastCell.up(); + } + cell.down(_this.paintbrush); + } else { + cell.bend(); + } + _this.currentElement = element.index; + e.preventDefault(); + e.stopPropagation(); + }); + + this.element.addEventListener("touchend", function (e) { + // no touches to calculate because none remaining + var cell = _this.cells[_this.currentElement]; + cell.up(); + _this.interacting = false; + _this.currentElement = false; + e.preventDefault(); + e.stopPropagation(); + }); + } + }, + rows: { + + /** + Number of rows in the sequencer + @type {number} + */ + + get: function () { + return this.matrix.rows; + }, + set: function (v) { + this.matrix.rows = v; + this.empty(); + this.buildInterface(); + this.update(); + } + }, + columns: { + + /** + Number of columns in the sequencer + @type {number} + */ + + get: function () { + return this.matrix.columns; + }, + set: function (v) { + this.matrix.columns = v; + this.stepper.max = v; + this.empty(); + this.buildInterface(); + this.update(); + } + } + }); + + return Sequencer; + })(Interface); + + module.exports = Sequencer; + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var math = _interopRequire(__webpack_require__(5)); + + var Sequence = _interopRequire(__webpack_require__(26)); + + // For the tutorial, looking at + + //Pattern section: + // .create(), .rows, .columns, + // .pattern, .length, .formatAsText(), .log(), + // .locate(i), .indexOf(c,r) + // row(), column() (returns contents of row or colum) + + //Control section: + // toggle x3 + // set x4 + // rotate x3 + // populate x3 + // erase x3 + + // should some version of this have a float value for each cell? + // could be like a mirror .pattern that has values. by default, everything is 1, but could be set... + // not a good way to do that on interface, but as a model it would be nice... + // for .formatAsText(), could multiply by 100 and floor, so each cell is an int from 0 to 9 + + var Matrix = (function () { + function Matrix(rows, columns) { + var _this = this; + + _classCallCheck(this, Matrix); + + // should also have ability to create using an existing matrix (2d array) + this.pattern = []; + this.create(rows, columns); + + this.toggle = { + cell: function (column, row) { + _this.pattern[row][column] = !_this.pattern[row][column]; // math.invert(this.pattern[row][column]); + if (_this.ui) { + _this.ui.update(); + } + return _this.pattern[row][column]; + }, + all: function () { + _this.iterate(function (r, c) { + _this.toggle.cell(c, r); + }); + if (_this.ui) { + _this.ui.update(); + } + }, + row: function (row) { + for (var i = 0; i < _this.columns; i++) { + _this.toggle.cell(i, row); + } + if (_this.ui) { + _this.ui.update(); + } + }, + column: function (column) { + for (var i = 0; i < _this.rows; i++) { + _this.toggle.cell(column, i); + } + if (_this.ui) { + _this.ui.update(); + } + } + }; + + this.set = { + cell: function (column, row, value) { + _this.pattern[row][column] = value; + if (_this.ui) { + _this.ui.update(); + } + }, + all: function (values) { + // set the whole matrix using a 2d array as input + // this should also resize the array? + _this.pattern = values; + if (_this.ui) { + _this.ui.update(); + } + }, + row: function (row, values) { + // set a row using an array as input + _this.pattern[row] = values; + if (_this.ui) { + _this.ui.update(); + } + }, + column: function (column, values) { + // set a column using an array as input + _this.pattern.forEach(function (row, i) { + _this.pattern[i][column] = values[i]; + }); + if (_this.ui) { + _this.ui.update(); + } + } + }; + + this.rotate = { + //should eventually do (amountX, amountY) here + // could just use a loop and this.rotate.row(i,amountX); + all: function (amount) { + if (!amount && amount !== 0) { + amount = 1; + } + amount %= _this.pattern[0].length; + if (amount < 0) { + amount = _this.pattern[0].length + amount; + } + for (var i = 0; i < _this.rows; i++) { + var cut = _this.pattern[i].splice(_this.pattern[i].length - amount, amount); + _this.pattern[i] = cut.concat(_this.pattern[i]); + } + if (_this.ui) { + _this.ui.update(); + } + }, + row: function (row, amount) { + if (!amount && amount !== 0) { + amount = 1; + } + amount %= _this.pattern[0].length; + if (amount < 0) { + amount = _this.pattern[0].length + amount; + } + var cut = _this.pattern[row].splice(_this.pattern[row].length - amount, amount); + _this.pattern[row] = cut.concat(_this.pattern[row]); + if (_this.ui) { + _this.ui.update(); + } + }, + column: function (column, amount) { + if (!amount && amount !== 0) { + amount = 1; + } + amount %= _this.pattern.length; + if (amount < 0) { + amount = _this.pattern.length + amount; + } + var proxy = []; + _this.pattern.forEach(function (row) { + proxy.push(row[column]); + }); + var cut = proxy.splice(proxy.length - amount, amount); + proxy = cut.concat(proxy); + _this.pattern.forEach(function (row, i) { + row[column] = proxy[i]; + }); + if (_this.ui) { + _this.ui.update(); + } + } + }; + + // the idea behind populate is to be able to set a whole row or column to 0 or 1 + // IF the value is a float, such as 0.7, then it would become a probability + // so populate(0.7) would give each cell a 70% chance of being 1 + this.populate = { + all: function (odds) { + var oddsSequence = new Sequence(odds); + _this.iterate(function (r, c) { + _this.pattern[r][c] = math.coin(oddsSequence.next()); + }); + // This could be used so that each row has same odds pattern, even if row length is not divisibly by sequence length. + //,() => { + // odds.pos = -1; + // } + if (_this.ui) { + _this.ui.update(); + } + }, + row: function () { + var row = arguments[0] === undefined ? 0 : arguments[0]; + var odds = arguments[1] === undefined ? 1 : arguments[1]; + + var oddsSequence = new Sequence(odds); + _this.pattern[row].forEach(function (cell, i) { + _this.pattern[row][i] = math.coin(oddsSequence.next()); + }); + if (_this.ui) { + _this.ui.update(); + } + }, + column: function () { + var column = arguments[0] === undefined ? 0 : arguments[0]; + var odds = arguments[1] === undefined ? 1 : arguments[1]; + + var oddsSequence = new Sequence(odds); + _this.pattern.forEach(function (row, i) { + _this.pattern[i][column] = math.coin(oddsSequence.next()); + }); + if (_this.ui) { + _this.ui.update(); + } + } + }; + + // essentiall populate(0) so i'm not sure if this is necessary but is nice + this.erase = { + all: function () { + _this.set.all(0); + }, + row: function (row) { + _this.set.row(row, 0); + }, + column: function (column) { + _this.set.column(column, 0); + } + }; + + // end constructor + } + + _createClass(Matrix, { + create: { + value: function create(rows, columns) { + var _this = this; + + this.pattern = []; + for (var row = 0; row < rows; row++) { + var arr = new Array(columns); + this.pattern.push(arr); + } + this.iterate(function (r, c) { + _this.pattern[r][c] = false; + }); + } + }, + iterate: { + value: function iterate(f, f2) { + var i = 0; + for (var row = 0; row < this.rows; row++) { + if (f2) { + f2(row); + } + for (var column = 0; column < this.columns; column++) { + f(row, column, i); + i++; + } + } + } + }, + formatAsText: { + value: function formatAsText() { + var _this = this; + + var patternString = ""; + this.iterate(function (r, c) { + patternString += (_this.pattern[r][c] ? 1 : 0) + " "; + }, function () { + patternString += "\n"; + }); + return patternString; + } + }, + log: { + value: function log() { + console.log(this.formatAsText()); + } + }, + update: { + value: function update(pattern) { + this.pattern = pattern || this.pattern; + } + }, + length: { + get: function () { + return this.rows * this.columns; + } + }, + locate: { + value: function locate(index) { + // returns row and column of cell by index + return { + row: ~ ~(index / this.columns), + column: index % this.columns + }; + } + }, + indexOf: { + value: function indexOf(row, column) { + return column + row * this.columns; + // returns index of cell by row and column + } + }, + row: { + value: (function (_row) { + var _rowWrapper = function row(_x) { + return _row.apply(this, arguments); + }; + + _rowWrapper.toString = function () { + return _row.toString(); + }; + + return _rowWrapper; + })(function (row) { + var data = []; + for (var i = 0; i < this.columns; i++) { + data.push(this.pattern[row] ? 1 : 0); + } + return data; + }) + }, + column: { + value: (function (_column) { + var _columnWrapper = function column(_x2) { + return _column.apply(this, arguments); + }; + + _columnWrapper.toString = function () { + return _column.toString(); + }; + + return _columnWrapper; + })(function (column) { + var data = []; + for (var i = 0; i < this.rows; i++) { + data.push(this.pattern[i][column] ? 1 : 0); + } + return data; + }) + }, + rows: { + get: function () { + return this.pattern.length; + }, + set: function (v) { + var _this = this; + + var previous = this.pattern.slice(0); + this.create(v, this.columns); + this.iterate(function (r, c) { + if (previous[r] && previous[r][c]) { + _this.pattern[r][c] = previous[r][c]; + } + }); + } + }, + columns: { + get: function () { + return this.pattern[0].length; + }, + set: function (v) { + var _this = this; + + var previous = this.pattern.slice(0); + this.create(this.rows, v); + this.iterate(function (r, c) { + if (previous[r] && previous[r][c]) { + _this.pattern[r][c] = previous[r][c]; + } + }); + } + } + }); + + return Matrix; + })(); + + module.exports = Matrix; + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var math = _interopRequire(__webpack_require__(5)); + + var Drunk = _interopRequire(__webpack_require__(27)); + + var Sequence = (function () { + function Sequence() { + var sequence = arguments[0] === undefined ? [0, 10, 20, 30] : arguments[0]; + var mode = arguments[1] === undefined ? "up" : arguments[1]; + var position = arguments[2] === undefined ? false : arguments[2]; + + _classCallCheck(this, Sequence); + + this.values = sequence; + if (!Array.isArray(this.values)) { + this.values = [this.values]; + } + this._mode = mode; + this.position = position; + + this.drunkWalk = new Drunk(0, this.values.length - 1); + + this.startValues = { + up: 0, + down: this.values.length - 1, + drunk: ~ ~(this.values.length / 2), + random: math.ri(this.values.length) + }; + + if (this.position !== false) { + this.next = this[this._mode]; + } else { + this.next = this.first; + } + } + + _createClass(Sequence, { + mode: { + get: function () { + return this._mode; + }, + set: function (mode) { + if (!(mode === "up" || mode === "down" || mode === "random" || mode === "drunk")) { + console.error("The only modes currently allowed are: up, down, random, drunk"); + return; + } + this._mode = mode; + if (this.position) { + this.next = this[this._mode]; + } + } + }, + value: { + get: function () { + return this.values[this.position]; + }, + set: function (v) { + this.position = this.values.indexOf(v); + } + }, + first: { + value: function first() { + if (this.position !== false) { + this.next = this[this._mode]; + return this.next(); + } + this.position = this.startValues[this._mode]; + this.next = this[this._mode]; + return this.value; + } + }, + up: { + value: function up() { + this.position++; + this.position %= this.values.length; + return this.value; + } + }, + down: { + value: function down() { + this.position--; + if (this.position < 0) { + this.position = (this.position + this.values.length) % this.values.length; + } + return this.value; + } + }, + random: { + value: function random() { + this.position = math.ri(0, this.values.length); + return this.value; + } + }, + drunk: { + value: function drunk() { + this.drunkWalk.max = this.values.length; + this.drunkWalk.value = this.position; + this.position = this.drunkWalk.next(); + return this.value; + } + + /* future methods
+ .group(start,stop) -- outputs a group of n items from the list, with wrapping
+ .loop(start,stop) -- confines sequencing to a subset of the values
+ (could even have a distinction between .originalValues and the array of values being used)
+ */ + + } + }); + + return Sequence; + })(); + + module.exports = Sequence; + +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var math = _interopRequire(__webpack_require__(5)); + + var Drunk = (function () { + function Drunk() { + var min = arguments[0] === undefined ? 0 : arguments[0]; + var max = arguments[1] === undefined ? 9 : arguments[1]; + var value = arguments[2] === undefined ? 0 : arguments[2]; + var increment = arguments[3] === undefined ? 1 : arguments[3]; + var loop = arguments[4] === undefined ? false : arguments[4]; + + _classCallCheck(this, Drunk); + + this.min = min; + this.max = max; + this.value = value; + this.increment = increment; + this.loop = loop; + } + + _createClass(Drunk, { + next: { + value: function next() { + this.value += math.pick(-1 * this.increment, this.increment); + if (this.value > this.max) { + if (this.loop) { + this.value = this.min; + } else { + this.value = this.max - this.increment; + } + } + + if (this.value < this.min) { + if (this.loop) { + this.value = this.max; + } else { + this.value = this.min + this.increment; + } + } + return this.value; + } + } + }); + + return Drunk; + })(); + + module.exports = Drunk; + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var math = _interopRequire(__webpack_require__(5)); + + var Drunk = _interopRequire(__webpack_require__(27)); + + var Counter = (function () { + function Counter() { + var min = arguments[0] === undefined ? 0 : arguments[0]; + var max = arguments[1] === undefined ? 10 : arguments[1]; + var mode = arguments[2] === undefined ? "up" : arguments[2]; + var value = arguments[3] === undefined ? false : arguments[3]; + + _classCallCheck(this, Counter); + + this.min = min; + this.max = max; + this.value = value; + this.mode = mode; + this.drunkWalk = new Drunk(this.min, this.max); + if (this.value !== false) { + this.next = this[this._mode]; + } else { + this.next = this.first; + } + } + + _createClass(Counter, { + mode: { + set: function (mode) { + if (!(mode === "up" || mode === "down" || mode === "random" || mode === "drunk")) { + console.error("The only modes currently allowed are: up, down, random, drunk"); + return; + } + this._mode = mode; + if (this.value) { + this.next = this[this._mode]; + } + }, + get: function () { + return this._mode; + } + }, + first: { + value: function first() { + if (this.value !== false) { + this.next = this[this._mode]; + return this.next(); + } + this.startValues = { + up: this.min, + down: this.max, + drunk: ~ ~math.average(this.min, this.max), + random: math.ri(this.min, this.max) + }; + this.value = this.startValues[this._mode]; + this.next = this[this._mode]; + return this.value; + } + }, + up: { + value: function up() { + this.value++; + if (this.value >= this.max) { + this.value = this.min; + } + return this.value; + } + }, + down: { + value: function down() { + this.value--; + if (this.value < this.min) { + this.value = this.max; + } + return this.value; + } + }, + random: { + value: function random() { + this.value = math.ri(this.min, this.max); + return this.value; + } + }, + drunk: { + value: function drunk() { + this.drunkWalk.min = this.min; + this.drunkWalk.max = this.max; + this.drunkWalk.value = this.value; + this.value = this.drunkWalk.next(); + return this.value; + } + } + }); + + return Counter; + })(); + + module.exports = Counter; + +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; }; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var svg = __webpack_require__(4); + var math = __webpack_require__(5); + var Interface = __webpack_require__(6); + var Step = __webpack_require__(11); + + var Interaction = _interopRequireWildcard(__webpack_require__(12)); + + /** + * Pan2D + * + * @description Interface for moving a sound around an array of speakers. Speaker locations can be customized. The interface calculates the closeness of the sound source to each speaker and returns that distance as a numeric value. + * + * @demo <span nexus-ui="pan2D"></span> + * + * @example + * var pan2d = new Nexus.Pan2d('#target') + * + * @example + * var pan2d = new Nexus.Pan2D('#target',{ + * 'size': [200,200], + * 'range': 0.5, // detection radius of each speaker + * 'mode': 'absolute', // 'absolute' or 'relative' sound movement + * 'speakers': [ // the speaker [x,y] positions + * [0.5,0.2], + * [0.75,0.25], + * [0.8,0.5], + * [0.75,0.75], + * [0.5,0.8], + * [0.25,0.75] + * [0.2,0.5], + * [0.25,0.25] + * ] + * }) + * + * @output + * change + * Fires any time the "source" node's position changes. <br> + * The event data is an array of the amplitudes (0-1), representing the level of each speaker (as calculated by its distance to the audio source). + * + * @outputexample + * pan2d.on('change',function(v) { + * console.log(v); + * }) + * + */ + + var Pan2D = (function (_Interface) { + function Pan2D() { + _classCallCheck(this, Pan2D); + + var options = ["range"]; + + var defaults = { + size: [200, 200], + range: 0.5, + mode: "absolute", + speakers: [[0.5, 0.2], [0.75, 0.25], [0.8, 0.5], [0.75, 0.75], [0.5, 0.8], [0.25, 0.75], [0.2, 0.5], [0.25, 0.25]] + }; + + _get(Object.getPrototypeOf(Pan2D.prototype), "constructor", this).call(this, arguments, options, defaults); + + this.value = { + x: new Step(0, 1, 0, 0.5), + y: new Step(0, 1, 0, 0.5) + }; + + /** + Absolute or relative mouse interaction. In "absolute" mode, the source node will jump to your mouse position on mouse click. In "relative" mode, it does not. + */ + this.mode = this.settings.mode; + + this.position = { + x: new Interaction.Handle(this.mode, "horizontal", [0, this.width], [this.height, 0]), + y: new Interaction.Handle(this.mode, "vertical", [0, this.width], [this.height, 0]) + }; + this.position.x.value = this.value.x.normalized; + this.position.y.value = this.value.y.normalized; + + /** + An array of speaker locations. Update this with .moveSpeaker() or .moveAllSpeakers() + */ + this.speakers = this.settings.speakers; + + /** + Rewrite: The maximum distance from a speaker that the source node can be for it to be heard from that speaker. A low range (0.1) will result in speakers only playing when the sound is very close it. Default is 0.5 (half of the interface). + */ + this.range = this.settings.range; + + /** + The current levels for each speaker. This is calculated when a source node or speaker node is moved through interaction or programatically. + */ + this.levels = []; + + this.init(); + + this.calculateLevels(); + this.render(); + } + + _inherits(Pan2D, _Interface); + + _createClass(Pan2D, { + buildInterface: { + value: function buildInterface() { + + this.knob = svg.create("circle"); + + this.element.appendChild(this.knob); + + // add speakers + this.speakerElements = []; + + for (var i = 0; i < this.speakers.length; i++) { + var speakerElement = svg.create("circle"); + + this.element.appendChild(speakerElement); + + this.speakerElements.push(speakerElement); + } + } + }, + sizeInterface: { + value: function sizeInterface() { + + this._minDimension = Math.min(this.width, this.height); + + this.knobRadius = { + off: ~ ~(this._minDimension / 100) * 3 + 5 }; + this.knobRadius.on = this.knobRadius.off * 2; + + this.knob.setAttribute("cx", this.width / 2); + this.knob.setAttribute("cy", this.height / 2); + this.knob.setAttribute("r", this.knobRadius.off); + + for (var i = 0; i < this.speakers.length; i++) { + var speakerElement = this.speakerElements[i]; + var speaker = this.speakers[i]; + speakerElement.setAttribute("cx", speaker[0] * this.width); + speakerElement.setAttribute("cy", speaker[1] * this.height); + speakerElement.setAttribute("r", this._minDimension / 20 + 5); + speakerElement.setAttribute("fill-opacity", "0"); + } + + this.position.x.resize([0, this.width], [this.height, 0]); + this.position.y.resize([0, this.width], [this.height, 0]); + + // next, need to + // resize positions + // calculate speaker distances + this.calculateLevels(); + this.render(); + } + }, + colorInterface: { + value: function colorInterface() { + + this.element.style.backgroundColor = this.colors.fill; + this.knob.setAttribute("fill", this.colors.mediumLight); + + for (var i = 0; i < this.speakers.length; i++) { + var speakerElement = this.speakerElements[i]; + speakerElement.setAttribute("fill", this.colors.accent); + speakerElement.setAttribute("stroke", this.colors.accent); + } + } + }, + render: { + value: function render() { + this.knobCoordinates = { + x: this.value.x.normalized * this.width, + y: this.height - this.value.y.normalized * this.height + }; + + this.knob.setAttribute("cx", this.knobCoordinates.x); + this.knob.setAttribute("cy", this.knobCoordinates.y); + } + }, + click: { + value: function click() { + this.position.x.anchor = this.mouse; + this.position.y.anchor = this.mouse; + this.move(); + } + }, + move: { + value: function move() { + if (this.clicked) { + this.position.x.update(this.mouse); + this.position.y.update(this.mouse); + // position.x and position.y are normalized + // so are the levels + // likely don't need this.value at all -- only used for drawing + // not going to be a 'step' or 'min' and 'max' in this one. + this.calculateLevels(); + this.emit("change", this.levels); + this.render(); + } + } + }, + release: { + value: function release() { + this.render(); + } + }, + normalized: { + get: function () { + return { + x: this.value.x.normalized, + y: this.value.y.normalized + }; + } + }, + calculateLevels: { + value: function calculateLevels() { + var _this = this; + + this.value.x.updateNormal(this.position.x.value); + this.value.y.updateNormal(this.position.y.value); + this.levels = []; + this.speakers.forEach(function (s, i) { + var distance = math.distance(s[0] * _this.width, s[1] * _this.height, _this.position.x.value * _this.width, (1 - _this.position.y.value) * _this.height); + var level = math.clip(1 - distance / (_this.range * _this.width), 0, 1); + _this.levels.push(level); + _this.speakerElements[i].setAttribute("fill-opacity", level); + }); + } + }, + moveSource: { + + /** + Move the audio source node and trigger the output event. + @param x {number} New x location, normalized 0-1 + @param y {number} New y location, normalized 0-1 + */ + + value: function moveSource(x, y) { + var location = { + x: x * this.width, + y: y * this.height + }; + this.position.x.update(location); + this.position.y.update(location); + this.calculateLevels(); + this.emit("change", this.levels); + this.render(); + } + }, + moveSpeaker: { + + /** + Move a speaker node and trigger the output event. + @param index {number} Index of the speaker to move + @param x {number} New x location, normalized 0-1 + @param y {number} New y location, normalized 0-1 + */ + + value: function moveSpeaker(index, x, y) { + + this.speakers[index] = [x, y]; + this.speakerElements[index].setAttribute("cx", x * this.width); + this.speakerElements[index].setAttribute("cy", y * this.height); + this.calculateLevels(); + this.emit("change", this.levels); + this.render(); + } + + /** + Set all speaker locations + @param locations {Array} Array of speaker locations. Each item in the array should be an array of normalized x and y coordinates. + setSpeakers(locations) { + } + */ + + } + }); + + return Pan2D; + })(Interface); + + module.exports = Pan2D; + +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var math = __webpack_require__(5); + var svg = __webpack_require__(4); + var Interface = __webpack_require__(6); + + /** + * Tilt + * + * @description Device tilt sensor with 2 or 3 axes (depending on your device and browser). + * + * @demo <span nexus-ui='tilt'></span> + * + * @example + * var tilt = new Nexus.Tilt('#target') + * + * @output + * change + * Fires at a regular interval, as long as this interface is active (see the interface's <i>.active</i> property)<br> + * The event data is an <i>object</i> containing x (number) and y (number) properties which represent the current tilt state of the device. + * + * @outputexample + * tilt.on('change',function(v) { + * console.log(v); + * }) + * + * + */ + + var Tilt = (function (_Interface) { + function Tilt() { + _classCallCheck(this, Tilt); + + var options = ["value"]; + + var defaults = { + size: [80, 80] + }; + + _get(Object.getPrototypeOf(Tilt.prototype), "constructor", this).call(this, arguments, options, defaults); + + this._active = true; + + this.init(); + + // add event listener for device orientation + + this.boundUpdate = this.update.bind(this); + // this.boundMozTilt = this.mozTilt.bind(this) + + if (window.DeviceOrientationEvent) { + this.orientationListener = window.addEventListener("deviceorientation", this.boundUpdate, false); + } else { + this._active = false; + this.colorInterface(); + } + + /*else if (window.OrientationEvent) { + // window.addEventListener('MozOrientation', this.boundMozTilt, false); + } else { + console.log('Not supported on your device or browser.'); + } */ + } + + _inherits(Tilt, _Interface); + + _createClass(Tilt, { + buildInterface: { + value: function buildInterface() { + + this.title = svg.create("text"); + this.circleX = svg.create("circle"); + this.circleY = svg.create("circle"); + this.circleZ = svg.create("circle"); + + this.barX = svg.create("path"); + this.barY = svg.create("path"); + this.barZ = svg.create("path"); + + this.barX2 = svg.create("path"); + this.barY2 = svg.create("path"); + this.barZ2 = svg.create("path"); + + this.barX.setAttribute("opacity", "0.8"); + this.barY.setAttribute("opacity", "0.8"); + this.barZ.setAttribute("opacity", "0.8"); + this.barX2.setAttribute("opacity", "0.8"); + this.barY2.setAttribute("opacity", "0.8"); + this.barZ2.setAttribute("opacity", "0.8"); + + this.circleX.setAttribute("cx", this.width * 3 / 12); + this.circleX.setAttribute("cy", this.height * 3 / 4); + this.circleX.setAttribute("r", this.height / 10); + this.circleX.setAttribute("opacity", "0.4"); + + this.circleY.setAttribute("cx", this.width * 6 / 12); + this.circleY.setAttribute("cy", this.height * 3 / 4); + this.circleY.setAttribute("r", this.height / 10); + this.circleY.setAttribute("opacity", "0.4"); + + this.circleZ.setAttribute("cx", this.width * 9 / 12); + this.circleZ.setAttribute("cy", this.height * 3 / 4); + this.circleZ.setAttribute("r", this.height / 10); + this.circleZ.setAttribute("opacity", "0.4"); + + this.barX.setAttribute("stroke-width", Math.round(this.height / 30)); + this.barY.setAttribute("stroke-width", Math.round(this.height / 30)); + this.barZ.setAttribute("stroke-width", Math.round(this.height / 30)); + + this.barX.setAttribute("fill", "none"); + this.barY.setAttribute("fill", "none"); + this.barZ.setAttribute("fill", "none"); + + this.barX2.setAttribute("stroke-width", Math.round(this.height / 30)); + this.barY2.setAttribute("stroke-width", Math.round(this.height / 30)); + this.barZ2.setAttribute("stroke-width", Math.round(this.height / 30)); + + this.barX2.setAttribute("fill", "none"); + this.barY2.setAttribute("fill", "none"); + this.barZ2.setAttribute("fill", "none"); + + this.title.setAttribute("x", this.width / 2); + this.title.setAttribute("y", this.height / 3 + 7); + this.title.setAttribute("font-size", "15px"); + this.title.setAttribute("font-weight", "bold"); + this.title.setAttribute("letter-spacing", "2px"); + this.title.setAttribute("opacity", "0.7"); + this.title.setAttribute("text-anchor", "middle"); + this.title.textContent = "TILT"; + + this.element.appendChild(this.circleX); + this.element.appendChild(this.circleY); + this.element.appendChild(this.circleZ); + + this.element.appendChild(this.barX); + this.element.appendChild(this.barY); + this.element.appendChild(this.barZ); + + this.element.appendChild(this.barX2); + this.element.appendChild(this.barY2); + this.element.appendChild(this.barZ2); + + this.element.appendChild(this.title); + } + }, + colorInterface: { + value: function colorInterface() { + + if (this._active) { + this.element.style.backgroundColor = this.colors.accent; + this.circleX.setAttribute("fill", this.colors.light); + this.circleY.setAttribute("fill", this.colors.light); + this.circleZ.setAttribute("fill", this.colors.light); + this.circleX.setAttribute("stroke", this.colors.light); + this.circleY.setAttribute("stroke", this.colors.light); + this.circleZ.setAttribute("stroke", this.colors.light); + this.barX.setAttribute("stroke", this.colors.light); + this.barY.setAttribute("stroke", this.colors.light); + this.barZ.setAttribute("stroke", this.colors.light); + this.barX2.setAttribute("stroke", this.colors.light); + this.barY2.setAttribute("stroke", this.colors.light); + this.barZ2.setAttribute("stroke", this.colors.light); + this.title.setAttribute("fill", this.colors.light); + } else { + this.element.style.backgroundColor = this.colors.fill; + this.circleX.setAttribute("fill", this.colors.mediumLight); + this.circleY.setAttribute("fill", this.colors.mediumLight); + this.circleZ.setAttribute("fill", this.colors.mediumLight); + this.circleX.setAttribute("stroke", this.colors.mediumLight); + this.circleY.setAttribute("stroke", this.colors.mediumLight); + this.circleZ.setAttribute("stroke", this.colors.mediumLight); + this.barX.setAttribute("stroke", this.colors.mediumLight); + this.barY.setAttribute("stroke", this.colors.mediumLight); + this.barZ.setAttribute("stroke", this.colors.mediumLight); + this.barX2.setAttribute("stroke", this.colors.mediumLight); + this.barY2.setAttribute("stroke", this.colors.mediumLight); + this.barZ2.setAttribute("stroke", this.colors.mediumLight); + this.title.setAttribute("fill", this.colors.mediumLight); + } + } + }, + update: { + value: function update(v) { + if (this._active) { + + var y = v.beta; + var x = v.gamma; + var z = v.alpha; + + // take the original -90 to 90 scale and normalize it 0-1 + x = math.scale(x, -90, 90, 0, 1); + y = math.scale(y, -90, 90, 0, 1); + z = math.scale(z, 0, 360, 0, 1); + + var handlePoints = { + start: Math.PI * 1.5, + end: math.clip(math.scale(x, 0, 0.5, Math.PI * 1.5, Math.PI * 0.5), Math.PI * 0.5, Math.PI * 1.5) + }; + var handle2Points = { + start: Math.PI * 2.5, + end: math.clip(math.scale(x, 0.5, 1, Math.PI * 2.5, Math.PI * 1.5), Math.PI * 1.5, Math.PI * 2.5) + }; + + var handlePath = svg.arc(this.circleX.cx.baseVal.value, this.circleX.cy.baseVal.value, this.circleX.r.baseVal.value, handlePoints.start, handlePoints.end); + var handle2Path = svg.arc(this.circleX.cx.baseVal.value, this.circleX.cy.baseVal.value, this.circleX.r.baseVal.value, handle2Points.start, handle2Points.end); + + this.barX.setAttribute("d", handlePath); + this.barX2.setAttribute("d", handle2Path); + + handlePoints = { + start: Math.PI * 1.5, + end: math.clip(math.scale(y, 0, 0.5, Math.PI * 1.5, Math.PI * 0.5), Math.PI * 0.5, Math.PI * 1.5) + }; + handle2Points = { + start: Math.PI * 2.5, + end: math.clip(math.scale(y, 0.5, 1, Math.PI * 2.5, Math.PI * 1.5), Math.PI * 1.5, Math.PI * 2.5) + }; + + handlePath = svg.arc(this.circleY.cx.baseVal.value, this.circleY.cy.baseVal.value, this.circleY.r.baseVal.value, handlePoints.start, handlePoints.end); + handle2Path = svg.arc(this.circleY.cx.baseVal.value, this.circleY.cy.baseVal.value, this.circleY.r.baseVal.value, handle2Points.start, handle2Points.end); + + this.barY.setAttribute("d", handlePath); + this.barY2.setAttribute("d", handle2Path); + + handlePoints = { + start: Math.PI * 1.5, + end: math.clip(math.scale(z, 0, 0.5, Math.PI * 1.5, Math.PI * 0.5), Math.PI * 0.5, Math.PI * 1.5) + }; + handle2Points = { + start: Math.PI * 2.5, + end: math.clip(math.scale(z, 0.5, 1, Math.PI * 2.5, Math.PI * 1.5), Math.PI * 1.5, Math.PI * 2.5) + }; + + handlePath = svg.arc(this.circleZ.cx.baseVal.value, this.circleZ.cy.baseVal.value, this.circleZ.r.baseVal.value, handlePoints.start, handlePoints.end); + handle2Path = svg.arc(this.circleZ.cx.baseVal.value, this.circleZ.cy.baseVal.value, this.circleZ.r.baseVal.value, handle2Points.start, handle2Points.end); + + this.barZ.setAttribute("d", handlePath); + this.barZ2.setAttribute("d", handle2Path); + + /* + let pointsX = { + start: 0, + end: math.scale( x, 0, 1, 0, Math.PI*2 ) + }; + // console.log(this.circleX.cx.baseVal.value); + let pathX = svg.arc(this.circleX.cx.baseVal.value, this.circleX.cy.baseVal.value, this.circleX.r.baseVal.value*2, pointsX.start, pointsX.end); + this.barX.setAttribute('d',pathX); */ + + //this.textH.textContent = math.prune(x,2); + //this.textV.textContent = math.prune(y,2); + // + // this.circleX.setAttribute('opacity',x); + // this.circleY.setAttribute('opacity',y); + // this.circleZ.setAttribute('opacity',z); + + this.emit("change", { + x: x, + y: y, + z: z + }); + } + } + }, + click: { + value: function click() { + if (window.DeviceOrientationEvent) { + this.active = !this.active; + } + } + }, + active: { + + /** + Whether the interface is on (emitting values) or off (paused & not emitting values). Setting this property will update it. + @type {boolean} + */ + + get: function () { + return this._active; + }, + set: function (on) { + this._active = on; + this.colorInterface(); + } + }, + customDestroy: { + value: function customDestroy() { + window.removeEventListener("deviceorientation", this.boundUpdate, false); + } + } + }); + + return Tilt; + })(Interface); + + module.exports = Tilt; + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var dom = __webpack_require__(7); + var math = __webpack_require__(5); + var Interface = __webpack_require__(6); + var SliderTemplate = __webpack_require__(32); + var touch = __webpack_require__(9); + + var SingleSlider = (function (_SliderTemplate) { + function SingleSlider() { + var _this = this; + + _classCallCheck(this, SingleSlider); + + var options = ["scale", "value"]; + + var defaults = { + size: [120, 20], + orientation: "vertical", + mode: "absolute", + scale: [0, 1], + step: 0, + value: 0, + hasKnob: true + }; + + _get(Object.getPrototypeOf(SingleSlider.prototype), "constructor", this).call(this, arguments, options, defaults); + + /* events */ + + if (!touch.exists) { + + this.click = function () { + _this.multislider.interacting = true; + _this.multislider.interpolation = { + index: _this.index, + value: _this.value + }; + _this.down(); + _this.multislider.values[_this.index] = _this.value; + }; + this.element.addEventListener("mouseover", function (e) { + if (_this.multislider.interacting) { + if (!_this.offset) { + _this.offset = dom.findPosition(_this.element); + } + _this.mouse = dom.locateMouse(e, _this.offset); + _this.down(); + _this.multislider.values[_this.index] = _this.value; + if (_this.multislider.interpolation) { + var distance = Math.abs(_this.multislider.interpolation.index - _this.index); + if (distance > 1) { + var low = Math.min(_this.multislider.interpolation.index, _this.index); + var high = Math.max(_this.multislider.interpolation.index, _this.index); + var lowValue = _this.multislider.sliders[low].value; + var highValue = _this.multislider.sliders[high].value; + for (var i = low; i < high; i++) { + _this.multislider.sliders[i].value = math.interp((i - low) / distance, lowValue, highValue); + var smoothedValue = _this.multislider.sliders[i].value; + _this.multislider.values[i] = smoothedValue; + _this.multislider.update(i, smoothedValue); + } + } + } + + _this.multislider.interpolation = { + index: _this.index, + value: _this.value + }; + } + }); + + this.move = function () {}; + this.element.addEventListener("mousemove", function (e) { + if (_this.multislider.interacting) { + if (!_this.offset) { + _this.offset = dom.findPosition(_this.element); + } + _this.mouse = dom.locateMouse(e, _this.offset); + _this.slide(); + _this.multislider.values[_this.index] = _this.value; + } + }); + + this.release = function () { + _this.multislider.interacting = false; + _this.multislider.interpolation = false; + }; + this.element.addEventListener("mouseup", function () { + if (_this.multislider.interacting) { + _this.up(); + _this.multislider.interpolation = false; + _this.multislider.values[_this.index] = _this.value; + } + }); + this.element.addEventListener("mouseout", function () { + if (_this.multislider.interacting) { + _this.up(); + _this.multislider.values[_this.index] = _this.value; + } + }); + } + + this.customStyle(); + } + + _inherits(SingleSlider, _SliderTemplate); + + _createClass(SingleSlider, { + customStyle: { + value: function customStyle() { + + /* style changes */ + + this.bar.setAttribute("x", 0); + this.bar.setAttribute("transform", "translate(0,0)"); + this.bar.setAttribute("rx", 0); // corner radius + this.bar.setAttribute("ry", 0); + this.bar.setAttribute("width", this.width); + this.bar.setAttribute("height", this.height); + + this.fillbar.setAttribute("x", 0); + this.fillbar.setAttribute("transform", "translate(0,0)"); + this.fillbar.setAttribute("rx", 0); // corner radius + this.fillbar.setAttribute("ry", 0); + this.fillbar.setAttribute("width", this.width); + this.fillbar.setAttribute("height", this.height); + } + } + }); + + return SingleSlider; + })(SliderTemplate); + + /** + * Multislider + * + * @description Multislider + * + * @demo <span nexus-ui="multislider"></span> + * + * @example + * var multislider = new Nexus.Multislider('#target') + * + * @example + * var multislider = new Nexus.Multislider('#target',{ + * 'size': [200,100], + * 'numberOfSliders': 5, + * 'min': 0, + * 'max': 1, + * 'step': 0, + * 'values': [0.7,0.7,0.7,0.7,0.7] + * }) + * + * @output + * change + * Fires any time the interface's value changes. <br> + * The event data an object containing <i>index</i> and <i>value</i> properties + * + * @outputexample + * multislider.on('change',function(v) { + * console.log(v); + * }) + * + */ + + /* + Properties + .values + + */ + + var Multislider = (function (_Interface) { + function Multislider() { + _classCallCheck(this, Multislider); + + var options = ["value"]; + + var defaults = { + size: [200, 100], + numberOfSliders: 5, + min: 0, + max: 1, + step: 0, + values: [0.7, 0.7, 0.7, 0.7, 0.7] + }; + + _get(Object.getPrototypeOf(Multislider.prototype), "constructor", this).call(this, arguments, options, defaults); + + this._numberOfSliders = this.settings.numberOfSliders; + this.values = this.settings.values; + + this.sliders = []; + + this.interacting = false; + + this.init(); + } + + _inherits(Multislider, _Interface); + + _createClass(Multislider, { + buildFrame: { + value: function buildFrame() { + this.element = document.createElement("div"); + this.parent.appendChild(this.element); + } + }, + buildInterface: { + value: function buildInterface() { + + var min = this.settings.min; + var max = this.settings.max; + var step = this.settings.step; + + if (this.sliders.length) { + min = this.sliders[0].min; + max = this.sliders[0].max; + step = this.sliders[0].step; + } + + this.sliders = []; + + for (var i = 0; i < this._numberOfSliders; i++) { + var container = document.createElement("span"); + + var slider = new SingleSlider(container, { + scale: [min, max], + step: step, + mode: "absolute", + orientation: "vertical", + value: this.values[i], + hasKnob: false, + component: true }, this.update.bind(this, i)); + slider.multislider = this; + + slider.index = i; + if (touch.exists) { + slider.bar.index = i; + slider.fillbar.index = i; + slider.preClick = slider.preMove = slider.preRelease = function () {}; + slider.click = slider.move = slider.release = function () {}; + slider.preTouch = slider.preTouchMove = slider.preTouchRelease = function () {}; + slider.touch = slider.touchMove = slider.touchRelease = function () {}; + } + + this.sliders.push(slider); + this.element.appendChild(container); + } + if (touch.exists) { + this.addTouchListeners(); + } + } + }, + colorInterface: { + value: function colorInterface() { + for (var i = 0; i < this.sliders.length; i++) { + this.sliders[i].colors = this.colors; + this.sliders[i].colorInterface(); + } + } + }, + sizeInterface: { + value: function sizeInterface() { + + var sliderWidth = this.width / this.sliders.length; + var sliderHeight = this.height; + + for (var i = 0; i < this.sliders.length; i++) { + this.sliders[i].resize(sliderWidth, sliderHeight); + this.sliders[i].customStyle(); + } + } + }, + update: { + value: function update(index, value) { + this.emit("change", { + index: index, + value: value + }); + } + }, + addTouchListeners: { + value: function addTouchListeners() { + var _this = this; + + this.preClick = this.preMove = this.preRelease = function () {}; + this.click = this.move = this.release = function () {}; + this.preTouch = this.preTouchMove = this.preTouchRelease = function () {}; + this.touch = this.touchMove = this.touchRelease = function () {}; + + this.currentElement = false; + + this.element.addEventListener("touchstart", function (e) { + var element = document.elementFromPoint(e.targetTouches[0].clientX, e.targetTouches[0].clientY); + var slider = _this.sliders[element.index]; + if (!slider.offset) { + slider.offset = dom.findPosition(slider.element); + } + slider.mouse = dom.locateMouse(e, slider.offset); + slider.down(); + _this.currentElement = element.index; + e.preventDefault(); + e.stopPropagation(); + }); + + this.element.addEventListener("touchmove", function (e) { + var element = document.elementFromPoint(e.targetTouches[0].clientX, e.targetTouches[0].clientY); + var slider = _this.sliders[element.index]; + if (!slider.offset) { + slider.offset = dom.findPosition(slider.element); + } + slider.mouse = dom.locateMouse(e, slider.offset); + if (element.index !== _this.currentElement) { + if (_this.currentElement >= 0) { + var pastslider = _this.sliders[_this.currentElement]; + pastslider.up(); + } + slider.down(); + } else { + slider.slide(); + } + _this.currentElement = element.index; + e.preventDefault(); + e.stopPropagation(); + }); + + this.element.addEventListener("touchend", function (e) { + // no touches to calculate because none remaining + var slider = _this.sliders[_this.currentElement]; + slider.up(); + _this.interacting = false; + _this.currentElement = false; + e.preventDefault(); + e.stopPropagation(); + }); + } + }, + numberOfSliders: { + + /** + Get or set the number of sliders + @type {Number} + */ + + get: function () { + return this.sliders.length; + }, + set: function (v) { + if (v === this.sliders.length) { + return; + } + this.sliders.forEach(function (slider) { + slider.destroy(); + }); + this.empty(); + this._numberOfSliders = v; + this.buildInterface(); + } + }, + min: { + + /** + Lower limit of the multislider's output range + @type {number} + @example multislider.min = 1000; + */ + + get: function () { + return this.sliders[0].min; + }, + set: function (v) { + this.sliders.forEach(function (slider) { + slider.min = v; + }); + } + }, + max: { + + /** + Upper limit of the multislider's output range + @type {number} + @example multislider.max = 1000; + */ + + get: function () { + return this.sliders[0].max; + }, + set: function (v) { + this.sliders.forEach(function (slider) { + slider.max = v; + }); + } + }, + step: { + + /** + The increment that the multislider's value changes by. + @type {number} + @example multislider.step = 5; + */ + + get: function () { + return this.sliders[0].step; + }, + set: function (v) { + this.sliders.forEach(function (slider) { + slider.step = v; + }); + } + }, + setSlider: { + + /** + Set the value of an individual slider + @param index {number} Slider index + @param value {number} New slider value + @example + // Set the first slider to value 0.5 + multislider.setSlider(0,0.5) + */ + + value: function setSlider(index, value) { + this.sliders[index].value = value; + this.emit("change", { + index: index, + value: value + }); + } + }, + setAllSliders: { + + /** + Set the value of all sliders at once. If the size of the input array does not match the current number of sliders, the value array will repeat until all sliders have been set. I.e. an input array of length 1 will set all sliders to that value. + @param values {Array} All slider values + @example + multislider.setAllSliders([0.2,0.3,0.4,0.5,0.6]) + */ + + value: function setAllSliders(values) { + var _this = this; + + this.values = values; + this.sliders.forEach(function (slider, i) { + slider.value = values[i % values.length]; + _this.emit("change", { + index: i, + value: slider.value + }); + }); + } + } + }); + + return Multislider; + })(Interface); + + module.exports = Multislider; + +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; }; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var svg = __webpack_require__(4); + var Interface = __webpack_require__(6); + var Step = __webpack_require__(11); + + var Interaction = _interopRequireWildcard(__webpack_require__(12)); + + var SliderTemplate = (function (_Interface) { + function SliderTemplate(args, options, defaults) { + _classCallCheck(this, SliderTemplate); + + _get(Object.getPrototypeOf(SliderTemplate.prototype), "constructor", this).call(this, args, options, defaults); + + this.orientation = this.settings.orientation; + + // this.mode = this.settings.mode; + + this.hasKnob = this.settings.hasKnob; + + // this.step should eventually be get/set + // updating it will update the _value step model + // this.step = this.settings.step; // float + + this._value = new Step(this.settings.scale[0], this.settings.scale[1], this.settings.step, this.settings.value); + + this.init(); + + this.position = new Interaction.Handle(this.settings.mode, this.orientation, [0, this.width], [this.height, 0]); + this.position.value = this._value.normalized; + + this.value = this._value.value; + + this.emit("change", this.value); + } + + _inherits(SliderTemplate, _Interface); + + _createClass(SliderTemplate, { + buildInterface: { + value: function buildInterface() { + + this.bar = svg.create("rect"); + this.fillbar = svg.create("rect"); + this.knob = svg.create("circle"); + + this.element.appendChild(this.bar); + this.element.appendChild(this.fillbar); + this.element.appendChild(this.knob); + + this.sizeInterface(); + } + }, + sizeInterface: { + value: function sizeInterface() { + + if (!this.settings.orientation) { + if (this.width < this.height) { + this.orientation = "vertical"; + } else { + this.orientation = "horizontal"; + } + } + + var x = undefined, + y = undefined, + w = undefined, + h = undefined, + barOffset = undefined, + cornerRadius = undefined; + this.knobData = { + level: 0, + r: 0 + }; + + if (this.orientation === "vertical") { + this.thickness = this.width / 2; + x = this.width / 2; + y = 0; + w = this.thickness; + h = this.height; + this.knobData.r = this.thickness * 0.8; + this.knobData.level = h - this.normalized * h; + barOffset = "translate(" + this.thickness * -1 / 2 + ",0)"; + cornerRadius = w / 2; + } else { + this.thickness = this.height / 2; + x = 0; + y = this.height / 2; + w = this.width; + h = this.thickness; + this.knobData.r = this.thickness * 0.8; + this.knobData.level = this.normalized * w; + barOffset = "translate(0," + this.thickness * -1 / 2 + ")"; + cornerRadius = h / 2; + } + + this.bar.setAttribute("x", x); + this.bar.setAttribute("y", y); + this.bar.setAttribute("transform", barOffset); + this.bar.setAttribute("rx", cornerRadius); // corner radius + this.bar.setAttribute("ry", cornerRadius); + this.bar.setAttribute("width", w); + this.bar.setAttribute("height", h); + + if (this.orientation === "vertical") { + this.fillbar.setAttribute("x", x); + this.fillbar.setAttribute("y", this.knobData.level); + this.fillbar.setAttribute("width", w); + this.fillbar.setAttribute("height", h - this.knobData.level); + } else { + this.fillbar.setAttribute("x", 0); + this.fillbar.setAttribute("y", y); + this.fillbar.setAttribute("width", this.knobData.level); + this.fillbar.setAttribute("height", h); + } + this.fillbar.setAttribute("transform", barOffset); + this.fillbar.setAttribute("rx", cornerRadius); + this.fillbar.setAttribute("ry", cornerRadius); + + if (this.orientation === "vertical") { + this.knob.setAttribute("cx", x); + this.knob.setAttribute("cy", this.knobData.level); + } else { + this.knob.setAttribute("cx", this.knobData.level); + this.knob.setAttribute("cy", y); + } + this.knob.setAttribute("r", this.knobData.r); + + if (this.position) { + this.position.resize([0, this.width], [this.height, 0]); + } + } + }, + colorInterface: { + value: function colorInterface() { + + this.bar.setAttribute("fill", this.colors.fill); + this.fillbar.setAttribute("fill", this.colors.accent); + this.knob.setAttribute("fill", this.colors.accent); + if (!this.hasKnob) { + this.knob.setAttribute("fill", "none"); + } + } + }, + render: { + value: function render() { + if (!this.clicked) { + this.knobData.r = this.thickness * 0.75; + } + this.knob.setAttribute("r", this.knobData.r); + + if (this.orientation === "vertical") { + this.knobData.level = this._value.normalized * this.height; + this.knob.setAttribute("cy", this.height - this.knobData.level); + this.fillbar.setAttribute("y", this.height - this.knobData.level); + this.fillbar.setAttribute("height", this.knobData.level); + } else { + this.knobData.level = this._value.normalized * this.width; + this.knob.setAttribute("cx", this.knobData.level); + this.fillbar.setAttribute("x", 0); + this.fillbar.setAttribute("width", this.knobData.level); + } + } + }, + down: { + value: function down() { + this.clicked = true; + this.knobData.r = this.thickness * 0.9; + this.position.anchor = this.mouse; + this.slide(); + } + }, + slide: { + value: function slide() { + if (this.clicked) { + this.position.update(this.mouse); + this.value = this._value.updateNormal(this.position.value); + this.emit("change", this.value); + } + } + }, + up: { + value: function up() { + this.clicked = false; + this.render(); + } + }, + normalized: { + get: function () { + return this._value.normalized; + } + }, + value: { + + /** + The slider's current value. If set manually, will update the interface and trigger the output event. + @type {number} + @example slider.value = 10; + */ + + get: function () { + return this._value.value; + }, + set: function (v) { + this._value.update(v); + this.position.value = this._value.normalized; + this.render(); + } + }, + min: { + + /** + Lower limit of the sliders's output range + @type {number} + @example slider.min = 1000; + */ + + get: function () { + return this._value.min; + }, + set: function (v) { + this._value.min = v; + } + }, + max: { + + /** + Upper limit of the slider's output range + @type {number} + @example slider.max = 1000; + */ + + get: function () { + return this._value.max; + }, + set: function (v) { + this._value.max = v; + } + }, + step: { + + /** + The increment that the slider's value changes by. + @type {number} + @example slider.step = 5; + */ + + get: function () { + return this._value.step; + }, + set: function (v) { + this._value.step = v; + } + }, + mode: { + + /** + Absolute mode (slider's value jumps to mouse click position) or relative mode (mouse drag changes value relative to its current position). Default: "relative". + @type {string} + @example slider.mode = "relative"; + */ + + get: function () { + return this.position.mode; + }, + set: function (v) { + this.position.mode = v; + } + } + }); + + return SliderTemplate; + })(Interface); + + module.exports = SliderTemplate; + +/***/ }), +/* 33 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; }; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var svg = __webpack_require__(4); + var math = __webpack_require__(5); + var Interface = __webpack_require__(6); + var Step = __webpack_require__(11); + + var Interaction = _interopRequireWildcard(__webpack_require__(12)); + + /** + * Pan + * + * @description Stereo crossfader. + * + * @demo <span nexus-ui="pan"></span> + * + * @example + * var pan = new Nexus.Pan('#target') + * + * @output + * change + * Fires any time the interface's value changes. <br> + * The event data is an object containing the interface's <i>value</i> (-1 to 1), as well as <i>L</i> and <i>R</i> amplitude values (0-1) for left and right speakers, calculated by a square-root crossfade algorithm. + * + * @outputexample + * pan.on('change',function(v) { + * console.log(v); + * }) + * + * + */ + + var Pan = (function (_Interface) { + function Pan() { + _classCallCheck(this, Pan); + + var options = ["scale", "value"]; + + var defaults = { + size: [120, 20], + orientation: "horizontal", + mode: "relative", + scale: [-1, 1], + step: 0, + value: 0, + hasKnob: true + }; + + _get(Object.getPrototypeOf(Pan.prototype), "constructor", this).call(this, arguments, options, defaults); + + this.orientation = this.settings.orientation; + + this.mode = this.settings.mode; + + this.hasKnob = this.settings.hasKnob; + + // this.step should eventually be get/set + // updating it will update the _value step model + this.step = this.settings.step; // float + + this._value = new Step(this.settings.scale[0], this.settings.scale[1], this.settings.step, this.settings.value); + + this.init(); + + this.position = new Interaction.Handle(this.mode, this.orientation, [0, this.width], [this.height, 0]); + this.position.value = this._value.normalized; + + this.value = this._value.value; + + this.emit("change", this.value); + } + + _inherits(Pan, _Interface); + + _createClass(Pan, { + buildInterface: { + value: function buildInterface() { + + this.bar = svg.create("rect"); + this.knob = svg.create("circle"); + + this.element.appendChild(this.bar); + this.element.appendChild(this.knob); + } + }, + sizeInterface: { + value: function sizeInterface() { + + if (this.position) { + this.position.resize([0, this.width], [this.height, 0]); + } + + if (this.width < this.height) { + this.orientation = "vertical"; + } else { + this.orientation = "horizontal"; + } + + var x = undefined, + y = undefined, + w = undefined, + h = undefined, + barOffset = undefined, + cornerRadius = undefined; + this.knobData = { + level: 0, + r: 0 + }; + + if (this.orientation === "vertical") { + this.thickness = this.width / 2; + x = this.width / 2; + y = 0; + w = this.thickness; + h = this.height; + this.knobData.r = this.thickness * 0.8; + this.knobData.level = h - this.knobData.r - this.normalized * (h - this.knobData.r * 2); + barOffset = "translate(" + this.thickness * -1 / 2 + ",0)"; + cornerRadius = w / 2; + } else { + this.thickness = this.height / 2; + x = 0; + y = this.height / 2; + w = this.width; + h = this.thickness; + this.knobData.r = this.thickness * 0.8; + this.knobData.level = this.normalized * (w - this.knobData.r * 2) + this.knobData.r; + barOffset = "translate(0," + this.thickness * -1 / 2 + ")"; + cornerRadius = h / 2; + } + + this.bar.setAttribute("x", x); + this.bar.setAttribute("y", y); + this.bar.setAttribute("transform", barOffset); + this.bar.setAttribute("rx", cornerRadius); // corner radius + this.bar.setAttribute("ry", cornerRadius); + this.bar.setAttribute("width", w); + this.bar.setAttribute("height", h); + + if (this.orientation === "vertical") { + this.knob.setAttribute("cx", x); + this.knob.setAttribute("cy", this.knobData.level); + } else { + this.knob.setAttribute("cx", this.knobData.level); + this.knob.setAttribute("cy", y); + } + this.knob.setAttribute("r", this.knobData.r); + } + }, + colorInterface: { + value: function colorInterface() { + + this.bar.setAttribute("fill", this.colors.fill); + this.knob.setAttribute("fill", this.colors.accent); + + if (!this.hasKnob) { + this.knob.setAttribute("fill", "transparent"); + } + } + }, + render: { + value: function render() { + if (!this.clicked) { + this.knobData.r = this.thickness * 0.75; + } + this.knob.setAttribute("r", this.knobData.r); + + if (this.orientation === "vertical") { + this.knobData.level = this.knobData.r + this._value.normalized * (this.height - this.knobData.r * 2); + this.knob.setAttribute("cy", this.height - this.knobData.level); + } else { + this.knobData.level = this._value.normalized * (this.width - this.knobData.r * 2) + this.knobData.r; + this.knob.setAttribute("cx", this.knobData.level); + } + } + }, + click: { + value: function click() { + this.knobData.r = this.thickness * 0.9; + this.position.anchor = this.mouse; + this.move(); + } + }, + move: { + value: function move() { + if (this.clicked) { + this.position.update(this.mouse); + + this.value = this._value.updateNormal(this.position.value); + + this.emit("change", { + value: this.value, + L: Math.pow(math.scale(this.value, -1, 1, 1, 0), 2), + R: Math.pow(math.scale(this.value, -1, 1, 0, 1), 2) + }); + } + } + }, + release: { + value: function release() { + this.render(); + } + }, + value: { + + /** + The position of crossfader, from -1 (left) to 1 (right). Setting this value updates the interface and triggers the output event. + @type {number} + */ + + get: function () { + return this._value.value; + }, + set: function (value) { + this._value.update(value); + this.position.value = this._value.normalized; + this.emit("change", { + value: this.value, + L: Math.pow(math.scale(this.value, -1, 1, 1, 0), 2), + R: Math.pow(math.scale(this.value, -1, 1, 0, 1), 2) + }); + this.render(); + } + }, + normalized: { + get: function () { + return this._value.normalized; + } + } + }); + + return Pan; + })(Interface); + + module.exports = Pan; + +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var math = __webpack_require__(5); + var svg = __webpack_require__(4); + var Interface = __webpack_require__(6); + + var Point = function Point(point, envelope) { + + this.x = point.x; + this.y = point.y; + this.envelope = envelope; + + this.element = svg.create("circle"); + this.element.setAttribute("fill", this.envelope.colors.accent); + + this.envelope.element.appendChild(this.element); + + this.resize = function () { + var r = ~ ~(Math.min(this.envelope.width, this.envelope.height) / 50) + 2; + this.element.setAttribute("r", r); + }; + + this.move = function (x, y) { + + this.x = x || x === 0 ? x : this.x; + this.y = y || y === 0 ? y : this.y; + + if (this.envelope.nodes.indexOf(this) >= 0) { + + var prevIndex = this.envelope.nodes.indexOf(this) - 1; + var nextIndex = this.envelope.nodes.indexOf(this) + 1; + + var prevNode = this.envelope.nodes[prevIndex]; + var nextNode = this.envelope.nodes[nextIndex]; + + var lowX = prevIndex >= 0 ? prevNode.x : 0; + var highX = nextIndex < this.envelope.nodes.length ? nextNode.x : 1; + + if (this.x < lowX) { + this.x = lowX; + } + if (this.x > highX) { + this.x = highX; + } + } + + this.location = this.getCoordinates(); + this.element.setAttribute("cx", this.location.x); + this.element.setAttribute("cy", this.location.y); + }; + + this.getCoordinates = function () { + return { + x: this.x * this.envelope.width, + y: (1 - this.y) * this.envelope.height + }; + }; + + this.move(this.x, this.y, true); + this.resize(); + + this.destroy = function () { + this.envelope.element.removeChild(this.element); + this.envelope.nodes.splice(this.envelope.nodes.indexOf(this), 1); + }; + }; + + /** + * Envelope + * + * @description Interactive linear ramp visualization. + * + * @demo <span nexus-ui="envelope"></span> + * + * @example + * var envelope = new Nexus.Envelope('#target') + * + * @example + * var envelope = new Nexus.Envelope('#target',{ + * 'size': [300,150], + * 'points': [ + * { + * x: 0.1, + * y: 0.4 + * }, + * { + * x: 0.35, + * y: 0.6 + * }, + * { + * x: 0.65, + * y: 0.2 + * }, + * { + * x: 0.9, + * y: 0.4 + * }, + * ] + * }) + * + * @output + * change + * Fires any time a node is moved. <br> + * The event data is an array of point locations. Each item in the array is an object containing <i>x</i> and <i>y</i> properties describing the location of a point on the envelope. + * + * @outputexample + * envelope.on('change',function(v) { + * console.log(v); + * }) + * + */ + + var Envelope = (function (_Interface) { + function Envelope() { + _classCallCheck(this, Envelope); + + var options = ["value"]; + + var defaults = { + size: [300, 150], + points: [{ + x: 0.1, + y: 0.4 + }, { + x: 0.35, + y: 0.6 + }, { + x: 0.65, + y: 0.2 + }, { + x: 0.9, + y: 0.4 + }] + }; + + _get(Object.getPrototypeOf(Envelope.prototype), "constructor", this).call(this, arguments, options, defaults); + + this.points = this.settings.points; + + this.nodes = []; + + this.selected = false; + + this.init(); + } + + _inherits(Envelope, _Interface); + + _createClass(Envelope, { + buildInterface: { + value: function buildInterface() { + var _this = this; + + this.points.forEach(function (point) { + var node = new Point(point, _this); + _this.nodes.push(node); + }); + + this.sortPoints(); + + this.line = svg.create("polyline"); + this.line.setAttribute("stroke-width", 2); + this.line.setAttribute("fill", "none"); + + this.element.appendChild(this.line); + + this.fill = svg.create("polyline"); + this.fill.setAttribute("fill-opacity", "0.2"); + + this.element.appendChild(this.fill); + } + }, + sizeInterface: { + value: function sizeInterface() { + + for (var i = 0; i < this.nodes.length; i++) { + this.nodes[i].resize(); + this.nodes[i].move(); + } + + this.render(); + } + }, + colorInterface: { + value: function colorInterface() { + var _this = this; + + this.element.style.backgroundColor = this.colors.fill; + this.line.setAttribute("stroke", this.colors.accent); + this.fill.setAttribute("fill", this.colors.accent); + this.nodes.forEach(function (node) { + node.element.setAttribute("fill", _this.colors.accent); + }); + } + }, + render: { + value: function render() { + // this.nodes[this.selected].move( this.points ) + this.calculatePath(); + } + }, + calculatePoints: { + value: function calculatePoints() { + var _this = this; + + this.points = []; + this.nodes.forEach(function (node) { + _this.points.push({ x: node.x, y: node.y }); + }); + } + }, + calculatePath: { + value: function calculatePath() { + + //stroke data + var data = "0 " + this.nodes[0].location.y + ", "; + + // data should be re-ordered based on x location. + // whatever function adds a node should add it at the right index + + this.nodes.forEach(function (node) { + // let location = node.getCoordinates(); + data += node.location.x + " " + node.location.y + ", "; + }); + + // data += point.x*this.width+' '+ point.y*this.height+', '; + data += this.width + " " + this.nodes[this.nodes.length - 1].location.y; + + this.line.setAttribute("points", data); + + // fill data + // add bottom corners + + data += ", " + this.width + " " + this.height + ", "; + data += "0 " + this.height; + + this.fill.setAttribute("points", data); + } + }, + click: { + value: function click() { + // find nearest node and set this.selected (index) + this.hasMoved = false; + this.selected = this.findNearestNode(); + + this.nodes[this.selected].move(this.mouse.x / this.width, 1 - this.mouse.y / this.height); + this.scaleNode(this.selected); + + // must do this b/c new node may have been created + this.calculatePoints(); + this.emit("change", this.points); + this.render(); + } + }, + move: { + value: function move() { + if (this.clicked) { + this.mouse.x = math.clip(this.mouse.x, 0, this.width); + this.hasMoved = true; + + this.nodes[this.selected].move(this.mouse.x / this.width, 1 - this.mouse.y / this.height); + this.scaleNode(this.selected); + + this.calculatePoints(); + this.emit("change", this.points); + this.render(); + } + } + }, + release: { + value: function release() { + + if (!this.hasMoved) { + this.nodes[this.selected].destroy(); + } + + this.calculatePoints(); + this.emit("change", this.points); + this.render(); + + // reset this.selected + this.selected = null; + } + }, + findNearestNode: { + value: function findNearestNode() { + var nearestIndex = null; + // set this unreasonably high so that every distance will be lower than it. + var nearestDist = 10000; + var before = false; + var x = this.mouse.x / this.width; + var y = 1 - this.mouse.y / this.height; + var nodes = this.nodes; + for (var i = 0; i < nodes.length; i++) { + + // calculate the distance from mouse to this node using pythagorean theorem + var distance = Math.sqrt(Math.pow(nodes[i].x - x, 2) + Math.pow(nodes[i].y - y, 2)); + + // if this distance is less than the previous shortest distance, use this index + if (distance < nearestDist) { + nearestDist = distance; + nearestIndex = i; + before = x > nodes[i].x; + } + } + + // if not very close to any node, create a node + if (nearestDist > 0.07) { + + nearestIndex = this.getIndexFromX(this.mouse.x / this.width); + + this.nodes.splice(nearestIndex, 0, new Point({ + x: this.mouse.x / this.width, + y: 1 - this.mouse.y / this.height + }, this)); + this.hasMoved = true; + } + + return nearestIndex; + } + }, + getIndexFromX: { + value: function getIndexFromX(x) { + var _this = this; + + var index = 0; + this.nodes.forEach(function (node, i) { + if (_this.nodes[i].x <= x) { + index = i + 1; + } + }); + return index; + } + }, + scaleNode: { + value: function scaleNode(i) { + + var clippedX = math.clip(this.nodes[i].x, 0, 1); + var clippedY = math.clip(this.nodes[i].y, 0, 1); + + this.nodes[i].move(clippedX, clippedY); + } + }, + sortPoints: { + + /** + Sort the this.points array from left-most point to right-most point. You should not regularly need to use this, however it may be useful if the points get unordered. + */ + + value: function sortPoints() { + this.nodes.sort(function (a, b) { + return a.x > b.x; + }); + } + }, + addPoint: { + + /** + Add a breakpoint on the envelope. + @param x {number} x location of the point, normalized (0-1) + @param y {number} y location of the point, normalized (0-1) + */ + + value: function addPoint(x, y) { + var index = this.nodes.length; + + this.sortPoints(); + + for (var i = 0; i < this.nodes.length; i++) { + if (x < this.nodes[i].x) { + index = i; + break; + } + } + + this.nodes.splice(index, 0, new Point({ + x: x, + y: y + }, this)); + + this.scaleNode(index); + + this.calculatePoints(); + this.emit("change", this.points); + + this.render(); + } + }, + scan: { + + /** + Find the level at a certain x location on the envelope. + @param x {number} The x location to find the level of, normalized 0-1 + */ + + value: function scan(x) { + // find surrounding points + var nextIndex = this.getIndexFromX(x); + var priorIndex = nextIndex - 1; + if (priorIndex < 0) { + priorIndex = 0; + } + if (nextIndex >= this.nodes.length) { + nextIndex = this.nodes.length - 1; + } + var priorPoint = this.nodes[priorIndex]; + var nextPoint = this.nodes[nextIndex]; + var loc = math.scale(x, priorPoint.x, nextPoint.x, 0, 1); + var value = math.interp(loc, priorPoint.y, nextPoint.y); + this.emit("scan", value); + return value; + } + }, + movePoint: { + + /** + Move a breakpoint on the envelope. + @param index {number} The index of the breakpoint to move + @param x {number} New x location, normalized 0-1 + @param y {number} New y location, normalized 0-1 + */ + + value: function movePoint(index, x, y) { + this.nodes[index].move(x, y); + this.scaleNode(index); + this.calculatePoints(); + this.emit("change", this.points); + this.render(); + } + }, + adjustPoint: { + + /** + Move a breakpoint on the envelope by a certain amount. + @param index {number} The index of the breakpoint to move + @param xOffset {number} X displacement, normalized 0-1 + @param yOffset {number} Y displacement, normalized 0-1 + */ + + value: function adjustPoint(index, xOffset, yOffset) { + this.nodes[index].move(this.nodes[index].x + xOffset, this.nodes[index].y + yOffset); + this.scaleNode(index); + this.calculatePoints(); + this.emit("change", this.points); + this.render(); + } + }, + destroyPoint: { + + /** + Remove a breakpoint from the envelope. + @param index {number} Index of the breakpoint to remove + */ + + value: function destroyPoint(index) { + this.nodes[index].destroy(); + this.calculatePoints(); + this.emit("change", this.points); + this.render(); + } + }, + setPoints: { + + /** + Remove all existing breakpoints and add an entirely new set of breakpoints. + @param allPoints {array} An array of objects with x/y properties (normalized 0-1). Each object in the array specifices the x/y location of a new breakpoint to be added. + */ + + value: function setPoints(allPoints) { + var _this = this; + + while (this.nodes.length) { + this.nodes[0].destroy(); + } + allPoints.forEach(function (point) { + _this.addPoint(point.x, point.y); + }); + this.calculatePoints(); + this.emit("change", this.points); + this.render(); + } + } + }); + + return Envelope; + })(Interface); + + module.exports = Envelope; + +/***/ }), +/* 35 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var dom = __webpack_require__(7); + //let math = require('../util/math'); + var Interface = __webpack_require__(6); + + /** + * Spectrogram + * + * @description Audio spectrum visualization + * + * @demo <span nexus-ui="spectrogram"></span> + * + * @example + * var spectrogram = new Nexus.Spectrogram('#target') + * + * @example + * var spectrogram = new Nexus.Spectrogram('#target',{ + * 'size': [300,150] + * }) + * + * @output + * + * No events + * + */ + + var context = __webpack_require__(1).context; + + var Spectrogram = (function (_Interface) { + function Spectrogram() { + _classCallCheck(this, Spectrogram); + + var options = ["scale", "value"]; + + var defaults = { + size: [300, 150] + }; + + _get(Object.getPrototypeOf(Spectrogram.prototype), "constructor", this).call(this, arguments, options, defaults); + + this.context = context(); // jshint ignore:line + + this.analyser = this.context.createAnalyser(); + this.analyser.fftSize = 2048; + this.bufferLength = this.analyser.frequencyBinCount; + this.dataArray = new Uint8Array(this.bufferLength); + + this.active = true; + + this.source = false; + + this.init(); + } + + _inherits(Spectrogram, _Interface); + + _createClass(Spectrogram, { + buildFrame: { + value: function buildFrame() { + this.canvas = new dom.SmartCanvas(this.parent); + this.element = this.canvas.element; + } + }, + sizeInterface: { + value: function sizeInterface() { + this.canvas.resize(this.width, this.height); + } + }, + colorInterface: { + value: function colorInterface() { + this.canvas.element.style.backgroundColor = this.colors.fill; + } + }, + render: { + value: function render() { + + if (this.active) { + requestAnimationFrame(this.render.bind(this)); + } + + this.analyser.getByteFrequencyData(this.dataArray); + + this.canvas.context.fillStyle = this.colors.fill; + this.canvas.context.fillRect(0, 0, this.canvas.element.width, this.canvas.element.height); + + if (this.source && this.dataArray) { + + //console.log(this.dataArray); + + var barWidth = this.canvas.element.width / this.bufferLength; + var barHeight = undefined; + var x = 0; + + var definition = this.canvas.element.width / 50; + + for (var i = 0; i < this.bufferLength; i = i + definition) { + barHeight = Math.max.apply(null, this.dataArray.subarray(i, i + definition)); + barHeight /= 255; + barHeight *= this.canvas.element.height; + + this.canvas.context.fillStyle = this.colors.accent; + this.canvas.context.fillRect(x, this.canvas.element.height - barHeight, barWidth * definition, barHeight); + + x += barWidth * definition; + } + } + } + }, + connect: { + + /** + Equivalent to "patching in" an audio node to visualize. NOTE: You cannot connect audio nodes across two different audio contexts. NexusUI runs its audio analysis on its own audio context, Nexus.context. If the audio node you are visualizing is created on a different audio context, you will need to tell NexusUI to use that context instead: i.e. Nexus.context = YourAudioContextName. For example, in ToneJS projects, the line would be: Nexus.context = Tone.context . We recommend that you write that line of code only once at the beginning of your project. + @param node {AudioNode} The audio node to visualize + @example Nexus.context = Tone.context // or another audio context you have created + spectrogram.connect( Tone.Master ); + */ + + value: function connect(node) { + if (this.source) { + this.disconnect(); + } + this.source = node; + this.source.connect(this.analyser); + this.render(); + } + }, + disconnect: { + + /** + Stop visualizing the source node and disconnect it. + */ + + value: function disconnect() { + this.source.disconnect(this.analyser); + this.source = null; + } + }, + click: { + value: function click() { + this.active = !this.active; + this.render(); + } + }, + customDestroy: { + value: function customDestroy() { + this.active = false; + } + } + }); + + return Spectrogram; + })(Interface); + + module.exports = Spectrogram; + +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var dom = __webpack_require__(7); + var math = __webpack_require__(5); + var Interface = __webpack_require__(6); + + /** + * Meter + * + * @description Stereo decibel meter + * + * @demo <span nexus-ui="meter"></span> + * + * @example + * var meter = new Nexus.Meter('#target') + * + * @example + * var meter = new Nexus.Meter('#target',{ + * size: [75,75] + * }) + * + * @output + * + * No events + * + */ + + var context = __webpack_require__(1).context; + + var Meter = (function (_Interface) { + function Meter() { + _classCallCheck(this, Meter); + + var options = ["scale", "value"]; + + var defaults = { + size: [30, 100] + }; + + _get(Object.getPrototypeOf(Meter.prototype), "constructor", this).call(this, arguments, options, defaults); + + this.context = context(); // jshint ignore:line + + this.channels = 2; + + this.splitter = this.context.createChannelSplitter(this.channels); + + this.analysers = []; + + for (var i = 0; i < this.channels; i++) { + var analyser = this.context.createAnalyser(); + this.splitter.connect(analyser, i); + analyser.fftSize = 1024; + analyser.smoothingTimeConstant = 1; + this.analysers.push(analyser); + } + this.bufferLength = this.analysers[0].frequencyBinCount; + this.dataArray = new Float32Array(this.bufferLength); + + /* + // add linear gradient + var grd = canvasCtx.createLinearGradient(0, 0, 0, canvas.height); + // light blue + grd.addColorStop(0, '#000'); + grd.addColorStop(0.2, '#bbb'); + grd.addColorStop(0.4, '#d18'); + // dark blue + grd.addColorStop(1, '#d18'); + canvasCtx.fillStyle = grd; */ + + this.active = true; + + this.db = -Infinity; + + this.init(); + + this.meterWidth = this.canvas.element.width / this.channels; + + this.render(); + } + + _inherits(Meter, _Interface); + + _createClass(Meter, { + buildFrame: { + value: function buildFrame() { + this.canvas = new dom.SmartCanvas(this.parent); + this.element = this.canvas.element; + } + }, + sizeInterface: { + value: function sizeInterface() { + this.canvas.resize(this.width, this.height); + } + }, + colorInterface: { + value: function colorInterface() { + this.canvas.element.style.backgroundColor = this.colors.fill; + } + }, + render: { + value: function render() { + + if (this.active) { + requestAnimationFrame(this.render.bind(this)); + } + + this.canvas.context.fillStyle = this.colors.fill; + this.canvas.context.fillRect(0, 0, this.canvas.element.width, this.canvas.element.height); + + for (var i = 0; i < this.analysers.length; i++) { + + if (this.source) { + + this.analysers[i].getFloatTimeDomainData(this.dataArray); + + var rms = 0; + + for (var _i = 0; _i < this.dataArray.length; _i++) { + rms += this.dataArray[_i] * this.dataArray[_i]; + } + + rms = Math.sqrt(rms / this.dataArray.length); + + this.db = 20 * Math.log10(rms); + } else if (this.db > -200 && this.db !== -Infinity) { + this.db -= 1; + } else { + this.db = -Infinity; + } + + //console.log(db) + + if (this.db > -70) { + + var linear = math.normalize(this.db, -70, 5); + var exp = linear * linear; + var y = math.scale(exp, 0, 1, this.element.height, 0); + + this.canvas.context.fillStyle = this.colors.accent; + this.canvas.context.fillRect(this.meterWidth * i, y, this.meterWidth, this.canvas.element.height - y); + + //console.log("rendering...") + } + } + } + }, + connect: { + + /** + Equivalent to "patching in" an audio node to visualize. NOTE: You cannot connect audio nodes across two different audio contexts. NexusUI runs its audio analysis on its own audio context, Nexus.context. If the audio node you are visualizing is created on a different audio context, you will need to tell NexusUI to use that context instead: i.e. Nexus.context = YourAudioContextName. For example, in ToneJS projects, the line would be: Nexus.context = Tone.context . We recommend that you write that line of code only once at the beginning of your project. + @param node {AudioNode} The audio node to visualize + @param channels {number} (optional) The number of channels in the source node to watch. If not specified, the interface will look for a .channelCount property on the input node. If it does not exist, the interface will default to 1 channel. + @example Nexus.context = Tone.context // or another audio context you have created + meter.connect( Tone.Master, 2 ); + */ + + value: function connect(node, channels) { + if (this.source) { + this.disconnect(); + } + //this.dummy.disconnect(this.splitter); + + if (channels) { + this.channels = channels; + } else if (node.channelCount) { + this.channels = node.channelCount; + } else { + this.channels = 2; + } + this.meterWidth = this.canvas.element.width / this.channels; + + this.source = node; + this.source.connect(this.splitter); + + // this.render(); + } + }, + disconnect: { + + /** + Stop visualizing the source node and disconnect it. + */ + + value: function disconnect() { + + this.source.disconnect(this.splitter); + this.source = false; + // this.dummy.connect(this.splitter); + this.meterWidth = this.canvas.element.width / this.channels; + } + }, + click: { + value: function click() { + this.active = !this.active; + this.render(); + } + }, + customDestroy: { + value: function customDestroy() { + this.active = false; + } + } + }); + + return Meter; + })(Interface); + + module.exports = Meter; + +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + + var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var dom = __webpack_require__(7); + var Interface = __webpack_require__(6); + + /** + * Oscilloscope + * + * @description Visualizes a waveform's stream of values. + * + * @demo <span nexus-ui="oscilloscope"></span> + * + * @example + * var oscilloscope = new Nexus.Oscilloscope('#target') + * + * @example + * var oscilloscope = new Nexus.Oscilloscope('#target',{ + * 'size': [300,150] + * }) + * + * @output + * + * No events + * + */ + + var context = __webpack_require__(1).context; + + var Oscilloscope = (function (_Interface) { + function Oscilloscope() { + _classCallCheck(this, Oscilloscope); + + var options = ["scale", "value"]; + + var defaults = { + size: [300, 150] + }; + + _get(Object.getPrototypeOf(Oscilloscope.prototype), "constructor", this).call(this, arguments, options, defaults); + + this.context = context(); // jshint ignore:line + + this.analyser = this.context.createAnalyser(); + this.analyser.fftSize = 2048; + this.bufferLength = this.analyser.frequencyBinCount; + this.dataArray = new Uint8Array(this.bufferLength); + this.analyser.getByteTimeDomainData(this.dataArray); + + this.active = true; + + this.source = false; + + this.init(); + + this.render(); + } + + _inherits(Oscilloscope, _Interface); + + _createClass(Oscilloscope, { + buildFrame: { + value: function buildFrame() { + this.canvas = new dom.SmartCanvas(this.parent); + this.element = this.canvas.element; + } + }, + sizeInterface: { + value: function sizeInterface() { + this.canvas.resize(this.width, this.height); + } + }, + colorInterface: { + value: function colorInterface() { + this.canvas.element.style.backgroundColor = this.colors.fill; + } + }, + render: { + value: function render() { + + if (this.active) { + requestAnimationFrame(this.render.bind(this)); + } + + this.analyser.getByteTimeDomainData(this.dataArray); + + this.canvas.context.fillStyle = this.colors.fill; + this.canvas.context.fillRect(0, 0, this.canvas.element.width, this.canvas.element.height); + + this.canvas.context.lineWidth = ~ ~(this.height / 100 + 2); + this.canvas.context.strokeStyle = this.colors.accent; + + this.canvas.context.beginPath(); + + if (this.source) { + + var sliceWidth = this.canvas.element.width * 1 / this.bufferLength; + var x = 0; + + for (var i = 0; i < this.bufferLength; i++) { + + var v = this.dataArray[i] / 128; + var y = v * this.canvas.element.height / 2; + + if (i === 0) { + this.canvas.context.moveTo(x, y); + } else { + this.canvas.context.lineTo(x, y); + } + + x += sliceWidth; + } + } else { + this.canvas.context.moveTo(0, this.canvas.element.height / 2); + this.canvas.context.lineTo(this.canvas.element.width, this.canvas.element.height / 2); + } + + this.canvas.context.stroke(); + } + }, + connect: { + + /** + Equivalent to "patching in" an audio node to visualize. NOTE: You cannot connect audio nodes across two different audio contexts. NexusUI runs its audio analysis on its own audio context, Nexus.context. If the audio node you are visualizing is created on a different audio context, you will need to tell NexusUI to use that context instead: i.e. Nexus.context = YourAudioContextName. For example, in ToneJS projects, the line would be: Nexus.context = Tone.context . We recommend that you write that line of code only once at the beginning of your project. + @param node {AudioNode} The audio node to visualize + @example Nexus.context = Tone.context // or another audio context you have created + oscilloscope.connect( Tone.Master ); + */ + + value: function connect(node) { + + if (this.source) { + this.disconnect(); + } + + this.source = node; + this.source.connect(this.analyser); + + this.render(); + } + }, + disconnect: { + + /** + Stop visualizing the source node and disconnect it. + */ + + value: function disconnect() { + if (this.source) { + this.source.disconnect(this.analyser); + this.source = null; + } + } + }, + click: { + value: function click() { + this.active = !this.active; + this.render(); + } + }, + customDestroy: { + value: function customDestroy() { + this.active = false; + } + } + }); + + return Oscilloscope; + })(Interface); + + module.exports = Oscilloscope; + +/***/ }), +/* 38 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; + + var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; }; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + /* + Main concept: + synth = new Nexus.Rack('elementID'); + + Transform all elements inside the div + synth.elementID will hold the first slider interface + + 2) In future, potentially writing a rack that is re-usable? + Could also take JSON + + new Nexus.Rack('#target',{ + pre: () => { + create some divs here, or some audio code + }, + interface: { + slider1: Nexus.add.slider({ + top:10, + left:10, + width:50, + height:100, + min: 0, + max: 100, + step: 1 + }), + wave1: Nexus.add.waveform({ + file: './path/to/file.mp3', + width:500, + height:100, + mode: 'range' + }) + }, + init: () => { + // some audio init code goes here... + } + }); + + */ + + var transform = _interopRequireWildcard(__webpack_require__(39)); + + var dom = _interopRequire(__webpack_require__(7)); + + var colors = __webpack_require__(1).colors; + + var Rack = (function () { + function Rack(target, settings) { + _classCallCheck(this, Rack); + + this.meta = {}; + this.meta.target = target; + this.meta.parent = dom.parseElement(target); // should be a generic function for parsing a 'target' argument that checks for string/DOM/jQUERY + this.meta.colors = {}; + + if (settings) { + this.meta.attribute = settings.attribute || "nexus-ui"; + this.meta.title = settings.name || false; + this.meta.open = settings.open || false; + } else { + this.meta.attribute = "nexus-ui"; + this.meta.title = false; + this.meta.open = false; + } + + var defaultColors = colors(); // jshint ignore:line + this.meta.colors.accent = defaultColors.accent; + this.meta.colors.fill = defaultColors.fill; + this.meta.colors.light = defaultColors.light; + this.meta.colors.dark = defaultColors.dark; + this.meta.colors.mediumLight = defaultColors.mediumLight; + this.meta.colors.mediumDark = defaultColors.mediumDark; + this.buildInterface(); + this.colorInterface(); + } + + _createClass(Rack, { + buildInterface: { + value: function buildInterface() { + var _this = this; + + this.meta.parent.style.boxSizing = "border-box"; + this.meta.parent.style.userSelect = "none"; + this.meta.parent.style.mozUserSelect = "none"; + this.meta.parent.style.webkitUserSelect = "none"; + + this.meta.contents = document.createElement("div"); + + while (this.meta.parent.childNodes.length > 0) { + this.meta.contents.appendChild(this.meta.parent.childNodes[0]); + } + + this.meta.contents.style.padding = "0px"; + this.meta.contents.style.boxSizing = "border-box"; + + if (this.meta.title) { + this.meta.titleBar = document.createElement("div"); + this.meta.titleBar.innerHTML = this.meta.title; + this.meta.titleBar.style.fontFamily = "arial"; + this.meta.titleBar.style.position = "relative"; + this.meta.titleBar.style.color = "#888"; + this.meta.titleBar.style.padding = "7px"; + this.meta.titleBar.style.fontSize = "12px"; + + this.meta.button = document.createElement("div"); + this.meta.button.style.position = "absolute"; + this.meta.button.style.top = "5px"; + this.meta.button.style.right = "5px"; + this.meta.button.innerHTML = "-"; + this.meta.button.style.padding = "0px 5px 2px"; + this.meta.button.style.lineHeight = "12px"; + this.meta.button.style.fontSize = "15px"; + + this.meta.button.style.cursor = "pointer"; + + this.meta.button.addEventListener("mouseover", function () { + _this.meta.button.style.backgroundColor = _this.meta.colors.mediumDark; + }); + this.meta.button.addEventListener("mouseleave", function () { + _this.meta.button.style.backgroundColor = _this.meta.colors.mediumLight; + }); + this.meta.button.addEventListener("click", function () { + if (_this.meta.open) { + _this.hide(); + } else { + _this.show(); + } + }); + + this.meta.titleBar.appendChild(this.meta.button); + + this.meta.parent.appendChild(this.meta.titleBar); + } + this.meta.parent.appendChild(this.meta.contents); + + // var width = this.meta.parent.style.width = getComputedStyle(this.meta.parent).getPropertyValue('width'); + // this.meta.parent.style.width = width; + + var ui = transform.section(this.meta.target, this.meta.attribute); + for (var key in ui) { + this[key] = ui[key]; + } + } + }, + colorInterface: { + value: function colorInterface() { + if (this.meta.title) { + this.meta.button.style.backgroundColor = this.meta.colors.mediumLight; + this.meta.button.style.border = "solid 0px " + this.meta.colors.fill; + this.meta.parent.style.border = "solid 1px " + this.meta.colors.mediumLight; + this.meta.parent.style.backgroundColor = this.meta.colors.light; + this.meta.titleBar.style.backgroundColor = this.meta.colors.fill; + } + } + }, + show: { + value: function show() { + this.meta.contents.style.display = "block"; + this.meta.open = true; + } + }, + hide: { + value: function hide() { + this.meta.contents.style.display = "none"; + this.meta.open = false; + } + }, + colorize: { + value: function colorize(type, color) { + for (var key in this) { + if (this[key].colorize) { + this[key].colorize(type, color); + } + } + this.meta.colors[type] = color; + this.colorInterface(); + } + }, + empty: { + value: function empty() { + for (var key in this) { + if (this[key].destroy) { + this[key].destroy(); + } + } + } + } + }); + + return Rack; + })(); + + module.exports = Rack; + +/***/ }), +/* 39 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + "use strict"; + + var dom = _interopRequire(__webpack_require__(7)); + + var Interfaces = _interopRequire(__webpack_require__(2)); + + var createInterfaceID = function (widget, interfaceIDs) { + var type = widget.type; + if (interfaceIDs[type]) { + interfaceIDs[type]++; + } else { + interfaceIDs[type] = 1; + } + return type + interfaceIDs[type]; + }; + + var element = function (element, type, options) { + options = options || {}; + for (var i = 0; i < element.attributes.length; i++) { + var att = element.attributes[i]; + // try { + // options[att.nodeName] = eval(att.nodeValue); + // } catch(e) { + options[att.nodeName] = att.nodeValue; + // } + } + type = type[0].toUpperCase() + type.slice(1); + var widget = new Interfaces[type](element, options); + widget.id = element.id; + return widget; + }; + + var section = function (parent, keyword) { + + keyword = keyword || "nexus-ui"; + + var interfaceIDs = {}; + + var container = dom.parseElement(parent); + + var ui = {}; + + var htmlElements = container.getElementsByTagName("*"); + var elements = []; + for (var i = 0; i < htmlElements.length; i++) { + elements.push(htmlElements[i]); + } + for (var i = 0; i < elements.length; i++) { + var type = elements[i].getAttribute(keyword); + if (type) { + var formattedType = false; + for (var key in Interfaces) { + if (type.toLowerCase() === key.toLowerCase()) { + formattedType = key; + } + } + console.log(formattedType); + var widget = element(elements[i], formattedType); + if (widget.id) { + ui[widget.id] = widget; + } else { + var id = createInterfaceID(widget, interfaceIDs); + ui[id] = widget; + } + } + } + + return ui; + }; + + var add = function (type, parent, options) { + var target = document.createElement("div"); + options = options || {}; + if (parent) { + parent = dom.parseElement(parent); + } else { + parent = document.body; + } + parent.appendChild(target); + options.target = target; + if (options.size) { + target.style.width = options.size[0] + "px"; + target.style.height = options.size[1] + "px"; + } + return element(target, type, options); + }; + + exports.element = element; + exports.section = section; + exports.add = add; + +/***/ }), +/* 40 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var math = _interopRequire(__webpack_require__(5)); + + var Tune = (function () { + function Tune() { + _classCallCheck(this, Tune); + + // the scale as ratios + this.scale = []; + + // i/o modes + this.mode = { + output: "frequency", + input: "step" + }; + + // ET major + this.etmajor = [261.62558, 293.664764, 329.627563, 349.228241, 391.995422, 440, 493.883301, 523.25116]; + + // Root frequency. + this.root = math.mtof(60); // * Math.pow(2,(60-69)/12); + + // default is a major scale + this.createScale(0, 2, 4, 5, 7, 9, 11); + } + + _createClass(Tune, { + note: { + + /* Return data in the mode you are in (freq, ratio, or midi) */ + + value: function note(input, octave) { + + var newvalue = undefined; + + if (this.mode.output === "frequency") { + newvalue = this.frequency(input, octave); + } else if (this.mode.output === "ratio") { + newvalue = this.ratio(input, octave); + } else if (this.mode.output === "MIDI") { + newvalue = this.MIDI(input, octave); + } else { + newvalue = this.frequency(input, octave); + } + + return newvalue; + } + }, + frequency: { + + /* Return freq data */ + + value: function frequency(stepIn, octaveIn) { + + if (this.mode.input === "midi" || this.mode.input === "MIDI") { + this.stepIn += 60; + } + + // what octave is our input + var octave = Math.floor(stepIn / this.scale.length); + + if (octaveIn) { + octave += octaveIn; + } + + // which scale degree (0 - scale length) is our input + var scaleDegree = stepIn % this.scale.length; + + while (scaleDegree < 0) { + scaleDegree += this.scale.length; + } + + var ratio = this.scale[scaleDegree]; + + var freq = this.root * ratio; + + freq = freq * Math.pow(2, octave); + + // truncate irrational numbers + freq = Math.floor(freq * 100000000000) / 100000000000; + + return freq; + } + }, + ratio: { + + /* Force return ratio data */ + + value: function ratio(stepIn, octaveIn) { + + if (this.mode.input === "midi" || this.mode.input === "MIDI") { + this.stepIn += 60; + } + + // what octave is our input + var octave = Math.floor(stepIn / this.scale.length); + + if (octaveIn) { + octave += octaveIn; + } + + // which scale degree (0 - scale length) is our input + var scaleDegree = stepIn % this.scale.length; + + // what ratio is our input to our key + var ratio = Math.pow(2, octave) * this.scale[scaleDegree]; + + ratio = Math.floor(ratio * 100000000000) / 100000000000; + + return ratio; + } + }, + MIDI: { + + /* Force return adjusted MIDI data */ + + value: function MIDI(stepIn, octaveIn) { + + var newvalue = this.frequency(stepIn, octaveIn); + + var n = 69 + 12 * Math.log(newvalue / 440) / Math.log(2); + + n = Math.floor(n * 1000000000) / 1000000000; + + return n; + } + }, + createScale: { + value: function createScale() { + var newScale = []; + for (var i = 0; i < arguments.length; i++) { + newScale.push(math.mtof(60 + arguments[i])); + } + this.loadScaleFromFrequencies(newScale); + } + }, + createJIScale: { + value: function createJIScale() { + this.scale = []; + for (var i = 0; i < arguments.length; i++) { + this.scale.push(arguments[i]); + } + } + }, + loadScaleFromFrequencies: { + value: function loadScaleFromFrequencies(freqs) { + this.scale = []; + for (var i = 0; i < freqs.length - 1; i++) { + this.scale.push(freqs[i] / freqs[0]); + } + } + }, + loadScale: { + + /* Load a new scale */ + + value: function loadScale(name) { + + /* load the scale */ + var freqs = this.scales[name].frequencies; + this.loadScaleFromFrequencies(freqs); + } + }, + search: { + + /* Search the names of tunings + Returns an array of names of tunings */ + + value: function search(letters) { + var possible = []; + for (var key in this.scales) { + if (key.toLowerCase().indexOf(letters.toLowerCase()) !== -1) { + possible.push(key); + } + } + return possible; + } + }, + chord: { + + /* Return a collection of notes as an array */ + + value: function chord(midis) { + var output = []; + for (var i = 0; i < midis.length; i++) { + output.push(this.note(midis[i])); + } + return output; + } + } + }); + + return Tune; + })(); + + module.exports = Tune; + +/***/ }), +/* 41 */ +/***/ (function(module, exports) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + //Disable jshint warning concerning trailing regular params + /*jshint -W138 */ + + var Radio = (function () { + //if non-existent buttons are switched, they are ignored + + function Radio() { + for (var _len = arguments.length, onVals = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + onVals[_key - 1] = arguments[_key]; + } + + var length = arguments[0] === undefined ? 3 : arguments[0]; + + _classCallCheck(this, Radio); + + //each optional 'onVals' argument switches on that value in the Radio if it exists + //In the example below, a 3-button radio is created, index 0 is switched on, index 1 is switched on then then attempted again producing an warning, and the final argument produces a warning because the index value does not exist. + //Example: + //` radio = new Radio(3, 0, 1, 1, 3); + //… [1,1,0] + + if (length < 0) { + length = 1; + } + + this.length = length; + this.onVals = onVals; + this.array = new Array(length).fill(0); + + if (onVals.length > 0) { + this.on.apply(this, onVals); + } + } + + _createClass(Radio, { + select: { + value: function select(value) { + this.array.fill(0); + this.array[value] = 1; + return this.array; + } + }, + flip: { + value: function flip() { + for (var _len = arguments.length, values = Array(_len), _key = 0; _key < _len; _key++) { + values[_key] = arguments[_key]; + } + + //flips the specified values. if no value is specified, flips all buttons + var a = this.array; + if (values.length > 0) { + values.forEach(function (v) { + if (v > a.length - 1) { + console.warn("Warning: AnonRadio[" + v + "] does not exist"); + } else { + a[v] = a[v] ? 0 : 1; + } + }); + } else { + a.forEach(function (v, i, arr) { + arr[i] = v ? 0 : 1; + }); + } + return a; + } + }, + on: { + value: function on() { + for (var _len = arguments.length, values = Array(_len), _key = 0; _key < _len; _key++) { + values[_key] = arguments[_key]; + } + + //switch on the specified values. if no value specified, flips on all buttons + var a = this.array; + if (values.length > 0) { + values.forEach(function (v) { + if (v > a.length - 1) { + console.warn("Warning: AnonRadio[" + v + "] exceeds size of object"); + } else { + if (a[v] === 1) { + console.warn("Warning: AnonRadio[" + v + "] was already on."); + } + a[v] = 1; + } + }); + } else { + a.fill(1); + } + return a; + } + }, + off: { + value: function off() { + for (var _len = arguments.length, values = Array(_len), _key = 0; _key < _len; _key++) { + values[_key] = arguments[_key]; + } + + //switch off the specified values. if no value specified, flips off all buttons + var a = this.array; + if (values.length > 0) { + values.forEach(function (v) { + a[v] = 0; + }); + } else { + a.fill(0); + } + return a; + } + } + }); + + return Radio; + })(); + + module.exports = Radio; + +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { + + var WAAClock = __webpack_require__(43) + + module.exports = WAAClock + if (typeof window !== 'undefined') window.WAAClock = WAAClock + + +/***/ }), +/* 43 */ +/***/ (function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(process) {var isBrowser = (typeof window !== 'undefined') + + var CLOCK_DEFAULTS = { + toleranceLate: 0.10, + toleranceEarly: 0.001 + } + + // ==================== Event ==================== // + var Event = function(clock, deadline, func) { + this.clock = clock + this.func = func + this._cleared = false // Flag used to clear an event inside callback + + this.toleranceLate = clock.toleranceLate + this.toleranceEarly = clock.toleranceEarly + this._latestTime = null + this._earliestTime = null + this.deadline = null + this.repeatTime = null + + this.schedule(deadline) + } + + // Unschedules the event + Event.prototype.clear = function() { + this.clock._removeEvent(this) + this._cleared = true + return this + } + + // Sets the event to repeat every `time` seconds. + Event.prototype.repeat = function(time) { + if (time === 0) + throw new Error('delay cannot be 0') + this.repeatTime = time + if (!this.clock._hasEvent(this)) + this.schedule(this.deadline + this.repeatTime) + return this + } + + // Sets the time tolerance of the event. + // The event will be executed in the interval `[deadline - early, deadline + late]` + // If the clock fails to execute the event in time, the event will be dropped. + Event.prototype.tolerance = function(values) { + if (typeof values.late === 'number') + this.toleranceLate = values.late + if (typeof values.early === 'number') + this.toleranceEarly = values.early + this._refreshEarlyLateDates() + if (this.clock._hasEvent(this)) { + this.clock._removeEvent(this) + this.clock._insertEvent(this) + } + return this + } + + // Returns true if the event is repeated, false otherwise + Event.prototype.isRepeated = function() { return this.repeatTime !== null } + + // Schedules the event to be ran before `deadline`. + // If the time is within the event tolerance, we handle the event immediately. + // If the event was already scheduled at a different time, it is rescheduled. + Event.prototype.schedule = function(deadline) { + this._cleared = false + this.deadline = deadline + this._refreshEarlyLateDates() + + if (this.clock.context.currentTime >= this._earliestTime) { + this._execute() + + } else if (this.clock._hasEvent(this)) { + this.clock._removeEvent(this) + this.clock._insertEvent(this) + + } else this.clock._insertEvent(this) + } + + Event.prototype.timeStretch = function(tRef, ratio) { + if (this.isRepeated()) + this.repeatTime = this.repeatTime * ratio + + var deadline = tRef + ratio * (this.deadline - tRef) + // If the deadline is too close or past, and the event has a repeat, + // we calculate the next repeat possible in the stretched space. + if (this.isRepeated()) { + while (this.clock.context.currentTime >= deadline - this.toleranceEarly) + deadline += this.repeatTime + } + this.schedule(deadline) + } + + // Executes the event + Event.prototype._execute = function() { + if (this.clock._started === false) return + this.clock._removeEvent(this) + + if (this.clock.context.currentTime < this._latestTime) + this.func(this) + else { + if (this.onexpired) this.onexpired(this) + console.warn('event expired') + } + // In the case `schedule` is called inside `func`, we need to avoid + // overrwriting with yet another `schedule`. + if (!this.clock._hasEvent(this) && this.isRepeated() && !this._cleared) + this.schedule(this.deadline + this.repeatTime) + } + + // Updates cached times + Event.prototype._refreshEarlyLateDates = function() { + this._latestTime = this.deadline + this.toleranceLate + this._earliestTime = this.deadline - this.toleranceEarly + } + + // ==================== WAAClock ==================== // + var WAAClock = module.exports = function(context, opts) { + var self = this + opts = opts || {} + this.tickMethod = opts.tickMethod || 'ScriptProcessorNode' + this.toleranceEarly = opts.toleranceEarly || CLOCK_DEFAULTS.toleranceEarly + this.toleranceLate = opts.toleranceLate || CLOCK_DEFAULTS.toleranceLate + this.context = context + this._events = [] + this._started = false + } + + // ---------- Public API ---------- // + // Schedules `func` to run after `delay` seconds. + WAAClock.prototype.setTimeout = function(func, delay) { + return this._createEvent(func, this._absTime(delay)) + } + + // Schedules `func` to run before `deadline`. + WAAClock.prototype.callbackAtTime = function(func, deadline) { + return this._createEvent(func, deadline) + } + + // Stretches `deadline` and `repeat` of all scheduled `events` by `ratio`, keeping + // their relative distance to `tRef`. In fact this is equivalent to changing the tempo. + WAAClock.prototype.timeStretch = function(tRef, events, ratio) { + events.forEach(function(event) { event.timeStretch(tRef, ratio) }) + return events + } + + // Removes all scheduled events and starts the clock + WAAClock.prototype.start = function() { + if (this._started === false) { + var self = this + this._started = true + this._events = [] + + if (this.tickMethod === 'ScriptProcessorNode') { + var bufferSize = 256 + // We have to keep a reference to the node to avoid garbage collection + this._clockNode = this.context.createScriptProcessor(bufferSize, 1, 1) + this._clockNode.connect(this.context.destination) + this._clockNode.onaudioprocess = function () { + process.nextTick(function() { self._tick() }) + } + } else if (this.tickMethod === 'manual') null // _tick is called manually + + else throw new Error('invalid tickMethod ' + this.tickMethod) + } + } + + // Stops the clock + WAAClock.prototype.stop = function() { + if (this._started === true) { + this._started = false + this._clockNode.disconnect() + } + } + + // ---------- Private ---------- // + + // This function is ran periodically, and at each tick it executes + // events for which `currentTime` is included in their tolerance interval. + WAAClock.prototype._tick = function() { + var event = this._events.shift() + + while(event && event._earliestTime <= this.context.currentTime) { + event._execute() + event = this._events.shift() + } + + // Put back the last event + if(event) this._events.unshift(event) + } + + // Creates an event and insert it to the list + WAAClock.prototype._createEvent = function(func, deadline) { + return new Event(this, deadline, func) + } + + // Inserts an event to the list + WAAClock.prototype._insertEvent = function(event) { + this._events.splice(this._indexByTime(event._earliestTime), 0, event) + } + + // Removes an event from the list + WAAClock.prototype._removeEvent = function(event) { + var ind = this._events.indexOf(event) + if (ind !== -1) this._events.splice(ind, 1) + } + + // Returns true if `event` is in queue, false otherwise + WAAClock.prototype._hasEvent = function(event) { + return this._events.indexOf(event) !== -1 + } + + // Returns the index of the first event whose deadline is >= to `deadline` + WAAClock.prototype._indexByTime = function(deadline) { + // performs a binary search + var low = 0 + , high = this._events.length + , mid + while (low < high) { + mid = Math.floor((low + high) / 2) + if (this._events[mid]._earliestTime < deadline) + low = mid + 1 + else high = mid + } + return low + } + + // Converts from relative time to absolute time + WAAClock.prototype._absTime = function(relTime) { + return relTime + this.context.currentTime + } + + // Converts from absolute time to relative time + WAAClock.prototype._relTime = function(absTime) { + return absTime - this.context.currentTime + } + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(44))) + +/***/ }), +/* 44 */ +/***/ (function(module, exports) { + + // shim for using process in browser + var process = module.exports = {}; + + // cached from whatever global is present so that test runners that stub it + // don't break things. But we need to wrap it in a try catch in case it is + // wrapped in strict mode code which doesn't define any globals. It's inside a + // function because try/catches deoptimize in certain engines. + + var cachedSetTimeout; + var cachedClearTimeout; + + function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); + } + function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); + } + (function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } + } ()) + function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + + } + function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + + } + var queue = []; + var draining = false; + var currentQueue; + var queueIndex = -1; + + function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } + } + + function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); + } + + process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } + }; + + // v8 likes predictible objects + function Item(fun, array) { + this.fun = fun; + this.array = array; + } + Item.prototype.run = function () { + this.fun.apply(null, this.array); + }; + process.title = 'browser'; + process.browser = true; + process.env = {}; + process.argv = []; + process.version = ''; // empty string to avoid regexp issues + process.versions = {}; + + function noop() {} + + process.on = noop; + process.addListener = noop; + process.once = noop; + process.off = noop; + process.removeListener = noop; + process.removeAllListeners = noop; + process.emit = noop; + process.prependListener = noop; + process.prependOnceListener = noop; + + process.listeners = function (name) { return [] } + + process.binding = function (name) { + throw new Error('process.binding is not supported'); + }; + + process.cwd = function () { return '/' }; + process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); + }; + process.umask = function() { return 0; }; + + +/***/ }), +/* 45 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + + var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + + var clock = __webpack_require__(1).clock; + + var Interval = (function () { + function Interval(rate, func, on) { + _classCallCheck(this, Interval); + + this.rate = rate; + this.on = on; + this.clock = clock(); // jshint ignore:line + + this.pattern = [1]; + this.index = 0; + + this.event = func ? func : function () {}; + + if (this.on) { + this.start(); + } + } + + _createClass(Interval, { + _event: { + value: function _event(e) { + // if (this.pattern[this.index%this.pattern.length]) { + this.event(e); + // } + this.index++; + } + }, + stop: { + value: function stop() { + this.on = false; + this.interval.clear(); + } + }, + start: { + value: function start() { + this.on = true; + this.interval = this.clock.callbackAtTime(this._event.bind(this), this.clock.context.currentTime).repeat(this.rate / 1000).tolerance({ early: 0.1, late: 1 }); + } + }, + ms: { + value: function ms(newrate) { + if (this.on) { + var ratio = newrate / this.rate; + this.rate = newrate; + this.clock.timeStretch(this.clock.context.currentTime, [this.interval], ratio); + } else { + this.rate = newrate; + } + } + } + }); + + return Interval; + })(); + + module.exports = Interval; + +/***/ }) +/******/ ]) +}); +; +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay91bml2ZXJzYWxNb2R1bGVEZWZpbml0aW9uIiwid2VicGFjazovLy93ZWJwYWNrL2Jvb3RzdHJhcCBiMjY5YWNlZjhjYWRhNzA4NDUwMiIsIndlYnBhY2s6Ly8vLi9pbmRleC5qcyIsIndlYnBhY2s6Ly8vLi9saWIvbWFpbi5qcyIsIndlYnBhY2s6Ly8vLi9saWIvaW50ZXJmYWNlcy9pbmRleC5qcyIsIndlYnBhY2s6Ly8vLi9saWIvaW50ZXJmYWNlcy9wb3NpdGlvbi5qcyIsIndlYnBhY2s6Ly8vLi9saWIvdXRpbC9zdmcuanMiLCJ3ZWJwYWNrOi8vLy4vbGliL3V0aWwvbWF0aC5qcyIsIndlYnBhY2s6Ly8vLi9saWIvY29yZS9pbnRlcmZhY2UuanMiLCJ3ZWJwYWNrOi8vLy4vbGliL3V0aWwvZG9tLmpzIiwid2VicGFjazovLy8uL2xpYi91dGlsL3V0aWwuanMiLCJ3ZWJwYWNrOi8vLy4vbGliL3V0aWwvd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IENvdW50ZXIgPSByZXF1aXJlKCcuL21vZGVscy9jb3VudGVyJyk7XG5sZXQgUmFkaW8gPSByZXF1aXJlKCcuL21vZGVscy9yYWRpbycpO1xubGV0IERydW5rID0gcmVxdWlyZSgnLi9tb2RlbHMvZHJ1bmsnKTtcbmxldCBTZXF1ZW5jZSA9IHJlcXVpcmUoJy4vbW9kZWxzL3NlcXVlbmNlJyk7XG5sZXQgTWF0cml4ID0gcmVxdWlyZSgnLi9tb2RlbHMvbWF0cml4Jyk7XG5cbmltcG9ydCBXQUFDbG9jayBmcm9tICd3YWFjbG9jayc7XG5pbXBvcnQgSW50ZXJ2YWwgZnJvbSAnLi90aW1lL2ludGVydmFsJztcblxuXG4vKipcbk5leHVzVUkgPT4gY3JlYXRlZCBhcyBOZXh1c1xuKi9cblxuY2xhc3MgTmV4dXNVSSB7XG5cbiAgICBjb25zdHJ1Y3Rvcihjb250ZXh0KSB7XG5cbiAgICAgICAgZm9yIChsZXQga2V5IGluIEludGVyZmFjZXMpIHtcbiAgICAgICAgICAgIHRoaXNba2V5XSA9IEludGVyZmFjZXNba2V5XTtcbiAgICAgICAgfVxuXG4gICAgICAgIGZvciAobGV0IGtleSBpbiBtYXRoKSB7XG4gICAgICAgICAgICB0aGlzW2tleV0gPSBtYXRoW2tleV07XG4gICAgICAgIH1cblxuICAgICAgICBsZXQgQ29yZSA9IHtcbiAgICAgICAgICAnUmFjayc6IFJhY2tcbiAgICAgICAgfTtcblxuICAgICAgICBsZXQgTW9kZWxzID0ge1xuICAgICAgICAgICdDb3VudGVyJzogQ291bnRlcixcbiAgICAgICAgICAnUmFkaW8nOiBSYWRpbyxcbiAgICAgICAgICAnRHJ1bmsnOiBEcnVuayxcbiAgICAgICAgICAnU2VxdWVuY2UnOiBTZXF1ZW5jZSxcbiAgICAgICAgICAnTWF0cml4JzogTWF0cml4XG4gICAgICAgIH07XG5cbiAgICAgICAgZm9yIChsZXQga2V5IGluIE1vZGVscykge1xuICAgICAgICAgIHRoaX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duKHRoaXMubWF0cml4LnBhaW50YnJ1c2gpO1xuICAgICAgICB9XG4gICAgICB9KTtcblxuXG4gICAgICB0aGlzLm1vdmUgPSAoKSA9PiB7XG4gICAgICB9O1xuICAgICAgdGhpcy5wYWQuYWRkRXZlbnRMaXN0ZW5lcignbW91c2Vtb3ZlJywgKGUpID0+IHtcbiAgICAgICAgaWYgKHRoaXMubWF0cml4LmludGVyYWN0aW5nKSB7XG4gICAgICAgICAgaWYgKCF0aGlzLm9mZnNldCkge1xuICAgICAgICAgICAgdGhpcy5vZmZzZXQgPSBkb20uZmluZFBvc2l0aW9uKHRoaXMuZWxlbWVudCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIHRoaXMubW91c2UgPSBkb20ubG9jYXRlTW91c2UoZSx0aGlzLm9mZnNldCk7XG4gICAgICAgICAgdGhpcy5iZW5kKCk7XG4gICAgICAgIH1cbiAgICAgIH0pO1xuXG5cbiAgICAgIHRoaXMucmVsZWFzZSA9ICgpID0+IHtcbiAgICAgICAgdGhpcy5tYXRyaXguaW50ZXJhY3RpbmcgPSBmYWxzZTtcbiAgICAgIH07XG4gICAgICB0aGlzLnBhZC5hZGRFdmVudExpc3RlbmVyKCdtb3VzZXVwJywgKCkgPT4ge1xuICAgICAgICBpZiAodGhpcy5tYXRyaXguaW50ZXJhY3RpbmcpIHtcbiAgICAgICAgICB0aGlzLnVwKCk7XG4gICAgICAgIH1cbiAgICAgIH0pO1xuICAgICAgdGhpcy5wYWQuYWRkRXZlbnRMaXN0ZW5lcignbW91c2VvdXQnLCAoKSA9PiB7XG4gICAgICAgIGlmICh0aGlzLm1hdHJpeC5pbnRlcmFjdGluZykge1xuICAgICAgICAgIHRoaXMudXAoKTtcbiAgICAgICAgfVxuICAgICAgfSk7XG4gICAgfVxuXG4gIH1cblxuICBzaXplSW50ZXJmYWNlKCkge1xuXG4gICAgdGhpcy5wYWQuc2V0QXR0cmlidXRlKCd4JywxKTtcbiAgICB0aGlzLnBhZC5zZXRBdHRya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HNldCBhIGNvbHVtbiB1c2luZyBhbiBhcnJheSBhcyBpbnB1dFxuICAgICAgICB0aGlzLnBhdHRlcm4uZm9yRWFjaCgocm93LGkpID0+IHtcbiAgICAgICAgICB0aGlzLnBhdHRlcm5baV1bY29sdW1uXSA9IHZhbHVlc1tpXTtcbiAgICAgICAgfSk7XG4gICAgICAgIGlmICh0aGlzLnVpKSB7IHRoaXMudWkudXBkYXRlKCk7IH1cbiAgICAgIH1cbiAgICB9O1xuXG4gICAgdGhpcy5yb3RhdGUgPSB7XG4gICAgICAvL3Nob3VsZCBldmVudHVhbGx5IGRvIChhbW91bnRYLCBhbW91bnRZKSBoZXJlXG4gICAgICAvLyBjb3VsZCBqdXN0IHVzZSBhIGxvb3AgYW5kIHRoaXMucm90YXRlLnJvdyhpLGFtb3VudFgpO1xuICAgICAgYWxsOiAoYW1vdW50KSA9PiB7XG4gICAgICAgIGlmICghYW1vdW50ICYmIGFtb3VudCE9PTApIHtcbiAgICAgICAgICBhbW91bnQgPSAxO1xuICAgICAgICB9XG4gICAgICAgIGFtb3VudCAlPSB0aGlzLnBhdHRlcm5bMF0ubGVuZ3RoO1xuICAgICAgICBpZiAoYW1vdW50IDwgMCkge1xuICAgICAgICAgIGFtb3VudCA9IHRoaXMucGF0dGVyblswXS5sZW5ndGggKyBhbW91bnQ7XG4gICAgICAgIH1cbiAgICAgICAgZm9yIChsZXQgaT0wOyBpPHRoaXMucm93czsgaSsrKSB7XG4gICAgICAgICAgbGV0IGN1dCA9IHRoaXMucGF0dGVybltpXS5zcGxpY2UoIHRoaXMucGF0dGVybltpXS5sZW5ndGggLSBhbW91bnQsIGFtb3VudCApO1xuICAgICAgICAgIHRoaXMucGF0dGVybltpXSA9IGN1dC5jb25jYXQoIHRoaXMucGF0dGVybltpXSApO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLnVpKSB7IHRoaXMudWkudXBkYXRlKCk7IH1cbiAgICAgIH0sXG4gICAgICByb3c6IChyb3csYW1vdW50KSA9PiB7XG4gICAgICAgIGlmICghYW1vdW50ICYmIGFtb3VudCE9PTApIHtcbiAgICAgICAgICBhbW91bnQgPSAxO1xuICAgICAgICB9XG4gICAgICAgIGFtb3VudCAlPSB0aGlzLnBhdHRlcm5bMF0ubGVuZ3RoO1xuICAgICAgICBpZiAoYW1vdW50IDwgMCkge1xuICAgICAgICAgIGFtb3VudCA9IHRoaXMucGF0dGVyblswXS5sZW5ndGggKyBhbW91bnQ7XG4gICAgICAgIH1cbiAgICAgICAgbGV0IGN1dCA9IHRoaXMucGF0dGVybltyb3ddLnNwbGljZSggdGhpcy5wYXR0ZXJuW3Jvd10ubGVuZ3RoIC0gYW1vdW50LCBhbW91bnQgKTtcbiAgICAgICAgdGhpcy5wYXR0ZXJuW3Jvd10gPSBjdXQuY29uY2F0KCB0aGlzLnBhdHRlcm5bcm93XSApO1xuICAgICAgICBpZiAodGhpcy51aSkgeyB0aGlzLnVpLnVwZGF0ZSgpOyB9XG4gICAgICB9LFxuICAgICAgY29sdW1uOiAoY29sdW1uLCBhbW91bnQpID0+IHtcbiAgICAgICAgaWYgKCFhbW91bnQgJiYgYW1vdW50IT09MCkge1xuICAgICAgICAgIGFtb3VudCA9IDE7XG4gICAgICAgIH1cbiAgICAgICAgYW1vdW50ICU9IHRoaXMucGF0dGVybi5sZW5ndGg7XG4gICAgICAgIGlmIChhbW91bnQgPCAwKSB7XG4gICAgICAgICAgYW1vdW50ID0gdGhpcy5wYXR0ZXJuLmxlbmd0aCArIGFtb3VudDtcbiAgICAgICAgfVxuICAgICAgICBsZXQgcHJveHkgPSBbXTtcbiAgICAgICAgdGhpcy5wYXR0ZXJuLmZvckVhY2goKHJvdykgPT4ge1xuICAgICAgICAgIHByb3h5LnB1c2goIHJvd1tjb2x1bW5dICk7XG4gICAgICAgIH0pO1xuICAgICAgICBsZXQgY3V0ID0gcHJveHkuc3BsaWNlKCBwcm94eS5sZW5ndGggLSBhbW91bnQsIGFtb3VudCApO1xuICAgICAgICBwcm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cblxuICB1cGRhdGUocGF0dGVybikge1xuICAgIHRoaXMucGF0dGVybiA9IHBhdHRlcm4gfHwgdGhpcy5wYXR0ZXJuO1xuICB9XG5cbiAgZ2V0IGxlbmd0aCgpIHtcbiAgICByZXR1cm4gdGhpcy5yb3dzKnRoaXMuY29sdW1ucztcbiAgfVxuXG4gIGxvY2F0ZShpbmRleCkge1xuICAgIC8vIHJldHVybnMgcm93IGFuZCBjb2x1bW4gb2YgY2VsbCBieSBpbmRleFxuICAgIHJldHVybiB7XG4gICAgICByb3c6IH5+KCBpbmRleCAvIHRoaXMuY29sdW1ucyApLFxuICAgICAgY29sdW1uOiBpbmRleCAlIHRoaXMuY29sdW1uc1xuICAgIH07XG4gIH1cblxuICBpbmRleE9mKHJvdyxjb2x1bW4pIHtcbiAgICByZXR1cm4gY29sdW1uICsgcm93ICogdGhpcy5jb2x1bW5zO1xuICAgIC8vIHJldHVybnMgaW5kZXggb2YgY2VsbCBieSByb3cgYW5kIGNvbHVtblxuICB9XG5cbiAgcm93KHJvdykge1xuICAgIGxldCBkYXRhID0gW107XG4gICAgZm9yIChsZXQgaT0wOyBpPHRoaXMuY29sdW1uczsgaSsrKSB7XG4gICAgICBkYXRhLnB1c2godGhpcy5wYXR0ZXJuW3Jvd10gPyAxIDogMCk7XG4gICAgfVxuICAgIHJldHVybiBkYXRhO1xuICB9XG5cbiAgY29sdW1uKGNvbHVtbikge1xuICAgIGxldCBkYXRhID0gW107XG4gICAgZm9yIChsZXQgaT0wOyBpPHRoaXMucm93czsgaSsrKSB7XG4gICAgICBkYXRhLnB1c2godGhpcy5wYXR0ZXJuW2ldW2NvbHVtbl0gPyAxIDogMCk7XG4gICAgfVxuICAgIHJldHVybiBkYXRhO1xuICB9XG5cbiAgZ2V0IHJvd3MoKSB7XG4gICAgcmV0dXJuIHRoaXMucGF0dGVybi5sZW5ndGg7XG4gIH1cbiAgc2V0IHJvd3Modikge1xuICAgIGxldCBwcmV2aW91cyA9IHRoaXMucGF0dGVyb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jtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9tb2RlID0gbW9kZTtcbiAgICAgICAgaWYgKHRoaXMudmFsdWUpIHtcbiAgICAgICAgICB0aGlzLm5leHQgPSB0aGlzW3RoaXMuX21vZGVdO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IG1vZGUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9tb2RlO1xuICAgIH1cblxuICAgIGZpcnN0KCkge1xuICAgICAgaWYgKHRoaXMudmFsdWUhPT1mYWxzZSkge1xuICAgICAgICB0aGlzLm5leHQgPSB0aGlzW3RoaXMuX21vZGVdO1xuICAgICAgICByZXR1cm4gdGhpcy5uZXh0KCk7XG4gICAgICB9XG4gICAgICB0aGlzLnN0YXJ0VmFsdWVzID0ge1xuICAgICAgICAndXAnOiB0aGlzLm1pbixcbiAgICAgICAgJ2Rvd24nOiB0aGlzLm1heCxcbiAgICAgICAgJ2RydW5rJzogfn5tYXRoLmF2ZXJhZ2UodGhpcy5taW4sdGhpcy5tYXgpLFxuICAgICAgICAncmFuZG9tJzogbWF0aC5yaSh0aGlzLm1pbix0aGlzLm1heClcbiAgICAgIH07XG4gICAgICB0aGlzLnZhbHVlID0gdGhpcy5zdGFydFZhbHVlc1t0aGlzLl9tb2RlXTtcbiAgICAgIHRoaXMubmV4dCA9IHRoaXNbdGhpcy5fbW9kZV07XG4gICAgICByZXR1cm4gdGhpcy52YWx1ZTtcbiAgICB9XG5cbiAgICB1cCgpIHtcbiAgICAgICAgdGhpcy52YWx1ZSsrO1xuICAgICAgICBpZiAodGhpcy52YWx1ZSA+PSB0aGlzLm1heCkge1xuICAgICAgICAgICAgdGhpcy52YWx1ZSA9IHRoaXMubWluO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLnZhbHVlO1xuICAgIH1cblxuICAgIGRvd24oKSB7XG4gICAgICAgIHRoaXMudmFsdWUtLTtcbiAgICAgICAgaWYgKHRoaXMudmFsdWUgPCB0aGlzLm1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Iuc2xpZGVyc1toaWdoXS52YWx1ZTtcbiAgICAgICAgICAgICAgZm9yIChsZXQgaT1sb3c7aTxoaWdoO2krKykge1xuICAgICAgICAgICAgICAgIHRoaXMubXVsdGlzbGlkZXIuc2xpZGVyc1tpXS52YWx1ZSA9IG1hdGguaW50ZXJwKCAoaS1sb3cpL2Rpc3RhbmNlLCBsb3dWYWx1ZSwgaGlnaFZhbHVlICk7XG4gICAgICAgICAgICAgICAgbGV0IHNtb290aGVkVmFsdWUgPSB0aGlzLm11bHRpc2xpZGVyLnNsaWRlcnNbaV0udmFsdWU7XG4gICAgICAgICAgICAgICAgdGhpcy5tdWx0aXNsaWRlci52YWx1ZXNbaV0gPSBzbW9vdGhlZFZhbHVlO1xuICAgICAgICAgICAgICAgIHRoaXMubXVsdGlzbGlkZXIudXBkYXRlKGksc21vb3RoZWRWYWx1ZSk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG5cbiAgICAgICAgICB0aGlzLm11bHRpc2xpZGVyLmludGVycG9sYXRpb24gPSB7XG4gICAgICAgICAgICBpbmRleDogdGhpcy5pbmRleCxcbiAgICAgICAgICAgIHZhbHVlOiB0aGlzLnZhbHVlXG4gICAgICAgICAgfTtcbiAgICAgICAgfVxuICAgICAgfSk7XG5cblxuICAgICAgdGhpcy5tb3ZlID0gKCkgPT4ge1xuICAgICAgfTtcbiAgICAgIHRoaXMuZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCdtb3VzZW1vdmUnLCAoZSkgPT4ge1xuICAgICAgICBpZiAodGhpcy5tdWx0aXNsaWRlci5pbnRlcmFjdGluZykge1xuICAgICAgICAgIGlmICghdGhpcy5vZmZzZXQpIHtcbiAgICAgICAgICAgIHRoaXMub2Zmc2V0ID0gZG9tLmZpbmRQb3NpdGlvbih0aGlzLmVsZW1lbnQpO1xuICAgICAgICAgIH1cbiAgICAgICAgICB0aGlzLm1vdXNlID0gZG9tLmxvY2F0ZU1vdXNlKGU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ICAgICAgICB2YWx1ZXMuZm9yRWFjaChmdW5jdGlvbih2KSB7XG4gICAgICAgICAgICAgICAgaWYgKHYgPiBhLmxlbmd0aCAtIDEpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS53YXJuKCdXYXJuaW5nOiBBbm9uUmFkaW9bJyArIHYgKyAnXSBkb2VzIG5vdCBleGlzdCcpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGFbdl0gPSAoYVt2XSA/IDAgOiAxKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGEuZm9yRWFjaChmdW5jdGlvbih2LCBpLCBhcnIpIHtcbiAgICAgICAgICAgICAgICBhcnJbaV0gPSAodiA/IDAgOiAxKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBhO1xuICAgIH1cblxuICAgIG9uKC4uLnZhbHVlcykge1xuICAgICAgICAvL3N3aXRjaCBvbiB0aGUgc3BlY2lmaWVkIHZhbHVlcy4gaWYgbm8gdmFsdWUgc3BlY2lmaWVkLCBmbGlwcyBvbiBhbGwgYnV0dG9uc1xuICAgICAgICBsZXQgYSA9IHRoaXMuYXJyYXk7XG4gICAgICAgIGlmICh2YWx1ZXMubGVuZ3RoID4gMCkge1xuICAgICAgICAgICAgdmFsdWVzLmZvckVhY2goZnVuY3Rpb24odikge1xuICAgICAgICAgICAgICAgIGlmICh2ID4gYS5sZW5ndGggLSAxKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybignV2FybmluZzogQW5vblJhZGlvWycgKyB2ICsgJ10gZXhjZWVkcyBzaXplIG9mIG9iamVjdCcpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChhW3ZdID09PSAxKSB7IGNvbnNvbGUud2FybignV2FybmluZzogQW5vblJhZGlv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aW9uIGRyYWluUXVldWUoKSB7XG4gICAgaWYgKGRyYWluaW5nKSB7XG4gICAgICAgIHJldHVybjtcbiAgICB9XG4gICAgdmFyIHRpbWVvdXQgPSBydW5UaW1lb3V0KGNsZWFuVXBOZXh0VGljayk7XG4gICAgZHJhaW5pbmcgPSB0cnVlO1xuXG4gICAgdmFyIGxlbiA9IHF1ZXVlLmxlbmd0aDtcbiAgICB3aGlsZShsZW4pIHtcbiAgICAgICAgY3VycmVudFF1ZXVlID0gcXVldWU7XG4gICAgICAgIHF1ZXVlID0gW107XG4gICAgICAgIHdoaWxlICgrK3F1ZXVlSW5kZXggPCBsZW4pIHtcbiAgICAgICAgICAgIGlmIChjdXJyZW50UXVldWUpIHtcbiAgICAgICAgICAgICAgICBjdXJyZW50UXVldWVbcXVldWVJbmRleF0ucnVuKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcXVldWVJbmRleCA9IC0xO1xuICAgICAgICBsZW4gPSBxdWV1ZS5sZW5ndGg7XG4gICAgfVxuICAgIGN1cnJlbnRRdWV1ZSA9IG51bGw7XG4gICAgZHJhaW5pbmcgPSBmYWxzZTtcbiAgICBydW5DbGVhclRpbWVvdXQodGltZW91dCk7XG59XG5cbnByb2Nlc3MubmV4dFRpY2sgPSBmdW5jdGlvbiAoZnVuKSB7XG4gICAgdmFyIGFyZ3MgPSBuZXcgQXJyYXkoYXJndW1lbnRzLmxlbmd0aCAtIDEpO1xuICAgIGlmIChhcmd1bWVudHMubGVuZ3RoID4gMSkge1xuICAgICAgICBmb3IgKHZhciBpID0gMTsgaSA8IGFyZ3VtZW50cy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgYXJnc1tpIC0gMV0gPSBhcmd1bWVudHNbaV07XG4gICAgICAgIH1cbiAgICB9XG4gICAgcXVldWUucHVzaChuZXcgSXRlbShmdW4sIGFyZ3MpKTtcbiAgICBpZiAocXVldWUubGVuZ3RoID09PSAxICYmICFkcmFpbmluZykge1xuICA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LyAgfVxuICAgIHRoaXMuaW5kZXgrKztcbiAgfVxuXG4gIHN0b3AoKSB7XG4gICAgdGhpcy5vbiA9IGZhbHNlO1xuICAgIHRoaXMuaW50ZXJ2YWwuY2xlYXIoKTtcbiAgfVxuXG4gIHN0YXJ0KCkge1xuICAgIHRoaXMub24gPSB0cnVlO1xuICAgIHRoaXMuaW50ZXJ2YWwgPSB0aGlzLmNsb2NrLmNhbGxiYWNrQXRUaW1lKHRoaXMuX2V2ZW50LmJpbmQodGhpcyksIHRoaXMuY2xvY2suY29udGV4dC5jdXJyZW50VGltZSkucmVwZWF0KHRoaXMucmF0ZS8xMDAwKS50b2xlcmFuY2Uoe2Vhcmx5OiAwLjEsIGxhdGU6MX0pO1xuICB9XG5cbiAgbXMobmV3cmF0ZSkge1xuICAgIGlmICh0aGlzLm9uKSB7XG4gICAgICB2YXIgcmF0aW8gPSBuZXdyYXRlL3RoaXMucmF0ZTtcbiAgICAgIHRoaXMucmF0ZSA9IG5ld3JhdGU7XG4gICAgICB0aGlzLmNsb2NrLnRpbWVTdHJldGNoKHRoaXMuY2xvY2suY29udGV4dC5jdXJyZW50VGltZSwgW3RoaXMuaW50ZXJ2YWxdLCByYXRpbyk7XG4gICAgfSBlbHNlIHtcbiAgICAgIHRoaXMucmF0ZSA9IG5ld3JhdGU7XG4gICAgfVxuICB9XG5cbn1cblxuXG5cbi8vIFdFQlBBQ0sgRk9PVEVSIC8vXG4vLyAuL34vanNoaW50LWxvYWRlciEuL2xpYi90aW1lL2ludGVydmFsLmpzIl0sInNvdXJjZVJvb3QiOiIifQ== + +/***/ }), +/* 77 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _slicedToArray2 = __webpack_require__(74); + +var _slicedToArray3 = _interopRequireDefault(_slicedToArray2); + +var _extends2 = __webpack_require__(73); + +var _extends3 = _interopRequireDefault(_extends2); + +var _tone = __webpack_require__(21); + +var _tone2 = _interopRequireDefault(_tone); + +var _nexusui = __webpack_require__(76); + +var _nexusui2 = _interopRequireDefault(_nexusui); + +var _FileSaver = __webpack_require__(75); + +var _keys = __webpack_require__(70); + +var _keys2 = _interopRequireDefault(_keys); + +var _scales = __webpack_require__(51); + +var _scales2 = _interopRequireDefault(_scales); + +var _midi = __webpack_require__(71); + +var _util = __webpack_require__(30); + +var _ui = __webpack_require__(72); + +var _data = __webpack_require__(69); + +var data = _interopRequireWildcard(_data); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var DEFAULT_BPM = 60; + +var nx = window.nx = {}; + +var recorder = null; +var recording = false; +var sendPitchBend = false; + +(0, _midi.midi_init)(); + +/* initialization */ + +var i = 0, + datasets = {}, + dataset = {}, + bounds = {}, + diff = []; +var play_fn = _midi.play_sequence; +data.load().then(function (lists) { + console.log(lists); + datasets = lists.map(function (list) { + list.shift(); + switch (list.name) { + // case 'gun_violence': + // return { + // ...list, + // lines: list.lines.map(line => { + // // 0 incident_id + // // 1 date + // // 2 state + // // 3 city_or_county + // // 4 address + // // 5 n_killed + // // 6 n_injured + // }) + // } + // break + case 'gun_violence': + return gun_violence_melody(list); + case 'mass_shootings': + return (0, _extends3.default)({}, list, { + lines: list.lines.map(function (line) { + // 0 case name + // 1 location + // 2 date + // 3 summary + // 4 fatalities + // 5 injured + // 6 total_victims + // 7 location + // 8 age_of_shooter + // 9 prior_signs_mental_health_issues + // 10 mental_health_details + // 11 weapons_obtained_legally + // 12 where_obtained + // 13 weapon_type + // 14 weapon_details + // 15 race + // 16 gender + // 17 sources + // 18 mental_health_sources + // 19 sources_additional_age + // 20 latitude + // 21 longitude + // 22 type (Spree / Mass) + // 23 year + }) + }); + break; + } + }); + pick_dataset('mass shootings'); + (0, _util.requestAudioContext)(ready); +}); + +/* + 479363, + 2013-01-19,New Mexico,Albuquerque,2806 Long Lane, + 5,0, + http://www.gunviolencearchive.org/incident/479363, + http://hinterlandgazette.com/2013/01/pastor-greg-griego-identified-victims-killed-nehemiah-griego-albuquerque-nm-shooting.html, + False,1, + + gun_stolen, + 0::Unknown||1::Unknown, + + gun_type, + 0::22 LR||1::223 Rem [AR-15], + + incident_characteristics, + "Shot - Dead (murder, accidental, suicide) + ||Mass Shooting (4+ victims injured or killed excluding the subject/suspect/perpetrator, one location) + ||Domestic Violence", + + latitude, location_description, longitude, + 34.9791,,-106.716, + + n_guns_involved, notes, + 2,, + + participant_age, + 0::51||1::40||2::9||3::5||4::2||5::15, + + participant_age_group, + 0::Adult 18+||1::Adult 18+||2::Child 0-11||3::Child 0-11||4::Child 0-11||5::Teen 12-17, + + participant_gender, + 0::Male||1::Female||2::Male||3::Female||4::Female||5::Male, + + participant_name, + 0::Greg Griego||1::Sara Griego||2::Zephania Griego||3::Jael Griego||4::Angelina Griego||5::Nehemiah Griego, + + participant_relationship, + 5::Family, + + participant_status, + "0::Killed||1::Killed||2::Killed||3::Killed||4::Killed||5::Unharmed, Arrested", + + participant_type, + 0::Victim||1::Victim||2::Victim||3::Victim||4::Victim||5::Subject-Suspect, + + http://www.cbsnews.com/news/nehemiah-gringo-case-memorial-service-planned-for-family-allegedly-slain-by-new-mexico-teen/|| + http://www.thewire.com/national/2013/01/teenager-reportedly-used-ar-15-kill-five-new-mexico/61199/|| + http://bigstory.ap.org/article/officials-nm-teen-gunman-kills-5-inside-home|| + http://www.huffingtonpost.com/2013/01/21/nehemiah-griego-teen-shoots-parents-3-children_n_2519359.html|| + http://murderpedia.org/male.G/g/griego-nehemiah.htm|| + http://hinterlandgazette.com/2013/01/pastor-greg-griego-identified-victims-killed-nehemiah-griego-albuquerque-nm-shooting.html, + 10,14 +*/ + +function gun_violence_melody(list) { + var melody = []; + var lookup = {}; + var last = Date.now(); + var last_y = 2018; + var last_m = 3; + list.lines.forEach(function (line) { + var _line = (0, _slicedToArray3.default)(line, 29), + incident_id = _line[0], + date = _line[1], + state = _line[2], + city_or_county = _line[3], + address = _line[4], + n_killed = _line[5], + n_injured = _line[6], + incident_url = _line[7], + source_url = _line[8], + incident_url_fields_missing = _line[9], + congressional_district = _line[10], + gun_stolen = _line[11], + gun_type = _line[12], + incident_characteristics = _line[13], + latitude = _line[14], + location_description = _line[15], + longitude = _line[16], + n_guns_involved = _line[17], + notes = _line[18], + participant_age = _line[19], + participant_age_group = _line[20], + participant_gender = _line[21], + participant_name = _line[22], + participant_relationship = _line[23], + participant_status = _line[24], + participant_type = _line[25], + sources = _line[26], + state_house_district = _line[27], + state_senate_district = _line[28]; + + var _date$split = date.split('-'), + _date$split2 = (0, _slicedToArray3.default)(_date$split, 3), + y = _date$split2[0], + m = _date$split2[1], + d = _date$split2[2]; + }); + return (0, _extends3.default)({}, list, { + lines: melody + }); +} + +/* play next note according to sonification */ + +function play_next() { + var note_time = 120000 / _tone2.default.Transport.bpm.value * _midi.note_values[nx.timing.active][0] * nx.duration.value; + setTimeout(play_next, note_time); + + var _play_fn = play_fn(i, bounds, note_time), + _play_fn2 = (0, _slicedToArray3.default)(_play_fn, 2), + new_i = _play_fn2[0], + notes = _play_fn2[1]; + + i = new_i; + if (recording) { + var timing = _midi.note_values[nx.timing.active][2]; + if (timing.length) timing = timing[i % timing.length]; + recorder.addEvent(new _midi.MidiWriter.NoteEvent({ pitch: notes, duration: 't' + timing })); + } +} + +/* bind selects */ + +function pick_dataset(key) { + console.log('pick dataset:', key); + i = 0; + dataset = datasets[key]; + bounds = (0, _util.get_bounds)(dataset); + diff = (0, _util.get_diff_bounds)(bounds.rows); +} +var behaviors = { + sequence: { name: 'Sequence', fn: _midi.play_sequence }, + interval: { name: 'Intervals', fn: _midi.play_interval_sequence } +}; +function pick_behavior(name) { + play_fn = behaviors[name].fn; +} + +/* build and bind the UI */ + +function ready() { + _scales2.default.build_options(document.querySelector('#scale')); + (0, _ui.build_options)(document.querySelector('#dataset'), datasets, pick_dataset); + (0, _ui.build_options)(document.querySelector('#behavior'), behaviors, pick_behavior); + // nx.colorize('#f4d142') + + _tone2.default.Transport.bpm.value = DEFAULT_BPM; + nx.tempo = new _nexusui2.default.Dial('#tempo', { + min: 10, + max: 300, + step: 1, + value: DEFAULT_BPM + }); + (0, _ui.update_value_on_change)(nx.tempo, '#tempo', true, function (v) { + return _tone2.default.Transport.bpm.value = v; + }); + + nx.timing = new _nexusui2.default.RadioButton('#timing', { + size: [400, 25], + numberOfButtons: _midi.note_values.length, + active: 6 + }); + (0, _ui.update_radio_value_on_change)(nx.timing, '#timing', _midi.note_values); + + nx.duration = new _nexusui2.default.Dial('#duration', { + min: 0, + max: 2, + step: 0.01, + value: 0.8 + }); + (0, _ui.update_value_on_change)(nx.duration, '#duration', false); + + nx.offset = new _nexusui2.default.Dial('#offset', { + min: -24, + max: 24, + step: 1, + value: 0 + }); + (0, _ui.update_value_on_change)(nx.offset, '#offset', true); + + nx.octave = new _nexusui2.default.Dial('#octave', { + min: -4, + max: 4, + step: 1, + value: 0 + }); + (0, _ui.update_value_on_change)(nx.octave, '#octave', true); + + nx.multiply = new _nexusui2.default.Dial('#multiply', { + min: -64, + max: 64, + step: 1, + value: 7 + }); + (0, _ui.update_value_on_change)(nx.multiply, '#multiply', true); + + nx.interval = new _nexusui2.default.Dial('#interval', { + min: -64, + max: 64, + step: 1, + value: 10 + }); + (0, _ui.update_value_on_change)(nx.interval, '#interval', true); + + var export_midi_button = document.querySelector('#export_midi'); + export_midi_button.addEventListener('click', function () { + export_pattern_as_midi(dataset.name, bounds, nx.tempo.value, nx.timing.active, play_fn); + }); + + var record_midi_button = document.querySelector('#record_midi'); + record_midi_button.addEventListener('click', function () { + if (recording) { + record_midi_button.innerHTML = 'Record MIDI'; + document.body.classList.remove('recording'); + recording = false; + var writer = new _midi.MidiWriter.Writer([recorder]); + var blob = (0, _util.dataURItoBlob)(writer.dataUri()); + (0, _FileSaver.saveAs)(blob, 'Recording - ' + dataset.name + '.mid'); + } else { + record_midi_button.innerHTML = 'Save Recording'; + document.body.classList.add('recording'); + recording = true; + recorder = new _midi.MidiWriter.Track(); + recorder.setTempo(nx.tempo.value); + } + }); + + document.querySelector('.loading').classList.remove('loading'); + play_next(); +} + +/* keys */ + +_keys2.default.listen(function (index) { + nx.offset.value = index; + nx.offset.update(index); +}); + +/***/ }), +/* 78 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _assign = __webpack_require__(31); + +var _assign2 = _interopRequireDefault(_assign); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +module.exports = function () { + var Intonation = function Intonation(opt) { + opt = this.opt = (0, _assign2.default)({ + name: "", + root: 440, + octave: 0, + interval: 2, + tet: 0, + intervals: null + }, opt || {}); + this.generate(); + }; + Intonation.prototype.generate = function (opt) { + opt = (0, _assign2.default)(this.opt, opt || {}); + if (opt.scl) { + this.generate_scl(); + } else if (opt.tet) { + this.generate_tet(); + } else if (opt.intervals) { + this.generate_intervals(); + } + }; + Intonation.prototype.generate_intervals = function () { + var root = this.opt.root; + var interval_list = this.opt.intervals; + if (typeof interval_list == "string") { + interval_list = interval_list.split(" "); + } + this.name = this.opt.name || "interval list"; + this.intervals = interval_list; + this.interval = this.opt.interval = parseInterval.call(this, interval_list.pop()); + this.scale = interval_list.map(parseIntervalString.bind(this)).filter(function (v) { + return !!v; + }); + }; + Intonation.prototype.generate_tet = function () { + var scale = this.scale = []; + var root = this.opt.root; + var tet = this.opt.tet; + var interval = this.interval = this.opt.interval; + var ratio = Math.pow(interval, 1 / tet); + var n = root; + scale.push(n); + for (var i = 0; i < tet - 1; i++) { + n *= ratio; + scale.push(n); + } + this.name = this.opt.name || tet + "-tone equal temperament"; + this.intervals = null; + }; + Intonation.prototype.generate_scl = function () { + var root = this.opt.root; + var scl = this.parse_scl(this.opt.scl); + this.intervals = scl.notes; + this.interval = scl.notes.pop(); + this.name = this.opt.name || scl.description; + this.scale = scl.notes.map(function (v) { + return v * root; + }); + }; + Intonation.prototype.parse_scl = function (s) { + var scl = {}; + scl.comments = []; + scl.notes = []; + s.trim().split("\n").forEach(function (line) { + // Lines beginning with an exclamation mark are regarded as comments + // and are to be ignored. + if (line.indexOf("!") !== -1) { + scl.comments.push(line); + } + // The first (non comment) line contains a short description of the scale. + // If there is no description, there should be an empty line. (nb: which is falsey) + else if (!('description' in scl)) { + scl.description = line; + } + // The second line contains the number of notes. + // The first note of 1/1 or 0.0 cents is implicit and not in the files. + else if (!scl.notes.length) { + scl.notes.push(1); + } else { + // If the value contains a period, it is a cents value, otherwise a ratio. + var note = line.replace(/^[^-\.0-9]+/, "").replace(/[^-\/\.0-9]+$/, ""); + if (note.indexOf(".") !== -1) { + note = Math.pow(2, parseFloat(note) / 1200); + } else { + note = parseInterval(note); + } + if (note) { + scl.notes.push(note); + } + } + }); + return scl; + }; + Intonation.prototype.index = function (i, octave) { + octave = octave || this.opt.octave; + var f = this.scale[mod(i, this.scale.length) | 0]; + var pow = Math.floor(norm(i, 0, this.scale.length)) + octave; + f *= Math.pow(this.interval, pow); + return f; + }; + Intonation.prototype.range = function (min, max) { + var a = []; + for (var i = min; i < max; i++) { + a.push(this.index(i)); + } + return a; + }; + Intonation.prototype.set_root = function (f) { + this.opt.root = f; + this.generate(); + }; + Intonation.prototype.quantize_frequency = function (f) { + if (f == 0) return 0; + var scale_f = f; + var pow = 0; + var interval = this.interval; + var scale = this.scale; + while (scale_f < root) { + scale_f *= interval; + pow -= 1; + } + while (scale_f > root * interval) { + scale_f /= interval; + pow += 1; + } + for (var i = 0; i < scale.length; i++) { + if (scale_f > scale[i]) continue; + scale_f = scale[i]; + break; + } + scale_f *= Math.pow(2, pow); + return scale_f; + }; + Intonation.prototype.quantize_index = function (i) { + return mod(index - 1, this.scale.length) | 0; + }; + var parseInterval = Intonation.prototype.parse_interval = function (s) { + if (typeof s == "number") return s; + if (!s.indexOf("/") == -1) return parseInt(s); + var pp = s.split("/"); + var num = parseInt(pp[0]); + var den = parseInt(pp[1]); + if (isNaN(num)) return 1; + if (isNaN(den) || den == 0) return num; + if (num == den) return 1; + return num / den; + }; + var parseIntervalString = Intonation.prototype.parse_interval_string = function (s) { + if (s.indexOf("/") !== -1) return parseInterval(s) * this.opt.root; // intervals + if (s.indexOf("f") !== -1) return parseFloat(s); // pure frequencies + return parseFloat(s); + }; + function norm(n, a, b) { + return (n - a) / (b - a); + } + function mod(n, m) { + return n - m * Math.floor(n / m); + } + + return Intonation; +}(); + +/***/ }), +/* 79 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _tone = __webpack_require__(21); + +var _tone2 = _interopRequireDefault(_tone); + +var _util = __webpack_require__(30); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var player_count = 2; + +var compressor = new _tone2.default.Compressor(-30, 3).toMaster(); + +var samples = [{ root: 226, fn: 'samples/380737__cabled-mess__sansula-01-a-raw.mp3' }, { root: 267, fn: 'samples/380736__cabled-mess__sansula-02-c-raw.mp3' }, { root: 340, fn: 'samples/380735__cabled-mess__sansula-03-e-raw.mp3' }, { root: 452, fn: 'samples/380733__cabled-mess__sansula-06-a-02-raw.mp3' }]; + +samples.forEach(function (sample) { + sample.players = []; + sample.index = -1; + for (var i = 0; i < player_count; i++) { + var fn = sample.fn; + if (window.location.href.match(/asdf.us/)) { + fn = '//asdf.us/kalimba/' + fn; + } + var player = new _tone2.default.Player({ + url: fn, + retrigger: true, + playbackRate: 1 + }); + player.connect(compressor); + sample.players.push(player); + } +}); + +function play(freq) { + var best = { sample: (0, _util.choice)(samples) }; + best.sample.index = (best.sample.index + 1) % player_count; + + var player = best.sample.players[best.sample.index]; + player.playbackRate = freq / best.sample.root; + console.log(player); + player.start(); +} + +exports.default = { play: play }; + +/***/ }), +/* 80 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__; + +var _typeof2 = __webpack_require__(88); + +var _typeof3 = _interopRequireDefault(_typeof2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * StartAudioContext.js + * @author Yotam Mann + * @license http://opensource.org/licenses/MIT MIT License + * @copyright 2016 Yotam Mann + */ +(function (root, factory) { + if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? + (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if ((typeof module === "undefined" ? "undefined" : (0, _typeof3.default)(module)) === 'object' && module.exports) { + module.exports = factory(); + } else { + root.StartAudioContext = factory(); + } +})(undefined, function () { + + /** + * The StartAudioContext object + */ + var StartAudioContext = { + /** + * The audio context passed in by the user + * @type {AudioContext} + */ + context: null, + /** + * The TapListeners bound to the elements + * @type {Array} + * @private + */ + _tapListeners: [], + /** + * Callbacks to invoke when the audio context is started + * @type {Array} + * @private + */ + _onStarted: [] + }; + + /** + * Set the context + * @param {AudioContext} ctx + * @returns {StartAudioContext} + */ + StartAudioContext.setContext = function (ctx) { + StartAudioContext.context = ctx; + return StartAudioContext; + }; + + /** + * Add a tap listener to the audio context + * @param {Array|Element|String|jQuery} element + * @returns {StartAudioContext} + */ + StartAudioContext.on = function (element) { + if (Array.isArray(element) || NodeList && element instanceof NodeList) { + for (var i = 0; i < element.length; i++) { + StartAudioContext.on(element[i]); + } + } else if (typeof element === "string") { + StartAudioContext.on(document.querySelectorAll(element)); + } else if (element.jquery && typeof element.toArray === "function") { + StartAudioContext.on(element.toArray()); + } else if (Element && element instanceof Element) { + //if it's an element, create a TapListener + var tap = new TapListener(element, onTap); + StartAudioContext._tapListeners.push(tap); + } + return StartAudioContext; + }; + + /** + * Bind a callback to when the audio context is started. + * @param {Function} cb + * @return {StartAudioContext} + */ + StartAudioContext.onStarted = function (cb) { + //if it's already started, invoke the callback + if (StartAudioContext.isStarted()) { + cb(); + } else { + StartAudioContext._onStarted.push(cb); + } + return StartAudioContext; + }; + + /** + * returns true if the context is started + * @return {Boolean} + */ + StartAudioContext.isStarted = function () { + return StartAudioContext.context !== null && StartAudioContext.context.state === "running"; + }; + + /** + * @class Listens for non-dragging tap ends on the given element + * @param {Element} element + * @internal + */ + var TapListener = function TapListener(element) { + + this._dragged = false; + + this._element = element; + + this._bindedMove = this._moved.bind(this); + this._bindedEnd = this._ended.bind(this); + + element.addEventListener("touchmove", this._bindedMove); + element.addEventListener("touchend", this._bindedEnd); + element.addEventListener("mouseup", this._bindedEnd); + }; + + /** + * drag move event + */ + TapListener.prototype._moved = function (e) { + this._dragged = true; + }; + + /** + * tap ended listener + */ + TapListener.prototype._ended = function (e) { + if (!this._dragged) { + onTap(); + } + this._dragged = false; + }; + + /** + * remove all the bound events + */ + TapListener.prototype.dispose = function () { + this._element.removeEventListener("touchmove", this._bindedMove); + this._element.removeEventListener("touchend", this._bindedEnd); + this._element.removeEventListener("mouseup", this._bindedEnd); + this._bindedMove = null; + this._bindedEnd = null; + this._element = null; + }; + + /** + * Invoked the first time of the elements is tapped. + * Creates a silent oscillator when a non-dragging touchend + * event has been triggered. + */ + function onTap() { + //start the audio context with a silent oscillator + if (StartAudioContext.context && !StartAudioContext.isStarted()) { + var osc = StartAudioContext.context.createOscillator(); + var silent = StartAudioContext.context.createGain(); + silent.gain.value = 0; + osc.connect(silent); + silent.connect(StartAudioContext.context.destination); + var now = StartAudioContext.context.currentTime; + osc.start(now); + osc.stop(now + 0.5); + } + + //dispose all the tap listeners + if (StartAudioContext._tapListeners) { + for (var i = 0; i < StartAudioContext._tapListeners.length; i++) { + StartAudioContext._tapListeners[i].dispose(); + } + StartAudioContext._tapListeners = null; + } + //the onstarted callbacks + if (StartAudioContext._onStarted) { + for (var j = 0; j < StartAudioContext._onStarted.length; j++) { + StartAudioContext._onStarted[j](); + } + StartAudioContext._onStarted = null; + } + } + + return StartAudioContext; +}); + +/***/ }), +/* 81 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = { "default": __webpack_require__(90), __esModule: true }; + +/***/ }), +/* 82 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = { "default": __webpack_require__(91), __esModule: true }; + +/***/ }), +/* 83 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = { "default": __webpack_require__(92), __esModule: true }; + +/***/ }), +/* 84 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = { "default": __webpack_require__(94), __esModule: true }; + +/***/ }), +/* 85 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = { "default": __webpack_require__(95), __esModule: true }; + +/***/ }), +/* 86 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = { "default": __webpack_require__(96), __esModule: true }; + +/***/ }), +/* 87 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = { "default": __webpack_require__(97), __esModule: true }; + +/***/ }), +/* 88 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.__esModule = true; + +var _iterator = __webpack_require__(87); + +var _iterator2 = _interopRequireDefault(_iterator); + +var _symbol = __webpack_require__(86); + +var _symbol2 = _interopRequireDefault(_symbol); + +var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; }; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) { + return typeof obj === "undefined" ? "undefined" : _typeof(obj); +} : function (obj) { + return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj); +}; + +/***/ }), +/* 89 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray + +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i +} + +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 + +function placeHoldersCount (b64) { + var len = b64.length + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 +} + +function byteLength (b64) { + // base64 is 4/3 + up to two characters of the original data + return b64.length * 3 / 4 - placeHoldersCount(b64) +} + +function toByteArray (b64) { + var i, j, l, tmp, placeHolders, arr + var len = b64.length + placeHolders = placeHoldersCount(b64) + + arr = new Arr(len * 3 / 4 - placeHolders) + + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? len - 4 : len + + var L = 0 + + for (i = 0, j = 0; i < l; i += 4, j += 3) { + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] + arr[L++] = (tmp >> 16) & 0xFF + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } + + if (placeHolders === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[L++] = tmp & 0xFF + } else if (placeHolders === 1) { + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} + +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var output = '' + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + output += lookup[tmp >> 2] + output += lookup[(tmp << 4) & 0x3F] + output += '==' + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) + output += lookup[tmp >> 10] + output += lookup[(tmp >> 4) & 0x3F] + output += lookup[(tmp << 2) & 0x3F] + output += '=' + } + + parts.push(output) + + return parts.join('') +} + + +/***/ }), +/* 90 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(29); +__webpack_require__(28); +module.exports = __webpack_require__(124); + +/***/ }), +/* 91 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(29); +__webpack_require__(28); +module.exports = __webpack_require__(125); + +/***/ }), +/* 92 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(127); +module.exports = __webpack_require__(1).Math.log2; + +/***/ }), +/* 93 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(128); +module.exports = __webpack_require__(1).Object.assign; + +/***/ }), +/* 94 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(129); +module.exports = __webpack_require__(1).Object.keys; + +/***/ }), +/* 95 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(63); +__webpack_require__(28); +__webpack_require__(29); +__webpack_require__(130); +module.exports = __webpack_require__(1).Promise; + +/***/ }), +/* 96 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(131); +__webpack_require__(63); +__webpack_require__(132); +__webpack_require__(133); +module.exports = __webpack_require__(1).Symbol; + +/***/ }), +/* 97 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(28); +__webpack_require__(29); +module.exports = __webpack_require__(45).f('iterator'); + +/***/ }), +/* 98 */ +/***/ (function(module, exports) { + +module.exports = function(){ /* empty */ }; + +/***/ }), +/* 99 */ +/***/ (function(module, exports) { + +module.exports = function(it, Constructor, name, forbiddenField){ + if(!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)){ + throw TypeError(name + ': incorrect invocation!'); + } return it; +}; + +/***/ }), +/* 100 */ +/***/ (function(module, exports, __webpack_require__) { + +// false -> Array#indexOf +// true -> Array#includes +var toIObject = __webpack_require__(9) + , toLength = __webpack_require__(61) + , toIndex = __webpack_require__(123); +module.exports = function(IS_INCLUDES){ + return function($this, el, fromIndex){ + var O = toIObject($this) + , length = toLength(O.length) + , index = toIndex(fromIndex, length) + , value; + // Array#includes uses SameValueZero equality algorithm + if(IS_INCLUDES && el != el)while(length > index){ + value = O[index++]; + if(value != value)return true; + // Array#toIndex ignores holes, Array#includes - not + } else for(;length > index; index++)if(IS_INCLUDES || index in O){ + if(O[index] === el)return IS_INCLUDES || index || 0; + } return !IS_INCLUDES && -1; + }; +}; + +/***/ }), +/* 101 */ +/***/ (function(module, exports, __webpack_require__) { + +// all enumerable object keys, includes symbols +var getKeys = __webpack_require__(15) + , gOPS = __webpack_require__(38) + , pIE = __webpack_require__(24); +module.exports = function(it){ + var result = getKeys(it) + , getSymbols = gOPS.f; + if(getSymbols){ + var symbols = getSymbols(it) + , isEnum = pIE.f + , i = 0 + , key; + while(symbols.length > i)if(isEnum.call(it, key = symbols[i++]))result.push(key); + } return result; +}; + +/***/ }), +/* 102 */ +/***/ (function(module, exports, __webpack_require__) { + +var ctx = __webpack_require__(22) + , call = __webpack_require__(106) + , isArrayIter = __webpack_require__(104) + , anObject = __webpack_require__(4) + , toLength = __webpack_require__(61) + , getIterFn = __webpack_require__(62) + , BREAK = {} + , RETURN = {}; +var exports = module.exports = function(iterable, entries, fn, that, ITERATOR){ + var iterFn = ITERATOR ? function(){ return iterable; } : getIterFn(iterable) + , f = ctx(fn, that, entries ? 2 : 1) + , index = 0 + , length, step, iterator, result; + if(typeof iterFn != 'function')throw TypeError(iterable + ' is not iterable!'); + // fast case for arrays with default iterator + if(isArrayIter(iterFn))for(length = toLength(iterable.length); length > index; index++){ + result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]); + if(result === BREAK || result === RETURN)return result; + } else for(iterator = iterFn.call(iterable); !(step = iterator.next()).done; ){ + result = call(iterator, f, step.value, entries); + if(result === BREAK || result === RETURN)return result; + } +}; +exports.BREAK = BREAK; +exports.RETURN = RETURN; + +/***/ }), +/* 103 */ +/***/ (function(module, exports) { + +// fast apply, http://jsperf.lnkit.com/fast-apply/5 +module.exports = function(fn, args, that){ + var un = that === undefined; + switch(args.length){ + case 0: return un ? fn() + : fn.call(that); + case 1: return un ? fn(args[0]) + : fn.call(that, args[0]); + case 2: return un ? fn(args[0], args[1]) + : fn.call(that, args[0], args[1]); + case 3: return un ? fn(args[0], args[1], args[2]) + : fn.call(that, args[0], args[1], args[2]); + case 4: return un ? fn(args[0], args[1], args[2], args[3]) + : fn.call(that, args[0], args[1], args[2], args[3]); + } return fn.apply(that, args); +}; + +/***/ }), +/* 104 */ +/***/ (function(module, exports, __webpack_require__) { + +// check on default Array iterator +var Iterators = __webpack_require__(14) + , ITERATOR = __webpack_require__(0)('iterator') + , ArrayProto = Array.prototype; + +module.exports = function(it){ + return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); +}; + +/***/ }), +/* 105 */ +/***/ (function(module, exports, __webpack_require__) { + +// 7.2.2 IsArray(argument) +var cof = __webpack_require__(17); +module.exports = Array.isArray || function isArray(arg){ + return cof(arg) == 'Array'; +}; + +/***/ }), +/* 106 */ +/***/ (function(module, exports, __webpack_require__) { + +// call something on iterator step with safe closing on error +var anObject = __webpack_require__(4); +module.exports = function(iterator, fn, value, entries){ + try { + return entries ? fn(anObject(value)[0], value[1]) : fn(value); + // 7.4.6 IteratorClose(iterator, completion) + } catch(e){ + var ret = iterator['return']; + if(ret !== undefined)anObject(ret.call(iterator)); + throw e; + } +}; + +/***/ }), +/* 107 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var create = __webpack_require__(56) + , descriptor = __webpack_require__(25) + , setToStringTag = __webpack_require__(26) + , IteratorPrototype = {}; + +// 25.1.2.1.1 %IteratorPrototype%[@@iterator]() +__webpack_require__(7)(IteratorPrototype, __webpack_require__(0)('iterator'), function(){ return this; }); + +module.exports = function(Constructor, NAME, next){ + Constructor.prototype = create(IteratorPrototype, {next: descriptor(1, next)}); + setToStringTag(Constructor, NAME + ' Iterator'); +}; + +/***/ }), +/* 108 */ +/***/ (function(module, exports, __webpack_require__) { + +var ITERATOR = __webpack_require__(0)('iterator') + , SAFE_CLOSING = false; + +try { + var riter = [7][ITERATOR](); + riter['return'] = function(){ SAFE_CLOSING = true; }; + Array.from(riter, function(){ throw 2; }); +} catch(e){ /* empty */ } + +module.exports = function(exec, skipClosing){ + if(!skipClosing && !SAFE_CLOSING)return false; + var safe = false; + try { + var arr = [7] + , iter = arr[ITERATOR](); + iter.next = function(){ return {done: safe = true}; }; + arr[ITERATOR] = function(){ return iter; }; + exec(arr); + } catch(e){ /* empty */ } + return safe; +}; + +/***/ }), +/* 109 */ +/***/ (function(module, exports) { + +module.exports = function(done, value){ + return {value: value, done: !!done}; +}; + +/***/ }), +/* 110 */ +/***/ (function(module, exports, __webpack_require__) { + +var getKeys = __webpack_require__(15) + , toIObject = __webpack_require__(9); +module.exports = function(object, el){ + var O = toIObject(object) + , keys = getKeys(O) + , length = keys.length + , index = 0 + , key; + while(length > index)if(O[key = keys[index++]] === el)return key; +}; + +/***/ }), +/* 111 */ +/***/ (function(module, exports, __webpack_require__) { + +var META = __webpack_require__(27)('meta') + , isObject = __webpack_require__(18) + , has = __webpack_require__(6) + , setDesc = __webpack_require__(8).f + , id = 0; +var isExtensible = Object.isExtensible || function(){ + return true; +}; +var FREEZE = !__webpack_require__(13)(function(){ + return isExtensible(Object.preventExtensions({})); +}); +var setMeta = function(it){ + setDesc(it, META, {value: { + i: 'O' + ++id, // object ID + w: {} // weak collections IDs + }}); +}; +var fastKey = function(it, create){ + // return primitive with prefix + if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; + if(!has(it, META)){ + // can't set metadata to uncaught frozen object + if(!isExtensible(it))return 'F'; + // not necessary to add metadata + if(!create)return 'E'; + // add missing metadata + setMeta(it); + // return object ID + } return it[META].i; +}; +var getWeak = function(it, create){ + if(!has(it, META)){ + // can't set metadata to uncaught frozen object + if(!isExtensible(it))return true; + // not necessary to add metadata + if(!create)return false; + // add missing metadata + setMeta(it); + // return hash weak collections IDs + } return it[META].w; +}; +// add metadata on freeze-family methods calling +var onFreeze = function(it){ + if(FREEZE && meta.NEED && isExtensible(it) && !has(it, META))setMeta(it); + return it; +}; +var meta = module.exports = { + KEY: META, + NEED: false, + fastKey: fastKey, + getWeak: getWeak, + onFreeze: onFreeze +}; + +/***/ }), +/* 112 */ +/***/ (function(module, exports, __webpack_require__) { + +var global = __webpack_require__(2) + , macrotask = __webpack_require__(60).set + , Observer = global.MutationObserver || global.WebKitMutationObserver + , process = global.process + , Promise = global.Promise + , isNode = __webpack_require__(17)(process) == 'process'; + +module.exports = function(){ + var head, last, notify; + + var flush = function(){ + var parent, fn; + if(isNode && (parent = process.domain))parent.exit(); + while(head){ + fn = head.fn; + head = head.next; + try { + fn(); + } catch(e){ + if(head)notify(); + else last = undefined; + throw e; + } + } last = undefined; + if(parent)parent.enter(); + }; + + // Node.js + if(isNode){ + notify = function(){ + process.nextTick(flush); + }; + // browsers with MutationObserver + } else if(Observer){ + var toggle = true + , node = document.createTextNode(''); + new Observer(flush).observe(node, {characterData: true}); // eslint-disable-line no-new + notify = function(){ + node.data = toggle = !toggle; + }; + // environments with maybe non-completely correct, but existent Promise + } else if(Promise && Promise.resolve){ + var promise = Promise.resolve(); + notify = function(){ + promise.then(flush); + }; + // for other environments - macrotask based on: + // - setImmediate + // - MessageChannel + // - window.postMessag + // - onreadystatechange + // - setTimeout + } else { + notify = function(){ + // strange IE + webpack dev server bug - use .call(global) + macrotask.call(global, flush); + }; + } + + return function(fn){ + var task = {fn: fn, next: undefined}; + if(last)last.next = task; + if(!head){ + head = task; + notify(); + } last = task; + }; +}; + +/***/ }), +/* 113 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 19.1.2.1 Object.assign(target, source, ...) +var getKeys = __webpack_require__(15) + , gOPS = __webpack_require__(38) + , pIE = __webpack_require__(24) + , toObject = __webpack_require__(42) + , IObject = __webpack_require__(54) + , $assign = Object.assign; + +// should work with symbols and should have deterministic property order (V8 bug) +module.exports = !$assign || __webpack_require__(13)(function(){ + var A = {} + , B = {} + , S = Symbol() + , K = 'abcdefghijklmnopqrst'; + A[S] = 7; + K.split('').forEach(function(k){ B[k] = k; }); + return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K; +}) ? function assign(target, source){ // eslint-disable-line no-unused-vars + var T = toObject(target) + , aLen = arguments.length + , index = 1 + , getSymbols = gOPS.f + , isEnum = pIE.f; + while(aLen > index){ + var S = IObject(arguments[index++]) + , keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S) + , length = keys.length + , j = 0 + , key; + while(length > j)if(isEnum.call(S, key = keys[j++]))T[key] = S[key]; + } return T; +} : $assign; + +/***/ }), +/* 114 */ +/***/ (function(module, exports, __webpack_require__) { + +var dP = __webpack_require__(8) + , anObject = __webpack_require__(4) + , getKeys = __webpack_require__(15); + +module.exports = __webpack_require__(5) ? Object.defineProperties : function defineProperties(O, Properties){ + anObject(O); + var keys = getKeys(Properties) + , length = keys.length + , i = 0 + , P; + while(length > i)dP.f(O, P = keys[i++], Properties[P]); + return O; +}; + +/***/ }), +/* 115 */ +/***/ (function(module, exports, __webpack_require__) { + +var pIE = __webpack_require__(24) + , createDesc = __webpack_require__(25) + , toIObject = __webpack_require__(9) + , toPrimitive = __webpack_require__(43) + , has = __webpack_require__(6) + , IE8_DOM_DEFINE = __webpack_require__(53) + , gOPD = Object.getOwnPropertyDescriptor; + +exports.f = __webpack_require__(5) ? gOPD : function getOwnPropertyDescriptor(O, P){ + O = toIObject(O); + P = toPrimitive(P, true); + if(IE8_DOM_DEFINE)try { + return gOPD(O, P); + } catch(e){ /* empty */ } + if(has(O, P))return createDesc(!pIE.f.call(O, P), O[P]); +}; + +/***/ }), +/* 116 */ +/***/ (function(module, exports, __webpack_require__) { + +// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window +var toIObject = __webpack_require__(9) + , gOPN = __webpack_require__(57).f + , toString = {}.toString; + +var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames + ? Object.getOwnPropertyNames(window) : []; + +var getWindowNames = function(it){ + try { + return gOPN(it); + } catch(e){ + return windowNames.slice(); + } +}; + +module.exports.f = function getOwnPropertyNames(it){ + return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it)); +}; + + +/***/ }), +/* 117 */ +/***/ (function(module, exports, __webpack_require__) { + +// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) +var has = __webpack_require__(6) + , toObject = __webpack_require__(42) + , IE_PROTO = __webpack_require__(39)('IE_PROTO') + , ObjectProto = Object.prototype; + +module.exports = Object.getPrototypeOf || function(O){ + O = toObject(O); + if(has(O, IE_PROTO))return O[IE_PROTO]; + if(typeof O.constructor == 'function' && O instanceof O.constructor){ + return O.constructor.prototype; + } return O instanceof Object ? ObjectProto : null; +}; + +/***/ }), +/* 118 */ +/***/ (function(module, exports, __webpack_require__) { + +// most Object methods by ES6 should accept primitives +var $export = __webpack_require__(12) + , core = __webpack_require__(1) + , fails = __webpack_require__(13); +module.exports = function(KEY, exec){ + var fn = (core.Object || {})[KEY] || Object[KEY] + , exp = {}; + exp[KEY] = exec(fn); + $export($export.S + $export.F * fails(function(){ fn(1); }), 'Object', exp); +}; + +/***/ }), +/* 119 */ +/***/ (function(module, exports, __webpack_require__) { + +var hide = __webpack_require__(7); +module.exports = function(target, src, safe){ + for(var key in src){ + if(safe && target[key])target[key] = src[key]; + else hide(target, key, src[key]); + } return target; +}; + +/***/ }), +/* 120 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var global = __webpack_require__(2) + , core = __webpack_require__(1) + , dP = __webpack_require__(8) + , DESCRIPTORS = __webpack_require__(5) + , SPECIES = __webpack_require__(0)('species'); + +module.exports = function(KEY){ + var C = typeof core[KEY] == 'function' ? core[KEY] : global[KEY]; + if(DESCRIPTORS && C && !C[SPECIES])dP.f(C, SPECIES, { + configurable: true, + get: function(){ return this; } + }); +}; + +/***/ }), +/* 121 */ +/***/ (function(module, exports, __webpack_require__) { + +// 7.3.20 SpeciesConstructor(O, defaultConstructor) +var anObject = __webpack_require__(4) + , aFunction = __webpack_require__(33) + , SPECIES = __webpack_require__(0)('species'); +module.exports = function(O, D){ + var C = anObject(O).constructor, S; + return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S); +}; + +/***/ }), +/* 122 */ +/***/ (function(module, exports, __webpack_require__) { + +var toInteger = __webpack_require__(41) + , defined = __webpack_require__(35); +// true -> String#at +// false -> String#codePointAt +module.exports = function(TO_STRING){ + return function(that, pos){ + var s = String(defined(that)) + , i = toInteger(pos) + , l = s.length + , a, b; + if(i < 0 || i >= l)return TO_STRING ? '' : undefined; + a = s.charCodeAt(i); + return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff + ? TO_STRING ? s.charAt(i) : a + : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; + }; +}; + +/***/ }), +/* 123 */ +/***/ (function(module, exports, __webpack_require__) { + +var toInteger = __webpack_require__(41) + , max = Math.max + , min = Math.min; +module.exports = function(index, length){ + index = toInteger(index); + return index < 0 ? max(index + length, 0) : min(index, length); +}; + +/***/ }), +/* 124 */ +/***/ (function(module, exports, __webpack_require__) { + +var anObject = __webpack_require__(4) + , get = __webpack_require__(62); +module.exports = __webpack_require__(1).getIterator = function(it){ + var iterFn = get(it); + if(typeof iterFn != 'function')throw TypeError(it + ' is not iterable!'); + return anObject(iterFn.call(it)); +}; + +/***/ }), +/* 125 */ +/***/ (function(module, exports, __webpack_require__) { + +var classof = __webpack_require__(34) + , ITERATOR = __webpack_require__(0)('iterator') + , Iterators = __webpack_require__(14); +module.exports = __webpack_require__(1).isIterable = function(it){ + var O = Object(it); + return O[ITERATOR] !== undefined + || '@@iterator' in O + || Iterators.hasOwnProperty(classof(O)); +}; + +/***/ }), +/* 126 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var addToUnscopables = __webpack_require__(98) + , step = __webpack_require__(109) + , Iterators = __webpack_require__(14) + , toIObject = __webpack_require__(9); + +// 22.1.3.4 Array.prototype.entries() +// 22.1.3.13 Array.prototype.keys() +// 22.1.3.29 Array.prototype.values() +// 22.1.3.30 Array.prototype[@@iterator]() +module.exports = __webpack_require__(55)(Array, 'Array', function(iterated, kind){ + this._t = toIObject(iterated); // target + this._i = 0; // next index + this._k = kind; // kind +// 22.1.5.2.1 %ArrayIteratorPrototype%.next() +}, function(){ + var O = this._t + , kind = this._k + , index = this._i++; + if(!O || index >= O.length){ + this._t = undefined; + return step(1); + } + if(kind == 'keys' )return step(0, index); + if(kind == 'values')return step(0, O[index]); + return step(0, [index, O[index]]); +}, 'values'); + +// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7) +Iterators.Arguments = Iterators.Array; + +addToUnscopables('keys'); +addToUnscopables('values'); +addToUnscopables('entries'); + +/***/ }), +/* 127 */ +/***/ (function(module, exports, __webpack_require__) { + +// 20.2.2.22 Math.log2(x) +var $export = __webpack_require__(12); + +$export($export.S, 'Math', { + log2: function log2(x){ + return Math.log(x) / Math.LN2; + } +}); + +/***/ }), +/* 128 */ +/***/ (function(module, exports, __webpack_require__) { + +// 19.1.3.1 Object.assign(target, source) +var $export = __webpack_require__(12); + +$export($export.S + $export.F, 'Object', {assign: __webpack_require__(113)}); + +/***/ }), +/* 129 */ +/***/ (function(module, exports, __webpack_require__) { + +// 19.1.2.14 Object.keys(O) +var toObject = __webpack_require__(42) + , $keys = __webpack_require__(15); + +__webpack_require__(118)('keys', function(){ + return function keys(it){ + return $keys(toObject(it)); + }; +}); + +/***/ }), +/* 130 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var LIBRARY = __webpack_require__(23) + , global = __webpack_require__(2) + , ctx = __webpack_require__(22) + , classof = __webpack_require__(34) + , $export = __webpack_require__(12) + , isObject = __webpack_require__(18) + , aFunction = __webpack_require__(33) + , anInstance = __webpack_require__(99) + , forOf = __webpack_require__(102) + , speciesConstructor = __webpack_require__(121) + , task = __webpack_require__(60).set + , microtask = __webpack_require__(112)() + , PROMISE = 'Promise' + , TypeError = global.TypeError + , process = global.process + , $Promise = global[PROMISE] + , process = global.process + , isNode = classof(process) == 'process' + , empty = function(){ /* empty */ } + , Internal, GenericPromiseCapability, Wrapper; + +var USE_NATIVE = !!function(){ + try { + // correct subclassing with @@species support + var promise = $Promise.resolve(1) + , FakePromise = (promise.constructor = {})[__webpack_require__(0)('species')] = function(exec){ exec(empty, empty); }; + // unhandled rejections tracking support, NodeJS Promise without it fails @@species test + return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise; + } catch(e){ /* empty */ } +}(); + +// helpers +var sameConstructor = function(a, b){ + // with library wrapper special case + return a === b || a === $Promise && b === Wrapper; +}; +var isThenable = function(it){ + var then; + return isObject(it) && typeof (then = it.then) == 'function' ? then : false; +}; +var newPromiseCapability = function(C){ + return sameConstructor($Promise, C) + ? new PromiseCapability(C) + : new GenericPromiseCapability(C); +}; +var PromiseCapability = GenericPromiseCapability = function(C){ + var resolve, reject; + this.promise = new C(function($$resolve, $$reject){ + if(resolve !== undefined || reject !== undefined)throw TypeError('Bad Promise constructor'); + resolve = $$resolve; + reject = $$reject; + }); + this.resolve = aFunction(resolve); + this.reject = aFunction(reject); +}; +var perform = function(exec){ + try { + exec(); + } catch(e){ + return {error: e}; + } +}; +var notify = function(promise, isReject){ + if(promise._n)return; + promise._n = true; + var chain = promise._c; + microtask(function(){ + var value = promise._v + , ok = promise._s == 1 + , i = 0; + var run = function(reaction){ + var handler = ok ? reaction.ok : reaction.fail + , resolve = reaction.resolve + , reject = reaction.reject + , domain = reaction.domain + , result, then; + try { + if(handler){ + if(!ok){ + if(promise._h == 2)onHandleUnhandled(promise); + promise._h = 1; + } + if(handler === true)result = value; + else { + if(domain)domain.enter(); + result = handler(value); + if(domain)domain.exit(); + } + if(result === reaction.promise){ + reject(TypeError('Promise-chain cycle')); + } else if(then = isThenable(result)){ + then.call(result, resolve, reject); + } else resolve(result); + } else reject(value); + } catch(e){ + reject(e); + } + }; + while(chain.length > i)run(chain[i++]); // variable length - can't use forEach + promise._c = []; + promise._n = false; + if(isReject && !promise._h)onUnhandled(promise); + }); +}; +var onUnhandled = function(promise){ + task.call(global, function(){ + var value = promise._v + , abrupt, handler, console; + if(isUnhandled(promise)){ + abrupt = perform(function(){ + if(isNode){ + process.emit('unhandledRejection', value, promise); + } else if(handler = global.onunhandledrejection){ + handler({promise: promise, reason: value}); + } else if((console = global.console) && console.error){ + console.error('Unhandled promise rejection', value); + } + }); + // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should + promise._h = isNode || isUnhandled(promise) ? 2 : 1; + } promise._a = undefined; + if(abrupt)throw abrupt.error; + }); +}; +var isUnhandled = function(promise){ + if(promise._h == 1)return false; + var chain = promise._a || promise._c + , i = 0 + , reaction; + while(chain.length > i){ + reaction = chain[i++]; + if(reaction.fail || !isUnhandled(reaction.promise))return false; + } return true; +}; +var onHandleUnhandled = function(promise){ + task.call(global, function(){ + var handler; + if(isNode){ + process.emit('rejectionHandled', promise); + } else if(handler = global.onrejectionhandled){ + handler({promise: promise, reason: promise._v}); + } + }); +}; +var $reject = function(value){ + var promise = this; + if(promise._d)return; + promise._d = true; + promise = promise._w || promise; // unwrap + promise._v = value; + promise._s = 2; + if(!promise._a)promise._a = promise._c.slice(); + notify(promise, true); +}; +var $resolve = function(value){ + var promise = this + , then; + if(promise._d)return; + promise._d = true; + promise = promise._w || promise; // unwrap + try { + if(promise === value)throw TypeError("Promise can't be resolved itself"); + if(then = isThenable(value)){ + microtask(function(){ + var wrapper = {_w: promise, _d: false}; // wrap + try { + then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1)); + } catch(e){ + $reject.call(wrapper, e); + } + }); + } else { + promise._v = value; + promise._s = 1; + notify(promise, false); + } + } catch(e){ + $reject.call({_w: promise, _d: false}, e); // wrap + } +}; + +// constructor polyfill +if(!USE_NATIVE){ + // 25.4.3.1 Promise(executor) + $Promise = function Promise(executor){ + anInstance(this, $Promise, PROMISE, '_h'); + aFunction(executor); + Internal.call(this); + try { + executor(ctx($resolve, this, 1), ctx($reject, this, 1)); + } catch(err){ + $reject.call(this, err); + } + }; + Internal = function Promise(executor){ + this._c = []; // <- awaiting reactions + this._a = undefined; // <- checked in isUnhandled reactions + this._s = 0; // <- state + this._d = false; // <- done + this._v = undefined; // <- value + this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled + this._n = false; // <- notify + }; + Internal.prototype = __webpack_require__(119)($Promise.prototype, { + // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected) + then: function then(onFulfilled, onRejected){ + var reaction = newPromiseCapability(speciesConstructor(this, $Promise)); + reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true; + reaction.fail = typeof onRejected == 'function' && onRejected; + reaction.domain = isNode ? process.domain : undefined; + this._c.push(reaction); + if(this._a)this._a.push(reaction); + if(this._s)notify(this, false); + return reaction.promise; + }, + // 25.4.5.1 Promise.prototype.catch(onRejected) + 'catch': function(onRejected){ + return this.then(undefined, onRejected); + } + }); + PromiseCapability = function(){ + var promise = new Internal; + this.promise = promise; + this.resolve = ctx($resolve, promise, 1); + this.reject = ctx($reject, promise, 1); + }; +} + +$export($export.G + $export.W + $export.F * !USE_NATIVE, {Promise: $Promise}); +__webpack_require__(26)($Promise, PROMISE); +__webpack_require__(120)(PROMISE); +Wrapper = __webpack_require__(1)[PROMISE]; + +// statics +$export($export.S + $export.F * !USE_NATIVE, PROMISE, { + // 25.4.4.5 Promise.reject(r) + reject: function reject(r){ + var capability = newPromiseCapability(this) + , $$reject = capability.reject; + $$reject(r); + return capability.promise; + } +}); +$export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, { + // 25.4.4.6 Promise.resolve(x) + resolve: function resolve(x){ + // instanceof instead of internal slot check because we should fix it without replacement native Promise core + if(x instanceof $Promise && sameConstructor(x.constructor, this))return x; + var capability = newPromiseCapability(this) + , $$resolve = capability.resolve; + $$resolve(x); + return capability.promise; + } +}); +$export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(108)(function(iter){ + $Promise.all(iter)['catch'](empty); +})), PROMISE, { + // 25.4.4.1 Promise.all(iterable) + all: function all(iterable){ + var C = this + , capability = newPromiseCapability(C) + , resolve = capability.resolve + , reject = capability.reject; + var abrupt = perform(function(){ + var values = [] + , index = 0 + , remaining = 1; + forOf(iterable, false, function(promise){ + var $index = index++ + , alreadyCalled = false; + values.push(undefined); + remaining++; + C.resolve(promise).then(function(value){ + if(alreadyCalled)return; + alreadyCalled = true; + values[$index] = value; + --remaining || resolve(values); + }, reject); + }); + --remaining || resolve(values); + }); + if(abrupt)reject(abrupt.error); + return capability.promise; + }, + // 25.4.4.4 Promise.race(iterable) + race: function race(iterable){ + var C = this + , capability = newPromiseCapability(C) + , reject = capability.reject; + var abrupt = perform(function(){ + forOf(iterable, false, function(promise){ + C.resolve(promise).then(capability.resolve, reject); + }); + }); + if(abrupt)reject(abrupt.error); + return capability.promise; + } +}); + +/***/ }), +/* 131 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// ECMAScript 6 symbols shim +var global = __webpack_require__(2) + , has = __webpack_require__(6) + , DESCRIPTORS = __webpack_require__(5) + , $export = __webpack_require__(12) + , redefine = __webpack_require__(59) + , META = __webpack_require__(111).KEY + , $fails = __webpack_require__(13) + , shared = __webpack_require__(40) + , setToStringTag = __webpack_require__(26) + , uid = __webpack_require__(27) + , wks = __webpack_require__(0) + , wksExt = __webpack_require__(45) + , wksDefine = __webpack_require__(44) + , keyOf = __webpack_require__(110) + , enumKeys = __webpack_require__(101) + , isArray = __webpack_require__(105) + , anObject = __webpack_require__(4) + , toIObject = __webpack_require__(9) + , toPrimitive = __webpack_require__(43) + , createDesc = __webpack_require__(25) + , _create = __webpack_require__(56) + , gOPNExt = __webpack_require__(116) + , $GOPD = __webpack_require__(115) + , $DP = __webpack_require__(8) + , $keys = __webpack_require__(15) + , gOPD = $GOPD.f + , dP = $DP.f + , gOPN = gOPNExt.f + , $Symbol = global.Symbol + , $JSON = global.JSON + , _stringify = $JSON && $JSON.stringify + , PROTOTYPE = 'prototype' + , HIDDEN = wks('_hidden') + , TO_PRIMITIVE = wks('toPrimitive') + , isEnum = {}.propertyIsEnumerable + , SymbolRegistry = shared('symbol-registry') + , AllSymbols = shared('symbols') + , OPSymbols = shared('op-symbols') + , ObjectProto = Object[PROTOTYPE] + , USE_NATIVE = typeof $Symbol == 'function' + , QObject = global.QObject; +// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173 +var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild; + +// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 +var setSymbolDesc = DESCRIPTORS && $fails(function(){ + return _create(dP({}, 'a', { + get: function(){ return dP(this, 'a', {value: 7}).a; } + })).a != 7; +}) ? function(it, key, D){ + var protoDesc = gOPD(ObjectProto, key); + if(protoDesc)delete ObjectProto[key]; + dP(it, key, D); + if(protoDesc && it !== ObjectProto)dP(ObjectProto, key, protoDesc); +} : dP; + +var wrap = function(tag){ + var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]); + sym._k = tag; + return sym; +}; + +var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function(it){ + return typeof it == 'symbol'; +} : function(it){ + return it instanceof $Symbol; +}; + +var $defineProperty = function defineProperty(it, key, D){ + if(it === ObjectProto)$defineProperty(OPSymbols, key, D); + anObject(it); + key = toPrimitive(key, true); + anObject(D); + if(has(AllSymbols, key)){ + if(!D.enumerable){ + if(!has(it, HIDDEN))dP(it, HIDDEN, createDesc(1, {})); + it[HIDDEN][key] = true; + } else { + if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false; + D = _create(D, {enumerable: createDesc(0, false)}); + } return setSymbolDesc(it, key, D); + } return dP(it, key, D); +}; +var $defineProperties = function defineProperties(it, P){ + anObject(it); + var keys = enumKeys(P = toIObject(P)) + , i = 0 + , l = keys.length + , key; + while(l > i)$defineProperty(it, key = keys[i++], P[key]); + return it; +}; +var $create = function create(it, P){ + return P === undefined ? _create(it) : $defineProperties(_create(it), P); +}; +var $propertyIsEnumerable = function propertyIsEnumerable(key){ + var E = isEnum.call(this, key = toPrimitive(key, true)); + if(this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return false; + return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true; +}; +var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key){ + it = toIObject(it); + key = toPrimitive(key, true); + if(it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return; + var D = gOPD(it, key); + if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true; + return D; +}; +var $getOwnPropertyNames = function getOwnPropertyNames(it){ + var names = gOPN(toIObject(it)) + , result = [] + , i = 0 + , key; + while(names.length > i){ + if(!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META)result.push(key); + } return result; +}; +var $getOwnPropertySymbols = function getOwnPropertySymbols(it){ + var IS_OP = it === ObjectProto + , names = gOPN(IS_OP ? OPSymbols : toIObject(it)) + , result = [] + , i = 0 + , key; + while(names.length > i){ + if(has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true))result.push(AllSymbols[key]); + } return result; +}; + +// 19.4.1.1 Symbol([description]) +if(!USE_NATIVE){ + $Symbol = function Symbol(){ + if(this instanceof $Symbol)throw TypeError('Symbol is not a constructor!'); + var tag = uid(arguments.length > 0 ? arguments[0] : undefined); + var $set = function(value){ + if(this === ObjectProto)$set.call(OPSymbols, value); + if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false; + setSymbolDesc(this, tag, createDesc(1, value)); + }; + if(DESCRIPTORS && setter)setSymbolDesc(ObjectProto, tag, {configurable: true, set: $set}); + return wrap(tag); + }; + redefine($Symbol[PROTOTYPE], 'toString', function toString(){ + return this._k; + }); + + $GOPD.f = $getOwnPropertyDescriptor; + $DP.f = $defineProperty; + __webpack_require__(57).f = gOPNExt.f = $getOwnPropertyNames; + __webpack_require__(24).f = $propertyIsEnumerable; + __webpack_require__(38).f = $getOwnPropertySymbols; + + if(DESCRIPTORS && !__webpack_require__(23)){ + redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true); + } + + wksExt.f = function(name){ + return wrap(wks(name)); + } +} + +$export($export.G + $export.W + $export.F * !USE_NATIVE, {Symbol: $Symbol}); + +for(var symbols = ( + // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14 + 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables' +).split(','), i = 0; symbols.length > i; )wks(symbols[i++]); + +for(var symbols = $keys(wks.store), i = 0; symbols.length > i; )wksDefine(symbols[i++]); + +$export($export.S + $export.F * !USE_NATIVE, 'Symbol', { + // 19.4.2.1 Symbol.for(key) + 'for': function(key){ + return has(SymbolRegistry, key += '') + ? SymbolRegistry[key] + : SymbolRegistry[key] = $Symbol(key); + }, + // 19.4.2.5 Symbol.keyFor(sym) + keyFor: function keyFor(key){ + if(isSymbol(key))return keyOf(SymbolRegistry, key); + throw TypeError(key + ' is not a symbol!'); + }, + useSetter: function(){ setter = true; }, + useSimple: function(){ setter = false; } +}); + +$export($export.S + $export.F * !USE_NATIVE, 'Object', { + // 19.1.2.2 Object.create(O [, Properties]) + create: $create, + // 19.1.2.4 Object.defineProperty(O, P, Attributes) + defineProperty: $defineProperty, + // 19.1.2.3 Object.defineProperties(O, Properties) + defineProperties: $defineProperties, + // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) + getOwnPropertyDescriptor: $getOwnPropertyDescriptor, + // 19.1.2.7 Object.getOwnPropertyNames(O) + getOwnPropertyNames: $getOwnPropertyNames, + // 19.1.2.8 Object.getOwnPropertySymbols(O) + getOwnPropertySymbols: $getOwnPropertySymbols +}); + +// 24.3.2 JSON.stringify(value [, replacer [, space]]) +$JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function(){ + var S = $Symbol(); + // MS Edge converts symbol values to JSON as {} + // WebKit converts symbol values to JSON as null + // V8 throws on boxed symbols + return _stringify([S]) != '[null]' || _stringify({a: S}) != '{}' || _stringify(Object(S)) != '{}'; +})), 'JSON', { + stringify: function stringify(it){ + if(it === undefined || isSymbol(it))return; // IE8 returns string on undefined + var args = [it] + , i = 1 + , replacer, $replacer; + while(arguments.length > i)args.push(arguments[i++]); + replacer = args[1]; + if(typeof replacer == 'function')$replacer = replacer; + if($replacer || !isArray(replacer))replacer = function(key, value){ + if($replacer)value = $replacer.call(this, key, value); + if(!isSymbol(value))return value; + }; + args[1] = replacer; + return _stringify.apply($JSON, args); + } +}); + +// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint) +$Symbol[PROTOTYPE][TO_PRIMITIVE] || __webpack_require__(7)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf); +// 19.4.3.5 Symbol.prototype[@@toStringTag] +setToStringTag($Symbol, 'Symbol'); +// 20.2.1.9 Math[@@toStringTag] +setToStringTag(Math, 'Math', true); +// 24.3.3 JSON[@@toStringTag] +setToStringTag(global.JSON, 'JSON', true); + +/***/ }), +/* 132 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(44)('asyncIterator'); + +/***/ }), +/* 133 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(44)('observable'); + +/***/ }), +/* 134 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(Buffer, process, setImmediate) {// Generated by CoffeeScript 2.3.1 +// # CSV Parser + +// This module provides a CSV parser tested and used against large datasets. Over +// the year, it has been enhance and is now full of useful options. + +// Please look at the [README], the [project website][site] the [samples] and the +// [tests] for additional information. +var Parser, StringDecoder, isObjLiteral, stream, util; + +stream = __webpack_require__(145); + +util = __webpack_require__(150); + +StringDecoder = __webpack_require__(47).StringDecoder; + +// ## Usage + +// Callback approach, for ease of use: + +// `parse(data, [options], callback)` + +// [Node.js Stream API][stream], for maximum of power: + +// `parse([options], [callback])` +module.exports = function() { + var callback, called, chunks, data, err, options, parser; + if (arguments.length === 3) { + data = arguments[0]; + options = arguments[1]; + callback = arguments[2]; + if (typeof callback !== 'function') { + throw Error(`Invalid callback argument: ${JSON.stringify(callback)}`); + } + if (!(typeof data === 'string' || Buffer.isBuffer(arguments[0]))) { + return callback(Error(`Invalid data argument: ${JSON.stringify(data)}`)); + } + } else if (arguments.length === 2) { + // 1st arg is data:string or options:object + if (typeof arguments[0] === 'string' || Buffer.isBuffer(arguments[0])) { + data = arguments[0]; + } else if (isObjLiteral(arguments[0])) { + options = arguments[0]; + } else { + err = `Invalid first argument: ${JSON.stringify(arguments[0])}`; + } + // 2nd arg is options:object or callback:function + if (typeof arguments[1] === 'function') { + callback = arguments[1]; + } else if (isObjLiteral(arguments[1])) { + if (options) { + err = 'Invalid arguments: got options twice as first and second arguments'; + } else { + options = arguments[1]; + } + } else { + err = `Invalid first argument: ${JSON.stringify(arguments[1])}`; + } + if (err) { + if (!callback) { + throw Error(err); + } else { + return callback(Error(err)); + } + } + } else if (arguments.length === 1) { + if (typeof arguments[0] === 'function') { + callback = arguments[0]; + } else { + options = arguments[0]; + } + } + if (options == null) { + options = {}; + } + parser = new Parser(options); + if (data != null) { + process.nextTick(function() { + parser.write(data); + return parser.end(); + }); + } + if (callback) { + called = false; + chunks = options.objname ? {} : []; + parser.on('readable', function() { + var chunk, results; + results = []; + while (chunk = parser.read()) { + if (options.objname) { + results.push(chunks[chunk[0]] = chunk[1]); + } else { + results.push(chunks.push(chunk)); + } + } + return results; + }); + parser.on('error', function(err) { + called = true; + return callback(err); + }); + parser.on('end', function() { + if (!called) { + return callback(null, chunks); + } + }); + } + return parser; +}; + +// ## `Parser([options])` + +// Options are documented [here](http://csv.adaltas.com/parse/). +Parser = function(options = {}) { + var base, base1, base10, base11, base12, base13, base14, base15, base16, base17, base2, base3, base4, base5, base6, base7, base8, base9, k, v; + // @options = options + this.options = {}; + for (k in options) { + v = options[k]; + this.options[k] = v; + } + this.options.objectMode = true; + stream.Transform.call(this, this.options); + if ((base = this.options).rowDelimiter == null) { + base.rowDelimiter = null; + } + if (typeof this.options.rowDelimiter === 'string') { + this.options.rowDelimiter = [this.options.rowDelimiter]; + } + if ((base1 = this.options).delimiter == null) { + base1.delimiter = ','; + } + if (this.options.quote !== void 0 && !this.options.quote) { + this.options.quote = ''; + } + if ((base2 = this.options).quote == null) { + base2.quote = '"'; + } + if ((base3 = this.options).escape == null) { + base3.escape = '"'; + } + if ((base4 = this.options).columns == null) { + base4.columns = null; + } + if ((base5 = this.options).comment == null) { + base5.comment = ''; + } + if ((base6 = this.options).objname == null) { + base6.objname = false; + } + if ((base7 = this.options).trim == null) { + base7.trim = false; + } + if ((base8 = this.options).ltrim == null) { + base8.ltrim = false; + } + if ((base9 = this.options).rtrim == null) { + base9.rtrim = false; + } + if (this.options.auto_parse != null) { + this.options.cast = this.options.auto_parse; + } + if ((base10 = this.options).cast == null) { + base10.cast = false; + } + if (this.options.auto_parse_date != null) { + this.options.cast_date = this.options.auto_parse_date; + } + if ((base11 = this.options).cast_date == null) { + base11.cast_date = false; + } + if (this.options.cast_date === true) { + this.options.cast_date = function(value) { + var m; + m = Date.parse(value); + if (!isNaN(m)) { + value = new Date(m); + } + return value; + }; + } + if ((base12 = this.options).relax == null) { + base12.relax = false; + } + if ((base13 = this.options).relax_column_count == null) { + base13.relax_column_count = false; + } + if ((base14 = this.options).skip_empty_lines == null) { + base14.skip_empty_lines = false; + } + if ((base15 = this.options).max_limit_on_data_read == null) { + base15.max_limit_on_data_read = 128000; + } + if ((base16 = this.options).skip_lines_with_empty_values == null) { + base16.skip_lines_with_empty_values = false; + } + if ((base17 = this.options).skip_lines_with_error == null) { + base17.skip_lines_with_error = false; + } + // Counters + // lines = count + skipped_line_count + empty_line_count + this.lines = 0; // Number of lines encountered in the source dataset + this.count = 0; // Number of records being processed + this.skipped_line_count = 0; // Number of records skipped due to errors + this.empty_line_count = 0; // Number of empty lines + // Constants + this.is_int = /^(\-|\+)?([1-9]+[0-9]*)$/; + // @is_float = /^(\-|\+)?([0-9]+(\.[0-9]+)([eE][0-9]+)?|Infinity)$/ + // @is_float = /^(\-|\+)?((([0-9])|([1-9]+[0-9]*))(\.[0-9]+)([eE][0-9]+)?|Infinity)$/ + this.is_float = function(value) { + return (value - parseFloat(value) + 1) >= 0; // Borrowed from jquery + }; + // Internal state + this._ = { + decoder: new StringDecoder(), + quoting: false, + commenting: false, + field: null, + nextChar: null, + closingQuote: 0, + line: [], + chunks: [], + rawBuf: '', + buf: '', + rowDelimiterLength: this.options.rowDelimiter ? Math.max(...this.options.rowDelimiter.map(function(v) { + return v.length; + })) : void 0, + lineHasError: false, + isEnded: false + }; + return this; +}; + +// ## Internal API + +// The Parser implement a [`stream.Transform` class][transform]. + +// ### Events + +// The library extends Node [EventEmitter][event] class and emit all +// the events of the Writable and Readable [Stream API][stream]. +util.inherits(Parser, stream.Transform); + +// For extra flexibility, you can get access to the original Parser +// class: `require('csv-parse').Parser`. +module.exports.Parser = Parser; + +// ### `_transform(chunk, encoding, callback)` + +// * `chunk` Buffer | String +// The chunk to be transformed. Will always be a buffer unless the decodeStrings option was set to false. +// * `encoding` String +// If the chunk is a string, then this is the encoding type. (Ignore if decodeStrings chunk is a buffer.) +// * `callback` Function +// Call this function (optionally with an error argument) when you are done processing the supplied chunk. + +// Implementation of the [`stream.Transform` API][transform] +Parser.prototype._transform = function(chunk, encoding, callback) { + return setImmediate(() => { + var err; + if (chunk instanceof Buffer) { + chunk = this._.decoder.write(chunk); + } + err = this.__write(chunk, false); + if (err) { + return this.emit('error', err); + } + return callback(); + }); +}; + +Parser.prototype._flush = function(callback) { + return callback(this.__flush()); +}; + +Parser.prototype.__flush = function() { + var err; + err = this.__write(this._.decoder.end(), true); + if (err) { + return err; + } + if (this._.quoting) { + err = this.error(`Quoted field not terminated at line ${this.lines + 1}`); + return err; + } + if (this._.line.length > 0) { + return this.__push(this._.line); + } +}; + +Parser.prototype.__push = function(line) { + var call_column_udf, columns, err, field, i, j, len, lineAsColumns, record; + if (this._.isEnded) { + return; + } + if (this.options.skip_lines_with_empty_values && line.join('').trim() === '') { + return; + } + record = null; + if (this.options.columns === true) { + this.options.columns = line; + return; + } else if (typeof this.options.columns === 'function') { + call_column_udf = function(fn, line) { + var columns, err; + try { + columns = fn.call(null, line); + return [null, columns]; + } catch (error) { + err = error; + return [err]; + } + }; + [err, columns] = call_column_udf(this.options.columns, line); + if (err) { + return err; + } + this.options.columns = columns; + return; + } + if (!this._.line_length && line.length > 0) { + this._.line_length = this.options.columns ? this.options.columns.length : line.length; + } + // Dont check column count on empty lines + if (line.length === 1 && line[0] === '') { + this.empty_line_count++; + } else if (line.length !== this._.line_length) { + // Dont check column count with relax_column_count + if (this.options.relax_column_count) { + this.count++; + this.skipped_line_count++; + } else if (this.options.columns != null) { + // Suggest: Inconsistent header and column numbers: header is 1 and number of columns is 1 on line 1 + err = this.error(`Number of columns on line ${this.lines} does not match header`); + return err; + } else { + err = this.error(`Number of columns is inconsistent on line ${this.lines}`); + return err; + } + } else { + this.count++; + } + if (this.options.columns != null) { + lineAsColumns = {}; + for (i = j = 0, len = line.length; j < len; i = ++j) { + field = line[i]; + if (this.options.columns[i] === false) { + continue; + } + lineAsColumns[this.options.columns[i]] = field; + } + if (this.options.objname) { + record = [lineAsColumns[this.options.objname], lineAsColumns]; + } else { + record = lineAsColumns; + } + } else { + record = line; + } + if (this.count < this.options.from) { + return; + } + if (this.options.raw) { + this.push({ + raw: this._.rawBuf, + row: record + }); + this._.rawBuf = ''; + } else { + this.push(record); + } + if (this.listenerCount('record')) { + this.emit('record', record); + } + // When to is reached set ignore any future calls + if (this.count >= this.options.to) { + this._.isEnded = true; + return this.push(null); + } + return null; +}; + +Parser.prototype.__write = function(chars, end) { + var areNextCharsDelimiter, areNextCharsRowDelimiters, cast, char, err, escapeIsQuote, i, isDelimiter, isEscape, isNextCharAComment, isNextCharTrimable, isQuote, isRowDelimiter, isRowDelimiterLength, is_float, is_int, l, ltrim, nextCharPos, ref, ref1, ref2, ref3, ref4, ref5, ref6, remainingBuffer, rowDelimiter, rtrim, wasCommenting; + is_int = (value) => { + if (typeof this.is_int === 'function') { + return this.is_int(value); + } else { + return this.is_int.test(value); + } + }; + is_float = (value) => { + if (typeof this.is_float === 'function') { + return this.is_float(value); + } else { + return this.is_float.test(value); + } + }; + cast = (value, context = {}) => { + if (!this.options.cast) { + return value; + } + if (context.quoting == null) { + context.quoting = !!this._.closingQuote; + } + if (context.lines == null) { + context.lines = this.lines; + } + if (context.count == null) { + context.count = this.count; + } + if (context.index == null) { + context.index = this._.line.length; + } + // context.header ?= if @options.column and @lines is 1 and @count is 0 then true else false + if (context.header == null) { + context.header = this.options.columns === true; + } + if (context.column == null) { + context.column = Array.isArray(this.options.columns) ? this.options.columns[context.index] : context.index; + } + if (typeof this.options.cast === 'function') { + return this.options.cast(value, context); + } + if (is_int(value)) { + value = parseInt(value); + } else if (is_float(value)) { + value = parseFloat(value); + } else if (this.options.cast_date) { + value = this.options.cast_date(value, context); + } + return value; + }; + ltrim = this.options.trim || this.options.ltrim; + rtrim = this.options.trim || this.options.rtrim; + chars = this._.buf + chars; + l = chars.length; + i = 0; + if (this.lines === 0 && 0xFEFF === chars.charCodeAt(0)) { + // Strip BOM header + i++; + } + while (i < l) { + // Ensure we get enough space to look ahead + if (!end) { + remainingBuffer = chars.substr(i, l - i); + // (i+1000 >= l) or + // Skip if the remaining buffer can be comment + // Skip if the remaining buffer can be row delimiter + if ((!this.options.rowDelimiter && i + 3 > l) || (!this._.commenting && l - i < this.options.comment.length && this.options.comment.substr(0, l - i) === remainingBuffer) || (this.options.rowDelimiter && l - i < this._.rowDelimiterLength && this.options.rowDelimiter.some(function(rd) { + return rd.substr(0, l - i) === remainingBuffer; + // Skip if the remaining buffer can be row delimiter following the closing quote + })) || (this.options.rowDelimiter && this._.quoting && l - i < (this.options.quote.length + this._.rowDelimiterLength) && this.options.rowDelimiter.some((rd) => { + return (this.options.quote + rd).substr(0, l - i) === remainingBuffer; + // Skip if the remaining buffer can be delimiter + // Skip if the remaining buffer can be escape sequence + })) || (l - i <= this.options.delimiter.length && this.options.delimiter.substr(0, l - i) === remainingBuffer) || (l - i <= this.options.escape.length && this.options.escape.substr(0, l - i) === remainingBuffer)) { + break; + } + } + char = this._.nextChar ? this._.nextChar : chars.charAt(i); + this._.nextChar = l > i + 1 ? chars.charAt(i + 1) : null; + if (this.options.raw) { + this._.rawBuf += char; + } + // Auto discovery of rowDelimiter, unix, mac and windows supported + if (this.options.rowDelimiter == null) { + nextCharPos = i; + rowDelimiter = null; + // First empty line + if (!this._.quoting && (char === '\n' || char === '\r')) { + rowDelimiter = char; + nextCharPos += 1; + } else if (this._.quoting && char === this.options.quote && ((ref = this._.nextChar) === '\n' || ref === '\r')) { + rowDelimiter = this._.nextChar; + nextCharPos += 2; + } + if (rowDelimiter) { + if (rowDelimiter === '\r' && chars.charAt(nextCharPos) === '\n') { + rowDelimiter += '\n'; + } + this.options.rowDelimiter = [rowDelimiter]; + this._.rowDelimiterLength = rowDelimiter.length; + } + } + // Parse that damn char + // Note, shouldn't we have sth like chars.substr(i, @options.escape.length) + if (!this._.commenting && char === this.options.escape) { + // Make sure the escape is really here for escaping: + // If escape is same as quote, and escape is first char of a field + // and it's not quoted, then it is a quote + // Next char should be an escape or a quote + escapeIsQuote = this.options.escape === this.options.quote; + isEscape = this._.nextChar === this.options.escape; + isQuote = this._.nextChar === this.options.quote; + if (!(escapeIsQuote && !this._.field && !this._.quoting) && (isEscape || isQuote)) { + i++; + char = this._.nextChar; + this._.nextChar = chars.charAt(i + 1); + if (this._.field == null) { + this._.field = ''; + } + this._.field += char; + // Since we're skipping the next one, better add it now if in raw mode. + if (this.options.raw) { + this._.rawBuf += char; + } + i++; + continue; + } + } + // Char match quote + if (!this._.commenting && char === this.options.quote) { + if (this._.acceptOnlyEmptyChars && (char !== ' ' && char !== '\t')) { + return this.error('Only trimable characters are accepted after quotes'); + } + if (this._.quoting) { + // Make sure a closing quote is followed by a delimiter + // If we have a next character and + // it isnt a rowDelimiter and + // it isnt an column delimiter and + // it isnt the begining of a comment + // Otherwise, if this is not "relax" mode, throw an error + isNextCharTrimable = rtrim && ((ref1 = this._.nextChar) === ' ' || ref1 === '\t'); + areNextCharsRowDelimiters = this.options.rowDelimiter && this.options.rowDelimiter.some(function(rd) { + return chars.substr(i + 1, rd.length) === rd; + }); + areNextCharsDelimiter = chars.substr(i + 1, this.options.delimiter.length) === this.options.delimiter; + isNextCharAComment = this._.nextChar === this.options.comment; + if ((this._.nextChar != null) && !isNextCharTrimable && !areNextCharsRowDelimiters && !areNextCharsDelimiter && !isNextCharAComment) { + if (this.options.relax) { + this._.quoting = false; + if (this._.field) { + this._.field = `${this.options.quote}${this._.field}`; + } + } else { + if (err = this.error(`Invalid closing quote at line ${this.lines + 1}; found ${JSON.stringify(this._.nextChar)} instead of delimiter ${JSON.stringify(this.options.delimiter)}`)) { + return err; + } + } + } else if ((this._.nextChar != null) && isNextCharTrimable) { + i++; + this._.quoting = false; + this._.closingQuote = this.options.quote.length; + this._.acceptOnlyEmptyChars = true; + continue; + } else { + i++; + this._.quoting = false; + this._.closingQuote = this.options.quote.length; + if (end && i === l) { + this._.line.push(cast(this._.field || '')); + this._.field = null; + } + continue; + } + } else if (!this._.field) { + this._.quoting = true; + i++; + continue; + } else if ((this._.field != null) && !this.options.relax) { + if (err = this.error(`Invalid opening quote at line ${this.lines + 1}`)) { + return err; + } + } + } + // Otherwise, treat quote as a regular character + isRowDelimiter = this.options.rowDelimiter && this.options.rowDelimiter.some(function(rd) { + return chars.substr(i, rd.length) === rd; + }); + if (isRowDelimiter || (end && i === l - 1)) { + this.lines++; + } + // Set the commenting flag + wasCommenting = false; + if (!this._.commenting && !this._.quoting && this.options.comment && chars.substr(i, this.options.comment.length) === this.options.comment) { + this._.commenting = true; + } else if (this._.commenting && isRowDelimiter) { + wasCommenting = true; + this._.commenting = false; + } + isDelimiter = chars.substr(i, this.options.delimiter.length) === this.options.delimiter; + if (this._.acceptOnlyEmptyChars) { + if (isDelimiter || isRowDelimiter) { + this._.acceptOnlyEmptyChars = false; + } else { + if (char === ' ' || char === '\t') { + i++; + continue; + } else { + return this.error('Only trimable characters are accepted after quotes'); + } + } + } + if (!this._.commenting && !this._.quoting && (isDelimiter || isRowDelimiter)) { + if (isRowDelimiter) { + isRowDelimiterLength = this.options.rowDelimiter.filter(function(rd) { + return chars.substr(i, rd.length) === rd; + })[0].length; + } + // Empty lines + if (isRowDelimiter && this._.line.length === 0 && (this._.field == null)) { + if (wasCommenting || this.options.skip_empty_lines) { + i += isRowDelimiterLength; + this._.nextChar = chars.charAt(i); + continue; + } + } + if (rtrim) { + if (!this._.closingQuote) { + this._.field = (ref2 = this._.field) != null ? ref2.trimRight() : void 0; + } + } + this._.line.push(cast(this._.field || '')); + this._.closingQuote = 0; + this._.field = null; + if (isDelimiter) { // End of field + i += this.options.delimiter.length; + this._.nextChar = chars.charAt(i); + if (end && !this._.nextChar) { + isRowDelimiter = true; + this._.line.push(''); + } + } + if (isRowDelimiter) { // End of record + if (!this._.lineHasError) { + err = this.__push(this._.line); + if (err) { + return err; + } + } + if (this._.lineHasError) { + this._.lineHasError = false; + } + // Some cleanup for the next record + this._.line = []; + i += isRowDelimiterLength; + this._.nextChar = chars.charAt(i); + continue; + } + } else if (!this._.commenting && !this._.quoting && (char === ' ' || char === '\t')) { + if (this._.field == null) { + // Left trim unless we are quoting or field already filled + this._.field = ''; + } + if (!(ltrim && !this._.field)) { + this._.field += char; + } + i++; + } else if (!this._.commenting) { + if (this._.field == null) { + this._.field = ''; + } + this._.field += char; + i++; + } else { + i++; + } + if (!this._.commenting && ((ref3 = this._.field) != null ? ref3.length : void 0) > this.options.max_limit_on_data_read) { + return Error(`Field exceeds max_limit_on_data_read setting (${this.options.max_limit_on_data_read}) ${JSON.stringify(this.options.delimiter)}`); + } + if (!this._.commenting && ((ref4 = this._.line) != null ? ref4.length : void 0) > this.options.max_limit_on_data_read) { + return Error(`Row delimiter not found in the file ${JSON.stringify(this.options.rowDelimiter)}`); + } + } + // Flush remaining fields and lines + if (end) { + if (l === 0) { + this.lines++; + } + if (this._.field != null) { + if (rtrim) { + if (!this._.closingQuote) { + this._.field = (ref5 = this._.field) != null ? ref5.trimRight() : void 0; + } + } + this._.line.push(cast(this._.field || '')); + this._.field = null; + } + if (((ref6 = this._.field) != null ? ref6.length : void 0) > this.options.max_limit_on_data_read) { + return Error(`Delimiter not found in the file ${JSON.stringify(this.options.delimiter)}`); + } + if (this._.line.length > this.options.max_limit_on_data_read) { + return Error(`Row delimiter not found in the file ${JSON.stringify(this.options.rowDelimiter)}`); + } + } + // Store un-parsed chars for next call + this._.buf = chars.substr(i); + return null; +}; + +Parser.prototype.error = function(msg) { + var err; + err = Error(msg); + if (!this.options.skip_lines_with_error) { + return err; + } else { + if (!this._.lineHasError) { + this._.lineHasError = true; + this.emit('skip', err); + } + } + return null; +}; + +// ## Utils +isObjLiteral = function(_obj) { + var _test; + _test = _obj; + if (typeof _obj !== 'object' || _obj === null || Array.isArray(_obj)) { + return false; + } else { + return (function() { + while (!false) { + if (Object.getPrototypeOf(_test = Object.getPrototypeOf(_test)) === null) { + break; + } + } + return Object.getPrototypeOf(_obj === _test); + })(); + } +}; + +// [readme]: https://github.com/wdavidw/node-csv-parse +// [site]: http://csv.adaltas.com/parse/ +// [samples]: https://github.com/wdavidw/node-csv-parse/tree/master/samples +// [tests]: https://github.com/wdavidw/node-csv-parse/tree/master/test +// [stream]: (http://nodejs.org/api/stream.html +// [transform]: (http://nodejs.org/api/stream.html#stream_class_stream_transform_1) + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer, __webpack_require__(10), __webpack_require__(68).setImmediate)) + +/***/ }), +/* 135 */ +/***/ (function(module, exports) { + +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} + +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } + + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 +} + + +/***/ }), +/* 136 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(Buffer, process) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Writer = exports.VexFlow = exports.Utils = exports.Track = exports.ProgramChangeEvent = exports.NoteOnEvent = exports.NoteOffEvent = exports.NoteEvent = exports.MetaEvent = exports.ControllerChangeEvent = exports.Constants = exports.Chunk = undefined; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _tonalMidi = __webpack_require__(146); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * Object representation of the chunk section of a MIDI file. + * @param {object} fields - {type: number, data: array, size: array} + * @return {Chunk} + */ +var Chunk = function Chunk(fields) { + _classCallCheck(this, Chunk); + + this.type = fields.type; + this.data = fields.data; + this.size = [0, 0, 0, fields.data.length]; +}; + +exports.Chunk = Chunk; +/** + * MIDI file format constants, including note -> MIDI number translation. + * @return {Constants} + */ + +var Constants = { + VERSION: '1.5.2', + HEADER_CHUNK_TYPE: [0x4d, 0x54, 0x68, 0x64], // Mthd + HEADER_CHUNK_LENGTH: [0x00, 0x00, 0x00, 0x06], // Header size for SMF + HEADER_CHUNK_FORMAT0: [0x00, 0x00], // Midi Type 0 id + HEADER_CHUNK_FORMAT1: [0x00, 0x01], // Midi Type 1 id + HEADER_CHUNK_DIVISION: [0x00, 0x80], // Defaults to 128 ticks per beat + TRACK_CHUNK_TYPE: [0x4d, 0x54, 0x72, 0x6b], // MTrk, + META_EVENT_ID: 0xFF, + META_TEXT_ID: 0x01, + META_COPYRIGHT_ID: 0x02, + META_TRACK_NAME_ID: 0x03, + META_INSTRUMENT_NAME_ID: 0x04, + META_LYRIC_ID: 0x05, + META_MARKER_ID: 0x06, + META_CUE_POINT: 0x07, + META_TEMPO_ID: 0x51, + META_SMTPE_OFFSET: 0x54, + META_TIME_SIGNATURE_ID: 0x58, + META_KEY_SIGNATURE_ID: 0x59, + META_END_OF_TRACK_ID: [0x2F, 0x00], + CONTROLLER_CHANGE_STATUS: 0xB0, // includes channel number (0) + PROGRAM_CHANGE_STATUS: 0xC0 // includes channel number (0) +}; + +exports.Constants = Constants; +/** + * Holds all data for a "controller change" MIDI event + * @param {object} fields {controllerNumber: integer, controllerValue: integer} + * @return {ControllerChangeEvent} + */ + +var ControllerChangeEvent = function ControllerChangeEvent(fields) { + _classCallCheck(this, ControllerChangeEvent); + + this.type = 'controller'; + // delta time defaults to 0. + this.data = Utils.numberToVariableLength(0x00).concat(Constants.CONTROLLER_CHANGE_STATUS, fields.controllerNumber, fields.controllerValue); +}; + +exports.ControllerChangeEvent = ControllerChangeEvent; +/** + * Object representation of a meta event. + * @param {object} fields - type, data + * @return {MetaEvent} + */ + +var MetaEvent = function MetaEvent(fields) { + _classCallCheck(this, MetaEvent); + + this.type = 'meta'; + this.data = Utils.numberToVariableLength(0x00); // Start with zero time delta + this.data = this.data.concat(Constants.META_EVENT_ID, fields.data); +}; + +exports.MetaEvent = MetaEvent; +/** + * Wrapper for noteOnEvent/noteOffEvent objects that builds both events. + * @param {object} fields - {pitch: '[C4]', duration: '4', wait: '4', velocity: 1-100} + * @return {NoteEvent} + */ + +var NoteEvent = function () { + function NoteEvent(fields) { + _classCallCheck(this, NoteEvent); + + this.type = 'note'; + this.pitch = Utils.toArray(fields.pitch); + this.wait = fields.wait || 0; + this.duration = fields.duration; + this.sequential = fields.sequential || false; + this.velocity = fields.velocity || 50; + this.channel = fields.channel || 1; + this.repeat = fields.repeat || 1; + this.velocity = this.convertVelocity(this.velocity); + this.grace = fields.grace; + this.buildData(); + } + + /** + * Builds int array for this event. + * @return {NoteEvent} + */ + + + _createClass(NoteEvent, [{ + key: 'buildData', + value: function buildData() { + this.data = []; + + var tickDuration = this.getTickDuration(this.duration, 'note'); + var restDuration = this.getTickDuration(this.wait, 'rest'); + + // Apply grace note(s) and subtract ticks (currently 1 tick per grace note) from tickDuration so net value is the same + if (this.grace) { + var graceDuration = 1; + this.grace = Utils.toArray(this.grace); + this.grace.forEach(function (pitch) { + var noteEvent = new NoteEvent({ pitch: this.grace, duration: 'T' + graceDuration }); + this.data = this.data.concat(noteEvent.data); + + tickDuration -= graceDuration; + }, this); + } + + // fields.pitch could be an array of pitches. + // If so create note events for each and apply the same duration. + var noteOn, noteOff; + if (Array.isArray(this.pitch)) { + // By default this is a chord if it's an array of notes that requires one NoteOnEvent. + // If this.sequential === true then it's a sequential string of notes that requires separate NoteOnEvents. + if (!this.sequential) { + // Handle repeat + for (var j = 0; j < this.repeat; j++) { + // Note on + this.pitch.forEach(function (p, i) { + if (i == 0) { + noteOn = new NoteOnEvent({ data: Utils.numberToVariableLength(restDuration).concat(this.getNoteOnStatus(), Utils.getPitch(p), this.velocity) }); + } else { + // Running status (can ommit the note on status) + noteOn = new NoteOnEvent({ data: [0, Utils.getPitch(p), this.velocity] }); + } + + this.data = this.data.concat(noteOn.data); + }, this); + + // Note off + this.pitch.forEach(function (p, i) { + if (i == 0) { + noteOff = new NoteOffEvent({ data: Utils.numberToVariableLength(tickDuration).concat(this.getNoteOffStatus(), Utils.getPitch(p), this.velocity) }); + } else { + // Running status (can ommit the note off status) + noteOff = new NoteOffEvent({ data: [0, Utils.getPitch(p), this.velocity] }); + } + + this.data = this.data.concat(noteOff.data); + }, this); + } + } else { + // Handle repeat + for (var j = 0; j < this.repeat; j++) { + this.pitch.forEach(function (p, i) { + // restDuration only applies to first note + if (i > 0) { + restDuration = 0; + } + + // If duration is 8th triplets we need to make sure that the total ticks == quarter note. + // So, the last one will need to be the remainder + if (this.duration === '8t' && i == this.pitch.length - 1) { + var quarterTicks = Utils.numberFromBytes(Constants.HEADER_CHUNK_DIVISION); + tickDuration = quarterTicks - tickDuration * 2; + } + + noteOn = new NoteOnEvent({ data: Utils.numberToVariableLength(restDuration).concat([this.getNoteOnStatus(), Utils.getPitch(p), this.velocity]) }); + noteOff = new NoteOffEvent({ data: Utils.numberToVariableLength(tickDuration).concat([this.getNoteOffStatus(), Utils.getPitch(p), this.velocity]) }); + + this.data = this.data.concat(noteOn.data, noteOff.data); + }, this); + } + } + + return this; + } + + throw 'pitch must be an array.'; + } + }, { + key: 'convertVelocity', + + + /** + * Converts velocity to value 0-127 + * @param {number} velocity - Velocity value 1-100 + * @return {number} + */ + value: function convertVelocity(velocity) { + // Max passed value limited to 100 + velocity = velocity > 100 ? 100 : velocity; + return Math.round(velocity / 100 * 127); + } + }, { + key: 'getTickDuration', + + + /** + * Gets the total number of ticks based on passed duration. + * Note: type=='note' defaults to quarter note, type==='rest' defaults to 0 + * @param {(string|array)} duration + * @param {string} type ['note', 'rest'] + * @return {number} + */ + value: function getTickDuration(duration, type) { + if (Array.isArray(duration)) { + // Recursively execute this method for each item in the array and return the sum of tick durations. + return duration.map(function (value) { + return this.getTickDuration(value, type); + }, this).reduce(function (a, b) { + return a + b; + }, 0); + } + + duration = duration.toString(); + + if (duration.toLowerCase().charAt(0) === 't') { + // If duration starts with 't' then the number that follows is an explicit tick count + return parseInt(duration.substring(1)); + } + + // Need to apply duration here. Quarter note == Constants.HEADER_CHUNK_DIVISION + // Rounding only applies to triplets, which the remainder is handled below + var quarterTicks = Utils.numberFromBytes(Constants.HEADER_CHUNK_DIVISION); + return Math.round(quarterTicks * this.getDurationMultiplier(duration, type)); + } + + /** + * Gets what to multiple ticks/quarter note by to get the specified duration. + * Note: type=='note' defaults to quarter note, type==='rest' defaults to 0 + * @param {string} duration + * @param {string} type ['note','rest'] + * @return {number} + */ + + }, { + key: 'getDurationMultiplier', + value: function getDurationMultiplier(duration, type) { + // Need to apply duration here. Quarter note == Constants.HEADER_CHUNK_DIVISION + switch (duration) { + case '0': + return 0; + case '1': + return 4; + case '2': + return 2; + case 'd2': + return 3; + case '4': + return 1; + case '4t': + return 0.666; + case 'd4': + return 1.5; + case '8': + return 0.5; + case '8t': + // For 8th triplets, let's divide a quarter by 3, round to the nearest int, and substract the remainder to the last one. + return 0.33; + case 'd8': + return 0.75; + case '16': + return 0.25; + case '16t': + return 0.166; + case '32': + return 0.125; + case '64': + return 0.0625; + default: + // Notes default to a quarter, rests default to 0 + //return type === 'note' ? 1 : 0; + } + + throw duration + ' is not a valid duration.'; + } + }, { + key: 'getNoteOnStatus', + + + /** + * Gets the note on status code based on the selected channel. 0x9{0-F} + * Note on at channel 0 is 0x90 (144) + * 0 = Ch 1 + * @return {number} + */ + value: function getNoteOnStatus() { + return 144 + this.channel - 1; + } + + /** + * Gets the note off status code based on the selected channel. 0x8{0-F} + * Note off at channel 0 is 0x80 (128) + * 0 = Ch 1 + * @return {number} + */ + + }, { + key: 'getNoteOffStatus', + value: function getNoteOffStatus() { + return 128 + this.channel - 1; + } + }]); + + return NoteEvent; +}(); + +exports.NoteEvent = NoteEvent; +/** + * Holds all data for a "note off" MIDI event + * @param {object} fields {data: []} + * @return {NoteOffEvent} + */ + +var NoteOffEvent = function NoteOffEvent(fields) { + _classCallCheck(this, NoteOffEvent); + + this.data = fields.data; +}; + +exports.NoteOffEvent = NoteOffEvent; +/** + * Holds all data for a "note on" MIDI event + * @param {object} fields {data: []} + * @return {NoteOnEvent} + */ + +var NoteOnEvent = function NoteOnEvent(fields) { + _classCallCheck(this, NoteOnEvent); + + this.data = fields.data; +}; + +exports.NoteOnEvent = NoteOnEvent; +/** + * Holds all data for a "program change" MIDI event + * @param {object} fields {instrument: integer} + * @return {ProgramChangeEvent} + */ + +var ProgramChangeEvent = function ProgramChangeEvent(fields) { + _classCallCheck(this, ProgramChangeEvent); + + this.type = 'program'; + // delta time defaults to 0. + this.data = Utils.numberToVariableLength(0x00).concat(Constants.PROGRAM_CHANGE_STATUS, fields.instrument); +}; + +exports.ProgramChangeEvent = ProgramChangeEvent; +/** + * Holds all data for a track. + * @param {object} fields {type: number, data: array, size: array, events: array} + * @return {Track} + */ + +var Track = function () { + function Track() { + _classCallCheck(this, Track); + + this.type = Constants.TRACK_CHUNK_TYPE; + this.data = []; + this.size = []; + this.events = []; + } + + /** + * Adds any event type to the track. + * @param {(NoteEvent|MetaEvent|ProgramChangeEvent)} event - Event object. + * @param {function} mapFunction - Callback which can be used to apply specific properties to all events. + * @return {Track} + */ + + + _createClass(Track, [{ + key: 'addEvent', + value: function addEvent(event, mapFunction) { + if (Array.isArray(event)) { + event.forEach(function (e, i) { + // Handle map function if provided + if (typeof mapFunction === 'function' && e.type === 'note') { + var properties = mapFunction(i, e); + + if ((typeof properties === 'undefined' ? 'undefined' : _typeof(properties)) === 'object') { + for (var j in properties) { + switch (j) { + case 'duration': + e.duration = properties[j]; + break; + case 'sequential': + e.sequential = properties[j]; + break; + case 'velocity': + e.velocity = e.convertVelocity(properties[j]); + break; + } + } + + // Gotta build that data + e.buildData(); + } + } + + this.data = this.data.concat(e.data); + this.size = Utils.numberToBytes(this.data.length, 4); // 4 bytes long + this.events.push(e); + }, this); + } else { + this.data = this.data.concat(event.data); + this.size = Utils.numberToBytes(this.data.length, 4); // 4 bytes long + this.events.push(event); + } + + return this; + } + + /** + * Sets tempo of the MIDI file. + * @param {number} bpm - Tempo in beats per minute. + * @return {Track} + */ + + }, { + key: 'setTempo', + value: function setTempo(bpm) { + var event = new MetaEvent({ data: [Constants.META_TEMPO_ID] }); + event.data.push(0x03); // Size + var tempo = Math.round(60000000 / bpm); + event.data = event.data.concat(Utils.numberToBytes(tempo, 3)); // Tempo, 3 bytes + return this.addEvent(event); + } + + /** + * Sets time signature. + * @param {number} numerator - Top number of the time signature. + * @param {number} denominator - Bottom number of the time signature. + * @param {number} midiclockspertick - Defaults to 24. + * @param {number} notespermidiclock - Defaults to 8. + * @return {Track} + */ + + }, { + key: 'setTimeSignature', + value: function setTimeSignature(numerator, denominator, midiclockspertick, notespermidiclock) { + midiclockspertick = midiclockspertick || 24; + notespermidiclock = notespermidiclock || 8; + + var event = new MetaEvent({ data: [Constants.META_TIME_SIGNATURE_ID] }); + event.data.push(0x04); // Size + event.data = event.data.concat(Utils.numberToBytes(numerator, 1)); // Numerator, 1 bytes + + var _denominator = Math.log2(denominator); // Denominator is expressed as pow of 2 + event.data = event.data.concat(Utils.numberToBytes(_denominator, 1)); // Denominator, 1 bytes + event.data = event.data.concat(Utils.numberToBytes(midiclockspertick, 1)); // MIDI Clocks per tick, 1 bytes + event.data = event.data.concat(Utils.numberToBytes(notespermidiclock, 1)); // Number of 1/32 notes per MIDI clocks, 1 bytes + return this.addEvent(event); + } + + /** + * Sets key signature. + * @param {*} sf - + * @param {*} mi - + * @return {Track} + */ + + }, { + key: 'setKeySignature', + value: function setKeySignature(sf, mi) { + var event = new MetaEvent({ data: [Constants.META_KEY_SIGNATURE_ID] }); + event.data.push(0x02); // Size + + var mode = mi || 0; + sf = sf || 0; + + // Function called with string notation + if (typeof mi === 'undefined') { + var fifths = [['Cb', 'Gb', 'Db', 'Ab', 'Eb', 'Bb', 'F', 'C', 'G', 'D', 'A', 'E', 'B', 'F#', 'C#'], ['ab', 'eb', 'bb', 'f', 'c', 'g', 'd', 'a', 'e', 'b', 'f#', 'c#', 'g#', 'd#', 'a#']]; + var _sflen = sf.length; + var note = sf || 'C'; + + if (sf[0] === sf[0].toLowerCase()) mode = 1; + + if (_sflen > 1) { + switch (sf.charAt(_sflen - 1)) { + case 'm': + mode = 1; + note = sf.charAt(0).toLowerCase(); + note = note.concat(sf.substring(1, _sflen - 1)); + break; + case '-': + mode = 1; + note = sf.charAt(0).toLowerCase(); + note = note.concat(sf.substring(1, _sflen - 1)); + break; + case 'M': + mode = 0; + note = sf.charAt(0).toUpperCase(); + note = note.concat(sf.substring(1, _sflen - 1)); + break; + case '+': + mode = 0; + note = sf.charAt(0).toUpperCase(); + note = note.concat(sf.substring(1, _sflen - 1)); + break; + } + } + + var fifthindex = fifths[mode].indexOf(note); + sf = fifthindex === -1 ? 0 : fifthindex - 7; + } + + event.data = event.data.concat(Utils.numberToBytes(sf, 1)); // Number of sharp or flats ( < 0 flat; > 0 sharp) + event.data = event.data.concat(Utils.numberToBytes(mode, 1)); // Mode: 0 major, 1 minor + return this.addEvent(event); + } + + /** + * Adds text to MIDI file. + * @param {string} text - Text to add. + * @return {Track} + */ + + }, { + key: 'addText', + value: function addText(text) { + var event = new MetaEvent({ data: [Constants.META_TEXT_ID] }); + var stringBytes = Utils.stringToBytes(text); + event.data = event.data.concat(Utils.numberToVariableLength(stringBytes.length)); // Size + event.data = event.data.concat(stringBytes); // Text + return this.addEvent(event); + } + + /** + * Adds copyright to MIDI file. + * @param {string} text - Text of copyright line. + * @return {Track} + */ + + }, { + key: 'addCopyright', + value: function addCopyright(text) { + var event = new MetaEvent({ data: [Constants.META_COPYRIGHT_ID] }); + var stringBytes = Utils.stringToBytes(text); + event.data = event.data.concat(Utils.numberToVariableLength(stringBytes.length)); // Size + event.data = event.data.concat(stringBytes); // Text + return this.addEvent(event); + } + + /** + * Adds Sequence/Track Name. + * @param {string} text - Text of track name. + * @return {Track} + */ + + }, { + key: 'addTrackName', + value: function addTrackName(text) { + var event = new MetaEvent({ data: [Constants.META_TRACK_NAME_ID] }); + var stringBytes = Utils.stringToBytes(text); + event.data = event.data.concat(Utils.numberToVariableLength(stringBytes.length)); // Size + event.data = event.data.concat(stringBytes); // Text + return this.addEvent(event); + } + + /** + * Sets instrument name of track. + * @param {string} text - Name of instrument. + * @return {Track} + */ + + }, { + key: 'addInstrumentName', + value: function addInstrumentName(text) { + var event = new MetaEvent({ data: [Constants.META_INSTRUMENT_NAME_ID] }); + var stringBytes = Utils.stringToBytes(text); + event.data = event.data.concat(Utils.numberToVariableLength(stringBytes.length)); // Size + event.data = event.data.concat(stringBytes); // Text + return this.addEvent(event); + } + + /** + * Adds marker to MIDI file. + * @param {string} text - Marker text. + * @return {Track} + */ + + }, { + key: 'addMarker', + value: function addMarker(text) { + var event = new MetaEvent({ data: [Constants.META_MARKER_ID] }); + var stringBytes = Utils.stringToBytes(text); + event.data = event.data.concat(Utils.numberToVariableLength(stringBytes.length)); // Size + event.data = event.data.concat(stringBytes); // Text + return this.addEvent(event); + } + + /** + * Adds cue point to MIDI file. + * @param {string} text - Text of cue point. + * @return {Track} + */ + + }, { + key: 'addCuePoint', + value: function addCuePoint(text) { + var event = new MetaEvent({ data: [Constants.META_CUE_POINT] }); + var stringBytes = Utils.stringToBytes(text); + event.data = event.data.concat(Utils.numberToVariableLength(stringBytes.length)); // Size + event.data = event.data.concat(stringBytes); // Text + return this.addEvent(event); + } + + /** + * Adds lyric to MIDI file. + * @param {string} lyric - Lyric text to add. + * @return {Track} + */ + + }, { + key: 'addLyric', + value: function addLyric(lyric) { + var event = new MetaEvent({ data: [Constants.META_LYRIC_ID] }); + var stringBytes = Utils.stringToBytes(lyric); + event.data = event.data.concat(Utils.numberToVariableLength(stringBytes.length)); // Size + event.data = event.data.concat(stringBytes); // Lyric + return this.addEvent(event); + } + + /** + * Channel mode messages + * @return {Track} + */ + + }, { + key: 'polyModeOn', + value: function polyModeOn() { + var event = new NoteOnEvent({ data: [0x00, 0xB0, 0x7E, 0x00] }); + return this.addEvent(event); + } + }]); + + return Track; +}(); + +exports.Track = Track; + +/** + * Static utility functions used throughout the library. + */ +var Utils = function () { + function Utils() { + _classCallCheck(this, Utils); + } + + _createClass(Utils, null, [{ + key: 'version', + + + /** + * Gets MidiWriterJS version number. + * @return {string} + */ + value: function version() { + return Constants.VERSION; + } + + /** + * Convert a string to an array of bytes + * @param {string} string + * @return {array} + */ + + }, { + key: 'stringToBytes', + value: function stringToBytes(string) { + return string.split('').map(function (char) { + return char.charCodeAt(); + }); + } + + /** + * Checks if argument is a valid number. + * @param {*} n - Value to check + * @return {boolean} + */ + + }, { + key: 'isNumeric', + value: function isNumeric(n) { + return !isNaN(parseFloat(n)) && isFinite(n); + } + + /** + * Returns the correct MIDI number for the specified pitch. + * Uses Tonal Midi - https://github.com/danigb/tonal/tree/master/packages/midi + * @param {(string|number)} pitch - 'C#4' or midi note code + * @return {number} + */ + + }, { + key: 'getPitch', + value: function getPitch(pitch) { + return (0, _tonalMidi.toMidi)(pitch); + } + + /** + * Translates number of ticks to MIDI timestamp format, returning an array of + * hex strings with the time values. Midi has a very particular time to express time, + * take a good look at the spec before ever touching this function. + * Thanks to https://github.com/sergi/jsmidi + * + * @param {number} ticks - Number of ticks to be translated + * @return {array} - Bytes that form the MIDI time value + */ + + }, { + key: 'numberToVariableLength', + value: function numberToVariableLength(ticks) { + var buffer = ticks & 0x7F; + + while (ticks = ticks >> 7) { + buffer <<= 8; + buffer |= ticks & 0x7F | 0x80; + } + + var bList = []; + while (true) { + bList.push(buffer & 0xff); + + if (buffer & 0x80) buffer >>= 8;else { + break; + } + } + + return bList; + } + + /** + * Counts number of bytes in string + * @param {string} s + * @return {array} + */ + + }, { + key: 'stringByteCount', + value: function stringByteCount(s) { + return encodeURI(s).split(/%..|./).length - 1; + } + + /** + * Get an int from an array of bytes. + * @param {array} bytes + * @return {number} + */ + + }, { + key: 'numberFromBytes', + value: function numberFromBytes(bytes) { + var hex = ''; + var stringResult; + + bytes.forEach(function (byte) { + stringResult = byte.toString(16); + + // ensure string is 2 chars + if (stringResult.length == 1) stringResult = "0" + stringResult; + + hex += stringResult; + }); + + return parseInt(hex, 16); + } + + /** + * Takes a number and splits it up into an array of bytes. Can be padded by passing a number to bytesNeeded + * @param {number} number + * @param {number} bytesNeeded + * @return {array} - Array of bytes + */ + + }, { + key: 'numberToBytes', + value: function numberToBytes(number, bytesNeeded) { + bytesNeeded = bytesNeeded || 1; + + var hexString = number.toString(16); + + if (hexString.length & 1) { + // Make sure hex string is even number of chars + hexString = '0' + hexString; + } + + // Split hex string into an array of two char elements + var hexArray = hexString.match(/.{2}/g); + + // Now parse them out as integers + hexArray = hexArray.map(function (item) { + return parseInt(item, 16); + }); + + // Prepend empty bytes if we don't have enough + if (hexArray.length < bytesNeeded) { + while (bytesNeeded - hexArray.length > 0) { + hexArray.unshift(0); + } + } + + return hexArray; + } + + /** + * Converts value to array if needed. + * @param {string} value + * @return {array} + */ + + }, { + key: 'toArray', + value: function toArray(value) { + if (Array.isArray(value)) return value; + return [value]; + } + }]); + + return Utils; +}(); + +exports.Utils = Utils; + +var VexFlow = function () { + function VexFlow() { + _classCallCheck(this, VexFlow); + } + // code... + + + /** + * Support for converting VexFlow voice into MidiWriterJS track + * @return MidiWritier.Track object + */ + + + _createClass(VexFlow, [{ + key: 'trackFromVoice', + value: function trackFromVoice(voice) { + var track = new Track(); + var wait; + var pitches = []; + + voice.tickables.forEach(function (tickable) { + pitches = []; + + if (tickable.noteType === 'n') { + tickable.keys.forEach(function (key) { + // build array of pitches + pitches.push(this.convertPitch(key)); + }); + } else if (tickable.noteType === 'r') { + // move on to the next tickable and use this rest as a `wait` property for the next event + wait = this.convertDuration(tickable); + return; + } + + track.addEvent(new NoteEvent({ pitch: pitches, duration: this.convertDuration(tickable), wait: wait })); + + // reset wait + wait = 0; + }); + + return track; + } + + /** + * Converts VexFlow pitch syntax to MidiWriterJS syntax + * @param pitch string + */ + + }, { + key: 'convertPitch', + value: function convertPitch(pitch) { + return pitch.replace('/', ''); + } + + /** + * Converts VexFlow duration syntax to MidiWriterJS syntax + * @param note struct from VexFlow + */ + + }, { + key: 'convertDuration', + value: function convertDuration(note) { + switch (note.duration) { + case 'w': + return '1'; + case 'h': + return note.isDotted() ? 'd2' : '2'; + case 'q': + return note.isDotted() ? 'd4' : '4'; + case '8': + return note.isDotted() ? 'd8' : '8'; + } + + return note.duration; + } + }]); + + return VexFlow; +}(); + +exports.VexFlow = VexFlow; +/** + * Object that puts together tracks and provides methods for file output. + * @param {array} tracks - An array of {Track} objects. + * @return {Writer} + */ + +var Writer = function () { + function Writer(tracks) { + _classCallCheck(this, Writer); + + this.data = []; + + var trackType = tracks.length > 1 ? Constants.HEADER_CHUNK_FORMAT1 : Constants.HEADER_CHUNK_FORMAT0; + var numberOfTracks = Utils.numberToBytes(tracks.length, 2); // two bytes long + + // Header chunk + this.data.push(new Chunk({ + type: Constants.HEADER_CHUNK_TYPE, + data: trackType.concat(numberOfTracks, Constants.HEADER_CHUNK_DIVISION) })); + + // Track chunks + tracks.forEach(function (track, i) { + track.addEvent(new MetaEvent({ data: Constants.META_END_OF_TRACK_ID })); + this.data.push(track); + }, this); + } + + /** + * Builds the file into a Uint8Array + * @return {Uint8Array} + */ + + + _createClass(Writer, [{ + key: 'buildFile', + value: function buildFile() { + var build = []; + + // Data consists of chunks which consists of data + this.data.forEach(function (d) { + return build = build.concat(d.type, d.size, d.data); + }); + + return new Uint8Array(build); + } + + /** + * Convert file buffer to a base64 string. Different methods depending on if browser or node. + * @return {string} + */ + + }, { + key: 'base64', + value: function base64() { + if (typeof btoa === 'function') return btoa(String.fromCharCode.apply(null, this.buildFile())); + return new Buffer(this.buildFile()).toString('base64'); + } + + /** + * Get the data URI. + * @return {string} + */ + + }, { + key: 'dataUri', + value: function dataUri() { + return 'data:audio/midi;base64,' + this.base64(); + } + + /** + * Output to stdout + * @return {string} + */ + + }, { + key: 'stdout', + value: function stdout() { + return process.stdout.write(new Buffer(this.buildFile())); + } + + /** + * Save to MIDI file + * @param {string} filename + */ + + }, { + key: 'saveMIDI', + value: function saveMIDI(filename) { + var buffer = new Buffer(this.buildFile()); + fs.writeFile(filename + '.mid', buffer, function (err) { + if (err) return console.log(err); + }); + } + }]); + + return Writer; +}(); + +exports.Writer = Writer; +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LmpzIl0sIm5hbWVzIjpbIkNodW5rIiwiZmllbGRzIiwidHlwZSIsImRhdGEiLCJzaXplIiwibGVuZ3RoIiwiQ29uc3RhbnRzIiwiVkVSU0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BPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer, __webpack_require__(10))) + +/***/ }), +/* 137 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* unused harmony export regex */ +/* unused harmony export parse */ +/* unused harmony export build */ +/* harmony export (immutable) */ __webpack_exports__["a"] = midi; +/* unused harmony export freq */ +/* unused harmony export letter */ +/* unused harmony export acc */ +/* unused harmony export pc */ +/* unused harmony export step */ +/* unused harmony export alt */ +/* unused harmony export chroma */ +/* unused harmony export oct */ + + +// util +function fillStr (s, num) { return Array(num + 1).join(s) } +function isNum (x) { return typeof x === 'number' } +function isStr (x) { return typeof x === 'string' } +function isDef (x) { return typeof x !== 'undefined' } +function midiToFreq (midi, tuning) { + return Math.pow(2, (midi - 69) / 12) * (tuning || 440) +} + +var REGEX = /^([a-gA-G])(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)\s*$/ +/** + * A regex for matching note strings in scientific notation. + * + * @name regex + * @function + * @return {RegExp} the regexp used to parse the note name + * + * The note string should have the form `letter[accidentals][octave][element]` + * where: + * + * - letter: (Required) is a letter from A to G either upper or lower case + * - accidentals: (Optional) can be one or more `b` (flats), `#` (sharps) or `x` (double sharps). + * They can NOT be mixed. + * - octave: (Optional) a positive or negative integer + * - element: (Optional) additionally anything after the duration is considered to + * be the element name (for example: 'C2 dorian') + * + * The executed regex contains (by array index): + * + * - 0: the complete string + * - 1: the note letter + * - 2: the optional accidentals + * - 3: the optional octave + * - 4: the rest of the string (trimmed) + * + * @example + * var parser = require('note-parser') + * parser.regex.exec('c#4') + * // => ['c#4', 'c', '#', '4', ''] + * parser.regex.exec('c#4 major') + * // => ['c#4major', 'c', '#', '4', 'major'] + * parser.regex().exec('CMaj7') + * // => ['CMaj7', 'C', '', '', 'Maj7'] + */ +function regex () { return REGEX } + +var SEMITONES = [0, 2, 4, 5, 7, 9, 11] +/** + * Parse a note name in scientific notation an return it's components, + * and some numeric properties including midi number and frequency. + * + * @name parse + * @function + * @param {String} note - the note string to be parsed + * @param {Boolean} isTonic - true the strings it's supposed to contain a note number + * and some category (for example an scale: 'C# major'). It's false by default, + * but when true, en extra tonicOf property is returned with the category ('major') + * @param {Float} tunning - The frequency of A4 note to calculate frequencies. + * By default it 440. + * @return {Object} the parsed note name or null if not a valid note + * + * The parsed note name object will ALWAYS contains: + * - letter: the uppercase letter of the note + * - acc: the accidentals of the note (only sharps or flats) + * - pc: the pitch class (letter + acc) + * - step: s a numeric representation of the letter. It's an integer from 0 to 6 + * where 0 = C, 1 = D ... 6 = B + * - alt: a numeric representation of the accidentals. 0 means no alteration, + * positive numbers are for sharps and negative for flats + * - chroma: a numeric representation of the pitch class. It's like midi for + * pitch classes. 0 = C, 1 = C#, 2 = D ... 11 = B. Can be used to find enharmonics + * since, for example, chroma of 'Cb' and 'B' are both 11 + * + * If the note has octave, the parser object will contain: + * - oct: the octave number (as integer) + * - midi: the midi number + * - freq: the frequency (using tuning parameter as base) + * + * If the parameter `isTonic` is set to true, the parsed object will contain: + * - tonicOf: the rest of the string that follows note name (left and right trimmed) + * + * @example + * var parse = require('note-parser').parse + * parse('Cb4') + * // => { letter: 'C', acc: 'b', pc: 'Cb', step: 0, alt: -1, chroma: -1, + * oct: 4, midi: 59, freq: 246.94165062806206 } + * // if no octave, no midi, no freq + * parse('fx') + * // => { letter: 'F', acc: '##', pc: 'F##', step: 3, alt: 2, chroma: 7 }) + */ +function parse (str, isTonic, tuning) { + if (typeof str !== 'string') return null + var m = REGEX.exec(str) + if (!m || (!isTonic && m[4])) return null + + var p = { letter: m[1].toUpperCase(), acc: m[2].replace(/x/g, '##') } + p.pc = p.letter + p.acc + p.step = (p.letter.charCodeAt(0) + 3) % 7 + p.alt = p.acc[0] === 'b' ? -p.acc.length : p.acc.length + var pos = SEMITONES[p.step] + p.alt + p.chroma = pos < 0 ? 12 + pos : pos % 12 + if (m[3]) { // has octave + p.oct = +m[3] + p.midi = pos + 12 * (p.oct + 1) + p.freq = midiToFreq(p.midi, tuning) + } + if (isTonic) p.tonicOf = m[4] + return p +} + +var LETTERS = 'CDEFGAB' +function accStr (n) { return !isNum(n) ? '' : n < 0 ? fillStr('b', -n) : fillStr('#', n) } +function octStr (n) { return !isNum(n) ? '' : '' + n } + +/** + * Create a string from a parsed object or `step, alteration, octave` parameters + * @param {Object} obj - the parsed data object + * @return {String} a note string or null if not valid parameters + * @since 1.2 + * @example + * parser.build(parser.parse('cb2')) // => 'Cb2' + * + * @example + * // it accepts (step, alteration, octave) parameters: + * parser.build(3) // => 'F' + * parser.build(3, -1) // => 'Fb' + * parser.build(3, -1, 4) // => 'Fb4' + */ +function build (s, a, o) { + if (s === null || typeof s === 'undefined') return null + if (s.step) return build(s.step, s.alt, s.oct) + if (s < 0 || s > 6) return null + return LETTERS.charAt(s) + accStr(a) + octStr(o) +} + +/** + * Get midi of a note + * + * @name midi + * @function + * @param {String|Integer} note - the note name or midi number + * @return {Integer} the midi number of the note or null if not a valid note + * or the note does NOT contains octave + * @example + * var parser = require('note-parser') + * parser.midi('A4') // => 69 + * parser.midi('A') // => null + * @example + * // midi numbers are bypassed (even as strings) + * parser.midi(60) // => 60 + * parser.midi('60') // => 60 + */ +function midi (note) { + if ((isNum(note) || isStr(note)) && note >= 0 && note < 128) return +note + var p = parse(note) + return p && isDef(p.midi) ? p.midi : null +} + +/** + * Get freq of a note in hertzs (in a well tempered 440Hz A4) + * + * @name freq + * @function + * @param {String} note - the note name or note midi number + * @param {String} tuning - (Optional) the A4 frequency (440 by default) + * @return {Float} the freq of the number if hertzs or null if not valid note + * @example + * var parser = require('note-parser') + * parser.freq('A4') // => 440 + * parser.freq('A') // => null + * @example + * // can change tuning (440 by default) + * parser.freq('A4', 444) // => 444 + * parser.freq('A3', 444) // => 222 + * @example + * // it accepts midi numbers (as numbers and as strings) + * parser.freq(69) // => 440 + * parser.freq('69', 442) // => 442 + */ +function freq (note, tuning) { + var m = midi(note) + return m === null ? null : midiToFreq(m, tuning) +} + +function letter (src) { return (parse(src) || {}).letter } +function acc (src) { return (parse(src) || {}).acc } +function pc (src) { return (parse(src) || {}).pc } +function step (src) { return (parse(src) || {}).step } +function alt (src) { return (parse(src) || {}).alt } +function chroma (src) { return (parse(src) || {}).chroma } +function oct (src) { return (parse(src) || {}).oct } + + +/***/ }), +/* 138 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = __webpack_require__(11); + + +/***/ }), +/* 139 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +// a passthrough stream. +// basically just the most minimal sort of Transform stream. +// Every written chunk gets output as-is. + + + +module.exports = PassThrough; + +var Transform = __webpack_require__(66); + +/*<replacement>*/ +var util = __webpack_require__(19); +util.inherits = __webpack_require__(16); +/*</replacement>*/ + +util.inherits(PassThrough, Transform); + +function PassThrough(options) { + if (!(this instanceof PassThrough)) return new PassThrough(options); + + Transform.call(this, options); +} + +PassThrough.prototype._transform = function (chunk, encoding, cb) { + cb(null, chunk); +}; + +/***/ }), +/* 140 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var Buffer = __webpack_require__(3).Buffer; +/*<replacement>*/ +var bufferShim = __webpack_require__(32); +/*</replacement>*/ + +module.exports = BufferList; + +function BufferList() { + this.head = null; + this.tail = null; + this.length = 0; +} + +BufferList.prototype.push = function (v) { + var entry = { data: v, next: null }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; +}; + +BufferList.prototype.unshift = function (v) { + var entry = { data: v, next: this.head }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; +}; + +BufferList.prototype.shift = function () { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; +}; + +BufferList.prototype.clear = function () { + this.head = this.tail = null; + this.length = 0; +}; + +BufferList.prototype.join = function (s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + while (p = p.next) { + ret += s + p.data; + }return ret; +}; + +BufferList.prototype.concat = function (n) { + if (this.length === 0) return bufferShim.alloc(0); + if (this.length === 1) return this.head.data; + var ret = bufferShim.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + while (p) { + p.data.copy(ret, i); + i += p.data.length; + p = p.next; + } + return ret; +}; + +/***/ }), +/* 141 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = __webpack_require__(50).PassThrough + + +/***/ }), +/* 142 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = __webpack_require__(50).Transform + + +/***/ }), +/* 143 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = __webpack_require__(49); + + +/***/ }), +/* 144 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) { + "use strict"; + + if (global.setImmediate) { + return; + } + + var nextHandle = 1; // Spec says greater than zero + var tasksByHandle = {}; + var currentlyRunningATask = false; + var doc = global.document; + var registerImmediate; + + function setImmediate(callback) { + // Callback can either be a function or a string + if (typeof callback !== "function") { + callback = new Function("" + callback); + } + // Copy function arguments + var args = new Array(arguments.length - 1); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i + 1]; + } + // Store and register the task + var task = { callback: callback, args: args }; + tasksByHandle[nextHandle] = task; + registerImmediate(nextHandle); + return nextHandle++; + } + + function clearImmediate(handle) { + delete tasksByHandle[handle]; + } + + function run(task) { + var callback = task.callback; + var args = task.args; + switch (args.length) { + case 0: + callback(); + break; + case 1: + callback(args[0]); + break; + case 2: + callback(args[0], args[1]); + break; + case 3: + callback(args[0], args[1], args[2]); + break; + default: + callback.apply(undefined, args); + break; + } + } + + function runIfPresent(handle) { + // From the spec: "Wait until any invocations of this algorithm started before this one have completed." + // So if we're currently running a task, we'll need to delay this invocation. + if (currentlyRunningATask) { + // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a + // "too much recursion" error. + setTimeout(runIfPresent, 0, handle); + } else { + var task = tasksByHandle[handle]; + if (task) { + currentlyRunningATask = true; + try { + run(task); + } finally { + clearImmediate(handle); + currentlyRunningATask = false; + } + } + } + } + + function installNextTickImplementation() { + registerImmediate = function(handle) { + process.nextTick(function () { runIfPresent(handle); }); + }; + } + + function canUsePostMessage() { + // The test against `importScripts` prevents this implementation from being installed inside a web worker, + // where `global.postMessage` means something completely different and can't be used for this purpose. + if (global.postMessage && !global.importScripts) { + var postMessageIsAsynchronous = true; + var oldOnMessage = global.onmessage; + global.onmessage = function() { + postMessageIsAsynchronous = false; + }; + global.postMessage("", "*"); + global.onmessage = oldOnMessage; + return postMessageIsAsynchronous; + } + } + + function installPostMessageImplementation() { + // Installs an event handler on `global` for the `message` event: see + // * https://developer.mozilla.org/en/DOM/window.postMessage + // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages + + var messagePrefix = "setImmediate$" + Math.random() + "$"; + var onGlobalMessage = function(event) { + if (event.source === global && + typeof event.data === "string" && + event.data.indexOf(messagePrefix) === 0) { + runIfPresent(+event.data.slice(messagePrefix.length)); + } + }; + + if (global.addEventListener) { + global.addEventListener("message", onGlobalMessage, false); + } else { + global.attachEvent("onmessage", onGlobalMessage); + } + + registerImmediate = function(handle) { + global.postMessage(messagePrefix + handle, "*"); + }; + } + + function installMessageChannelImplementation() { + var channel = new MessageChannel(); + channel.port1.onmessage = function(event) { + var handle = event.data; + runIfPresent(handle); + }; + + registerImmediate = function(handle) { + channel.port2.postMessage(handle); + }; + } + + function installReadyStateChangeImplementation() { + var html = doc.documentElement; + registerImmediate = function(handle) { + // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted + // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called. + var script = doc.createElement("script"); + script.onreadystatechange = function () { + runIfPresent(handle); + script.onreadystatechange = null; + html.removeChild(script); + script = null; + }; + html.appendChild(script); + }; + } + + function installSetTimeoutImplementation() { + registerImmediate = function(handle) { + setTimeout(runIfPresent, 0, handle); + }; + } + + // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live. + var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global); + attachTo = attachTo && attachTo.setTimeout ? attachTo : global; + + // Don't get fooled by e.g. browserify environments. + if ({}.toString.call(global.process) === "[object process]") { + // For Node.js before 0.9 + installNextTickImplementation(); + + } else if (canUsePostMessage()) { + // For non-IE10 modern browsers + installPostMessageImplementation(); + + } else if (global.MessageChannel) { + // For web workers, where supported + installMessageChannelImplementation(); + + } else if (doc && "onreadystatechange" in doc.createElement("script")) { + // For IE 6–8 + installReadyStateChangeImplementation(); + + } else { + // For older browsers + installSetTimeoutImplementation(); + } + + attachTo.setImmediate = setImmediate; + attachTo.clearImmediate = clearImmediate; +}(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self)); + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(20), __webpack_require__(10))) + +/***/ }), +/* 145 */ +/***/ (function(module, exports, __webpack_require__) { + +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +module.exports = Stream; + +var EE = __webpack_require__(46).EventEmitter; +var inherits = __webpack_require__(16); + +inherits(Stream, EE); +Stream.Readable = __webpack_require__(50); +Stream.Writable = __webpack_require__(143); +Stream.Duplex = __webpack_require__(138); +Stream.Transform = __webpack_require__(142); +Stream.PassThrough = __webpack_require__(141); + +// Backwards-compat with node 0.4.x +Stream.Stream = Stream; + + + +// old-style streams. Note that the pipe method (the only relevant +// part of this class) is overridden in the Readable class. + +function Stream() { + EE.call(this); +} + +Stream.prototype.pipe = function(dest, options) { + var source = this; + + function ondata(chunk) { + if (dest.writable) { + if (false === dest.write(chunk) && source.pause) { + source.pause(); + } + } + } + + source.on('data', ondata); + + function ondrain() { + if (source.readable && source.resume) { + source.resume(); + } + } + + dest.on('drain', ondrain); + + // If the 'end' option is not supplied, dest.end() will be called when + // source gets the 'end' or 'close' events. Only dest.end() once. + if (!dest._isStdio && (!options || options.end !== false)) { + source.on('end', onend); + source.on('close', onclose); + } + + var didOnEnd = false; + function onend() { + if (didOnEnd) return; + didOnEnd = true; + + dest.end(); + } + + + function onclose() { + if (didOnEnd) return; + didOnEnd = true; + + if (typeof dest.destroy === 'function') dest.destroy(); + } + + // don't leave dangling pipes when there are errors. + function onerror(er) { + cleanup(); + if (EE.listenerCount(this, 'error') === 0) { + throw er; // Unhandled stream error in pipe. + } + } + + source.on('error', onerror); + dest.on('error', onerror); + + // remove all the event listeners that were added. + function cleanup() { + source.removeListener('data', ondata); + dest.removeListener('drain', ondrain); + + source.removeListener('end', onend); + source.removeListener('close', onclose); + + source.removeListener('error', onerror); + dest.removeListener('error', onerror); + + source.removeListener('end', cleanup); + source.removeListener('close', cleanup); + + dest.removeListener('close', cleanup); + } + + source.on('end', cleanup); + source.on('close', cleanup); + + dest.on('close', cleanup); + + dest.emit('pipe', source); + + // Allow for unix-like usage: A.pipe(B).pipe(C) + return dest; +}; + + +/***/ }), +/* 146 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_note_parser__ = __webpack_require__(137); +/* harmony export (immutable) */ __webpack_exports__["toMidi"] = toMidi; +/* harmony export (immutable) */ __webpack_exports__["note"] = note; +/** + * A midi note number is a number representation of a note pitch. It can be + * integers so it's equal tempered tuned, or float to indicate it's not + * tuned into equal temepered scale. + * + * This module contains functions to convert to and from midi notes. + * + * @example + * var midi = require('tonal-midi') + * midi.toMidi('A4') // => 69 + * midi.note(69) // => 'A4' + * midi.note(61) // => 'Db4' + * midi.note(61, true) // => 'C#4' + * + * @module midi + */ + + + +/** + * Convert the given note to a midi note number. If you pass a midi number it + * will returned as is. + * + * @param {Array|String|Number} note - the note to get the midi number from + * @return {Integer} the midi number or null if not valid pitch + * @example + * midi.toMidi('C4') // => 60 + * midi.toMidi(60) // => 60 + * midi.toMidi('60') // => 60 + */ +function toMidi (val) { + if (Array.isArray(val) && val.length === 2) return val[0] * 7 + val[1] * 12 + 12 + return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_note_parser__["a" /* midi */])(val) +} + +var FLATS = 'C Db D Eb E F Gb G Ab A Bb B'.split(' ') +var SHARPS = 'C C# D D# E F F# G G# A A# B'.split(' ') + +/** + * Given a midi number, returns a note name. The altered notes will have + * flats unless explicitly set with the optional `useSharps` parameter. + * + * @function + * @param {Integer} midi - the midi note number + * @param {Boolean} useSharps - (Optional) set to true to use sharps instead of flats + * @return {String} the note name + * @example + * var midi = require('tonal-midi') + * midi.note(61) // => 'Db4' + * midi.note(61, true) // => 'C#4' + * // it rounds to nearest note + * midi.note(61.7) // => 'D4' + */ +function note (num, sharps) { + if (num === true || num === false) return function (m) { return note(m, num) } + num = Math.round(num) + var pcs = sharps === true ? SHARPS : FLATS + var pc = pcs[num % 12] + var o = Math.floor(num / 12) - 1 + return pc + o +} + + +/***/ }), +/* 147 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) { +/** + * Module exports. + */ + +module.exports = deprecate; + +/** + * Mark that a method should not be used. + * Returns a modified function which warns once by default. + * + * If `localStorage.noDeprecation = true` is set, then it is a no-op. + * + * If `localStorage.throwDeprecation = true` is set, then deprecated functions + * will throw an Error when invoked. + * + * If `localStorage.traceDeprecation = true` is set, then deprecated functions + * will invoke `console.trace()` instead of `console.error()`. + * + * @param {Function} fn - the function to deprecate + * @param {String} msg - the string to print to the console when `fn` is invoked + * @returns {Function} a new "deprecated" version of `fn` + * @api public + */ + +function deprecate (fn, msg) { + if (config('noDeprecation')) { + return fn; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (config('throwDeprecation')) { + throw new Error(msg); + } else if (config('traceDeprecation')) { + console.trace(msg); + } else { + console.warn(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; +} + +/** + * Checks `localStorage` for boolean values for the given `name`. + * + * @param {String} name + * @returns {Boolean} + * @api private + */ + +function config (name) { + // accessing global.localStorage can trigger a DOMException in sandboxed iframes + try { + if (!global.localStorage) return false; + } catch (_) { + return false; + } + var val = global.localStorage[name]; + if (null == val) return false; + return String(val).toLowerCase() === 'true'; +} + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(20))) + +/***/ }), +/* 148 */ +/***/ (function(module, exports) { + +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } +} + + +/***/ }), +/* 149 */ +/***/ (function(module, exports) { + +module.exports = function isBuffer(arg) { + return arg && typeof arg === 'object' + && typeof arg.copy === 'function' + && typeof arg.fill === 'function' + && typeof arg.readUInt8 === 'function'; +} + +/***/ }), +/* 150 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var formatRegExp = /%[sdj%]/g; +exports.format = function(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect(arguments[i])); + } + return objects.join(' '); + } + + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; + } + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += ' ' + x; + } else { + str += ' ' + inspect(x); + } + } + return str; +}; + + +// Mark that a method should not be used. +// Returns a modified function which warns once by default. +// If --no-deprecation is set, then it is a no-op. +exports.deprecate = function(fn, msg) { + // Allow for deprecating things in the process of starting up. + if (isUndefined(global.process)) { + return function() { + return exports.deprecate(fn, msg).apply(this, arguments); + }; + } + + if (process.noDeprecation === true) { + return fn; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (process.throwDeprecation) { + throw new Error(msg); + } else if (process.traceDeprecation) { + console.trace(msg); + } else { + console.error(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; +}; + + +var debugs = {}; +var debugEnviron; +exports.debuglog = function(set) { + if (isUndefined(debugEnviron)) + debugEnviron = process.env.NODE_DEBUG || ''; + set = set.toUpperCase(); + if (!debugs[set]) { + if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { + var pid = process.pid; + debugs[set] = function() { + var msg = exports.format.apply(exports, arguments); + console.error('%s %d: %s', set, pid, msg); + }; + } else { + debugs[set] = function() {}; + } + } + return debugs[set]; +}; + + +/** + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. + * + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. + */ +/* legacy: obj, showHidden, depth, colors*/ +function inspect(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor + }; + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + exports._extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); +} +exports.inspect = inspect; + + +// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +inspect.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] +}; + +// Don't use 'blue' not visible on cmd.exe +inspect.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' +}; + + +function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; + + if (style) { + return '\u001b[' + inspect.colors[style][0] + 'm' + str + + '\u001b[' + inspect.colors[style][1] + 'm'; + } else { + return str; + } +} + + +function stylizeNoColor(str, styleType) { + return str; +} + + +function arrayToHash(array) { + var hash = {}; + + array.forEach(function(val, idx) { + hash[val] = true; + }); + + return hash; +} + + +function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== exports.inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + var ret = value.inspect(recurseTimes, ctx); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); + } + return ret; + } + + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = Object.keys(value); + var visibleKeys = arrayToHash(keys); + + if (ctx.showHidden) { + keys = Object.getOwnPropertyNames(value); + } + + // IE doesn't make error fields non-enumerable + // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx + if (isError(value) + && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { + return formatError(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); +} + + +function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); +} + + +function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; +} + + +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); + } + } + keys.forEach(function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); + } + }); + return output; +} + + +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } + } else { + str = ctx.stylize('[Circular]', 'special'); + } + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } + + return name + ': ' + str; +} + + +function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = output.reduce(function(prev, cur) { + numLinesEst++; + if (cur.indexOf('\n') >= 0) numLinesEst++; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); + + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } + + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +} + + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = __webpack_require__(149); + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + + +function pad(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); +} + + +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', + 'Oct', 'Nov', 'Dec']; + +// 26 Feb 16:19:34 +function timestamp() { + var d = new Date(); + var time = [pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds())].join(':'); + return [d.getDate(), months[d.getMonth()], time].join(' '); +} + + +// log is just a thin wrapper to console.log that prepends a timestamp +exports.log = function() { + console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +}; + + +/** + * Inherit the prototype methods from one constructor into another. + * + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). + * + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. + */ +exports.inherits = __webpack_require__(148); + +exports._extend = function(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin; +}; + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(20), __webpack_require__(10))) + +/***/ }), +/* 151 */ +/***/ (function(module, exports) { + +module.exports = function() {
+ throw new Error("define cannot be used indirect");
+};
+ + +/***/ }), +/* 152 */ +/***/ (function(module, exports) { + +/* WEBPACK VAR INJECTION */(function(__webpack_amd_options__) {/* globals __webpack_amd_options__ */
+module.exports = __webpack_amd_options__;
+ +/* WEBPACK VAR INJECTION */}.call(exports, {})) + +/***/ }), +/* 153 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 154 */ +/***/ (function(module, exports, __webpack_require__) { + +var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* + +WebMidi v2.2.0 + +WebMidi.js helps you tame the Web MIDI API. Send and receive MIDI messages with ease. Control instruments with user-friendly functions (playNote, sendPitchBend, etc.). React to MIDI input with simple event listeners (noteon, pitchbend, controlchange, etc.). +https://github.com/djipco/webmidi + + +The MIT License (MIT) + +Copyright (c) 2015-2018, Jean-Philippe Côté + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT +NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +!function(scope){"use strict";function WebMidi(){if(WebMidi.prototype._singleton)throw new Error("WebMidi is a singleton, it cannot be instantiated directly.");WebMidi.prototype._singleton=this,this._inputs=[],this._outputs=[],this._userHandlers={},this._stateChangeQueue=[],this._processingStateChange=!1,this._midiInterfaceEvents=["connected","disconnected"],this._notes=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],this._semitones={C:0,D:2,E:4,F:5,G:7,A:9,B:11},Object.defineProperties(this,{MIDI_SYSTEM_MESSAGES:{value:{sysex:240,timecode:241,songposition:242,songselect:243,tuningrequest:246,sysexend:247,clock:248,start:250,"continue":251,stop:252,activesensing:254,reset:255,midimessage:0,unknownsystemmessage:-1},writable:!1,enumerable:!0,configurable:!1},MIDI_CHANNEL_MESSAGES:{value:{noteoff:8,noteon:9,keyaftertouch:10,controlchange:11,channelmode:11,programchange:12,channelaftertouch:13,pitchbend:14},writable:!1,enumerable:!0,configurable:!1},MIDI_REGISTERED_PARAMETER:{value:{pitchbendrange:[0,0],channelfinetuning:[0,1],channelcoarsetuning:[0,2],tuningprogram:[0,3],tuningbank:[0,4],modulationrange:[0,5],azimuthangle:[61,0],elevationangle:[61,1],gain:[61,2],distanceratio:[61,3],maximumdistance:[61,4],maximumdistancegain:[61,5],referencedistanceratio:[61,6],panspreadangle:[61,7],rollangle:[61,8]},writable:!1,enumerable:!0,configurable:!1},MIDI_CONTROL_CHANGE_MESSAGES:{value:{bankselectcoarse:0,modulationwheelcoarse:1,breathcontrollercoarse:2,footcontrollercoarse:4,portamentotimecoarse:5,dataentrycoarse:6,volumecoarse:7,balancecoarse:8,pancoarse:10,expressioncoarse:11,effectcontrol1coarse:12,effectcontrol2coarse:13,generalpurposeslider1:16,generalpurposeslider2:17,generalpurposeslider3:18,generalpurposeslider4:19,bankselectfine:32,modulationwheelfine:33,breathcontrollerfine:34,footcontrollerfine:36,portamentotimefine:37,dataentryfine:38,volumefine:39,balancefine:40,panfine:42,expressionfine:43,effectcontrol1fine:44,effectcontrol2fine:45,holdpedal:64,portamento:65,sustenutopedal:66,softpedal:67,legatopedal:68,hold2pedal:69,soundvariation:70,resonance:71,soundreleasetime:72,soundattacktime:73,brightness:74,soundcontrol6:75,soundcontrol7:76,soundcontrol8:77,soundcontrol9:78,soundcontrol10:79,generalpurposebutton1:80,generalpurposebutton2:81,generalpurposebutton3:82,generalpurposebutton4:83,reverblevel:91,tremololevel:92,choruslevel:93,celestelevel:94,phaserlevel:95,databuttonincrement:96,databuttondecrement:97,nonregisteredparametercoarse:98,nonregisteredparameterfine:99,registeredparametercoarse:100,registeredparameterfine:101},writable:!1,enumerable:!0,configurable:!1},MIDI_CHANNEL_MODE_MESSAGES:{value:{allsoundoff:120,resetallcontrollers:121,localcontrol:122,allnotesoff:123,omnimodeoff:124,omnimodeon:125,monomodeon:126,polymodeon:127},writable:!1,enumerable:!0,configurable:!1},octaveOffset:{value:0,writable:!0,enumerable:!0,configurable:!1}}),Object.defineProperties(this,{supported:{enumerable:!0,get:function(){return"requestMIDIAccess"in navigator}},enabled:{enumerable:!0,get:function(){return void 0!==this["interface"]}.bind(this)},inputs:{enumerable:!0,get:function(){return this._inputs}.bind(this)},outputs:{enumerable:!0,get:function(){return this._outputs}.bind(this)},sysexEnabled:{enumerable:!0,get:function(){return!(!this["interface"]||!this["interface"].sysexEnabled)}.bind(this)},time:{enumerable:!0,get:function(){return performance.now()}}})}function Input(midiInput){var that=this;this._userHandlers={channel:{},system:{}},this._midiInput=midiInput,Object.defineProperties(this,{connection:{enumerable:!0,get:function(){return that._midiInput.connection}},id:{enumerable:!0,get:function(){return that._midiInput.id}},manufacturer:{enumerable:!0,get:function(){return that._midiInput.manufacturer}},name:{enumerable:!0,get:function(){return that._midiInput.name}},state:{enumerable:!0,get:function(){return that._midiInput.state}},type:{enumerable:!0,get:function(){return that._midiInput.type}}}),this._initializeUserHandlers(),this._midiInput.onmidimessage=this._onMidiMessage.bind(this)}function Output(midiOutput){var that=this;this._midiOutput=midiOutput,Object.defineProperties(this,{connection:{enumerable:!0,get:function(){return that._midiOutput.connection}},id:{enumerable:!0,get:function(){return that._midiOutput.id}},manufacturer:{enumerable:!0,get:function(){return that._midiOutput.manufacturer}},name:{enumerable:!0,get:function(){return that._midiOutput.name}},state:{enumerable:!0,get:function(){return that._midiOutput.state}},type:{enumerable:!0,get:function(){return that._midiOutput.type}}})}var wm=new WebMidi;WebMidi.prototype.enable=function(callback,sysex){return this.enabled?void 0:this.supported?void navigator.requestMIDIAccess({sysex:sysex}).then(function(midiAccess){function onPortsOpen(){clearTimeout(promiseTimeout),this._updateInputsAndOutputs(),this["interface"].onstatechange=this._onInterfaceStateChange.bind(this),"function"==typeof callback&&callback.call(this),events.forEach(function(event){this._onInterfaceStateChange(event)}.bind(this))}var promiseTimeout,events=[],promises=[];this["interface"]=midiAccess,this._resetInterfaceUserHandlers(),this["interface"].onstatechange=function(e){events.push(e)};for(var inputs=midiAccess.inputs.values(),input=inputs.next();input&&!input.done;input=inputs.next())promises.push(input.value.open());for(var outputs=midiAccess.outputs.values(),output=outputs.next();output&&!output.done;output=outputs.next())promises.push(output.value.open());promiseTimeout=setTimeout(onPortsOpen.bind(this),200),Promise&&Promise.all(promises)["catch"](function(err){}).then(onPortsOpen.bind(this))}.bind(this),function(err){"function"==typeof callback&&callback.call(this,err)}.bind(this)):void("function"==typeof callback&&callback(new Error("The Web MIDI API is not supported by your browser.")))},WebMidi.prototype.disable=function(){if(!this.supported)throw new Error("The Web MIDI API is not supported by your browser.");this["interface"]&&(this["interface"].onstatechange=void 0),this["interface"]=void 0,this._inputs=[],this._outputs=[],this._resetInterfaceUserHandlers()},WebMidi.prototype.addListener=function(type,listener){if(!this.enabled)throw new Error("WebMidi must be enabled before adding event listeners.");if("function"!=typeof listener)throw new TypeError("The 'listener' parameter must be a function.");if(!(this._midiInterfaceEvents.indexOf(type)>=0))throw new TypeError("The specified event type is not supported.");return this._userHandlers[type].push(listener),this},WebMidi.prototype.hasListener=function(type,listener){if(!this.enabled)throw new Error("WebMidi must be enabled before checking event listeners.");if("function"!=typeof listener)throw new TypeError("The 'listener' parameter must be a function.");if(!(this._midiInterfaceEvents.indexOf(type)>=0))throw new TypeError("The specified event type is not supported.");for(var o=0;o<this._userHandlers[type].length;o++)if(this._userHandlers[type][o]===listener)return!0;return!1},WebMidi.prototype.removeListener=function(type,listener){if(!this.enabled)throw new Error("WebMidi must be enabled before removing event listeners.");if(void 0!==listener&&"function"!=typeof listener)throw new TypeError("The 'listener' parameter must be a function.");if(this._midiInterfaceEvents.indexOf(type)>=0)if(listener)for(var o=0;o<this._userHandlers[type].length;o++)this._userHandlers[type][o]===listener&&this._userHandlers[type].splice(o,1);else this._userHandlers[type]=[];else{if(void 0!==type)throw new TypeError("The specified event type is not supported.");this._resetInterfaceUserHandlers()}return this},WebMidi.prototype.toMIDIChannels=function(channel){var channels;return channels="all"===channel||void 0===channel?["all"]:Array.isArray(channel)?channel:[channel],channels.indexOf("all")>-1&&(channels=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),channels.map(function(ch){return parseInt(ch)}).filter(function(ch){return ch>=1&&16>=ch})},WebMidi.prototype.getInputById=function(id){if(!this.enabled)throw new Error("WebMidi is not enabled.");for(var i=0;i<this.inputs.length;i++)if(this.inputs[i].id===id)return this.inputs[i];return!1},WebMidi.prototype.getOutputById=function(id){if(!this.enabled)throw new Error("WebMidi is not enabled.");for(var i=0;i<this.outputs.length;i++)if(this.outputs[i].id===id)return this.outputs[i];return!1},WebMidi.prototype.getInputByName=function(name){if(!this.enabled)throw new Error("WebMidi is not enabled.");for(var i=0;i<this.inputs.length;i++)if(~this.inputs[i].name.indexOf(name))return this.inputs[i];return!1},WebMidi.prototype.getOctave=function(number){return null!=number&&number>=0&&127>=number?Math.floor(Math.floor(number)/12-1)+Math.floor(wm.octaveOffset):void 0},WebMidi.prototype.getOutputByName=function(name){if(!this.enabled)throw new Error("WebMidi is not enabled.");for(var i=0;i<this.outputs.length;i++)if(~this.outputs[i].name.indexOf(name))return this.outputs[i];return!1},WebMidi.prototype.guessNoteNumber=function(input){var output=!1;if(input&&input.toFixed&&input>=0&&127>=input?output=Math.round(input):parseInt(input)>=0&&parseInt(input)<=127?output=parseInt(input):("string"==typeof input||input instanceof String)&&(output=this.noteNameToNumber(input)),output===!1)throw new Error("Invalid input value ("+input+").");return output},WebMidi.prototype.noteNameToNumber=function(name){"string"!=typeof name&&(name="");var matches=name.match(/([CDEFGAB])(#{0,2}|b{0,2})(-?\d+)/i);if(!matches)throw new RangeError("Invalid note name.");var semitones=wm._semitones[matches[1].toUpperCase()],octave=parseInt(matches[3]),result=12*(octave+1-Math.floor(wm.octaveOffset))+semitones;if(matches[2].toLowerCase().indexOf("b")>-1?result-=matches[2].length:matches[2].toLowerCase().indexOf("#")>-1&&(result+=matches[2].length),0>result||result>127)throw new RangeError("Invalid note name or note outside valid range.");return result},WebMidi.prototype._updateInputsAndOutputs=function(){this._updateInputs(),this._updateOutputs()},WebMidi.prototype._updateInputs=function(){for(var i=0;i<this._inputs.length;i++){for(var remove=!0,updated=this["interface"].inputs.values(),input=updated.next();input&&!input.done;input=updated.next())if(this._inputs[i]._midiInput===input.value){remove=!1;break}remove&&this._inputs.splice(i,1)}this["interface"]&&this["interface"].inputs.forEach(function(nInput){for(var add=!0,j=0;j<this._inputs.length;j++)this._inputs[j]._midiInput===nInput&&(add=!1);add&&this._inputs.push(new Input(nInput))}.bind(this))},WebMidi.prototype._updateOutputs=function(){for(var i=0;i<this._outputs.length;i++){for(var remove=!0,updated=this["interface"].outputs.values(),output=updated.next();output&&!output.done;output=updated.next())if(this._outputs[i]._midiOutput===output.value){remove=!1;break}remove&&this._outputs.splice(i,1)}this["interface"]&&this["interface"].outputs.forEach(function(nOutput){for(var add=!0,j=0;j<this._outputs.length;j++)this._outputs[j]._midiOutput===nOutput&&(add=!1);add&&this._outputs.push(new Output(nOutput))}.bind(this))},WebMidi.prototype._onInterfaceStateChange=function(e){this._updateInputsAndOutputs();var event={timestamp:e.timeStamp,type:e.port.state};this["interface"]&&"connected"===e.port.state?"output"===e.port.type?event.port=this.getOutputById(e.port.id):"input"===e.port.type&&(event.port=this.getInputById(e.port.id)):event.port={connection:"closed",id:e.port.id,manufacturer:e.port.manufacturer,name:e.port.name,state:e.port.state,type:e.port.type},this._userHandlers[e.port.state].forEach(function(handler){handler(event)})},WebMidi.prototype._resetInterfaceUserHandlers=function(){for(var i=0;i<this._midiInterfaceEvents.length;i++)this._userHandlers[this._midiInterfaceEvents[i]]=[]},Input.prototype.addListener=function(type,channel,listener){var that=this;if(void 0===channel&&(channel="all"),Array.isArray(channel)||(channel=[channel]),channel.forEach(function(item){if("all"!==item&&!(item>=1&&16>=item))throw new RangeError("The 'channel' parameter is invalid.")}),"function"!=typeof listener)throw new TypeError("The 'listener' parameter must be a function.");if(void 0!==wm.MIDI_SYSTEM_MESSAGES[type])this._userHandlers.system[type]||(this._userHandlers.system[type]=[]),this._userHandlers.system[type].push(listener);else{if(void 0===wm.MIDI_CHANNEL_MESSAGES[type])throw new TypeError("The specified event type is not supported.");if(channel.indexOf("all")>-1){channel=[];for(var j=1;16>=j;j++)channel.push(j)}this._userHandlers.channel[type]||(this._userHandlers.channel[type]=[]),channel.forEach(function(ch){that._userHandlers.channel[type][ch]||(that._userHandlers.channel[type][ch]=[]),that._userHandlers.channel[type][ch].push(listener)})}return this},Input.prototype.on=Input.prototype.addListener,Input.prototype.hasListener=function(type,channel,listener){var that=this;if("function"!=typeof listener)throw new TypeError("The 'listener' parameter must be a function.");if(void 0===channel&&(channel="all"),channel.constructor!==Array&&(channel=[channel]),void 0!==wm.MIDI_SYSTEM_MESSAGES[type]){for(var o=0;o<this._userHandlers.system[type].length;o++)if(this._userHandlers.system[type][o]===listener)return!0}else if(void 0!==wm.MIDI_CHANNEL_MESSAGES[type]){if(channel.indexOf("all")>-1){channel=[];for(var j=1;16>=j;j++)channel.push(j)}return this._userHandlers.channel[type]?channel.every(function(chNum){var listeners=that._userHandlers.channel[type][chNum];return listeners&&listeners.indexOf(listener)>-1}):!1}return!1},Input.prototype.removeListener=function(type,channel,listener){var that=this;if(void 0!==listener&&"function"!=typeof listener)throw new TypeError("The 'listener' parameter must be a function.");if(void 0===channel&&(channel="all"),channel.constructor!==Array&&(channel=[channel]),void 0!==wm.MIDI_SYSTEM_MESSAGES[type])if(void 0===listener)this._userHandlers.system[type]=[];else for(var o=0;o<this._userHandlers.system[type].length;o++)this._userHandlers.system[type][o]===listener&&this._userHandlers.system[type].splice(o,1);else if(void 0!==wm.MIDI_CHANNEL_MESSAGES[type]){if(channel.indexOf("all")>-1){channel=[];for(var j=1;16>=j;j++)channel.push(j)}if(!this._userHandlers.channel[type])return this;channel.forEach(function(chNum){var listeners=that._userHandlers.channel[type][chNum];if(listeners)if(void 0===listener)that._userHandlers.channel[type][chNum]=[];else for(var l=0;l<listeners.length;l++)listeners[l]===listener&&listeners.splice(l,1)})}else{if(void 0!==type)throw new TypeError("The specified event type is not supported.");this._initializeUserHandlers()}return this},Input.prototype._initializeUserHandlers=function(){for(var prop1 in wm.MIDI_CHANNEL_MESSAGES)wm.MIDI_CHANNEL_MESSAGES.hasOwnProperty(prop1)&&(this._userHandlers.channel[prop1]={});for(var prop2 in wm.MIDI_SYSTEM_MESSAGES)wm.MIDI_SYSTEM_MESSAGES.hasOwnProperty(prop2)&&(this._userHandlers.system[prop2]=[])},Input.prototype._onMidiMessage=function(e){if(this._userHandlers.system.midimessage.length>0){var event={target:this,data:e.data,timestamp:e.timeStamp,type:"midimessage"};this._userHandlers.system.midimessage.forEach(function(callback){callback(event)})}e.data[0]<240?this._parseChannelEvent(e):e.data[0]<=255&&this._parseSystemEvent(e)},Input.prototype._parseChannelEvent=function(e){var data1,data2,command=e.data[0]>>4,channel=(15&e.data[0])+1;e.data.length>1&&(data1=e.data[1],data2=e.data.length>2?e.data[2]:void 0);var event={target:this,data:e.data,timestamp:e.timeStamp,channel:channel};command===wm.MIDI_CHANNEL_MESSAGES.noteoff||command===wm.MIDI_CHANNEL_MESSAGES.noteon&&0===data2?(event.type="noteoff",event.note={number:data1,name:wm._notes[data1%12],octave:wm.getOctave(data1)},event.velocity=data2/127,event.rawVelocity=data2):command===wm.MIDI_CHANNEL_MESSAGES.noteon?(event.type="noteon",event.note={number:data1,name:wm._notes[data1%12],octave:wm.getOctave(data1)},event.velocity=data2/127,event.rawVelocity=data2):command===wm.MIDI_CHANNEL_MESSAGES.keyaftertouch?(event.type="keyaftertouch",event.note={number:data1,name:wm._notes[data1%12],octave:wm.getOctave(data1)},event.value=data2/127):command===wm.MIDI_CHANNEL_MESSAGES.controlchange&&data1>=0&&119>=data1?(event.type="controlchange",event.controller={number:data1,name:this.getCcNameByNumber(data1)},event.value=data2):command===wm.MIDI_CHANNEL_MESSAGES.channelmode&&data1>=120&&127>=data1?(event.type="channelmode",event.controller={number:data1,name:this.getChannelModeByNumber(data1)},event.value=data2):command===wm.MIDI_CHANNEL_MESSAGES.programchange?(event.type="programchange",event.value=data1):command===wm.MIDI_CHANNEL_MESSAGES.channelaftertouch?(event.type="channelaftertouch",event.value=data1/127):command===wm.MIDI_CHANNEL_MESSAGES.pitchbend?(event.type="pitchbend",event.value=((data2<<7)+data1-8192)/8192):event.type="unknownchannelmessage",this._userHandlers.channel[event.type]&&this._userHandlers.channel[event.type][channel]&&this._userHandlers.channel[event.type][channel].forEach(function(callback){callback(event)})},Input.prototype.getCcNameByNumber=function(number){if(number=Math.floor(number),!(number>=0&&119>=number))throw new RangeError("The control change number must be between 0 and 119.");for(var cc in wm.MIDI_CONTROL_CHANGE_MESSAGES)if(wm.MIDI_CONTROL_CHANGE_MESSAGES.hasOwnProperty(cc)&&number===wm.MIDI_CONTROL_CHANGE_MESSAGES[cc])return cc;return void 0},Input.prototype.getChannelModeByNumber=function(number){if(number=Math.floor(number),!(number>=120&&status<=127))throw new RangeError("The control change number must be between 120 and 127.");for(var cm in wm.MIDI_CHANNEL_MODE_MESSAGES)if(wm.MIDI_CHANNEL_MODE_MESSAGES.hasOwnProperty(cm)&&number===wm.MIDI_CHANNEL_MODE_MESSAGES[cm])return cm},Input.prototype._parseSystemEvent=function(e){var command=e.data[0],event={target:this,data:e.data,timestamp:e.timeStamp};command===wm.MIDI_SYSTEM_MESSAGES.sysex?event.type="sysex":command===wm.MIDI_SYSTEM_MESSAGES.timecode?event.type="timecode":command===wm.MIDI_SYSTEM_MESSAGES.songposition?event.type="songposition":command===wm.MIDI_SYSTEM_MESSAGES.songselect?(event.type="songselect",event.song=e.data[1]):command===wm.MIDI_SYSTEM_MESSAGES.tuningrequest?event.type="tuningrequest":command===wm.MIDI_SYSTEM_MESSAGES.clock?event.type="clock":command===wm.MIDI_SYSTEM_MESSAGES.start?event.type="start":command===wm.MIDI_SYSTEM_MESSAGES["continue"]?event.type="continue":command===wm.MIDI_SYSTEM_MESSAGES.stop?event.type="stop":command===wm.MIDI_SYSTEM_MESSAGES.activesensing?event.type="activesensing":command===wm.MIDI_SYSTEM_MESSAGES.reset?event.type="reset":event.type="unknownsystemmessage",this._userHandlers.system[event.type]&&this._userHandlers.system[event.type].forEach(function(callback){callback(event)})},Output.prototype.send=function(status,data,timestamp){if(!(status>=128&&255>=status))throw new RangeError("The status byte must be an integer between 128 (0x80) and 255 (0xFF).");void 0===data&&(data=[]),Array.isArray(data)||(data=[data]);var message=[];return data.forEach(function(item,index){var parsed=Math.floor(item);if(!(parsed>=0&&255>=parsed))throw new RangeError("Data bytes must be integers between 0 (0x00) and 255 (0xFF).");message.push(parsed)}),this._midiOutput.send([status].concat(message),parseFloat(timestamp)||0),this},Output.prototype.sendSysex=function(manufacturer,data,options){if(!wm.sysexEnabled)throw new Error("Sysex message support must first be activated.");return options=options||{},manufacturer=[].concat(manufacturer),data.forEach(function(item){if(0>item||item>127)throw new RangeError("The data bytes of a sysex message must be integers between 0 (0x00) and 127 (0x7F).")}),data=manufacturer.concat(data,wm.MIDI_SYSTEM_MESSAGES.sysexend),this.send(wm.MIDI_SYSTEM_MESSAGES.sysex,data,this._parseTimeParameter(options.time)),this},Output.prototype.sendTimecodeQuarterFrame=function(value,options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.timecode,value,this._parseTimeParameter(options.time)),this},Output.prototype.sendSongPosition=function(value,options){value=Math.floor(value)||0,options=options||{};var msb=value>>7&127,lsb=127&value;return this.send(wm.MIDI_SYSTEM_MESSAGES.songposition,[msb,lsb],this._parseTimeParameter(options.time)),this},Output.prototype.sendSongSelect=function(value,options){if(value=Math.floor(value),options=options||{},!(value>=0&&127>=value))throw new RangeError("The song number must be between 0 and 127.");return this.send(wm.MIDI_SYSTEM_MESSAGES.songselect,[value],this._parseTimeParameter(options.time)),this},Output.prototype.sendTuningRequest=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.tuningrequest,void 0,this._parseTimeParameter(options.time)),this},Output.prototype.sendClock=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.clock,void 0,this._parseTimeParameter(options.time)),this},Output.prototype.sendStart=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.start,void 0,this._parseTimeParameter(options.time)),this},Output.prototype.sendContinue=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES["continue"],void 0,this._parseTimeParameter(options.time)),this},Output.prototype.sendStop=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.stop,void 0,this._parseTimeParameter(options.time)),this},Output.prototype.sendActiveSensing=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.activesensing,[],this._parseTimeParameter(options.time)),this},Output.prototype.sendReset=function(options){return options=options||{},this.send(wm.MIDI_SYSTEM_MESSAGES.reset,void 0,this._parseTimeParameter(options.time)),this},Output.prototype.stopNote=function(note,channel,options){if("all"===note)return this.sendChannelMode("allnotesoff",0,channel,options);var nVelocity=64;return options=options||{},options.rawVelocity?!isNaN(options.velocity)&&options.velocity>=0&&options.velocity<=127&&(nVelocity=options.velocity):!isNaN(options.velocity)&&options.velocity>=0&&options.velocity<=1&&(nVelocity=127*options.velocity),this._convertNoteToArray(note).forEach(function(item){wm.toMIDIChannels(channel).forEach(function(ch){this.send((wm.MIDI_CHANNEL_MESSAGES.noteoff<<4)+(ch-1),[item,Math.round(nVelocity)],this._parseTimeParameter(options.time))}.bind(this))}.bind(this)),this},Output.prototype.playNote=function(note,channel,options){var nVelocity=64;if(options=options||{},options.rawVelocity?!isNaN(options.velocity)&&options.velocity>=0&&options.velocity<=127&&(nVelocity=options.velocity):!isNaN(options.velocity)&&options.velocity>=0&&options.velocity<=1&&(nVelocity=127*options.velocity),options.time=this._parseTimeParameter(options.time),this._convertNoteToArray(note).forEach(function(item){wm.toMIDIChannels(channel).forEach(function(ch){this.send((wm.MIDI_CHANNEL_MESSAGES.noteon<<4)+(ch-1),[item,Math.round(nVelocity)],options.time)}.bind(this))}.bind(this)),!isNaN(options.duration)){options.duration<=0&&(options.duration=0);var nRelease=64;options.rawVelocity?!isNaN(options.release)&&options.release>=0&&options.release<=127&&(nRelease=options.release):!isNaN(options.release)&&options.release>=0&&options.release<=1&&(nRelease=127*options.release),this._convertNoteToArray(note).forEach(function(item){wm.toMIDIChannels(channel).forEach(function(ch){this.send((wm.MIDI_CHANNEL_MESSAGES.noteoff<<4)+(ch-1),[item,Math.round(nRelease)],(options.time||wm.time)+options.duration)}.bind(this))}.bind(this))}return this},Output.prototype.sendKeyAftertouch=function(note,channel,pressure,options){var that=this;if(options=options||{},1>channel||channel>16)throw new RangeError("The channel must be between 1 and 16.");(isNaN(pressure)||0>pressure||pressure>1)&&(pressure=.5);var nPressure=Math.round(127*pressure);return this._convertNoteToArray(note).forEach(function(item){wm.toMIDIChannels(channel).forEach(function(ch){that.send((wm.MIDI_CHANNEL_MESSAGES.keyaftertouch<<4)+(ch-1),[item,nPressure],that._parseTimeParameter(options.time))})}),this},Output.prototype.sendControlChange=function(controller,value,channel,options){if(options=options||{},"string"==typeof controller){if(controller=wm.MIDI_CONTROL_CHANGE_MESSAGES[controller],!controller)throw new TypeError("Invalid controller name.")}else if(controller=Math.floor(controller),!(controller>=0&&119>=controller))throw new RangeError("Controller numbers must be between 0 and 119.");if(value=Math.floor(value)||0,!(value>=0&&127>=value))throw new RangeError("Controller value must be between 0 and 127.");return wm.toMIDIChannels(channel).forEach(function(ch){this.send((wm.MIDI_CHANNEL_MESSAGES.controlchange<<4)+(ch-1),[controller,value],this._parseTimeParameter(options.time))}.bind(this)),this},Output.prototype._selectRegisteredParameter=function(parameter,channel,time){var that=this;if(parameter[0]=Math.floor(parameter[0]),!(parameter[0]>=0&¶meter[0]<=127))throw new RangeError("The control65 value must be between 0 and 127");if(parameter[1]=Math.floor(parameter[1]),!(parameter[1]>=0&¶meter[1]<=127))throw new RangeError("The control64 value must be between 0 and 127");return wm.toMIDIChannels(channel).forEach(function(ch){that.sendControlChange(101,parameter[0],channel,{time:time}),that.sendControlChange(100,parameter[1],channel,{time:time})}),this},Output.prototype._selectNonRegisteredParameter=function(parameter,channel,time){var that=this;if(parameter[0]=Math.floor(parameter[0]),!(parameter[0]>=0&¶meter[0]<=127))throw new RangeError("The control63 value must be between 0 and 127");if(parameter[1]=Math.floor(parameter[1]),!(parameter[1]>=0&¶meter[1]<=127))throw new RangeError("The control62 value must be between 0 and 127");return wm.toMIDIChannels(channel).forEach(function(ch){that.sendControlChange(99,parameter[0],channel,{time:time}),that.sendControlChange(98,parameter[1],channel,{time:time})}),this},Output.prototype._setCurrentRegisteredParameter=function(data,channel,time){var that=this;if(data=[].concat(data),data[0]=Math.floor(data[0]),!(data[0]>=0&&data[0]<=127))throw new RangeError("The msb value must be between 0 and 127");return wm.toMIDIChannels(channel).forEach(function(ch){that.sendControlChange(6,data[0],channel,{time:time})}),data[1]=Math.floor(data[1]),data[1]>=0&&data[1]<=127&&wm.toMIDIChannels(channel).forEach(function(ch){that.sendControlChange(38,data[1],channel,{time:time})}),this},Output.prototype._deselectRegisteredParameter=function(channel,time){var that=this;return wm.toMIDIChannels(channel).forEach(function(ch){that.sendControlChange(101,127,channel,{time:time}),that.sendControlChange(100,127,channel,{time:time})}),this},Output.prototype.setRegisteredParameter=function(parameter,data,channel,options){var that=this;if(options=options||{},!Array.isArray(parameter)){if(!wm.MIDI_REGISTERED_PARAMETER[parameter])throw new Error("The specified parameter is not available.");parameter=wm.MIDI_REGISTERED_PARAMETER[parameter]}return wm.toMIDIChannels(channel).forEach(function(ch){that._selectRegisteredParameter(parameter,channel,options.time),that._setCurrentRegisteredParameter(data,channel,options.time),that._deselectRegisteredParameter(channel,options.time)}),this},Output.prototype.setNonRegisteredParameter=function(parameter,data,channel,options){var that=this;if(options=options||{},!(parameter[0]>=0&¶meter[0]<=127&¶meter[1]>=0&¶meter[1]<=127))throw new Error("Position 0 and 1 of the 2-position parameter array must both be between 0 and 127.");return data=[].concat(data),wm.toMIDIChannels(channel).forEach(function(ch){that._selectNonRegisteredParameter(parameter,channel,options.time),that._setCurrentRegisteredParameter(data,channel,options.time),that._deselectRegisteredParameter(channel,options.time)}),this},Output.prototype.incrementRegisteredParameter=function(parameter,channel,options){var that=this;if(options=options||{},!Array.isArray(parameter)){if(!wm.MIDI_REGISTERED_PARAMETER[parameter])throw new Error("The specified parameter is not available.");parameter=wm.MIDI_REGISTERED_PARAMETER[parameter]}return wm.toMIDIChannels(channel).forEach(function(ch){that._selectRegisteredParameter(parameter,channel,options.time),that.sendControlChange(96,0,channel,{time:options.time}),that._deselectRegisteredParameter(channel,options.time)}),this},Output.prototype.decrementRegisteredParameter=function(parameter,channel,options){if(options=options||{},!Array.isArray(parameter)){if(!wm.MIDI_REGISTERED_PARAMETER[parameter])throw new TypeError("The specified parameter is not available.");parameter=wm.MIDI_REGISTERED_PARAMETER[parameter]}return wm.toMIDIChannels(channel).forEach(function(ch){this._selectRegisteredParameter(parameter,channel,options.time),this.sendControlChange(97,0,channel,{time:options.time}),this._deselectRegisteredParameter(channel,options.time)}.bind(this)),this},Output.prototype.setPitchBendRange=function(semitones,cents,channel,options){var that=this;if(options=options||{},semitones=Math.floor(semitones)||0,!(semitones>=0&&127>=semitones))throw new RangeError("The semitones value must be between 0 and 127");if(cents=Math.floor(cents)||0,!(cents>=0&&127>=cents))throw new RangeError("The cents value must be between 0 and 127");return wm.toMIDIChannels(channel).forEach(function(ch){that.setRegisteredParameter("pitchbendrange",[semitones,cents],channel,{time:options.time})}),this},Output.prototype.setModulationRange=function(semitones,cents,channel,options){var that=this;if(options=options||{},semitones=Math.floor(semitones)||0,!(semitones>=0&&127>=semitones))throw new RangeError("The semitones value must be between 0 and 127");if(cents=Math.floor(cents)||0,!(cents>=0&&127>=cents))throw new RangeError("The cents value must be between 0 and 127");return wm.toMIDIChannels(channel).forEach(function(ch){that.setRegisteredParameter("modulationrange",[semitones,cents],channel,{time:options.time})}),this},Output.prototype.setMasterTuning=function(value,channel,options){var that=this;if(options=options||{},value=parseFloat(value)||0,-65>=value||value>=64)throw new RangeError("The value must be a decimal number larger than -65 and smaller than 64.");var coarse=Math.floor(value)+64,fine=value-Math.floor(value);fine=Math.round((fine+1)/2*16383);var msb=fine>>7&127,lsb=127&fine;return wm.toMIDIChannels(channel).forEach(function(ch){that.setRegisteredParameter("channelcoarsetuning",coarse,channel,{time:options.time}),that.setRegisteredParameter("channelfinetuning",[msb,lsb],channel,{time:options.time})}),this},Output.prototype.setTuningProgram=function(value,channel,options){var that=this;if(options=options||{},value=Math.floor(value),!(value>=0&&127>=value))throw new RangeError("The program value must be between 0 and 127");return wm.toMIDIChannels(channel).forEach(function(ch){that.setRegisteredParameter("tuningprogram",value,channel,{time:options.time})}),this},Output.prototype.setTuningBank=function(value,channel,options){var that=this;if(options=options||{},value=Math.floor(value)||0,!(value>=0&&127>=value))throw new RangeError("The bank value must be between 0 and 127");return wm.toMIDIChannels(channel).forEach(function(ch){that.setRegisteredParameter("tuningbank",value,channel,{time:options.time})}),this},Output.prototype.sendChannelMode=function(command,value,channel,options){if(options=options||{},"string"==typeof command){if(command=wm.MIDI_CHANNEL_MODE_MESSAGES[command],!command)throw new TypeError("Invalid channel mode message name.")}else if(command=Math.floor(command),!(command>=120&&127>=command))throw new RangeError("Channel mode numerical identifiers must be between 120 and 127.");if(value=Math.floor(value)||0,0>value||value>127)throw new RangeError("Value must be an integer between 0 and 127.");return wm.toMIDIChannels(channel).forEach(function(ch){this.send((wm.MIDI_CHANNEL_MESSAGES.channelmode<<4)+(ch-1),[command,value],this._parseTimeParameter(options.time))}.bind(this)),this},Output.prototype.sendProgramChange=function(program,channel,options){ +var that=this;if(options=options||{},program=Math.floor(program),isNaN(program)||0>program||program>127)throw new RangeError("Program numbers must be between 0 and 127.");return wm.toMIDIChannels(channel).forEach(function(ch){that.send((wm.MIDI_CHANNEL_MESSAGES.programchange<<4)+(ch-1),[program],that._parseTimeParameter(options.time))}),this},Output.prototype.sendChannelAftertouch=function(pressure,channel,options){var that=this;options=options||{},pressure=parseFloat(pressure),(isNaN(pressure)||0>pressure||pressure>1)&&(pressure=.5);var nPressure=Math.round(127*pressure);return wm.toMIDIChannels(channel).forEach(function(ch){that.send((wm.MIDI_CHANNEL_MESSAGES.channelaftertouch<<4)+(ch-1),[nPressure],that._parseTimeParameter(options.time))}),this},Output.prototype.sendPitchBend=function(bend,channel,options){var that=this;if(options=options||{},isNaN(bend)||-1>bend||bend>1)throw new RangeError("Pitch bend value must be between -1 and 1.");var nLevel=Math.round((bend+1)/2*16383),msb=nLevel>>7&127,lsb=127&nLevel;return wm.toMIDIChannels(channel).forEach(function(ch){that.send((wm.MIDI_CHANNEL_MESSAGES.pitchbend<<4)+(ch-1),[lsb,msb],that._parseTimeParameter(options.time))}),this},Output.prototype._parseTimeParameter=function(time){var parsed,value;return"string"==typeof time&&"+"===time.substring(0,1)?(parsed=parseFloat(time),parsed&&parsed>0&&(value=wm.time+parsed)):(parsed=parseFloat(time),parsed>wm.time&&(value=parsed)),value},Output.prototype._convertNoteToArray=function(note){var notes=[];return Array.isArray(note)||(note=[note]),note.forEach(function(item){notes.push(wm.guessNoteNumber(item))}),notes}, true?!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function(){return wm}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)):"undefined"!=typeof module&&module.exports?module.exports=wm:scope.WebMidi||(scope.WebMidi=wm)}(this); + +/***/ }) +/******/ ]); +//# sourceMappingURL=bundle.js.map
\ No newline at end of file |
