c++ - Converting 1-d array to 2-d array with overlapping -


i need convert 1 dimensional array of size n 2 dimensional array of size a*b > n. let take such case:

int onedimensionalarray[6] = {7, 8, 10, 11, 12, 15}; //then second array int twodimensionalarray[2][4] = {{7, 8, 10, 11},                                  {10, 11, 12, 15}}; 

this used in called overlap-add method used in digital sound processing. have tried approach gives improper results:

   for(unsigned long = 0; < amountofwindows; i++)    {        for(unsigned long j = hopsize; j < windowlength; j++)        {            //buffer without overlapping            if( (i * amountofwindows + j) >= bufferlength)                break;             windowedbuffer[i][j] = unwindowedbuffer[i * amountofwindows + j];        }    }     for(unsigned long = 1; < amountofwindows; i++ )    {        for(unsigned long j = 0; j < hopsize; j++)        {            // filling overlapping region            windowedbuffer[i][j] = windowedbuffer[i-1][windowlength - hopsize + i];        }    } 

i've tried finding relation using modulo operation can't find right one. 1 i've tried:

windowedbuffer[m][n % (windowlength - hopsize)] = unwindowedbuffer[n]; 

since know hopsize (from comment), want simply:

for (size_t = 0; < amountofwindows; ++i) {     (size_t j = 0; j < windowlength; ++j) {         windowedbuffer[i][j] = unwindowedbuffer[i * hopsize + j];     } } 

where amountofwindows, windowlength , hopsize parameters (resp. 2, 4 , 2 in example).


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -