Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Files Functions Variables Typedefs Macros Groups
Classes | Public Member Functions | Friends | List of all members
Scope Class Reference

An oscilloscope which allows data to be visualised in a browser in real time. More...

#include <Scope.h>

Public Member Functions

void setup (unsigned int numChannels, float sampleRate, int numSliders=0)
 Initialise the scope, setting the number of channels and the sample rate. More...
 
void log (double chn1,...)
 Logs a frame of data to the scope. More...
 
void log (const float *values)
 Logs a frame of data to the scope. More...
 
bool trigger ()
 Cause the scope to trigger when set to custom trigger mode. More...
 
float getSliderValue (int slider)
 Read the value of a slider. More...
 
bool sliderChanged (int slider)
 Check if the value of a slider has changed. More...
 
void setSlider (int slider, float min, float max, float step, float value, std::string name="Slider")
 Initialise a slider's value and parameters. More...
 
void setTrigger (int mode, int channel, int dir, float level)
 Initialise a slider's value and parameters. More...
 

Friends

struct ScopeControlHandler
 

Detailed Description

An oscilloscope which allows data to be visualised in a browser in real time.

To use the scope, ensure the Bela IDE is running, and navigate to http://bela.local/scope

Examples:
sample-piezo-trigger/render.cpp, scope-analog/render.cpp, scope-sliders/render.cpp, scope/render.cpp, and ultrasonic-distance/render.cpp.

Member Function Documentation

void Scope::setup ( unsigned int  numChannels,
float  sampleRate,
int  numSliders = 0 
)

Initialise the scope, setting the number of channels and the sample rate.

This function must be called once during setup. numChannels must be set to the number of parameters passed in to log() or the channels may not be displayed correctly. sampleRate must be the rate at which data is logged to the scope (the rate at which log() is called) in Hz or the x-axis time values displayed on the scope will be incorrect. numSliders is an optional parameter which defaults to 0. Passing a non-zero value will create sliders in the scope's control panel whose values can be read with scope.getSliderValue().

Parameters
numChannelsnumber of channels displayed by the scope.
sampleRatesample rate of the data passed in.
numSliders(optional) number of sliders to create (default is 0)
Examples:
sample-piezo-trigger/render.cpp, scope-analog/render.cpp, scope-sliders/render.cpp, scope/render.cpp, and ultrasonic-distance/render.cpp.
void Scope::log ( double  chn1,
  ... 
)

Logs a frame of data to the scope.

Pass one argument per channel (starting from the first), up to the number of channels of the object. Omitted values will be set to 0.

Examples:
sample-piezo-trigger/render.cpp, scope-analog/render.cpp, scope-sliders/render.cpp, scope/render.cpp, and ultrasonic-distance/render.cpp.
void Scope::log ( const float *  values)

Logs a frame of data to the scope.

Accepts a pointer to an array of floats representing each channel's value in ascending order.

Parameters
valuesa pointer to an array containing numChannels values.
bool Scope::trigger ( )

Cause the scope to trigger when set to custom trigger mode.

This method can be used to force the scope to trigger rather than relying on the typical auto or normal trigger.

Examples:
scope/render.cpp.
float Scope::getSliderValue ( int  slider)

Read the value of a slider.

If a slider was created in setup(), the value of that slider can be read at any time with this function. This allows values in your code to be adjusted in real-time from the scope's UI.

Parameters
sliderthe index of the slider to read
Examples:
scope-sliders/render.cpp.
bool Scope::sliderChanged ( int  slider)

Check if the value of a slider has changed.

Check if the value of a slider has changed since the last time the value of that slider was read using getSliderValue()

Parameters
sliderthe index of the slider to read
void Scope::setSlider ( int  slider,
float  min,
float  max,
float  step,
float  value,
std::string  name = "Slider" 
)

Initialise a slider's value and parameters.

This method can be used to set a slider's value and parameters, including its minimum, maximum, step increment and name. This method is not safe to be called on the audio thread and must be called in setup() only, and not render().

Parameters
sliderthe index of the slider to set
minthe minimum value of the slider
maxthe maximum value of the slider
stepthe step increment of the slider
valuethe initial value of the slider
name(optional) the name of the slider
Examples:
scope-sliders/render.cpp.
void Scope::setTrigger ( int  mode,
int  channel,
int  dir,
float  level 
)

Initialise a slider's value and parameters.

This method can be used to set a slider's value and parameters, including its minimum, maximum, step increment and name. This method is not safe to be called on the audio thread and must be called in setup() only, and not render().

Parameters
sliderthe index of the slider to set
minthe minimum value of the slider
maxthe maximum value of the slider
stepthe step increment of the slider
valuethe initial value of the slider
name(optional) the name of the slider

The documentation for this class was generated from the following file: