Receive
You need to define something to be called when Pd receive the thing you want.
Pd4Web.onBangReceived
Pd4Web.onBangReceived("mybang", function () {
console.log("Received a bang");
});
[s mybang]
.
Pd4Web.onFloatReceived
Pd4Web.onFloatReceived("myfloat", function (f) {
console.log("Received " + f)
});
[s myfloat]
.
Pd4Web.onSymbolReceived
Pd4Web.onSymbolReceived("mysymbol", function (s) {
console.log("Received " + s)
});
[s mysymbol]
.
Pd4Web.onListReceived
Pd4Web.onListReceived("mylist", function (mylist) {
console.log("Received list");
});
[s mylist]
.
On the Score Follower example in the main page, I use Pd4Web.onFloatReceived
:
Pd4Web.onFloatReceived("score-render", function (f) {
var svgId = notes[f].getSVGId();
var svgElement = document.getElementById("vf-" + svgId);
var noteheadElement = svgElement.querySelector(".vf-notehead");
var pathElement = noteheadElement.querySelector("path");
pathElement.setAttribute("fill", "red");
});
In this example, always that the object o.scofo~
receive a float from the score-render
sender I change the color of the notehead of the note that is being detected from the o.scofo~
object to red. Check the example here, the source code, and the Pd patch.