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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
/**********************************************************************
Audacity: A Digital Audio Editor
Envelope.h
Dominic Mazzoni
This class manages an envelope - i.e. a piecewise linear funtion
that the user can edit by dragging control points around. The
envelope is most commonly used to control the amplitude of a
waveform, but it is also used to shape a general FFT filter.
**********************************************************************/
#ifndef __AUDACITY_ENVELOPE__
#define __AUDACITY_ENVELOPE__
#include <wx/dynarray.h>
#include <wx/event.h>
#include <wx/textfile.h>
class DirManager;
struct EnvPoint {
double t;
double val;
};
WX_DEFINE_ARRAY(EnvPoint *, EnvArray);
class Envelope {
public:
Envelope();
virtual ~ Envelope();
void Flatten(double value);
void Mirror(bool mirror);
void CopyFrom(Envelope * e);
// File I/O
virtual bool Load(wxTextFile * in, DirManager * dirManager);
virtual bool Save(wxTextFile * out, bool overwrite);
// Event Handlers
void Draw(wxDC & dc, wxRect & r, double h, double pps, bool dB);
// Returns true if parents needs to be redrawn
bool MouseEvent(wxMouseEvent & event, wxRect & r,
double h, double pps, bool dB);
// Handling Cut/Copy/Paste events
void CollapseRegion(double t0, double t1);
void ExpandRegion(double t0, double deltat);
// Control
void SetOffset(double newOffset);
void SetTrackLen(double trackLen);
// Accessors
double GetValue(double t);
// This is much faster than calling GetValue() multiple times
// if you need more than one value in a row.
void GetValues(double *buffer, int len, double t0, double tstep);
bool IsDirty();
private:
bool mMirror;
int Insert(double when, double value);
double fromDB(double x);
double toDB(double x);
EnvArray mEnv;
double mOffset;
double mTrackLen;
int mDragPoint;
int mInitialX;
int mInitialY;
double mInitialWhen;
double mInitialVal;
bool mUpper;
bool mIsDeleting;
bool mDirty;
};
#endif
|