1
我需要的大小为N的一个维数组转换为尺寸A的二维阵列* B> N。让我们采取这样的情况下:转换1-d阵列2-d阵列重叠
int oneDimensionalArray[6] = {7, 8, 10, 11, 12, 15};
//then the second array would be
int twoDimensionalArray[2][4] = {{7, 8, 10, 11},
{10, 11, 12, 15}};
这用于数字声音处理中使用的所谓叠加方法。我曾尝试这种做法赋予不当的结果:
for(unsigned long i = 0; i < amountOfWindows; i++)
{
for(unsigned long j = hopSize; j < windowLength; j++)
{
//buffer without the overlapping
if((i * amountOfWindows + j) >= bufferLength)
break;
windowedBuffer[i][j] = unwindowedBuffer[i * amountOfWindows + j];
}
}
for(unsigned long i = 1; i < amountOfWindows; i++)
{
for(unsigned long j = 0; j < hopSize; j++)
{
// Filling the overlapping region
windowedBuffer[i][j] = windowedBuffer[i-1][windowLength - hopSize + i];
}
}
我也试着寻找使用模运算的关系,但我不能找到合适的人。这是我试过的一个:
windowedBuffer[m][n % (windowLength - hopSize)] = unwindowedBuffer[n];
而'j + 2 * i'? – Jarod42
你是什么意思?那是什么2? – Kokos34
你的重叠是'2'。 – Jarod42