@sebastbake/music-tempo
Version:
Finding out tempo of the music
1,269 lines (1,268 loc) • 596 kB
JSON
{
"type": "File",
"start": 0,
"end": 4553,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 91,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 4553,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 91,
"column": 1
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 28
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 7,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 12
}
},
"local": {
"type": "Identifier",
"start": 7,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "Agent"
},
"name": "Agent"
}
}
],
"source": {
"type": "StringLiteral",
"start": 18,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 27
}
},
"extra": {
"rawValue": "./Agent",
"raw": "\"./Agent\""
},
"value": "./Agent"
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "* \r\n * Performs automatic beat tracking\r\n * @class\r\n ",
"start": 30,
"end": 87,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 5,
"column": 3
}
}
}
]
},
{
"type": "ExportDefaultDeclaration",
"start": 89,
"end": 4553,
"loc": {
"start": {
"line": 6,
"column": 0
},
"end": {
"line": 91,
"column": 1
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 104,
"end": 4553,
"loc": {
"start": {
"line": 6,
"column": 15
},
"end": {
"line": 91,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 110,
"end": 122,
"loc": {
"start": {
"line": 6,
"column": 21
},
"end": {
"line": 6,
"column": 33
},
"identifierName": "BeatTracking"
},
"name": "BeatTracking",
"leadingComments": null
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 123,
"end": 4553,
"loc": {
"start": {
"line": 6,
"column": 34
},
"end": {
"line": 91,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 1862,
"end": 4550,
"loc": {
"start": {
"line": 25,
"column": 4
},
"end": {
"line": 90,
"column": 5
}
},
"computed": false,
"key": {
"type": "Identifier",
"start": 1869,
"end": 1878,
"loc": {
"start": {
"line": 25,
"column": 11
},
"end": {
"line": 25,
"column": 20
},
"identifierName": "trackBeat"
},
"name": "trackBeat"
},
"static": true,
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 1879,
"end": 1885,
"loc": {
"start": {
"line": 25,
"column": 21
},
"end": {
"line": 25,
"column": 27
},
"identifierName": "events"
},
"name": "events"
},
{
"type": "Identifier",
"start": 1887,
"end": 1899,
"loc": {
"start": {
"line": 25,
"column": 29
},
"end": {
"line": 25,
"column": 41
},
"identifierName": "eventsScores"
},
"name": "eventsScores"
},
{
"type": "Identifier",
"start": 1901,
"end": 1910,
"loc": {
"start": {
"line": 25,
"column": 43
},
"end": {
"line": 25,
"column": 52
},
"identifierName": "tempoList"
},
"name": "tempoList"
},
{
"type": "AssignmentPattern",
"start": 1912,
"end": 1923,
"loc": {
"start": {
"line": 25,
"column": 54
},
"end": {
"line": 25,
"column": 65
}
},
"left": {
"type": "Identifier",
"start": 1912,
"end": 1918,
"loc": {
"start": {
"line": 25,
"column": 54
},
"end": {
"line": 25,
"column": 60
},
"identifierName": "params"
},
"name": "params"
},
"right": {
"type": "ObjectExpression",
"start": 1921,
"end": 1923,
"loc": {
"start": {
"line": 25,
"column": 63
},
"end": {
"line": 25,
"column": 65
}
},
"properties": []
}
}
],
"body": {
"type": "BlockStatement",
"start": 1925,
"end": 4550,
"loc": {
"start": {
"line": 25,
"column": 67
},
"end": {
"line": 90,
"column": 5
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 1936,
"end": 2098,
"loc": {
"start": {
"line": 26,
"column": 8
},
"end": {
"line": 28,
"column": 57
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 1944,
"end": 1979,
"loc": {
"start": {
"line": 26,
"column": 16
},
"end": {
"line": 26,
"column": 51
}
},
"id": {
"type": "Identifier",
"start": 1944,
"end": 1954,
"loc": {
"start": {
"line": 26,
"column": 16
},
"end": {
"line": 26,
"column": 26
},
"identifierName": "initPeriod"
},
"name": "initPeriod"
},
"init": {
"type": "LogicalExpression",
"start": 1957,
"end": 1979,
"loc": {
"start": {
"line": 26,
"column": 29
},
"end": {
"line": 26,
"column": 51
}
},
"left": {
"type": "MemberExpression",
"start": 1957,
"end": 1974,
"loc": {
"start": {
"line": 26,
"column": 29
},
"end": {
"line": 26,
"column": 46
}
},
"object": {
"type": "Identifier",
"start": 1957,
"end": 1963,
"loc": {
"start": {
"line": 26,
"column": 29
},
"end": {
"line": 26,
"column": 35
},
"identifierName": "params"
},
"name": "params"
},
"property": {
"type": "Identifier",
"start": 1964,
"end": 1974,
"loc": {
"start": {
"line": 26,
"column": 36
},
"end": {
"line": 26,
"column": 46
},
"identifierName": "initPeriod"
},
"name": "initPeriod"
},
"computed": false
},
"operator": "||",
"right": {
"type": "NumericLiteral",
"start": 1978,
"end": 1979,
"loc": {
"start": {
"line": 26,
"column": 50
},
"end": {
"line": 26,
"column": 51
}
},
"extra": {
"rawValue": 5,
"raw": "5"
},
"value": 5
}
}
},
{
"type": "VariableDeclarator",
"start": 1998,
"end": 2038,
"loc": {
"start": {
"line": 27,
"column": 16
},
"end": {
"line": 27,
"column": 56
}
},
"id": {
"type": "Identifier",
"start": 1998,
"end": 2009,
"loc": {
"start": {
"line": 27,
"column": 16
},
"end": {
"line": 27,
"column": 27
},
"identifierName": "thresholdBI"
},
"name": "thresholdBI"
},
"init": {
"type": "LogicalExpression",
"start": 2012,
"end": 2038,
"loc": {
"start": {
"line": 27,
"column": 30
},
"end": {
"line": 27,
"column": 56
}
},
"left": {
"type": "MemberExpression",
"start": 2012,
"end": 2030,
"loc": {
"start": {
"line": 27,
"column": 30
},
"end": {
"line": 27,
"column": 48
}
},
"object": {
"type": "Identifier",
"start": 2012,
"end": 2018,
"loc": {
"start": {
"line": 27,
"column": 30
},
"end": {
"line": 27,
"column": 36
},
"identifierName": "params"
},
"name": "params"
},
"property": {
"type": "Identifier",
"start": 2019,
"end": 2030,
"loc": {
"start": {
"line": 27,
"column": 37
},
"end": {
"line": 27,
"column": 48
},
"identifierName": "thresholdBI"
},
"name": "thresholdBI"
},
"computed": false
},
"operator": "||",
"right": {
"type": "NumericLiteral",
"start": 2034,
"end": 2038,
"loc": {
"start": {
"line": 27,
"column": 52
},
"end": {
"line": 27,
"column": 56
}
},
"extra": {
"rawValue": 0.02,
"raw": "0.02"
},
"value": 0.02
}
}
},
{
"type": "VariableDeclarator",
"start": 2057,
"end": 2097,
"loc": {
"start": {
"line": 28,
"column": 16
},
"end": {
"line": 28,
"column": 56
}
},
"id": {
"type": "Identifier",
"start": 2057,
"end": 2068,
"loc": {
"start": {
"line": 28,
"column": 16
},
"end": {
"line": 28,
"column": 27
},
"identifierName": "thresholdBT"
},
"name": "thresholdBT"
},
"init": {
"type": "LogicalExpression",
"start": 2071,
"end": 2097,
"loc": {
"start": {
"line": 28,
"column": 30
},
"end": {
"line": 28,
"column": 56
}
},
"left": {
"type": "MemberExpression",
"start": 2071,
"end": 2089,
"loc": {
"start": {
"line": 28,
"column": 30
},
"end": {
"line": 28,
"column": 48
}
},
"object": {
"type": "Identifier",
"start": 2071,
"end": 2077,
"loc": {
"start": {
"line": 28,
"column": 30
},
"end": {
"line": 28,
"column": 36
},
"identifierName": "params"
},
"name": "params"
},
"property": {
"type": "Identifier",
"start": 2078,
"end": 2089,
"loc": {
"start": {
"line": 28,
"column": 37
},
"end": {
"line": 28,
"column": 48
},
"identifierName": "thresholdBT"
},
"name": "thresholdBT"
},
"computed": false
},
"operator": "||",
"right": {
"type": "NumericLiteral",
"start": 2093,
"end": 2097,
"loc": {
"start": {
"line": 28,
"column": 52
},
"end": {
"line": 28,
"column": 56
}
},
"extra": {
"rawValue": 0.04,
"raw": "0.04"
},
"value": 0.04
}
}
}
],
"kind": "const"
},
{
"type": "FunctionDeclaration",
"start": 2108,
"end": 3154,
"loc": {
"start": {
"line": 29,
"column": 8
},
"end": {
"line": 54,
"column": 9
}
},
"id": {
"type": "Identifier",
"start": 2117,
"end": 2136,
"loc": {
"start": {
"line": 29,
"column": 17
},
"end": {
"line": 29,
"column": 36
},
"identifierName": "removeSimilarAgents"
},
"name": "removeSimilarAgents"
},
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 2139,
"end": 3154,
"loc": {
"start": {
"line": 29,
"column": 39
},
"end": {
"line": 54,
"column": 9
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 2154,
"end": 2215,
"loc": {
"start": {
"line": 30,
"column": 12
},
"end": {
"line": 30,
"column": 73
}
},
"expression": {
"type": "CallExpression",
"start": 2154,
"end": 2214,
"loc": {
"start": {
"line": 30,
"column": 12
},
"end": {
"line": 30,
"column": 72
}
},
"callee": {
"type": "MemberExpression",
"start": 2154,
"end": 2165,
"loc": {
"start": {
"line": 30,
"column": 12
},
"end": {
"line": 30,
"column": 23
}
},
"object": {
"type": "Identifier",
"start": 2154,
"end": 2160,
"loc": {
"start": {
"line": 30,
"column": 12
},
"end": {
"line": 30,
"column": 18
},
"identifierName": "agents"
},
"name": "agents"
},
"property": {
"type": "Identifier",
"start": 2161,
"end": 2165,
"loc": {
"start": {
"line": 30,
"column": 19
},
"end": {
"line": 30,
"column": 23
},
"identifierName": "sort"
},
"name": "sort"
},
"computed": false
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"start": 2167,
"end": 2212,
"loc": {
"start": {
"line": 30,
"column": 25
},
"end": {
"line": 30,
"column": 70
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [
{
"type": "Identifier",
"start": 2168,
"end": 2170,
"loc": {
"start": {
"line": 30,
"column": 26
},
"end": {
"line": 30,
"column": 28
},
"identifierName": "a1"
},
"name": "a1"
},
{
"type": "Identifier",
"start": 2172,
"end": 2174,
"loc": {
"start": {
"line": 30,
"column": 30
},
"end": {
"line": 30,
"column": 32
},
"identifierName": "a2"
},
"name": "a2"
}
],
"body": {
"type": "BinaryExpression",
"start": 2179,
"end": 2212,
"loc": {
"start": {
"line": 30,
"column": 37
},
"end": {
"line": 30,
"column": 70
}
},
"left": {
"type": "MemberExpression",
"start": 2179,
"end": 2194,
"loc": {
"start": {
"line": 30,
"column": 37
},
"end": {
"line": 30,
"column": 52
}
},
"object": {
"type": "Identifier",
"start": 2179,
"end": 2181,
"loc": {
"start": {
"line": 30,
"column": 37
},
"end": {
"line": 30,
"column": 39
},
"identifierName": "a1"
},
"name": "a1"
},
"property": {
"type": "Identifier",
"start": 2182,
"end": 2194,
"loc": {
"start": {
"line": 30,
"column": 40
},
"end": {
"line": 30,
"column": 52
},
"identifierName": "beatInterval"
},
"name": "beatInterval"
},
"computed": false
},
"operator": "-",
"right": {
"type": "MemberExpression",
"start": 2197,
"end": 2212,
"loc": {
"start": {
"line": 30,
"column": 55
},
"end": {
"line": 30,
"column": 70
}
},
"object": {
"type": "Identifier",
"start": 2197,
"end": 2199,
"loc": {
"start": {
"line": 30,
"column": 55
},
"end": {
"line": 30,
"column": 57
},
"identifierName": "a2"
},
"name": "a2"
},
"property": {
"type": "Identifier",
"start": 2200,
"end": 2212,
"loc": {
"start": {
"line": 30,
"column": 58
},
"end": {
"line": 30,
"column": 70
},
"identifierName": "beatInterval"
},
"name": "beatInterval"
},
"computed": false
}
}
}
]
}
},
{
"type": "VariableDeclaration",
"start": 2229,
"end": 2258,
"loc": {
"start": {
"line": 31,
"column": 12
},
"end": {
"line": 31,
"column": 41
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 2235,
"end": 2257,
"loc": {
"start": {
"line": 31,
"column": 18
},
"end": {
"line": 31,
"column": 40
}
},
"id": {
"type": "Identifier",
"start": 2235,
"end": 2241,
"loc": {
"start": {
"line": 31,
"column": 18
},
"end": {
"line": 31,
"column": 24
},
"identifierName": "length"
},
"name": "length"
},
"init": {
"type": "MemberExpression",
"start": 2244,
"end": 2257,
"loc": {
"start": {
"line": 31,
"column": 27
},
"end": {
"line": 31,
"column": 40
}
},
"object": {
"type": "Identifier",
"start": 2244,
"end": 2250,
"loc": {
"start": {
"line": 31,
"column": 27
},
"end": {
"line": 31,
"column": 33
},
"identifierName": "agents"
},
"name": "agents"
},
"property": {
"type": "Identifier",
"start": 2251,
"end": 2257,
"loc": {
"start": {
"line": 31,
"column": 34
},
"end": {
"line": 31,
"column": 40
},
"identifierName": "length"
},
"name": "length"
},
"computed": false
}
}
],
"kind": "const"
},
{
"type": "ForStatement",
"start": 2272,
"end": 2970,
"loc": {
"start": {
"line": 32,
"column": 12
},
"end": {
"line": 48,
"column": 13
}
},
"init": {
"type": "VariableDeclaration",
"start": 2277,
"end": 2286,
"loc": {
"start": {
"line": 32,
"column": 17
},
"end": {
"line": 32,
"column": 26
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 2281,
"end": 2286,
"loc": {
"start": {
"line": 32,
"column": 21
},
"end": {
"line": 32,
"column": 26
}
},
"id": {
"type": "Identifier",
"start": 2281,
"end": 2282,
"loc": {
"start": {
"line": 32,
"column": 21
},
"end": {
"line": 32,
"column": 22
},
"identifierName": "i"
},
"name": "i"
},
"init": {
"type": "NumericLiteral",
"start": 2285,
"end": 2286,
"loc": {
"start": {
"line": 32,
"column": 25
},
"end": {
"line": 32,
"column": 26
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
],
"kind": "let"
},
"test": {
"type": "BinaryExpression",
"start": 2288,
"end": 2298,
"loc": {
"start": {
"line": 32,
"column": 28
},
"end": {
"line": 32,
"column": 38
}
},
"left": {
"type": "Identifier",
"start": 2288,
"end": 2289,
"loc": {
"start": {
"line": 32,
"column": 28
},
"end": {
"line": 32,
"column": 29
},
"identifierName": "i"
},
"name": "i"
},
"operator": "<",
"right": {
"type": "Identifier",
"start": 2292,
"end": 2298,
"loc": {
"start": {
"line": 32,
"column": 32
},
"end": {
"line": 32,
"column": 38
},
"identifierName": "length"
},
"name": "length"
}
},
"update": {
"type": "UpdateExpression",
"start": 2300,
"end": 2303,
"loc": {
"start": {
"line": 32,
"column": 40
},
"end": {
"line": 32,
"column": 43
}
},
"operator": "++",
"prefix": false,
"argument": {
"type": "Identifier",
"start": 2300,
"end": 2301,
"loc": {
"start": {
"line": 32,
"column": 40
},
"end": {