-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSpectralHarp.h
70 lines (52 loc) · 2.1 KB
/
SpectralHarp.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
67
68
69
70
#ifndef __SPECTRALHARP__
#define __SPECTRALHARP__
#include "IPlug_include_in_plug_hdr.h"
#include "IMidiQueue.h"
#include "Params.h"
#include "SpectralGen.h"
#include "BitCrush.h"
#include "TickRate.h"
#include <vector>
class SpectralHarp : public IPlug
{
public:
SpectralHarp(IPlugInstanceInfo instanceInfo);
~SpectralHarp();
void Reset() override;
void OnParamChange(int paramIdx) override;
void ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames) override;
int UnserializeState(ByteChunk* pChunk, int startPos) override;
void BeginMIDILearn(int paramIdx1, int paramIdx2, int x, int y);
void ProcessMidiMsg(IMidiMsg* pMsg) override;
// catch the About menu item to display what we wants in a box
bool HostRequestingAboutBox() override;
void BroadcastParamChange(const int paramIdx);
// given a string number between 0 and the current value of Density,
// return the current frequency based on related parameters like BandFirst and BandLast.
float FrequencyOfString(int stringNum);
// can be called directly from StringControl, but also used internally in response to param changes and midi.
void Pluck(const float pluckX, const float pluckY);
private:
void InitBandParam(const char * name, const int paramIdx, const int defaultValue);
void HandleMidiControlChange(IMidiMsg* pMsg);
void SetControlChangeForParam(const IMidiMsg::EControlChangeMsg cc, const int paramIdx);
float GetPluckAmp(const float pluckY) const;
void PluckSpectrum(const float freq, float mag);
bool mIsLoading;
float mGain;
float mPluckX;
float mPluckY;
float mSpread;
float mBrightness;
SpectralGen specGen;
Minim::BitCrush bitCrush;
Minim::TickRate tickRate;
// if not -1 when we receive a control change midi message
// we use this to determine which param should be linked to the control change
int midiLearnParamIdx;
// for each param, which midi control change should set its value
IMidiMsg::EControlChangeMsg controlChangeForParam[kNumParams];
IMidiQueue mMidiQueue;
std::vector<IMidiMsg> mNotes;
};
#endif