Mercurial > hg > nnls-chroma
comparison Chordino.cpp @ 81:4270f3039ab0 matthiasm-plugin
dont remember, sorry
author | Matthias Mauch <mail@matthiasmauch.net> |
---|---|
date | Mon, 15 Nov 2010 11:01:36 +0900 |
parents | 026a5c0ee2c2 |
children | e5c16976513d |
comparison
equal
deleted
inserted
replaced
80:026a5c0ee2c2 | 81:4270f3039ab0 |
---|---|
372 float currval; | 372 float currval; |
373 unsigned iSemitone = 0; | 373 unsigned iSemitone = 0; |
374 | 374 |
375 if (some_b_greater_zero) { | 375 if (some_b_greater_zero) { |
376 if (m_useNNLS == 0) { | 376 if (m_useNNLS == 0) { |
377 for (unsigned iNote = 2; iNote < nNote - 2; iNote += 3) { | 377 for (unsigned iNote = nBPS/2 + 2; iNote < nNote - nBPS/2; iNote += nBPS) { |
378 currval = 0; | 378 currval = 0; |
379 currval += b[iNote + 1 + -1] * 0.5; | 379 for (int iBPS = -nBPS/2; iBPS < nBPS/2+1; ++iBPS) { |
380 currval += b[iNote + 1 + 0] * 1.0; | 380 currval += b[iNote + iBPS] * (1-abs(iBPS*1.0/(nBPS/2+1))); |
381 currval += b[iNote + 1 + 1] * 0.5; | 381 } |
382 chroma[iSemitone % 12] += currval * treblewindow[iSemitone]; | 382 chroma[iSemitone % 12] += currval * treblewindow[iSemitone]; |
383 basschroma[iSemitone % 12] += currval * basswindow[iSemitone]; | 383 basschroma[iSemitone % 12] += currval * basswindow[iSemitone]; |
384 iSemitone++; | 384 iSemitone++; |
385 } | 385 } |
386 | 386 |
388 float x[84+1000]; | 388 float x[84+1000]; |
389 for (int i = 1; i < 1084; ++i) x[i] = 1.0; | 389 for (int i = 1; i < 1084; ++i) x[i] = 1.0; |
390 vector<int> signifIndex; | 390 vector<int> signifIndex; |
391 int index=0; | 391 int index=0; |
392 sumb /= 84.0; | 392 sumb /= 84.0; |
393 for (unsigned iNote = 2; iNote < nNote - 2; iNote += 3) { | 393 for (unsigned iNote = nBPS/2 + 2; iNote < nNote - nBPS/2; iNote += nBPS) { |
394 float currval = 0; | 394 float currval = 0; |
395 currval += b[iNote + 1 + -1]; | 395 for (int iBPS = -nBPS/2; iBPS < nBPS/2+1; ++iBPS) { |
396 currval += b[iNote + 1 + 0]; | 396 currval += b[iNote + iBPS]; |
397 currval += b[iNote + 1 + 1]; | 397 } |
398 if (currval > 0) signifIndex.push_back(index); | 398 if (currval > 0) signifIndex.push_back(index); |
399 index++; | 399 index++; |
400 } | 400 } |
401 float rnorm; | 401 float rnorm; |
402 float w[84+1000]; | 402 float w[84+1000]; |
403 float zz[84+1000]; | 403 float zz[84+1000]; |
404 int indx[84+1000]; | 404 int indx[84+1000]; |
405 int mode; | 405 int mode; |
406 int dictsize = nNote*signifIndex.size(); | 406 int dictsize = nNote*signifIndex.size(); |
407 // cerr << "dictsize is " << dictsize << "and values size" << f3.values.size()<< endl; | |
407 float *curr_dict = new float[dictsize]; | 408 float *curr_dict = new float[dictsize]; |
408 for (unsigned iNote = 0; iNote < signifIndex.size(); ++iNote) { | 409 for (unsigned iNote = 0; iNote < signifIndex.size(); ++iNote) { |
409 for (unsigned iBin = 0; iBin < nNote; iBin++) { | 410 for (unsigned iBin = 0; iBin < nNote; iBin++) { |
410 curr_dict[iNote * nNote + iBin] = 1.0 * m_dict[signifIndex[iNote] * nNote + iBin]; | 411 curr_dict[iNote * nNote + iBin] = 1.0 * m_dict[signifIndex[iNote] * nNote + iBin]; |
411 } | 412 } |