Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Functions
Wiring language support

Functions

static float map (float x, float in_min, float in_max, float out_min, float out_max)
 Linearly rescale a number from one range of values to another. More...
 
static float constrain (float x, float min_val, float max_val)
 Constrain a number to stay within a given range. More...
 
static float min (float x, float y)
 Returns the maximum of two numbers. More...
 
static float max (float x, float y)
 Returns the minimum of two numbers. More...
 

Detailed Description

These are functions found in the Wiring (Arduino) language which are not directly related to I/O but are provided as a convenience.

Function Documentation

static float map ( float  x,
float  in_min,
float  in_max,
float  out_min,
float  out_max 
)
inlinestatic

Linearly rescale a number from one range of values to another.

This function linearly scales values of x such that the range in_min to in_max at the input corresponds to the range out_min to out_max at the output. Values outside this range are extrapolated.

This function behaves identically to the function of the same name in Processing. It is also similar to the corresponding function in Arduino, except that it supports floating point values.

Parameters
xInput value to be mapped.
in_minLower bound of the input range.
in_maxUpper bound of the input range.
out_minLower bound of the output range.
out_maxUpper bound of the output range.
Returns
Rescaled value.
Examples:
Analog/analog-input/render.cpp, Analog/scope-analog/render.cpp, Audio/tremolo/render.cpp, Communication/Serial/render.cpp, Extras/oscillator-bank/render.cpp, Gui/gui-to-bela/render.cpp, Gui/mouse-track/render.cpp, Sensors/LDR/render.cpp, Trill/bar-sound/render.cpp, Trill/hex-sound/render.cpp, and Trill/square-sound/render.cpp.
static float constrain ( float  x,
float  min_val,
float  max_val 
)
inlinestatic

Constrain a number to stay within a given range.

This function constrains x to remain within the range min_val to max_val. Values of x outside this range are clipped to the edges of the range.

This function behaves identically to the function of the same name in Processing. It is also similar to the corresponding function in Arduino, except that it supports floating point values.

Parameters
xInput value to be constrained.
min_valMinimum possible value.
max_valMaximum possible value.
Returns
Constrained value.
Examples:
Gui/mouse-track/render.cpp.
static float min ( float  x,
float  y 
)
inlinestatic
static float max ( float  x,
float  y 
)
inlinestatic

Returns the minimum of two numbers.

Returns the minimum of two numbers