Mercurial > hg > easaier-soundaccess
changeset 111:9cd248a25b74
correct partially the bug of the parameter settings
author | lbajardsilogic |
---|---|
date | Mon, 17 Sep 2007 16:19:27 +0000 |
parents | 71e5f393b727 |
children | 1c638a8e9897 |
files | sv/filter/TimeStretchFilter.cpp sv/filter/TimeStretchFilter.h |
diffstat | 2 files changed, 28 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/sv/filter/TimeStretchFilter.cpp Mon Sep 17 08:07:23 2007 +0000 +++ b/sv/filter/TimeStretchFilter.cpp Mon Sep 17 16:19:27 2007 +0000 @@ -57,11 +57,13 @@ m_peakcheck(false), m_framesize(4096), m_interpfactor(1), - m_transhold(0) + m_transhold(0), + m_tmaxfactor(2), + m_pmaxfactor(2) { m_hop = m_framesize/4; - m_inputBuffer = (float *)calloc(m_framesize*3, sizeof(float)); + m_inputBuffer = (float *)calloc(m_framesize*(m_pmaxfactor+1), sizeof(float)); /**********malloc***********/ FFTframe=(float *)calloc((m_framesize), sizeof(float)); @@ -163,12 +165,24 @@ if (min) *min = -100; if (max) *max = 100; if (deflt) *deflt = 0; + if (hopfactor > 1) + val = (hopfactor-1)/(m_tmaxfactor-1)*100.0; + else if (hopfactor < 1) + val = (1/hopfactor - 1)*(1-m_tmaxfactor)*100.0; + else if (hopfactor == 1) + val = 0; } if (name == "Pitch") { if (min) *min = -100; if (max) *max = 100; if (deflt) *deflt = 0; + if (m_interpfactor > 1) + val = (m_interpfactor-1)/(m_pmaxfactor-1)*100.0; + else if (m_interpfactor < 1) + val = (1/m_interpfactor - 1)*(1-m_pmaxfactor)*100.0; + else if (m_interpfactor == 1) + val = 0; } if (name == "Bypass") { @@ -185,7 +199,9 @@ if (deflt) *deflt = 0; val = (m_peakcheck ? 1 : 0); } - +#ifdef DEBUG_FILTERS + std::cerr << "TimeStretchFilter::getPropertyRangeAndValue = " << val << std::endl; +#endif return val; } @@ -204,23 +220,21 @@ void TimeStretchFilter::setProperty(const PropertyName &name, int value) { if (name == "Time") { - float tmaxfactor=2; if (value > 0){ - hopfactor=1.0+((tmaxfactor-1)*(((float)value)/100)); + hopfactor=1.0+((m_tmaxfactor-1)*(((float)value)/100.0)); } if (value < 0){ - hopfactor=1.0/(1.0+((tmaxfactor-1)*(-((float)value)/100))); + hopfactor=1.0/(1.0+((m_tmaxfactor-1)*(-((float)value)/100.0))); } if(value == 0){ hopfactor=1; } } else if (name == "Pitch") { - float pmaxfactor=2; if (value > 0){ - m_interpfactor=1.0+((pmaxfactor-1)*(((float)value)/100)); + m_interpfactor=1.0+((m_pmaxfactor-1)*(((float)value)/100.0)); } if (value < 0){ - m_interpfactor=1.0/(1.0+((pmaxfactor-1)*(-((float)value)/100))); + m_interpfactor=1.0/(1.0+((m_pmaxfactor-1)*(-((float)value)/100.0))); } if(value == 0){ m_interpfactor=1; @@ -253,7 +267,7 @@ int currentposition = m_hop; - if ( samples < floor(m_framesize*(m_interpfactor + 1)) ) + if ( samples < ( (size_t) floor(m_framesize*(m_interpfactor + 1)) ) ) return; int channel = getSourceChannelCount(); @@ -386,7 +400,7 @@ size_t TimeStretchFilter::getRequiredInputSamples(size_t outputSamplesNeeded) { - size_t need = floor(m_framesize*(m_interpfactor + 1)); + size_t need = (size_t) (floor(m_framesize*(m_interpfactor + 1))); return need; }