GNU Radio Manual and C++ API Reference
3.8.1.0
The Free & Open Software Radio Ecosystem
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/sync_decimator.h
>
26
#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
91
typedef
boost::shared_ptr<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.
99
* Default: "10" \param max_step Maximum step size used to update the internal
100
* reference. Default: "1280" \param step_decay Decay factor applied to step size
101
* when there is not a run of J output 1s or 0s. Default: "0.9990234375" (i.e.
102
* 1-1/1024) \param accum_decay Decay factor applied to the internal reference
103
* during every iteration of the codec. Default: "0.96875" (i.e. 1-1/32) \param K
104
* Size of shift register; the number of output bits remembered by codec (must be <=
105
* to 32). Default: "32" \param J Number of bits in the shift register
106
* that are equal; i.e. the size of a run of 1s, 0s. Default: "4" \param pos_accum_max
107
* Maximum integer value allowed for the internal reference. Default: "32767" (2^15 -
108
* 1 or MAXSHORT) \param neg_accum_max Minimum integer value allowed for the internal
109
* reference. Default: "-32767" (-2^15 + 1 or MINSHORT+1)
110
*/
111
static
sptr
make(
short
min_step = 10,
112
short
max_step = 1280,
113
double
step_decay = 0.9990234375,
114
double
accum_decay = 0.96875,
115
int
K = 32,
116
int
J = 4,
117
short
pos_accum_max = 32767,
118
short
neg_accum_max = -32767);
119
120
virtual
short
min_step() = 0;
121
virtual
short
max_step() = 0;
122
virtual
double
step_decay() = 0;
123
virtual
double
accum_decay() = 0;
124
virtual
int
K() = 0;
125
virtual
int
J() = 0;
126
virtual
short
pos_accum_max() = 0;
127
virtual
short
neg_accum_max() = 0;
128
};
129
130
}
/* namespace vocoder */
131
}
/* namespace gr */
132
133
#endif
/* INCLUDED_VOCODER_CVSD_ENCODE_SB_H */
api.h
gr::sync_decimator
synchronous N:1 input to output with history
Definition:
sync_decimator.h:37
gr::vocoder::cvsd_encode_sb::sptr
boost::shared_ptr< cvsd_encode_sb > sptr
Definition:
cvsd_encode_sb.h:91
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:87
sync_decimator.h
VOCODER_API
#define VOCODER_API
Definition:
gr-vocoder/include/gnuradio/vocoder/api.h:30
gr
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition:
basic_block.h:43
gr-vocoder
include
gnuradio
vocoder
cvsd_encode_sb.h
Generated by
1.8.16