Debian Codegraph @

BambooTracker/instrument/envelope_fm.hpp

raw
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 <unordered_map>
29 #include <bitset>
30 #include <memory>
31 #include "abstract_instrument_property.hpp"
32 #include "enum_hash.hpp"
33
34 enum class FMEnvelopeParameter
35 {
36 AL, FB,
37 AR1, DR1, SR1, RR1, SL1, TL1, KS1, ML1, DT1,
38 AR2, DR2, SR2, RR2, SL2, TL2, KS2, ML2, DT2,
39 AR3, DR3, SR3, RR3, SL3, TL3, KS3, ML3, DT3,
40 AR4, DR4, SR4, RR4, SL4, TL4, KS4, ML4, DT4,
41 SSGEG1, SSGEG2, SSGEG3, SSGEG4
42 };
43
44 class EnvelopeFM final : public AbstractInstrumentProperty
45 {
46 public:
47 explicit EnvelopeFM(int num);
48
49 friend bool operator==(const EnvelopeFM& a, const EnvelopeFM& b)
50 {
51 return (a.params_ == b.params_ && a.isEnabledOp_ == b.isEnabledOp_);
52 }
53 friend bool operator!=(const EnvelopeFM& a, const EnvelopeFM& b) { return !(a == b); }
54
55 std::unique_ptr<EnvelopeFM> clone();
56
57 bool getOperatorEnabled(int num) const;
58 void setOperatorEnabled(int num, bool enabled);
59
60 int getParameterValue(FMEnvelopeParameter param) const;
61 void setParameterValue(FMEnvelopeParameter param, int value);
62
63 bool isEdited() const override;
64 void clearParameters() override;
65
66 private:
67 std::unordered_map<FMEnvelopeParameter, int> params_;
68 std::bitset<4> isEnabledOp_;
69 };