-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathdecimator.h
More file actions
executable file
·75 lines (60 loc) · 2.3 KB
/
decimator.h
File metadata and controls
executable file
·75 lines (60 loc) · 2.3 KB
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
75
////////////////////////////////////////////////////////////////////////////
// **** DECIMATOR **** //
// Float to Integer Audio Decimation //
// Copyright (c) 2006 - 2024 David Bryant //
// All Rights Reserved. //
// Distributed under the BSD Software License (see license.txt) //
////////////////////////////////////////////////////////////////////////////
// decimator.h
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <math.h>
#include "biquad.h"
#ifdef ENABLE_THREADS
#include "workers.h"
#endif
#if defined(PATH_WIDTH) && (PATH_WIDTH==64)
typedef double artsample_t;
#else
typedef float artsample_t;
#endif
#define DITHER_HIGHPASS 0x1
#define DITHER_FLAT 0x2
#define DITHER_LOWPASS 0x4
#define DITHER_ENABLED (DITHER_HIGHPASS | DITHER_FLAT | DITHER_LOWPASS)
#define SHAPING_1ST_ORDER 0x100
#define SHAPING_2ND_ORDER 0x200
#define SHAPING_3RD_ORDER 0x400
#define SHAPING_ATH_CURVE 0x800
#define SHAPING_ENABLED (SHAPING_1ST_ORDER | SHAPING_2ND_ORDER | SHAPING_3RD_ORDER | SHAPING_ATH_CURVE)
#define DECIMATE_MULTITHREADED 0x1000
typedef struct {
int numChannels, outputBits, outputBytes, dither_type, flags;
double outputGain;
artsample_t *feedback;
uint32_t *tpdf_generators;
Biquad *noise_shapers;
#ifdef ENABLE_THREADS
Workers *workers;
const artsample_t *input;
int numInputFrames;
unsigned char *output;
int stride, clips;
uint32_t tpdf_generator;
Biquad noise_shaper;
artsample_t feedback_val;
#endif
} Decimate;
#ifdef __cplusplus
extern "C" {
#endif
void floatIntegersLE (unsigned char *input, double inputGain, int inputBits, int inputBytes, int inputStride, artsample_t *output, int numSamples);
Decimate *decimateInit (int numChannels, int outputBits, int outputBytes, double outputGain, int sampleRate, int flags);
int decimateProcessLE (Decimate *cxt, const artsample_t *const *input, int numInputFrames, unsigned char *const *output);
int decimateProcessInterleavedLE (Decimate *cxt, const artsample_t *input, int numInputFrames, unsigned char *output);
void decimateFree (Decimate *cxt);
#ifdef __cplusplus
}
#endif