mirror of
https://github.com/JvanKatwijk/qt-dab.git
synced 2025-10-06 00:02:40 +02:00
112 lines
3.2 KiB
C++
112 lines
3.2 KiB
C++
#
|
|
/*
|
|
* Copyright (C) 2016 .. 2024
|
|
* Jan van Katwijk (J.vanKatwijk@gmail.com)
|
|
* Lazy Chair Computing
|
|
*
|
|
* This file is part of Qt-DAB
|
|
*
|
|
* Qt-DAB 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; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Qt-DAB 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.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Qt-DAB; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
#pragma once
|
|
|
|
#include "dab-constants.h"
|
|
#include <QObject>
|
|
#include <vector>
|
|
#include <cstdint>
|
|
#include "ringbuffer.h"
|
|
#include "phasetable.h"
|
|
#include "freq-interleaver.h"
|
|
#include "dab-params.h"
|
|
#include "fft-handler.h"
|
|
#include "phasetable.h"
|
|
class RadioInterface;
|
|
|
|
#define SHOW_RAW 0100
|
|
#define SHOW_DECODED 0101
|
|
|
|
#ifndef M_PI_2
|
|
#define M_PI_2 (M_PI / 2)
|
|
#endif
|
|
#ifndef M_PI_4
|
|
#define M_PI_4 (M_PI / 4)
|
|
#endif
|
|
class ofdmDecoder: public QObject {
|
|
Q_OBJECT
|
|
public:
|
|
ofdmDecoder (RadioInterface *,
|
|
uint8_t,
|
|
int16_t,
|
|
RingBuffer<float> *devBuffer,
|
|
RingBuffer<Complex> * iqBuffer = nullptr);
|
|
~ofdmDecoder ();
|
|
void setNullLevel (const std::vector<Complex> &);
|
|
//
|
|
// Note: the parameter should not be altered, it is used later on
|
|
void processBlock_0 (std::vector<Complex>);
|
|
void decode (std::vector<Complex> &,
|
|
int32_t n,
|
|
std::vector<int16_t> &, DABFLOAT);
|
|
void stop ();
|
|
void reset ();
|
|
void handle_iqSelector ();
|
|
void handle_decoderSelector (int);
|
|
private:
|
|
RadioInterface *myRadioInterface;
|
|
dabParams params;
|
|
phaseTable theTable;
|
|
interLeaver myMapper;
|
|
fftHandler fft;
|
|
RingBuffer<float> *devBuffer;
|
|
RingBuffer<Complex> *iqBuffer;
|
|
|
|
float computeQuality (Complex *);
|
|
float compute_timeOffset (Complex *,
|
|
Complex *);
|
|
float compute_clockOffset (Complex *,
|
|
Complex *);
|
|
float compute_frequencyOffset (Complex *,
|
|
Complex *);
|
|
int32_t T_s;
|
|
int32_t T_u;
|
|
int32_t T_g;
|
|
int32_t nrBlocks;
|
|
int32_t carriers;
|
|
std::vector<Complex> phaseReference;
|
|
std::vector<int16_t> ibits;
|
|
std::vector<Complex> conjVector;
|
|
std::vector<Complex> fft_buffer;
|
|
std::vector<DABFLOAT> sigmaSQ_Vector;
|
|
std::vector<DABFLOAT> meanLevelVector;
|
|
std::vector<DABFLOAT> stdDevVector;
|
|
std::vector<DABFLOAT> angleVector;
|
|
std::vector<DABFLOAT> powerLevelVector;
|
|
std::vector<DABFLOAT> nullLevelVector;
|
|
|
|
float meanValue;
|
|
float avgBit;
|
|
int iqSelector;
|
|
int decoder;
|
|
int repetitionCounter;
|
|
|
|
double sqrt_2;
|
|
signals:
|
|
void showIQ (int);
|
|
void show_quality (float, float, float);
|
|
void show_stdDev (int);
|
|
};
|
|
|
|
|