author | llornkcor <llornkcor> | 2005-03-20 09:26:37 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2005-03-20 09:26:37 (UTC) |
commit | 421ee128d31c51f8530b0e37313ea0086e023237 (patch) (side-by-side diff) | |
tree | e5738e366ba3b14559361fdde87c4c8ce1a19a59 /noncore | |
parent | d5451e7abbfa3c3d14202311abccac8781736dae (diff) | |
download | opie-421ee128d31c51f8530b0e37313ea0086e023237.zip opie-421ee128d31c51f8530b0e37313ea0086e023237.tar.gz opie-421ee128d31c51f8530b0e37313ea0086e023237.tar.bz2 |
add rainbow leds
-rw-r--r-- | noncore/multimedia/opierec/vumeter.cpp | 130 | ||||
-rw-r--r-- | noncore/multimedia/opierec/vumeter.h | 8 |
2 files changed, 47 insertions, 91 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,20 +1,22 @@ +//************************************************************ +//=======-VUMeter +///// copyright : (C) 1999 by Martin Lorenz +////// email : lorenz@ch.tum.de + #include "vumeter.h" #include "qtrec.h" + +#include <qpe/config.h> #include <qtimer.h> -#include <math.h> #include <qdrawutl.h> + #include <opie2/odebug.h> using namespace Opie::Core; -//************************************************************ -//===========================================================-VUMeter - -///// copyright : (C) 1999 bY Martin Lorenz -////// email : lorenz@ch.tum.de +#include <math.h> VUMeter::VUMeter(QWidget *parent, const char *name, const int tr) : QWidget( parent, name ) { -// qDebug("Making VUMeter"); int tracks = tr; int i; @@ -23,18 +25,28 @@ VUMeter::VUMeter(QWidget *parent, const char *name, const int tr) for(i=0;i < tracks+2;i++) { peak[i] = hold[i] = 32768; -// i_peak[i]=i_hold[i]=32768; holdTime[i] = 20; } - para.onOff = true; - para.hold = 20; - para.update = 25; //timer - para.leds = 17; - para.reso = 3; - para.resoFactor = pow(2, para.reso/6.0); + readConf(); +// QColor c; +// c.setHsv( (x * 255)/w, 255, 255 );// rainbow effect +// c.setRgb( 255, 0, 255); +// p.setPen(c); + + //rainbow effect + if( colorScheme = 0 ) { for( i = 0; i < para.leds; i++) color[i] = green; color[0] = color[1] = red; color[2] = color[3] = color[4] = color[5] = yellow; + } else { + int j = para.leds - 4; + for( i = 0; i < para.leds; i++) { + int i16 = (j);// & 15; + color[i] = QColor(( 15 - i16) * 16, 255, 255, QColor::Hsv); + owarn << color[i].name() << oendl; + j--; + } + } buffer = new QPixmap(); @@ -42,25 +54,9 @@ VUMeter::VUMeter(QWidget *parent, const char *name, const int tr) vuTimer = new QTimer(this,"vu timer"); - -// vuProp= new QPopupMenu(NULL,"vu popoup"); -// vuProp->insertItem(("O&n"),this,SLOT(slotOn()),0,0 ); -// vuProp->setItemEnabled(0, FALSE); -// vuProp->insertItem(("O&ff"),this,SLOT(slotOff()), 0,1); -// vuProp->insertSeparator(); -// vuProp->insertItem(("&Properties..."),this,SLOT(slotProps()) ); - -// dia=new VUMeterDialog(¶); -// connect(dia, SIGNAL(accepted()), this, SLOT(update()) ); - // QtRec *qtrecPtr; - -// if(qtrecPtr->tab_2->isActiveWindow()) -// vuTimer->start( 50 /*para.update*/, FALSE); -// startTimer(); connect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); -// update(); } VUMeter::~VUMeter(){ -// delete vuProp; + writeConf(); } @@ -69,11 +65,7 @@ void VUMeter::update(){ vuTimer->start(para.update, FALSE); if (para.onOff) { -// vuProp->setItemEnabled(0, FALSE); -// vuProp->setItemEnabled(1, TRUE); disconnect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); connect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); } else { -// vuProp->setItemEnabled(0, TRUE); -// vuProp->setItemEnabled(1, FALSE); disconnect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); } @@ -84,7 +76,4 @@ void VUMeter::slotOn() { connect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); para.onOff=true; -// dia->updatePara(); -// vuProp->setItemEnabled(0, FALSE); -// vuProp->setItemEnabled(1, TRUE); } @@ -92,12 +81,8 @@ void VUMeter::slotOff() { disconnect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); para.onOff=false; -// dia->updatePara(); -// vuProp->setItemEnabled(0, TRUE); -// vuProp->setItemEnabled(1, FALSE); } void VUMeter::slotProps() { qDebug("VU-Dialog"); -// dia->show(); } @@ -110,6 +95,4 @@ void VUMeter::paintEvent(QPaintEvent* e) { void VUMeter::mousePressEvent(QMouseEvent* e) { Q_UNUSED(e); -// if (e->button() == RightButton) -// vuProp->popup(QCursor::pos() ); } @@ -139,8 +122,4 @@ void VUMeter::resize() { qWarning("Painting pixmap did not work!"); else { -// QColor c; - //c.setHsv( (x * 255)/w, 255, 255 );// rainbow effect - // c.setRgb( 255, 0, 255); -// p.setPen(c); painter.setPen(green); qDrawShadePanel ( &painter, 0,0, width(),height(), colorGroup(), TRUE, 2, 0); @@ -155,8 +134,6 @@ void VUMeter::resize() { painter.drawRect(ox+dx*i,oy+dy*(para.leds)-2,sx,2*dy-1); -// painter.drawRect(ox+dx*i,oy+dy*(15)+1,sx,2*dy-1); painter.setPen(black); painter.drawText(textOffset+ox+dx*i,oy+dy*(para.leds)-2,sx,2*dy,AlignCenter,str); -// painter.drawText(textOffset+ox+dx*i,oy+dy*(15),sx,2*dy,AlignCenter,str); } painter.end(); @@ -172,8 +149,5 @@ void VUMeter::timeSlot() { for(i=0;i<tracks+2;i++) { peak[i] /= para.resoFactor; -// i_peak[i] /= (int)para.resoFactor; } -//cout <<"VU "<<peak[0]<<"\n"; - } @@ -181,8 +155,4 @@ void VUMeter::paint() { int i, k; float p, h ; -// int i_p, i_h; -//draw background in resizeEvent -//cout <<x <<" "<<y <<" "<<dx<<" " <<dy <<" vumeter.paint\n"; -// qDebug("paint()\n"); QPainter painter; painter.begin(buffer); @@ -190,21 +160,15 @@ void VUMeter::paint() { for(i=0;i<tracks+2;i++) { -// i_p=i_peak[i]; i_h=i_hold[i]; p=peak[i]; h=hold[i]; if (p>=32767) p=32768; -// if (i_p>=32767) i_p=32768; if (h>=32767) h=32768; -// if (i_h>=32767) i_h=32768; for(k=para.leds+1; k>=2; k--) { c=para.leds+1-k; if (p>=32768) { //LED on -// if (i_p>=32768) { //LED on painter.setBrush(color[c]); } else { //LED off - //painter.setPen(color[c].dark(300)); painter.setBrush(color[c].dark(300)); } if (h>=32768) { //LED-Frame on -// if (i_h>=32768) { //LED-Frame on painter.setPen(color[c]); } else { //LED off @@ -213,8 +177,6 @@ void VUMeter::paint() { painter.drawRect(ox+dx*i,oy+dy*c,sx,sy); p*=para.resoFactor; h*=para.resoFactor; -// i_p*=(int)para.resoFactor; i_h*=(int)para.resoFactor; } if (--holdTime[i]<=0) hold[i]=peak[i]; -// if (--holdTime[i]<=0) i_hold[i]=i_peak[i]; } painter.end(); @@ -235,6 +197,4 @@ void VUMeter::setPeak(int a[]) { void VUMeter::setPeak(float a[]) { int i; -// owarn <<"set peak float"<< a[0]<< oendl; - for(i=0;i<tracks+2;i++) { if (a[i] > peak[i]) peak[i]= a[i]; @@ -253,14 +213,15 @@ void VUMeter::stopTimer() { void VUMeter::readConf() { -// Config config("QtRec"); -// config->setGroup("VU-Meter"); - -// para.onOff=config->readBoolEntry("OnOff", true ) ; -// para.update=config->readNumEntry("Update", 50 ); -// para.hold=config->readNumEntry("Hold", 20 ); -// para.reso=config->readNumEntry("Resolution", 3 ); -// para.leds=config->readNumEntry("LEDs", 16 ); -// para.resoFactor=pow(2,para.reso/6.0); + Config config("OpieRec"); + config.setGroup("VU-Meter"); + + para.onOff = config.readBoolEntry("OnOff", true); + para.update = config.readNumEntry("Update", 25); + para.hold = config.readNumEntry("Hold", 20); + para.reso = config.readNumEntry("Resolution", 3); + para.leds = config.readNumEntry("LEDs", 20); + para.resoFactor = pow(2, para.reso / 6.0); + colorScheme = config.readNumEntry("colorScheme", 0); // update(); // dia->updatePara(); @@ -269,12 +230,11 @@ void VUMeter::readConf() { void VUMeter::writeConf() { -// Config config("QtRec"); -// config->setGroup("VU-Meter"); - -// config->writeEntry("OnOff" ,para.onOff ); -// config->writeEntry("Update" ,para.update ); -// config->writeEntry("Hold" ,para.hold ); -// config->writeEntry("Resolution" , para.reso ); -// config->writeEntry("LEDs" , para.leds); - + Config config("OpieRec"); + config.setGroup("VU-Meter"); + + config.writeEntry("OnOff", para.onOff); + config.writeEntry("Update", para.update); + config.writeEntry("Hold", para.hold); + config.writeEntry("Resolution", para.reso); + config.writeEntry("LEDs", para.leds); } diff --git a/noncore/multimedia/opierec/vumeter.h b/noncore/multimedia/opierec/vumeter.h index e167686..435dff5 100644 --- a/noncore/multimedia/opierec/vumeter.h +++ b/noncore/multimedia/opierec/vumeter.h @@ -47,7 +47,5 @@ protected: void paint(); private: - //bool status; - int tracks; -// VUPara para; // dialogs.h + int tracks, colorScheme; float resoFactor; int x,y,sx,sy,dx,dy,ox,oy; @@ -56,9 +54,7 @@ private: int holdTime[4]; - // VUMeterDialog *dia; - QPixmap *buffer, *warning; /// ? + QPixmap *buffer, *warning; QPopupMenu *vuProp; QColor color[37]; - }; |