Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
math.h File Reference

Math utils. More...

#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include "utils/types.h"
#include <float.h>
Include dependency graph for math.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MATH_RMS_FRAMES   1
 Frames to skip when calculating the RMS.
 
#define MATH_TINY_NUMBER   (0.0000001)
 Tiny number to be used for denormaml prevention (-140dB).
 
#define MATH_MINUS_INFINITY   (-HUGE_VAL)
 
#define math_floats_equal_epsilon(a, b, e)    ((a) > (b) ? (a) - (b) < e : (b) - (a) < e)
 Checks if 2 doubles are equal.
 
#define math_doubles_equal_epsilon   math_floats_equal_epsilon
 
#define math_floats_equal(a, b)    ((a) > (b) ? (a) - (b) < FLT_EPSILON : (b) - (a) < FLT_EPSILON)
 Checks if 2 doubles are equal.
 
#define math_doubles_equal(a, b)    ((a) > (b) ? (a) - (b) < DBL_EPSILON : (b) - (a) < DBL_EPSILON)
 
#define math_round_double_to_signed_32(x)   (lround (x))
 Rounds a double to a (minimum) signed 32-bit integer.
 
#define math_round_double_to_signed_64(x)   (llround (x))
 Rounds a double to a (minimum) signed 64-bit integer.
 
#define math_round_double_to_signed_frame_t(x)    math_round_double_to_signed_64 (x)
 
#define math_round_float_to_signed_32(x)   (lroundf (x))
 Rounds a float to a (minimum) signed 32-bit integer.
 
#define math_round_float_to_signed_64(x)   (llroundf (x))
 Rounds a float to a (minimum) signed 64-bit integer.
 
#define math_round_float_to_signed_frame_t(x)   math_round_float_to_signed_64 (x)
 

Functions

sample_t math_calculate_rms_amp (sample_t *buf, const nframes_t nframes)
 
sample_t math_calculate_rms_db (sample_t *buf, const nframes_t nframes)
 Calculate db using RMS method.
 
bool math_assert_nonnann (float x)
 Asserts that the value is non-nan.
 
bool math_is_string_valid_float (const char *str, float *ret)
 Returns whether the given string is a valid float.
 

Detailed Description

Math utils.

For more, look at libs/pbd/pbd/control_math.h in ardour.

Definition in file math.h.