-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
51 lines (43 loc) · 1.49 KB
/
main.cpp
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
#include <QtCore>
#include "WaveRegionFile.h"
using namespace RiffFileNamespace;
double samples2time(int samples, WaveFileInfo* info){
return ((double)samples/(double)info->sampleRate)*1000.;
}
int main(int argc, char *argv[])
{
// QCoreApplication a(argc, argv);
// argc = 2;
// argv = {"", ""};
// argv[0] = "ZH102Y220.wav";
// argv[1] = "regions.txt";
if (argc==3){
QFile file(argv[1]);
WaveRegionFile waveFile(&file);
waveFile.open(QIODevice::ReadOnly);
waveFile.read();
QFile outputfile(QString::fromLocal8Bit(argv[2]));
outputfile.open(QIODevice::WriteOnly);
QTextStream out(&outputfile);
WaveFileInfo* info = waveFile.getInfo();
RegionList* regions = waveFile.getRegions();
Region* r;
foreach(r, *regions){
int startInMSec = samples2time(r->begin, info)*10000.;
int endInMSec = samples2time(r->end , info)*10000.;
QString s1 = QString::number(startInMSec);
QString s2 = QString::number(endInMSec);`
out << s1 << " " << s2 << " " << r->name << "\n";
// QString str = durInMMs
// outputfile.write();
}
waveFile.close();
outputfile.close();
// getRootChunk
} else {
qDebug() << "there should be two paramentres: "<<
"wav file with regions and text file where to place regions info";
}
return 0;
// return a.exec();
}