1 /*
2  * monodelay.h - defination of MonoDelay class.
3  *
4  * Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
5  *
6  * This file is part of LMMS - https://lmms.io
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public
19  * License along with this program (see COPYING); if not, write to the
20  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301 USA.
22  *
23  */
24 
25 #ifndef MONODELAY_H
26 #define MONODELAY_H
27 
28 #include "lmms_basics.h"
29 
30 class MonoDelay
31 {
32 public:
33 	MonoDelay( int maxTime , int sampleRate );
34 	~MonoDelay();
setLength(float length)35 	inline void setLength( float length )
36 	{
37 		if( length <= m_maxLength && length >= 0 )
38 		{
39 			m_length = length;
40 		}
41 	}
42 
setFeedback(float feedback)43 	inline void setFeedback( float feedback )
44 	{
45 		m_feedback = feedback;
46 	}
47 
48 	void tick( sample_t* sample );
49 	void setSampleRate( int sampleRate );
50 
51 private:
52 	sample_t* m_buffer;
53 	int m_maxLength;
54 	float m_length;
55 	int m_writeIndex;
56 	float m_feedback;
57 	float m_maxTime;
58 };
59 
60 #endif // MONODELAY_H
61