Is this project you can find a sketch.js file which is a p5.js file that is rendered in a browser tab. Click the GUI button (next to the Scope button) in the IDE to see the rendering of this file.
This example sends voltage readings from one of the analog inputs in Bela and the corresponding timestamp (in milliseconds) to be represented as a graph in the browser. Buffers are sent with id 0 and 1 corresponding to the timestamps and the voltage respectively: gui.sendBuffer(0, gTimestamps); gui.sendBuffer(1, gVoltage);
The p5.js file displays the received data in a graph using a library called grafica.js The graph will be updated with new values until the page is refreshed, Pressing the space bar will stop the auto scrolling and allow to scroll manually and zoom in to se the values of the different points. Pressing the space bar again will resume the auto scrolling.
If you want to edit sketch.js you can do so in the browser but must write your p5.js code in instance mode.
 
#include <vector>
#include <libraries/Gui/Gui.h>
 
 
std::vector <float> gTimestamps;
std::vector <float> gVoltage;
 
int gSensorChanel = 0;
 
float gReadPeriod = 0.01;
float gSendPeriod = 1;
 
float gLastTimeRecorded = 0;
 
float gInverseAnalogSampleRate = 0;
 
float gAnalogScale = 4.096; 
 
 
{
        
        
        unsigned int numElements = gSendPeriod / gReadPeriod + 0.5;
        gTimestamps.reserve(numElements);
        gVoltage.reserve(numElements);
 
        return true;
}
 
{
        static int readFramesElapsed = 0;
        static int sendFramesElapsed = 0;
 
 
                
                        
                        float millis = gLastTimeRecorded + 1000*readFramesElapsed*gInverseAnalogSampleRate;
                        gLastTimeRecorded = millis;
                        
                        float analogVolt = gAnalogScale * 
analogRead(context, n, gSensorChanel);
 
                        
                        gTimestamps.push_back(millis);
                        gVoltage.push_back(analogVolt);
 
                        readFramesElapsed = 0;
                }
                ++readFramesElapsed;
 
                
                        
                        if(gui.isConnected()) {
                                
                                gui.sendBuffer(0, gTimestamps);
                                gui.sendBuffer(1, gVoltage);
 
                                
                                gTimestamps.clear();
                                gVoltage.clear();
                        }
 
                        sendFramesElapsed = 0;
                }
                ++sendFramesElapsed;
 
        }
}
 
{
}
static float analogRead(BelaContext *context, int frame, int channel)
Read an analog input, specifying the frame number (when to read) and the channel.
Definition Bela.h:1480
void render(BelaContext *context, void *userData)
User-defined callback function to process audio and sensor data.
Definition render.cpp:68
bool setup(BelaContext *context, void *userData)
User-defined initialisation function which runs before audio rendering begins.
Definition render.cpp:51
void cleanup(BelaContext *context, void *userData)
User-defined cleanup function which runs when the program finishes.
Definition render.cpp:96
Structure holding audio and sensor settings and pointers to I/O data buffers.
Definition Bela.h:231
char projectName[MAX_PROJECTNAME_LENGTH]
Name of running project.
Definition Bela.h:417
const uint32_t analogFrames
The number of analog frames per block.
Definition Bela.h:341
const float analogSampleRate
Analog sample rate in Hz.
Definition Bela.h:362