/*
 * modulations.h fichier d'en-tête
 * Licence GPL v2
 * Author and copyright : Eric Bachard 2026/01/08 18h03
 *
 */

#ifndef __MODULATIONS_H
#define __MODULATIONS_H

#define DEFAULT_WORD_SIZE  8
#define WORD_SIZE_MAX     24

#define DEFAULT_SAMPLES_PER_BIT  400
#define SAMPLES_PER_BIT_MAX      400

#define VTOGGLEBUTTON_WIDTH   30.8f
#define CHILD2_WIDTH          300.0f
#define LARGE_CHILD2_WIDTH    400.0f
#define CANVAS_HEIGHT         400.0f

#define SINUS_AMPLITUDE  (0.35 * CANVAS_HEIGHT)

#include "application.h"


typedef enum DigitalModulationType
{
    // Amplitude
    MOD_OOK_TYPE    = 0,
    MOD_ASK_TYPE    = 1,
    MOD_MASK_TYPE   = 2,
    // Phase
    MOD_BPSK_TYPE    = 3,
    MOD_DPSK_TYPE   = 4,
    // Fréquence
    MOD_FSK_TYPE    = 5,
    MOD_MFSK_TYPE   = 6,
    // M-QAM
    MOD_M_QAM_TYPE  = 7,
    MOD_4_QAM_TYPE  = 8,
    MOD_16_QAM_TYPE = 9,
    // We can dream (wifi 7)
    MOD_256_QAM_TYPE = 10,
    // Should never be used
    NOT_A_MODULATION = 100
} DigitalModulationType;

class DigitalModulation
{
  public:
    // Ctor
    DigitalModulation();

    // Dtor
    ~DigitalModulation();

    short int AmplitudeDigitalModulation(float *, int *, DigitalModulationType *);
    short int FrequencyDigitalModulation(float *, int *, DigitalModulationType *);
    short int PhaseDigitalModulation    (float *, int *, DigitalModulationType *);
    short int M_QAM_DigitalModulation   (float *, int *, DigitalModulationType *);

    inline int getWordSize() { return mdWordSize; }
    inline void setWordSize(int aWordSize) { mdWordSize = aWordSize; }

    inline DigitalModulationType get_AM_DigitalModulationType()   { return md_AM_DigitalModulation_t; }
    inline DigitalModulationType get_FM_DigitalModulationType()   { return md_FM_DigitalModulation_t; }
    inline DigitalModulationType get_PM_DigitalModulationType()   { return md_PM_DigitalModulation_t; }
    inline DigitalModulationType getM_QAM_DigitalModulationType() { return md_M_QAM_DigitalModulation_t; }

    void setDigitalModulationType (TAB_Name aTab, DigitalModulationType aType);

  private:
    int mdWordSize;

    DigitalModulationType md_AM_DigitalModulation_t;
    DigitalModulationType md_FM_DigitalModulation_t;
    DigitalModulationType md_PM_DigitalModulation_t;
    DigitalModulationType md_M_QAM_DigitalModulation_t;
};


#endif  /* __MODULATIONS_H */