// -*- C++ -*- generated by wxGlade 0.4 on Wed Apr 19 09:12:48 2006

/********************************

Copyright 2006-2012 ir drs E.J Boks, Hogeschool van Arnhem en Nijmegen
Demonstratieprogramma voor IIR implementatie met Matlab filter coefficienten

********************************/ 

#ifndef IIRFLOATFILTER_H
#define IIRFLOATFILTER_H

#include <wx/wx.h>
#include <wx/image.h>

// begin wxGlade: ::dependencies
#include <wx/spinctrl.h>
#include <wx/tglbtn.h>
// end wxGlade

#include "algdef.h"
#include <grafiekVenster.h>
#include <desktopApp.h>
#include <dsbklassen.h>

const unsigned int MWSPT_NSEC = 8;
const unsigned int AantalDataPunten   =   128;
#define SignaalMaxAmplitude       (1<<15)


/* filterbank van 2e orde IIR secties */
/* Direct Form II structuur (Canonical ) */
/* sluit aan bij Matlab Header export formaat double precision */ 
//typedef int Frequentie;


class FilterIIRDoubleSectie
{
public: 
	
    FilterIIRDoubleSectie(double const * const,     /* x coeffs */
                          double const * const );   /* y coeffs */
	
    ~FilterIIRDoubleSectie();
	
    void reset();
	
    double filter(const double );
	
    
	
private:
	
    RingBuffer<double>  xCoeffs;
    RingBuffer<double>  yCoeffs;
	
    RingBuffer<double> xWaarden;
    RingBuffer<double> yWaarden;
};

const unsigned int MaxAantalSekties=32;


class FilterIIRDouble
{
public:
	FilterIIRDouble(const Teller,
					double const * const,     /* x coeffs */
					double const * const );   /* y coeffs */
	~FilterIIRDouble();
	
	void reset();
	
    double filter(const double );
	
private:
	FilterIIRDoubleSectie *sekties[MaxAantalSekties];
	const unsigned int aantalSekties;
};



class IIRFloatVenster: public wxFrame {
public:
    // begin wxGlade: IIRFloatVenster::ids
    // end wxGlade

    IIRFloatVenster(wxWindow* parent, int id, const wxString& title, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE);


protected:
    // begin wxGlade: IIRFloatVenster::attributes
    wxMenuBar* iirFloatVenster_menubar;
    wxRadioBox* signaalKeuzeRadioBox;
    wxStaticText* amplitudeLabel;
    wxSpinCtrl* amplitudeSpin;
    wxStaticText* sigFreqLabel;
    wxChoice* signaalFreqKeuze;
    wxToggleButton* startKnop;
    wxButton* eindeKnop;
    wxStaticText* kopTekstLabel;
    GrafiekVenster* grafiekPaneel;
    wxPanel* paneel;
    // end wxGlade

    DECLARE_EVENT_TABLE();

private:
    // begin wxGlade: IIRFloatVenster::methods
    void set_properties();
    void do_layout();
    // end wxGlade

  	FilterIIRDouble filter;
	
    wxArrayDouble signaal, signaalGefilterd;
	
    double hoekFreq;
    double amplitude;
    bool start;
    
    void bouwSignaal();
    void filterSignaal();
    void tekenSignalen();

    void eindeUpdateHandler(wxUpdateUIEvent &);

    virtual void signaalKeuzeHandler(wxCommandEvent &event); // wxGlade: <event_handler>
    virtual void signaalAmplitudeHandler(wxSpinEvent &event); // wxGlade: <event_handler>
    virtual void signaalFreqHandler(wxCommandEvent &event); // wxGlade: <event_handler>
    virtual void startStopHandler(wxCommandEvent &event); // wxGlade: <event_handler>
    virtual void eindeHandler(wxCommandEvent &event); // wxGlade: <event_handler>
    virtual void overHandler(wxCommandEvent &event); // wxGlade: <event_handler>
}; // wxGlade: end class


class IIRFloatFilter: public DesktopApp
{
public:
	IIRFloatFilter();
	
    bool OnInit();
};

DECLARE_APP(IIRFloatFilter)




#endif // FIR_H
