GNU Radio Manual and C++ API Reference  3.7.4
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
cvsd_encode_sb.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2007,2013 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 #ifndef INCLUDED_VOCODER_CVSD_ENCODER_SB_H
23 #define INCLUDED_VOCODER_CVSD_ENCODER_SB_H
24 
25 #include <gnuradio/vocoder/api.h>
27 
28 namespace gr {
29  namespace vocoder {
30 
31  /*!
32  * \brief This block performs CVSD audio encoding. Its design and
33  * implementation is modeled after the CVSD encoder/decoder
34  * specifications defined in the Bluetooth standard.
35  * \ingroup audio_blk
36  *
37  * \details
38  * CVSD is a method for encoding speech that seeks to reduce the
39  * bandwidth required for digital voice transmission. CVSD takes
40  * advantage of strong correlation between samples, quantizing the
41  * difference in amplitude between two consecutive samples. This
42  * difference requires fewer quantization levels as compared to
43  * other methods that quantize the actual amplitude level,
44  * reducing the bandwidth. CVSD employs a two level quantizer
45  * (one bit) and an adaptive algorithm that allows for continuous
46  * step size adjustment.
47  *
48  * The coder can represent low amplitude signals with accuracy
49  * without sacrificing performance on large amplitude signals, a
50  * trade off that occurs in some non-adaptive modulations.
51  *
52  * The CVSD encoder effectively provides 8-to-1 compression. More
53  * specifically, each incoming audio sample is compared to an
54  * internal reference value. If the input is greater or equal to
55  * the reference, the encoder outputs a "1" bit. If the input is
56  * less than the reference, the encoder outputs a "0" bit. The
57  * reference value is then updated accordingly based on the
58  * frequency of outputted "1" or "0" bits. By grouping 8 outputs
59  * bits together, the encoder essentially produce one output byte
60  * for every 8 input audio samples.
61  *
62  * This encoder requires that input audio samples are 2-byte short
63  * signed integers. The result bandwidth conversion, therefore,
64  * is 16 input bytes of raw audio data to 1 output byte of encoded
65  * audio data.
66  *
67  * The CVSD encoder module must be prefixed by an up-converter to
68  * over-sample the audio data prior to encoding. The Bluetooth
69  * standard specifically calls for a 1-to-8 interpolating
70  * up-converter. While this reduces the overall compression of
71  * the codec, this is required so that the encoder can accurately
72  * compute the slope between adjacent audio samples and correctly
73  * update its internal reference value.
74  *
75  * References:
76  *
77  * 1. Continuously Variable Slope Delta Modulation (CVSD) A Tutorial,
78  * Available: http://www.eetkorea.com/ARTICLES/2003AUG/A/2003AUG29_NTEK_RFD_AN02.PDF.
79  *
80  * 2. Specification of The Bluetooth System
81  * Available: http://grouper.ieee.org/groups/802/15/Bluetooth/core_10_b.pdf.
82  *
83  * 3. McGarrity, S., Bluetooth Full Duplex Voice and Data Transmission. 2002.
84  * Bluetooth Voice Simulink Model, Available:
85  * http://www.mathworks.com/company/newsletters/digest/nov01/bluetooth.html
86  */
87  class VOCODER_API cvsd_encode_sb : virtual public sync_decimator
88  {
89  public:
90  // gr::vocoder::cvsd_encode_sb::sptr
92 
93  /*!
94  * \brief Constructor parameters to initialize the CVSD encoder.
95  * The default values are modeled after the Bluetooth standard and
96  * should not be changed except by an advanced user
97  *
98  * \param min_step Minimum step size used to update the internal reference. Default: "10"
99  * \param max_step Maximum step size used to update the internal reference. Default: "1280"
100  * \param step_decay Decay factor applied to step size when there is not a run of J output 1s or 0s.
101  * Default: "0.9990234375" (i.e. 1-1/1024)
102  * \param accum_decay Decay factor applied to the internal reference during every interation of the codec.
103  * Default: "0.96875" (i.e. 1-1/32)
104  * \param K Size of shift register; the number of output bits remembered by codec (must be <= to 32).
105  * Default: "32"
106  * \param J Number of bits in the shift register that are equal; i.e. the size of a run of 1s, 0s.
107  * Default: "4"
108  * \param pos_accum_max Maximum integer value allowed for the internal reference.
109  * Default: "32767" (2^15 - 1 or MAXSHORT)
110  * \param neg_accum_max Minimum integer value allowed for the internal reference.
111  * Default: "-32767" (-2^15 + 1 or MINSHORT+1)
112  */
113  static sptr make(short min_step=10, short max_step=1280,
114  double step_decay=0.9990234375, double accum_decay= 0.96875,
115  int K=32, int J=4,
116  short pos_accum_max=32767, short neg_accum_max=-32767);
117 
118  virtual short min_step() = 0;
119  virtual short max_step() = 0;
120  virtual double step_decay() = 0;
121  virtual double accum_decay() = 0;
122  virtual int K() = 0;
123  virtual int J() = 0;
124  virtual short pos_accum_max() = 0;
125  virtual short neg_accum_max() = 0;
126  };
127 
128  } /* namespace vocoder */
129 } /* namespace gr */
130 
131 #endif /* INCLUDED_VOCODER_CVSD_ENCODE_SB_H */
boost::shared_ptr< cvsd_encode_sb > sptr
Definition: cvsd_encode_sb.h:91
shared_ptr documentation stub
Definition: shared_ptr_docstub.h:15
synchronous N:1 input to output with historyOverride work to provide the signal processing implementa...
Definition: sync_decimator.h:37
#define VOCODER_API
Definition: gr-vocoder/include/gnuradio/vocoder/api.h:30
This block performs CVSD audio encoding. Its design and implementation is modeled after the CVSD enco...
Definition: cvsd_encode_sb.h:87