Diffstat (limited to 'noncore/multimedia/opierec/vumeter.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opierec/vumeter.cpp | 130 |
1 files changed, 45 insertions, 85 deletions
diff --git a/noncore/multimedia/opierec/vumeter.cpp b/noncore/multimedia/opierec/vumeter.cpp index 8bab2f2..0edc806 100644 --- a/noncore/multimedia/opierec/vumeter.cpp +++ b/noncore/multimedia/opierec/vumeter.cpp | |||
@@ -1,6 +1,13 @@ | |||
1 | //************************************************************ | ||
2 | //=======-VUMeter | ||
3 | ///// copyright : (C) 1999 by Martin Lorenz | ||
4 | ////// email : lorenz@ch.tum.de | ||
5 | |||
1 | #include "vumeter.h" | 6 | #include "vumeter.h" |
2 | #include "qtrec.h" | 7 | #include "qtrec.h" |
8 | |||
9 | #include <qpe/config.h> | ||
3 | #include <qtimer.h> | 10 | #include <qtimer.h> |
4 | #include <math.h> | ||
5 | #include <qdrawutl.h> | 11 | #include <qdrawutl.h> |
12 | |||
6 | #include <opie2/odebug.h> | 13 | #include <opie2/odebug.h> |
@@ -8,7 +15,3 @@ using namespace Opie::Core; | |||
8 | 15 | ||
9 | //************************************************************ | 16 | #include <math.h> |
10 | //===========================================================-VUMeter | ||
11 | |||
12 | ///// copyright : (C) 1999 bY Martin Lorenz | ||
13 | ////// email : lorenz@ch.tum.de | ||
14 | 17 | ||
@@ -17,3 +20,2 @@ VUMeter::VUMeter(QWidget *parent, const char *name, const int tr) | |||
17 | { | 20 | { |
18 | // qDebug("Making VUMeter"); | ||
19 | int tracks = tr; | 21 | int tracks = tr; |
@@ -24,3 +26,2 @@ VUMeter::VUMeter(QWidget *parent, const char *name, const int tr) | |||
24 | peak[i] = hold[i] = 32768; | 26 | peak[i] = hold[i] = 32768; |
25 | // i_peak[i]=i_hold[i]=32768; | ||
26 | holdTime[i] = 20; | 27 | holdTime[i] = 20; |
@@ -28,9 +29,11 @@ VUMeter::VUMeter(QWidget *parent, const char *name, const int tr) | |||
28 | 29 | ||
29 | para.onOff = true; | 30 | readConf(); |
30 | para.hold = 20; | ||
31 | para.update = 25; //timer | ||
32 | para.leds = 17; | ||
33 | para.reso = 3; | ||
34 | para.resoFactor = pow(2, para.reso/6.0); | ||
35 | 31 | ||
32 | // QColor c; | ||
33 | // c.setHsv( (x * 255)/w, 255, 255 );// rainbow effect | ||
34 | // c.setRgb( 255, 0, 255); | ||
35 | // p.setPen(c); | ||
36 | |||
37 | //rainbow effect | ||
38 | if( colorScheme = 0 ) { | ||
36 | for( i = 0; i < para.leds; i++) color[i] = green; | 39 | for( i = 0; i < para.leds; i++) color[i] = green; |
@@ -38,2 +41,11 @@ VUMeter::VUMeter(QWidget *parent, const char *name, const int tr) | |||
38 | color[2] = color[3] = color[4] = color[5] = yellow; | 41 | color[2] = color[3] = color[4] = color[5] = yellow; |
42 | } else { | ||
43 | int j = para.leds - 4; | ||
44 | for( i = 0; i < para.leds; i++) { | ||
45 | int i16 = (j);// & 15; | ||
46 | color[i] = QColor(( 15 - i16) * 16, 255, 255, QColor::Hsv); | ||
47 | owarn << color[i].name() << oendl; | ||
48 | j--; | ||
49 | } | ||
50 | } | ||
39 | 51 | ||
@@ -43,19 +55,3 @@ VUMeter::VUMeter(QWidget *parent, const char *name, const int tr) | |||
43 | 55 | ||
44 | |||
45 | // vuProp= new QPopupMenu(NULL,"vu popoup"); | ||
46 | // vuProp->insertItem(("O&n"),this,SLOT(slotOn()),0,0 ); | ||
47 | // vuProp->setItemEnabled(0, FALSE); | ||
48 | // vuProp->insertItem(("O&ff"),this,SLOT(slotOff()), 0,1); | ||
49 | // vuProp->insertSeparator(); | ||
50 | // vuProp->insertItem(("&Properties..."),this,SLOT(slotProps()) ); | ||
51 | |||
52 | // dia=new VUMeterDialog(¶); | ||
53 | // connect(dia, SIGNAL(accepted()), this, SLOT(update()) ); | ||
54 | // QtRec *qtrecPtr; | ||
55 | |||
56 | // if(qtrecPtr->tab_2->isActiveWindow()) | ||
57 | // vuTimer->start( 50 /*para.update*/, FALSE); | ||
58 | // startTimer(); | ||
59 | connect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); | 56 | connect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); |
60 | //update(); | ||
61 | } | 57 | } |
@@ -63,3 +59,3 @@ VUMeter::VUMeter(QWidget *parent, const char *name, const int tr) | |||
63 | VUMeter::~VUMeter(){ | 59 | VUMeter::~VUMeter(){ |
64 | // delete vuProp; | 60 | writeConf(); |
65 | } | 61 | } |
@@ -70,4 +66,2 @@ void VUMeter::update(){ | |||
70 | if (para.onOff) { | 66 | if (para.onOff) { |
71 | // vuProp->setItemEnabled(0, FALSE); | ||
72 | // vuProp->setItemEnabled(1, TRUE); | ||
73 | disconnect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); | 67 | disconnect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); |
@@ -75,4 +69,2 @@ void VUMeter::update(){ | |||
75 | } else { | 69 | } else { |
76 | // vuProp->setItemEnabled(0, TRUE); | ||
77 | // vuProp->setItemEnabled(1, FALSE); | ||
78 | disconnect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); | 70 | disconnect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); |
@@ -85,5 +77,2 @@ void VUMeter::slotOn() { | |||
85 | para.onOff=true; | 77 | para.onOff=true; |
86 | // dia->updatePara(); | ||
87 | // vuProp->setItemEnabled(0, FALSE); | ||
88 | // vuProp->setItemEnabled(1, TRUE); | ||
89 | } | 78 | } |
@@ -93,5 +82,2 @@ void VUMeter::slotOff() { | |||
93 | para.onOff=false; | 82 | para.onOff=false; |
94 | // dia->updatePara(); | ||
95 | // vuProp->setItemEnabled(0, TRUE); | ||
96 | // vuProp->setItemEnabled(1, FALSE); | ||
97 | } | 83 | } |
@@ -100,3 +86,2 @@ void VUMeter::slotProps() { | |||
100 | qDebug("VU-Dialog"); | 86 | qDebug("VU-Dialog"); |
101 | // dia->show(); | ||
102 | } | 87 | } |
@@ -111,4 +96,2 @@ void VUMeter::mousePressEvent(QMouseEvent* e) { | |||
111 | Q_UNUSED(e); | 96 | Q_UNUSED(e); |
112 | // if (e->button() == RightButton) | ||
113 | // vuProp->popup(QCursor::pos() ); | ||
114 | } | 97 | } |
@@ -140,6 +123,2 @@ void VUMeter::resize() { | |||
140 | else { | 123 | else { |
141 | // QColor c; | ||
142 | //c.setHsv( (x * 255)/w, 255, 255 );// rainbow effect | ||
143 | // c.setRgb( 255, 0, 255); | ||
144 | // p.setPen(c); | ||
145 | painter.setPen(green); | 124 | painter.setPen(green); |
@@ -156,6 +135,4 @@ void VUMeter::resize() { | |||
156 | painter.drawRect(ox+dx*i,oy+dy*(para.leds)-2,sx,2*dy-1); | 135 | painter.drawRect(ox+dx*i,oy+dy*(para.leds)-2,sx,2*dy-1); |
157 | // painter.drawRect(ox+dx*i,oy+dy*(15)+1,sx,2*dy-1); | ||
158 | painter.setPen(black); | 136 | painter.setPen(black); |
159 | painter.drawText(textOffset+ox+dx*i,oy+dy*(para.leds)-2,sx,2*dy,AlignCenter,str); | 137 | painter.drawText(textOffset+ox+dx*i,oy+dy*(para.leds)-2,sx,2*dy,AlignCenter,str); |
160 | // painter.drawText(textOffset+ox+dx*i,oy+dy*(15),sx,2*dy,AlignCenter,str); | ||
161 | } | 138 | } |
@@ -173,6 +150,3 @@ void VUMeter::timeSlot() { | |||
173 | peak[i] /= para.resoFactor; | 150 | peak[i] /= para.resoFactor; |
174 | // i_peak[i] /= (int)para.resoFactor; | ||
175 | } | 151 | } |
176 | //cout <<"VU "<<peak[0]<<"\n"; | ||
177 | |||
178 | } | 152 | } |
@@ -182,6 +156,2 @@ void VUMeter::paint() { | |||
182 | float p, h ; | 156 | float p, h ; |
183 | //int i_p, i_h; | ||
184 | //draw background in resizeEvent | ||
185 | //cout <<x <<" "<<y <<" "<<dx<<" " <<dy <<" vumeter.paint\n"; | ||
186 | // qDebug("paint()\n"); | ||
187 | QPainter painter; | 157 | QPainter painter; |
@@ -191,8 +161,5 @@ void VUMeter::paint() { | |||
191 | for(i=0;i<tracks+2;i++){ | 161 | for(i=0;i<tracks+2;i++){ |
192 | // i_p=i_peak[i]; i_h=i_hold[i]; | ||
193 | p=peak[i]; h=hold[i]; | 162 | p=peak[i]; h=hold[i]; |
194 | if (p>=32767) p=32768; | 163 | if (p>=32767) p=32768; |
195 | // if (i_p>=32767) i_p=32768; | ||
196 | if (h>=32767) h=32768; | 164 | if (h>=32767) h=32768; |
197 | // if (i_h>=32767) i_h=32768; | ||
198 | for(k=para.leds+1; k>=2; k--){ | 165 | for(k=para.leds+1; k>=2; k--){ |
@@ -200,6 +167,4 @@ void VUMeter::paint() { | |||
200 | if (p>=32768) { //LED on | 167 | if (p>=32768) { //LED on |
201 | // if (i_p>=32768){ //LED on | ||
202 | painter.setBrush(color[c]); | 168 | painter.setBrush(color[c]); |
203 | } else { //LED off | 169 | } else { //LED off |
204 | //painter.setPen(color[c].dark(300)); | ||
205 | painter.setBrush(color[c].dark(300)); | 170 | painter.setBrush(color[c].dark(300)); |
@@ -207,3 +172,2 @@ void VUMeter::paint() { | |||
207 | if (h>=32768) { //LED-Frame on | 172 | if (h>=32768) { //LED-Frame on |
208 | // if (i_h>=32768){ //LED-Frame on | ||
209 | painter.setPen(color[c]); | 173 | painter.setPen(color[c]); |
@@ -214,6 +178,4 @@ void VUMeter::paint() { | |||
214 | p*=para.resoFactor; h*=para.resoFactor; | 178 | p*=para.resoFactor; h*=para.resoFactor; |
215 | // i_p*=(int)para.resoFactor; i_h*=(int)para.resoFactor; | ||
216 | } | 179 | } |
217 | if (--holdTime[i]<=0) hold[i]=peak[i]; | 180 | if (--holdTime[i]<=0) hold[i]=peak[i]; |
218 | // if (--holdTime[i]<=0) i_hold[i]=i_peak[i]; | ||
219 | } | 181 | } |
@@ -236,4 +198,2 @@ void VUMeter::setPeak(float a[]) { | |||
236 | int i; | 198 | int i; |
237 | //owarn <<"set peak float"<< a[0]<< oendl; | ||
238 | |||
239 | for(i=0;i<tracks+2;i++) { | 199 | for(i=0;i<tracks+2;i++) { |
@@ -254,12 +214,13 @@ void VUMeter::stopTimer() { | |||
254 | void VUMeter::readConf() { | 214 | void VUMeter::readConf() { |
255 | // Config config("QtRec"); | 215 | Config config("OpieRec"); |
256 | // config->setGroup("VU-Meter"); | 216 | config.setGroup("VU-Meter"); |
257 | 217 | ||
258 | // para.onOff=config->readBoolEntry("OnOff", true ) ; | 218 | para.onOff = config.readBoolEntry("OnOff", true); |
259 | // para.update=config->readNumEntry("Update", 50 ); | 219 | para.update = config.readNumEntry("Update", 25); |
260 | // para.hold=config->readNumEntry("Hold", 20 ); | 220 | para.hold = config.readNumEntry("Hold", 20); |
261 | // para.reso=config->readNumEntry("Resolution", 3 ); | 221 | para.reso = config.readNumEntry("Resolution", 3); |
262 | // para.leds=config->readNumEntry("LEDs", 16 ); | 222 | para.leds = config.readNumEntry("LEDs", 20); |
263 | // para.resoFactor=pow(2,para.reso/6.0); | 223 | para.resoFactor = pow(2, para.reso / 6.0); |
264 | 224 | ||
225 | colorScheme = config.readNumEntry("colorScheme", 0); | ||
265 | // update(); | 226 | // update(); |
@@ -270,11 +231,10 @@ void VUMeter::readConf() { | |||
270 | void VUMeter::writeConf() { | 231 | void VUMeter::writeConf() { |
271 | // Config config("QtRec"); | 232 | Config config("OpieRec"); |
272 | // config->setGroup("VU-Meter"); | 233 | config.setGroup("VU-Meter"); |
273 | 234 | ||
274 | // config->writeEntry("OnOff" ,para.onOff ); | 235 | config.writeEntry("OnOff", para.onOff); |
275 | // config->writeEntry("Update" ,para.update ); | 236 | config.writeEntry("Update", para.update); |
276 | // config->writeEntry("Hold" ,para.hold ); | 237 | config.writeEntry("Hold", para.hold); |
277 | // config->writeEntry("Resolution" , para.reso ); | 238 | config.writeEntry("Resolution", para.reso); |
278 | // config->writeEntry("LEDs" , para.leds); | 239 | config.writeEntry("LEDs", para.leds); |
279 | |||
280 | } | 240 | } |