コード例 #1
0
ファイル: CicEqualizer.cpp プロジェクト: g4idrijs/ODR-DabMod
CicEqualizer::CicEqualizer(size_t nbCarriers, size_t spacing, int R) :
    ModCodec(ModFormat(nbCarriers * sizeof(complexf)),
            ModFormat(nbCarriers * sizeof(complexf))),
    myNbCarriers(nbCarriers),
    mySpacing(spacing)
{
    PDEBUG("CicEqualizer::CicEqualizer(%zu, %zu, %i) @ %p\n",
            nbCarriers, spacing, R, this);

    myFilter = new float[nbCarriers];
    const int M = 1;
    const int N = 4;
    const float pi = 4.0f * atanf(1.0f);
    for (size_t i = 0; i < nbCarriers; ++i) {
        int k = i < (nbCarriers + 1) / 2
            ? i + ((nbCarriers & 1) ^ 1)
            : i - (int)nbCarriers;
        float angle = pi * k / spacing;
        if (k == 0) {
            myFilter[i] = 1.0f;
        }
        else {
            myFilter[i] = sinf(angle / R) / sinf(angle * M);
            myFilter[i] = fabsf(myFilter[i]) * R * M;
            myFilter[i] = powf(myFilter[i], N);
        }
        PDEBUG("HCic[%zu -> %i] = %f (%f dB) -> angle: %f\n",
                i, k,myFilter[i], 20.0 * log10(myFilter[i]), angle);
    }
}
コード例 #2
0
ファイル: ConvEncoder.cpp プロジェクト: g4idrijs/ODR-DabMod
ConvEncoder::ConvEncoder(size_t framesize) :
    ModCodec(ModFormat(framesize), ModFormat((framesize * 4) + 3)),
    d_framesize(framesize)
{
    PDEBUG("ConvEncoder::ConvEncoder(%zu)\n", framesize);

}
コード例 #3
0
DifferentialModulator::DifferentialModulator(size_t carriers) :
    ModMux(ModFormat(carriers * sizeof(complexf)), ModFormat(carriers * sizeof(complexf))),
    d_carriers(carriers)
{
    PDEBUG("DifferentialModulator::DifferentialModulator(%zu)\n", carriers);

}
コード例 #4
0
QpskSymbolMapper::QpskSymbolMapper(size_t carriers) :
    ModCodec(ModFormat(carriers / 4), ModFormat(carriers * 8)),
    d_carriers(carriers)
{
    PDEBUG("QpskSymbolMapper::QpskSymbolMapper(%zu) @ %p\n", carriers, this);

}
コード例 #5
0
ファイル: NullSymbol.cpp プロジェクト: barczynsky/ODR-DabMod
NullSymbol::NullSymbol(size_t nbCarriers) :
    ModCodec(ModFormat(0), ModFormat(nbCarriers * sizeof(complexf))),
    myNbCarriers(nbCarriers)
{
    PDEBUG("NullSymbol::NullSymbol(%zu) @ %p\n", nbCarriers, this);

}
コード例 #6
0
DabModulator::DabModulator(
        struct modulator_offset_config& modconf,
        BaseRemoteController* rc,
        Logger& logger,
        unsigned outputRate, unsigned clockRate,
        unsigned dabMode, GainMode gainMode, float factor,
        std::string filterTapsFilename
        ) :
    ModCodec(ModFormat(1), ModFormat(0)),
    myLogger(logger),
    myOutputRate(outputRate),
    myClockRate(clockRate),
    myDabMode(dabMode),
    myGainMode(gainMode),
    myFactor(factor),
    myEtiReader(EtiReader(modconf, myLogger)),
    myFlowgraph(NULL),
    myFilterTapsFilename(filterTapsFilename),
    myRC(rc)
{
    PDEBUG("DabModulator::DabModulator(%u, %u, %u, %u) @ %p\n",
            outputRate, clockRate, dabMode, gainMode, this);

    if (myDabMode == 0) {
        setMode(2);
    } else {
        setMode(myDabMode);
    }
}
コード例 #7
0
Resampler::Resampler(size_t inputRate, size_t outputRate, size_t resolution) :
    ModCodec(ModFormat(inputRate * sizeof(complexf)),
            ModFormat(outputRate * sizeof(complexf))),
    myFftPlan1(NULL),
    myFftPlan2(NULL),
    myFftIn(NULL),
    myFftOut(NULL),
    myBufferIn(NULL),
    myBufferOut(NULL),
    myFront(NULL),
    myBack(NULL),
    myWindow(NULL)
{
    PDEBUG("Resampler::Resampler(%zu, %zu) @ %p\n", inputRate, outputRate, this);

    size_t divisor = gcd(inputRate, outputRate);
    L = outputRate / divisor;
    M = inputRate / divisor;
    PDEBUG(" gcd: %zu, L: %zu, M: %zu\n", divisor, L, M);
    {
        size_t factor = resolution * 2 / M;
        if (factor & 1) {
            ++factor;
        }
        myFftSizeIn = factor * M;
        myFftSizeOut = factor * L;
    }
    PDEBUG(" FFT size in: %zu, FFT size out: %zu\n", myFftSizeIn, myFftSizeOut);

    if (myFftSizeIn > myFftSizeOut) {
        myFactor = 1.0f / myFftSizeIn;
    } else {
        myFactor = 1.0f / myFftSizeOut;
    }

    myWindow = (float*)memalign(16, myFftSizeIn * sizeof(float));
    for (size_t i = 0; i < myFftSizeIn; ++i) {
        myWindow[i] = 0.5f * (1.0f - cosf(2.0f * M_PI * i / (myFftSizeIn - 1)));
        PDEBUG("Window[%zu] = %f\n", i, myWindow[i]);
    }

    myFftIn = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeIn);
    myFront = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeIn);
    myFftPlan1 = fftwf_plan_dft_1d(myFftSizeIn,
            myFftIn, myFront,
            FFTW_FORWARD, FFTW_MEASURE);

    myBack = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeOut);
    myFftOut = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeOut);
    myFftPlan2 = fftwf_plan_dft_1d(myFftSizeOut,
            myBack, myFftOut,
            FFTW_BACKWARD, FFTW_MEASURE);

    myBufferIn = (complexf*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeIn / 2);
    myBufferOut = (complexf*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeOut / 2);

    memset(myBufferIn, 0, myFftSizeIn / 2 * sizeof(FFT_TYPE));
    memset(myBufferOut, 0, myFftSizeOut / 2 * sizeof(FFT_TYPE));
}
コード例 #8
0
PuncturingEncoder::PuncturingEncoder() :
    ModCodec(ModFormat(0), ModFormat(0)),
    d_in_block_size(0),
    d_out_block_size(0),
    d_tail_rule(NULL)
{
    PDEBUG("PuncturingEncoder() @ %p\n", this);

}
コード例 #9
0
PrbsGenerator::PrbsGenerator(size_t framesize, uint32_t polynomial,
        uint32_t accum, size_t init) :
    ModCodec(ModFormat(0), ModFormat(framesize)),
    d_framesize(framesize),
    d_polynomial(polynomial),
    d_accum(accum),
    d_accum_init(accum),
    d_init(init)
{
    PDEBUG("PrbsGenerator::PrbsGenerator(%zu, %u, %u, %zu) @ %p\n",
            framesize, polynomial, accum, init, this);

    gen_prbs_table();
    gen_weight_table();
}
コード例 #10
0
OfdmGenerator::OfdmGenerator(size_t nbSymbols,
        size_t nbCarriers,
        size_t spacing,
        bool inverse) :
    ModCodec(ModFormat(nbSymbols * nbCarriers * sizeof(FFT_TYPE)),
            ModFormat(nbSymbols * spacing * sizeof(FFT_TYPE))),
    myFftPlan(NULL),
#if USE_FFTW
    myFftIn(NULL), myFftOut(NULL),
#else
    myFftBuffer(NULL),
#endif
    myNbSymbols(nbSymbols),
    myNbCarriers(nbCarriers),
    mySpacing(spacing)
{
    PDEBUG("OfdmGenerator::OfdmGenerator(%zu, %zu, %zu, %s) @ %p\n",
            nbSymbols, nbCarriers, spacing, inverse ? "true" : "false", this);

    if (nbCarriers > spacing) {
        throw std::runtime_error(
                "OfdmGenerator::OfdmGenerator nbCarriers > spacing!");
    }

    if (inverse) {
        myPosDst = (nbCarriers & 1 ? 0 : 1);
        myPosSrc = 0;
        myPosSize = (nbCarriers + 1) / 2;
        myNegDst = spacing - (nbCarriers / 2);
        myNegSrc = (nbCarriers + 1) / 2;
        myNegSize = nbCarriers / 2;
    }
    else {
        myPosDst = (nbCarriers & 1 ? 0 : 1);
        myPosSrc = nbCarriers / 2;
        myPosSize = (nbCarriers + 1) / 2;
        myNegDst = spacing - (nbCarriers / 2);
        myNegSrc = 0;
        myNegSize = nbCarriers / 2;
    }
    myZeroDst = myPosDst + myPosSize;
    myZeroSize = myNegDst - myZeroDst;

    PDEBUG("  myPosDst: %u\n", myPosDst);
    PDEBUG("  myPosSrc: %u\n", myPosSrc);
    PDEBUG("  myPosSize: %u\n", myPosSize);
    PDEBUG("  myNegDst: %u\n", myNegDst);
    PDEBUG("  myNegSrc: %u\n", myNegSrc);
    PDEBUG("  myNegSize: %u\n", myNegSize);
    PDEBUG("  myZeroDst: %u\n", myZeroDst);
    PDEBUG("  myZeroSize: %u\n", myZeroSize);

#if USE_FFTW
    const int N = mySpacing; // The size of the FFT
    myFftIn = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * N);
    myFftOut = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * N);
    myFftPlan = fftwf_plan_dft_1d(N,
            myFftIn, myFftOut,
            FFTW_BACKWARD, FFTW_MEASURE);

    if (sizeof(complexf) != sizeof(FFT_TYPE)) {
        printf("sizeof(complexf) %zu\n", sizeof(complexf));
        printf("sizeof(FFT_TYPE) %zu\n", sizeof(FFT_TYPE));
        throw std::runtime_error(
                "OfdmGenerator::process complexf size is not FFT_TYPE size!");
    }
#else
    myFftPlan = kiss_fft_alloc(mySpacing, 1, NULL, NULL);
    myFftBuffer = (FFT_TYPE*)memalign(16, mySpacing * sizeof(FFT_TYPE));
#endif

}