comparison NNLSChroma.cpp @ 122:21181297da99 monophonicness

replacing unsigned/size_t iterators by int and casting others to int
author matthiasm
date Fri, 15 Apr 2011 11:31:37 +0000
parents 7a8956e903e1
children 00868d67c0ae
comparison
equal deleted inserted replaced
121:072327bbb1a2 122:21181297da99
307 floatShift = m_localTuning[count] * 3 - intShift; // floatShift is a really bad name for this 307 floatShift = m_localTuning[count] * 3 - intShift; // floatShift is a really bad name for this
308 } 308 }
309 309
310 // cerr << intShift << " " << floatShift << endl; 310 // cerr << intShift << " " << floatShift << endl;
311 311
312 for (unsigned k = 2; k < f1.values.size() - 3; ++k) { // interpolate all inner bins 312 for (int k = 2; k < (int)f1.values.size() - 3; ++k) { // interpolate all inner bins
313 tempValue = f1.values[k + intShift] * (1-floatShift) + f1.values[k+intShift+1] * floatShift; 313 tempValue = f1.values[k + intShift] * (1-floatShift) + f1.values[k+intShift+1] * floatShift;
314 f2.values.push_back(tempValue); 314 f2.values.push_back(tempValue);
315 } 315 }
316 316
317 f2.values.push_back(0.0); f2.values.push_back(0.0); f2.values.push_back(0.0); // upper edge 317 f2.values.push_back(0.0); f2.values.push_back(0.0); f2.values.push_back(0.0); // upper edge
399 // here's where the non-negative least squares algorithm calculates the note activation x 399 // here's where the non-negative least squares algorithm calculates the note activation x
400 400
401 vector<float> chroma = vector<float>(12, 0); 401 vector<float> chroma = vector<float>(12, 0);
402 vector<float> basschroma = vector<float>(12, 0); 402 vector<float> basschroma = vector<float>(12, 0);
403 float currval; 403 float currval;
404 unsigned iSemitone = 0; 404 int iSemitone = 0;
405 405
406 if (some_b_greater_zero) { 406 if (some_b_greater_zero) {
407 if (m_useNNLS == 0) { 407 if (m_useNNLS == 0) {
408 for (unsigned iNote = nBPS/2 + 2; iNote < nNote - nBPS/2; iNote += nBPS) { 408 for (int iNote = nBPS/2 + 2; iNote < nNote - nBPS/2; iNote += nBPS) {
409 currval = 0; 409 currval = 0;
410 for (int iBPS = -nBPS/2; iBPS < nBPS/2+1; ++iBPS) { 410 for (int iBPS = -nBPS/2; iBPS < nBPS/2+1; ++iBPS) {
411 currval += b[iNote + iBPS] * (1-abs(iBPS*1.0/(nBPS/2+1))); 411 currval += b[iNote + iBPS] * (1-abs(iBPS*1.0/(nBPS/2+1)));
412 } 412 }
413 f3.values.push_back(currval); 413 f3.values.push_back(currval);
420 float x[84+1000]; 420 float x[84+1000];
421 for (int i = 1; i < 1084; ++i) x[i] = 1.0; 421 for (int i = 1; i < 1084; ++i) x[i] = 1.0;
422 vector<int> signifIndex; 422 vector<int> signifIndex;
423 int index=0; 423 int index=0;
424 sumb /= 84.0; 424 sumb /= 84.0;
425 for (unsigned iNote = nBPS/2 + 2; iNote < nNote - nBPS/2; iNote += nBPS) { 425 for (int iNote = nBPS/2 + 2; iNote < nNote - nBPS/2; iNote += nBPS) {
426 float currval = 0; 426 float currval = 0;
427 for (int iBPS = -nBPS/2; iBPS < nBPS/2+1; ++iBPS) { 427 for (int iBPS = -nBPS/2; iBPS < nBPS/2+1; ++iBPS) {
428 currval += b[iNote + iBPS]; 428 currval += b[iNote + iBPS];
429 } 429 }
430 if (currval > 0) signifIndex.push_back(index); 430 if (currval > 0) signifIndex.push_back(index);
538 } 538 }
539 chromanorm[2] = sqrt(chromanorm[2]); 539 chromanorm[2] = sqrt(chromanorm[2]);
540 break; 540 break;
541 } 541 }
542 if (chromanorm[0] > 0) { 542 if (chromanorm[0] > 0) {
543 for (size_t i = 0; i < f4.values.size(); i++) { 543 for (int i = 0; i < (int)f4.values.size(); i++) {
544 f4.values[i] /= chromanorm[0]; 544 f4.values[i] /= chromanorm[0];
545 } 545 }
546 } 546 }
547 if (chromanorm[1] > 0) { 547 if (chromanorm[1] > 0) {
548 for (size_t i = 0; i < f5.values.size(); i++) { 548 for (int i = 0; i < (int)f5.values.size(); i++) {
549 f5.values[i] /= chromanorm[1]; 549 f5.values[i] /= chromanorm[1];
550 } 550 }
551 } 551 }
552 if (chromanorm[2] > 0) { 552 if (chromanorm[2] > 0) {
553 for (size_t i = 0; i < f6.values.size(); i++) { 553 for (int i = 0; i < (int)f6.values.size(); i++) {
554 f6.values[i] /= chromanorm[2]; 554 f6.values[i] /= chromanorm[2];
555 } 555 }
556 } 556 }
557 } 557 }
558 558