Debian Codegraph @

BambooTracker/instrument/effect_iterator.hpp

raw
1 /*
2 * Copyright (C) 2018-2022 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 #include <vector>
28 #include "sequence_iterator_interface.hpp"
29 #include "sequence_property.hpp"
30
31 class ArpeggioEffectIterator : public SequenceIteratorInterface<InstrumentSequenceBaseUnit>
32 {
33 public:
34 ArpeggioEffectIterator(int second, int third);
35 SequenceType type() const noexcept override { return SequenceType::AbsoluteSequence; }
36
37 InstrumentSequenceBaseUnit data() const noexcept override;
38
39 int next() override;
40 int front() override;
41 inline int release() override { return next(); }
42 int end() override;
43
44 private:
45 InstrumentSequenceBaseUnit second_, third_;
46 };
47
48 class WavingEffectIterator : public SequenceIteratorInterface<InstrumentSequenceBaseUnit>
49 {
50 public:
51 WavingEffectIterator(int period, int depth);
52 SequenceType type() const noexcept override { return SequenceType::AbsoluteSequence; }
53
54 InstrumentSequenceBaseUnit data() const override;
55
56 int next() override;
57 int front() override;
58 inline int release() override { return next(); }
59 int end() override;
60
61 private:
62 std::vector<InstrumentSequenceBaseUnit> seq_;
63 };
64
65 class NoteSlideEffectIterator : public SequenceIteratorInterface<InstrumentSequenceBaseUnit>
66 {
67 public:
68 NoteSlideEffectIterator(int speed, int semitone);
69 SequenceType type() const noexcept override { return SequenceType::AbsoluteSequence; }
70
71 InstrumentSequenceBaseUnit data() const override;
72
73 int next() override;
74 int front() override;
75 inline int release() override { return next(); }
76 int end() override;
77
78 private:
79 std::vector<InstrumentSequenceBaseUnit> seq_;
80 };
81
82 class XVolumeSlideEffectIterator : public SequenceIteratorInterface<InstrumentSequenceBaseUnit>
83 {
84 public:
85 XVolumeSlideEffectIterator(int factor, int cycleCount);
86 SequenceType type() const noexcept override { return SequenceType::AbsoluteSequence; }
87
88 InstrumentSequenceBaseUnit data() const noexcept override;
89
90 int next() override; // Use next() instead of front() and release()
91 int front() override;
92 inline int release() override { return next(); }
93 int end() override;
94
95 private:
96 int mem_, sum_;
97 int factor_;
98 int cycleCount_;
99 };