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