@sebastbake/music-tempo
Version:
Finding out tempo of the music
1,435 lines • 510 kB
JSON
{
"type": "File",
"start": 0,
"end": 5980,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 123,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 5980,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 123,
"column": 1
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 46
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 7,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 21
}
},
"local": {
"type": "Identifier",
"start": 7,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 21
},
"identifierName": "OnsetDetection"
},
"name": "OnsetDetection"
}
}
],
"source": {
"type": "StringLiteral",
"start": 27,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 27
},
"end": {
"line": 1,
"column": 45
}
},
"extra": {
"rawValue": "./OnsetDetection",
"raw": "\"./OnsetDetection\""
},
"value": "./OnsetDetection"
}
},
{
"type": "ImportDeclaration",
"start": 48,
"end": 94,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 46
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 55,
"end": 69,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 21
}
},
"local": {
"type": "Identifier",
"start": 55,
"end": 69,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 21
},
"identifierName": "TempoInduction"
},
"name": "TempoInduction"
}
}
],
"source": {
"type": "StringLiteral",
"start": 75,
"end": 93,
"loc": {
"start": {
"line": 2,
"column": 27
},
"end": {
"line": 2,
"column": 45
}
},
"extra": {
"rawValue": "./TempoInduction",
"raw": "\"./TempoInduction\""
},
"value": "./TempoInduction"
}
},
{
"type": "ImportDeclaration",
"start": 96,
"end": 138,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 42
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 103,
"end": 115,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 19
}
},
"local": {
"type": "Identifier",
"start": 103,
"end": 115,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 19
},
"identifierName": "BeatTracking"
},
"name": "BeatTracking"
}
}
],
"source": {
"type": "StringLiteral",
"start": 121,
"end": 137,
"loc": {
"start": {
"line": 3,
"column": 25
},
"end": {
"line": 3,
"column": 41
}
},
"extra": {
"rawValue": "./BeatTracking",
"raw": "\"./BeatTracking\""
},
"value": "./BeatTracking"
}
},
{
"type": "ImportDeclaration",
"start": 140,
"end": 164,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 4,
"column": 24
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 147,
"end": 150,
"loc": {
"start": {
"line": 4,
"column": 7
},
"end": {
"line": 4,
"column": 10
}
},
"local": {
"type": "Identifier",
"start": 147,
"end": 150,
"loc": {
"start": {
"line": 4,
"column": 7
},
"end": {
"line": 4,
"column": 10
},
"identifierName": "FFT"
},
"name": "FFT"
}
}
],
"source": {
"type": "StringLiteral",
"start": 156,
"end": 163,
"loc": {
"start": {
"line": 4,
"column": 16
},
"end": {
"line": 4,
"column": 23
}
},
"extra": {
"rawValue": "./FFT",
"raw": "\"./FFT\""
},
"value": "./FFT"
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "* \r\n * Class combines the work of all the steps of tempo extraction\r\n * @class\r\n ",
"start": 168,
"end": 253,
"loc": {
"start": {
"line": 6,
"column": 0
},
"end": {
"line": 9,
"column": 3
}
}
}
]
},
{
"type": "ExportDefaultDeclaration",
"start": 255,
"end": 5980,
"loc": {
"start": {
"line": 10,
"column": 0
},
"end": {
"line": 123,
"column": 1
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 270,
"end": 5980,
"loc": {
"start": {
"line": 10,
"column": 15
},
"end": {
"line": 123,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 276,
"end": 286,
"loc": {
"start": {
"line": 10,
"column": 21
},
"end": {
"line": 10,
"column": 31
},
"identifierName": "MusicTempo"
},
"name": "MusicTempo",
"leadingComments": null
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 287,
"end": 5980,
"loc": {
"start": {
"line": 10,
"column": 32
},
"end": {
"line": 123,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 2993,
"end": 5977,
"loc": {
"start": {
"line": 38,
"column": 4
},
"end": {
"line": 122,
"column": 5
}
},
"computed": false,
"key": {
"type": "Identifier",
"start": 2993,
"end": 3004,
"loc": {
"start": {
"line": 38,
"column": 4
},
"end": {
"line": 38,
"column": 15
},
"identifierName": "constructor"
},
"name": "constructor",
"leadingComments": null
},
"static": false,
"kind": "constructor",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 3005,
"end": 3014,
"loc": {
"start": {
"line": 38,
"column": 16
},
"end": {
"line": 38,
"column": 25
},
"identifierName": "audioData"
},
"name": "audioData"
},
{
"type": "AssignmentPattern",
"start": 3016,
"end": 3027,
"loc": {
"start": {
"line": 38,
"column": 27
},
"end": {
"line": 38,
"column": 38
}
},
"left": {
"type": "Identifier",
"start": 3016,
"end": 3022,
"loc": {
"start": {
"line": 38,
"column": 27
},
"end": {
"line": 38,
"column": 33
},
"identifierName": "params"
},
"name": "params"
},
"right": {
"type": "ObjectExpression",
"start": 3025,
"end": 3027,
"loc": {
"start": {
"line": 38,
"column": 36
},
"end": {
"line": 38,
"column": 38
}
},
"properties": []
}
}
],
"body": {
"type": "BlockStatement",
"start": 3029,
"end": 5977,
"loc": {
"start": {
"line": 38,
"column": 40
},
"end": {
"line": 122,
"column": 5
}
},
"body": [
{
"type": "IfStatement",
"start": 3040,
"end": 3172,
"loc": {
"start": {
"line": 39,
"column": 8
},
"end": {
"line": 41,
"column": 9
}
},
"test": {
"type": "LogicalExpression",
"start": 3045,
"end": 3110,
"loc": {
"start": {
"line": 39,
"column": 13
},
"end": {
"line": 39,
"column": 78
}
},
"left": {
"type": "UnaryExpression",
"start": 3045,
"end": 3081,
"loc": {
"start": {
"line": 39,
"column": 13
},
"end": {
"line": 39,
"column": 49
}
},
"operator": "!",
"prefix": true,
"argument": {
"type": "BinaryExpression",
"start": 3047,
"end": 3080,
"loc": {
"start": {
"line": 39,
"column": 15
},
"end": {
"line": 39,
"column": 48
}
},
"left": {
"type": "Identifier",
"start": 3047,
"end": 3056,
"loc": {
"start": {
"line": 39,
"column": 15
},
"end": {
"line": 39,
"column": 24
},
"identifierName": "audioData"
},
"name": "audioData"
},
"operator": "instanceof",
"right": {
"type": "Identifier",
"start": 3068,
"end": 3080,
"loc": {
"start": {
"line": 39,
"column": 36
},
"end": {
"line": 39,
"column": 48
},
"identifierName": "Float32Array"
},
"name": "Float32Array"
},
"extra": {
"parenthesized": true,
"parenStart": 3046
}
},
"extra": {
"parenthesizedArgument": false
}
},
"operator": "&&",
"right": {
"type": "UnaryExpression",
"start": 3085,
"end": 3110,
"loc": {
"start": {
"line": 39,
"column": 53
},
"end": {
"line": 39,
"column": 78
}
},
"operator": "!",
"prefix": true,
"argument": {
"type": "CallExpression",
"start": 3086,
"end": 3110,
"loc": {
"start": {
"line": 39,
"column": 54
},
"end": {
"line": 39,
"column": 78
}
},
"callee": {
"type": "MemberExpression",
"start": 3086,
"end": 3099,
"loc": {
"start": {
"line": 39,
"column": 54
},
"end": {
"line": 39,
"column": 67
}
},
"object": {
"type": "Identifier",
"start": 3086,
"end": 3091,
"loc": {
"start": {
"line": 39,
"column": 54
},
"end": {
"line": 39,
"column": 59
},
"identifierName": "Array"
},
"name": "Array"
},
"property": {
"type": "Identifier",
"start": 3092,
"end": 3099,
"loc": {
"start": {
"line": 39,
"column": 60
},
"end": {
"line": 39,
"column": 67
},
"identifierName": "isArray"
},
"name": "isArray"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 3100,
"end": 3109,
"loc": {
"start": {
"line": 39,
"column": 68
},
"end": {
"line": 39,
"column": 77
},
"identifierName": "audioData"
},
"name": "audioData"
}
]
},
"extra": {
"parenthesizedArgument": false
}
}
},
"consequent": {
"type": "BlockStatement",
"start": 3112,
"end": 3172,
"loc": {
"start": {
"line": 39,
"column": 80
},
"end": {
"line": 41,
"column": 9
}
},
"body": [
{
"type": "ThrowStatement",
"start": 3127,
"end": 3161,
"loc": {
"start": {
"line": 40,
"column": 12
},
"end": {
"line": 40,
"column": 46
}
},
"argument": {
"type": "StringLiteral",
"start": 3133,
"end": 3160,
"loc": {
"start": {
"line": 40,
"column": 18
},
"end": {
"line": 40,
"column": 45
}
},
"extra": {
"rawValue": "audioData is not an array",
"raw": "\"audioData is not an array\""
},
"value": "audioData is not an array"
}
}
],
"directives": []
},
"alternate": null
},
{
"type": "VariableDeclaration",
"start": 3182,
"end": 3223,
"loc": {
"start": {
"line": 42,
"column": 8
},
"end": {
"line": 42,
"column": 49
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 3188,
"end": 3222,
"loc": {
"start": {
"line": 42,
"column": 14
},
"end": {
"line": 42,
"column": 48
}
},
"id": {
"type": "Identifier",
"start": 3188,
"end": 3196,
"loc": {
"start": {
"line": 42,
"column": 14
},
"end": {
"line": 42,
"column": 22
},
"identifierName": "timeStep"
},
"name": "timeStep"
},
"init": {
"type": "LogicalExpression",
"start": 3199,
"end": 3222,
"loc": {
"start": {
"line": 42,
"column": 25
},
"end": {
"line": 42,
"column": 48
}
},
"left": {
"type": "MemberExpression",
"start": 3199,
"end": 3214,
"loc": {
"start": {
"line": 42,
"column": 25
},
"end": {
"line": 42,
"column": 40
}
},
"object": {
"type": "Identifier",
"start": 3199,
"end": 3205,
"loc": {
"start": {
"line": 42,
"column": 25
},
"end": {
"line": 42,
"column": 31
},
"identifierName": "params"
},
"name": "params"
},
"property": {
"type": "Identifier",
"start": 3206,
"end": 3214,
"loc": {
"start": {
"line": 42,
"column": 32
},
"end": {
"line": 42,
"column": 40
},
"identifierName": "timeStep"
},
"name": "timeStep"
},
"computed": false
},
"operator": "||",
"right": {
"type": "NumericLiteral",
"start": 3218,
"end": 3222,
"loc": {
"start": {
"line": 42,
"column": 44
},
"end": {
"line": 42,
"column": 48
}
},
"extra": {
"rawValue": 0.01,
"raw": "0.01"
},
"value": 0.01
}
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 3233,
"end": 3294,
"loc": {
"start": {
"line": 43,
"column": 8
},
"end": {
"line": 43,
"column": 69
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 3237,
"end": 3293,
"loc": {
"start": {
"line": 43,
"column": 12
},
"end": {
"line": 43,
"column": 68
}
},
"id": {
"type": "Identifier",
"start": 3237,
"end": 3240,
"loc": {
"start": {
"line": 43,
"column": 12
},
"end": {
"line": 43,
"column": 15
},
"identifierName": "res"
},
"name": "res"
},
"init": {
"type": "CallExpression",
"start": 3243,
"end": 3293,
"loc": {
"start": {
"line": 43,
"column": 18
},
"end": {
"line": 43,
"column": 68
}
},
"callee": {
"type": "MemberExpression",
"start": 3243,
"end": 3269,
"loc": {
"start": {
"line": 43,
"column": 18
},
"end": {
"line": 43,
"column": 44
}
},
"object": {
"type": "Identifier",
"start": 3243,
"end": 3257,
"loc": {
"start": {
"line": 43,
"column": 18
},
"end": {
"line": 43,
"column": 32
},
"identifierName": "OnsetDetection"
},
"name": "OnsetDetection"
},
"property": {
"type": "Identifier",
"start": 3258,
"end": 3269,
"loc": {
"start": {
"line": 43,
"column": 33
},
"end": {
"line": 43,
"column": 44
},
"identifierName": "calculateSF"
},
"name": "calculateSF"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 3270,
"end": 3279,
"loc": {
"start": {
"line": 43,
"column": 45
},
"end": {
"line": 43,
"column": 54
},
"identifierName": "audioData"
},
"name": "audioData"
},
{
"type": "Identifier",
"start": 3281,
"end": 3284,
"loc": {
"start": {
"line": 43,
"column": 56
},
"end": {
"line": 43,
"column": 59
},
"identifierName": "FFT"
},
"name": "FFT"
},
{
"type": "Identifier",
"start": 3286,
"end": 3292,
"loc": {
"start": {
"line": 43,
"column": 61
},
"end": {
"line": 43,
"column": 67
},
"identifierName": "params"
},
"name": "params"
}
]
}
}
],
"kind": "let",
"trailingComments": [
{
"type": "CommentBlock",
"value": "* \r\n * Spectral flux\r\n * @type {Array} \r\n ",
"start": 3304,
"end": 3374,
"loc": {
"start": {
"line": 44,
"column": 8
},
"end": {
"line": 47,
"column": 11
}
}
}
]
},
{
"type": "ExpressionStatement",
"start": 3394,
"end": 3418,
"loc": {
"start": {
"line": 48,
"column": 8
},
"end": {
"line": 48,
"column": 32
}
},
"expression": {
"type": "AssignmentExpression",
"start": 3394,
"end": 3417,
"loc": {
"start": {
"line": 48,
"column": 8
},
"end": {
"line": 48,
"column": 31
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 3394,
"end": 3411,
"loc": {
"start": {
"line": 48,
"column": 8
},
"end": {
"line": 48,
"column": 25
}
},
"object": {
"type": "ThisExpression",
"start": 3394,
"end": 3398,
"loc": {
"start": {
"line": 48,
"column": 8
},
"end": {
"line": 48,
"column": 12
}
},
"leadingComments": null
},
"property": {
"type": "Identifier",
"start": 3399,
"end": 3411,
"loc": {
"start": {
"line": 48,
"column": 13
},
"end": {
"line": 48,
"column": 25
},
"identifierName": "spectralFlux"
},
"name": "spectralFlux"
},
"computed": false,
"leadingComments": null
},
"right": {
"type": "Identifier",
"start": 3414,
"end": 3417,
"loc": {
"start": {
"line": 48,
"column": 28
},
"end": {
"line": 48,
"column": 31
},
"identifierName": "res"
},
"name": "res"
},
"leadingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "* \r\n * Spectral flux\r\n * @type {Array} \r\n ",
"start": 3304,
"end": 3374,
"loc": {
"start": {
"line": 44,
"column": 8
},
"end": {
"line": 47,
"column": 11
}
}
}
]
},
{
"type": "ExpressionStatement",
"start": 3428,
"end": 3472,
"loc": {
"start": {
"line": 49,
"column": 8
},
"end": {
"line": 49,
"column": 52
}
},
"expression": {
"type": "CallExpression",
"start": 3428,
"end": 3471,
"loc": {
"start": {
"line": 49,
"column": 8
},
"end": {
"line": 49,
"column": 51
}
},
"callee": {
"type": "MemberExpression",
"start": 3428,
"end": 3452,
"loc": {
"start": {
"line": 49,
"column": 8
},
"end": {
"line": 49,
"column": 32
}
},
"object": {
"type": "Identifier",
"start": 3428,
"end": 3442,
"loc": {
"start": {
"line": 49,
"column": 8
},
"end": {
"line": 49,
"column": 22
},
"identifierName": "OnsetDetection"
},
"name": "OnsetDetection"
},
"property": {
"type": "Identifier",
"start": 3443,
"end": 3452,
"loc": {
"start": {
"line": 49,
"column": 23
},
"end": {
"line": 49,
"column": 32
},
"identifierName": "normalize"
},
"name": "normalize"
},
"computed": false
},
"arguments": [
{
"type": "MemberExpression",
"start": 3453,
"end": 3470,
"loc": {
"start": {
"line": 49,
"column": 33
},
"end": {
"line": 49,
"column": 50
}
},
"object": {
"type": "ThisExpression",
"start": 3453,
"end": 3457,
"loc": {
"start": {
"line": 49,
"column": 33
},
"end": {
"line": 49,
"column": 37
}
}
},
"property": {
"type": "Identifier",
"start": 3458,
"end": 3470,
"loc": {
"start": {
"line": 49,
"column": 38
},
"end": {
"line": 49,
"column": 50
},
"identifierName": "spectralFlux"
},
"name": "spectralFlux"
},
"computed": false
}
]
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "* \r\n * Spectral flux peaks indexes\r\n * @type {Array} \r\n ",
"start": 3482,
"end": 3566,
"loc": {
"start": {
"line": 50,
"column": 8
},
"end": {
"line": 53,
"column": 11
}
}
}
]
},
{
"type": "ExpressionStatement",
"start": 3585,
"end": 3650,
"loc": {
"start": {
"line": 54,
"column": 8
},
"end": {
"line": 54,
"column": 73
}
},
"expression": {
"type": "AssignmentExpression",
"start": 3585,
"end": 3649,
"loc": {
"start": {
"line": 54,
"column": 8
},
"end": {
"line": 54,
"column": 72
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 3585,
"end": 3595,
"loc": {
"start": {
"line": 54,
"column": 8
},
"end": {
"line": 54,
"column": 18
}
},
"object": {
"type": "ThisExpression",
"start": 3585,
"end": 3589,
"loc": {
"start": {
"line": 54,
"column": 8
},
"end": {
"line": 54,
"column": 12
}
},
"leadingComments": null
},
"property": {
"type": "Identifier",
"start": 3590,
"end": 3595,
"loc": {
"start": {
"line": 54,
"column": 13
},
"end": {
"line": 54,
"column": 18
},
"identifierName": "peaks"
},
"name": "peaks"
},
"computed": false,
"lead