Click.h 1.93 KB
Newer Older
1 2 3
/*
	Click.h
	
4
	Copyright 2004-13 Tim Goetze <tim@quitte.de>
5 6 7
	
	http://quitte.de/dsp/

8
	Units repeatedly playing back a wavetable.
9 10 11 12 13

*/
/*
	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
14
	as published by the Free Software Foundation; either version 3
15 16 17 18 19 20 21 22 23 24 25 26 27
	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 or point your web browser to http://www.gnu.org.
*/

28 29
#ifndef CLICK_H
#define CLICK_H
30

31 32
#include "dsp/IIR1.h"
#include "dsp/IIR2.h"
33 34
#include "dsp/util.h"

35
template <int Waves>
36
class ClickStub
37
: public Plugin
38 39
{
	public:
40
		sample_t bpm;
41

42 43 44 45
		struct {
			int16 * data;
			uint N; /* number of samples in wave */
		} wave[Waves];
46

47
		DSP::LP1<sample_t> lp;
48

49 50
		uint period; /* frames remaining in period */
		uint played; /* frames played from sample */
51

52
		void cycle (uint frames);
53

54 55 56 57 58 59 60 61 62 63
		ClickStub() 
			{
				for (int i=0; i < Waves; ++i)
					wave[i].data = 0;
			}
		~ClickStub() 
			{
				for (int i=0; i < Waves; ++i)
					if (wave[i].data) delete [] wave[i].data;
			}
64

65 66
	public:
		void initwave (int i, int16 * wave, uint N);
67 68 69 70 71

		void activate()
			{ 
				played = 0;
				period = 0;
72
				bpm = -1;
73 74 75 76
			}
};

class Click
77
: public ClickStub<4>
78 79
{
	public:
80 81 82
		void initsimple();
		void initparfilt();
		void initsine();
83
		void initdirac();
84

85 86
		void init()
			{ initsimple(); initparfilt(); initsine(); initdirac(); }
87 88 89 90

		static PortInfo port_info [];
};

91
class CEO
92
: public ClickStub<1>
93 94
{
	public:
95
		void init();
96 97 98 99

		static PortInfo port_info [];
};

100
#endif /* CLICK_H */