GNU Radio 3.6.4.1 C++ API
vocoder_cvsd_decode_bs.h
Go to the documentation of this file.
1
/* -*- c++ -*- */
2
/*
3
* Copyright 2007,2011 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 <
vocoder_api.h
>
27
#include <
gr_sync_interpolator.h
>
28
29
class
vocoder_cvsd_decode_bs
;
30
31
typedef
boost::shared_ptr<vocoder_cvsd_decode_bs>
vocoder_cvsd_decode_bs_sptr
;
32
33
/*!
34
* \brief Constructor parameters to initialize the CVSD decoder. The default
35
* values are modeled after the Bluetooth standard and should not be changed,
36
* except by an advanced user
37
*
38
* \ingroup vocoder_blk
39
*
40
* \param min_step Minimum step size used to update the internal reference. Default: "10"
41
* \param max_step Maximum step size used to update the internal reference. Default: "1280"
42
* \param step_decay Decay factor applied to step size when there is not a run of J output 1s or 0s. Default: "0.9990234375" (i.e. 1-1/1024)
43
* \param accum_decay Decay factor applied to the internal reference during every interation of the codec. Default: "0.96875" (i.e. 1-1/32)
44
* \param K; Size of shift register; the number of output bits remembered by codec (must be less or equal to 32). Default: "32"
45
* \param J; Number of bits in the shift register that are equal; i.e. the size of a run of 1s, 0s. Default: "4"
46
* \param pos_accum_max Maximum integer value allowed for the internal reference. Default: "32767" (2^15 - 1 or MAXSHORT)
47
* \param neg_accum_max Minimum integer value allowed for the internal reference. Default: "-32767" (-2^15 + 1 or MINSHORT+1)
48
*
49
*/
50
VOCODER_API
vocoder_cvsd_decode_bs_sptr
vocoder_make_cvsd_decode_bs
(
short
min_step
=10,
51
short
max_step
=1280,
52
double
step_decay
=0.9990234375,
53
double
accum_decay
= 0.96875,
54
int
K
=32,
55
int
J
=4,
56
short
pos_accum_max
=32767,
57
short
neg_accum_max
=-32767);
58
59
/*!
60
* \brief This block performs CVSD audio decoding. Its design and implementation
61
* is modeled after the CVSD encoder/decoder specifications defined in the
62
* Bluetooth standard.
63
*
64
* \ingroup vocoder_blk
65
*
66
* CVSD is a method for encoding speech that seeks to reduce the
67
* bandwidth required for digital voice transmission. CVSD takes
68
* advantage of strong correlation between samples, quantizing the
69
* difference in amplitude between two consecutive samples. This
70
* difference requires fewer quantization levels as compared to other
71
* methods that quantize the actual amplitude level, reducing the
72
* bandwidth. CVSD employs a two level quantizer (one bit) and an
73
* adaptive algorithm that allows for continuous step size adjustment.
74
*
75
* The coder can represent low amplitude signals with accuracy without
76
* sacrificing performance on large amplitude signals, a trade off that
77
* occurs in some non-adaptive modulations.
78
*
79
* The CVSD decoder effectively provides 1-to-8 decompression. More
80
* specifically, for each incoming input bit, the decoder outputs one
81
* audio sample. If the input is a "1" bit, the internal reference is
82
* increased appropriately and then outputted as the next estimated audio
83
* sample. If the input is a "0" bit, the internal reference is
84
* decreased appropriately and then likewise outputted as the next estimated
85
* audio sample. Grouping 8 input bits together, the encoder essentially
86
* produces 8 output audio samples for everyone one input byte.
87
*
88
* This decoder requires that output audio samples are 2-byte short signed
89
* integers. The result bandwidth conversion, therefore, is 1 byte of
90
* encoded audio data to 16 output bytes of raw audio data.
91
*
92
* The CVSD decoder module must be post-fixed by a down-converter to
93
* under-sample the audio data after decoding. The Bluetooth standard
94
* specifically calls for a 8-to-1 decimating down-converter. This is
95
* required so that so that output sampling rate equals the original input
96
* sampling rate present before the encoder. In all cases, the output
97
* down-converter rate must be the inverse of the input up-converter rate
98
* before the CVSD encoder.
99
*
100
* References:
101
* 1. Continuously Variable Slope Delta Modulation (CVSD) A Tutorial,
102
* Available: http://www.eetkorea.com/ARTICLES/2003AUG/A/2003AUG29_NTEK_RFD_AN02.PDF.
103
* 2. Specification of The Bluetooth System
104
* Available: http://grouper.ieee.org/groups/802/15/Bluetooth/core_10_b.pdf.
105
* 3. McGarrity, S., Bluetooth Full Duplex Voice and Data Transmission. 2002.
106
* Bluetooth Voice Simulink® Model, Available:
107
* http://www.mathworks.com/company/newsletters/digest/nov01/bluetooth.html
108
*
109
*/
110
111
class
VOCODER_API
vocoder_cvsd_decode_bs
:
public
gr_sync_interpolator
112
{
113
private
:
114
friend
VOCODER_API
vocoder_cvsd_decode_bs_sptr
vocoder_make_cvsd_decode_bs
(
short
min_step,
115
short
max_step,
116
double
step_decay,
117
double
accum_decay,
118
int
K,
119
int
J,
120
short
pos_accum_max,
121
short
neg_accum_max);
122
123
vocoder_cvsd_decode_bs
(
short
min_step,
short
max_step,
double
step_decay,
124
double
accum_decay,
int
K,
int
J,
125
short
pos_accum_max,
short
neg_accum_max);
126
127
//! Member functions required by the encoder/decoder
128
//! \brief Rounding function specific to CVSD
129
//! \return the input value rounded to the nearest integer
130
int
cvsd_round(
double
input);
131
132
//! \brief A power function specific to CVSD data formats
133
//! \return (radix)^power, where radix and power are short integers
134
unsigned
int
cvsd_pow (
short
radix,
short
power);
135
136
//! \brief Sums number of 1's in the input
137
//! \return the number of 1s in the four bytes of an input unsigned integer
138
unsigned
char
cvsd_bitwise_sum (
unsigned
int
input);
139
140
short
d_min_step;
141
short
d_max_step;
142
double
d_step_decay;
143
double
d_accum_decay;
144
145
int
d_K;
//!< \brief Size of shift register; the number of output bits remembered in shift register
146
int
d_J;
//!< \brief Number of bits in the shift register that are equal; size of run of 1s, 0s
147
148
short
d_pos_accum_max;
149
short
d_neg_accum_max;
150
151
int
d_accum;
//!< \brief Current value of internal reference
152
int
d_loop_counter;
//!< \brief Current value of the loop counter
153
unsigned
int
d_runner;
//!< \brief Current value of the shift register
154
unsigned
int
d_runner_mask;
//!< \brief Value of the mask to access the last J bits of the shift register
155
short
d_stepsize;
//!< \brief Current value of the step sizer
156
157
public
:
158
~
vocoder_cvsd_decode_bs
();
// public destructor
159
160
short
min_step
() {
return
d_min_step; }
161
short
max_step
() {
return
d_max_step; }
162
double
step_decay
() {
return
d_step_decay; }
163
double
accum_decay
() {
return
d_accum_decay; }
164
int
K
() {
return
d_K; }
165
int
J
() {
return
d_J; }
166
short
pos_accum_max
() {
return
d_pos_accum_max; }
167
short
neg_accum_max
() {
return
d_neg_accum_max; }
168
169
int
work
(
int
noutput_items,
170
gr_vector_const_void_star
&input_items,
171
gr_vector_void_star
&output_items);
172
};
173
174
#endif
/* INCLUDED_VOCODER_CVSD_DECODE_BS_H */
gr-vocoder
include
vocoder_cvsd_decode_bs.h
Generated on Thu Mar 21 2013 15:59:34 for GNU Radio 3.6.4.1 C++ API by
1.8.1.2