[c5c04b]: plugins / averagefft / module.cpp Maximize Restore History

Download this file

module.cpp    96 lines (77 with data), 2.8 kB

 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
#include <stdio.h>
#include <stdlib.h>
#include <qpushbutton.h>
#include <qkeycode.h>
#include <qcombobox.h>
#include <qtooltip.h>
#include "module.h"
#include "libkwave/String.h"
#include "libkwave/WindowFunction.h"
#include <kapp.h>
const char *version = "1.0";
const char *author = "Martin Wilz";
const char *name = "averagefft";
//**********************************************************
Dialog *getDialog(DialogOperation *operation)
{
return new AverageFFTDialog(operation->getRate(), operation->isModal());
}
//**********************************************************
AverageFFTDialog::AverageFFTDialog(int rate, bool modal)
:Dialog(modal)
{
WindowFunction w(0);
this->rate = rate;
resize (320, 200);
setCaption (i18n("Choose window type and length :"));
pointlabel = new QLabel (i18n("Length of window :"), this);
windowlength = new TimeLine (this);
windowlength->setMs (100);
windowtypebox = new QComboBox (true, this);
windowtypebox->insertStrList (w.getTypes(), w.getCount());
QToolTip::add(windowtypebox, i18n("Choose windowing function here."));
windowtypelabel = new QLabel (i18n("Window Function :"), this);
ok = new QPushButton (OK, this);
cancel = new QPushButton (CANCEL, this);
int bsize = ok->sizeHint().height();
setMinimumSize (320, bsize*8);
resize (320, bsize*3);
ok->setAccel (Key_Return);
cancel->setAccel(Key_Escape);
ok->setFocus ();
connect (ok , SIGNAL(clicked()), SLOT (accept()));
connect (cancel , SIGNAL(clicked()), SLOT (reject()));
}
//**********************************************************
const char *AverageFFTDialog::getCommand()
{
char buf[512];
deleteString (comstr);
snprintf(buf, sizeof(buf), "%f", windowlength->getMs());
comstr = catString ("averagefft (",
buf,
",",
windowtypebox->currentText(),
")");
return comstr;
}
//**********************************************************
void AverageFFTDialog::resizeEvent(QResizeEvent *)
{
int bsize = ok->sizeHint().height();
pointlabel->setGeometry (8, bsize / 2, width() / 2 - 8, bsize);
windowlength->setGeometry(width() / 2, bsize / 2, width()*3 / 10, bsize);
windowtypelabel->setGeometry(8, bsize*3 / 2 + 8, width() / 2 - 8, bsize);
windowtypebox->setGeometry(width() / 2, bsize*3 / 2 + 8,
width() / 2 - 8, bsize);
ok->setGeometry(width() / 10, height() - bsize*3 / 2,
width()*3 / 10, bsize);
cancel->setGeometry(width()*6 / 10, height() - bsize*3 / 2,
width()*3 / 10, bsize);
}
//**********************************************************
AverageFFTDialog::~AverageFFTDialog()
{
deleteString (comstr);
}
//**********************************************************