-rw-r--r-- | noncore/multimedia/opierec/vumeter.cpp | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/noncore/multimedia/opierec/vumeter.cpp b/noncore/multimedia/opierec/vumeter.cpp index 0edc806..c28dbe4 100644 --- a/noncore/multimedia/opierec/vumeter.cpp +++ b/noncore/multimedia/opierec/vumeter.cpp @@ -1,112 +1,107 @@ //************************************************************ //=======-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 <qdrawutl.h> #include <opie2/odebug.h> using namespace Opie::Core; #include <math.h> VUMeter::VUMeter(QWidget *parent, const char *name, const int tr) : QWidget( parent, name ) { int tracks = tr; int i; qWarning("initialize peakvalues"); for(i = 0; i < tracks + 2; i++) { peak[i] = hold[i] = 32768; holdTime[i] = 20; } 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 ) { + 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; + int i16 = (j); color[i] = QColor(( 15 - i16) * 16, 255, 255, QColor::Hsv); - owarn << color[i].name() << oendl; +// owarn << color[i].name() << oendl; j--; } } buffer = new QPixmap(); setBackgroundMode(NoBackground); vuTimer = new QTimer(this,"vu timer"); connect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); } VUMeter::~VUMeter(){ writeConf(); } void VUMeter::update(){ - qWarning("vumeter update"); +// qWarning("vumeter update"); vuTimer->start(para.update, FALSE); if (para.onOff) { disconnect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); connect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); } else { disconnect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); } resize(); } void VUMeter::slotOn() { connect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); para.onOff=true; } void VUMeter::slotOff() { disconnect(vuTimer, SIGNAL(timeout()), this , SLOT(timeSlot())); para.onOff=false; } void VUMeter::slotProps() { qDebug("VU-Dialog"); } void VUMeter::paintEvent(QPaintEvent* e) { Q_UNUSED(e); bitBlt(this, 0, 0, buffer); } void VUMeter::mousePressEvent(QMouseEvent* e) { Q_UNUSED(e); } void VUMeter::resizeEvent(QResizeEvent* event) { buffer->resize(event->size()); resize(); } void VUMeter::resize() { qWarning("resize VUMeter painting"); if(buffer == 0) qDebug("Dude NULL pixmap buffer!"); buffer->fill(black); x = width() - 7; y = height() - 12; @@ -177,64 +172,62 @@ void VUMeter::paint() { painter.drawRect(ox + dx * i, oy + dy * c, sx, sy); p *= para.resoFactor; h *= para.resoFactor; } if ( --holdTime[i] <= 0) hold[i] = peak[i]; } painter.end(); bitBlt(this, 0, 0, buffer); } void VUMeter::setPeak(int a[]) { int i; // qDebug("set peak int"); // cerr<<"setting peak\n"; for(i = 0; i < tracks + 2; i++) { if (a[i] > i_peak[i]) i_peak[i] = a[i]; if (a[i] > i_hold[i]) { i_hold[i] = a[i]; holdTime[i] = para.hold; } } paint(); } void VUMeter::setPeak(float a[]) { int i; for(i = 0; i < tracks + 2; i++) { if (a[i] > peak[i]) peak[i] = a[i]; if (a[i] > hold[i]) { hold[i] = a[i]; holdTime[i] = para.hold; } } paint(); } void VUMeter::startTimer() { vuTimer->start(para.update, FALSE); } void VUMeter::stopTimer() { vuTimer->stop(); } void VUMeter::readConf() { 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(); + colorScheme = config.readNumEntry("colorScheme", 1); } void VUMeter::writeConf() { 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); } |