GNU Radio C++ API Reference: cvsd_encode_sb.h Source File

| GNU Radio C++ API Reference 3.10.12.0 The Free & Open Software Radio Ecosystem |

Loading...
Searching...
No Matches
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 * SPDX-License-Identifier: GPL-3.0-or-later
8 *
9 */
10#ifndef INCLUDED_VOCODER_CVSD_ENCODER_SB_H
11#define INCLUDED_VOCODER_CVSD_ENCODER_SB_H
12
13#include <gnuradio/sync_decimator.h>
14#include <gnuradio/vocoder/api.h>
15
16namespace gr {
17namespace vocoder {
18
19/*!
20 * \brief This block performs CVSD audio encoding. Its design and
21 * implementation is modeled after the CVSD encoder/decoder
22 * specifications defined in the Bluetooth standard.
23 * \ingroup audio_blk
24 *
25 * \details
26 * CVSD is a method for encoding speech that seeks to reduce the
27 * bandwidth required for digital voice transmission. CVSD takes
28 * advantage of strong correlation between samples, quantizing the
29 * difference in amplitude between two consecutive samples. This
30 * difference requires fewer quantization levels as compared to
31 * other methods that quantize the actual amplitude level,
32 * reducing the bandwidth. CVSD employs a two level quantizer
33 * (one bit) and an adaptive algorithm that allows for continuous
34 * step size adjustment.
35 *
36 * The coder can represent low amplitude signals with accuracy
37 * without sacrificing performance on large amplitude signals, a
38 * trade off that occurs in some non-adaptive modulations.
39 *
40 * The CVSD encoder effectively provides 8-to-1 compression. More
41 * specifically, each incoming audio sample is compared to an
42 * internal reference value. If the input is greater or equal to
43 * the reference, the encoder outputs a "1" bit. If the input is
44 * less than the reference, the encoder outputs a "0" bit. The
45 * reference value is then updated accordingly based on the
46 * frequency of outputted "1" or "0" bits. By grouping 8 outputs
47 * bits together, the encoder essentially produce one output byte
48 * for every 8 input audio samples.
49 *
50 * This encoder requires that input audio samples are 2-byte short
51 * signed integers. The result bandwidth conversion, therefore,
52 * is 16 input bytes of raw audio data to 1 output byte of encoded
53 * audio data.
54 *
55 * The CVSD encoder module must be prefixed by an up-converter to
56 * over-sample the audio data prior to encoding. The Bluetooth
57 * standard specifically calls for a 1-to-8 interpolating
58 * up-converter. While this reduces the overall compression of
59 * the codec, this is required so that the encoder can accurately
60 * compute the slope between adjacent audio samples and correctly
61 * update its internal reference value.
62 *
63 * References:
64 *
65 * 1. Continuously Variable Slope Delta Modulation (CVSD) A Tutorial,
66 * Available: http://www.eetkorea.com/ARTICLES/2003AUG/A/2003AUG29_NTEK_RFD_AN02.PDF.
67 *
68 * 2. Specification of The Bluetooth System
69 * Available: http://grouper.ieee.org/groups/802/15/Bluetooth/core_10_b.pdf.
70 *
71 * 3. McGarrity, S., Bluetooth Full Duplex Voice and Data Transmission. 2002.
72 * Bluetooth Voice Simulink Model, Available:
73 * http://www.mathworks.com/company/newsletters/digest/nov01/bluetooth.html
74 */
75 class VOCODER_API cvsd_encode_sb : virtual public sync_decimator
76{
77public:
78 // gr::vocoder::cvsd_encode_sb::sptr
79 typedef std::shared_ptr<cvsd_encode_sb> sptr;
80
81 /*!
82 * \brief Constructor parameters to initialize the CVSD encoder.
83 * The default values are modeled after the Bluetooth standard and
84 * should not be changed except by an advanced user
85 *
86 * \param min_step Minimum step size used to update the internal reference.
87 * Default: "10" \param max_step Maximum step size used to update the internal
88 * reference. Default: "1280" \param step_decay Decay factor applied to step size
89 * when there is not a run of J output 1s or 0s. Default: "0.9990234375" (i.e.
90 * 1-1/1024) \param accum_decay Decay factor applied to the internal reference
91 * during every iteration of the codec. Default: "0.96875" (i.e. 1-1/32) \param K
92 * Size of shift register; the number of output bits remembered by codec (must be <=
93 * to 32). Default: "32" \param J Number of bits in the shift register
94 * that are equal; i.e. the size of a run of 1s, 0s. Default: "4" \param pos_accum_max
95 * Maximum integer value allowed for the internal reference. Default: "32767" (2^15 -
96 * 1 or MAXSHORT) \param neg_accum_max Minimum integer value allowed for the internal
97 * reference. Default: "-32767" (-2^15 + 1 or MINSHORT+1)
98 */
99 static sptr make(short min_step = 10,
100 short max_step = 1280,
101 double step_decay = 0.9990234375,
102 double accum_decay = 0.96875,
103 int K = 32,
104 int J = 4,
105 short pos_accum_max = 32767,
106 short neg_accum_max = -32767);
107
108 virtual short min_step() = 0;
109 virtual short max_step() = 0;
110 virtual double step_decay() = 0;
111 virtual double accum_decay() = 0;
112 virtual int K() = 0;
113 virtual int J() = 0;
114 virtual short pos_accum_max() = 0;
115 virtual short neg_accum_max() = 0;
116};
117
118} /* namespace vocoder */
119} /* namespace gr */
120
121#endif /* INCLUDED_VOCODER_CVSD_ENCODE_SB_H */
gr::sync_decimator::sync_decimator
sync_decimator(void)
Definition sync_decimator.h:31
gr::vocoder::cvsd_encode_sb
This block performs CVSD audio encoding. Its design and implementation is modeled after the CVSD enco...
Definition cvsd_encode_sb.h:76
gr::vocoder::cvsd_encode_sb::J
virtual int J()=0
gr::vocoder::cvsd_encode_sb::accum_decay
virtual double accum_decay()=0
gr::vocoder::cvsd_encode_sb::min_step
virtual short min_step()=0
gr::vocoder::cvsd_encode_sb::max_step
virtual short max_step()=0
gr::vocoder::cvsd_encode_sb::sptr
std::shared_ptr< cvsd_encode_sb > sptr
Definition cvsd_encode_sb.h:79
gr::vocoder::cvsd_encode_sb::neg_accum_max
virtual short neg_accum_max()=0
gr::vocoder::cvsd_encode_sb::make
static sptr make(short min_step=10, short max_step=1280, double step_decay=0.9990234375, double accum_decay=0.96875, int K=32, int J=4, short pos_accum_max=32767, short neg_accum_max=-32767)
Constructor parameters to initialize the CVSD encoder. The default values are modeled after the Bluet...
gr::vocoder::cvsd_encode_sb::step_decay
virtual double step_decay()=0
gr::vocoder::cvsd_encode_sb::pos_accum_max
virtual short pos_accum_max()=0
gr::vocoder::cvsd_encode_sb::K
virtual int K()=0
api.h
VOCODER_API
#define VOCODER_API
Definition gr-vocoder/include/gnuradio/vocoder/api.h:18
gr::vocoder
Definition alaw_decode_bs.h:18
gr
GNU Radio logging wrapper.
Definition basic_block.h:29
sync_decimator.h