We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi - I am working on an installation that will be using 'real time' data from an AQ mesh pod API. I want to turn the data (which provides a minute-to-minute output of this data) into a JS object and then sonify. Below is the data I am receiving:
SAMPLE:
[
{
"Timestamp": "2018-03-18 00:15:00",
"StationType": "AQMeshPod",
"GasProtocol": "4.2.2",
"ParticleProtocol": null,
"Channels": [
{
"ChannelNumber": null,
"PreScaled": -13.0183,
"Scaled": -13.2733,
"Offset": -0.2549999952,
"Slope": 1,
"Status": "sampling",
"UnitId": 3,
"SensorId": 0
},
{
"ChannelNumber": null,
"PreScaled": 6.3399,
"Scaled": 12.9826,
"Offset": 6.6427001953,
"Slope": 1,
"Status": "sampling",
"UnitId": 3,
"SensorId": 1
},
{
"ChannelNumber": null,
"PreScaled": 22.524401,
"Scaled": 23.987284,
"Offset": 1.2015999556,
"Slope": 1.0116000175,
"Status": "sampling",
"UnitId": 3,
"SensorId": 8
},
{
"ChannelNumber": null,
"PreScaled": 0,
"Scaled": 0,
"Offset": 0,
"Slope": 1,
"Status": "sampling",
"UnitId": 9,
"SensorId": 18
},
{
"ChannelNumber": null,
"PreScaled": 84.400002,
"Scaled": 84.400002,
"Offset": 0,
"Slope": 1,
"Status": "sampling",
"UnitId": 10,
"SensorId": 19
},
{
"ChannelNumber": null,
"PreScaled": 1004.700012,
"Scaled": 1004.700012,
"Offset": 0,
"Slope": 1,
"Status": "sampling",
"UnitId": 31,
"SensorId": 364
},
{
"ChannelNumber": null,
"PreScaled": 3.5,
"Scaled": 3.5,
"Offset": 0,
"Slope": 1,
"Status": "sampling",
"UnitId": 35,
"SensorId": 580
}
]
},
{
"Timestamp": "2018-03-18 00:16:00",
"StationType": "AQMeshPod",
"GasProtocol": "4.2.2",
"ParticleProtocol": null,
"Channels": [
{
"ChannelNumber": null,
"PreScaled": -16.691601,
"Scaled": -16.946601,
"Offset": -0.2549999952,
"Slope": 1,
"Status": "sampling",
"UnitId": 3,
"SensorId": 0
},
{
"ChannelNumber": null,
"PreScaled": 7.1464,
"Scaled": 13.7891,
"Offset": 6.6427001953,
"Slope": 1,
"Status": "sampling",
"UnitId": 3,
"SensorId": 1
},
{
"ChannelNumber": null,
"PreScaled": 23.385099,
"Scaled": 24.857967,
"Offset": 1.2015999556,
"Slope": 1.0116000175,
"Status": "sampling",
"UnitId": 3,
"SensorId": 8
},
{
"ChannelNumber": null,
"PreScaled": 0,
"Scaled": 0,
"Offset": 0,
"Slope": 1,
"Status": "sampling",
"UnitId": 9,
"SensorId": 18
},
{
"ChannelNumber": null,
"PreScaled": 84.300003,
"Scaled": 84.300003,
"Offset": 0,
"Slope": 1,
"Status": "sampling",
"UnitId": 10,
"SensorId": 19
},
{
"ChannelNumber": null,
"PreScaled": 1004.700012,
"Scaled": 1004.700012,
"Offset": 0,
"Slope": 1,
"Status": "sampling",
"UnitId": 31,
"SensorId": 364
},
{
"ChannelNumber": null,
"PreScaled": 3.5,
"Scaled": 3.5,
"Offset": 0,
"Slope": 1,
"Status": "sampling",
"UnitId": 35,
"SensorId": 580
}
]
}
I am plenty comfortable processing the JS into audio in the browser, but does anyone have any experience with this sort of thing? I have toyed with APIs in the past, but I am not well-versed.
AQ mesh > https://www.aqmesh.com/product/
Answers
go to the reference and check json
say loadJson
And use the JsonObject
I guess it’s an jsonArray
Then show your attempt and we help you
Best, Chrisir ;-)
For sonify look at library sound or google minim processing library
thanks @chrisir ! what exactly do you mean when you say go to the reference? do you mean the link? sorry, slow sometimes...
yeah reference to look up commands if you need it
Reference
https://www.processing.org/reference/
JSON
https://www.processing.org/reference/loadJSONObject_.html
https://www.processing.org/reference/loadJSONArray_.html
Sound
https://www.processing.org/reference/libraries/sound/index.html
http://code.compartmental.net/tools/minim/
@chrisir :)
;-)
I have the impression the OP is working in JS. If so, you will need these links instead:
https://p5js.org/reference/
https://p5js.org/reference/#/p5/loadJSON
Consider checking as well: https://github.com/processing/p5.js/issues/1451 as they talk about cross-origin resource sharing.
Kf