-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathdsp.h
74 lines (64 loc) · 1.9 KB
/
dsp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* This file is part of dsp.
*
* Copyright (c) 2013-2025 Michael Barbour <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef DSP_DSP_H
#define DSP_DSP_H
#include <stdio.h>
#include <sys/types.h>
enum {
LL_SILENT = 0,
LL_ERROR,
LL_OPEN_ERROR,
LL_NORMAL,
LL_VERBOSE,
};
#define LOGLEVEL(l) (dsp_globals.loglevel >= (l))
#define dsp_log_printf(...) fprintf(stderr, __VA_ARGS__)
#define LOG_FMT(l, fmt, ...) \
do { \
if (LOGLEVEL(l)) { \
dsp_log_acquire(); \
dsp_log_printf("%s: " fmt "\n", dsp_globals.prog_name, __VA_ARGS__); \
dsp_log_release(); \
} \
} while (0)
#define LOG_S(l, s) \
do { \
if (LOGLEVEL(l)) { \
dsp_log_acquire(); \
dsp_log_printf("%s: %s\n", dsp_globals.prog_name, s); \
dsp_log_release(); \
} \
} while (0)
#define DEFAULT_FS 44100
#define DEFAULT_CHANNELS 1
#define BIT_PERFECT 1
#define DEFAULT_BLOCK_FRAMES 2048
#define DEFAULT_INPUT_BUF_RATIO 64
#define DEFAULT_OUTPUT_BUF_RATIO 8
typedef double sample_t;
struct dsp_globals {
int loglevel;
const char *prog_name;
};
struct stream_info {
int fs, channels;
};
extern struct dsp_globals dsp_globals;
extern void dsp_log_acquire(void);
extern void dsp_log_release(void);
#endif