music21j-port
Version:
A toolkit for computer-aided musicology, Javascript version
1,737 lines (1,513 loc) • 898 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["Vex"] = factory();
else
root["Vex"] = factory();
})(typeof self !== 'undefined' ? self : 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] = {
/******/ 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;
/******/
/******/ // 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 = 64);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
// [VexFlow](http://vexflow.com) - Copyright (c) Mohit Muthanna 2010.
//
// ## Description
// This file implements utility methods used by the rest of the VexFlow
// codebase.
//
var Vex = function Vex() {};
// Default log function sends all arguments to console.
Vex.L = function (block, args) {
if (!args) return;
var line = Array.prototype.slice.call(args).join(' ');
window.console.log(block + ': ' + line);
};
Vex.MakeException = function (name) {
var exception = function (_Error) {
_inherits(exception, _Error);
function exception(message, data) {
_classCallCheck(this, exception);
var _this = _possibleConstructorReturn(this, (exception.__proto__ || Object.getPrototypeOf(exception)).call(this, message));
_this.name = name;
_this.message = message;
_this.data = data;
return _this;
}
return exception;
}(Error);
return exception;
};
// Default runtime exception.
var RuntimeError = function () {
function RuntimeError(code, message) {
_classCallCheck(this, RuntimeError);
this.code = code;
this.message = message;
}
_createClass(RuntimeError, [{
key: 'toString',
value: function toString() {
return '[RuntimeError] ' + this.code + ':' + this.message;
}
}]);
return RuntimeError;
}();
// Shortcut method for `RuntimeError`.
Vex.RuntimeError = RuntimeError;
Vex.RERR = Vex.RuntimeError;
// Merge `destination` hash with `source` hash, overwriting like keys
// in `source` if necessary.
Vex.Merge = function (destination, source) {
for (var property in source) {
// eslint-disable-line guard-for-in
destination[property] = source[property];
}
return destination;
};
// DEPRECATED. Use `Math.*`.
Vex.Min = Math.min;
Vex.Max = Math.max;
Vex.forEach = function (a, fn) {
for (var i = 0; i < a.length; i++) {
fn(a[i], i);
}
};
// Round number to nearest fractional value (`.5`, `.25`, etc.)
Vex.RoundN = function (x, n) {
return x % n >= n / 2 ? parseInt(x / n, 10) * n + n : parseInt(x / n, 10) * n;
};
// Locate the mid point between stave lines. Returns a fractional line if a space.
Vex.MidLine = function (a, b) {
var mid_line = b + (a - b) / 2;
if (mid_line % 2 > 0) {
mid_line = Vex.RoundN(mid_line * 10, 5) / 10;
}
return mid_line;
};
// Take `arr` and return a new list consisting of the sorted, unique,
// contents of arr. Does not modify `arr`.
Vex.SortAndUnique = function (arr, cmp, eq) {
if (arr.length > 1) {
var newArr = [];
var last = void 0;
arr.sort(cmp);
for (var i = 0; i < arr.length; ++i) {
if (i === 0 || !eq(arr[i], last)) {
newArr.push(arr[i]);
}
last = arr[i];
}
return newArr;
} else {
return arr;
}
};
// Check if array `a` contains `obj`.
Vex.Contains = function (a, obj) {
var i = a.length;
while (i--) {
if (a[i] === obj) {
return true;
}
}
return false;
};
// Get the 2D Canvas context from DOM element `canvas_sel`.
Vex.getCanvasContext = function (canvas_sel) {
if (!canvas_sel) {
throw new Vex.RERR('BadArgument', 'Invalid canvas selector: ' + canvas_sel);
}
var canvas = document.getElementById(canvas_sel);
if (!(canvas && canvas.getContext)) {
throw new Vex.RERR('UnsupportedBrowserError', 'This browser does not support HTML5 Canvas');
}
return canvas.getContext('2d');
};
// Draw a tiny dot marker on the specified canvas. A great debugging aid.
//
// `ctx`: Canvas context.
// `x`, `y`: Dot coordinates.
Vex.drawDot = function (ctx, x, y) {
var color = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '#55';
ctx.save();
ctx.setFillStyle(color);
// draw a circle
ctx.beginPath();
ctx.arc(x, y, 3, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fill();
ctx.restore();
};
// Benchmark. Run function `f` once and report time elapsed shifted by `s` milliseconds.
Vex.BM = function (s, f) {
var start_time = new Date().getTime();
f();
var elapsed = new Date().getTime() - start_time;
Vex.L(s + elapsed + 'ms');
};
// Get stack trace.
Vex.StackTrace = function () {
var err = new Error();
return err.stack;
};
// Dump warning to console.
Vex.W = function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var line = args.join(' ');
window.console.log('Warning: ', line, Vex.StackTrace());
};
// Used by various classes (e.g., SVGContext) to provide a
// unique prefix to element names (or other keys in shared namespaces).
Vex.Prefix = function (text) {
return Vex.Prefix.prefix + text;
};
Vex.Prefix.prefix = 'vf-';
exports.Vex = Vex;
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Flow = 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; }; // [VexFlow](http://vexflow.com) - Copyright (c) Mohit Muthanna 2010.
/* eslint-disable key-spacing */
var _vex = __webpack_require__(0);
var _fraction = __webpack_require__(8);
var _glyph = __webpack_require__(2);
var Flow = {
STEM_WIDTH: 1.5,
STEM_HEIGHT: 35,
STAVE_LINE_THICKNESS: 1,
RESOLUTION: 16384,
DEFAULT_NOTATION_FONT_SCALE: 39,
DEFAULT_TABLATURE_FONT_SCALE: 39,
SLASH_NOTEHEAD_WIDTH: 15,
// HACK:
// Since text origins are positioned at the baseline, we must
// compensate for the ascender of the text. Of course, 1 staff space is
// a very poor approximation.
//
// This will be deprecated in the future. This is a temporary solution until
// we have more robust text metrics.
TEXT_HEIGHT_OFFSET_HACK: 1,
/* Kerning (DEPRECATED) */
IsKerned: true
};
Flow.clefProperties = function (clef) {
if (!clef) throw new _vex.Vex.RERR('BadArgument', 'Invalid clef: ' + clef);
var props = Flow.clefProperties.values[clef];
if (!props) throw new _vex.Vex.RERR('BadArgument', 'Invalid clef: ' + clef);
return props;
};
Flow.clefProperties.values = {
'treble': { line_shift: 0 },
'bass': { line_shift: 6 },
'tenor': { line_shift: 4 },
'alto': { line_shift: 3 },
'soprano': { line_shift: 1 },
'percussion': { line_shift: 0 },
'mezzo-soprano': { line_shift: 2 },
'baritone-c': { line_shift: 5 },
'baritone-f': { line_shift: 5 },
'subbass': { line_shift: 7 },
'french': { line_shift: -1 }
};
/*
Take a note in the format "Key/Octave" (e.g., "C/5") and return properties.
The last argument, params, is a struct the currently can contain one option,
octave_shift for clef ottavation (0 = default; 1 = 8va; -1 = 8vb, etc.).
*/
Flow.keyProperties = function (key, clef, params) {
if (clef === undefined) {
clef = 'treble';
}
var options = { octave_shift: 0 };
if ((typeof params === 'undefined' ? 'undefined' : _typeof(params)) === 'object') {
_vex.Vex.Merge(options, params);
}
var pieces = key.split('/');
if (pieces.length < 2) {
throw new _vex.Vex.RERR('BadArguments', 'Key must have note + octave and an optional glyph: ' + key);
}
var k = pieces[0].toUpperCase();
var value = Flow.keyProperties.note_values[k];
if (!value) throw new _vex.Vex.RERR('BadArguments', 'Invalid key name: ' + k);
if (value.octave) pieces[1] = value.octave;
var octave = parseInt(pieces[1], 10);
// Octave_shift is the shift to compensate for clef 8va/8vb.
octave += -1 * options.octave_shift;
var base_index = octave * 7 - 4 * 7;
var line = (base_index + value.index) / 2;
line += Flow.clefProperties(clef).line_shift;
var stroke = 0;
if (line <= 0 && line * 2 % 2 === 0) stroke = 1; // stroke up
if (line >= 6 && line * 2 % 2 === 0) stroke = -1; // stroke down
// Integer value for note arithmetic.
var int_value = typeof value.int_val !== 'undefined' ? octave * 12 + value.int_val : null;
/* Check if the user specified a glyph. */
var code = value.code;
var shift_right = value.shift_right;
if (pieces.length > 2 && pieces[2]) {
var glyph_name = pieces[2].toUpperCase();
var note_glyph = Flow.keyProperties.note_glyph[glyph_name];
if (note_glyph) {
code = note_glyph.code;
shift_right = note_glyph.shift_right;
}
}
return {
key: k,
octave: octave,
line: line,
int_value: int_value,
accidental: value.accidental,
code: code,
stroke: stroke,
shift_right: shift_right,
displaced: false
};
};
Flow.keyProperties.note_values = {
'C': { index: 0, int_val: 0, accidental: null },
'CN': { index: 0, int_val: 0, accidental: 'n' },
'C#': { index: 0, int_val: 1, accidental: '#' },
'C##': { index: 0, int_val: 2, accidental: '##' },
'CB': { index: 0, int_val: -1, accidental: 'b' },
'CBB': { index: 0, int_val: -2, accidental: 'bb' },
'D': { index: 1, int_val: 2, accidental: null },
'DN': { index: 1, int_val: 2, accidental: 'n' },
'D#': { index: 1, int_val: 3, accidental: '#' },
'D##': { index: 1, int_val: 4, accidental: '##' },
'DB': { index: 1, int_val: 1, accidental: 'b' },
'DBB': { index: 1, int_val: 0, accidental: 'bb' },
'E': { index: 2, int_val: 4, accidental: null },
'EN': { index: 2, int_val: 4, accidental: 'n' },
'E#': { index: 2, int_val: 5, accidental: '#' },
'E##': { index: 2, int_val: 6, accidental: '##' },
'EB': { index: 2, int_val: 3, accidental: 'b' },
'EBB': { index: 2, int_val: 2, accidental: 'bb' },
'F': { index: 3, int_val: 5, accidental: null },
'FN': { index: 3, int_val: 5, accidental: 'n' },
'F#': { index: 3, int_val: 6, accidental: '#' },
'F##': { index: 3, int_val: 7, accidental: '##' },
'FB': { index: 3, int_val: 4, accidental: 'b' },
'FBB': { index: 3, int_val: 3, accidental: 'bb' },
'G': { index: 4, int_val: 7, accidental: null },
'GN': { index: 4, int_val: 7, accidental: 'n' },
'G#': { index: 4, int_val: 8, accidental: '#' },
'G##': { index: 4, int_val: 9, accidental: '##' },
'GB': { index: 4, int_val: 6, accidental: 'b' },
'GBB': { index: 4, int_val: 5, accidental: 'bb' },
'A': { index: 5, int_val: 9, accidental: null },
'AN': { index: 5, int_val: 9, accidental: 'n' },
'A#': { index: 5, int_val: 10, accidental: '#' },
'A##': { index: 5, int_val: 11, accidental: '##' },
'AB': { index: 5, int_val: 8, accidental: 'b' },
'ABB': { index: 5, int_val: 7, accidental: 'bb' },
'B': { index: 6, int_val: 11, accidental: null },
'BN': { index: 6, int_val: 11, accidental: 'n' },
'B#': { index: 6, int_val: 12, accidental: '#' },
'B##': { index: 6, int_val: 13, accidental: '##' },
'BB': { index: 6, int_val: 10, accidental: 'b' },
'BBB': { index: 6, int_val: 9, accidental: 'bb' },
'R': { index: 6, int_val: 9, rest: true }, // Rest
'X': {
index: 6,
accidental: '',
octave: 4,
code: 'v3e',
shift_right: 5.5
}
};
Flow.keyProperties.note_glyph = {
/* Diamond */
'D0': { code: 'v27', shift_right: -0.5 },
'D1': { code: 'v2d', shift_right: -0.5 },
'D2': { code: 'v22', shift_right: -0.5 },
'D3': { code: 'v70', shift_right: -0.5 },
/* Triangle */
'T0': { code: 'v49', shift_right: -2 },
'T1': { code: 'v93', shift_right: 0.5 },
'T2': { code: 'v40', shift_right: 0.5 },
'T3': { code: 'v7d', shift_right: 0.5 },
/* Cross */
'X0': { code: 'v92', shift_right: -2 },
'X1': { code: 'v95', shift_right: -0.5 },
'X2': { code: 'v7f', shift_right: 0.5 },
'X3': { code: 'v3b', shift_right: -2 }
};
Flow.integerToNote = function (integer) {
if (typeof integer === 'undefined') {
throw new _vex.Vex.RERR('BadArguments', 'Undefined integer for integerToNote');
}
if (integer < -2) {
throw new _vex.Vex.RERR('BadArguments', 'integerToNote requires integer > -2: ' + integer);
}
var noteValue = Flow.integerToNote.table[integer];
if (!noteValue) {
throw new _vex.Vex.RERR('BadArguments', 'Unknown note value for integer: ' + integer);
}
return noteValue;
};
Flow.integerToNote.table = {
0: 'C',
1: 'C#',
2: 'D',
3: 'D#',
4: 'E',
5: 'F',
6: 'F#',
7: 'G',
8: 'G#',
9: 'A',
10: 'A#',
11: 'B'
};
Flow.tabToGlyph = function (fret) {
var scale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1.0;
var glyph = null;
var width = 0;
var shift_y = 0;
if (fret.toString().toUpperCase() === 'X') {
var glyphMetrics = new _glyph.Glyph('v7f', Flow.DEFAULT_TABLATURE_FONT_SCALE).getMetrics();
glyph = 'v7f';
width = glyphMetrics.width;
shift_y = -glyphMetrics.height / 2;
} else {
width = Flow.textWidth(fret.toString());
}
return {
text: fret,
code: glyph,
getWidth: function getWidth() {
return width * scale;
},
shift_y: shift_y
};
};
Flow.textWidth = function (text) {
return 7 * text.toString().length;
};
Flow.articulationCodes = function (artic) {
return Flow.articulationCodes.articulations[artic];
};
Flow.articulationCodes.articulations = {
'a.': { code: 'v23', between_lines: true }, // Staccato
'av': { code: 'v28', between_lines: true }, // Staccatissimo
'a>': { code: 'v42', between_lines: true }, // Accent
'a-': { code: 'v25', between_lines: true }, // Tenuto
'a^': { code: 'va', between_lines: false }, // Marcato
'a+': { code: 'v8b', between_lines: false }, // Left hand pizzicato
'ao': { code: 'v94', between_lines: false }, // Snap pizzicato
'ah': { code: 'vb9', between_lines: false }, // Natural harmonic or open note
'a@a': { code: 'v43', between_lines: false }, // Fermata above staff
'a@u': { code: 'v5b', between_lines: false }, // Fermata below staff
'a|': { code: 'v75', between_lines: false }, // Bow up - up stroke
'am': { code: 'v97', between_lines: false }, // Bow down - down stroke
'a,': { code: 'vb3', between_lines: false } // Choked
};
Flow.accidentalCodes = function (acc) {
return Flow.accidentalCodes.accidentals[acc];
};
Flow.accidentalCodes.accidentals = {
'#': { code: 'v18', parenRightPaddingAdjustment: -1 },
'##': { code: 'v7f', parenRightPaddingAdjustment: -1 },
'b': { code: 'v44', parenRightPaddingAdjustment: -2 },
'bb': { code: 'v26', parenRightPaddingAdjustment: -2 },
'n': { code: 'v4e', parenRightPaddingAdjustment: -1 },
'{': { code: 'v9c', parenRightPaddingAdjustment: -1 },
'}': { code: 'v84', parenRightPaddingAdjustment: -1 },
'db': { code: 'v9e', parenRightPaddingAdjustment: -1 },
'd': { code: 'vab', parenRightPaddingAdjustment: 0 },
'bbs': { code: 'v90', parenRightPaddingAdjustment: -1 },
'++': { code: 'v51', parenRightPaddingAdjustment: -1 },
'+': { code: 'v78', parenRightPaddingAdjustment: -1 },
'+-': { code: 'v8d', parenRightPaddingAdjustment: -1 },
'++-': { code: 'v7a', parenRightPaddingAdjustment: -1 },
'bs': { code: 'vb7', parenRightPaddingAdjustment: -1 },
'bss': { code: 'v39', parenRightPaddingAdjustment: -1 },
'o': { code: 'vd0', parenRightPaddingAdjustment: -1 },
'k': { code: 'vd1', parenRightPaddingAdjustment: -1 }
};
Flow.accidentalColumnsTable = {
1: {
a: [1],
b: [1]
},
2: {
a: [1, 2]
},
3: {
a: [1, 3, 2],
b: [1, 2, 1],
second_on_bottom: [1, 2, 3]
},
4: {
a: [1, 3, 4, 2],
b: [1, 2, 3, 1],
spaced_out_tetrachord: [1, 2, 1, 2]
},
5: {
a: [1, 3, 5, 4, 2],
b: [1, 2, 4, 3, 1],
spaced_out_pentachord: [1, 2, 3, 2, 1],
very_spaced_out_pentachord: [1, 2, 1, 2, 1] },
6: {
a: [1, 3, 5, 6, 4, 2],
b: [1, 2, 4, 5, 3, 1],
spaced_out_hexachord: [1, 3, 2, 1, 3, 2],
very_spaced_out_hexachord: [1, 2, 1, 2, 1, 2]
}
};
Flow.ornamentCodes = function (acc) {
return Flow.ornamentCodes.ornaments[acc];
};
Flow.ornamentCodes.ornaments = {
'mordent': { code: 'v1e' },
'mordent_inverted': { code: 'v45' },
'turn': { code: 'v72' },
'turn_inverted': { code: 'v33' },
'tr': { code: 'v1f' },
'upprall': { code: 'v60' },
'downprall': { code: 'vb4' },
'prallup': { code: 'v6d' },
'pralldown': { code: 'v2c' },
'upmordent': { code: 'v29' },
'downmordent': { code: 'v68' },
'lineprall': { code: 'v20' },
'prallprall': { code: 'v86' }
};
Flow.keySignature = function (spec) {
var keySpec = Flow.keySignature.keySpecs[spec];
if (!keySpec) {
throw new _vex.Vex.RERR('BadKeySignature', 'Bad key signature spec: \'' + spec + '\'');
}
if (!keySpec.acc) {
return [];
}
var notes = Flow.keySignature.accidentalList(keySpec.acc);
var acc_list = [];
for (var i = 0; i < keySpec.num; ++i) {
var line = notes[i];
acc_list.push({ type: keySpec.acc, line: line });
}
return acc_list;
};
Flow.keySignature.keySpecs = {
'C': { acc: null, num: 0 },
'Am': { acc: null, num: 0 },
'F': { acc: 'b', num: 1 },
'Dm': { acc: 'b', num: 1 },
'Bb': { acc: 'b', num: 2 },
'Gm': { acc: 'b', num: 2 },
'Eb': { acc: 'b', num: 3 },
'Cm': { acc: 'b', num: 3 },
'Ab': { acc: 'b', num: 4 },
'Fm': { acc: 'b', num: 4 },
'Db': { acc: 'b', num: 5 },
'Bbm': { acc: 'b', num: 5 },
'Gb': { acc: 'b', num: 6 },
'Ebm': { acc: 'b', num: 6 },
'Cb': { acc: 'b', num: 7 },
'Abm': { acc: 'b', num: 7 },
'G': { acc: '#', num: 1 },
'Em': { acc: '#', num: 1 },
'D': { acc: '#', num: 2 },
'Bm': { acc: '#', num: 2 },
'A': { acc: '#', num: 3 },
'F#m': { acc: '#', num: 3 },
'E': { acc: '#', num: 4 },
'C#m': { acc: '#', num: 4 },
'B': { acc: '#', num: 5 },
'G#m': { acc: '#', num: 5 },
'F#': { acc: '#', num: 6 },
'D#m': { acc: '#', num: 6 },
'C#': { acc: '#', num: 7 },
'A#m': { acc: '#', num: 7 }
};
Flow.unicode = {
// Unicode accidentals
'sharp': String.fromCharCode(parseInt('266F', 16)),
'flat': String.fromCharCode(parseInt('266D', 16)),
'natural': String.fromCharCode(parseInt('266E', 16)),
// Major Chord
'triangle': String.fromCharCode(parseInt('25B3', 16)),
// half-diminished
'o-with-slash': String.fromCharCode(parseInt('00F8', 16)),
// Diminished
'degrees': String.fromCharCode(parseInt('00B0', 16)),
'circle': String.fromCharCode(parseInt('25CB', 16))
};
Flow.keySignature.accidentalList = function (acc) {
var patterns = {
'b': [2, 0.5, 2.5, 1, 3, 1.5, 3.5],
'#': [0, 1.5, -0.5, 1, 2.5, 0.5, 2]
};
return patterns[acc];
};
Flow.parseNoteDurationString = function (durationString) {
if (typeof durationString !== 'string') {
return null;
}
var regexp = /(\d*\/?\d+|[a-z])(d*)([nrhms]|$)/;
var result = regexp.exec(durationString);
if (!result) {
return null;
}
var duration = result[1];
var dots = result[2].length;
var type = result[3];
if (type.length === 0) {
type = 'n';
}
return {
duration: duration,
dots: dots,
type: type
};
};
Flow.parseNoteData = function (noteData) {
var duration = noteData.duration;
// Preserve backwards-compatibility
var durationStringData = Flow.parseNoteDurationString(duration);
if (!durationStringData) {
return null;
}
var ticks = Flow.durationToTicks(durationStringData.duration);
if (ticks == null) {
return null;
}
var type = noteData.type;
if (type) {
if (!(type === 'n' || type === 'r' || type === 'h' || type === 'm' || type === 's')) {
return null;
}
} else {
type = durationStringData.type;
if (!type) {
type = 'n';
}
}
var dots = noteData.dots ? noteData.dots : durationStringData.dots;
if (typeof dots !== 'number') {
return null;
}
var currentTicks = ticks;
for (var i = 0; i < dots; i++) {
if (currentTicks <= 1) return null;
currentTicks = currentTicks / 2;
ticks += currentTicks;
}
return {
duration: durationStringData.duration,
type: type,
dots: dots,
ticks: ticks
};
};
// Used to convert duration aliases to the number based duration.
// If the input isn't an alias, simply return the input.
//
// example: 'q' -> '4', '8' -> '8'
Flow.sanitizeDuration = function (duration) {
var alias = Flow.durationAliases[duration];
if (alias !== undefined) {
duration = alias;
}
if (Flow.durationToTicks.durations[duration] === undefined) {
throw new _vex.Vex.RERR('BadArguments', 'The provided duration is not valid: ' + duration);
}
return duration;
};
// Convert the `duration` to an fraction
Flow.durationToFraction = function (duration) {
return new _fraction.Fraction().parse(Flow.sanitizeDuration(duration));
};
// Convert the `duration` to an number
Flow.durationToNumber = function (duration) {
return Flow.durationToFraction(duration).value();
};
// Convert the `duration` to total ticks
Flow.durationToTicks = function (duration) {
duration = Flow.sanitizeDuration(duration);
var ticks = Flow.durationToTicks.durations[duration];
if (ticks === undefined) {
return null;
}
return ticks;
};
Flow.durationToTicks.durations = {
'1/2': Flow.RESOLUTION * 2,
'1': Flow.RESOLUTION / 1,
'2': Flow.RESOLUTION / 2,
'4': Flow.RESOLUTION / 4,
'8': Flow.RESOLUTION / 8,
'16': Flow.RESOLUTION / 16,
'32': Flow.RESOLUTION / 32,
'64': Flow.RESOLUTION / 64,
'128': Flow.RESOLUTION / 128,
'256': Flow.RESOLUTION / 256
};
Flow.durationAliases = {
'w': '1',
'h': '2',
'q': '4',
// This is the default duration used to render bars (BarNote). Bars no longer
// consume ticks, so this should be a no-op.
//
// TODO(0xfe): This needs to be cleaned up.
'b': '256'
};
Flow.durationToGlyph = function (duration, type) {
duration = Flow.sanitizeDuration(duration);
var code = Flow.durationToGlyph.duration_codes[duration];
if (code === undefined) {
return null;
}
if (!type) {
type = 'n';
}
var glyphTypeProperties = code.type[type];
if (glyphTypeProperties === undefined) {
return null;
}
return _vex.Vex.Merge(_vex.Vex.Merge({}, code.common), glyphTypeProperties);
};
Flow.durationToGlyph.duration_codes = {
'1/2': {
common: {
getWidth: function getWidth() {
var scale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Flow.DEFAULT_NOTATION_FONT_SCALE;
return new _glyph.Glyph(this.code_head || 'v53', scale).getMetrics().width;
},
stem: false,
stem_offset: 0,
flag: false,
stem_up_extension: -Flow.STEM_HEIGHT,
stem_down_extension: -Flow.STEM_HEIGHT,
gracenote_stem_up_extension: -Flow.STEM_HEIGHT,
gracenote_stem_down_extension: -Flow.STEM_HEIGHT,
tabnote_stem_up_extension: -Flow.STEM_HEIGHT,
tabnote_stem_down_extension: -Flow.STEM_HEIGHT,
dot_shiftY: 0,
line_above: 0,
line_below: 0
},
type: {
'n': { // Breve note
code_head: 'v53'
},
'h': { // Breve note harmonic
code_head: 'v59'
},
'm': { // Breve note muted -
code_head: 'vf',
stem_offset: 0
},
'r': { // Breve rest
code_head: 'v31',
rest: true,
position: 'B/5',
dot_shiftY: 0.5
},
's': { // Breve note slash -
// Drawn with canvas primitives
getWidth: function getWidth() {
return Flow.SLASH_NOTEHEAD_WIDTH;
},
position: 'B/4'
}
}
},
'1': {
common: {
getWidth: function getWidth() {
var scale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Flow.DEFAULT_NOTATION_FONT_SCALE;
return new _glyph.Glyph(this.code_head || 'v1d', scale).getMetrics().width;
},
stem: false,
stem_offset: 0,
flag: false,
stem_up_extension: -Flow.STEM_HEIGHT,
stem_down_extension: -Flow.STEM_HEIGHT,
gracenote_stem_up_extension: -Flow.STEM_HEIGHT,
gracenote_stem_down_extension: -Flow.STEM_HEIGHT,
tabnote_stem_up_extension: -Flow.STEM_HEIGHT,
tabnote_stem_down_extension: -Flow.STEM_HEIGHT,
dot_shiftY: 0,
line_above: 0,
line_below: 0
},
type: {
'n': { // Whole note
code_head: 'v1d'
},
'h': { // Whole note harmonic
code_head: 'v46'
},
'm': { // Whole note muted
code_head: 'v92',
stem_offset: -3
},
'r': { // Whole rest
code_head: 'v5c',
rest: true,
position: 'D/5',
dot_shiftY: 0.5
},
's': { // Whole note slash
// Drawn with canvas primitives
getWidth: function getWidth() {
return Flow.SLASH_NOTEHEAD_WIDTH;
},
position: 'B/4'
}
}
},
'2': {
common: {
getWidth: function getWidth() {
var scale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Flow.DEFAULT_NOTATION_FONT_SCALE;
return new _glyph.Glyph(this.code_head || 'v81', scale).getMetrics().width;
},
stem: true,
stem_offset: 0,
flag: false,
stem_up_extension: 0,
stem_down_extension: 0,
gracenote_stem_up_extension: -14,
gracenote_stem_down_extension: -14,
tabnote_stem_up_extension: 0,
tabnote_stem_down_extension: 0,
dot_shiftY: 0,
line_above: 0,
line_below: 0
},
type: {
'n': { // Half note
code_head: 'v81'
},
'h': { // Half note harmonic
code_head: 'v2d'
},
'm': { // Half note muted
code_head: 'v95',
stem_offset: -3
},
'r': { // Half rest
code_head: 'vc',
stem: false,
rest: true,
position: 'B/4',
dot_shiftY: -0.5
},
's': { // Half note slash
// Drawn with canvas primitives
getWidth: function getWidth() {
return Flow.SLASH_NOTEHEAD_WIDTH;
},
position: 'B/4'
}
}
},
'4': {
common: {
getWidth: function getWidth() {
var scale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Flow.DEFAULT_NOTATION_FONT_SCALE;
return new _glyph.Glyph(this.code_head || 'vb', scale).getMetrics().width;
},
stem: true,
stem_offset: 0,
flag: false,
stem_up_extension: 0,
stem_down_extension: 0,
gracenote_stem_up_extension: -14,
gracenote_stem_down_extension: -14,
tabnote_stem_up_extension: 0,
tabnote_stem_down_extension: 0,
dot_shiftY: 0,
line_above: 0,
line_below: 0
},
type: {
'n': { // Quarter note
code_head: 'vb'
},
'h': { // Quarter harmonic
code_head: 'v22'
},
'm': { // Quarter muted
code_head: 'v3e',
stem_offset: -3
},
'r': { // Quarter rest
code_head: 'v7c',
stem: false,
rest: true,
position: 'B/4',
dot_shiftY: -0.5,
line_above: 1.5,
line_below: 1.5
},
's': { // Quarter slash
// Drawn with canvas primitives
getWidth: function getWidth() {
return Flow.SLASH_NOTEHEAD_WIDTH;
},
position: 'B/4'
}
}
},
'8': {
common: {
getWidth: function getWidth() {
var scale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Flow.DEFAULT_NOTATION_FONT_SCALE;
return new _glyph.Glyph(this.code_head || 'vb', scale).getMetrics().width;
},
stem: true,
stem_offset: 0,
flag: true,
beam_count: 1,
code_flag_upstem: 'v54',
code_flag_downstem: 'v9a',
stem_up_extension: 0,
stem_down_extension: 0,
gracenote_stem_up_extension: -14,
gracenote_stem_down_extension: -14,
tabnote_stem_up_extension: 0,
tabnote_stem_down_extension: 0,
dot_shiftY: 0,
line_above: 0,
line_below: 0
},
type: {
'n': { // Eighth note
code_head: 'vb'
},
'h': { // Eighth note harmonic
code_head: 'v22'
},
'm': { // Eighth note muted
code_head: 'v3e'
},
'r': { // Eighth rest
code_head: 'va5',
stem: false,
flag: false,
rest: true,
position: 'B/4',
dot_shiftY: -0.5,
line_above: 1.0,
line_below: 1.0
},
's': { // Eight slash
// Drawn with canvas primitives
getWidth: function getWidth() {
return Flow.SLASH_NOTEHEAD_WIDTH;
},
position: 'B/4'
}
}
},
'16': {
common: {
beam_count: 2,
getWidth: function getWidth() {
var scale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Flow.DEFAULT_NOTATION_FONT_SCALE;
return new _glyph.Glyph(this.code_head || 'vb', scale).getMetrics().width;
},
stem: true,
stem_offset: 0,
flag: true,
code_flag_upstem: 'v3f',
code_flag_downstem: 'v8f',
stem_up_extension: 0,
stem_down_extension: 0,
gracenote_stem_up_extension: -14,
gracenote_stem_down_extension: -14,
tabnote_stem_up_extension: 0,
tabnote_stem_down_extension: 0,
dot_shiftY: 0,
line_above: 0,
line_below: 0
},
type: {
'n': { // Sixteenth note
code_head: 'vb'
},
'h': { // Sixteenth note harmonic
code_head: 'v22'
},
'm': { // Sixteenth note muted
code_head: 'v3e'
},
'r': { // Sixteenth rest
code_head: 'v3c',
stem: false,
flag: false,
rest: true,
position: 'B/4',
dot_shiftY: -0.5,
line_above: 1.0,
line_below: 2.0
},
's': { // Sixteenth slash
// Drawn with canvas primitives
getWidth: function getWidth() {
return Flow.SLASH_NOTEHEAD_WIDTH;
},
position: 'B/4'
}
}
},
'32': {
common: {
beam_count: 3,
getWidth: function getWidth() {
var scale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Flow.DEFAULT_NOTATION_FONT_SCALE;
return new _glyph.Glyph(this.code_head || 'vb', scale).getMetrics().width;
},
stem: true,
stem_offset: 0,
flag: true,
code_flag_upstem: 'v47',
code_flag_downstem: 'v2a',
stem_up_extension: 9,
stem_down_extension: 9,
gracenote_stem_up_extension: -12,
gracenote_stem_down_extension: -12,
tabnote_stem_up_extension: 8,
tabnote_stem_down_extension: 5,
dot_shiftY: 0,
line_above: 0,
line_below: 0
},
type: {
'n': { // Thirty-second note
code_head: 'vb'
},
'h': { // Thirty-second harmonic
code_head: 'v22'
},
'm': { // Thirty-second muted
code_head: 'v3e'
},
'r': { // Thirty-second rest
code_head: 'v55',
stem: false,
flag: false,
rest: true,
position: 'B/4',
dot_shiftY: -1.5,
line_above: 2.0,
line_below: 2.0
},
's': { // Thirty-second slash
// Drawn with canvas primitives
getWidth: function getWidth() {
return Flow.SLASH_NOTEHEAD_WIDTH;
},
position: 'B/4'
}
}
},
'64': {
common: {
beam_count: 4,
getWidth: function getWidth() {
var scale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Flow.DEFAULT_NOTATION_FONT_SCALE;
return new _glyph.Glyph(this.code_head || 'vb', scale).getMetrics().width;
},
stem: true,
stem_offset: 0,
flag: true,
code_flag_upstem: 'va9',
code_flag_downstem: 'v58',
stem_up_extension: 13,
stem_down_extension: 13,
gracenote_stem_up_extension: -10,
gracenote_stem_down_extension: -10,
tabnote_stem_up_extension: 12,
tabnote_stem_down_extension: 9,
dot_shiftY: 0,
line_above: 0,
line_below: 0
},
type: {
'n': { // Sixty-fourth note
code_head: 'vb'
},
'h': { // Sixty-fourth harmonic
code_head: 'v22'
},
'm': { // Sixty-fourth muted
code_head: 'v3e'
},
'r': { // Sixty-fourth rest
code_head: 'v38',
stem: false,
flag: false,
rest: true,
position: 'B/4',
dot_shiftY: -1.5,
line_above: 2.0,
line_below: 3.0
},
's': { // Sixty-fourth slash
// Drawn with canvas primitives
getWidth: function getWidth() {
return Flow.SLASH_NOTEHEAD_WIDTH;
},
position: 'B/4'
}
}
},
'128': {
common: {
beam_count: 5,
getWidth: function getWidth() {
var scale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Flow.DEFAULT_NOTATION_FONT_SCALE;
return new _glyph.Glyph(this.code_head || 'vb', scale).getMetrics().width;
},
stem: true,
stem_offset: 0,
flag: true,
code_flag_upstem: 'v9b',
code_flag_downstem: 'v30',
stem_up_extension: 22,
stem_down_extension: 22,
gracenote_stem_up_extension: -8,
gracenote_stem_down_extension: -8,
tabnote_stem_up_extension: 21,
tabnote_stem_down_extension: 18,
dot_shiftY: 0,
line_above: 0,
line_below: 0
},
type: {
'n': { // Hundred-twenty-eight note
code_head: 'vb'
},
'h': { // Hundred-twenty-eight harmonic
code_head: 'v22'
},
'm': { // Hundred-twenty-eight muted
code_head: 'v3e'
},
'r': { // Hundred-twenty-eight rest
code_head: 'vaa',
stem: false,
flag: false,
rest: true,
position: 'B/4',
dot_shiftY: 1.5,
line_above: 3.0,
line_below: 3.0
},
's': { // Hundred-twenty-eight rest
// Drawn with canvas primitives
getWidth: function getWidth() {
return Flow.SLASH_NOTEHEAD_WIDTH;
},
position: 'B/4'
}
}
}
};
// Some defaults
Flow.TIME4_4 = {
num_beats: 4,
beat_value: 4,
resolution: Flow.RESOLUTION
};
exports.Flow = Flow;
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Glyph = undefined;
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 _vex = __webpack_require__(0);
var _element = __webpack_require__(3);
var _boundingboxcomputation = __webpack_require__(65);
var _boundingbox = __webpack_require__(10);
var _vexflow_font = __webpack_require__(40);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // [VexFlow](http://vexflow.com) - Copyright (c) Mohit Muthanna 2010.
function processOutline(outline, originX, originY, scaleX, scaleY, outlineFns) {
var command = void 0;
var x = void 0;
var y = void 0;
var i = 0;
function nextX() {
return originX + outline[i++] * scaleX;
}
function nextY() {
return originY + outline[i++] * scaleY;
}
while (i < outline.length) {
command = outline[i++];
switch (command) {
case 'm':
case 'l':
outlineFns[command](nextX(), nextY());
break;
case 'q':
x = nextX();
y = nextY();
outlineFns.q(nextX(), nextY(), x, y);
break;
case 'b':
x = nextX();
y = nextY();
outlineFns.b(nextX(), nextY(), nextX(), nextY(), x, y);
break;
default:
break;
}
}
}
var Glyph = exports.Glyph = function (_Element) {
_inherits(Glyph, _Element);
_createClass(Glyph, null, [{
key: 'loadMetrics',
/* Static methods used to implement loading / unloading of glyphs */
value: function loadMetrics(font, code, cache) {
var glyph = font.glyphs[code];
if (!glyph) {
throw new _vex.Vex.RERR('BadGlyph', 'Glyph ' + code + ' does not exist in font.');
}
var x_min = glyph.x_min;
var x_max = glyph.x_max;
var ha = glyph.ha;
var outline = void 0;
if (glyph.o) {
if (cache) {
if (glyph.cached_outline) {
outline = glyph.cached_outline;
} else {
outline = glyph.o.split(' ');
glyph.cached_outline = outline;
}
} else {
if (glyph.cached_outline) delete glyph.cached_outline;
outline = glyph.o.split(' ');
}
return {
x_min: x_min,
x_max: x_max,
ha: ha,
outline: outline
};
} else {
throw new _vex.Vex.RERR('BadGlyph', 'Glyph ' + code + ' has no outline defined.');
}
}
/**
* A quick and dirty static glyph renderer. Renders glyphs from the default
* font defined in Vex.Flow.Font.
*
* @param {!Object} ctx The canvas context.
* @param {number} x_pos X coordinate.
* @param {number} y_pos Y coordinate.
* @param {number} point The point size to use.
* @param {string} val The glyph code in Vex.Flow.Font.
* @param {boolean} nocache If set, disables caching of font outline.
*/
}, {
key: 'renderGlyph',
value: function renderGlyph(ctx, x_pos, y_pos, point, val, nocache) {
var scale = point * 72.0 / (_vexflow_font.Font.resolution * 100.0);
var metrics = Glyph.loadMetrics(_vexflow_font.Font, val, !nocache);
Glyph.renderOutline(ctx, metrics.outline, scale, x_pos, y_pos);
}
}, {
key: 'renderOutline',
value: function renderOutline(ctx, outline, scale, x_pos, y_pos) {
ctx.beginPath();
ctx.moveTo(x_pos, y_pos);
processOutline(outline, x_pos, y_pos, scale, -scale, {
m: ctx.moveTo.bind(ctx),
l: ctx.lineTo.bind(ctx),
q: ctx.quadraticCurveTo.bind(ctx),
b: ctx.bezierCurveTo.bind(ctx)
});
ctx.fill();
}
}, {
key: 'getOutlineBoundingBox',
value: function getOutlineBoundingBox(outline, scale, x_pos, y_pos) {
var bboxComp = new _boundingboxcomputation.BoundingBoxComputation();
processOutline(outline, x_pos, y_pos, scale, -scale, {
m: bboxComp.addPoint.bind(bboxComp),
l: bboxComp.addPoint.bind(bboxComp),
q: bboxComp.addQuadraticCurve.bind(bboxComp),
b: bboxComp.addBezierCurve.bind(bboxComp)
});
return new _boundingbox.BoundingBox(bboxComp.x1, bboxComp.y1, bboxComp.width(), bboxComp.height());
}
/**
* @constructor
*/
}]);
function Glyph(code, point, options) {
_classCallCheck(this, Glyph);
var _this = _possibleConstructorReturn(this, (Glyph.__proto__ || Object.getPrototypeOf(Glyph)).call(this));
_this.setAttribute('type', 'Glyph');
_this.code = code;
_this.point = point;
_this.options = {
cache: true,
font: _vexflow_font.Font
};
_this.metrics = null;
_this.x_shift = 0;
_this.y_shift = 0;
_this.originShift = {
x: 0,
y: 0
};
if (options) {
_this.setOptions(options);
} else {
_this.reset();
}
return _this;
}
_createClass(Glyph, [{
key: 'setOptions',
value: function setOptions(options) {
_vex.Vex.Merge(this.options, options);
this.reset();
}
}, {
key: 'setPoint',
value: function setPoint(point) {
this.point = point;return this;
}
}, {
key: 'setStave',
value: function setStave(stave) {
this.stave = stave;return this;
}
}, {
key: 'setXShift',
value: function setXShift(x_shift) {
this.x_shift = x_shift;return this;
}
}, {
key: 'setYShift',
value: function setYShift(y_shift) {
this.y_shift = y_shift;return this;
}
}, {
key: 'reset',
value: function reset() {
this.scale = this.point * 72 / (this.options.font.resolution * 100);
this.metrics = Glyph.loadMetrics(this.options.font, this.code, this.options.cache);
this.bbox = Glyph.getOutlineBoundingBox(this.metrics.outline, this.scale, 0, 0);
}
}, {
key: 'getMetrics',
value: function getMetrics() {
if (!this.metrics) {
throw new _vex.Vex.RuntimeError('BadGlyph', 'Glyph ' + this.code + ' is not initialized.');
}
return {
x_min: this.metrics.x_min * this.scale,
x_max: this.metrics.x_max * this.scale,
width: this.bbox.getW(),
height: this.bbox.getH()
};
}
}, {
key: 'setOriginX',
value: function setOriginX(x) {
var bbox = this.bbox;
var originX = Math.abs(bbox.getX() / bbox.getW());
var xShift = (x - originX) * bbox.getW();
this.originShift.x = -xShift;
}
}, {
key: 'setOriginY',
value: function setOriginY(y) {
var bbox = this.bbox;
var originY = Math.abs(bbox.getY() / bbox.getH());
var yShift = (y - originY) * bbox.getH();
this.originShift.y = -yShift;
}
}, {
key: 'setOrigin',
value: function setOrigin(x, y) {
this.setOriginX(x);
this.setOriginY(y);
}
}, {
key: 'render',
value: function render(ctx, x, y) {
if (!this.metrics) {
throw new _vex.Vex.RuntimeError('BadGlyph', 'Glyph ' + this.code + ' is not initialized.');
}
var outline = this.metrics.outline;
var scale = this.scale;
this.setRendered();
this.applyStyle(ctx);
Glyph.renderOutline(ctx, outline, scale, x + this.originShift.x, y + this.originShift.y);
this.restoreStyle(ctx);
}
}, {
key: 'renderToStave',
value: function renderToStave(x) {
this.checkContext();
if (!this.metrics) {
throw new _vex.Vex.RuntimeError('BadGlyph', 'Glyph ' + this.code + ' is not initialized.');
}
if (!this.stave) {
throw new _vex.Vex.RuntimeError('GlyphError', 'No valid stave');
}
var outline = this.metrics.outline;
var scale = this.scale;
this.setRendered();
this.applyStyle();
Glyph.renderOutline(this.context, outline, scale, x + this.x_shift, this.stave.getYForGlyphs() + this.y_shift);
this.restoreStyle();
}
}]);
return Glyph;
}(_element.Element);
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Element = undefined;
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; }; }(); // [VexFlow](http://vexflow.com) - Copyright (c) Mohit Muthanna 2010.
// @author Mohit Cheppudira
//
// ## Description
//
// This file implements a generic base class for VexFlow, with implementations
// of general functions and properties that can be inherited by all VexFlow elements.
var _vex = __webpack_require__(0);
var _registry = __webpack_require__(39);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Element = exports.Element = function () {
_createClass(Element, null, [{
key: 'newID',
value: function newID() {
return 'auto' + Element.ID++;
}
}]);
function Element() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
type = _ref.type;
_classCallCheck(this, Element);
this.attrs = {
id: Element.newID(),
el: null,
type: type || 'Base',
classes: {}
};
this.boundingBox = null;
this.context = null;
this.rendered = false;
// If a default registry exist, then register with it right away.
if (_registry.Registry.getDefaultRegistry()) {
_registry.Registry.getDefaultRegistry().register(this);
}
}
// set the draw style of a stemmable note:
_createClass(Element, [{
key: 'setStyle',
value: function setStyle(style) {
this.style = style;return this;
}
}, {
key: 'getStyle',
value: function getStyle() {
return this.style;