/***************************************************************************
                          tone.h  -  description
                             -------------------
    begin                : Don Feb 10 2005
    copyright            : (C) 2005 by klaus frieler
    email                : kgf@omniversum.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program 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.                                   *
 *                                                                         *
 ***************************************************************************/
#ifndef _LIBMELODY_TONE_H
#define _LIBMELODY_TONE_H
#include "types.h"
#include "BarTime.h"
 
#define invalidTick ((uint)-1)

class Tone{

public:
//construction
   Tone(const uint ticks, const double t, const uint pitch, const double dur, const BarPosition barPos)
      :m_ticks(ticks), m_t(t), m_pitch(pitch), m_dur(dur), m_barPos(barPos)
   { }
   Tone():m_ticks(0), m_t(0.0),m_pitch(0), m_dur(0.0), m_barPos(invalidBarPosition)
   {}
   Tone(const Tone& tone): m_ticks(tone.m_ticks), m_t(tone.m_t), m_pitch(tone.m_pitch), m_dur(tone.m_dur), m_barPos(tone.m_barPos)
   {}

//destruction
  ~Tone(){}

//operators  
   Tone& operator=(const Tone& tone)
   {
      m_ticks = tone.m_ticks;
      m_t = tone.m_t;
      m_pitch = tone.m_pitch;
      m_dur = tone.m_dur;
      m_barPos = tone.m_barPos;
      return *this;
   }

//setter   
   void     set(const uint ticks, const double t, const uint pitch, const double dur = 0.0)
   {
      m_ticks = ticks;
      m_t= t;
      m_dur = dur;
      m_pitch = pitch;
   }
   void     setTicks(const uint ticks)   { m_ticks = ticks;}
   void     setTime(const double t)      { m_t     = t;    }
   void     setDuration(const double dur){ m_dur   = dur;  }
   void     setPitch(const uint pitch)   { m_pitch = pitch;}
   void     setBarPosition(const uint bar, const uint beat, const uint ticks)
   { 
      m_barPos.set(bar, beat, ticks);
   }
   void     setBarPosition(const BarPosition& barPos){ m_barPos = barPos;}
//getter
   uint     getTicks() const    { return m_ticks; }
   double   getTime() const     { return m_t;}
   double   getDuration() const { return m_dur;}
   uint     getPitch()const     { return m_pitch;}
   BarPosition getBarPosition() const { return m_barPos;}
   void     dump() const 
   { 
      cout<<"ticks  ="<<m_ticks<<" t = "<<m_t<<" dur:"<<m_dur<<" pitch: "<<m_pitch<<" BarPosition:"; m_barPos.dump(); 
   }

protected:
   uint        m_ticks;
   double      m_t;
   uint        m_pitch;
   double      m_dur;
   BarPosition m_barPos;
};

typedef  vector<Tone>               ToneList;
typedef  ToneList::iterator         toneIt;
typedef  ToneList::const_iterator   const_toneIt;

#endif