/*
* Copyright (c) 2007 - 2015 Joseph Gaeddert
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
//
// modem_common.c : common utilities specific to precision
//
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "liquid.internal.h"
#define DEBUG_DEMODULATE_SOFT 0
// modem structure used for both modulation and demodulation
//
// The modem structure implements a variety of common modulation schemes,
// including (differential) phase-shift keying, and (quadrature) amplitude
// modulation.
//
// While the same modem structure may be used for both modulation and
// demodulation for most schemes, it is important to use separate objects
// for differential-mode modems (e.g. LIQUID_MODEM_DPSK) as the internal state
// will change after each symbol. It is usually good practice to keep
// separate instances of modulators and demodulators.
struct MODEM(_s)
{
// common data
modulation_scheme scheme; // modulation scheme
unsigned int m; // bits per symbol (modulation depth)
unsigned int M; // constellation size, M=2^m
// Reference vector for demodulating linear arrays
//
// By storing these values in an array they do not need to be
// calculated during run-time. This speeds up the demodulation by
// approximately 8%.
T ref[MAX_MOD_BITS_PER_SYMBOL];
// modulation