Move file suffixes out of the Session class and into filename_extensions.h/cc
[ardour.git] / libs / ardour / ardour / gdither.h
1 /*
2  *  Copyright (C) 2002 Steve Harris <steve@plugin.org.uk>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  *
18  */
19
20 #ifndef GDITHER_H
21 #define GDITHER_H
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #include "gdither_types.h"
28
29 /* Create and initialise a state structure, takes a dither type, a number of
30  * channels and a bit depth as input
31  *
32  * The Dither type is one of
33  *
34  *   GDitherNone - straight nearest neighbour rounding. Theres no pressing
35  *   reason to do this at 8 or 16 bit, but you might want to at 24, for some
36  *   reason. At the lest it will save you writing int->float conversion code,
37  *   which is arder than it sounds.
38  *
39  *   GDitherRect - mathematically most accurate, lowest noise floor, but not
40  *   that good for audio. It is the fastest though.
41  *
42  *   GDitherTri - a happy medium between Rectangular and Shaped, reasonable
43  *   noise floor, not too obvious, quite fast.
44  *
45  *   GDitherShaped - should have the least audible impact, but has the highest
46  *   noise floor, fairly CPU intensive. Not advisible if your going to apply
47  *   any frequency manipulation afterwards.
48  *
49  * channels, sets the number of channels in the output data, output data will
50  * be written interleaved into the area given to gdither_run(). Set to 1
51  * if you are not working with interleaved buffers.
52  *
53  * bit depth, sets the bit width of the output sample data, it can be one of:
54  *
55  *   GDither8bit   - 8 bit unsiged
56  *   GDither16bit  - 16 bit signed
57  *   GDither32bit  - 24+bits in upper bits of a 32 bit word
58  *   GDitherFloat  - IEEE floating point (32bits)
59  *   GDitherDouble - Double precision IEEE floating point (64bits)
60  *
61  * dither_depth, set the number of bits before the signal will be truncated to,
62  * eg. 16 will produce an output stream with 16bits-worth of signal. Setting to
63  * zero or greater than the width of the output format will dither to the
64  * maximum precision allowed by the output format.
65  */
66 GDither gdither_new(GDitherType type, uint32_t channels,
67
68                     GDitherSize bit_depth, int dither_depth);
69
70 /* Frees memory used by gdither_new.
71  */
72 void gdither_free(GDither s);
73
74 /* Applies dithering to the supplied signal.
75  *
76  * channel is the channel number you are processing (0 - channles-1), length is
77  * the length of the input, in samples, x is the input samples (float), y is
78  * where the output samples will be written, it should have the approaprate
79  * type for the chosen bit depth
80  */
81 void gdither_runf(GDither s, uint32_t channel, uint32_t length,
82                    float *x, void *y);
83
84 /* see gdither_runf, vut input argument is double format */
85 void gdither_run(GDither s, uint32_t channel, uint32_t length,
86                    double *x, void *y);
87
88 #ifdef __cplusplus
89 }
90 #endif
91
92 #endif