GNU Radio 3.7.1 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2007,2011,2013 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef INCLUDED_VOCODER_CVSD_DECODE_BS_H 00024 #define INCLUDED_VOCODER_CVSD_DECODE_BS_H 00025 00026 #include <gnuradio/vocoder/api.h> 00027 #include <gnuradio/sync_interpolator.h> 00028 00029 namespace gr { 00030 namespace vocoder { 00031 00032 /*! 00033 * \brief This block performs CVSD audio decoding. Its design and 00034 * implementation is modeled after the CVSD encoder/decoder 00035 * specifications defined in the Bluetooth standard. 00036 * \ingroup audio_blk 00037 * 00038 * \details 00039 * CVSD is a method for encoding speech that seeks to reduce the 00040 * bandwidth required for digital voice transmission. CVSD takes 00041 * advantage of strong correlation between samples, quantizing the 00042 * difference in amplitude between two consecutive samples. This 00043 * difference requires fewer quantization levels as compared to 00044 * other methods that quantize the actual amplitude level, 00045 * reducing the bandwidth. CVSD employs a two level quantizer 00046 * (one bit) and an adaptive algorithm that allows for continuous 00047 * step size adjustment. 00048 * 00049 * The coder can represent low amplitude signals with accuracy 00050 * without sacrificing performance on large amplitude signals, a 00051 * trade off that occurs in some non-adaptive modulations. 00052 * 00053 * The CVSD decoder effectively provides 1-to-8 decompression. 00054 * More specifically, for each incoming input bit, the decoder 00055 * outputs one audio sample. If the input is a "1" bit, the 00056 * internal reference is increased appropriately and then 00057 * outputted as the next estimated audio sample. If the input is 00058 * a "0" bit, the internal reference is decreased appropriately 00059 * and then likewise outputted as the next estimated audio sample. 00060 * Grouping 8 input bits together, the encoder essentially 00061 * produces 8 output audio samples for everyone one input byte. 00062 * 00063 * This decoder requires that output audio samples are 2-byte 00064 * short signed integers. The result bandwidth conversion, 00065 * therefore, is 1 byte of encoded audio data to 16 output bytes 00066 * of raw audio data. 00067 * 00068 * The CVSD decoder module must be post-fixed by a down-converter 00069 * to under-sample the audio data after decoding. The Bluetooth 00070 * standard specifically calls for a 8-to-1 decimating 00071 * down-converter. This is required so that so that output 00072 * sampling rate equals the original input sampling rate present 00073 * before the encoder. In all cases, the output down-converter 00074 * rate must be the inverse of the input up-converter rate before 00075 * the CVSD encoder. 00076 * 00077 * References: 00078 * 1. Continuously Variable Slope Delta Modulation (CVSD) A Tutorial, 00079 * Available: http://www.eetkorea.com/ARTICLES/2003AUG/A/2003AUG29_NTEK_RFD_AN02.PDF. 00080 * 2. Specification of The Bluetooth System 00081 * Available: http://grouper.ieee.org/groups/802/15/Bluetooth/core_10_b.pdf. 00082 * 3. McGarrity, S., Bluetooth Full Duplex Voice and Data Transmission. 2002. 00083 * Bluetooth Voice Simulink® Model, Available: 00084 * http://www.mathworks.com/company/newsletters/digest/nov01/bluetooth.html 00085 */ 00086 class VOCODER_API cvsd_decode_bs : virtual public sync_interpolator 00087 { 00088 public: 00089 // gr::vocoder::cvsd_decode_bs::sptr 00090 typedef boost::shared_ptr<cvsd_decode_bs> sptr; 00091 00092 /*! 00093 * \brief Constructor parameters to initialize the CVSD decoder. 00094 * The default values are modeled after the Bluetooth standard 00095 * and should not be changed, except by an advanced user 00096 * 00097 * \param min_step Minimum step size used to update the internal reference. 00098 * Default: "10" 00099 * \param max_step Maximum step size used to update the internal reference. 00100 * Default: "1280" 00101 * \param step_decay Decay factor applied to step size when there is not a run of J output 1s or 0s. 00102 * Default: "0.9990234375" (i.e. 1-1/1024) 00103 * \param accum_decay Decay factor applied to the internal reference during every interation of the codec. 00104 * Default: "0.96875" (i.e. 1-1/32) 00105 * \param K; Size of shift register; the number of output bits remembered by codec (must be <= to 32). 00106 * Default: "32" 00107 * \param J; Number of bits in the shift register that are equal; i.e. the size of a run of 1s, 0s. 00108 * Default: "4" 00109 * \param pos_accum_max Maximum integer value allowed for the internal reference. 00110 * Default: "32767" (2^15 - 1 or MAXSHORT) 00111 * \param neg_accum_max Minimum integer value allowed for the internal reference. 00112 * Default: "-32767" (-2^15 + 1 or MINSHORT+1) 00113 */ 00114 static sptr make(short min_step=10, short max_step=1280, 00115 double step_decay=0.9990234375, double accum_decay= 0.96875, 00116 int K=32, int J=4, 00117 short pos_accum_max=32767, short neg_accum_max=-32767); 00118 00119 virtual short min_step() = 0; 00120 virtual short max_step() = 0; 00121 virtual double step_decay() = 0; 00122 virtual double accum_decay() = 0; 00123 virtual int K() = 0; 00124 virtual int J() = 0; 00125 virtual short pos_accum_max() = 0; 00126 virtual short neg_accum_max() = 0; 00127 }; 00128 00129 } /* namespace vocoder */ 00130 } /* namespace gr */ 00131 00132 #endif /* INCLUDED_VOCODER_CVSD_DECODE_BS_H */