You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.1 KiB
65 lines
2.1 KiB
/*
|
|
* Copyright (C) 2009,2015 by Jonathan Naylor, G4KLX
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; version 2 of the License.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#include "DStarGMSKModulator.h"
|
|
|
|
#include "DStarDefines.h"
|
|
|
|
#include <cassert>
|
|
|
|
// Generated by gaussfir(0.5, 4, 10)
|
|
const float COEFFS_TABLE[] = {
|
|
0.000000000000003F, 0.000000000000065F, 0.000000000001037F, 0.000000000014448F, 0.000000000174579F,
|
|
0.000000001829471F, 0.000000016627294F, 0.000000131062698F, 0.000000895979719F, 0.000005312253663F, 0.000027316243802F,
|
|
0.000121821714020F, 0.000471183399421F, 0.001580581180127F, 0.004598383433830F, 0.011602594308899F, 0.025390226926262F,
|
|
0.048188078330624F, 0.079318443411643F, 0.113232294527059F, 0.140193533802410F, 0.150538369557851F, 0.140193533802410F,
|
|
0.113232294527059F, 0.079318443411643F, 0.048188078330623F, 0.025390226926262F, 0.011602594308899F, 0.004598383433830F,
|
|
0.001580581180127F, 0.000471183399421F, 0.000121821714020F, 0.000027316243802F, 0.000005312253663F, 0.000000895979719F,
|
|
0.000000131062698F, 0.000000016627294F, 0.000000001829471F, 0.000000000174579F, 0.000000000014448F, 0.000000000001037F,
|
|
0.000000000000065F, 0.000000000000003F};
|
|
|
|
const unsigned int COEFFS_LENGTH = 43U;
|
|
|
|
CDStarGMSKModulator::CDStarGMSKModulator() :
|
|
m_filter(COEFFS_TABLE, COEFFS_LENGTH),
|
|
m_invert(false)
|
|
{
|
|
}
|
|
|
|
CDStarGMSKModulator::~CDStarGMSKModulator()
|
|
{
|
|
}
|
|
|
|
unsigned int CDStarGMSKModulator::code(bool bit, float* buffer, unsigned int length)
|
|
{
|
|
assert(buffer != nullptr);
|
|
assert(length == DSTAR_RADIO_BIT_LENGTH);
|
|
|
|
if (m_invert)
|
|
bit = !bit;
|
|
|
|
for (unsigned int i = 0U; i < DSTAR_RADIO_BIT_LENGTH; i++) {
|
|
if (bit)
|
|
buffer[i] = m_filter.process(-0.5F);
|
|
else
|
|
buffer[i] = m_filter.process(0.5F);
|
|
}
|
|
|
|
return DSTAR_RADIO_BIT_LENGTH;
|
|
}
|
|
|
|
void CDStarGMSKModulator::setInvert(bool set)
|
|
{
|
|
m_invert = set;
|
|
}
|