| 328 | } |
| 329 | |
| 330 | std::string ChordDatabase::NoteNameScaleRelative(int pitch, bool useDegrees) const |
| 331 | { |
| 332 | |
| 333 | if (useDegrees) |
| 334 | { |
| 335 | int relpitch = (pitch + 12 - TheScale->ScaleRoot()) % 12; |
| 336 | |
| 337 | //const std::vector<std::string> flats = { "1^", "2^b", "2^", "3^b", "3^", "4^", "5^b", "5^", "6^b", "6^", "7^b", "7^" }; |
| 338 | //const std::vector<std::string> sharps = { "1^", "1^#", "2^", "2^#", "3^", "4^", "4^#", "5^", "5^#", "6^", "6^#", "7^" }; |
| 339 | // Choice of flats or sharps here depends strongly on context that can't really be gathered, so instead use some common options |
| 340 | const std::vector<std::string> accidentals = { "1^", "2^b", "2^", "3^b", "3^", "4^", "5^b", "5^", "5^#", "6^", "7^b", "7^" }; |
| 341 | |
| 342 | // For consistency with scale types, all scales are related to the major scale. i.e. in C minor Cb is 3^b rather than 3^. |
| 343 | return accidentals[relpitch]; |
| 344 | } |
| 345 | else |
| 346 | { |
| 347 | pitch %= 12; |
| 348 | |
| 349 | if (TheScale->GetType() == "aeolian") |
| 350 | { |
| 351 | const std::vector<int> flatScales = { 0, 2, 3, 5, 8, 10 }; // D G C F Ab Eb Bb |
| 352 | if (std::find(flatScales.begin(), flatScales.end(), TheScale->ScaleRoot()) != flatScales.end()) |
| 353 | return NoteName(pitch, true); |
| 354 | else |
| 355 | return NoteName(pitch); |
| 356 | } |
| 357 | else |
| 358 | { |
| 359 | const std::vector<int> flatScales = { 0, 1, 3, 5, 6, 8, 10 }; // C F Bb Eb Ab Gb Db (Cb not included) |
| 360 | if (std::find(flatScales.begin(), flatScales.end(), TheScale->ScaleRoot()) != flatScales.end()) |
| 361 | return NoteName(pitch, true); |
| 362 | else |
| 363 | return NoteName(pitch); |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | std::string ChordDatabase::GetChordName(std::vector<int> pitches) const |
| 369 | { |