remove VST functions
[software/lv2-mdametapiano.git] / src / mdaPiano.h
1 //See associated .cpp file for copyright and other info
2
3 #ifndef __mdaPiano__
4 #define __mdaPiano__
5
6 #include <string.h>
7
8 #include "audioeffectx.h"
9
10 #define NPARAMS 12 //number of parameters
11 #define NPROGS 8 //number of programs
12 #define NOUTS 2 //number of outputs
13 #define NVOICES 32 //max polyphony
14 #define SUSTAIN 128
15 #define SILENCE 0.0001f //voice choking
16 #define WAVELEN 586348 //wave data bytes
17
18 class mdaPianoProgram
19 {
20 friend class mdaPiano;
21 public:
22 mdaPianoProgram();
23 ~mdaPianoProgram() {}
24
25 private:
26 float param[NPARAMS];
27 char name[24];
28 };
29
30
31 struct VOICE //voice state
32 {
33 VstInt32 delta; //sample playback
34 VstInt32 frac;
35 VstInt32 pos;
36 VstInt32 end;
37 VstInt32 loop;
38
39 float env; //envelope
40 float dec;
41
42 float f0; //first-order LPF
43 float f1;
44 float ff;
45
46 float outl;
47 float outr;
48 VstInt32 note; //remember what note triggered this
49 };
50
51
52 struct KGRP //keygroup
53 {
54 VstInt32 root; //MIDI root note
55 VstInt32 high; //highest note
56 VstInt32 pos;
57 VstInt32 end;
58 VstInt32 loop;
59 };
60
61 class mdaPiano : public AudioEffectX
62 {
63 public:
64 mdaPiano(audioMasterCallback audioMaster);
65 ~mdaPiano();
66
67 virtual void process(float **inputs, float **outputs, VstInt32 sampleframes);
68 virtual void processReplacing(float **inputs, float **outputs, VstInt32 sampleframes);
69 virtual VstInt32 processEvents(VstEvents* events);
70
71 virtual void setProgram(VstInt32 program);
72 virtual void setProgramName(char *name);
73 virtual void getProgramName(char *name);
74 virtual void setParameter(VstInt32 index, float value);
75 virtual float getParameter(VstInt32 index);
76 virtual void getParameterLabel(VstInt32 index, char *label);
77 virtual void getParameterDisplay(VstInt32 index, char *text);
78 virtual void getParameterName(VstInt32 index, char *text);
79 virtual void setBlockSize(VstInt32 blockSize);
80 virtual void resume();
81
82 virtual bool copyProgram (VstInt32 destination);
83
84
85 private:
86 void update(); //my parameter update
87 void noteOn(VstInt32 note, VstInt32 velocity);
88 void fillpatch(VstInt32 p, char *name, float p0, float p1, float p2, float p3, float p4,
89 float p5, float p6, float p7, float p8, float p9, float p10,float p11);
90
91 float param[NPARAMS];
92 mdaPianoProgram* programs;
93 float Fs, iFs;
94
95 #define EVENTBUFFER 120
96 #define EVENTS_DONE 99999999
97 VstInt32 notes[EVENTBUFFER + 8]; //list of delta|note|velocity for current block
98
99 ///global internal variables
100 KGRP kgrp[16];
101 VOICE voice[NVOICES];
102 VstInt32 activevoices, poly, cpos;
103 short *waves;
104 VstInt32 cmax;
105 float *comb, cdep, width, trim;
106 VstInt32 size, sustain;
107 float tune, fine, random, stretch;
108 float muff, muffvel, sizevel, velsens, volume;
109 };
110
111 #endif