/*  SpiralSynth
 *  Copyleft (C) 2000 David Griffiths <dave@pawfal.org>
 *
 *  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.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ 

#include <math.h>
#include "NoteTable.h"
#include "SpiralInfo.h"

#ifndef SEQ
#define SEQ

static const float MIN_TIME=SpiralInfo::BUFSIZE/(float)SpiralInfo::SAMPLERATE;

class Sequencer
{
public:
	Sequencer();
	void Trigger(int oct, int note);
	void Play(bool n) {m_Playing=n;}
	bool Playing() {return m_Playing;}
	void SetEvent(int n) {m_EventList[n]=true;}
	void UnSetEvent(int n) {m_EventList[n]=false;}
	void SetSpeed(float s) {m_NCalls=(int)(s/MIN_TIME);}
	void SetArpType(int s) {m_ArpType=s;}
	void SetOctave(int s) {m_Octave=s;}
	void SetLength(int s) {m_Length=s;}
	void SetArp(bool s) {m_Arp=s;}
	void SetArpNotes(int s) {m_ArpNotes=s;}
	bool Sequencer::GetSeqNote(float &note, int &oct, int &key);

private:

	bool  m_Playing;
	int   m_Step;
	int   m_NCalls;
	int   m_Count;
	int   m_EventList[191]; // 16X12
	float m_TimeList[16];
	float m_FreqList[12];
	float m_VolList[16];
	
	int   m_ArpType;
	int   m_Octave;
	int   m_Length;
	bool  m_Arp;
	int   m_ArpNotes;
	int   m_ArpPos;
	int   m_OffsetNote;
	int   m_OffsetOct;
};

#endif
