implement volume setter
[software/lv2-mdametapiano.git] / src / mdaPianoVoice.h
1 #ifndef MDA_PIANO_VOICE_H
2 #define MDA_PIANO_VOICE_H
3
4 #include "mdaPianoCommon.h"
5 #include "mdaPiano.peg"
6
7 #pragma GCC system_header
8 #include <lv2synth.hpp>
9
10 enum Param {
11 Default,
12 Current
13 };
14
15 class mdaPianoVoice : public LV2::Voice {
16 private:
17 float Fs, iFs;
18
19 /// global internal variables
20 KGRP *kgrp;
21 short *waves;
22 float default_preset[NPARAMS]; // contains the default preset
23 short sustain;
24 float volume;
25
26 // voice state
27 uint32_t delta; //sample playback
28 uint32_t frac;
29 uint32_t pos;
30 uint32_t end;
31 uint32_t loop;
32
33 float env; //envelope
34 float dec;
35
36 float f0; //first-order LPF
37 float f1;
38 float ff;
39
40 float outl;
41 float outr;
42 uint32_t note; //remember what note triggered this
43 // end of voice state
44
45 protected:
46 unsigned char m_key;
47
48 public:
49 mdaPianoVoice(double, short*, KGRP*);
50 void set_volume(float v) { volume = v; }
51
52 float p_helper(unsigned short, Param);
53 void update(Param); // recalculates internal variables
54 void on(unsigned char key, unsigned char velocity);
55 void reset(void);
56 unsigned char get_key(void) const { return m_key; }
57 };
58
59 #endif