Update Fluidsynth to 2.0.1
[ardour.git] / libs / fluidsynth / src / fluid_conv.h
1 /* FluidSynth - A Software Synthesizer
2  *
3  * Copyright (C) 2003  Peter Hanappe and others.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public License
7  * as published by the Free Software Foundation; either version 2.1 of
8  * the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free
17  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  * 02110-1301, USA
19  */
20
21 #ifndef _FLUID_CONV_H
22 #define _FLUID_CONV_H
23
24 #include "fluidsynth_priv.h"
25
26 /*
27  Attenuation range in centibels.
28  Attenuation range is the dynamic range of the volume envelope generator
29  from 0 to the end of attack segment.
30  fluidsynth is a 24 bit synth, it could (should??) be 144 dB of attenuation.
31  However the spec makes no distinction between 16 or 24 bit synths, so use
32  96 dB here.
33
34  Note about usefulness of 24 bits:
35  1)Even fluidsynth is a 24 bit synth, this format is only relevant if
36  the sample format coming from the soundfont is 24 bits and the audio sample format
37  choosen by the application (audio.sample.format) is not 16 bits.
38
39  2)When the sample soundfont is 16 bits, the internal 24 bits number have
40  16 bits msb and lsb to 0. Consequently, at the DAC output, the dynamic range of
41  this 24 bit sample is reduced to the the dynamic of a 16 bits sample (ie 90 db)
42  even if this sample is produced by the audio driver using an audio sample format
43  compatible for a 24 bit DAC.
44
45  3)When the audio sample format settings is 16 bits (audio.sample.format), the
46  audio driver will make use of a 16 bit DAC, and the dynamic will be reduced to 96 dB
47  even if the initial sample comes from a 24 bits soundfont.
48
49  In both cases (2) or (3), the real dynamic range is only 96 dB.
50
51  Other consideration for FLUID_NOISE_FLOOR related to case (1),(2,3):
52  - for case (1), FLUID_NOISE_FLOOR should be the noise floor for 24 bits (i.e -138 dB).
53  - for case (2) or (3), FLUID_NOISE_FLOOR should be the noise floor for 16 bits (i.e -90 dB).
54  */
55 #define FLUID_PEAK_ATTENUATION  960.0f
56
57 void fluid_conversion_config(void);
58
59 fluid_real_t fluid_ct2hz_real(fluid_real_t cents);
60 fluid_real_t fluid_ct2hz(fluid_real_t cents);
61 fluid_real_t fluid_cb2amp(fluid_real_t cb);
62 fluid_real_t fluid_tc2sec(fluid_real_t tc);
63 fluid_real_t fluid_tc2sec_delay(fluid_real_t tc);
64 fluid_real_t fluid_tc2sec_attack(fluid_real_t tc);
65 fluid_real_t fluid_tc2sec_release(fluid_real_t tc);
66 fluid_real_t fluid_act2hz(fluid_real_t c);
67 fluid_real_t fluid_hz2ct(fluid_real_t c);
68 fluid_real_t fluid_pan(fluid_real_t c, int left);
69 fluid_real_t fluid_balance(fluid_real_t balance, int left);
70 fluid_real_t fluid_concave(fluid_real_t val);
71 fluid_real_t fluid_convex(fluid_real_t val);
72
73 #endif /* _FLUID_CONV_H */