UNPKG

@sebastbake/music-tempo

Version:

Finding out tempo of the music

1,326 lines (1,325 loc) 810 kB
{ "type": "File", "start": 0, "end": 8316, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 188, "column": 1 } }, "program": { "type": "Program", "start": 0, "end": 8316, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 188, "column": 1 } }, "sourceType": "module", "body": [ { "type": "ExportDefaultDeclaration", "start": 71, "end": 8316, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 188, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 86, "end": 8316, "loc": { "start": { "line": 5, "column": 15 }, "end": { "line": 188, "column": 1 } }, "id": { "type": "Identifier", "start": 92, "end": 97, "loc": { "start": { "line": 5, "column": 21 }, "end": { "line": 5, "column": 26 }, "identifierName": "Agent" }, "name": "Agent", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 98, "end": 8316, "loc": { "start": { "line": 5, "column": 27 }, "end": { "line": 188, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 1548, "end": 4538, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 97, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 1548, "end": 1559, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 21, "column": 15 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "static": false, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1560, "end": 1565, "loc": { "start": { "line": 21, "column": 16 }, "end": { "line": 21, "column": 21 }, "identifierName": "tempo" }, "name": "tempo" }, { "type": "Identifier", "start": 1567, "end": 1580, "loc": { "start": { "line": 21, "column": 23 }, "end": { "line": 21, "column": 36 }, "identifierName": "firstBeatTime" }, "name": "firstBeatTime" }, { "type": "Identifier", "start": 1582, "end": 1597, "loc": { "start": { "line": 21, "column": 38 }, "end": { "line": 21, "column": 53 }, "identifierName": "firsteventScore" }, "name": "firsteventScore" }, { "type": "Identifier", "start": 1599, "end": 1608, "loc": { "start": { "line": 21, "column": 55 }, "end": { "line": 21, "column": 64 }, "identifierName": "agentList" }, "name": "agentList" }, { "type": "AssignmentPattern", "start": 1610, "end": 1621, "loc": { "start": { "line": 21, "column": 66 }, "end": { "line": 21, "column": 77 } }, "left": { "type": "Identifier", "start": 1610, "end": 1616, "loc": { "start": { "line": 21, "column": 66 }, "end": { "line": 21, "column": 72 }, "identifierName": "params" }, "name": "params" }, "right": { "type": "ObjectExpression", "start": 1619, "end": 1621, "loc": { "start": { "line": 21, "column": 75 }, "end": { "line": 21, "column": 77 } }, "properties": [] } } ], "body": { "type": "BlockStatement", "start": 1623, "end": 4538, "loc": { "start": { "line": 21, "column": 79 }, "end": { "line": 97, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 1780, "end": 1822, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 50 } }, "expression": { "type": "AssignmentExpression", "start": 1780, "end": 1821, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 49 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1780, "end": 1795, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 23 } }, "object": { "type": "ThisExpression", "start": 1780, "end": 1784, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 1785, "end": 1795, "loc": { "start": { "line": 26, "column": 13 }, "end": { "line": 26, "column": 23 }, "identifierName": "expiryTime" }, "name": "expiryTime" }, "computed": false, "leadingComments": null }, "right": { "type": "LogicalExpression", "start": 1798, "end": 1821, "loc": { "start": { "line": 26, "column": 26 }, "end": { "line": 26, "column": 49 } }, "left": { "type": "MemberExpression", "start": 1798, "end": 1815, "loc": { "start": { "line": 26, "column": 26 }, "end": { "line": 26, "column": 43 } }, "object": { "type": "Identifier", "start": 1798, "end": 1804, "loc": { "start": { "line": 26, "column": 26 }, "end": { "line": 26, "column": 32 }, "identifierName": "params" }, "name": "params" }, "property": { "type": "Identifier", "start": 1805, "end": 1815, "loc": { "start": { "line": 26, "column": 33 }, "end": { "line": 26, "column": 43 }, "identifierName": "expiryTime" }, "name": "expiryTime" }, "computed": false }, "operator": "||", "right": { "type": "NumericLiteral", "start": 1819, "end": 1821, "loc": { "start": { "line": 26, "column": 47 }, "end": { "line": 26, "column": 49 } }, "extra": { "rawValue": 10, "raw": "10" }, "value": 10 } }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* \r\n * the time after which an Agent that has not accepted any beat will be destroyed\r\n * @type {Number} \r\n ", "start": 1634, "end": 1770, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 25, "column": 11 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* \r\n * the maximum time that a beat can deviate from the predicted beat time without a fork occurring\r\n * @type {Number} \r\n ", "start": 1832, "end": 1984, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 30, "column": 11 } } } ] }, { "type": "ExpressionStatement", "start": 1994, "end": 2052, "loc": { "start": { "line": 31, "column": 8 }, "end": { "line": 31, "column": 66 } }, "expression": { "type": "AssignmentExpression", "start": 1994, "end": 2051, "loc": { "start": { "line": 31, "column": 8 }, "end": { "line": 31, "column": 65 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1994, "end": 2016, "loc": { "start": { "line": 31, "column": 8 }, "end": { "line": 31, "column": 30 } }, "object": { "type": "ThisExpression", "start": 1994, "end": 1998, "loc": { "start": { "line": 31, "column": 8 }, "end": { "line": 31, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 1999, "end": 2016, "loc": { "start": { "line": 31, "column": 13 }, "end": { "line": 31, "column": 30 }, "identifierName": "toleranceWndInner" }, "name": "toleranceWndInner" }, "computed": false, "leadingComments": null }, "right": { "type": "LogicalExpression", "start": 2019, "end": 2051, "loc": { "start": { "line": 31, "column": 33 }, "end": { "line": 31, "column": 65 } }, "left": { "type": "MemberExpression", "start": 2019, "end": 2043, "loc": { "start": { "line": 31, "column": 33 }, "end": { "line": 31, "column": 57 } }, "object": { "type": "Identifier", "start": 2019, "end": 2025, "loc": { "start": { "line": 31, "column": 33 }, "end": { "line": 31, "column": 39 }, "identifierName": "params" }, "name": "params" }, "property": { "type": "Identifier", "start": 2026, "end": 2043, "loc": { "start": { "line": 31, "column": 40 }, "end": { "line": 31, "column": 57 }, "identifierName": "toleranceWndInner" }, "name": "toleranceWndInner" }, "computed": false }, "operator": "||", "right": { "type": "NumericLiteral", "start": 2047, "end": 2051, "loc": { "start": { "line": 31, "column": 61 }, "end": { "line": 31, "column": 65 } }, "extra": { "rawValue": 0.04, "raw": "0.04" }, "value": 0.04 } }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* \r\n * the maximum time that a beat can deviate from the predicted beat time without a fork occurring\r\n * @type {Number} \r\n ", "start": 1832, "end": 1984, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 30, "column": 11 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* \r\n * the maximum amount by which a beat can be earlier than the predicted beat time, expressed as a fraction of the beat period\r\n * @type {Number} \r\n ", "start": 2062, "end": 2242, "loc": { "start": { "line": 32, "column": 8 }, "end": { "line": 35, "column": 11 } } } ] }, { "type": "ExpressionStatement", "start": 2252, "end": 2306, "loc": { "start": { "line": 36, "column": 8 }, "end": { "line": 36, "column": 62 } }, "expression": { "type": "AssignmentExpression", "start": 2252, "end": 2305, "loc": { "start": { "line": 36, "column": 8 }, "end": { "line": 36, "column": 61 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 2252, "end": 2272, "loc": { "start": { "line": 36, "column": 8 }, "end": { "line": 36, "column": 28 } }, "object": { "type": "ThisExpression", "start": 2252, "end": 2256, "loc": { "start": { "line": 36, "column": 8 }, "end": { "line": 36, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 2257, "end": 2272, "loc": { "start": { "line": 36, "column": 13 }, "end": { "line": 36, "column": 28 }, "identifierName": "toleranceWndPre" }, "name": "toleranceWndPre" }, "computed": false, "leadingComments": null }, "right": { "type": "LogicalExpression", "start": 2275, "end": 2305, "loc": { "start": { "line": 36, "column": 31 }, "end": { "line": 36, "column": 61 } }, "left": { "type": "MemberExpression", "start": 2275, "end": 2297, "loc": { "start": { "line": 36, "column": 31 }, "end": { "line": 36, "column": 53 } }, "object": { "type": "Identifier", "start": 2275, "end": 2281, "loc": { "start": { "line": 36, "column": 31 }, "end": { "line": 36, "column": 37 }, "identifierName": "params" }, "name": "params" }, "property": { "type": "Identifier", "start": 2282, "end": 2297, "loc": { "start": { "line": 36, "column": 38 }, "end": { "line": 36, "column": 53 }, "identifierName": "toleranceWndPre" }, "name": "toleranceWndPre" }, "computed": false }, "operator": "||", "right": { "type": "NumericLiteral", "start": 2301, "end": 2305, "loc": { "start": { "line": 36, "column": 57 }, "end": { "line": 36, "column": 61 } }, "extra": { "rawValue": 0.15, "raw": "0.15" }, "value": 0.15 } }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* \r\n * the maximum amount by which a beat can be earlier than the predicted beat time, expressed as a fraction of the beat period\r\n * @type {Number} \r\n ", "start": 2062, "end": 2242, "loc": { "start": { "line": 32, "column": 8 }, "end": { "line": 35, "column": 11 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* \r\n * the maximum amount by which a beat can be later than the predicted beat time, expressed as a fraction of the beat period\r\n * @type {Number} \r\n ", "start": 2316, "end": 2494, "loc": { "start": { "line": 37, "column": 8 }, "end": { "line": 40, "column": 11 } } } ] }, { "type": "ExpressionStatement", "start": 2504, "end": 2559, "loc": { "start": { "line": 41, "column": 8 }, "end": { "line": 41, "column": 63 } }, "expression": { "type": "AssignmentExpression", "start": 2504, "end": 2558, "loc": { "start": { "line": 41, "column": 8 }, "end": { "line": 41, "column": 62 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 2504, "end": 2525, "loc": { "start": { "line": 41, "column": 8 }, "end": { "line": 41, "column": 29 } }, "object": { "type": "ThisExpression", "start": 2504, "end": 2508, "loc": { "start": { "line": 41, "column": 8 }, "end": { "line": 41, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 2509, "end": 2525, "loc": { "start": { "line": 41, "column": 13 }, "end": { "line": 41, "column": 29 }, "identifierName": "toleranceWndPost" }, "name": "toleranceWndPost" }, "computed": false, "leadingComments": null }, "right": { "type": "LogicalExpression", "start": 2528, "end": 2558, "loc": { "start": { "line": 41, "column": 32 }, "end": { "line": 41, "column": 62 } }, "left": { "type": "MemberExpression", "start": 2528, "end": 2551, "loc": { "start": { "line": 41, "column": 32 }, "end": { "line": 41, "column": 55 } }, "object": { "type": "Identifier", "start": 2528, "end": 2534, "loc": { "start": { "line": 41, "column": 32 }, "end": { "line": 41, "column": 38 }, "identifierName": "params" }, "name": "params" }, "property": { "type": "Identifier", "start": 2535, "end": 2551, "loc": { "start": { "line": 41, "column": 39 }, "end": { "line": 41, "column": 55 }, "identifierName": "toleranceWndPost" }, "name": "toleranceWndPost" }, "computed": false }, "operator": "||", "right": { "type": "NumericLiteral", "start": 2555, "end": 2558, "loc": { "start": { "line": 41, "column": 59 }, "end": { "line": 41, "column": 62 } }, "extra": { "rawValue": 0.3, "raw": "0.3" }, "value": 0.3 } }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* \r\n * the maximum amount by which a beat can be later than the predicted beat time, expressed as a fraction of the beat period\r\n * @type {Number} \r\n ", "start": 2316, "end": 2494, "loc": { "start": { "line": 37, "column": 8 }, "end": { "line": 40, "column": 11 } } } ] }, { "type": "ExpressionStatement", "start": 2571, "end": 2601, "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 38 } }, "expression": { "type": "AssignmentExpression", "start": 2571, "end": 2600, "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 37 } }, "operator": "*=", "left": { "type": "MemberExpression", "start": 2571, "end": 2591, "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 28 } }, "object": { "type": "ThisExpression", "start": 2571, "end": 2575, "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 12 } } }, "property": { "type": "Identifier", "start": 2576, "end": 2591, "loc": { "start": { "line": 43, "column": 13 }, "end": { "line": 43, "column": 28 }, "identifierName": "toleranceWndPre" }, "name": "toleranceWndPre" }, "computed": false }, "right": { "type": "Identifier", "start": 2595, "end": 2600, "loc": { "start": { "line": 43, "column": 32 }, "end": { "line": 43, "column": 37 }, "identifierName": "tempo" }, "name": "tempo" } } }, { "type": "ExpressionStatement", "start": 2611, "end": 2642, "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 39 } }, "expression": { "type": "AssignmentExpression", "start": 2611, "end": 2641, "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 38 } }, "operator": "*=", "left": { "type": "MemberExpression", "start": 2611, "end": 2632, "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 29 } }, "object": { "type": "ThisExpression", "start": 2611, "end": 2615, "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 12 } } }, "property": { "type": "Identifier", "start": 2616, "end": 2632, "loc": { "start": { "line": 44, "column": 13 }, "end": { "line": 44, "column": 29 }, "identifierName": "toleranceWndPost" }, "name": "toleranceWndPost" }, "computed": false }, "right": { "type": "Identifier", "start": 2636, "end": 2641, "loc": { "start": { "line": 44, "column": 33 }, "end": { "line": 44, "column": 38 }, "identifierName": "tempo" }, "name": "tempo" } }, "trailingComments": [ { "type": "CommentBlock", "value": "* \r\n * correction factor for updating beat period\r\n * @type {Number} \r\n ", "start": 2654, "end": 2754, "loc": { "start": { "line": 46, "column": 8 }, "end": { "line": 49, "column": 11 } } } ] }, { "type": "ExpressionStatement", "start": 2764, "end": 2818, "loc": { "start": { "line": 50, "column": 8 }, "end": { "line": 50, "column": 62 } }, "expression": { "type": "AssignmentExpression", "start": 2764, "end": 2817, "loc": { "start": { "line": 50, "column": 8 }, "end": { "line": 50, "column": 61 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 2764, "end": 2785, "loc": { "start": { "line": 50, "column": 8 }, "end": { "line": 50, "column": 29 } }, "object": { "type": "ThisExpression", "start": 2764, "end": 2768, "loc": { "start": { "line": 50, "column": 8 }, "end": {