Skip to content

Commit

Permalink
* implement level decaying
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/lennart/svn/public/pavumeter/trunk@21 c62a5a7b-6fe3-0310-9d5a-afe6de46906b
  • Loading branch information
poettering committed Nov 17, 2004
1 parent 8a5f3e4 commit 8c33f68
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/vumeter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class MainWindow : public Gtk::Window {
virtual bool on_delete_event(GdkEventAny* e);
virtual bool on_display_timeout();
virtual bool on_calc_timeout();
virtual void decayLevels();

sigc::connection display_timeout_signal_connection;
sigc::connection calc_timeout_signal_connection;
Expand Down Expand Up @@ -205,9 +206,34 @@ void MainWindow::showLevels(const LevelInfo &i) {

}

#define DECAY_LEVEL (0.005)

void MainWindow::decayLevels() {
unsigned nchan = channels.size();

for (unsigned n = 0; n < nchan; n++) {
double level;

ChannelInfo *c = channels[n];

level = c->progress->get_fraction();

if (level <= 0)
continue;

level = level > DECAY_LEVEL ? level - DECAY_LEVEL : 0;
c->progress->set_fraction(level);
}
}

bool MainWindow::on_display_timeout() {
LevelInfo *i = NULL;

if (levelQueue.empty()) {
decayLevels();
return true;
}

while (levelQueue.size() > 0) {
if (i)
delete i;
Expand Down

0 comments on commit 8c33f68

Please sign in to comment.