From fe2abbd4edf2a1db8b30a7983729d74bef466452 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 30 Apr 2016 20:48:09 -0400 Subject: [PATCH] Minor adjustments to ensure sampling occurs as intended. --- .../Internals/Shaders/IntermediateShader.cpp | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp b/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp index 006ca60be..51deed3e1 100644 --- a/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp +++ b/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp @@ -61,17 +61,17 @@ std::unique_ptr IntermediateShader::make_shader(const char * "iInputPositionVarying = extendedInputPosition;" "vec2 mappedInputPosition = (extendedInputPosition + vec2(0.0, 0.5)) / textureSize;" - "inputPositionsVarying[0] = mappedInputPosition - (vec2(offsets[4], 0.0) / textureSize);" - "inputPositionsVarying[1] = mappedInputPosition - (vec2(offsets[3], 0.0) / textureSize);" + "inputPositionsVarying[0] = mappedInputPosition - (vec2(offsets[0], 0.0) / textureSize);" + "inputPositionsVarying[1] = mappedInputPosition - (vec2(offsets[1], 0.0) / textureSize);" "inputPositionsVarying[2] = mappedInputPosition - (vec2(offsets[2], 0.0) / textureSize);" - "inputPositionsVarying[3] = mappedInputPosition - (vec2(offsets[1], 0.0) / textureSize);" - "inputPositionsVarying[4] = mappedInputPosition - (vec2(offsets[0], 0.0) / textureSize);" + "inputPositionsVarying[3] = mappedInputPosition - (vec2(offsets[3], 0.0) / textureSize);" + "inputPositionsVarying[4] = mappedInputPosition - (vec2(offsets[4], 0.0) / textureSize);" "inputPositionsVarying[5] = mappedInputPosition;" - "inputPositionsVarying[6] = mappedInputPosition + (vec2(offsets[0], 0.0) / textureSize);" - "inputPositionsVarying[7] = mappedInputPosition + (vec2(offsets[1], 0.0) / textureSize);" + "inputPositionsVarying[6] = mappedInputPosition + (vec2(offsets[4], 0.0) / textureSize);" + "inputPositionsVarying[7] = mappedInputPosition + (vec2(offsets[3], 0.0) / textureSize);" "inputPositionsVarying[8] = mappedInputPosition + (vec2(offsets[2], 0.0) / textureSize);" - "inputPositionsVarying[9] = mappedInputPosition + (vec2(offsets[3], 0.0) / textureSize);" - "inputPositionsVarying[10] = mappedInputPosition + (vec2(offsets[4], 0.0) / textureSize);" + "inputPositionsVarying[9] = mappedInputPosition + (vec2(offsets[1], 0.0) / textureSize);" + "inputPositionsVarying[10] = mappedInputPosition + (vec2(offsets[0], 0.0) / textureSize);" "delayLinePositionVarying = mappedInputPosition - vec2(0.0, 1.0);" "phaseAndAmplitudeVarying.x = (phaseCyclesPerTick * (extendedOutputPosition.x - phaseTime) + phaseAmplitudeAndOffset.x) * 2.0 * 3.141592654;" @@ -284,23 +284,26 @@ void IntermediateShader::set_filter_coefficients(float sampling_rate, float cuto int sample = 0; int c = 0; memset(weights, 0, sizeof(float)*12); - while(c < (taps >> 1) && sample < 5) + memset(offsets, 0, sizeof(float)*5); + + int halfSize = (taps >> 1); + while(c < halfSize && sample < 5) { + offsets[sample] = (float)(halfSize - c); if((coefficients[c] < 0.0f) == (coefficients[c+1] < 0.0f) && c+1 < (taps >> 1)) { weights[sample] = coefficients[c] + coefficients[c+1]; - offsets[sample] = (float)c + 1.0f + (coefficients[c+1] / weights[sample]); + offsets[sample] -= (coefficients[c+1] / weights[sample]); c += 2; } else { - offsets[sample] = (float)c + 1.0f; weights[sample] = coefficients[c]; c++; } sample ++; } - if(c == (taps >> 1)) + if(c == halfSize) // i.e. we finished combining inputs before we ran out of space { weights[sample] = coefficients[c]; for(int c = 0; c < sample; c++)