/
uMain.h
113 lines (98 loc) · 3.26 KB
/
uMain.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//--------------------------------------------------------------------------------------------------
#ifndef uMainH
#define uMainH
//--------------------------------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
#include <ExtCtrls.hpp>
#include <Graphics.hpp>
#include <mmsystem.h>
#include <Dialogs.hpp>
#include <ExtDlgs.hpp>
#include <ComCtrls.hpp>
#include <vector>
#include <fstream.h>
#include <vcl.h>
//--------------------------------------------------------------------------------------------------
struct TVecPoint {
double x;
double y;
};
//--------------------------------------------------------------------------------------------------
#pragma pack(push, 1)
struct TWaveHeader {
char chunkId[4];
unsigned int chunkSize;
char format[4];
char subChunk1Id[4];
unsigned int subChunk1Size;
unsigned short audioFormat;
unsigned short numChannels;
unsigned int sampleRate;
unsigned int byteRate;
unsigned short blockAlign;
unsigned short bitsPerSample;
char subChunk2Id[4];
unsigned int subChunk2Size;
};
#pragma pack(pop)
//--------------------------------------------------------------------------------------------------
using namespace std;
//--------------------------------------------------------------------------------------------------
class TfrmMain : public TForm
{
__published: // IDE-managed Components
TPanel *pnlDraw;
TPanel *pnlAxisX;
TPanel *Panel3;
TSpeedButton *SpeedButton1;
TImage *imgMain;
TImage *imgY;
TPanel *pnlAxisY;
TImage *imgX;
TOpenDialog *openDialog;
TProgressBar *progress;
TEdit *ebDuration;
TEdit *ebCycles;
TLabel *lblDone;
TSpeedButton *SpeedButton2;
TLabel *Label2;
TLabel *Label3;
TLabel *Label1;
TLabel *Label4;
TButton *Button1;
void __fastcall SpeedButton1Click(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
void __fastcall FormResize(TObject *Sender);
void __fastcall FormActivate(TObject *Sender);
void __fastcall SpeedButton2Click(TObject *Sender);
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
bool __fastcall LoadFile(AnsiString fileName);
void __fastcall DecodeLine(AnsiString line, bool relative);
void __fastcall DrawPoints(void);
void __fastcall NormalizePoints();
void __fastcall BreakAxis();
void __fastcall WriteWaveData();
void __fastcall WriteWaveFile(AnsiString fileName);
void __fastcall ProcessFile(AnsiString file);
vector <TVecPoint> points;
vector <double> axis_x;
vector <double> axis_y;
float sampleRate;
double duration;
//int cycles;
int fileLength;
//bool calculating;
public: // User declarations
__fastcall TfrmMain(TComponent* Owner);
};
//--------------------------------------------------------------------------------------------------
extern PACKAGE TfrmMain *frmMain;
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
#endif
//--------------------------------------------------------------------------------------------------