X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fspeedquantizer.cpp;h=1098d437c38e76caf7ecb6f1afdd335ae5aaf2e5;hb=8b828fc32fd210b6e335ac6614d269aa892d4d57;hp=710e1041fb1d1f42a74dee61fe717d84394def9c;hpb=251270c97a5e5eb8630bc1662a406255dedae90e;p=r2c2.git diff --git a/source/libr2c2/speedquantizer.cpp b/source/libr2c2/speedquantizer.cpp index 710e104..1098d43 100644 --- a/source/libr2c2/speedquantizer.cpp +++ b/source/libr2c2/speedquantizer.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2011 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #include "speedquantizer.h" using namespace std; @@ -13,7 +6,8 @@ using namespace Msp; namespace R2C2 { SpeedQuantizer::SpeedQuantizer(unsigned n): - steps(n+1) + steps(n+1), + weight_limit(10) { if(n<1) throw InvalidParameterValue("Must have at leats one speed step"); @@ -30,16 +24,16 @@ float SpeedQuantizer::get_speed(unsigned i) const { if(i==0) return 0; - if(steps[i].weight) + if(steps[i].weight>=weight_limit) return steps[i].speed; unsigned low; unsigned high; for(low=i; low>0; --low) - if(steps[low].weight) + if(steps[low].weight>=weight_limit) break; for(high=i; high+1=weight_limit) break; if(steps[high].weight) @@ -69,7 +63,7 @@ unsigned SpeedQuantizer::find_speed_step(float speed) const unsigned high = 0; unsigned last = 0; for(unsigned i=0; (!high && i=weight_limit) { last = i; if(steps[i].speed>=speed)