| 1 |
/* |
| 2 |
* Copyright (C) 2018-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 |
#pragma once |
| 27 |
|
| 28 |
#include <vector> |
| 29 |
#include <set> |
| 30 |
#include <unordered_map> |
| 31 |
#include "pattern.hpp" |
| 32 |
#include "bamboo_tracker_defs.hpp" |
| 33 |
|
| 34 |
struct TrackAttribute |
| 35 |
{ |
| 36 |
int number; |
| 37 |
SoundSource source; |
| 38 |
int channelInSource; |
| 39 |
}; |
| 40 |
|
| 41 |
struct OrderInfo |
| 42 |
{ |
| 43 |
TrackAttribute trackAttribute; |
| 44 |
int order; |
| 45 |
int patten; |
| 46 |
}; |
| 47 |
|
| 48 |
class Track |
| 49 |
{ |
| 50 |
public: |
| 51 |
Track(int number, SoundSource source, int channelInSource, int defPattenSize); |
| 52 |
|
| 53 |
void setAttribute(int number, SoundSource source, int channelInSource) noexcept; |
| 54 |
TrackAttribute getAttribute() const noexcept { return attrib_; } |
| 55 |
OrderInfo getOrderInfo(int order) const; |
| 56 |
size_t getOrderSize() const; |
| 57 |
bool canAddNewOrder() const; |
| 58 |
Pattern& getPattern(int num); |
| 59 |
Pattern& getPatternFromOrderNumber(int num); |
| 60 |
int searchFirstUneditedUnusedPattern() const; |
| 61 |
int clonePattern(int num); |
| 62 |
std::vector<int> getEditedPatternIndices() const; |
| 63 |
std::set<int> getRegisteredInstruments() const; |
| 64 |
|
| 65 |
void registerPatternToOrder(int order, int pattern); |
| 66 |
void insertOrderBelow(int order); |
| 67 |
void deleteOrder(int order); |
| 68 |
void swapOrder(int a, int b); |
| 69 |
|
| 70 |
void changeDefaultPatternSize(size_t size); |
| 71 |
|
| 72 |
void setEffectDisplayWidth(size_t w) noexcept { effetDisplayWidth_ = w; } |
| 73 |
size_t getEffectDisplayWidth() const noexcept { return effetDisplayWidth_; } |
| 74 |
|
| 75 |
void setVisibility(bool visible) noexcept { visibility_ = visible; } |
| 76 |
bool isVisible() const noexcept { return visibility_; } |
| 77 |
|
| 78 |
void clearUnusedPatterns(); |
| 79 |
void replaceDuplicateInstrumentsInPatterns(const std::unordered_map<int, int>& map); |
| 80 |
|
| 81 |
void transpose(int semitones, const std::vector<int>& excludeInsts); |
| 82 |
|
| 83 |
private: |
| 84 |
TrackAttribute attrib_; |
| 85 |
|
| 86 |
std::vector<int> order_; |
| 87 |
std::vector<Pattern> patterns_; |
| 88 |
size_t effetDisplayWidth_; |
| 89 |
bool visibility_; |
| 90 |
}; |