@sebastbake/music-tempo
Version:
Finding out tempo of the music
1,282 lines (1,281 loc) • 673 kB
JSON
{
"type": "File",
"start": 0,
"end": 2950,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 87,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 2950,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 87,
"column": 1
}
},
"sourceType": "module",
"body": [
{
"type": "ExportDefaultDeclaration",
"start": 78,
"end": 2950,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 87,
"column": 1
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 93,
"end": 2950,
"loc": {
"start": {
"line": 5,
"column": 15
},
"end": {
"line": 87,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 99,
"end": 102,
"loc": {
"start": {
"line": 5,
"column": 21
},
"end": {
"line": 5,
"column": 24
},
"identifierName": "FFT"
},
"name": "FFT",
"leadingComments": null
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 103,
"end": 2950,
"loc": {
"start": {
"line": 5,
"column": 25
},
"end": {
"line": 87,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 257,
"end": 697,
"loc": {
"start": {
"line": 11,
"column": 4
},
"end": {
"line": 22,
"column": 5
}
},
"computed": false,
"key": {
"type": "Identifier",
"start": 264,
"end": 280,
"loc": {
"start": {
"line": 11,
"column": 11
},
"end": {
"line": 11,
"column": 27
},
"identifierName": "getHammingWindow"
},
"name": "getHammingWindow"
},
"static": true,
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 281,
"end": 291,
"loc": {
"start": {
"line": 11,
"column": 28
},
"end": {
"line": 11,
"column": 38
},
"identifierName": "bufferSize"
},
"name": "bufferSize"
}
],
"body": {
"type": "BlockStatement",
"start": 293,
"end": 697,
"loc": {
"start": {
"line": 11,
"column": 40
},
"end": {
"line": 22,
"column": 5
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 304,
"end": 322,
"loc": {
"start": {
"line": 12,
"column": 8
},
"end": {
"line": 12,
"column": 26
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 310,
"end": 321,
"loc": {
"start": {
"line": 12,
"column": 14
},
"end": {
"line": 12,
"column": 25
}
},
"id": {
"type": "Identifier",
"start": 310,
"end": 311,
"loc": {
"start": {
"line": 12,
"column": 14
},
"end": {
"line": 12,
"column": 15
},
"identifierName": "a"
},
"name": "a"
},
"init": {
"type": "BinaryExpression",
"start": 314,
"end": 321,
"loc": {
"start": {
"line": 12,
"column": 18
},
"end": {
"line": 12,
"column": 25
}
},
"left": {
"type": "NumericLiteral",
"start": 314,
"end": 316,
"loc": {
"start": {
"line": 12,
"column": 18
},
"end": {
"line": 12,
"column": 20
}
},
"extra": {
"rawValue": 25,
"raw": "25"
},
"value": 25
},
"operator": "/",
"right": {
"type": "NumericLiteral",
"start": 319,
"end": 321,
"loc": {
"start": {
"line": 12,
"column": 23
},
"end": {
"line": 12,
"column": 25
}
},
"extra": {
"rawValue": 46,
"raw": "46"
},
"value": 46
}
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 332,
"end": 350,
"loc": {
"start": {
"line": 13,
"column": 8
},
"end": {
"line": 13,
"column": 26
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 338,
"end": 349,
"loc": {
"start": {
"line": 13,
"column": 14
},
"end": {
"line": 13,
"column": 25
}
},
"id": {
"type": "Identifier",
"start": 338,
"end": 339,
"loc": {
"start": {
"line": 13,
"column": 14
},
"end": {
"line": 13,
"column": 15
},
"identifierName": "b"
},
"name": "b"
},
"init": {
"type": "BinaryExpression",
"start": 342,
"end": 349,
"loc": {
"start": {
"line": 13,
"column": 18
},
"end": {
"line": 13,
"column": 25
}
},
"left": {
"type": "NumericLiteral",
"start": 342,
"end": 344,
"loc": {
"start": {
"line": 13,
"column": 18
},
"end": {
"line": 13,
"column": 20
}
},
"extra": {
"rawValue": 21,
"raw": "21"
},
"value": 21
},
"operator": "/",
"right": {
"type": "NumericLiteral",
"start": 347,
"end": 349,
"loc": {
"start": {
"line": 13,
"column": 23
},
"end": {
"line": 13,
"column": 25
}
},
"extra": {
"rawValue": 46,
"raw": "46"
},
"value": 46
}
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 360,
"end": 396,
"loc": {
"start": {
"line": 14,
"column": 8
},
"end": {
"line": 14,
"column": 44
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 366,
"end": 395,
"loc": {
"start": {
"line": 14,
"column": 14
},
"end": {
"line": 14,
"column": 43
}
},
"id": {
"type": "Identifier",
"start": 366,
"end": 371,
"loc": {
"start": {
"line": 14,
"column": 14
},
"end": {
"line": 14,
"column": 19
},
"identifierName": "scale"
},
"name": "scale"
},
"init": {
"type": "BinaryExpression",
"start": 374,
"end": 395,
"loc": {
"start": {
"line": 14,
"column": 22
},
"end": {
"line": 14,
"column": 43
}
},
"left": {
"type": "BinaryExpression",
"start": 374,
"end": 388,
"loc": {
"start": {
"line": 14,
"column": 22
},
"end": {
"line": 14,
"column": 36
}
},
"left": {
"type": "NumericLiteral",
"start": 374,
"end": 375,
"loc": {
"start": {
"line": 14,
"column": 22
},
"end": {
"line": 14,
"column": 23
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
},
"operator": "/",
"right": {
"type": "Identifier",
"start": 378,
"end": 388,
"loc": {
"start": {
"line": 14,
"column": 26
},
"end": {
"line": 14,
"column": 36
},
"identifierName": "bufferSize"
},
"name": "bufferSize"
}
},
"operator": "/",
"right": {
"type": "NumericLiteral",
"start": 391,
"end": 395,
"loc": {
"start": {
"line": 14,
"column": 39
},
"end": {
"line": 14,
"column": 43
}
},
"extra": {
"rawValue": 0.54,
"raw": "0.54"
},
"value": 0.54
}
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 407,
"end": 453,
"loc": {
"start": {
"line": 15,
"column": 8
},
"end": {
"line": 15,
"column": 54
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 413,
"end": 452,
"loc": {
"start": {
"line": 15,
"column": 14
},
"end": {
"line": 15,
"column": 53
}
},
"id": {
"type": "Identifier",
"start": 413,
"end": 427,
"loc": {
"start": {
"line": 15,
"column": 14
},
"end": {
"line": 15,
"column": 28
},
"identifierName": "sqrtBufferSize"
},
"name": "sqrtBufferSize"
},
"init": {
"type": "CallExpression",
"start": 431,
"end": 452,
"loc": {
"start": {
"line": 15,
"column": 32
},
"end": {
"line": 15,
"column": 53
}
},
"callee": {
"type": "MemberExpression",
"start": 431,
"end": 440,
"loc": {
"start": {
"line": 15,
"column": 32
},
"end": {
"line": 15,
"column": 41
}
},
"object": {
"type": "Identifier",
"start": 431,
"end": 435,
"loc": {
"start": {
"line": 15,
"column": 32
},
"end": {
"line": 15,
"column": 36
},
"identifierName": "Math"
},
"name": "Math"
},
"property": {
"type": "Identifier",
"start": 436,
"end": 440,
"loc": {
"start": {
"line": 15,
"column": 37
},
"end": {
"line": 15,
"column": 41
},
"identifierName": "sqrt"
},
"name": "sqrt"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 441,
"end": 451,
"loc": {
"start": {
"line": 15,
"column": 42
},
"end": {
"line": 15,
"column": 52
},
"identifierName": "bufferSize"
},
"name": "bufferSize"
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 463,
"end": 505,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 50
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 469,
"end": 504,
"loc": {
"start": {
"line": 16,
"column": 14
},
"end": {
"line": 16,
"column": 49
}
},
"id": {
"type": "Identifier",
"start": 469,
"end": 475,
"loc": {
"start": {
"line": 16,
"column": 14
},
"end": {
"line": 16,
"column": 20
},
"identifierName": "factor"
},
"name": "factor"
},
"init": {
"type": "BinaryExpression",
"start": 478,
"end": 504,
"loc": {
"start": {
"line": 16,
"column": 23
},
"end": {
"line": 16,
"column": 49
}
},
"left": {
"type": "BinaryExpression",
"start": 479,
"end": 490,
"loc": {
"start": {
"line": 16,
"column": 24
},
"end": {
"line": 16,
"column": 35
}
},
"left": {
"type": "MemberExpression",
"start": 479,
"end": 486,
"loc": {
"start": {
"line": 16,
"column": 24
},
"end": {
"line": 16,
"column": 31
}
},
"object": {
"type": "Identifier",
"start": 479,
"end": 483,
"loc": {
"start": {
"line": 16,
"column": 24
},
"end": {
"line": 16,
"column": 28
},
"identifierName": "Math"
},
"name": "Math"
},
"property": {
"type": "Identifier",
"start": 484,
"end": 486,
"loc": {
"start": {
"line": 16,
"column": 29
},
"end": {
"line": 16,
"column": 31
},
"identifierName": "PI"
},
"name": "PI"
},
"computed": false
},
"operator": "*",
"right": {
"type": "NumericLiteral",
"start": 489,
"end": 490,
"loc": {
"start": {
"line": 16,
"column": 34
},
"end": {
"line": 16,
"column": 35
}
},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
},
"extra": {
"parenthesized": true,
"parenStart": 478
}
},
"operator": "/",
"right": {
"type": "Identifier",
"start": 494,
"end": 504,
"loc": {
"start": {
"line": 16,
"column": 39
},
"end": {
"line": 16,
"column": 49
},
"identifierName": "bufferSize"
},
"name": "bufferSize"
}
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 515,
"end": 528,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 21
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 519,
"end": 527,
"loc": {
"start": {
"line": 17,
"column": 12
},
"end": {
"line": 17,
"column": 20
}
},
"id": {
"type": "Identifier",
"start": 519,
"end": 522,
"loc": {
"start": {
"line": 17,
"column": 12
},
"end": {
"line": 17,
"column": 15
},
"identifierName": "wnd"
},
"name": "wnd"
},
"init": {
"type": "ArrayExpression",
"start": 525,
"end": 527,
"loc": {
"start": {
"line": 17,
"column": 18
},
"end": {
"line": 17,
"column": 20
}
},
"elements": []
}
}
],
"kind": "let"
},
{
"type": "ForStatement",
"start": 538,
"end": 669,
"loc": {
"start": {
"line": 18,
"column": 8
},
"end": {
"line": 20,
"column": 9
}
},
"init": {
"type": "VariableDeclaration",
"start": 543,
"end": 552,
"loc": {
"start": {
"line": 18,
"column": 13
},
"end": {
"line": 18,
"column": 22
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 547,
"end": 552,
"loc": {
"start": {
"line": 18,
"column": 17
},
"end": {
"line": 18,
"column": 22
}
},
"id": {
"type": "Identifier",
"start": 547,
"end": 548,
"loc": {
"start": {
"line": 18,
"column": 17
},
"end": {
"line": 18,
"column": 18
},
"identifierName": "i"
},
"name": "i"
},
"init": {
"type": "NumericLiteral",
"start": 551,
"end": 552,
"loc": {
"start": {
"line": 18,
"column": 21
},
"end": {
"line": 18,
"column": 22
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
],
"kind": "let"
},
"test": {
"type": "BinaryExpression",
"start": 554,
"end": 568,
"loc": {
"start": {
"line": 18,
"column": 24
},
"end": {
"line": 18,
"column": 38
}
},
"left": {
"type": "Identifier",
"start": 554,
"end": 555,
"loc": {
"start": {
"line": 18,
"column": 24
},
"end": {
"line": 18,
"column": 25
},
"identifierName": "i"
},
"name": "i"
},
"operator": "<",
"right": {
"type": "Identifier",
"start": 558,
"end": 568,
"loc": {
"start": {
"line": 18,
"column": 28
},
"end": {
"line": 18,
"column": 38
},
"identifierName": "bufferSize"
},
"name": "bufferSize"
}
},
"update": {
"type": "UpdateExpression",
"start": 570,
"end": 573,
"loc": {
"start": {
"line": 18,
"column": 40
},
"end": {
"line": 18,
"column": 43
}
},
"operator": "++",
"prefix": false,
"argument": {
"type": "Identifier",
"start": 570,
"end": 571,
"loc": {
"start": {
"line": 18,
"column": 40
},
"end": {
"line": 18,
"column": 41
},
"identifierName": "i"
},
"name": "i"
}
},
"body": {
"type": "BlockStatement",
"start": 575,
"end": 669,
"loc": {
"start": {
"line": 18,
"column": 45
},
"end": {
"line": 20,
"column": 9
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 590,
"end": 658,
"loc": {
"start": {
"line": 19,
"column": 12
},
"end": {
"line": 19,
"column": 80
}
},
"expression": {
"type": "AssignmentExpression",
"start": 590,
"end": 656,
"loc": {
"start": {
"line": 19,
"column": 12
},
"end": {
"line": 19,
"column": 78
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 590,
"end": 596,
"loc": {
"start": {
"line": 19,
"column": 12
},
"end": {
"line": 19,
"column": 18
}
},
"object": {
"type": "Identifier",
"start": 590,
"end": 593,
"loc": {
"start": {
"line": 19,
"column": 12
},
"end": {
"line": 19,
"column": 15
},
"identifierName": "wnd"
},
"name": "wnd"
},
"property": {
"type": "Identifier",
"start": 594,
"end": 595,
"loc": {
"start": {
"line": 19,
"column": 16
},
"end": {
"line": 19,
"column": 17
},
"identifierName": "i"
},
"name": "i"
},
"computed": true
},
"right": {
"type": "BinaryExpression",
"start": 599,
"end": 656,
"loc": {
"start": {
"line": 19,
"column": 21
},
"end": {
"line": 19,
"column": 78
}
},
"left": {
"type": "Identifier",
"start": 599,
"end": 613,
"loc": {
"start": {
"line": 19,
"column": 21
},
"end": {
"line": 19,
"column": 35
},
"identifierName": "sqrtBufferSize"
},
"name": "sqrtBufferSize"
},
"operator": "*",
"right": {
"type": "BinaryExpression",
"start": 617,
"end": 655,
"loc": {
"start": {
"line": 19,
"column": 39
},
"end": {
"line": 19,
"column": 77
}
},
"left": {
"type": "Identifier",
"start": 617,
"end": 622,
"loc": {
"start": {
"line": 19,
"column": 39
},
"end": {
"line": 19,
"column": 44
},
"identifierName": "scale"
},
"name": "scale"
},
"operator": "*",
"right": {
"type": "BinaryExpression",
"start": 626,
"end": 654,
"loc": {
"start": {
"line": 19,
"column": 48
},
"end": {
"line": 19,
"column": 76
}
},
"left": {
"type": "Identifier",
"start": 626,
"end": 627,
"loc": {
"start": {
"line": 19,
"column": 48
},
"end": {
"line": 19,
"column": 49
},
"identifierName": "a"
},
"name": "a"
},
"operator": "-",
"right": {
"type": "BinaryExpression",
"start": 630,
"end": 654,
"loc": {
"start": {
"line": 19,
"column": 52
},
"end": {
"line": 19,
"column": 76
}
},
"left": {
"type": "Identifier",
"start": 630,
"end": 631,
"loc": {
"start": {
"line": 19,
"column": 52
},
"end": {
"line": 19,
"column": 53
},
"identifierName": "b"
},
"name": "b"
},
"operator": "*",
"right": {
"type": "CallExpression",
"start": 634,