/
IsochronicSoundSynthesis.h
65 lines (41 loc) · 1.43 KB
/
IsochronicSoundSynthesis.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
64
65
/*
* IsochronicSoundSynthesis.h
*
* 2022 Tomas Ukkonen
*/
#ifndef ISOCHRONICSOUNDSYNTHESIS_H_
#define ISOCHRONICSOUNDSYNTHESIS_H_
#include "SDLSoundSynthesis.h"
#include <vector>
#include <list>
class IsochronicSoundSynthesis: public SDLSoundSynthesis {
public:
IsochronicSoundSynthesis();
virtual ~IsochronicSoundSynthesis();
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 A; // amplitude/volume of carrier
double Fc; // carrier frequency
double F; // isochronic frequency
std::vector<float> currentp;
unsigned long long resetTime = 0ULL;
double timeSinceReset; // from tbase value (secs)
double fadeoutTime; // in milliseconds
double oldA, oldFc, oldF;
std::list<double> meanbuffer;
double meansum = 0.0f;
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_ */