hi all... ive got a flow where im calculating the tempo of some music by tapping a button in time with the beat.. problem is i dont think its doing a great job and im wondering if someone might have a better method.. possibly a way of doing it all in a function node where timing could be pretty accurate ?
here is what i have..
[
{
"id": "6c913a509314f175",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "6d10a55b844e105c",
"type": "function",
"z": "6c913a509314f175",
"name": "Tempo",
"func": "let interval = msg.interval\nlet count\nlet tempo\n\ncount = 1-(interval / 1000);\ntempo = count*4*60;\n\nmsg.payload = Math.floor(tempo/1)*1 \n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 690,
"y": 200,
"wires": [
[
"ad1050e6144ac0ae"
]
]
},
{
"id": "e6319cdc2abfa468",
"type": "interval-length",
"z": "6c913a509314f175",
"format": "mills",
"bytopic": false,
"minimum": "",
"maximum": "",
"window": "",
"timeout": false,
"msgTimeout": "2",
"minimumunit": "msecs",
"maximumunit": "msecs",
"windowunit": "msecs",
"msgTimeoutUnit": "secs",
"reset": true,
"startup": false,
"msgField": "interval",
"timestampField": "timestamp",
"repeatTimeout": false,
"name": "Interval",
"x": 380,
"y": 200,
"wires": [
[
"5660bc8ade2a3098"
],
[
"9f839aae647eb9eb"
]
]
},
{
"id": "9f839aae647eb9eb",
"type": "change",
"z": "6c913a509314f175",
"name": "reset",
"rules": [
{
"t": "set",
"p": "reset",
"pt": "msg",
"to": "true",
"tot": "bool"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 390,
"y": 260,
"wires": [
[
"e6319cdc2abfa468"
]
]
},
{
"id": "78444743675c6619",
"type": "inject",
"z": "6c913a509314f175",
"name": "tap tempo",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "str",
"x": 220,
"y": 200,
"wires": [
[
"e6319cdc2abfa468"
]
]
},
{
"id": "ad1050e6144ac0ae",
"type": "debug",
"z": "6c913a509314f175",
"name": "debug 183",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 830,
"y": 200,
"wires": []
},
{
"id": "5660bc8ade2a3098",
"type": "smooth",
"z": "6c913a509314f175",
"name": "",
"property": "payload",
"action": "mean",
"count": "3",
"round": "",
"mult": "single",
"reduce": false,
"x": 560,
"y": 200,
"wires": [
[
"6d10a55b844e105c"
]
]
}
]