1 /*
2   Copyright 2008-2011 David Robillard <http://drobilla.net>
3   Copyright 1999-2000 Paul Kellett (Maxim Digital Audio)
4 
5   This is free software: you can redistribute it and/or modify it
6   under the terms of the GNU General Public License as published by
7   the Free Software Foundation, either version 3 of the License,
8   or (at your option) any later version.
9 
10   This software is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13   See the GNU General Public License for more details.
14 
15   You should have received a copy of the GNU General Public License
16   along with this software. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef __mdaLooplex__
20 #define __mdaLooplex__
21 
22 #include "audioeffectx.h"
23 
24 #include <cstdint>
25 #include <cstring>
26 
27 #define NPARAMS  7       //number of parameters
28 #define NPROGS   1       //number of programs
29 #define NOUTS    2       //number of outputs
30 #define SILENCE  0.00001f
31 
32 
33 class mdaLooplexProgram
34 {
35   friend class mdaLooplex;
36 public:
37 	mdaLooplexProgram();
38 private:
39   float param[NPARAMS];
40   char  name[24];
41 };
42 
43 
44 class mdaLooplex : public AudioEffectX
45 {
46 public:
47 	mdaLooplex(audioMasterCallback audioMaster);
48 	~mdaLooplex();
49 
50 	virtual void process(float **inputs, float **outputs, int32_t sampleframes);
51 	virtual void processReplacing(float **inputs, float **outputs, int32_t sampleframes);
52 	virtual int32_t processEvents(LvzEvents* events);
53 
54 	virtual void setProgram(int32_t program);
55 	virtual void setProgramName(char *name);
56 	virtual void getProgramName(char *name);
57 	virtual void setParameter(int32_t index, float value);
58 	virtual float getParameter(int32_t index);
59 	virtual void getParameterLabel(int32_t index, char *label);
60 	virtual void getParameterDisplay(int32_t index, char *text);
61 	virtual void getParameterName(int32_t index, char *text);
62 	virtual void setSampleRate(float sampleRate);
63 	virtual void setBlockSize(int32_t blockSize);
64     virtual void resume();
65 
66 	virtual bool getProgramNameIndexed (int32_t category, int32_t index, char* text);
67 	virtual bool copyProgram (int32_t destination);
68 	virtual bool getEffectName (char* name);
69 	virtual bool getVendorString (char* text);
70 	virtual bool getProductString (char* text);
getVendorVersion()71 	virtual int32_t getVendorVersion () {return 1;}
72 	virtual int32_t canDo (char* text);
73 
getNumMidiInputChannels()74 	virtual int32_t getNumMidiInputChannels ()  { return 1; }
75 
76   void idle();
77 
78 private:
79 	void update();  //my parameter update
80 
81   mdaLooplexProgram* programs;
82   float Fs;
83 
84   #define EVENTBUFFER 120
85   #define EVENTS_DONE 99999999
86   int32_t notes[EVENTBUFFER + 8];  //list of delta|note|velocity for current block
87 
88   ///global internal variables
89   float in_mix, in_pan, out_mix, feedback, modwhl;
90 
91   short *buffer;
92   int32_t bufpos, buflen, bufmax, mode;
93 
94   int32_t bypass, bypassed, busy, status, recreq;
95   float oldParam0, oldParam1, oldParam2;
96 
97 };
98 
99 #endif
100