| 1 |
/* |
| 2 |
* Copyright (C) 2018-2020 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 <string> |
| 31 |
#include <unordered_map> |
| 32 |
#include "song.hpp" |
| 33 |
|
| 34 |
using Groove = std::vector<int>; |
| 35 |
|
| 36 |
enum class MixerType : int |
| 37 |
{ |
| 38 |
UNSPECIFIED = 0, |
| 39 |
CUSTOM = 1, |
| 40 |
PC_9821_PC_9801_86 = 2, |
| 41 |
PC_9821_SPEAK_BOARD = 3, |
| 42 |
PC_8801_VA2 = 4, |
| 43 |
PC_8801_MKII_SR = 5 |
| 44 |
}; |
| 45 |
|
| 46 |
class Module |
| 47 |
{ |
| 48 |
public: |
| 49 |
Module(const std::string& filePath = "", const std::string& title = u8"", |
| 50 |
const std::string& author = u8"", const std::string& copyright = u8"", |
| 51 |
const std::string& comment = u8"", unsigned int tickFreq = 60); |
| 52 |
|
| 53 |
inline void setFilePath(const std::string& path) { filePath_ = path; } |
| 54 |
std::string getFilePath() const noexcept { return filePath_; }; |
| 55 |
inline void setTitle(const std::string& title) { title_ = title; } |
| 56 |
inline std::string getTitle() const noexcept { return title_; } |
| 57 |
inline void setAuthor(const std::string& author) { author_ = author; } |
| 58 |
inline std::string getAuthor() const noexcept { return author_; } |
| 59 |
inline void setCopyright(const std::string& copyright) { copyright_ = copyright; } |
| 60 |
inline std::string getCopyright() const noexcept { return copyright_; } |
| 61 |
inline void setComment(const std::string& comment) { comment_ = comment; } |
| 62 |
inline std::string getComment() const noexcept { return comment_; } |
| 63 |
inline void setTickFrequency(unsigned int freq) { tickFreq_ = freq; } |
| 64 |
inline unsigned int getTickFrequency() const noexcept { return tickFreq_; } |
| 65 |
inline void setStepHighlight1Distance(size_t dist) { stepHl1Dist_ = dist; } |
| 66 |
inline size_t getStepHighlight1Distance() const noexcept { return stepHl1Dist_; } |
| 67 |
inline void setStepHighlight2Distance(size_t dist) { stepHl2Dist_ = dist; } |
| 68 |
inline size_t getStepHighlight2Distance() const noexcept { return stepHl2Dist_; } |
| 69 |
size_t getSongCount() const; |
| 70 |
size_t getGrooveCount() const; |
| 71 |
inline void setMixerType(MixerType type) { mixType_ = type; } |
| 72 |
inline MixerType getMixerType() const noexcept { return mixType_; } |
| 73 |
inline void setCustomMixerFMLevel(double level) { customLevelFM_ = level; } |
| 74 |
inline double getCustomMixerFMLevel() const noexcept { return customLevelFM_; } |
| 75 |
inline void setCustomMixerSSGLevel(double level) { customLevelSSG_ = level; } |
| 76 |
inline double getCustomMixerSSGLevel() const noexcept { return customLevelSSG_; } |
| 77 |
|
| 78 |
void addSong(SongType songType, const std::string& title); |
| 79 |
void addSong(int n, SongType songType, const std::string& title, bool isUsedTempo, |
| 80 |
int tempo, int groove, int speed, size_t defaultPatternSize); |
| 81 |
void sortSongs(const std::vector<int>& numbers); |
| 82 |
Song& getSong(int num); |
| 83 |
|
| 84 |
void addGroove(); |
| 85 |
void removeGroove(int num); |
| 86 |
void setGroove(int num, const std::vector<int>& seq); |
| 87 |
void setGrooves(const std::vector<std::vector<int>>& seqs); |
| 88 |
Groove getGroove(int num) const; |
| 89 |
|
| 90 |
std::set<int> getRegisterdInstruments() const; |
| 91 |
|
| 92 |
void clearUnusedPatterns(); |
| 93 |
void replaceDuplicateInstrumentsInPatterns(const std::unordered_map<int, int>& map); |
| 94 |
|
| 95 |
private: |
| 96 |
std::string filePath_; |
| 97 |
std::string title_; |
| 98 |
std::string author_; |
| 99 |
std::string copyright_; |
| 100 |
std::string comment_; |
| 101 |
unsigned int tickFreq_; |
| 102 |
size_t stepHl1Dist_, stepHl2Dist_; |
| 103 |
std::vector<Song> songs_; |
| 104 |
std::vector<Groove> grooves_; |
| 105 |
MixerType mixType_; |
| 106 |
double customLevelFM_, customLevelSSG_; |
| 107 |
}; |