Hi, I have two pieces of code I want to connect togheter.
The first one is a simple hashtag counter. The second one is an node.js osc library.
I want to get the data from the counter and send it with osc to sonic pi.
The data is in form of a posts.length and that is the value to send via osc.
At the moment I’m unable to figure out how to pass the counter data (posts.length) and send it to the osc send function.
Any help is greatly appreciated
(async() => {
console.log("Hashtag Script")
let ig = await login();
async function hashtag(ig) {
let hashtag = "cat";
console.log("\n -- Hashtag counter --\n".bold.underline);
let posts = await recentHashtagList(ig, hashtag);
console.log("Posts received with hashtag: ".cyan + *posts.length*);
oscPort.on("ready", function() {
oscPort.send({
address: "/osc*/play/note",
args: [{
type: "f",
value: *posts.length*
}]
});
});
let promises = [];
for (let i = 0; i < posts.length; i++) {
let post = posts[i];
}
Promise.all(promises).then(function() {
console.log("end");
});
}
// every 10 minutes do hashtag job
schedule.scheduleJob('*/10 * * * *', async function() { await hashtag(ig) });
})();