[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdenonbeta/amarok/amarok
From: Mark Kretschmann <markey () web ! de>
Date: 2003-10-31 20:08:20
[Download RAW message or body]
CVS commit by markey:
fix analyzer interpolation
M +13 -5 viswidget.cpp 1.9
--- kdenonbeta/amarok/amarok/viswidget.cpp #1.8:1.9
@@ -176,15 +176,23 @@ std::vector<float>* VisWidget::interpola
double pos = 0.0;
- double step = (double) oldVec->size() / newSize;
+ double step = static_cast<double>( oldVec->size() ) / newSize;
for ( int i = 0; i < newSize; i++ )
{
double error = pos - floor( pos );
- unsigned long offset = (unsigned long) pos;
+ unsigned long offset = static_cast<unsigned long>( pos );
- if ( offset >= oldVec->size() - 2 )
- offset = oldVec->size() - 2;
+ unsigned long indexLeft = offset + 0;
- newVec->at( i ) = oldVec->at( offset + 0 ) * ( 1.0 - error ) + oldVec->at( offset + 1 ) * error;
+ if ( indexLeft > oldVec->size() - 1 )
+ indexLeft = oldVec->size() - 1;
+
+ unsigned long indexRight = offset + 1;
+
+ if ( indexRight > oldVec->size() - 1 )
+ indexRight = oldVec->size() - 1;
+
+ newVec->at( i ) = oldVec->at( indexLeft ) * ( 1.0 - error ) +
+ oldVec->at( indexRight ) * error;
pos += step;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic