1 /*  SpiralSynth
2  *  Copyleft (C) 2000 David Griffiths <dave@pawfal.org>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18 
19 #include <math.h>
20 #include "NoteTable.h"
21 #include "SpiralInfo.h"
22 
23 #ifndef SEQ
24 #define SEQ
25 
26 static const float MIN_TIME=SpiralInfo::BUFSIZE/(float)SpiralInfo::SAMPLERATE;
27 
28 class Sequencer
29 {
30 public:
31 	Sequencer();
32 	void Trigger(int oct, int note);
Play(bool n)33 	void Play(bool n) {m_Playing=n;}
Playing()34 	bool Playing() {return m_Playing;}
SetEvent(int n)35 	void SetEvent(int n) {m_EventList[n]=true;}
UnSetEvent(int n)36 	void UnSetEvent(int n) {m_EventList[n]=false;}
SetSpeed(float s)37 	void SetSpeed(float s) {m_NCalls=(int)(s/MIN_TIME);}
SetArpType(int s)38 	void SetArpType(int s) {m_ArpType=s;}
SetOctave(int s)39 	void SetOctave(int s) {m_Octave=s;}
SetLength(int s)40 	void SetLength(int s) {m_Length=s;}
SetArp(bool s)41 	void SetArp(bool s) {m_Arp=s;}
SetArpNotes(int s)42 	void SetArpNotes(int s) {m_ArpNotes=s;}
43 	bool GetSeqNote(float &note, int &oct, int &key);
44 
45 private:
46 
47 	bool  m_Playing;
48 	int   m_Step;
49 	int   m_NCalls;
50 	int   m_Count;
51 	int   m_EventList[191]; // 16X12
52 	float m_TimeList[16];
53 	float m_FreqList[12];
54 	float m_VolList[16];
55 
56 	int   m_ArpType;
57 	int   m_Octave;
58 	int   m_Length;
59 	bool  m_Arp;
60 	int   m_ArpNotes;
61 	int   m_ArpPos;
62 	int   m_OffsetNote;
63 	int   m_OffsetOct;
64 };
65 
66 #endif
67