you can send whatever values you want to the GUI. If you load up the Gui/bela-to-gui example, you can replace the gui.sendBuffer line with
gui.sendBuffer(0, analogRead(context, 0, 0));
and in sketch.js, replace background(colors[counter % 5]); with
background(colors[parseInt(counter % 5)]);
this will send one frame of analog input from channel 0 and display its value in the GUI.
You can also send multiple values per buffer, e.g.:
float ins[context->analogInChannels];
for(size_t c = 0; c < context->analogInChannels; ++c)
ins[c] = analogRead(context, 0, c);
....
gui.sendBuffer(0, ins, context->analogInChannels);
The example above only takes one value per channel: 0 means the first frame from each analog in. Alternatively, you can send all of the frames from a given channel (channel 3 in the example below):
float ins[context->analogFrames];
for(size_t n = 0; n < context->analogFrames; ++n)
ins[n] = analogRead(context, n, 3);
....
gui.sendBuffer(0, ins, context->analogFrames);
When sending arrays from the backend, in the frontend `sketch.js you'll have to handle them as such. E.g.:
function draw() {
//Read buffer with index 0 coming from render.cpp.
let analogIns = Bela.data.buffers[0];
if(!analogIns)
return;
background(255);
stroke('red');
beginShape();
for(let n = 0; n < analogIns.length; ++n) {
let x = n / analogIns.length;
let y = analogIns[n];
vertex(windowWidth * x, windowHeight * y);
}
endShape();
}