Mercurial > hg > nnls-chroma
comparison chromamethods.cpp @ 112:846b552ea3b0 monophonicness
Harte syntax as option in Chordino
author | Matthias Mauch <mail@matthiasmauch.net> |
---|---|
date | Tue, 29 Mar 2011 15:12:19 +0100 |
parents | daee3c60c4f9 |
children | 526250b06fe0 |
comparison
equal
deleted
inserted
replaced
111:96cea9c05046 | 112:846b552ea3b0 |
---|---|
283 vector<string> chordnames; | 283 vector<string> chordnames; |
284 chordnames.push_back("");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0 | 284 chordnames.push_back("");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0 |
285 chordnames.push_back("");// =0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0 | 285 chordnames.push_back("");// =0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0 |
286 chordnames.push_back("m");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0 | 286 chordnames.push_back("m");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0 |
287 chordnames.push_back("m");//=0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0 | 287 chordnames.push_back("m");//=0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0 |
288 chordnames.push_back("dim7");//=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0 | 288 chordnames.push_back("hdim7");//=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0 |
289 chordnames.push_back("dim7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,1,0 | 289 chordnames.push_back("hdim7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,1,0 |
290 chordnames.push_back("6");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,1,0,0 | 290 chordnames.push_back("6");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,1,0,0 |
291 chordnames.push_back("7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0 | 291 chordnames.push_back("7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0 |
292 chordnames.push_back("maj7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1 | 292 chordnames.push_back("maj7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1 |
293 chordnames.push_back("m7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0 | 293 chordnames.push_back("m7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0 |
294 chordnames.push_back("m6");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,1,0,0 | 294 chordnames.push_back("m6");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,1,0,0 |
297 chordnames.push_back("");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,0,0 | 297 chordnames.push_back("");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,0,0 |
298 chordnames.push_back("aug");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0 | 298 chordnames.push_back("aug");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0 |
299 chordnames.push_back("");//=0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0 | 299 chordnames.push_back("");//=0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0 |
300 chordnames.push_back("");//=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0 | 300 chordnames.push_back("");//=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0 |
301 chordnames.push_back("7");//=0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0 | 301 chordnames.push_back("7");//=0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0 |
302 // from here: Harte syntax | |
303 chordnames.push_back("");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0 | |
304 chordnames.push_back("");// =0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0 | |
305 chordnames.push_back(":min");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0 | |
306 chordnames.push_back(":min");//=0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0 | |
307 chordnames.push_back(":hdim7");//=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0 | |
308 chordnames.push_back(":hdim7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,1,0 | |
309 chordnames.push_back(":maj6");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,1,0,0 | |
310 chordnames.push_back(":7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0 | |
311 chordnames.push_back(":maj7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1 | |
312 chordnames.push_back(":min7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0 | |
313 chordnames.push_back(":min6");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,1,0,0 | |
314 chordnames.push_back("");//=0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0 | |
315 chordnames.push_back("");//=0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0 | |
316 chordnames.push_back("");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,0,0 | |
317 chordnames.push_back(":aug");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0 | |
318 chordnames.push_back("");//=0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0 | |
319 chordnames.push_back("");//=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0 | |
320 chordnames.push_back(":7");//=0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0 | |
321 // TODO: what about a dim chord? | |
302 return chordnames; | 322 return chordnames; |
303 } | 323 } |
304 | 324 |
305 static vector<float> staticChordvalues() { | 325 static vector<float> staticChordvalues() { |
306 vector<float> chordvalues; | 326 vector<float> chordvalues; |
328 } | 348 } |
329 } | 349 } |
330 return chordvalues; | 350 return chordvalues; |
331 } | 351 } |
332 | 352 |
333 vector<string> chordDictionary(vector<float> *mchorddict, vector<vector<int> > *m_chordnotes, float boostN) { | 353 vector<string> chordDictionary(vector<float> *mchorddict, vector<vector<int> > *m_chordnotes, float boostN, float useHarte) { |
334 | 354 |
335 typedef tokenizer<char_separator<char> > Tok; | 355 typedef tokenizer<char_separator<char> > Tok; |
336 char_separator<char> sep(",; ","="); | 356 char_separator<char> sep(",; ","="); |
337 | 357 |
338 string chordDictBase("chord.dict"); | 358 string chordDictBase("chord.dict"); |
364 iostreams::stream<iostreams::file_source> chordDictFile(chordDictFilename); | 384 iostreams::stream<iostreams::file_source> chordDictFile(chordDictFilename); |
365 string line; | 385 string line; |
366 // int iElement = 0; | 386 // int iElement = 0; |
367 int nChord = 0; | 387 int nChord = 0; |
368 | 388 |
389 vector<float> tempChordDict = staticChordvalues(); | |
369 vector<string> tempChordNames = staticChordnames(); | 390 vector<string> tempChordNames = staticChordnames(); |
370 vector<float> tempChordDict = staticChordvalues(); | 391 if (useHarte == 1.0) { |
392 tempChordNames.erase(tempChordNames.begin(),tempChordNames.begin()+tempChordNames.size()/2); | |
393 } else { | |
394 tempChordNames.erase(tempChordNames.begin()+tempChordNames.size()/2,tempChordNames.begin()+tempChordNames.size()); | |
395 } | |
396 | |
371 vector<string> loadedChordNames; | 397 vector<string> loadedChordNames; |
372 vector<float> loadedChordDict; | 398 vector<float> loadedChordDict; |
373 if (hasExternalDictinoary && chordDictFile.is_open()) { | 399 if (hasExternalDictinoary && chordDictFile.is_open()) { |
374 cerr << "-----------------> " << tempChordNames.size() << endl; | 400 cerr << "-----------------> " << tempChordNames.size() << endl; |
375 tempChordDict.clear(); | 401 tempChordDict.clear(); |
407 vector<int> tempchordnotes; | 433 vector<int> tempchordnotes; |
408 // add bass slash notation | 434 // add bass slash notation |
409 string slashNotation = ""; | 435 string slashNotation = ""; |
410 for (int kSemitone = 1; kSemitone < 12; kSemitone++) { | 436 for (int kSemitone = 1; kSemitone < 12; kSemitone++) { |
411 if (tempChordDict[24*iType+(kSemitone) % 12] > 0.99) { | 437 if (tempChordDict[24*iType+(kSemitone) % 12] > 0.99) { |
412 slashNotation = bassnames[iSemitone][kSemitone]; | 438 if (useHarte == 0.0) { |
439 slashNotation = bassnames[iSemitone][kSemitone]; | |
440 } else { | |
441 slashNotation = bassnames[12][kSemitone]; | |
442 } | |
413 } | 443 } |
414 } | 444 } |
415 if (slashNotation=="") tempchordnotes.push_back(MIDI_basenote + (iSemitone+12) % 12); | 445 if (slashNotation=="") tempchordnotes.push_back(MIDI_basenote + (iSemitone+12) % 12); |
416 for (int kSemitone = 0; kSemitone < 12; kSemitone++) { // bass pitch classes | 446 for (int kSemitone = 0; kSemitone < 12; kSemitone++) { // bass pitch classes |
417 // cerr << ((kSemitone - iSemitone + 12) % 12) << endl; | 447 // cerr << ((kSemitone - iSemitone + 12) % 12) << endl; |