//-----------------------------------------------------------------------------
///
/// \brief  Synthesizer, can produze some music/noise/alarm sounds via Dac
///
///         See implementation for further details
///
/// \author Maximilian Seesslen <mes@seesslen.net>
///
//-----------------------------------------------------------------------------


//---Includes-----------------------------------------------------------------


#include <biwak/biwak.h>
#include <stdint.h>


//---Defines------------------------------------------------------------------


#define DEFAULT_SAMPLE_COUNT     0x40


//---Declarations-------------------------------------------------------------


enum EWaveForm{
// enum class EDisplayMode : char {
   eWaveFormNone=0,
   eWaveFormNoise,
   eWaveFormSinus,
   eWaveFormSquare,
   eWaveFormSawtooth,
   eWaveFormTriangle,
   eWaveFormMax,
};


enum ESirenMode
{
   eSirenModeNone,
   eSirenModeUp,
   eSirenModeDown,
   eSirenModeUpDown,
};


enum ESirenState
{
   eSirenStateNone,
   eSirenStateStart,
   eSirenStateUpDown,
   eSirenStateHold,
   eSirenStateStop,
   eSirenStateEnd,
};


class CDac;
class CTimer;


class CSynthesizer
{
   private:
      CDac &dac;
      CTimer &dacTimer;
      CTimer &controlTimer;
      int m_sampleCount;
      uint8_t *data;

      ESirenMode eSirenMode;
      ESirenState eSirenState;
      int   frequency;
      int   counter;

      static CSynthesizer* synth;

   public:
      CSynthesizer(CDac &_dac, CTimer &_dacTimer, CTimer &_controlTimer);
      ~CSynthesizer();
      void generateWaveForm(EWaveForm eWaveForm);
      void play();
      void startSiren( ESirenMode _eSirenMode);
      void stop();

      virtual void interrupt();

};


//---fin----------------------------------------------------------------------
