-
Notifications
You must be signed in to change notification settings - Fork 1
/
piano_coupled_strings.h
66 lines (48 loc) · 1.59 KB
/
piano_coupled_strings.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
66
#ifndef _PIANO_COUPLED_STRINGS_H_
#define _PIANO_COUPLED_STRINGS_H_
#include "Generator.h" // STK
#include "BiQuad.h"
#include "DelayA.h"
#include "PoleZero.h"
#include "TwoZero.h"
#include "Effect.h"
#include "Asymp.h"
using namespace stk;
class CoupledStrings : public Effect
{
public:
CoupledStrings();
~CoupledStrings() {}
virtual void clear() {};
virtual void noteOn (StkFloat frequency, StkFloat amplitude); // needed?
virtual void noteOff (StkFloat amplitude); // needed?
virtual void controlChange (int number, StkFloat value); // needed?
virtual void setFrequency (StkFloat frequency);
// Parameters
void setDetuningFactor(StkFloat factor);
void setStiffnessFactor(StkFloat factor);
// Helpers
static StkFloat AllPassPhase(StkFloat a1, StkFloat wT);
static StkFloat PoleZeroPhase(StkFloat b0, StkFloat b1, StkFloat a1, StkFloat wT);
static int FrequencyToNoteNumber(StkFloat frequency);
static StkFloat NoteNumberToFrequency(int note);
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
virtual StkFloat tick( StkFloat, unsigned int channel = 0 );
protected:
StkFloat delayLength(StkFloat freq, StkFloat stiffnessCoefficient);
void calcCouplingFilter();
StkFloat computeSample(StkFloat input);
PoleZero stiffnessAP[6];
DelayA delay1, delay2;
PoleZero couplingPoleZero;
Asymp loopGain;
StkFloat prev_y1, prev_y2;
StkFloat detuningFactor;
StkFloat frequency, freq1, freq2;
StkFloat stiffnessFactor;
int noteNumber;
StkFloat couplingB0;
StkFloat couplingB1;
StkFloat couplingA1;
};
#endif // _PIANO_COUPLED_STRINGS_H_