Ok I started writing some code, but i ran into another problem. I read and understood the text, but I am not quiet sure, which formulas to translate to code. Obviously I have to take the ones on the bottom of the page, because i have signed values. But which one? Would it be like this:
const sf::Int16* SamplesOne = BufferOne.GetSamples();
int n = BufferOne.GetSamplesCount();
const sf::Int16* SamplesTwo = BufferTwo.GetSamples();
if(n < BufferTwo.GetSamplesCount())
{
n = BufferTwo.GetSamplesCount();
}
sf::Int16* FinalSamples;
for(int i = 0; i < n; i++)
{
if(SamplesOne[i] < 0 && SamplesTwo[i] < 0)
{
FinalSamples[i] = 2 * SamplesOne[i] * SamplesTwo[i];
}
else
{
FinalSamples[i] = 2 * (SamplesOne[i] + SamplesTwo[i]) - 2 * SamplesOne[i] * SamplesTwo[i] - 1;
}
}
Or like this:
for(int i = 0; i < n; i++)
{
if(SamplesOne[i] < 0 && SamplesTwo[i] < 0)
{
FinalSamples[i] = (SamplesOne[i] * SamplesTwo[i]) / 128;
}
else
{
FinalSamples[i] = 2 * (SamplesOne[i] + SamplesTwo[i]) - (SamplesOne[i] * SamplesTwo[i]) / 128 - 256;
}
}
Or is it something completely different, because it says that the range is between 0 and 1 for the first and 0 and 255 for the second, but my range is actually between -32767 and 32767. But I am not sure about how to do it, because of the negative numbers.
Thanks again.
Foaly