| 1 |
/* |
| 2 |
* Copyright (C) 2020-2021 Rerrah |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person |
| 5 |
* obtaining a copy of this software and associated documentation |
| 6 |
* files (the "Software"), to deal in the Software without |
| 7 |
* restriction, including without limitation the rights to use, |
| 8 |
* copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 |
* copies of the Software, and to permit persons to whom the |
| 10 |
* Software is furnished to do so, subject to the following |
| 11 |
* conditions: |
| 12 |
* |
| 13 |
* The above copyright notice and this permission notice shall be |
| 14 |
* included in all copies or substantial portions of the Software. |
| 15 |
* |
| 16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 17 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
| 18 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 19 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 20 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 21 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 22 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 23 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 24 |
*/ |
| 25 |
|
| 26 |
#include "gui_utils.hpp" |
| 27 |
#include <algorithm> |
| 28 |
#include "song.hpp" |
| 29 |
|
| 30 |
namespace gui_utils |
| 31 |
{ |
| 32 |
QString getTrackName(SongType songType, SoundSource src, int chInSrc) |
| 33 |
{ |
| 34 |
QString name; |
| 35 |
switch (src) { |
| 36 |
case SoundSource::FM: |
| 37 |
switch (songType) { |
| 38 |
case SongType::Standard: |
| 39 |
name = "FM" + QString::number(chInSrc + 1); |
| 40 |
break; |
| 41 |
case SongType::FM3chExpanded: |
| 42 |
switch (chInSrc) { |
| 43 |
case 2: |
| 44 |
name = "FM3-OP1"; |
| 45 |
break; |
| 46 |
case 6: |
| 47 |
name = "FM3-OP2"; |
| 48 |
break; |
| 49 |
case 7: |
| 50 |
name = "FM3-OP3"; |
| 51 |
break; |
| 52 |
case 8: |
| 53 |
name = "FM3-OP4"; |
| 54 |
break; |
| 55 |
default: |
| 56 |
name = "FM" + QString::number(chInSrc + 1); |
| 57 |
break; |
| 58 |
} |
| 59 |
break; |
| 60 |
} |
| 61 |
break; |
| 62 |
case SoundSource::SSG: |
| 63 |
name = "SSG" + QString::number(chInSrc + 1); |
| 64 |
break; |
| 65 |
case SoundSource::RHYTHM: |
| 66 |
switch (chInSrc) { |
| 67 |
case 0: name = "Bass drum"; break; |
| 68 |
case 1: name = "Snare drum"; break; |
| 69 |
case 2: name = "Top cymbal"; break; |
| 70 |
case 3: name = "Hi-hat"; break; |
| 71 |
case 4: name = "Tom"; break; |
| 72 |
case 5: name = "Rim shot"; break; |
| 73 |
} |
| 74 |
break; |
| 75 |
case SoundSource::ADPCM: |
| 76 |
name = "ADPCM"; |
| 77 |
break; |
| 78 |
} |
| 79 |
return name; |
| 80 |
} |
| 81 |
|
| 82 |
std::vector<int> adaptVisibleTrackList(const std::vector<int> list, |
| 83 |
const SongType prevType, const SongType curType) |
| 84 |
{ |
| 85 |
if (prevType == curType) return list; |
| 86 |
|
| 87 |
std::vector<int> tracks; |
| 88 |
if (prevType == SongType::Standard) { |
| 89 |
for (const int& track : list) { |
| 90 |
switch (track) { |
| 91 |
case 0: |
| 92 |
case 1: |
| 93 |
tracks.push_back(track); |
| 94 |
break; |
| 95 |
case 2: |
| 96 |
{ |
| 97 |
std::vector<int> tmp { 2, 3, 4, 5 }; |
| 98 |
std::copy(tmp.begin(), tmp.end(), std::back_inserter(tracks)); |
| 99 |
break; |
| 100 |
} |
| 101 |
default: |
| 102 |
tracks.push_back(track + 3); |
| 103 |
break; |
| 104 |
} |
| 105 |
} |
| 106 |
} |
| 107 |
else { // FM3chExpanded |
| 108 |
bool hasPushed3 = false; |
| 109 |
for (const int& track : list) { |
| 110 |
switch (track) { |
| 111 |
case 0: |
| 112 |
case 1: |
| 113 |
tracks.push_back(track); |
| 114 |
break; |
| 115 |
case 2: |
| 116 |
case 3: |
| 117 |
case 4: |
| 118 |
case 5: |
| 119 |
if (!hasPushed3) { |
| 120 |
tracks.push_back(2); |
| 121 |
hasPushed3 = true; |
| 122 |
} |
| 123 |
break; |
| 124 |
default: |
| 125 |
tracks.push_back(track - 3); |
| 126 |
break; |
| 127 |
} |
| 128 |
} |
| 129 |
} |
| 130 |
return tracks; |
| 131 |
} |
| 132 |
} |