/
FMSoundSynthesis.h
63 lines (40 loc) · 1.31 KB
/
FMSoundSynthesis.h
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
/*
* FMSoundSynthesis.h
*
*/
#ifndef FMSOUNDSYNTHESIS_H_
#define FMSOUNDSYNTHESIS_H_
#include "SDLSoundSynthesis.h"
#include <vector>
class FMSoundSynthesis: public SDLSoundSynthesis {
public:
FMSoundSynthesis();
virtual ~FMSoundSynthesis();
virtual std::string getSynthesizerName();
virtual bool reset();
virtual bool getParameters(std::vector<float>& p);
virtual bool setParameters(const std::vector<float>& p);
virtual int getNumberOfParameters();
virtual unsigned long long getSoundSynthesisSpeedMS();
virtual double getSynthPower();
protected:
// milliseconds since epoch
unsigned long long getMilliseconds();
double tbase;
double Ac; // amplitude/volume of carrier
double Fc; // carrier frequency
double Fm; // modulating frequency
double Am; // amplitude of modulator: delta of frequency
std::vector<float> currentp;
unsigned long long resetTime = 0ULL;
double fadeoutTime;
double oldAc;
double oldFc;
double oldFm;
double oldAm;
static const unsigned int NBUFFERS = 10;
std::vector<int16_t> prevbuffer[NBUFFERS];
virtual bool synthesize(int16_t* buffer, int samples);
double currentPower = 0.0; // current output signal power
};
#endif /* FMSOUNDSYNTHESIS_H_ */