consistent use of two space indentation
[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 getOutputProperties (VstInt32 index, VstPinProperties* properties);
83 virtual bool getProgramNameIndexed (VstInt32 category, VstInt32 index, char* text);
84 virtual bool copyProgram (VstInt32 destination);
85 virtual bool getEffectName (char* name);
86 virtual bool getVendorString (char* text);
87 virtual bool getProductString (char* text);
88 virtual VstInt32 getVendorVersion () {return 1;}
89 virtual VstInt32 canDo (char* text);
90
91 virtual VstInt32 getNumMidiInputChannels () { return 1; }
92
93 VstInt32 guiUpdate;
94 void guiGetDisplay(VstInt32 index, char *label);
95
96 private:
97 void update(); //my parameter update
98 void noteOn(VstInt32 note, VstInt32 velocity);
99 void fillpatch(VstInt32 p, char *name, float p0, float p1, float p2, float p3, float p4,
100 float p5, float p6, float p7, float p8, float p9, float p10,float p11);
101
102 float param[NPARAMS];
103 mdaPianoProgram* programs;
104 float Fs, iFs;
105
106 #define EVENTBUFFER 120
107 #define EVENTS_DONE 99999999
108 VstInt32 notes[EVENTBUFFER + 8]; //list of delta|note|velocity for current block
109
110 ///global internal variables
111 KGRP kgrp[16];
112 VOICE voice[NVOICES];
113 VstInt32 activevoices, poly, cpos;
114 short *waves;
115 VstInt32 cmax;
116 float *comb, cdep, width, trim;
117 VstInt32 size, sustain;
118 float tune, fine, random, stretch;
119 float muff, muffvel, sizevel, velsens, volume;
120 };
121
122 #endif