#ifndef __SOUNDTEST_VIEWER_H
#define __SOUNDTEST_VIEWER_H
#include "defines.h"
#include <vdr/plugin.h>
#include <st.h>

extern "C" void cleanup(void);

class cCalculateData : public cThread {
private:
    uint64 time;
    void Data(void);
    void Calculate(void);
    bool first;
    long double C[SAMPLES];//Cosius-Tabelle
    long double S[SAMPLES];//Sinus-Tabelle
    long double B[SAMPLES];//2*Cosinus-Tabelle
    long double Q[SAMPLES];//zu bestimmende Frequenzen
    wert werte[2][MAXWERTE];//alte und neue Meßwerte
    int D[2][MAXCHANNELS][SAMPLES];//Meßwerte
    long double DD[MAXCHANNELS][SAMPLES];//für Meßwerte
    long double U[MAXCHANNELS][SAMPLES];
    int K[MAXCHANNELS][SAMPLES];//Frequenzanteile
    int size;
    int channels;
protected:
    virtual void Action(void);
public:
    cCalculateData(int samplerate, int samplesize, int samplechannels);
    ~cCalculateData();
    int Pid;
    int Kanal1;
    int Kanal2;
    bool linear;
    int screen;
};

class cUpdateData : public cThread {
private:
    st_size_t buffer_size;
protected:
    virtual void Action(void);
public:
    cUpdateData(st_size_t buffersize);
    ~cUpdateData();
    int Pid;
};

// --- cViewerObject -----------------------------------------------------------

class cViewerObject : public cOsdObject, public cThread {
private:
    cCalculateData *calculate;
    cUpdateData *update;
    tColor Color;
    bool color_changed;
    int Pid;
    int samplerate;
    int size;
    int channels;
    bool byteswap;
protected:
    virtual void Action(void);
public:
    cViewerObject(void);
    ~cViewerObject();
    virtual void Show(void);
    virtual eOSState ProcessKey(eKeys Key);
  };
#endif
