GNU Radio Manual and C++ API Reference  3.7.13.4
The Free & Open Software Radio Ecosystem
cvsd_decode_bs.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2007,2011,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 
23 #ifndef INCLUDED_VOCODER_CVSD_DECODE_BS_H
24 #define INCLUDED_VOCODER_CVSD_DECODE_BS_H
25 
26 #include <gnuradio/vocoder/api.h>
28 
29 namespace gr {
30  namespace vocoder {
31 
32  /*!
33  * \brief This block performs CVSD audio decoding. Its design and
34  * implementation is modeled after the CVSD encoder/decoder
35  * specifications defined in the Bluetooth standard.
36  * \ingroup audio_blk
37  *
38  * \details
39  * CVSD is a method for encoding speech that seeks to reduce the
40  * bandwidth required for digital voice transmission. CVSD takes
41  * advantage of strong correlation between samples, quantizing the
42  * difference in amplitude between two consecutive samples. This
43  * difference requires fewer quantization levels as compared to
44  * other methods that quantize the actual amplitude level,
45  * reducing the bandwidth. CVSD employs a two level quantizer
46  * (one bit) and an adaptive algorithm that allows for continuous
47  * step size adjustment.
48  *
49  * The coder can represent low amplitude signals with accuracy
50  * without sacrificing performance on large amplitude signals, a
51  * trade off that occurs in some non-adaptive modulations.
52  *
53  * The CVSD decoder effectively provides 1-to-8 decompression.
54  * More specifically, for each incoming input bit, the decoder
55  * outputs one audio sample. If the input is a "1" bit, the
56  * internal reference is increased appropriately and then
57  * outputted as the next estimated audio sample. If the input is
58  * a "0" bit, the internal reference is decreased appropriately
59  * and then likewise outputted as the next estimated audio sample.
60  * Grouping 8 input bits together, the encoder essentially
61  * produces 8 output audio samples for everyone one input byte.
62  *
63  * This decoder requires that output audio samples are 2-byte
64  * short signed integers. The result bandwidth conversion,
65  * therefore, is 1 byte of encoded audio data to 16 output bytes
66  * of raw audio data.
67  *
68  * The CVSD decoder module must be post-fixed by a down-converter
69  * to under-sample the audio data after decoding. The Bluetooth
70  * standard specifically calls for a 8-to-1 decimating
71  * down-converter. This is required so that so that output
72  * sampling rate equals the original input sampling rate present
73  * before the encoder. In all cases, the output down-converter
74  * rate must be the inverse of the input up-converter rate before
75  * the CVSD encoder.
76  *
77  * References:
78  *
79  * 1. Continuously Variable Slope Delta Modulation (CVSD) A Tutorial,
80  * Available: http://www.eetkorea.com/ARTICLES/2003AUG/A/2003AUG29_NTEK_RFD_AN02.PDF.
81  *
82  * 2. Specification of The Bluetooth System
83  * Available: http://grouper.ieee.org/groups/802/15/Bluetooth/core_10_b.pdf.
84  *
85  * 3. McGarrity, S., Bluetooth Full Duplex Voice and Data Transmission. 2002.
86  * Bluetooth Voice Simulink Model, Available:
87  * http://www.mathworks.com/company/newsletters/digest/nov01/bluetooth.html
88  */
90  {
91  public:
92  // gr::vocoder::cvsd_decode_bs::sptr
93  typedef boost::shared_ptr<cvsd_decode_bs> sptr;
94 
95  /*!
96  * \brief Constructor parameters to initialize the CVSD decoder.
97  * The default values are modeled after the Bluetooth standard
98  * and should not be changed, except by an advanced user
99  *
100  * \param min_step Minimum step size used to update the internal reference.
101  * Default: "10"
102  * \param max_step Maximum step size used to update the internal reference.
103  * Default: "1280"
104  * \param step_decay Decay factor applied to step size when there is not a run of J output 1s or 0s.
105  * Default: "0.9990234375" (i.e. 1-1/1024)
106  * \param accum_decay Decay factor applied to the internal reference during every iteration of the codec.
107  * Default: "0.96875" (i.e. 1-1/32)
108  * \param K Size of shift register; the number of output bits remembered by codec (must be <= to 32).
109  * Default: "32"
110  * \param J Number of bits in the shift register that are equal; i.e. the size of a run of 1s, 0s.
111  * Default: "4"
112  * \param pos_accum_max Maximum integer value allowed for the internal reference.
113  * Default: "32767" (2^15 - 1 or MAXSHORT)
114  * \param neg_accum_max Minimum integer value allowed for the internal reference.
115  * Default: "-32767" (-2^15 + 1 or MINSHORT+1)
116  */
117  static sptr make(short min_step=10, short max_step=1280,
118  double step_decay=0.9990234375, double accum_decay= 0.96875,
119  int K=32, int J=4,
120  short pos_accum_max=32767, short neg_accum_max=-32767);
121 
122  virtual short min_step() = 0;
123  virtual short max_step() = 0;
124  virtual double step_decay() = 0;
125  virtual double accum_decay() = 0;
126  virtual int K() = 0;
127  virtual int J() = 0;
128  virtual short pos_accum_max() = 0;
129  virtual short neg_accum_max() = 0;
130  };
131 
132  } /* namespace vocoder */
133 } /* namespace gr */
134 
135 #endif /* INCLUDED_VOCODER_CVSD_DECODE_BS_H */
boost::shared_ptr< cvsd_decode_bs > sptr
Definition: cvsd_decode_bs.h:93
synchronous 1:N input to output with historyOverride work to provide the signal processing implementa...
Definition: sync_interpolator.h:37
This block performs CVSD audio decoding. Its design and implementation is modeled after the CVSD enco...
Definition: cvsd_decode_bs.h:89
Include this header to use the message passing features.
Definition: logger.h:695
#define VOCODER_API
Definition: gr-vocoder/include/gnuradio/vocoder/api.h:30