UNPKG

@sebastbake/music-tempo

Version:

Finding out tempo of the music

1,225 lines (1,224 loc) 1.17 MB
{ "type": "File", "start": 0, "end": 6908, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 183, "column": 1 } }, "program": { "type": "Program", "start": 0, "end": 6908, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 183, "column": 1 } }, "sourceType": "module", "body": [ { "type": "ExportDefaultDeclaration", "start": 70, "end": 6908, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 183, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 85, "end": 6908, "loc": { "start": { "line": 5, "column": 15 }, "end": { "line": 183, "column": 1 } }, "id": { "type": "Identifier", "start": 91, "end": 105, "loc": { "start": { "line": 5, "column": 21 }, "end": { "line": 5, "column": 35 }, "identifierName": "OnsetDetection" }, "name": "OnsetDetection", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 106, "end": 6908, "loc": { "start": { "line": 5, "column": 36 }, "end": { "line": 183, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 649, "end": 3753, "loc": { "start": { "line": 15, "column": 4 }, "end": { "line": 99, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 656, "end": 667, "loc": { "start": { "line": 15, "column": 11 }, "end": { "line": 15, "column": 22 }, "identifierName": "calculateSF" }, "name": "calculateSF" }, "static": true, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 668, "end": 677, "loc": { "start": { "line": 15, "column": 23 }, "end": { "line": 15, "column": 32 }, "identifierName": "audioData" }, "name": "audioData" }, { "type": "Identifier", "start": 679, "end": 682, "loc": { "start": { "line": 15, "column": 34 }, "end": { "line": 15, "column": 37 }, "identifierName": "fft" }, "name": "fft" }, { "type": "AssignmentPattern", "start": 684, "end": 695, "loc": { "start": { "line": 15, "column": 39 }, "end": { "line": 15, "column": 50 } }, "left": { "type": "Identifier", "start": 684, "end": 690, "loc": { "start": { "line": 15, "column": 39 }, "end": { "line": 15, "column": 45 }, "identifierName": "params" }, "name": "params" }, "right": { "type": "ObjectExpression", "start": 693, "end": 695, "loc": { "start": { "line": 15, "column": 48 }, "end": { "line": 15, "column": 50 } }, "properties": [] } } ], "body": { "type": "BlockStatement", "start": 697, "end": 3753, "loc": { "start": { "line": 15, "column": 52 }, "end": { "line": 99, "column": 5 } }, "body": [ { "type": "IfStatement", "start": 708, "end": 810, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 18, "column": 9 } }, "test": { "type": "BinaryExpression", "start": 712, "end": 737, "loc": { "start": { "line": 16, "column": 12 }, "end": { "line": 16, "column": 37 } }, "left": { "type": "UnaryExpression", "start": 712, "end": 722, "loc": { "start": { "line": 16, "column": 12 }, "end": { "line": 16, "column": 22 } }, "operator": "typeof", "prefix": true, "argument": { "type": "Identifier", "start": 719, "end": 722, "loc": { "start": { "line": 16, "column": 19 }, "end": { "line": 16, "column": 22 }, "identifierName": "fft" }, "name": "fft" }, "extra": { "parenthesizedArgument": false } }, "operator": "==", "right": { "type": "StringLiteral", "start": 726, "end": 737, "loc": { "start": { "line": 16, "column": 26 }, "end": { "line": 16, "column": 37 } }, "extra": { "rawValue": "undefined", "raw": "\"undefined\"" }, "value": "undefined" } }, "consequent": { "type": "BlockStatement", "start": 739, "end": 810, "loc": { "start": { "line": 16, "column": 39 }, "end": { "line": 18, "column": 9 } }, "body": [ { "type": "ThrowStatement", "start": 754, "end": 799, "loc": { "start": { "line": 17, "column": 12 }, "end": { "line": 17, "column": 57 } }, "argument": { "type": "NewExpression", "start": 760, "end": 798, "loc": { "start": { "line": 17, "column": 18 }, "end": { "line": 17, "column": 56 } }, "callee": { "type": "Identifier", "start": 764, "end": 778, "loc": { "start": { "line": 17, "column": 22 }, "end": { "line": 17, "column": 36 }, "identifierName": "ReferenceError" }, "name": "ReferenceError" }, "arguments": [ { "type": "StringLiteral", "start": 779, "end": 797, "loc": { "start": { "line": 17, "column": 37 }, "end": { "line": 17, "column": 55 } }, "extra": { "rawValue": "fft is undefined", "raw": "\"fft is undefined\"" }, "value": "fft is undefined" } ] } } ], "directives": [] }, "alternate": null }, { "type": "IfStatement", "start": 821, "end": 1024, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 21, "column": 9 } }, "test": { "type": "LogicalExpression", "start": 825, "end": 908, "loc": { "start": { "line": 19, "column": 12 }, "end": { "line": 19, "column": 95 } }, "left": { "type": "BinaryExpression", "start": 825, "end": 867, "loc": { "start": { "line": 19, "column": 12 }, "end": { "line": 19, "column": 54 } }, "left": { "type": "UnaryExpression", "start": 825, "end": 852, "loc": { "start": { "line": 19, "column": 12 }, "end": { "line": 19, "column": 39 } }, "operator": "typeof", "prefix": true, "argument": { "type": "MemberExpression", "start": 832, "end": 852, "loc": { "start": { "line": 19, "column": 19 }, "end": { "line": 19, "column": 39 } }, "object": { "type": "Identifier", "start": 832, "end": 835, "loc": { "start": { "line": 19, "column": 19 }, "end": { "line": 19, "column": 22 }, "identifierName": "fft" }, "name": "fft" }, "property": { "type": "Identifier", "start": 836, "end": 852, "loc": { "start": { "line": 19, "column": 23 }, "end": { "line": 19, "column": 39 }, "identifierName": "getHammingWindow" }, "name": "getHammingWindow" }, "computed": false }, "extra": { "parenthesizedArgument": false } }, "operator": "!==", "right": { "type": "StringLiteral", "start": 857, "end": 867, "loc": { "start": { "line": 19, "column": 44 }, "end": { "line": 19, "column": 54 } }, "extra": { "rawValue": "function", "raw": "\"function\"" }, "value": "function" } }, "operator": "||", "right": { "type": "BinaryExpression", "start": 871, "end": 908, "loc": { "start": { "line": 19, "column": 58 }, "end": { "line": 19, "column": 95 } }, "left": { "type": "UnaryExpression", "start": 871, "end": 893, "loc": { "start": { "line": 19, "column": 58 }, "end": { "line": 19, "column": 80 } }, "operator": "typeof", "prefix": true, "argument": { "type": "MemberExpression", "start": 878, "end": 893, "loc": { "start": { "line": 19, "column": 65 }, "end": { "line": 19, "column": 80 } }, "object": { "type": "Identifier", "start": 878, "end": 881, "loc": { "start": { "line": 19, "column": 65 }, "end": { "line": 19, "column": 68 }, "identifierName": "fft" }, "name": "fft" }, "property": { "type": "Identifier", "start": 882, "end": 893, "loc": { "start": { "line": 19, "column": 69 }, "end": { "line": 19, "column": 80 }, "identifierName": "getSpectrum" }, "name": "getSpectrum" }, "computed": false }, "extra": { "parenthesizedArgument": false } }, "operator": "!==", "right": { "type": "StringLiteral", "start": 898, "end": 908, "loc": { "start": { "line": 19, "column": 85 }, "end": { "line": 19, "column": 95 } }, "extra": { "rawValue": "function", "raw": "\"function\"" }, "value": "function" } } }, "consequent": { "type": "BlockStatement", "start": 910, "end": 1024, "loc": { "start": { "line": 19, "column": 97 }, "end": { "line": 21, "column": 9 } }, "body": [ { "type": "ThrowStatement", "start": 925, "end": 1013, "loc": { "start": { "line": 20, "column": 12 }, "end": { "line": 20, "column": 100 } }, "argument": { "type": "NewExpression", "start": 931, "end": 1012, "loc": { "start": { "line": 20, "column": 18 }, "end": { "line": 20, "column": 99 } }, "callee": { "type": "Identifier", "start": 935, "end": 949, "loc": { "start": { "line": 20, "column": 22 }, "end": { "line": 20, "column": 36 }, "identifierName": "ReferenceError" }, "name": "ReferenceError" }, "arguments": [ { "type": "StringLiteral", "start": 950, "end": 1011, "loc": { "start": { "line": 20, "column": 37 }, "end": { "line": 20, "column": 98 } }, "extra": { "rawValue": "fft doesn't contain getHammingWindow or getSpectrum methods", "raw": "\"fft doesn't contain getHammingWindow or getSpectrum methods\"" }, "value": "fft doesn't contain getHammingWindow or getSpectrum methods" } ] } } ], "directives": [], "trailingComments": null }, "alternate": null, "trailingComments": [ { "type": "CommentLine", "value": " Array.fill polyfill", "start": 1034, "end": 1056, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 30 } } } ] }, { "type": "IfStatement", "start": 1066, "end": 1954, "loc": { "start": { "line": 23, "column": 8 }, "end": { "line": 47, "column": 9 } }, "test": { "type": "UnaryExpression", "start": 1070, "end": 1091, "loc": { "start": { "line": 23, "column": 12 }, "end": { "line": 23, "column": 33 } }, "operator": "!", "prefix": true, "argument": { "type": "MemberExpression", "start": 1071, "end": 1091, "loc": { "start": { "line": 23, "column": 13 }, "end": { "line": 23, "column": 33 } }, "object": { "type": "MemberExpression", "start": 1071, "end": 1086, "loc": { "start": { "line": 23, "column": 13 }, "end": { "line": 23, "column": 28 } }, "object": { "type": "Identifier", "start": 1071, "end": 1076, "loc": { "start": { "line": 23, "column": 13 }, "end": { "line": 23, "column": 18 }, "identifierName": "Array" }, "name": "Array", "leadingComments": null }, "property": { "type": "Identifier", "start": 1077, "end": 1086, "loc": { "start": { "line": 23, "column": 19 }, "end": { "line": 23, "column": 28 }, "identifierName": "prototype" }, "name": "prototype" }, "computed": false, "leadingComments": null }, "property": { "type": "Identifier", "start": 1087, "end": 1091, "loc": { "start": { "line": 23, "column": 29 }, "end": { "line": 23, "column": 33 }, "identifierName": "fill" }, "name": "fill" }, "computed": false, "leadingComments": null }, "extra": { "parenthesizedArgument": false }, "leadingComments": null }, "consequent": { "type": "BlockStatement", "start": 1093, "end": 1954, "loc": { "start": { "line": 23, "column": 35 }, "end": { "line": 47, "column": 9 } }, "body": [ { "type": "ExpressionStatement", "start": 1106, "end": 1943, "loc": { "start": { "line": 24, "column": 10 }, "end": { "line": 46, "column": 12 } }, "expression": { "type": "AssignmentExpression", "start": 1106, "end": 1942, "loc": { "start": { "line": 24, "column": 10 }, "end": { "line": 46, "column": 11 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1106, "end": 1126, "loc": { "start": { "line": 24, "column": 10 }, "end": { "line": 24, "column": 30 } }, "object": { "type": "MemberExpression", "start": 1106, "end": 1121, "loc": { "start": { "line": 24, "column": 10 }, "end": { "line": 24, "column": 25 } }, "object": { "type": "Identifier", "start": 1106, "end": 1111, "loc": { "start": { "line": 24, "column": 10 }, "end": { "line": 24, "column": 15 }, "identifierName": "Array" }, "name": "Array" }, "property": { "type": "Identifier", "start": 1112, "end": 1121, "loc": { "start": { "line": 24, "column": 16 }, "end": { "line": 24, "column": 25 }, "identifierName": "prototype" }, "name": "prototype" }, "computed": false }, "property": { "type": "Identifier", "start": 1122, "end": 1126, "loc": { "start": { "line": 24, "column": 26 }, "end": { "line": 24, "column": 30 }, "identifierName": "fill" }, "name": "fill" }, "computed": false }, "right": { "type": "FunctionExpression", "start": 1129, "end": 1942, "loc": { "start": { "line": 24, "column": 33 }, "end": { "line": 46, "column": 11 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1138, "end": 1143, "loc": { "start": { "line": 24, "column": 42 }, "end": { "line": 24, "column": 47 }, "identifierName": "value" }, "name": "value" } ], "body": { "type": "BlockStatement", "start": 1145, "end": 1942, "loc": { "start": { "line": 24, "column": 49 }, "end": { "line": 46, "column": 11 } }, "body": [ { "type": "IfStatement", "start": 1160, "end": 1261, "loc": { "start": { "line": 25, "column": 12 }, "end": { "line": 27, "column": 13 } }, "test": { "type": "BinaryExpression", "start": 1164, "end": 1176, "loc": { "start": { "line": 25, "column": 16 }, "end": { "line": 25, "column": 28 } }, "left": { "type": "ThisExpression", "start": 1164, "end": 1168, "loc": { "start": { "line": 25, "column": 16 }, "end": { "line": 25, "column": 20 } } }, "operator": "==", "right": { "type": "NullLiteral", "start": 1172, "end": 1176, "loc": { "start": { "line": 25, "column": 24 }, "end": { "line": 25, "column": 28 } } } }, "consequent": { "type": "BlockStatement", "start": 1178, "end": 1261, "loc": { "start": { "line": 25, "column": 30 }, "end": { "line": 27, "column": 13 } }, "body": [ { "type": "ThrowStatement", "start": 1195, "end": 1246, "loc": { "start": { "line": 26, "column": 14 }, "end": { "line": 26, "column": 65 } }, "argument": { "type": "NewExpression", "start": 1201, "end": 1245, "loc": { "start": { "line": 26, "column": 20 }, "end": { "line": 26, "column": 64 } }, "callee": { "type": "Identifier", "start": 1205, "end": 1214, "loc": { "start": { "line": 26, "column": 24 }, "end": { "line": 26, "column": 33 }, "identifierName": "TypeError" }, "name": "TypeError" }, "arguments": [ { "type": "StringLiteral", "start": 1215, "end": 1244, "loc": { "start": { "line": 26, "column": 34 }, "end": { "line": 26, "column": 63 } }, "extra": { "rawValue": "this is null or not defined", "raw": "'this is null or not defined'" }, "value": "this is null or not defined" } ] } } ], "directives": [] }, "alternate": null }, { "type": "VariableDeclaration", "start": 1275, "end": 1296, "loc": { "start": { "line": 28, "column": 12 }, "end": { "line": 28, "column": 33 } }, "declarations": [ { "type": "VariableDeclarator", "start": 1279, "end": 1295, "loc": {