1 /*      libSoX DVMS format module (implementation in cvsd.c)
2  *
3  *      Copyright (C) 1996-2007 Thomas Sailer and SoX Contributors
4  *      Thomas Sailer (sailer@ife.ee.ethz.ch) (HB9JNX/AE4WA)
5  *      Swiss Federal Institute of Technology, Electronics Lab
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation; either version 2.1 of the License, or (at
10  * your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20  *
21  */
22 #include "sox_i.h"
23 
24 #define CVSD_ENC_FILTERLEN 16  /* PCM sampling rate */
25 #define CVSD_DEC_FILTERLEN 48  /* CVSD sampling rate */
26 
27 typedef struct {
28   struct {
29     unsigned overload;
30     float mla_int;
31     float mla_tc0;
32     float mla_tc1;
33     unsigned phase;
34     unsigned phase_inc;
35     float v_min, v_max;
36   } com;
37   union {
38     struct {
39       /* mirror circular buffer */
40       float output_filter[CVSD_DEC_FILTERLEN*2];
41       unsigned offset; /* into output_filter; always in first half */
42     } dec;
43     struct {
44       float recon_int;
45       /* mirror circular buffer */
46       float input_filter[CVSD_ENC_FILTERLEN*2];
47       unsigned offset; /* into input_filter; always in first half */
48     } enc;
49   } c;
50   struct {
51     unsigned char shreg;
52     unsigned mask;
53     unsigned cnt;
54   } bit;
55   unsigned bytes_written;
56   unsigned cvsd_rate;
57 } cvsd_priv_t;
58 
59 int lsx_cvsdstartread(sox_format_t * ft);
60 int lsx_cvsdstartwrite(sox_format_t * ft);
61 size_t lsx_cvsdread(sox_format_t * ft, sox_sample_t *buf, size_t nsamp);
62 size_t lsx_cvsdwrite(sox_format_t * ft, const sox_sample_t *buf, size_t nsamp);
63 int lsx_cvsdstopread(sox_format_t * ft);
64 int lsx_cvsdstopwrite(sox_format_t * ft);
65 
66 int lsx_dvmsstartread(sox_format_t * ft);
67 int lsx_dvmsstartwrite(sox_format_t * ft);
68 int lsx_dvmsstopwrite(sox_format_t * ft);
69