From a988086ec66decd58c3d795fe41673e064a6300f Mon Sep 17 00:00:00 2001 From: xenakios Date: Fri, 23 Feb 2018 21:01:39 +0200 Subject: [PATCH] Whoops, almost forgot the smoothed play range stuff for multiple channels --- Source/PS_Source/Input/AInputS.h | 84 ++++++++++++++++---------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/Source/PS_Source/Input/AInputS.h b/Source/PS_Source/Input/AInputS.h index 8eaeec4..ec60a0b 100644 --- a/Source/PS_Source/Input/AInputS.h +++ b/Source/PS_Source/Input/AInputS.h @@ -171,52 +171,51 @@ public: readinc = -1; for (int i = 0; i < nsmps; ++i) { - + float seekfadegain = 1.0f; + if (m_seekfade.state == 1) + { + //Logger::writeToLog("Seek requested to pos " + String(m_seekfade.requestedpos)); + m_seekfade.state = 2; + } + if (m_seekfade.state == 2) + { + seekfadegain = 1.0 - (1.0 / m_seekfade.length*m_seekfade.counter); + ++m_seekfade.counter; + if (m_seekfade.counter >= m_seekfade.length) + { + //Logger::writeToLog("Doing seek " + String(m_seekfade.requestedpos)); + m_seekfade.counter = 0; + m_seekfade.state = 3; + if (m_seekfade.requestedrange.isEmpty() == false) + { + setActiveRangeImpl(m_seekfade.requestedrange); + updatesamplepositions(); + if (m_activerange.contains(getCurrentPositionPercent()) == false) + seekImpl(m_activerange.getStart()); + } + + } + } + if (m_seekfade.state == 3) + { + seekfadegain = 1.0 / m_seekfade.length*m_seekfade.counter; + ++m_seekfade.counter; + if (m_seekfade.counter >= m_seekfade.length) + { + //Logger::writeToLog("Seek cycle finished"); + m_seekfade.counter = 0; + m_seekfade.state = 0; + m_seekfade.requestedpos = 0.0; + m_seekfade.requestedrange = Range(); + } + } + jassert(seekfadegain >= 0.0f && seekfadegain<=1.0f); if (inchans == 1 && numchans > 0) { float sig = getCrossFadedSampleLambda(m_currentsample, 0, subsect_t0, subsect_t1, xfadelen); - if (m_seekfade.state == 1) - { - //Logger::writeToLog("Seek requested to pos " + String(m_seekfade.requestedpos)); - m_seekfade.state = 2; - } - if (m_seekfade.state == 2) - { - float seekfadegain = 1.0-(1.0 / m_seekfade.length*m_seekfade.counter); - sig *= seekfadegain; - ++m_seekfade.counter; - if (m_seekfade.counter >= m_seekfade.length) - { - //Logger::writeToLog("Doing seek " + String(m_seekfade.requestedpos)); - m_seekfade.counter = 0; - m_seekfade.state = 3; - if (m_seekfade.requestedrange.isEmpty() == false) - { - setActiveRangeImpl(m_seekfade.requestedrange); - updatesamplepositions(); - if (m_activerange.contains(getCurrentPositionPercent()) == false) - seekImpl(m_activerange.getStart()); - } - - } - } - if (m_seekfade.state == 3) - { - float seekfadegain = 1.0 / m_seekfade.length*m_seekfade.counter; - sig *= seekfadegain; - ++m_seekfade.counter; - if (m_seekfade.counter >= m_seekfade.length) - { - //Logger::writeToLog("Seek cycle finished"); - m_seekfade.counter = 0; - m_seekfade.state = 0; - m_seekfade.requestedpos = 0.0; - m_seekfade.requestedrange = Range(); - } - } for (int j = 0; j < numchans; ++j) { - smps[j][i] = sig; + smps[j][i] = sig*seekfadegain; } } else if (inchans > 1 && numchans > 1) @@ -224,7 +223,8 @@ public: for (int j = 0; j < numchans; ++j) { int inchantouse = j % inchans; - smps[j][i] = getCrossFadedSampleLambda(m_currentsample, inchantouse, subsect_t0, subsect_t1,xfadelen); + smps[j][i] = seekfadegain*getCrossFadedSampleLambda(m_currentsample, inchantouse, + subsect_t0, subsect_t1,xfadelen); } }