aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.h
blob: 4ad3a7e694f5aec981c92374ecc3817bfa1b8476 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef UTILS_H_
#define UTILS_H_

#include <math.h>
#include <stdint.h>
#include <stddef.h>

#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

#define NUMOF(l) (sizeof(l) / sizeof(*l))

#define linear_to_dB(x) (log10(x) * 20)

/*! Calculate the little string containing a bargraph
 * 'VU-meter' from the peak value measured
 */
const char* level(int channel, int peak);

size_t strlen_utf8(const char *s);

#endif