-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvelope.h
84 lines (71 loc) · 2.91 KB
/
envelope.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef ENVELOPE_H
#define ENVELOPE_H
/*
Copyright 2011 Arne Jacobs <[email protected]>
This file is part of elektrocillin.
Elektrocillin is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Elektrocillin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Elektrocillin. If not, see <http://www.gnu.org/licenses/>.
*/
#include "audioprocessor.h"
#include "midiprocessor.h"
#include "eventprocessor.h"
#include "parameterprocessor.h"
#include "linearinterpolator.h"
#include "logarithmicinterpolator.h"
class Envelope : public AudioProcessor, public MidiProcessor, public EventProcessor, public ParameterProcessor, public LogarithmicInterpolator
{
public:
enum Phase {
ATTACK = 0,
RELEASE = 1,
NONE,
SUSTAIN
};
class ChangeSustainPositionEvent : public RingBufferEvent
{
public:
ChangeSustainPositionEvent(int sustainIndex_) :
sustainIndex(sustainIndex_)
{}
int sustainIndex;
};
Envelope(double durationInSeconds = 20);
Envelope & operator=(const Envelope &envelope);
void save(QDataStream &stream) const;
void load(QDataStream &stream);
int getSustainIndex() const;
// reimplemented from MidiProcessor:
virtual void processNoteOn(int inputIndex, unsigned char channel, unsigned char noteNumber, unsigned char velocity, jack_nframes_t time);
virtual void processNoteOff(int inputIndex, unsigned char channel, unsigned char noteNumber, unsigned char velocity, jack_nframes_t time);
// reimplemented from AudioProcessor:
virtual void processAudio(const double *inputs, double *outputs, jack_nframes_t time);
// reimplemented from EventProcessor:
virtual bool processEvent(const RingBufferEvent *event, jack_nframes_t time);
// reimpemented from ParameterProcessor:
virtual bool setParameterValue(int index, double value, double min, double max, unsigned int time);
// reimplemented from Interpolator:
// change the behaviour when changing control points:
virtual void changeControlPoint(int index, double x, double y);
virtual void deleteControlPoint(int index);
virtual void addControlPoint(double x, double y);
protected:
virtual void controlPointsChanged();
void setSustainIndex(int sustainIndex);
private:
int sustainIndex;
double durationInSeconds;
double currentTime, previousLevel, velocity;
Phase currentPhase;
bool release;
double startLevel;
unsigned char noteNumber;
};
#endif // ENVELOPE_H