Possible bug in effect_freeverb.cpp in the current release of Teensyduino (1.56)

Synvox

Member
In the Audio Library of the current Teenyduino version 1.56 i may have found a bug in the code for the Freeverb object (Stereo version).

In effect_freeverb.cpp in the function definition for "AudioEffectFreeverbStereo::update()" right at the bottom there is this block of code:
Code:
		bufout = allpass1bufL[allpass1indexL];
		allpass1bufL[allpass1indexL] = outputL + (bufout >> 1);
		outputL = sat16(bufout - outputL, 1);
		if (++allpass1indexL >= sizeof(allpass1bufL)/sizeof(int16_t)) allpass1indexL = 0;

		bufout = allpass2bufL[allpass2indexL];
		allpass2bufL[allpass2indexL] = outputL + (bufout >> 1);
		outputL = sat16(bufout - outputL, 1);
		if (++allpass2indexL >= sizeof(allpass2bufL)/sizeof(int16_t)) allpass2indexL = 0;

		bufout = allpass3bufL[allpass3indexL];
		allpass3bufL[allpass3indexL] = outputL + (bufout >> 1);
		outputL = sat16(bufout - outputL, 1);
		if (++allpass3indexL >= sizeof(allpass3bufL)/sizeof(int16_t)) allpass3indexL = 0;

		bufout = allpass4bufL[allpass4indexL];
		allpass4bufL[allpass4indexL] = outputL + (bufout >> 1);
		outputL = sat16(bufout - outputL, 1);
		if (++allpass4indexL >= sizeof(allpass4bufL)/sizeof(int16_t)) allpass4indexL = 0;

		outblockL->data[i] = sat16(outputL * 30, 0);

		bufout = allpass1bufR[allpass1indexR];
		allpass1bufR[allpass1indexR] = outputR + (bufout >> 1);
		outputR = sat16(bufout - outputR, 1);
		if (++allpass1indexR >= sizeof(allpass1bufR)/sizeof(int16_t)) allpass1indexR = 0;

		bufout = allpass2bufR[allpass2indexR];
		allpass2bufR[allpass2indexR] = outputR + (bufout >> 1);
		outputR = sat16(bufout - outputR, 1);
		if (++allpass2indexR >= sizeof(allpass2bufR)/sizeof(int16_t)) allpass2indexR = 0;

		bufout = allpass3bufR[allpass3indexR];
		allpass3bufR[allpass3indexR] = outputR + (bufout >> 1);
		outputR = sat16(bufout - outputR, 1);
		if (++allpass3indexR >= sizeof(allpass3bufR)/sizeof(int16_t)) allpass3indexR = 0;

		bufout = allpass4bufR[allpass4indexR];
		allpass4bufR[allpass4indexR] = outputR + (bufout >> 1);
		outputR = sat16(bufout - outputR, 1);
		if (++allpass4indexR >= sizeof(allpass4bufR)/sizeof(int16_t)) allpass4indexR = 0;

		outblockR->data[i] = sat16(outputL * 30, 0);
The upper half of the code calculates values for outblockL (left channel) and uses the variable outputL. At the end of the upper half there is this statement for the left channel output, which is correct:
Code:
outblockL->data[i] = sat16(outputL * 30, 0);
The lower half of the code calculates values for outblockR (right channel) and uses the variable outputR. But at the end of the lower half the statement for the right channel output is incorrect:
Code:
outblockR->data[i] = sat16(outputL * 30, 0);
It also uses outputL. That is incorrect in my opinion and the statment shoud be replaced with:
Code:
outblockR->data[i] = sat16(outputR * 30, 0);
Otherwise the previous calculation of outputR is pointless.

So with the current code (bug not corrected) Stereo Freeverb produces a Mono output (outblockL and outblockR have the same data), which is probably not intended.

Thanks and best regards
Neni
 
Back
Top